Developers
Kate linter plugin
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
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:
Kate Internals: The Undo/Redo System
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 MoreEncapsulation is not Information Hiding
Memory Leak Continued
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); };</pr
Read More
Memory leak: Ui files and direct approach
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->... }Read More
Kate Scripting: Indentation
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 MoreWriting a Kate Plugin
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