Developers
MovingRanges moving on ;)
As with any new code, during adoption bottlenecks show up.
For example the rendering of text lines with many ranges inside was quiet slow. This is now partly addressed by Milian Wolff, thanks a lot.
An other bottleneck was the assumption, that it is fast enough to hash the ranges just by their block and iterate over all of them to search the ranges matching a specific line. This does scale well enough for KatePart itself, but KDevelop creates multi-thousand ranges for small documents. To improve this, an internal special mapping was implemented by David Nolden for ranges which don’t span more than one line. For them an efficient line => range mapping is easy and not to costly.
Read MoreKDE 4.5: SmartRange => MovingRange
Dominik already blogged about the issues we have in KatePart with the current SmartRange/SmartCursor/Smart* interfaces that were designed during the early KDE 4.0 release.
Given that large amounts of the internal implementation are exposed to the outside in the interfaces, there was no feasible way to fix the issues with them. The problem with the not thread-safe behaviour could have been prevented by just stating the plain fact that multi-threaded access to the ranges doesn’t work, even thought there is a mutex in the interface exposed which should be locked to gain this safety. Still the real problems of the unchangable bad implemenation and design choices would have remained.
Read MoreGSoC – Swap Files for Kate
Hello,
As mid-term evaluations have started, I would like to show my current state of GSoC project, because I’ve never found the time to do it.
The swap file feature is implemented, except for the view differences feature and few TODOs. Some more testing need to be done, though. Below are some screenshots of how it works.
When you start editing in a document, a swap file for the document is created (“.swp.originalFileName”). If Kate crashes and the user didn’t save the changes, the swap file remains on the disk.
Read MoreKate: 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
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 More