Triple clicks

Text editors and line edits support the so-called triple clicks according to [1]. The document says

  • Triple Click: Select the targeted row. [...]

It is unclear whether the “targeted row” includes the trailing linebreak. Kate Part selects the targeted line including the linebreak. You get the following behavior:

  • If you move the selected row with the mouse, you usually have the linebreaks right. The same applies for copy/cut & paste. If you are used to it, it really is a nice feature.

While this behavior is pretty straightforward, it is not widely in use. If you look at text edit widgets like in firefox, konqueror, Qt, KWord or OOo you will notice that they do not include the trailing newline character.

Question now is: Should we change it for KDE 4 in Kate Part just to be compliant with the others? As Kate Part is an editor component mainly used for programming, my favourite option is to include it, i.e. to keep the current behavior.

(update) I just stumbled over http://bugs.kde.org/show_bug.cgi?id=91041 =)

[1] http://developer.kde.org/documentation/standards/kde/style/mouse/selection.html

Kate Part in upcoming KDE 3.5.4

The last week was highly productive for Kate Part, as the following bugs were fixed:

  • 89042 while pressing “del” key kate crashes (crash, bt)
  • 103648 Codefolding Crash – Reproducable
  • 118584 scroll position not upgrading (dynamic word wrap)
  • 119435 kate crash when a file is saved
  • 123315 kwrite/kate crashes randomly after save
  • 124102 changing syntax highlighting when code is folded crashes katepart
  • 127928 kate crashes deleting a block of text
  • 128690 Dynamic word wrap makes text input slow
  • 129853 Horizontal scrollbar and view not synced, if dynamic and static word wrap are off
  • and some minor issues

That are 6 crash fixes. Kate Part in KDE 3.5.4 will be more stable than ever :) That’s especially cool for KDevelop, Quanta+, Kile – well and Kate.
Special thanks to Andreas Kling for initiating the bug squashing sessions! You are like a blackbox: The input is a bug and your output is the fix ;)

Kate Modes & Filetypes

Modes allow the user to override the default configuration for documents of specified mimetypes or file extensions. When the editor loads a document and the mimetype or file extensions match for one of the defined filetypes, KatePart will read the configuration from the mode and apply the modelines defined. If more filetypes match, the one with the highest priority will be used.

To create a filetype, go into the settings dialog available in Kate via Settings > Configure Kate > Open/Save > Modes/Filetypes, then press the New button and fill in the properties. To remove an existing filetype, select it from the dropdown list and press the Delete button. To edit an existing mode, select it from the dropdown list.

Some Available Properties

  • Name
    This is a user friendly name that will be displayed in the menu Tools > Mode.
  • Section
    A submenu of Tools > Mode in which to place this filetype. If the section does not already exist, it will automatically be created.
  • Variables
    This is where the actual configuration goes. Variables set here will overwrite the default configuration values. Be aware that this line must begin with kate: and end with a semicolon. For a full list of available variables refer to modelines.
  • File Extensions
    A semicolon separated list of filename globs used to determine if a document matches this filetype.
  • Mimetypes
    A semicolon separated list of mime types used to determine if a document matches this filetype.
  • Priority
    If a document matches several filetypes, the one with the highest priority will be chosen.

Example

As an example we will create a new mode configuration for C++ and Java files. It should use the C Style indenter and indent with 4 spaces (no tabs). The configuration could look like this:

Name: C++ and Java settings
Section: Sources
Variables: kate: space-indent on; indent-width 4; mixed-indent off; indent-mode cstyle;
File Extensions: *.cpp;*.java
Mimetypes: text/x-c++hdr;text/x-c++src;text/x-java
Priority: 10

.kateconfig Files

Kate allows you to specify local document variables by setting the corresponding modelines. The hidden file .kateconfig provides exactly the same functionality, but for all files in the directory.

Enable the Feature

To use a .kateconfig file you first have to enable the feature by invoking Settings > Configure Kate. In the config page Open/Save you can find the option Search depth for config file, which defaults to Do not use a config file. Change the value to an appropriate number,

  • 0 means look in the current folder
  • 1 means look in the current folder, and if there is no .kateconfig file, look in the parent folder
  • etc…

In short – Kate will search the number of given folder levels upwards for a .kateconfig file and load the settings from it.

Fill the .kateconfig File

The .kateconfig file simply contains modelines.

The following example will cause all documents to indent with 4 spaces with a tab width of 4. Tabs will be replaced during editing text and the end-of-line symbol is a linefeed (\n).

kate: space-indent on; tab-width 4; indent-width 4; replace-tabs on; eol unix;

Final Note

Right now it is not possible to specify different settings for different filetypes/mimetypes. We are aware of this problem and hope to provide a fix in near future, perhaps for KDE 4.