All posts by Christoph Cullmann

Dr.-Ing. Christoph Cullmann is a Senior Software Engineer at AbsInt Angewandte Informatik GmbH. His work is focused on static analysis of both binary and source programs and the WCET analysis of embedded systems. In his spare time, he works on the KDE project and maintains the Kate editor application and component.

Kate Developer Sprint 2008 Results

The below notes is what was decided at the development sprint in Darmstadt on April 11-13, 2008

Short term goals

  1. Scripting, part level QtScript
  2. API for indentation scripts
  3. Sessions handling
  4. make text completion work!
  5. VI-Modes (GSoC-project)

Long term goals

  1. Scripting at application level (Kate): Kross
  2. Combination of highlightings & indentations

Table of Contents

  • Scripting
  • Indentation
  • Kate Sessions
  • Extending the highlighting system (Highlighting combination)
  • Collaborative editing
  • Text input modes (vi mode)
  • Minor topics: Search & Replace, text completion
  • Interface Review
  • Simplifying KWrite

Scripting

  • Use cases
    • indentation
    • helper scripts + assign shortcut
    • useful for vi-mode scripting
  • right now: kjs (barely documented, future uncertain)
  • choices: Kross, QtScript
    • Kross: language independent, depends on available bindings/plugins at runtime
    • QtScript, Kross: simply wrap QObjects (signals/slots, Q_SCRIPTABLE automatically exported)

Kate Part: QtScript

  • flexible integration possible
  • make it fast for specific use cases (e.g. indentation)
  • script header
    • meta information: key/value pairs (type, name, mimetype, wildcard, …)
    • contact i18n people: how to do translation
    • translation possible outside KDE?

Kate App

  • Kross

Indentation

  • allow multiple indenters for documents with mixed languages (e.g. php and html)
    • document variables: e.g. indent-mode [ ];
    • document variables: allow different settings (indent-width, …)
  • remove option “Default Indenter”, it does not make sense (really?)
  • the script header should state which hl-modes it can indent (instead of mimetype/wildcard in the header)

Auto-completion:

  • build word completion plugin into kate part by default
  • fix implementation to actually complete stuff
  • simplfy the popupmenu (!), just as in KDE3
  • remove code completion config dialog, this must be implemented in the code completion model, as this is not applicable to any other than the cpp model. Better have something tiny working instead of a broken monster

Kate Sessions (profiles)

  • data stored:
    • application plugin config
    • file list (opened files)
    • window configuration
    • editor component config
    • ktexteditor plugin config (maybe kpluginselector problems)
  • session level configuration / document variables
  • kill default.katesession file, always use katerc
  • do not show the session chooser at startup, instead, make a good default (katerc)
  • clone session: “save as” opens a small dialog with line edit and options like window config, file list
  • remove option “restore view config” -> simply always do it
  • make sure kate part plugins can save data to sessions: fork kpluginselector, if necessary :)

Highlighting

  • extend highlighting system to allow combined highlighting
    • add e.g. “entercontext” rules
    • separate highlighting loader from hightlight class

Explanation: The purpose of this is to combine template languages such as PHP, EmbPerl, Mason etc with any other syntax highlighting on the fly, as opposed to the current practice which requires a combined set of files to be generated at build time. This is only done for the HTML + PHP combination, so with the new way a multitude of combination becomes available. In addition to that, nothing needs to be regenerated when a highlight is updated, makeing it much easier for users to keep their highlightings updated.

Highlighting / Modes

  • when opening the config page choose the current used entries (highlight and mode) in the combo box, so that it is immediately clear to the user which mode/hl is active
    • “Fonts & Colors” > Highlight Text Styles
    • “Open/Save” > Modes & Filetypes
    • -> implement in kate part internally: simply track an active view (the last that got focus)

Collaborative Editing

  • example: gobby
  • as KTextEditor plugin?
    • probably not completely possible right now, missing internal access
  • Decibel (realtime communication protocol)
    • move communication framework into separate process and use dbus interfaces
  • implementation postponed

Input modes (vi mode)

  • background: yzis
    • rewrite from scratch
    • idea of abstracting away “everything” to be flexible (e.g. to support different front ends)
    • development stalled 2 years ago
  • right now in kate part
    • command line already similar to vim’s “input mode”
    • keep this mode + extend, if needed
  • idea: integrate into kate part: extend/refactor kate to support input modes
    • make code reusable (in other modes)
    • extend KTE::Commands to support ranges (e.g. <1,10>)
    • add “normal mode”

Search & Replace

  • bar has big minimum width, works bad in split view
  • make it possible to embed widgets in the host application (KTE extension?)
  • search & replace over multiple buffers

Interfaces

  • Rule of thumb: Introduce interfaces only if usecase is known and best thing is always to have an implementation ready to get out the bugs before binary compatibility issues count

Annotation Interfaces

  • derive AnnotationViewInterface from AnnotationInterface
  • —> allow for KTE::Document and KTE::View
  • merge header files into one

Spellchecking Interface / Viewport Interface

  • both aim to support Kile doing spellcheck
  • conclusions
    • spellcheck should be first integrated in katepart
    • on-the-fly spellcheck support
    • highlighting should feed info which parts are able to be spellchecked (extend highlighting system)
    • after this is done, an interface can be invented to help Kile to enrich the spellcheck with meta-info like languages, additional spellcheckable ranges, …

Message Interface

  • implement a way to show messages in a non-intrusive way in the view bar
  • avoid message boxes by using it, this won’t influence the workflow!
  • allow quering the user (buttons like OK, Yes, No, i.e. KMessageBox-like)
  • multiple messages should be queued (or stacked?)
  • allow both implementation in the part for messages per view and a fallback provided by the application for messages when no view is available

Load/Save Filter Interfaces

  • preprocessing/postprocessing of text streamed from/to file
  • checking of input/output, warning, error, …
  • allow lazy loading, using .desktop files to describe mime-type + wildcards
  • allow to trigger usage of the plugins via document vars or mode config
  • default: not allow any plugin, user must allow them (!)

KWrite: should be more simple

  • extend the kate part to allow blacklist/whitelist highlightings/plugins
  • remove some advanced actions from ui file, provide simple mode, dummy mode
  • remove hl
  • remove folding option
  • remove bookmarks (menu, settings)
  • remove modus
  • remove almost all of extras
  • all in all: strip down to make it usable for the average user

Kate Developer Sprint 2008

In April there will be a Kate Developer Sprint, similar to previous sprints for Decibel, Akonadi, KDevelop and others. This is a great opportunity as developers interested in development of KDE’s text editor will discuss what to do to make Kate the best text editor on earth. This also means lots of polishing so that Kate in KDE 4.1 will shine even more! The meeting will take place from 2008-04-11 till 2008-04-13. The location is hosted by basysKom in Darmstadt, Germany. Many thanks goes especially to the KDE e.V. for their financial support. If you are interested in Kate development, join our mailing list. More to come, stay tuned!

The event is organized by Dominik Haumann, and is supported by the kde.ev.

On the agenda is discussing Kates future development and improving scripting capabilities amongst others.

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.