Fl_RichTextDisplay and Fl_RichTextEditor
Fl_RichTextDisplay and Fl_RichTextEditor are text display and editor widgets for use with the Fast Light Toolkit (FLTK), a cross-platform C++ GUI toolkit.
FLTK already includes text display and editor widgets (Fl_Text_Display and Fl_Text_Editor). These widgets provide excellent functionality that will meet most text display and editing needs. But for some applications, they may have a few shortcomings:
- Hyperlinking is not supported.
- Undo capability is very limited.
- Only text styles that are part of the font itself are supported (i.e., bold and italic).
- The developer must write callback functions, called by FLTK whenever text is edited, to update a style buffer that stores the style table index for each character. This increases the complexity and effort of using these widgets for apps that support text styling.
I developed Fl_RichTextDisplay and Fl_RichTextEditor to address these shortcomings.
Features
Fl_RichTextDisplay and Fl_RichTextEditor provide the following improvements over the existing FLTK text widgets:
- Hyperlinking.
- Undo capability including undo of both text editing and text styling.
- Underlining.
- Strikethrough.
- Background color/highlighting.
- No style buffer is used; the classes maintain all style information internally (and provide methods for applications to call to apply styling over specified ranges of text).
But Fl_RichTextDisplay and Fl_RichTextEditor do not do a couple of things as well as the FLTK-provided Fl_Text_Display and Fl_Text_Editor widgets:
- No non-wrapping mode is provided.
- Styling based on syntax (e.g., for a code editor) may be easier to do via Fl_Text_Display's and and Fl_Text_Editor's style buffer approach than by facilities provided by Fl_RichTextDisplay and Fl_RichTextEditor.
Screenshot
Note that the toolbar on the Fl_RichTextEditor widget in the above screenshot is not part of the editor; it is part of the demo application, and uses methods in Fl_RichTextEditor to apply styling, fonts, etc. to selected text.
Status
Fl_RichTextDisplay and Fl_RichTextEditor are currently available as a beta release. I could use some help from my fellow FLTK developers in shaking the bugs out.
Please email all bug reports and feedback to jeffellis1@gmail.com.
System Requirements
Fl_RichTextDisplay and Fl_RichTextEditor were developed specifically for FLTK 1.3.x and may not work with older versions of FLTK.
I also developed them under Windows 7 and have not yet compiled and tested them under Linux.
Download
Click here to download a zip file containing the source code for v1.1b of Fl_RichTextDisplay, Fl_RichTextEditor, and related classes, and code for the demo application.
