Developers
Kate linter plugin
Thursday, 15 January 2009
| Milian Wolff
Just a quicky: I wrote a little plugin for KTextEditor which supplies you with basic error checking when you save documents. Currently only PHP (via php <span class="re5">-l</span>) and JavaScript (via JavaScript Lint) are supported. Screenshots PHP error list of errors Requirements usual tools for compiling C++, e.g. gcc. cmake Qt development packages, i.e. under Ubuntu: <span class="kw2">sudo</span> <span class="kw2">aptitude</span> <span class="kw2">install</span> libqt4-dev KDE 4.2 with development packages for kdelibs and kdebase, i.e. under Ubuntu: <span class="kw2">sudo</span> <span class="kw2">aptitude</span> <span class="kw2">install</span> kdebase-dev kdebase-workspace-dev kdelibs5-dev. Note: You’ll need the experimental KDE 4.2 packages activated as of now, see for example the Kubuntu news on KDE 4.2 RC1 for hints. proper setup of environment variables, read this techbase article for more information. the .bashrc linked there should be enough for most people For PHP support: a PHP executable which supports the -l switch for linting For JavaScript support: a JavaScript Lint executable, you could download and compile the sources for example. Installing Get the sources for the linter plugin from KDE SVN and compile it, using e.g. the functions supplied via the .bashrc mentioned above:
Read More
Kate Internals: The Undo/Redo System
Friday, 14 November 2008
| Dominik Haumann
The Kate Editor Component (also called KatePart) has its own undo/redo system. It did not change much since KDE2 and basically it is very simple. Meanwhile there are classes for undo/redo support in Qt as well. In fact both systems are very similar. This article focuses on Kate Part’s system.
Text Operations
First we have to take a look at what actions need to be saved. In Kate Part this basically comes down to
Read More
Encapsulation is not Information Hiding
Friday, 21 December 2007
| Dominik Haumann
As food for thought and in reply to Why Encapsulation is a Good Thing it’s interesting to take a closer look. What does encapsulation mean exactly, and what can you do with it? Maybe what you really want is Information Hiding? …and encapsulation is just a way of possibly achieving it? If you are interested in the details/differences, read the article Encapsulation is not Information Hiding.
Memory Leak Continued
Thursday, 22 November 2007
| Dominik Haumann
There was some confusion with regard to my last blog about leaking memory. Suppose the ui_mywidget.h files looks like this:
class Ui_Widget { public: QGridLayout *gridLayout; QGroupBox *groupBox; QGridLayout *gridLayout1; QListWidget *listWidget; QSpacerItem *spacerItem; QPushButton *pushButton; void setupUi(QWidget *Widget); void retranslateUi(QWidget *Widget); }; Of course, those 6 QObject derived classes are deleted. But the sizeof(Ui_Widget) = 6 * sizeof(void*) = 24 bytes are not deleted. As Ui_Widget is not QObject derived those 24 bytes leak. Confirmed by valgrind.
Read More
Memory leak: Ui files and direct approach
Wednesday, 21 November 2007
| Dominik Haumann
The KDE codebase often uses a forward declaration in the .h-file to speedup compilation. The code often looks like this:
// header file namespace Ui { class MyWidget; } class MyDialog : public KDialog { // ... private: Ui::MyWidget *ui; }; The impl looks like this:
// source file #include "mydialog.h" #include "ui_mywidget.h" MyDialog::MyDialog() : KDialog() { QWidget *w = new QWidget(this); setMainWidget(w); ui = new Ui::MyWidget(); // allocation ui->setupUi(w); // ui->... } See the memory leak? You have to call »delete ui;« in the destructor if you use the »direct approach«. Searching in lxr.kde.org shows lots of results, and in some places this delete is missing indeed. Happy fixing :)
Read More
Kate Scripting: Indentation
Wednesday, 18 July 2007
| Dominik Haumann
Kate Part in KDE4 supports the ECMAScript (JavaScript) language by using kjs. In KDE3 we had several hard-coded indenters in C++, the idea is to let scripts do all the indentation in KDE4.
How does it work? It is similar to vim: You simply create a script in the directory $KDEDIR/share/apps/katepart/jscript. An indentation script has to follow several rules:
it must have a valid script header (the first line must include the string kate-script and indentation scripts must have the type: indentation) it must define some variables and functions Whenever the user types a character, the flow in Kate Part works like this
Read More
Writing a Kate Plugin
Tuesday, 6 January 2004
| Christoph Cullmann
Warning
This is an outdated tutorial and is only kept here for historical reasons. For an up-to-date version of the tutorial please check https://develop.kde.org/docs/apps/kate/plugin/ Introduction First at all, why writing plugins for an editor ? Good question, and I hope I have a good answer: Because we want Kate to be small and all extended features not all users need should go into plugins (like CVS suppport, project managment, coffee cooking ;) Therefore Kate provides a quite full-featured plugin interface and interfaces to all important stuff in the Kate application (the documents, views, windows, sidebar …).
Read More