Kate Love: HighlightInterface, Autobrace

Well, I have to admit: I didn’t spent much time developing the PHP plugin for KDevelop these past weeks. Instead I hacked on Kate:

HighlightInterface

I added another Kate interface, this time to access some of the highlighting information:

  • what’s the Attribute for a given default style right now? Default styles are those known from syntax files, e.g. dsKeyword, dsFunction,…
  • what are used Attributes in a given line and what range do they occupy?
  • what modes do we embed? E.g. PHP embeds HTML, JavaScript, CSS, …
  • what mode is used at a given Cursor position?

This made it possible to port the “Export to HTML” action to a real plugin. If you come up with other output formats I might add them, I wondered about LaTeX support… might do this at some point.

This should also make it possible to use KatePart in other applications and than export the highlighting to a different format, e.g. a Flake shape for Koffice. Afaik this is actually planned by The_User - lets see if it works out!

The other stuff gives huge potential in various places, but I fear it won’t make it in KDE 4.4. But think of it:

  • simple code completion based on keyword databases, dependent on the mode at the position where completion was requested
  • same as above for snippets (actually this will make it to 4.4).
  • insert your ideas here :)
Auto-Brace plugin

Jakob Petsovits created this gem of a plugin some time ago, yet it lived in playground was probably only used by few. I imported it to kdelibs, hence it will be shipped with KDE 4.4. It supersedes the limited “auto-brackets” feature of Kate and only adds braces when a newline gets added. I find this fits my personal coding habits much better than blindly copying brackets when they get added.

And I don’t just copied to kdelibs, I also added a few features:

  • automatically add a semicolon after the closing brace when we start a new struct/class in C++ mode
  • check for auto-brackets feature and disable it automatically

Also did this:

  • don’t add brace when current line contains namespace and a following line starts with class or struct (C++ mode only)
  • don’t add brace when current line contains class, interface or struct and the following line contains private, public, protected. C++ code is also checked for signals, Q_SIGNALS", other modes are checked forfunction`.

This should fix the bug for code like (note the indendation levels):

  1. namespace foo { // insert line here
  2. class bar;
  3. }
  4. class asdf { // insert line here
  5. private:
  6. ...
  7. };

Kate Love: HighlightInterface, Autobrace

Well, I have to admit: I didn’t spent much time developing the PHP plugin for KDevelop these past weeks. Instead I hacked on Kate:

HighlightInterface

I added another Kate interface, this time to access some of the highlighting information:

  • what’s the Attribute for a given default style right now? Default styles are those known from syntax files, e.g. dsKeyword, dsFunction,…
  • what are used Attributes in a given line and what range do they occupy?
  • what modes do we embed? E.g. PHP embeds HTML, JavaScript, CSS, …
  • what mode is used at a given Cursor position?

This made it possible to port the “Export to HTML” action to a real plugin. If you come up with other output formats I might add them, I wondered about LaTeX support… might do this at some point.

This should also make it possible to use KatePart in other applications and than export the highlighting to a different format, e.g. a Flake shape for Koffice. Afaik this is actually planned by The_User - lets see if it works out!

The other stuff gives huge potential in various places, but I fear it won’t make it in KDE 4.4. But think of it:

  • simple code completion based on keyword databases, dependent on the mode at the position where completion was requested
  • same as above for snippets (actually this will make it to 4.4).
  • insert your ideas here :)
Auto-Brace plugin

Jakob Petsovits created this gem of a plugin some time ago, yet it lived in playground was probably only used by few. I imported it to kdelibs, hence it will be shipped with KDE 4.4. It supersedes the limited “auto-brackets” feature of Kate and only adds braces when a newline gets added. I find this fits my personal coding habits much better than blindly copying brackets when they get added.

And I don’t just copied to kdelibs, I also added a few features:

  • automatically add a semicolon after the closing brace when we start a new struct/class in C++ mode
  • check for auto-brackets feature and disable it automatically

Also did this:

  • don’t add brace when current line contains namespace and a following line starts with class or struct (C++ mode only)
  • don’t add brace when current line contains class, interface or struct and the following line contains private, public, protected. C++ code is also checked for signals, Q_SIGNALS", other modes are checked forfunction`.

This should fix the bug for code like (note the indendation levels):

  1. namespace foo { // insert line here
  2. class bar;
  3. }
  4. class asdf { // insert line here
  5. private:
  6. ...
  7. };

KDevelop & KWrite/Kate hacksprint 2010 in Berlin

Hey everybody!

If you are a KDevelop and/or Kate/Kwrite developer and do not read the mailing lists: There’s a hack sprint coming up in Berlin in 2010. I think there’ve been enough sprints in Berlin already so that you know it’s a great city for such an event. Though this time it won’t be at KDAB or Nokia offices, but at the Physics Faculty of the FU-Berlin. Since I (currently) work there as an IT admin, it was my first choice and worked out. I hope it will be a good location for the meeting. If you want to attend, vote on doodle:

http://www.doodle.com/vkyh9up9794zr4s8

But you probably also should register either on the KDevelop or KWrite mailing lists so I have some kind of way to contact you.

PS: in unrelated news I’ll do an internship at KDAB next year! yay

Scripting Kate

In my last blog I explained Kate’s scripting features in KDE 4.4. To better understand how scripting can be used let’s look at some use cases.

  • join lines: This feature request wants the action “join lines” to not join different paragraphs, i.e. not remove empty lines. We have not implemented this wish, as there are probably users who prefer the current behaviour. This request can be fixed by writing a small script that joins the lines according to the user’s wishes.
  • reformat paragraph: An intelligent reformatter for paragraphs. Should be rather straight forward to implement.
  • XML tools: In KDE3, Kate once had a xmltools plugin. Unfortunately noone ported it to KDE4. The plugin provided lots of very useful features for xml editing. For example, you could select text and then wrap it with xml elements, e.g. “text” would become “<para>text</para>”. This is a perfect example for a command line script as well. Any volunteers? :)

Scripting also brings us closer to fixing the following reports:

  • macro system: Kate still does not have a macro system. A macro can be interpreted as a group of scripts, executed in a sequence (more or less). The vi input mode already supports pretty complex commands, and the code for scripting is all there. It’s just a matter of putting this together so it’s usable for users.
  • word count: maybe the word count features can be implemented by a script (too slow?). Problem is, that a script cannot show dialogs etc.

To make scripting an even better experience, we still need to implement binding shortcuts to scripts. Again: any volunteers? :)