Bug Hunting – Please help poor Kate ;)

The Kate/KDevelop sprint in Vienna was a really productive time.

Thanks to Joseph Wenninger for organizing it and the KDE e.V. for the additional funding!

The Kate team was able to really wade through a lot of bugs & wishes and fix/invalidate a lot of them.

After some more days of work, this really is visible in our nice bug chart ;)

Kate, KatePart & KWrite are now down to a bug level as low as years ago ;)

Still, there is a lot to do.

If you have some spare time and Qt/KDE knowledge, please help us to have an even better KDE 4.10 release and look at the remaining bugs.

We have the following ~60 bugs and ~330 wishes still around. They vary from small stuff to “a lot” of work. If you want to help out, just pick the bug you want to work on and assign it ;)

Default Color Schemas

With KDE 4.10, the naming of the color schemas in Kate Part changed. Instead of having “<app name> – Normal” and “<app name> – Printing” we now just have “Normal” and “Printing,” meaning that all applications using Kate Part now share these color schemas. In other words: If you change the Normal schema in KDevelop, you also will see these changes in Kile, Kate, or any other application that embeds Kate Part. If you just want to change the color schema for a single application, create a new color schema and then use this new schema as default!

Besides that, it’s been a looong way, but finally Kate will ship several default color schemas in KDE 4.10:

Normal Color Schema

Vim (dark)

The colors are not all perfect, so we hope to improve them over time, so if you always wanted to contribute to Kate, we could need help here :-)

Kate Scripting Updates & Zen-like Quick Coding

In KDE >= 4.10, Kate Part’s scripting changed a bit. The changes are already documented in the Kate handbook, but we’ll quickly have a look into it now anyway.

Prior to KDE SC 4.10, scripts in Kate Part always had to contain the “type” in the scripting header, like indentation or command. This was changed to simply using different folders (system wide or in your $HOME kde folder) as follows:

  • indenters are located in share/apps/katepart/script/indentation
  • commands are located in share/apps/katepart/script/commands
  • api is located in share/apps/katepart/script/libraries

Further, the API is not loaded automatically anymore. Instead, we introduced the function require(“file.js”), which takes one argument. For instance, if you want to use the Cursor and Range API, you just write


In this example, it would even suffice to just write require(“range.js”); since range.js itself contains the line require(“cursor.js”); Kate Part tracks, which files are already included through require, so you don’t have to worry about include guards like in C/C++.

Now as we are able to just load the libraries that we really need, we can add as many libraries as wanted. For instance, the author of zen-coding wrote a thin wrapper to make all the zen-coding goodies available to Kate Part. It’s included in the emmet subfolder in the script/libraries folder. So if you need this stuff, you just write require(“emmet/desired-file.js”);

It’s a bit unfortunate that we still break how the scripting works from time to time, but it’s better to fix and improve the scripting instead of living with limited capabilities. So if you have own scripts, it’s the best time to contribute them to Kate!

Generic Quick Coding Features

Further, we have some new command line script called quickcoding.js that already uses the zen-coding idea: If you for instance write


and press Ctrl+Alt+# in C++ files (the Mode must be C++!), it will automatically expand to

 * Class Test
class Test : public Parent
     * Constructor of Test
    Test ();

     * Destructor of Test
    ~Test ();

So how does it work? Since the file mode is C++, the quick coding command will read files from katepart/script/files/quickcoding/cpp/. The first character of this cryptic string is ‘c’, which tells the quick coding command to look into c.template. This template now expands according to the specified arguments: n:Test sets the class name to Test, and the optional p:Parent derives Test from Parent.

This is just a proof of concept, and you can do the same with Text Snippts in Kate. But still, this is another way adding support for quick coding for arbitrary languges, and the implementation is completely in JavaScript, so it is rather easy to extend and customize it to your needs. We’ll probably extend/change this feature a bit more over time, let’s see :-) It’s also not yet documented in the Kate Handbook. We’ll probably add ‘official’ documentation for this in later Kate releases. Happy coding!

Passive Notifications in Kate Part

In KDE 4.10, Kate Part got a new MessageInterface. The idea of this interface is to have a standardized way of showing notifications in a non-intrusive way, similar to how KMessageWidget in kdelibs works. Using the MessageInterface is extremly easy, for instance to show a quick notification, you write

KTextEditor::Message *message = new KTextEditor::Message(KTextEditor::Message::Positive,
                                                         "Code successfully reformated.");

That’s basically it! The result looks like this (with a nice fade-in and fade-out animation):

As developer, once you called postMessage(), you can safely forget the message pointer. It’s automatically deleted either if the user closes the notification, or if the document is closed or reloaded. The API for more tricks. You can add multiple actions through KTextEditor::Message::addAction(), which then appear as buttons. For each added action, you can control whether triggering the action should close the widget or not.

Further, you can set an auto hide timer through Message::setAutoHide(int timeInMilliSeconds).

If you want a message to only appear in one specific KTextEditor::View of the Document, you just call Message::setView() before calling postMessage(). If several messages are in the queue, the one with the highest Message::priority() is shown first.

This notification system is already used in Kate Part by the data recovery (swap files), or to show a notification when loading remote files, and in some other places.

The cool thin is that this solution requires no special code in KateView or other classes, hence, it’s a perfectly clean solution with an easy-to-use API. You as KTextEditor user (developer) should definitely consider using it when it’s public.

Note: The MessageInterface is a KTextEditor interface; however, since the 4.10 branch is frozen for BIC changes, we cannot just add this interface for KDE 4.10. Instead, for Kate Part users (Kile, KDevelop, …) this interface will only be available in KDE5.

Finally, an example of all four message types: Positive, Information, Warning and Error: