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.
Fl_RichTextDisplay and Fl_RichTextEditor provide the following improvements over the existing FLTK text widgets:
- Undo capability including undo of both text editing and text styling.
- 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.
(Click to view larger)
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 email@example.com.
6/20/14: Beta version 1.2.1b is now available for download. Includes one minor bug fix that restores line thickness to default before exiting the Fl_RichTextDisplay::draw() method.
4/11/14: Beta version 1.2b is now available for download. Includes numerous bug fixes and behavior improvements to text cursor placement and movement.
10/1/12: Beta version 1.1b is now available for download. Includes numerous bug fixes and a new EditorContent class, analogous to the FLTK Fl_Text_Buffer, that can be used to switch contents (i.e., “documents”) within the same editor widget.
9/18/12: Fl_RichTextDisplay and Fl_RichTextEditor v1.0b (beta) are available for download.
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.
Click here to download a zip file containing the source code for v1.2.1b of Fl_RichTextDisplay, Fl_RichTextEditor, and related classes, and code for the demo application.