Class Hierarchy
Fl_Group
|
+----Fl_Editor,
|
+----Fl_MultiEditor
Include Files
#include <FL/Fl_FancyEditor.H>
Description
This is an extension to the basic text editor widget. This one supports
interactive find and replace, an optional status panel display, and other features.
The editor widgets allow you to enter text of any length,
limited by available memory. A number of operations can
be performed on the text, including loading from and saving
to files, cutting and pasting from the clipboard, and
searching and replacing text.
The editor widgets support "CUA-style" keys. That is, in
addition to the normal ASCII keys, the following keys are
recognized by the editor:
Cursor Arrows | Move left, right, up, and down |
Page Up/Down | Move the text up or down one screen |
Ctrl-Home | Move to the first character of the text |
Ctrl-End | Move to the last character of the text |
Home | Move to the start of the current line |
End | Move to the end of the current line |
Ctrl-Left | Move to the start of the previous word |
Ctrl-Right | Move to the start of the next word |
Delete | Delete the character under the cursor. |
Insert | Toggle Insert / Overstrike mode |
Backspace | Delete character to the left of the cursor. |
Shift-Delete or Ctrl-X | Cut selection to clipboard |
Ctrl-Insert or Ctrl-C | Copy selection to clipboard |
Shift-Insert or Ctrl-V | Paste from clipboard |
Mouse | Click for cursor placement
Double-click selects word
Triple-click selects line
Click and drag selects text. |
Shift | hold the Shift key while moving the cursor to select text. |
The editor also has a scrollbar which will automatically appear when the
text being edited is larger than will fit in the visible area. Text is reformatted automatically
when the editor widget is resized.
Also please note that this is NOT presently a "rich text"
editor -- that is, it doesn't support more than one font,
size, or color at a time. This is planned for a future
release, but the present widgets limit you to one font at a
time.
Methods
Creates a new Fl_Editor widget using the given position, size,
and label string. The default boxtype is FL_DOWN_BOX. The widget will
be created to fit within the given dimensions.
Destroys the widget and any value associated with it.
Changes the editor state into or out of "browse mode". In browse mode,
the editor is made read-only, the cursor is hidden, and using the
up/down arrows scrolls the visible text. This is useful for situations where
all you want to do is display some text, but not edit it.
Returns true if there have been any changes to the edited text,
otherwise returns false.
Returns the character count in the editor's buffers. Note that this is NOT
the number of characters to allocate in a buffer to save the text, but rather
the actual number of characters in the editor's buffers. To find the number
of characters to allocate, use
GetTextBuffeSize() instead.
Resets the editor to a "clean slate" -- a blank document, cursor at the start of
the document.
Copy selected text to the clipboard.
Based on the position of the logical cursor in the edit buffer, returns
the top left corner where the cursor image will be drawn on the display.
Cuts selected text to the clipboard.
Redraws the editor. Tries to minimize the area redrawn to only the part that
actually needs drawn.
Used in conjunction with the HandleScroll() routine to redraw while scrolling.
Returns a pointer to the editor engine being driven by the widget. This engine can be driven by
sending it commands (see the header file, editor.hpp for details), and then resynchronized with the editor
widget by calling SyncDisplay() on the widget.
void Fl_Editor::FindCursor()
Positions the logical edit cursor based on a screen position. Returns the position set. If the cursor is outside the
text (for example, a mouse click past the end of the text being edited), both functions will position to the
end of the text and return -1.
Returns the number of characters that would be needed to do a
SaveTo(char *buffer) call on this instance.
(The number returned already includes space for a terminating NULL, so you
don't need to add one to it). If you need
to save the edited text to a buffer, just allocate a buffer of this size and call
SaveTo() with your buffer as an argument.
This is the event handler loop. If you need to subclass and define special event
processing, this is where you'll start.
Checks for whether the widget display contains the logical cursor. If it
doesn't, it is automatically "scrolled" (redrawn) so that the cursor is visible.
Allows for having the cursor shown or hidden, or determining the present state.
Reads a file or buffer, inserting it at the current cursor position.
Paste from the clipboard at the current cursor location. After pasting, the cursor
will be positioned at the end of the inserted text.
Determine whether the edit buffer is read only, and be able to change whether
it is or not.
Displays a "search and replace" dialog where the user can enter a string to
search for and replace with another string. Various options can be set for case
sensitivity, etc., and the user can optionally be asked to confirm each
replacement.
Overrides the standard FLTK resize method. Reformats the text to match the new size.
Saves the entire contents of the editor to the buffer or file specified. Note
that no length checking is done when saving to buffers. You should check your
buffer size against CharacterCount() first.
Get or set the speed at which scroll select operates, in lines per second. The
default is five lines per second.
The editor uses an internal engine that can be manipulated without involving the
user or the display. This function allows for synchronizing the display with the
present editor state after programmatic manipulations.
Gets or sets the color of the text in the input field.
Gets or sets the font of the text in the input field.
Gets or sets the size of the text in the input field.
Returns true if the scroll timer is presently enabled (if the user is drag-selecting and has
moved the mouse outside the bounds of the widget).
Read the word wrap state, or change it. Setting it true turns on word wrap. Setting it
false turns off word wrap, but the cursor still wraps at the margin. (That is, with word
wrap off, when the user hits the margin, the word will split in the middle and typing
will continue on the next line.)