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 and KTextEditor 5 after Akademy 2014

The yearly KDE conference Akademy just ended, so it’s time to look at what changed in the holy Kate in the Frameworks 5 land.

KTextEditor Framework

  • silent reload of document: Switching a git branch, Kate always pops up a dialog asking whether to reload the document. With this patch, if the document is version controlled by git, the git hash of the file computed and then it’s checked whether the file exists in git. If so, the file is reloaded without asking you. This should be very handy for developers using git! Thanks to Sven Brauch for this idea!
  • new highlighting unit testing infrastructure
  • several new syntax highlighting files
  • cursor down in the last line in the document moves the cursor to the end of the line, same for the cursor up behavior, after just 8 years a bugzilla wish becomes true ;)
  • properly load/save the search & replace history
  • fix kateversion tags in all our >200 highlighting files, thanks to Martin Walch
  • as always: lots of improvements to the vi input mode

Kate Application

  • use native dialogs on all platforms, including OS X, Windows
  • split view: action to toggle splitter orientation
  • the toolbar is by default turned off (see screenshot), resulting in a very cleaned up interface. You can turn it on in the Settings menu.
  • new document switcher plugin (see screenshot) through Ctrl+Tab, providing quick access to the most recently used documents (similar to Alt+Tab in kwin), based on KDevelops code
  • improvements to the tab bar
  • revive, cleanup and improve the text snippet plugin by Sven Brauch
  • projects plugin: autoload project even if no .kateproject is found (configurable to not clash with the auto-generated cmake .kateproject file), implemented by Michal Humpula
  • the Plasma 5 applet to start a Kate session is back, thanks to the work of Josef Wenninger

Kate Document Switcher

A big thanks to the organizers of this year’s Akademy, and a big thanks to all our sponsors and supporting members. The location was amazing and the venue allowed us all to have a very productive week! Looking forward to next year! :-)

Links about C++ and Programming

Just like some time ago, here are several links that might be of interest:

Kate Part (KF5): New Default Styles for better Color Schemes

Kate Part gained 17 new default styles in addition to the existing 14 default styles. These changes are available for Kate based on the KDE frameworks 5 initiative and currently live in ktexteditor.git module.

Default Styles are predefined font and color styles that are used by Kate Part’s syntax highlighting. For instance, Kate Part always had a default style for comments. Therewith, the comments in all syntax highlighting files look the same (by default, a gray color). Or keywords are by default always bold and black.

However, during the last years it became apparent that the list of 14 default styles were not always enough. Consequently, lots of syntax highlighting files defined their own hard-coded colors. For instance, doxygen comments were hard-coded in a dark blue color. The problem with hard-coded colors is that they do not adapt when changing the default styles. Hence, doxygen comments were barely readable on a dark color scheme.

Therefore, a discussion took place on kwrite-devel (thread 1, thread 2, thread 3) that ended in 17 new default styles and a categorization of these as follows (the new default styles are bold):

Category “Normal Text and Source Code

  • dsNormal: default for normal text and source code.
  • dsKeyword: Used for language keywords.
  • dsFunction: Used for function definitions and function calls.
  • dsVariable: Used for variables, if applicable. Example: $foo in PHP.
  • dsControlFlow: Used for control flow highlighting, e.g., if, then, else, return, continue.
  • dsOperator: Used for operators such as +, -, *, / and :: etc.
  • dsBuiltIn: Used for built-in language classes and functions, if applicable.
  • dsExtension: Used for extensions, such as Qt or boost.
  • dsPreprocessor: Used for preprocessor statements.
  • dsAttribute: Used for attributes of functions or objects, e.g. @override in Java, or __declspec(…) and __attribute__((…))in C/C++.

Category “Strings & Characters

  • dsChar: Used for a single character.
  • dsSpecialChar: Used for an escaped character in strings, e.g. “hello\n”.
  • dsString: Default for strings.
  • dsVerbatimString: Used for verbatim strings such as HERE docs.
  • dsSpecialString: Used for special strings such as regular expressions in ECMAScript or LaTeX math mode.
  • dsImport: Used for includes, imports, modules, or LaTeX packages

Category “Numbers, Types & Constants

  • dsDataType: Used for data types such as int, char, float etc.
  • dsDecVal: Used for decimal values.
  • dsBaseN: Used for numbers with base other than 10.
  • dsFloat: Used for floating point numbers.
  • dsConstant: Used for language constants, e.g. True, False, None in Python or nullptr in C/C++.

Category “Comments & Documentation

  • dsComment: Used for normal comments.
  • dsDocumentation: Used for comments that reflect API documentation, e.g., the default style for /** */ comments.
  • dsAnnotation: Used for annotations in comments, e.g. @param in Doxygen or JavaDoc.
  • dsCommentVar: Used to refer to variables in a comment, e.g. after @param <identifier> in Doxygen or JavaDoc.
  • dsRegionMarker: Used for region markers, typically defined by BEGIN/END.
  • dsInformation: Used for information, e.g. the keyword @note in Doxygen.
  • dsWarning: Used for warnings, e.g. the keyword @warning in Doxygen.
  • dsAlert: Used for comment specials such as TODO and WARNING in comments.

Category “Miscellaneous

  • dsOthers: Used for attributes that do not match any of the other default styles.
  • dsError: Used to indicate wrong syntax.

Existing Syntax Highlighting Files

If the new default styles are not used, syntax highlighting files are backwards compatible to Kate Part in KDE SC 4. However, the plan is to use the new default styles where applicable to avoid hard-coded colors. To this end, the kateversion attribute in the language element will be set to 5.0 (yes, Kate Part’s version changed from 3 to 5 to match KDE frameworks 5) to avoid loading incompatible syntax highlighting xml files in older Kate Part versions. Example:

<language name="C++" kateversion="5.0" [other attributes omitted]>

With the new default styles, the Default Styles tab looks as follows:
Default Styles in KF5

 

In comparison, the KDE 4.x version looks like this:
Default Styles in KDE 4

 

The new default style colors are not fixed yet, so improvements and additional color themes we can ship with Kate Part by default are a welcome addition!

A Note at 3rd Party Developers

There are other implementations (such as in Qt Creator or for Haskell). If you developers read this, we encourage you to add these default styles as well once Kate Part 5 is released (stable). Otherwise, the new syntax highlighting files may not be compatible.