› kate

» Kate Highlighting for QML, JavaScript
Fri, 02/26/2010 - 16:45
Hey everyone!
I’ve started my internship at KDAB this week, it’s great fun so far! Though I spent most of my time this week on Bertjans KDevelop plugin, I couldn’t resist on a bit of Kate hacking:
steveire is experimenting with QML so I couldn’t stop but notice that there is no highlighting for it in Kate. Well, there was none ;-) Now you get pretty colors, rejoice!
Note: Since QML is basically JSON with some added sugar, I reused the existing JavaScript highlighter and improved it. Hence you get imrpoved JSON and member highlighting in plain.js as well. Enjoy!
» Kate/KDevelop HackSprint - Up To Day 4
Wed, 02/17/2010 - 19:43
Woha, quite a few days flew by without me blogging about anything. Thankfully the others started to write so I don’t have to repeat it all ;-) Instead I’ll concentrate on stuff I did or learned.
GHNS for Snippets
Well, first I think an excuse is in oder: There is a GHNS button for Kate Snippets in 4.4.0 but it’s broken, neither me nor Joseph had time to acutally use and fix it… But anyways, I fixed it now for 4.4.1. For 4.5 we’ll also have an Upload Dialog.
I also added both now to KDevelop, you can now upload and download snippets from it. I added a few dump examples but will probably improve it steadily.
Kate Performance
On Saturday and Sunday I started to profile Kate highlighting for a large MySQL dump and managed to greatly improve the speed. Actually the funny thing is that I could improve RegExp based highlighting (you still should try to prevent using it, it will always be slower than simple char/string based highlighting). And the knowledge for this optimization I had from my time as an active contributor for GeSHi. I feel like it was ages ago, he funny :)
So if anybody has a big file that takes ages to load (but only if you use KDE 4.5 trunk or higher), tell me and give me the file. I might find some more ways to optimize different languages.
Other Stuff
Other than that I also managed to fix a few more bugs in Kate and KDevelop and had a good time with the other guys here in Berlin. Yesterday I showed some others how I spent quite a few nights: Partying in Berlin is nice :)
Oh and Bernhard showed me a little gem of his: Kate Standalone which you can use to build only KatePart from kdelibs trunk. This actually works very well (up until some new API from KDE trunk is used).
» Kate/KDevelop HackSprint Day 1
Sun, 02/14/2010 - 01:58
So, first day of the Kate/KDevelop hacksprint.
We just talked and hacked at the rented flat,got to know each other and had a fun time. Everybody made it more or less in time, even last minute attendee Adymo from Ukraine, nice! Hacking-wise the productivity wasn’t that high, esp. for me, but a few patches got committed here and there.
Right now I’m working on a little speedup for Kate, esp. for big MySQL files - lets see how it turns out. Cullmann showed me a few things I could do so maybe it works out, lets see.
Over the next week I plan to push in user configurable include paths for the PHP plugin and do some more Snippets & Scripting work in Kate, lets see how it turns out. I’ll go home now, kinda sucks that I don’t stay with the others here at the flat but have to take a 1h ride into the city… Berlin is definitely too big :D
» Snippets In KDevelop / Kate
Wed, 02/03/2010 - 17:59
Hey all!
Just wanted to give you a little rundown on Snippets in Kate 4.4 (via the snippets_tng plugin) and KDevelop Beta 8 (soon to be released).
Note: The Kate plugin was written by Jowenn and introduced me to all these nice features. For KDevelop I wrote a somewhat simpler yet imo better implementation. We will try to get the best of both worlds into KDE 4.5. Stay tuned!
General Usage & Features
- create a snippet repository (or download via GHNS [see below])
- create snippets in that repository
- insert snippets via the snippets view (i.e. double click), or (imo better/faster) insert them via code-completion (remember: CTRL + Space requests code completion at the current cursor position!).
- snippet gets inserted (properly indented) and potential placeholders/variables get expanded. A variable is something like
%{date}or${email}. Also take a look at the API documentation. - variables that get inserted via “${…}” will be “selectable”, meaning you can jump from one var to the other by hitting TAB / Shift TAB
- the
%{...}vars will only get expanded and inserted, without getting selectable. - multiple occurrences of the same variable will be updated once one of them gets edited, something that is called “mirroring” in other editors.
- once one edits ESC the cursor is placed at the end of the snippet or to the first occurrence of
${cursor}or%{cursor}and the user types something, the snippet-handler quits and you are left with your normal editor until you insert the next snippet - nested snippets (i.e. insert snippet than insert another one) should “just work”.
Snippet Management
- group snippets by file type, i.e. PHP snippets will only be offered during code completion when one edits a PHP file.
Note: In KDevelop and KDE 4.4 nested documents are supported, e.g. create a CSS snippet and it will be shown inside the CSS parts of a HTML document or similar. This uses my HighlightInterface I wrote for KDE 4.4. I still have to rewrite some parts of the snippets_tng plugin for Kate so that it works there as well - group snippets in repositories, set an Author and a License of your choice
- publish snippet repositories via GHNS: In Kate you can already download snippets from GHNS but we sadly don’t have any repos up on opendesktop… I’ll have to add some prior to KDE 4.4. Also we didn’t have enough time to implement uploading of Repos from inside Kate in time for KDE 4.4. So stay tuned for KDE 4.5. KDevelop currently has no support for GHNS, but I plan to fix this tomorrow or the next days - together with uploading from inside KDevelop, i.e. all the nice features of GHNS v3.
- in KDevelop (and someday in Kate as well) you can simply select a part of your currently opened document and select the “create snippet from selection” in the ContextMenu - easy & fast!
TODO
There’s much to do.
- Highest priority right now for me is to get GHNS with all bells and whistles supported for KDevelop.
- Then I’ll merge and integrate the Kate & KDevelop plugins as much as possible, so we have a reduce code base.
- Also important is to make all shortcuts configurable
- Another thing is: How could we improve interoperability even between e.g. editors like TextMate or Gedit? Both have snippets features and their bundles are available in the net. If we can support those we’d save us a lot of work
Also, I should probably do a screencast… Not now though ;-)
» Kate polishing
Thu, 01/21/2010 - 02:09
Phew, I just finished some last-minute backports to the KDE 4.3.5 branch. Lets hope the bug fixes I and pletourn did are as good as they look. Expect a much more stable Kate for 4.3.5 & 4.4! We managed to fix two bugs which are potentially the cause for dozens of bug reports, all seemingly random. Lets see whether our fixes hold up to our hopes!
Other than that: You should look forward to Kate scripting (with JavaScript) in 4.4. It’s dead simple but actually useful. In the utils.js file we ship with Kate there are now the following tools (all operate on the selection or - if none exists - on the whole document):
- sort - simple sorting
- natsort - natural sorting
- uniq - filter duplicates
- trim - remove leading & trailing whitespace
- ltrim - remove leading whitespace
- rtrim - remove trailing whitespace
Do you have more ideas for such simple helper functions?
» Kate Love: HighlightInterface, Autobrace
Sun, 11/22/2009 - 20:15
Well, I have to admit: I didn’t spent much time developing the PHP plugin for KDevelop these past weeks. Instead I hacked on Kate:
HighlightInterface
I added another Kate interface, this time to access some of the highlighting information:
- what’s the Attribute for a given default style right now? Default styles are those known from syntax files, e.g.
dsKeyword,dsFunction,… - what are used Attributes in a given line and what range do they occupy?
- what modes do we embed? E.g. PHP embeds HTML, JavaScript, CSS, …
- what mode is used at a given Cursor position?
This made it possible to port the “Export to HTML” action to a real plugin. If you come up with other output formats I might add them, I wondered about LaTeX support… might do this at some point.
This should also make it possible to use KatePart in other applications and than export the highlighting to a different format, e.g. a Flake shape for Koffice. Afaik this is actually planned by The_User - lets see if it works out!
The other stuff gives huge potential in various places, but I fear it won’t make it in KDE 4.4. But think of it:
- simple code completion based on keyword databases, dependent on the mode at the position where completion was requested
- same as above for snippets (actually this will make it to 4.4).
- insert your ideas here :)
Auto-Brace plugin
Jakob Petsovits created this gem of a plugin some time ago, yet it lived in playground was probably only used by few. I imported it to kdelibs, hence it will be shipped with KDE 4.4. It supersedes the limited “auto-brackets” feature of Kate and only adds braces when a newline gets added. I find this fits my personal coding habits much better than blindly copying brackets when they get added.
And I don’t just copied to kdelibs, I also added a few features:
- automatically add a semicolon after the closing brace when we start a new struct/class in C++ mode
- check for auto-brackets feature and disable it automatically
Also did this:
- don’t add brace when current line contains
namespaceand a following line starts withclassorstruct(C++ mode only) - don’t add brace when current line contains
class,interfaceorstructand the following line containsprivate,public,protected. C++ code is also checked forsignals,Q_SIGNALS", other modes are checked forfunction`.
This should fix the bug for code like (note the indendation levels):
namespace foo { // insert line here class bar; } class asdf { // insert line here private: ... };
» KDevelop & KWrite/Kate hacksprint 2010 in Berlin
Mon, 11/16/2009 - 16:38
Hey everybody!
If you are a KDevelop and/or Kate/Kwrite developer and do not read the mailing lists: There’s a hack sprint coming up in Berlin in 2010. I think there’ve been enough sprints in Berlin already so that you know it’s a great city for such an event. Though this time it won’t be at KDAB or Nokia offices, but at the Physics Faculty of the FU-Berlin. Since I (currently) work there as an IT admin, it was my first choice and worked out. I hope it will be a good location for the meeting. If you want to attend, vote on doodle:
http://www.doodle.com/vkyh9up9794zr4s8
But you probably also should register either on the KDevelop or KWrite mailing lists so I have some kind of way to contact you.
PS: in unrelated news I’ll do an internship at KDAB next year! yay
» first experience with Archlinux
Sun, 10/18/2009 - 02:24
So, I kinda messed up my desktop right after the upgrade to karmic, because I was too greedy for performance and converted my root file system to ext4. Well, that worked like a charm on my laptop, but it broke my desktop. This is in no way karmic’s fault, it’s my own misbehavior. Thankfully I could rescue most of my data.
Since I’d had to reinstall anyways, I decided to finally try out Archlinux. I find the rolling release mantra very intriguing. Together with a “simpler” packaging, namely no splitting between -dev and -dbg packages like debian/ubuntu does, this is destined to be a good environment for a developer. I always hated it to track down missing -dev packages when compiling software. And don’t get me started on outdated software in repos… I just compiled kdelibs and the only missing build dependency was hspell, that I don’t need anyways. Under Jaunty I had to compile stuff from kdesupport to fulfill updated dependencies. And the list of not-found optional dependencies was huge, since I did not spent time to install all those -dev packages by hand…
My first impression of Archlinux is very good so far. I also finally migrated to 64bit wich works like a charm, no issues with flash or anything. Since I never used a 64bit Ubuntu/Debian I’m not sure, whether the perceived performance increase is due to the switch to 64bit or whether Archlinux optimized packages are responsible. Probably both. Nevertheless I can safely say that my system feels snappier than before.
Of course, the installation and initial setup is not as straight forward / easy as with Debian/Ubuntu: Yet it’s no big deal for anyone with some Linux experience. And, once everything is setup, you are running KDE again, so no real difference. Thanks to the Chakra team for kdemod, it works like a charm!
I might have spent a bit more time during the installation / initial configuration, but I think this would have happened also if I’d installed any other distro I’ve never used before, like OpenSuse or Fedora.
Oh and since I can install sudo I can keep my old habits. Neat.
The only thing I miss so far is aptitude with it’s straight forward command structure. Yaourt/Pacman is fast and nice, esp. with pacman-color, but the commands don’t feel as straight forward to me… Personal preference I’d say.
To conclude: Archlinux is very nice, I can wholeheartedly recommend using it so far. Probably nothing for a novice Linux user, yet perfect for advanced users. Very good as a development environment. Fast. Up to date. I like it :)
Now I can finally continue hacking on Kate/Kdelibs again :) I’m currently in the process of refactoring Kate’s implementation of the TemplateInterface. Even in it’s current state it already implements features like mirrored snippets and the like. But once I’ve finished with the cleanup I will try to implement some more of the features that are found in e.g. yasnippet for Emacs. I really wonder why nobody else did that already…
Once this is finished, you can expect that I will deeply integrate that feature in various places in KDevelop, especially for code completion, snippet plugin etc. pp. Stay tuned!
» Improved PHP support in Kate
Wed, 08/26/2009 - 16:20
Not only KDevelop gets better and better PHP support — the Kate PHP syntax file also got a few new features and fixes over the last weeks. The good thing is of course that all users of KWrite, Kate, Quanta, KDevelop and other editors leveraging the Katepart benefit from these changes.
Improved HereDocs
screenshot of improved highlighting in PHP heredocs
I went over PHP related bugs on bugs.kde.org today and spotted one that was fairly easy to fix:
vim-like syntax highlighting support for heredocs in php.xml
With some magic (IncludeRules just rocks) I got it working fairly easy. You can see the results to the right.
Additionally I added code folding to heredocs, since often these strings include lots of text and hiding it often makes sense.
Better support for overlapping syntax regions
code folding with overlapping syntax regions
Another long standing bug (”accommodate overlapping syntax regions (especially for php)”) got fixed by James Sleeman.
Finally PHP templates with code such as
<?php if ( true ) : ?> <!-- some html stuff --> <?php elseif ( false ) { ?> <!-- some other html stuff --> <?php } ?>
can be folded properly. This kind of spaghetti code is used quite often in simple templates and having the posibility to fold it properly is a huge win in my opinion. Thanks to James Sleeman again!
» Kate linter plugin
Thu, 01/15/2009 - 18:58
Just a quicky: I wrote a little plugin for KTextEditor which supplies you with basic error checking when you save documents. Currently only PHP (via php -l) and JavaScript (via JavaScript Lint) are supported.
