jeffreyellis.org

the homepage of Jeffrey Ellis

FLTK

Overview

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.

News

6/17/2019: v2.0 is now available for download.

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 (now provided in v2.0)
  • 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

(Click to view larger)

Status

Please email all bug reports and feedback to jeffellis1@gmail.com.

6/17/19: Version 2.0 is now available for download. Includes a few new features:

  • Word wrap on/off (previous versions were word wrap only)
  • Ability to pair two displays/editors for synchronized scrolling
  • Ability to highlight the corresponding rows in two paired displays/editors (i.e., the row the cursor is currently on)
  • Ability to register a callback to get called whenever the cursor is moved
  • Ability to register a callback to be called as part of the draw() method, so you can add overlays to the text display/editor

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.

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 (v2.0 was developed under Windows 10) and have not yet compiled and tested them under Linux.

Download

Click here to download a zip file containing the source code for v2.0 of Fl_RichTextDisplay, Fl_RichTextEditor, and related classes, and code for the demo application.

Copyright © 2023 by Jeffrey Ellis. All rights reserved. Frontier Theme