My blog has been moved to ariya.ofilabs.com.

Saturday, September 11, 2010

minimalistic JavaScript editing widget

In the spirit of clean-up-and-publish, here is another code example of X2: a subclass of QPlainTextEdit which acts as a nice and minimalistic JavaScript editor. Basically it just adds a sidebar for the line number and a syntax highlighter. Thanks to QPlainTextEdit and QSyntaxHighlighter, this editing widget is quite performant. At just about 500 lines, think about it as another example on how to use these two classes.

It does support specifying different colors so you can have funky color scheme if you want:

The widget is BSD licensed. Find it out in the X2 repository under the javascript/jsedit subdirectory.

It does not have fancy features such as code folding or autocomplete (not sure I would have time to add them, so patches are welcomed!), but if you want feature packed editor, use QScintilla, KDE's Kate, Qt Creator's editor, or grab something else or even write your own.

1 comment:

Anonymous said...

hey,

couldn't compile the example on my ~amd64 gentoo box with gcc-4.4.4

had to edit the jsedit.cpp:410 for it to look like this

#if defined(Q_OS_MAC)
...
#elif defined(Q_OS_UNIX)

instead of the old #ifdef #elif