Encapsulation is not Information Hiding

Friday, 21 December 2007 | Dominik Haumann
As food for thought and in reply to Why Encapsulation is a Good Thing it’s interesting to take a closer look. What does encapsulation mean exactly, and what can you do with it? Maybe what you really want is Information Hiding? …and encapsulation is just a way of possibly achieving it? If you are interested in the details/differences, read the article Encapsulation is not Information Hiding.

Memory Leak Continued

Thursday, 22 November 2007 | Dominik Haumann
There was some confusion with regard to my last blog about leaking memory. Suppose the ui_mywidget.h files looks like this: class Ui_Widget { public: QGridLayout *gridLayout; QGroupBox *groupBox; QGridLayout *gridLayout1; QListWidget *listWidget; QSpacerItem *spacerItem; QPushButton *pushButton; void setupUi(QWidget *Widget); void retranslateUi(QWidget Widget); }; Of course, those 6 QObject derived classes are deleted. But the sizeof(Ui_Widget) = 6 * sizeof(void) = 24 bytes are not deleted. As Ui_Widget is not QObject derived those 24 bytes leak. Read More

Memory leak: Ui files and direct approach

Wednesday, 21 November 2007 | Dominik Haumann
The KDE codebase often uses a forward declaration in the .h-file to speedup compilation. The code often looks like this: // header file namespace Ui { class MyWidget; } class MyDialog : public KDialog { // ... private: Ui::MyWidget *ui; }; The impl looks like this: // source file #include "mydialog.h" #include "ui_mywidget.h" MyDialog::MyDialog() : KDialog() { QWidget *w = new QWidget(this); setMainWidget(w); ui = new Ui::MyWidget(); // allocation ui->setupUi(w); // ui->. Read More

Kate Highlighting Power

Wednesday, 12 September 2007 | Dominik Haumann
Kate’s highlighting capabilities are amazing. If you want you can highlight really complex syntax, without having to hardcode rules in C++. As an example, we’ll take a look at how Lua comments can be realized: –[=[ starts a multiline comment (the ‘=’ chars are optional) ]=] ends the multiline comment the number of ‘=’ chars in ]=] must match the number of –[=[ That means: When the highlighting processor matches the end of a multiline comment, it has to know how many ‘=’ chars started the comment. Read More

Extending Kate by Scripts

Saturday, 21 July 2007 | Dominik Haumann
We have seen how scripting basically works for indentation. It’s also possible to register commandline functions (The command line is bound to F7 by default, or invoke View > Switch to Command Line). We will consider a small example again: sort the selected text. / kate-script name: unused author: foo bar license: LGPL version: 1 kate-version: 3.0 functions: sorter / function sorter () {     if (view.hasSelection()) {         var start = view.startOfSelection().line;         var end = view.endOfSelection().line;         var text = document.textRange(start, 0, end, document.lineLength(end));         var lines = text.split(“\n”);         lines.sort();         text = lines.join(“\n”);         view.clearSelection();         document. Read More

Kate: More on Indentation Scripting

Friday, 20 July 2007 | Dominik Haumann
My last blog was about the theory of how indentation works by using javascripts. Now we will look at a concrete example: a LISP-style indenter. (LISP indentation is easy, that’s why it’s a good example). The rules: comments starting with ;;; always have indentation 0 comments starting with ;; should be aligned with the next line comments starting with ; should only appear behind code, so they are simply ignored every ‘(‘ indents and every ‘)’ unindents lisp. Read More

Kate Scripting: Indentation

Wednesday, 18 July 2007 | Dominik Haumann
Kate Part in KDE4 supports the ECMAScript (JavaScript) language by using kjs. In KDE3 we had several hard-coded indenters in C++, the idea is to let scripts do all the indentation in KDE4. How does it work? It is similar to vim: You simply create a script in the directory $KDEDIR/share/apps/katepart/jscript. An indentation script has to follow several rules: it must have a valid script header (the first line must include the string kate-script and indentation scripts must have the type: indentation) it must define some variables and functions Whenever the user types a character, the flow in Kate Part works like this Read More

API documentation & refactored kdelibs/kdeui

Wednesday, 27 December 2006 | Dominik Haumann
During the last weeks/days the directory structure of especially kdelibs/kdeui got a major overhaul: in KDE 3 all files of a module were in the same directory which was more or less a mess as you did not know immediately which files belonged to the same category. kdelibs/kdeui in KDE4 has a rather clean structure now (similar to the one in Qt) by using subfolders like actions dialogs widgets xmlgui several others… Compare this to KDE3’s kdelibs/kdeui structure. Read More

Share Kate Highlighting Files

Thursday, 12 October 2006 | Dominik Haumann
Thanks to Frank we have a dedicated section for Kate Highlighting files on now. We encourage everyone to publish their .xml files there. The Kate team agreed to add more highlighting files to the official Kate releases, though, as long as they are of general use. For KDE4 we plan to have a section for Kate Indentation scripts, too. But that’s content for another blog, which will follow later :)

Kate: More eye-candy

Friday, 29 September 2006 | Dominik Haumann
Two years ago we had the KDE conference in Ludwigsburg, Germany. At that time, Martijn Klingens committed a patch to show trailing spaces in Kate. I just change the visualization a bit, the change is in for KDE4 :) Tabs are marked with a ‘»’ character, and spaces with a dot. On the left you can see the old and on the right the new version; Here is a screenshot: