All posts by Dominik

Dominik is a PhD student at the Control Theory and Robotics Lab, TU Darmstadt, as part of the Research Training Group GKMM (GRK1362). My research focuses on state estimation in distributed systems. As hobby, I contribute to the KDE project and work on the Kate application and editor component.

Kate in KDE 4.6

Some days ago KDE 4.6 was branched. So what will Kate in KDE 4.6 bring?

  • The new tree view as “Documents” sidebar completely replaces the old file list. It supports the simple list mode as well as a pseudo-intelligent tree view to group files. The “Documents” tab is now implemented as plugin (always loaded), meaning that it brought a code cleanup as well. We hope you like it! :)
  • Swap file support, meaning that you can recover all your unsaved data for local files on the next Kate startup.
  • Ability to always load plugins.
  • New SQL Query plugin. The day we blogged about it had the most visits in the entire kate-editor.org history. So it seems the the SQL plugin is a really nice addon for web developers! :)
  • New GNU Debugger (GDB) Plugin!
  • New Highlight Selected Text Plugin.
  • Ability to add scripts to the menu and bind shortcuts.
  • Kate got a new homepage on http://www.kate-editor.org featuring WordPress.
  • Lots of bugs fixed since the KDE 4.5.0 release.
  • SmartCursors and SmartRanges are gone, resulting in more stable and clean code. MovingCursors and MovingRanges replace the old classes and work reliable. For instance, KDevelop is already ported leading to less crashes.
  • Christoph found the emails of the early days of Kate again. A funny read! :)
  • Daily unit test runs. We have more and more unit tests, securing the correct behavior of e.g. search&replace, the text buffer, encoding detection or indenters.
  • Kate development mostly moved to KDE’s git infrastructure, resulting in very easy build instructions.
  • The default settings of a session are now stored in the katerc file again, rendering the default.katesession obsolete. This means you will have to configure your default session again (sorry!). On the other hand, this fixed quite some bugs with regard to the session handling.

Credit where credit is due!

There were lots of developers involved who helped to improve Kate. Thanks a lot to every one of you! Without your contribution, Kate would not be what it is :-) Keep it up!

Highlight Selected Text

Kate has a new plugin called “Highlight Selection”. Since it is a KTextEditor plugin, it is available for all apps using KatePart (e.g.: Kile, Kate, KWrite, KDevelop etc). What does it do? If you select a whole word, all occurrences of this word are highlighted as well:

You can jump to the next occurrence with ctrl+h (btw: ctrl+h works already since KDE 4.2 or so). The plugin will be included in KDE 4.6. If you can’t wait, you can use it already now by building Kate from the sources.

(Side note: Be careful with enabling this plugin in KDevelop, since KDevelop itself is already doing extensive highlighting)

Recent Files Menu in Kate

As many other applications Kate has the menu File > Recent Files, which lists all files you recently used. This recent file list right now is per session, i.e., each session has its own entries listed as recent files. Now there is a request to change it such that there is just one single global recent file list. I think having two recent files menus (one for the session and one global) is a bad solution. Further, adding an option for that also sounds wrong.

To change or not to change, that’s the question?! :) What do you think?

Encoding Detection Revised

In recent KDE releases up to version 4.4 Kate unfortunately very often selected the wrong encoding. The result is that e.g. german umlauts (öäü) show up as cryptic signs in the text editor. What I’ve seen lots of times is that in this case people start to fix those characters manually for the entire document. In other words: They totally do not get at all that the text document simply was opened with the wrong encoding. In fact, the users usually do not even know what encoding is at all. While this is of course kind of sad, this certainly won’t change…

Given this fact, the only correct “fix” is a very good automatic encoding detection, such that the encoding is usually chosen correctly. In the rewrite of Kate’s text buffer for KDE 4.5, Christoph also rewrote the file loader including the encoding detection. The detection now works as follows:

  1. try selected encoding by the user (through the open-file-dialog or the console)
  2. try encoding detection (some intelligent trial & error method)
  3. use fallback encoding

In step 1, Kate tries to use the encoding specified in the open-file-dialog or the one given when launching Kate from the console. On success, we are done.

The encoding detection in step 2 first tries unicode encoding by looking for a Byte Order Mark (BOM). If found, it is certain that the text document is unicode encoded.  If there is no BOM, Kate next uses a tool from KDElibs (KEncodingProber) to detect the correct encoding. This is basically trial & error: Try encoding A, if there are characters in the document the encoding is not able to represent, try encoding B. Then C and so on… Unfortunately, this also doesn’t always work, because a byte sequence might be valid in several encodings and represent different characters. This is why it’s more or less impossible to get the encoding always right. There is simply no way…

If the encoding detection fails, Kate uses a fallback encoding. You can configure this fallback encoding in the editor component settings in the “Open/Save” category. If the fallback encoding fails as well, the document is marked as read-only and a warning is shown.

What about Kile and KDevelop?

One of the applications that heavily suffered of the wrong encoding detection in the past was the LaTeX editor Kile. The same holds probably for KDevelop (although it’s usually less critical with source code). The good news is, that with KDE >= 4.5 the problems with respect to wrong encoding should be gone. So it’s certainly worth to update if you are affected by this issue.