Back to Blog home

KDevelop gets Kross scripting

Published on Wednesday April 16, 2008 by Harald Fernengel in KDE Qt Script | Comments

One of the more heated points in the ongoing KDevelop team meeting here in Munich is the good old language war - while I love (and hate just as much) Perl, Alex likes Ruby, Roberto JavaScript and I'm sure we can find someone who prefers Python.

Since Revision 797621 of KDevPlatform, scripting via Kross is now supported. This allows everyone to write an extension to KDevelop in his favorite scripting language. Since I'm most familiar with QtScript (yes, I did forget all my Perl a moment ago), here's an example KDevelop script:

function documentLoaded(doc) {
print(KDevTools.toDocument(doc).url());
}

documentController = KDevTools.toDocumentController(KDevCore.documentController());
documentController.documentLoaded.connect(docLoaded);

This little script will listen to all documentLoaded signals from the document controller and outpout the URL of the file once it's loaded.

So, let's load a file:

documentController.openDocument("test.cpp");

and watch the URL being printed to command line. The available scripting backend could already be used to implement a simple "switch header/source" plugin, that opens the corresponding *.h/*.cpp file when invoked.

For the moment, the "casts" using KDevTools are required as long as I don't understand how to auto-convert meta-types in a script-independent way :)

My goal for this meeting - implement a version control system plugin completely in a scripting language, so it can be deployed without headache for all supported OSes.

Subscribe to Our Blog

Stay up to date with the latest marketing, sales and service tips and news.

The blog comment system has been migrated to a new platform. If you face any issues, please let us know via feedback@qt.io.