Skip to content

Posts 

New kate-editor.org launched

Friday, 9 July 2010  | Christoph Cullmann | Tags:  planet

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

Friday, 9 July 2010  | Dominik Haumann

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

Tuesday, 6 July 2010  | Dominik Haumann
As always, the KDE conference has its funny sides, as you can see on the photo: 4 Kate developers shaping the future of the (as you all know) most awesome application: Kate :-)

A Flashback of Kate in Gitorious

Thursday, 24 June 2010  | Dominik Haumann
Back in February, I blogged about Kate’s move to gitorious. The main reason for this move was to make building Kate as easy as possible. If you want to build Kate as part of KDE, (as of now) you have to compile kdesupport, phonon, dbusmenu-qt, kdelibs, kdepimlibs, kdebase for kwrite and kdesdk for the kate application. Getting all this done is a huge effort, especially if you are new to KDE development (I very well remember my own times spending weeks to get everything going. Be aware of new contributors might now close to nothing about KDE and all the dependencies!).
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

Saturday, 19 June 2010  | Dominik Haumann

Let’s have a quick look at how to debug Kate and KWrite with Qt Creator. First, make sure you meet the requirements:

  1. build Kate according to this tutorial
  2. install Qt-Creator (in my case this is version 2.0.0)

Setup the Kate project Qt-Creator once like this

  1. start Qt-Creator like this (important to get all environment variables right):
    ~/kde/run.sh qtcreator
  2. invoke File > Open File or Project and choose ~/kde/kate/CMakeLists.txt
  3. Build Location: choose ~/kde/build
  4. Run CMake arguments: type
    ../kate -DCMAKE_BUILD_TYPE=debugfull -DCMAKE_INSTALL_PREFIX=~/kde/usr
  5. click the button “Run CMake” and then “Finish”

Start debugging like this

Read More

Kate: Code Folding Crash

Thursday, 10 June 2010  | Dominik Haumann

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

Wednesday, 28 April 2010  | Dominik Haumann

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.

Read More

Kate XML Completion Plugin

Tuesday, 27 April 2010  | Dominik Haumann
A while ago I’ve blogged about the Kate’s most powerful plugins: the XML completion plugin. Thanks to Tomáš Trnka this plugin is back alive with all its features since today and compiled by default in trunk: It will be included in KDE 4.5. Yay! :) And if you need it already now for KDE 4.4, you can build Kate yourself very easily according to this howto, without touching your global KDE installation (probably interesting for KDE documentation writers!). Have fun! Read More

Quick Compiling Kate in a stable KDE Environment

Saturday, 17 April 2010  | Dominik Haumann

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:

  1. make sure you have the following packages installed: git, cmake and kdelibs development package (on openSUSE this is git, cmake and libkde4-devel)
  2. create and change into a KDE development directory:
    mkdir ~/kde; cd ~/kde
  3. get a copy of the Kate code:
    git clone git://gitorious.org/kate/kate.git
  4. create and change into a build directory for compilation:
    mkdir build; cd build
  5. run the configure process with cmake:
    cmake ../kate -DCMAKE_BUILD_TYPE=debugfull <br /> -DCMAKE_INSTALL_PREFIX=~/kde/usr
  6. compile Kate:
    make
  7. 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 More

Kate Internals: Text Buffer

Tuesday, 2 March 2010  | Dominik Haumann

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:

Read More