Akademy 2010 – Best experience so far

My first Akademy was the greatest thing I’ve ever experienced. I remember I was quite unsure a month ago, wheter to come or not, but finally decided and booked my flight and hotel. In my first day, I was very shy and didn’t know what to do, but people came and talked to me and everything got better. The talks had very interesting topics and the speakers did their job professionally. I also want to congratulate the organization team, for making everything happen as scheduled.

The BoFs at Demola were even more interesting. You go there, find a place to sit, and start hacking with many other KDE developers. I never did this before and it is simply amazing. You can’t believe the things that can come out from these hacking days/nights :).

I have never thought that KDE is such a great community, but now I am convinced. Akademy gave me a lot of confidence ( especially “Highlights on KDE Women” talk :P ) and now I really feel I can bring something to KDE. I am a little sad because I couldn’t attend the whole Akademy, but I think that more Akademies are to come :).

kate-editor.org shaping up

kate-editor.org now contains all articles from the old page still applicable to Kate in KDE 4 and in addition all blog entries of Dominik which are Kate centric.

Beside that it will aggregate the blog entries of Milian for Kate ;)

Still, a lot of work is needed. We already got an offer for help to beautify the page by a web designer, still content writers are missing. You have a nice short post about how to use Kate best? You have some howto? Just contact us or me in private. We can either give you an account on the page or just add your content if you like that more.

Kate: Scripted Actions

Finally, I came around to implement scripted actions for Kate in KDE SC 4.6. Let’s take a look at how this works. When Kate starts, it searches for $KDEDIRS/share/apps/katepart/script/ for *.js files. As example, let’s take a look at utils.js there:

/* kate-script
 * author: Dominik Haumann
 * license: LGPL
 * revision: 3
 * kate-version: 3.4
 * type: commands
 * functions: moveLinesDown
 */

function moveLinesDown()
{
  var fromLine = -1;
  var toLine = -1;

  var selectionRange = view.selection();
  if (selectionRange.isValid() &&
      selectionRange.end.line < document.lines() - 1)
  {
    toLine = selectionRange.start.line;
    fromLine = selectionRange.end.line + 1;
  } else if (view.cursorPosition().line < document.lines() - 1) {
    toLine = view.cursorPosition().line;
    fromLine = toLine + 1;
  }

  if (fromLine != -1 && toLine != -1) {
    var text = document.line(fromLine);

    document.editBegin();
    document.removeLine(fromLine);
    document.insertLine(toLine, text);
    document.editEnd();
  }
}

function action(cmd)
{
  var a = new Object();
  if (cmd == "moveLinesDown") {
    a.text = i18n("Move Lines Down");
    a.icon = "";
    a.category = "";
    a.interactive = false;
    a.shortcut = "";
  }

  return a;
}

function help(cmd)
{
  if (cmd == "moveLinesDown") {
    return i18n("Move selected lines down.");
  }
}

What happens is the following:

  1. the header tells kate that there is an exported function “moveLinesDown”
  2. so when Kate Part is loaded, it calls “action(moveLinesDown)” to check whether this function should be exposed in the GUI. Here, we return the action info that includes the displayed text, an icon, a category, whether the script needs user input (interactive) and a default shortcut. Of course, you can change the shortcuts, and also configure the toolbars to show the actions.

With this, every user is able to script arbitrary editing functions for Kate Part. We don’t have to implement all those helpers in C++ anymore. The result looks like this:
You can have this already now, you just have to use the development version of Kate :)