Friday, May 24, 2013

Fl_Highlight_Editor, editing widget for FLTK

Last couple of days (and months) I was secretly working on a new widget for text editing under FLTK, Fl_Highlight_Editor.

FLTK is missing a good editing widget with code highlighting capabilities, so I gave it a shot adding some new concepts; not revolutionary, but how many text widgets comes with a scripting language? ;)

Having extensible editing facility, where you can easily add new language support without digging in C/C++ code isn't common. My favorite, Scintilla isn't ready for FLTK (actually there is no available port for FLTK) and all syntax highlighting capabilities are added by subclassing C++ classes. Means, you have to recompile your binary if you want to add or modify something.

So, I tried to find inspiration in editor of all editors, Emacs. Sure, that >50 MB monster isn't model for embedding, but some concepts like small core and everything else written in extensible language sounds quite interesting. By using similar design, widget user can easily remove parts it doesn't like or only add one he/she likes. For example, editing and highlighting support only for language X, where scripts could be embedded in binary (or not).

Scripting language I used is Scheme; better say TinyScheme, which is still the only awesome interpreter I could find, bundled inside 4 files, that doesn't suck. Extensible language (the language which you can extend without digging inside interpreter) where code is data, is a great deal: you can easily experiment with the syntax, have so called configuration files without external libraries or additional code and the best of all, have fun using it.

Initial Fl_Highlight_Editor version comes with modes for C/C++, Python, Scheme and Markdown; not advanced as Emacs modes, but capable enough to highlight known patterns and setup TAB width depending on language. Sure, there is a lot of work, but ultimate goal is to keep the whole package simple, but flexible enough for adding new features.

Happy usage :)

5 comments:

LM said...

Scintilla would make a great base for an FLTK editing widget. Someone was able to port Scintilla to an older version of FLTK ( http://webnomad.altervista.org/dokuwiki/doku.php?id=fl_scintilla ). Am wondering how hard it would be to update it to work with a later version of FLTK.

Sanel Z. said...

AFAIK, that port isn't full FLTK port, but is using Win32 API to load Scintilla code and display it as Win32 component (no FLTK involvement).

Inside Scintilla there is Gtk+ code as sample and out there is Qt port too. How hard would be to support it? Not sure; some time ago I started pure FLTK port, but due other obligations had to stop it. There is substantial work to do it, for sure....

Anonymous said...

There's also an ncurses/pdcurses port of Scintilla: http://foicica.com/scinterm/api/Scinterm.html

I've seen a port for Fox Toolkit as well.

Sanel Z. said...

Thanks for the link! The project looks too interesting to be missed... :)

nimday said...
This comment has been removed by the author.