• Users

    Extending Kate by Scripts

    by  • July 21, 2007 • Users

    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.editBegin();        document.removeText(start, 0, end, document.lineLength(end));        document.insertText(start, 0, text);        document.editEnd();    }} The header line functions:...

    Read more →

    Kate: More on Indentation Scripting

    by  • July 20, 2007 • Users

    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...

    Read more →

    Kate Scripting: Indentation

    by  • July 18, 2007 • Developers, Users

    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...

    Read more →

    Kate Modelines

    by  • February 9, 2006 • Users

    Kate Part’s modelines – also called Kate document variables – are Kate Part’s implementation of document variables, similar to Emacs and vim modelines. Document variables can be used to set Kate settings local to a file. This is for example for using another indenter than the one defined in the GUI settings. Or assume...

    Read more →