javascript Syndicate content

warning: Creating default object from empty value in /www/htdocs/w0065fc9/milianw/modules/taxonomy/taxonomy.pages.inc on line 33.

» Progress on JavaScript language support in KDevelop

Sat, 01/26/2013 - 17:06

During the sprint in Vienna last year, Aleix and me laid the ground work for a QML/JS language support plugin for KDevelop. Sadly we two only have very limited time working on fancy new features such as that.

Thankfully someone stood up and started contributing - none other than Andrea Scarpino of ArchLinux KDE/Qt packaging fame. With some help of me and Sven he managed to get the JavaScript support into a much more shiny state - behold:

Colorful JavaScript Analysis in KDevelop
Colorful JavaScript Analysis in KDevelop

For simple JavaScript files we already have proper context browsing, uses and declarations. And all that in just a few lines of code thanks to the good work of the QtCreator team, whose JavaScript/QML parser we use (which is the one of the most complicated parts of a language support plugin). Thanks again, guys!

The next steps on the JavaScript side will be proper support for objects and prototypes - I’m interested to see how we can cope with that. Then we’ll need support for built-in APIs such as DOM window, document and such. But we’ll keep the other use-cases of JavaScript in mind, like using it to extend your own applications (see e.g. Kate).

Anyone else out there who wants to help? Or maybe someone wants to work on our QML support? We KDevelop hackers would be happy to help!

» More BKO javascript goodness

Sat, 09/25/2010 - 22:54

Hey all,

I’ve improved my javascript highlighter for backtraces on bugs.kde.org and fixed some bugs (e.g. the BUG 123456 links where lost before). Additionally I just added another feature that gives you a nice little navigation bar like this:

improved highlighting of backtraces on bugs.kde.org with additional navigation helpers
highlighted backtrace with navigation bar

Pressing crash scrolls the window to the [KCrash Handler] in that backtrace, prev thread and next thread do what you would think they do.

To get all the goodies, click this link to install the updated script in GreaseMonkey:

http://users.physik.fu-berlin.de/~milianw/bko_highlighter.user.js

NOTE: This also works with Tampermonkey in Chromium!

Happy backtrace reading!

PS: Yeah, we really should get this by default into BKO… I’ll write a mail to the sysadmins now.

» Highlighted Backtraces on BKO

Mon, 09/20/2010 - 19:05

Hello everyone, the “I can syntax highlight everything” guy speaking again :)

Yeah, I couldn’t sleep well after I put colors on Dr Konqi. I also did the same for Kate, if you did not notice it. There is a new GDB Backtrace syntax highlighting file for it, giving you the same pleasant experience you are now used to from Dr Konqi. Awesome.

But well, lets admit it: What use are these two for bug triaging? Visit any crash report on bko and you are left to plain old black-on-white… Stone-age stuff, lets put it on LSD, shall we not? I propose: The GDB Backtrace highlighter GreaseMonkey userscript!

Bug reports, feedback, pizza & beer all welcome :)

PS: How is GreaseMonkey for Konqueror coming along, anyone working on that? Does someone know whether Chrome or Opera could be made to work with this?

PPS: We could also install this script directly on BKO, but I fear it might be a tad bit slow, esp. for huge backtraces.

PPPS: Attached backtraces should be setup to be opened in Kate :)

» Spotlight: Kate Scripting

Tue, 07/27/2010 - 00:51

Hey ho everyone.

Dominik asked me to blog about a feature in Kate that is still (sadly!) pretty unknown and seldom used: Kate Scripting. As you should know you can script KatePart completely via JavaScript. As those articles explain, it’s rather simple to write functions and put them into a file to have them reusable. But what for those write-use-throwaway kind of cases, where you simply need to get a job done quickly and don’t want to go through the overhead of writing some full fledged, documented, action-binded, localized script?

Utility Functions and why JavaScript rocks

Note: Neither map nor filter will be shipped with 4.5 to my knowledge, sorry about that. But you can still use the each helper (see below) to achieve the same with a bit more typing…

Take a look at utils.js on current git master: http://gitorious.org/kate/kate/blobs/master/part/script/data/utils.js

Put a special note on the helper functions map, filter and each and how they are used to implement e.g. rmblank, [rl]trim and the other functions. Cool eh? And the best part, you can reuse them directly from inside KatePart to get a job done:

mail-style quoting

Lets assume you write an email or use something like Markdown or Textile and want to quote. You’ll have to prepend a few lines with the two chars ‘> ‘. Instead of copy’n’pasting like a maniac do this instead and save yourself some breath:

  1. press F7 to open the Kate command line
  2. write e.g. map "function(l) { return '> ' + l; }"
  3. execute

Note: When you don’t have anything selected, the whole document will get “quoted”.

remove lines that match a pattern

This is something everyone needs to do sooner or later, happened quite a few times to me already. I bet vim has some esoteric command I cannot remember and emacs has something like C-x M-c M-butterfly. But with Kate most users only see search & replace and forfeit to the command line. Well, now it’s again a good time to use the command line:

  1. press F7 again
  2. write e.g. filter "function(l) { return l.indexOf('myNeedle') == -1; }"
  3. execute

Now all lines that contain ‘myNeedle’ will get removed. Sure, this is “verbose” but assuming you know JavaScript it’s actually quite easy, expendable and - best of all - good to remember. At least for me, YMMV.

shortcuts

For simple cases I’ve now introduced a shortcut way of doing the above, that saves you even more typing, but is limited to simple evaluations like the ones above. If you need something fancy, you’ll have to stick to the type-intensive way. Aynhow, here’s the shortcut version of the two scripts:

  1. map "'> ' + line"
  2. filter "line.indexOf('myNeedle') == -1"
the guts: each (interesting for users of KDE 4.x, x < 6)

Both of the above are implemented using the each helper I introduced even before KDE 4.4 afair. If you are using KDE 4.5 and want to do one of the above, a bit more typing is required:

  1. for map, you write something like this:
    each "function(lines) { return lines.map(function(l){ /** actual map code **/ }); }"
  2. for filter you do the same but replace map with filter:
    each "function(lines) { return lines.filter(function(l){ /** actual filter code **/ }); }"
Conclusion

You see, it’s quite simple and powerful. I really love map-reduce and how easy it is to use with JavaScript. Hope you like it as well.

PS: I actually think about making it yet even easier, by allowing some syntax like this: map '> ' + line or filter line.indexOf('myNeedle') == -1, must take a look on how hard it would be (beside the need for extensive documentation, but hey we have the help command in the Kate CLI, who can complain now? :) Implemented

Bye

» 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!

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

  1. <?php if ( true ) : ?>
  2. <!-- some html stuff -->
  3. <?php elseif ( false ) { ?>
  4. <!-- some other html stuff -->
  5. <?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.

» updated TypoGridder

Thu, 04/12/2007 - 05:42

Yes I know it is pretty darn late but hey - what else are holidays there for? Except learning and partying and dancing and chilling and… well yes I just could not stop until it worked like I wanted it to.

My TypoGridder now works as a MiniTool for Konqueror and as a bookmarklet in Firefox and Opera. It should have the correct height on any page and should be on top of everything. Please test it and report any bugs.

Visit TypoGridder project Page

» TypoGridder

Wed, 04/11/2007 - 19:13

I recently read two articles about using grids in webdesign. It just makes sense. Read them yourself:

I’ve wrote a little javascript which displays a basline grid on any page (via bookmarklet). For more information visit the project website.

Please use this article for any feedback.

PS: And as you might see, I have a lot to do to let my website align to any grid. The curse of a layman.