Tag Archives: planet

Navigation in Okular: Back & Forward

Okular, KDE’s universal document viewer, has a really cool feature I’m using for years already: “Go > Forward” and “Go > Backward”. These two actions allow to quickly jump to positions in the document where you came from in a chronological order. Consider e.g. reading the phrase “As shown in [15], …”, and you want to know quickly lookup reference [15]. So you click on it, and okular will jump to the list of references. And “Go > Back” will bring you back to exactly the position where you came from.

Awesome πŸ˜€

In fact, I removed the “Previous” and “Next”-page buttons from the toolbar in favor of the “Back” and “Forward” feature, which is much more useful to me πŸ™‚ Given that my colleagues were not aware of this feature (all experts in LaTeX Β and all using Kile and Okular), I thought to praise it here in a dedicated blog. Interestingly, the Okular Handbook is missing this feature. Any takers to fix this? πŸ™‚ Update: This is also mentioned in the Okular handbook πŸ™‚

Idea: Code Completion for JavaScript

In 2012, Kate had a GSoC project with the aim of adding a Scripting IDE plugin. The idea was to make it easy to write Kate Part scriptsΒ (command line scripts, indenters), that should include rudimentary code completion and a gui to manage available scripts. As detailed in the blog post, a rudimentary list that showed all available scripts is available. However, due to changes in Kate Part’s scripting framework (e.g. changes in the folder structure, require() function to load libraries), the plugin in its current form is not applicable anymore. Still, the idea of having a better JavaScript support is valid.

So this blog post is about some ideas how we can add possibly really cool JavaScript support to Kate as a plugin. This plugin should provide the following features:

  1. provide code completion
  2. support for loading additional modules (jQuery, Node.js, Prototype, Kate Scripting API, …)
  3. specialized support for Kate Part scripting
  4. outline in terms of a function and prototype browser

JavaScript Code Completion

Providing code completion to JavaScript requires a parser so we have an abstract syntax tree (AST) of the current file. This parser needs to be error-tolerant, since during the process of programming, the source code often violates the syntax. Searching the Web, relatively few information about such a parser exists. But one tiny parser shines: EsprimaΒ (source code, more info), written by KDE’s “very own” Ariya πŸ™‚

Esprima is a JavaScript parser written in JavaScript. It is (to some degree) error-tolerant and returns an AST as shown in the parse demo. The AST is returned in simple JSON syntax, meaning it can be easily parsed with either the JavaScript JSON functions or JSON in Qt5 (JSON for Qt4). Along the error-tolerant mode, the AST returned by Esprima also contains comments and line/column information, if desired.

Interestingly, the idea of using Esprima for code completion arose about a year ago, and meanwhile there are several projects that successfully use the Esprima AST: Eclipse Orion, a web-based IDE, uses Esprima for code completion and for the outline view (sources). The source code for the code completion is available in the orion client git module: lib, code completion (content assist), unit tests.

So What Next?

As it seems the code is all there, the next step would be to start a small standalone project and write a proof of concept to check whether this approach is feasible. I’d suggest to use Qt’s JavaScript interpreter (QtScript in Qt4, QJS in Qt5). In the long run, the goal would be to have code completion and possibly an outline view. If this works, more functionality like support for Kate Scripting could be added. So there is a lot to play around with.

If you are interested, just start working on it. It might be a good GSoC project (although we’d require a quite skilled developer here) πŸ˜› Thoughts? Comments?

Kate Git Statistics

Now the statistics of the kate.git are online for public viewing.
They will be updated daily, located on:Β http://kate-editor.org/stats/

Unfortunately, the statistics of the last years are not that “representative”, as the moves of Kate around in SVN and to Git biased the statistics, as I did a lot of the commits for syncing and moving and so on.

Still it is amazing how MANY people did contribute during Kate’s history! (see Kate Authors)

A big THANK YOU to all contributors that appear there (and all the people that provided patches others merged in, did the testing, bug reporting, translations, …).

(And thanks to the authors of git_stats.)