New kate-editor.org launched
After some years of no real updates, beside the brave work of Dominik, a new kate-editor.org is launched.
It will be used to aggregate the blogs of the Kate developers and provide information about current development in Kate/KWrite/KatePart and guides for users.
Hope more people join the effort to once again provide a constant stream of up-to-date information.
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 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."); } }</pr
Read More
Enjoying Tampere
A Flashback of Kate in Gitorious
As getting new contributors is essential for keeping a project alive, the barrier to get involved should be as low as possible. And exactly this was achieved by moving all pieces to one place (this was gitorious for us). Building Kate is so simple right now that we can even make bug reporters build Kate out of the box. This helps a lot, and even results in patches from time to time. We also got quite some merge requests.
There were several voices at that time that considered moving “away from KDE” was very bad. However, this is not the case, as Christoph is synchronizing all the changes in KDE’s subversion and gitorious almost every day. This is certainly not optimal, but looking back at the last months, we can say it was worth it.
KDE is moving to git.kde.org in the near future. This also raises the discussion about how KDE’s source code will be organized. Speaking for Kate, we certainly want to have all of Kate’s code in one place, just as it is now with gitorious, no matter what :) I hope we can find a solution the KDE community can live with. To be discussed, maybe in Tampere in two weeks? :) Read More
Debugging Kate with Qt Creator
Let’s have a quick look at how to debug Kate and KWrite with Qt Creator. First, make sure you meet the requirements:
- build Kate according to this tutorial
- install Qt-Creator (in my case this is version 2.0.0)
Setup the Kate project Qt-Creator once like this
- start Qt-Creator like this (important to get all environment variables right):
~/kde/run.sh qtcreator - invoke File > Open File or Project and choose ~/kde/kate/CMakeLists.txt
- Build Location: choose ~/kde/build
- Run CMake arguments: type
../kate -DCMAKE_BUILD_TYPE=debugfull -DCMAKE_INSTALL_PREFIX=~/kde/usr - click the button “Run CMake” and then “Finish”
Start debugging like this
Read MoreKate: Code Folding Crash
We still have a crash in Kate’s code folding code; no one was able to find a proper fix, yet. So if you want to get your hands dirty, just build Kate, find a fix and be the hero of all Kate developers :)
Update: Fixed by Stefan Schenk in this commit for KDE 4.5. Awesome! :)
Kate Internals: Smart Cursors and Smart Ranges
SmartCursors and SmartRanges in KDE 4.0 – KDE 4.4
Since KDE 4.0 the KTextEditor interfaces have so called SmartCursors and SmartRanges. A SmartCursor is a text cursor (i.e. a line/column tuple) , which is bound to a text document. When editing the text document, the cursor is automatically moved such that it maintains its position. You need this for the displayed text cursor in a view for instance. If you type text, the cursor automatically moves.
A SmartRange consists of two SmartCursors: start and end. We use that for instance for the text selection or the inline spell checking, or KDevelop uses it to add arbitrary highlighting to parsed C/C++ code. Again, if you modify text in the document, the text range automatically moves, expands or shrinks.
Kate XML Completion Plugin
Quick Compiling Kate in a stable KDE Environment
Since all of the Kate code is now co-hosted on gitorious, it became very easy to build Kate in your stable KDE >= 4.4 environment. This means you can run the newest version of Kate with very few effort. Just give it a try and do the following steps:
- make sure you have the following packages installed: git, cmake and kdelibs development package (on openSUSE this is git, cmake and libkde4-devel)
- create and change into a KDE development directory:
mkdir ~/kde; cd ~/kde - get a copy of the Kate code:
git clone git://gitorious.org/kate/kate.git - create and change into a build directory for compilation:
mkdir build; cd build - run the configure process with cmake:
cmake ../kate -DCMAKE_BUILD_TYPE=debugfull <br /> -DCMAKE_INSTALL_PREFIX=~/kde/usr - compile Kate:
make - finally install Kate:
make install
That’s all! This installs Kate locally into the separate directory ~/kde/usr, so that your global KDE installation will not be touched at all.
Read MoreKate Internals: Text Buffer
Right now, in Kate’s gitorious repository we, or rather mainly Christoph, is rewriting the heart of Kate: The text buffer. In this blog I’ll explain how the text buffer works in detail. After reading, you’ll be able to understand the code. And be warned: Probably you will be desperately amazed about its awesomeness! So this is a must read :^)
Storage. Kate Part internally stores the content of a text document as a QVector of text lines. Each text line holds the text in a QString object as well as additional data like color attributes for highlighting. Inserting and removing text lines implies inserting or removing items in the QVector of the text lines. This is can get slow when there are thousands of text lines in a document, because QVector has to move the memory every time. Thus, to keep text operations fast, Kate splits all text lines into several text blocks: Each text block contains a certain amount of lines (e.g. 256). The expense of memory movement is then always limited. When a text block grows too much, it is automatically split. When the amount of lines in a text block shrinks, it is merged with the previous text block. In other words, Kate’s text buffer automatically balances the text blocks. The basic idea of Kate’s text buffer, the text blocks and text lines looks like this: