This is the FLTK text editor widget. More...
#include <Fl_Text_Editor.H>
Classes | |
struct | Key_Binding |
Simple linked list item associating a key/state to a function. More... | |
Public Types | |
typedef int(* | Key_Func )(int key, Fl_Text_Editor *editor) |
Key function binding callback type. | |
Public Member Functions | |
void | add_default_key_bindings (Key_Binding **list) |
Adds all of the default editor key bindings to the specified key binding list. | |
void | add_key_binding (int key, int state, Key_Func f) |
Adds a key of state state with the function f . | |
void | add_key_binding (int key, int state, Key_Func f, Key_Binding **list) |
Adds a key of state state with the function function to an arbitrary key binding list list . | |
Key_Func | bound_key_function (int key, int state) |
Returns the function associated with a key binding. | |
Key_Func | bound_key_function (int key, int state, Key_Binding *list) |
Returns the function associated with a key binding. | |
void | default_key_function (Key_Func f) |
Sets the default key function for unassigned keys. | |
Fl_Text_Editor (int X, int Y, int W, int H, const char *l=0) | |
The constructor creates a new text editor widget. | |
virtual int | handle (int e) |
Event handling. | |
int | insert_mode () |
Gets the current insert mode; if non-zero, new text is inserted before the current cursor position. | |
void | insert_mode (int b) |
Sets the current insert mode; if non-zero, new text is inserted before the current cursor position. | |
void | remove_all_key_bindings () |
Removes all of the key bindings associated with the text editor or list. | |
void | remove_all_key_bindings (Key_Binding **list) |
Removes all of the key bindings associated with the text editor or list. | |
void | remove_key_binding (int key, int state) |
Removes the key binding associated with the key "key" of state "state". | |
void | remove_key_binding (int key, int state, Key_Binding **list) |
Removes the key binding associated with the key key of state state from the Key_Binding list list . | |
Static Public Member Functions | |
static int | kf_backspace (int c, Fl_Text_Editor *e) |
Does a backspace for key 'c' in the current buffer of editor 'e' . | |
static int | kf_c_s_move (int c, Fl_Text_Editor *e) |
Extends the current selection in the direction indicated by control key 'c' in editor 'e' . | |
static int | kf_copy (int c, Fl_Text_Editor *e) |
Does a copy of selected text or the current character in the current buffer of editor 'e' . | |
static int | kf_ctrl_move (int c, Fl_Text_Editor *e) |
Moves the current text cursor in the direction indicated by control key 'c' in editor 'e' . | |
static int | kf_cut (int c, Fl_Text_Editor *e) |
Does a cut of selected text in the current buffer of editor 'e' . | |
static int | kf_default (int c, Fl_Text_Editor *e) |
Inserts the text associated with key 'c' in editor 'e' . | |
static int | kf_delete (int c, Fl_Text_Editor *e) |
Does a delete of selected text or the current character in the current buffer of editor 'e' . | |
static int | kf_down (int c, Fl_Text_Editor *e) |
Moves the text cursor one line down for editor 'e' . | |
static int | kf_end (int c, Fl_Text_Editor *e) |
Moves the text cursor to the end of the current line in editor 'e' . | |
static int | kf_enter (int c, Fl_Text_Editor *e) |
Inserts a newline for key 'c' at the current cursor position in editor 'e' . | |
static int | kf_home (int, Fl_Text_Editor *e) |
Moves the text cursor to the beginning of the current line in editor 'e' . | |
static int | kf_ignore (int c, Fl_Text_Editor *e) |
Ignores the key 'c' in editor 'e' . | |
static int | kf_insert (int c, Fl_Text_Editor *e) |
Toggles the insert mode for editor 'e' . | |
static int | kf_left (int c, Fl_Text_Editor *e) |
Moves the text cursor one character to the left in editor 'e' . | |
static int | kf_m_s_move (int c, Fl_Text_Editor *e) |
Extends the current selection in the direction indicated by meta key 'c' in editor 'e' . | |
static int | kf_meta_move (int c, Fl_Text_Editor *e) |
Moves the current text cursor in the direction indicated by meta key 'c' in editor 'e' . | |
static int | kf_move (int c, Fl_Text_Editor *e) |
Moves the text cursor in the direction indicated by key 'c' in editor 'e' . | |
static int | kf_page_down (int c, Fl_Text_Editor *e) |
Moves the text cursor down one page for editor 'e' . | |
static int | kf_page_up (int c, Fl_Text_Editor *e) |
Moves the text cursor up one page for editor 'e' . | |
static int | kf_paste (int c, Fl_Text_Editor *e) |
Does a paste of selected text in the current buffer of editor 'e' . | |
static int | kf_right (int c, Fl_Text_Editor *e) |
Moves the text cursor one character to the right for editor 'e' . | |
static int | kf_select_all (int c, Fl_Text_Editor *e) |
Selects all text in the current buffer in editor 'e' . | |
static int | kf_shift_move (int c, Fl_Text_Editor *e) |
Extends the current selection in the direction of key 'c' in editor 'e' . | |
static int | kf_undo (int c, Fl_Text_Editor *e) |
Undo last edit in the current buffer of editor 'e' . | |
static int | kf_up (int c, Fl_Text_Editor *e) |
Moves the text cursor one line up for editor 'e' . | |
Protected Member Functions | |
int | handle_key () |
Handles a key press in the editor. | |
void | maybe_do_callback () |
does or does not a callback according to changed() and when() settings | |
Static Protected Attributes | |
static Key_Binding * | global_key_bindings |
Global key binding list. |
This is the FLTK text editor widget.
It allows the user to edit multiple lines of text and supports highlighting and scrolling. The buffer that is displayed in the widget is managed by the Fl_Text_Buffer class.
typedef int(* Fl_Text_Editor::Key_Func)(int key, Fl_Text_Editor *editor) |
Key function binding callback type.
Fl_Text_Editor::Fl_Text_Editor | ( | int | X, | |
int | Y, | |||
int | W, | |||
int | H, | |||
const char * | l = 0 | |||
) |
The constructor creates a new text editor widget.
void Fl_Text_Editor::add_default_key_bindings | ( | Key_Binding ** | list | ) |
Adds all of the default editor key bindings to the specified key binding list.
void Fl_Text_Editor::add_key_binding | ( | int | key, | |
int | state, | |||
Key_Func | f | |||
) | [inline] |
Adds a key
of state state
with the function f
.
void Fl_Text_Editor::add_key_binding | ( | int | key, | |
int | state, | |||
Key_Func | function, | |||
Key_Binding ** | list | |||
) |
Adds a key
of state state
with the function function
to an arbitrary key binding list list
.
This can be used in derived classes to add global key bindings by using the global (static) Key_Binding list Fl_Text_Editor::global_key_bindings.
Key_Func Fl_Text_Editor::bound_key_function | ( | int | key, | |
int | state | |||
) | [inline] |
Returns the function associated with a key binding.
Fl_Text_Editor::Key_Func Fl_Text_Editor::bound_key_function | ( | int | key, | |
int | state, | |||
Key_Binding * | list | |||
) |
Returns the function associated with a key binding.
void Fl_Text_Editor::default_key_function | ( | Key_Func | f | ) | [inline] |
Sets the default key function for unassigned keys.
int Fl_Text_Editor::insert_mode | ( | ) | [inline] |
Gets the current insert mode; if non-zero, new text is inserted before the current cursor position.
Otherwise, new text replaces text at the current cursor position.
void Fl_Text_Editor::insert_mode | ( | int | b | ) | [inline] |
Sets the current insert mode; if non-zero, new text is inserted before the current cursor position.
Otherwise, new text replaces text at the current cursor position.
int Fl_Text_Editor::kf_backspace | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Does a backspace for key 'c'
in the current buffer of editor 'e'
.
Any current selection is deleted. Otherwise, the character left is deleted and the cursor moved. The key value 'c'
is currently unused.
int Fl_Text_Editor::kf_c_s_move | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Extends the current selection in the direction indicated by control key 'c'
in editor 'e'
.
int Fl_Text_Editor::kf_copy | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Does a copy of selected text or the current character in the current buffer of editor 'e'
.
The key value 'c'
is currently unused.
int Fl_Text_Editor::kf_ctrl_move | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Moves the current text cursor in the direction indicated by control key 'c'
in editor 'e'
.
Supported values for 'c' are currently:
FL_Home -- moves the cursor to the beginning of the document FL_End -- moves the cursor to the end of the document FL_Left -- moves the cursor left one word FL_Right -- moves the cursor right one word FL_Up -- scrolls up one line, without moving cursor FL_Down -- scrolls down one line, without moving cursor FL_Page_Up -- moves the cursor to the beginning of the top line on the current page FL_Page_Down -- moves the cursor to the beginning of the last line on the current page
int Fl_Text_Editor::kf_cut | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Does a cut of selected text in the current buffer of editor 'e'
.
The key value 'c'
is currently unused.
int Fl_Text_Editor::kf_default | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Inserts the text associated with key 'c'
in editor 'e'
.
Honors the current selection and insert/overstrike mode.
int Fl_Text_Editor::kf_delete | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Does a delete of selected text or the current character in the current buffer of editor 'e'
.
The key value 'c'
is currently unused.
int Fl_Text_Editor::kf_down | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Moves the text cursor one line down for editor 'e'
.
Same as kf_move(FL_Down, e). The key value 'c'
is currently unused.
int Fl_Text_Editor::kf_end | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Moves the text cursor to the end of the current line in editor 'e'
.
Same as kf_move(FL_End, e). The key value 'c'
is currently unused.
int Fl_Text_Editor::kf_enter | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Inserts a newline for key 'c'
at the current cursor position in editor 'e'
.
The key value 'c'
is currently unused.
int Fl_Text_Editor::kf_home | ( | int | , | |
Fl_Text_Editor * | e | |||
) | [static] |
Moves the text cursor to the beginning of the current line in editor 'e'
.
Same as kf_move(FL_Home, e). The key value 'c'
is currently unused.
int Fl_Text_Editor::kf_ignore | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Ignores the key 'c'
in editor 'e'
.
This method can be used as a keyboard binding to disable a key that might otherwise be handled or entered as text.
An example would be disabling FL_Escape, so that it isn't added to the buffer when invoked by the user.
int Fl_Text_Editor::kf_insert | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Toggles the insert mode for editor 'e'
.
The key value 'c'
is currently unused.
int Fl_Text_Editor::kf_left | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Moves the text cursor one character to the left in editor 'e'
.
Same as kf_move(FL_Left, e). The key value 'c'
is currently unused.
int Fl_Text_Editor::kf_m_s_move | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Extends the current selection in the direction indicated by meta key 'c'
in editor 'e'
.
int Fl_Text_Editor::kf_meta_move | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Moves the current text cursor in the direction indicated by meta key 'c'
in editor 'e'
.
Supported values for 'c' are currently:
int Fl_Text_Editor::kf_move | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Moves the text cursor in the direction indicated by key 'c'
in editor 'e'
.
Supported values for 'c' are currently:
FL_Home -- moves the cursor to the beginning of the current line FL_End -- moves the cursor to the end of the current line FL_Left -- moves the cursor left one character FL_Right -- moves the cursor right one character FL_Up -- moves the cursor up one line FL_Down -- moves the cursor down one line FL_Page_Up -- moves the cursor up one page FL_Page_Down -- moves the cursor down one page
int Fl_Text_Editor::kf_page_down | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Moves the text cursor down one page for editor 'e'
.
Same as kf_move(FL_Page_Down, e). The key value 'c'
is currently unused.
int Fl_Text_Editor::kf_page_up | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Moves the text cursor up one page for editor 'e'
.
Same as kf_move(FL_Page_Up, e). The key value 'c'
is currently unused.
int Fl_Text_Editor::kf_paste | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Does a paste of selected text in the current buffer of editor 'e'
.
Any current selection is replaced with the pasted content. The key value 'c'
is currently unused.
int Fl_Text_Editor::kf_right | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Moves the text cursor one character to the right for editor 'e'
.
Same as kf_move(FL_Right, e). The key value 'c'
is currently unused.
int Fl_Text_Editor::kf_select_all | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Selects all text in the current buffer in editor 'e'
.
The key value 'c'
is currently unused.
int Fl_Text_Editor::kf_shift_move | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Extends the current selection in the direction of key 'c'
in editor 'e'
.
int Fl_Text_Editor::kf_undo | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Undo last edit in the current buffer of editor 'e'
.
Also deselects previous selection. The key value 'c'
is currently unused.
int Fl_Text_Editor::kf_up | ( | int | c, | |
Fl_Text_Editor * | e | |||
) | [static] |
Moves the text cursor one line up for editor 'e'
.
Same as kf_move(FL_Up, e). The key value 'c'
is currently unused.
void Fl_Text_Editor::remove_all_key_bindings | ( | ) | [inline] |
Removes all of the key bindings associated with the text editor or list.
void Fl_Text_Editor::remove_all_key_bindings | ( | Key_Binding ** | list | ) |
Removes all of the key bindings associated with the text editor or list.
void Fl_Text_Editor::remove_key_binding | ( | int | key, | |
int | state | |||
) | [inline] |
Removes the key binding associated with the key "key" of state "state".
void Fl_Text_Editor::remove_key_binding | ( | int | key, | |
int | state, | |||
Key_Binding ** | list | |||
) |
Removes the key binding associated with the key key
of state state
from the Key_Binding list list
.
This can be used in derived classes to remove global key bindings by using the global (static) Key_Binding list Fl_Text_Editor::global_key_bindings.
Key_Binding* Fl_Text_Editor::global_key_bindings [static, protected] |
Global key binding list.
Derived classes can add key bindings for all Fl_Text_Editor widgets by adding a Key_Binding to this list.