diff options
| -rw-r--r-- | FL/Fl_Text_Editor.H | 27 | ||||
| -rw-r--r-- | src/Fl_Text_Editor.cxx | 17 |
2 files changed, 34 insertions, 10 deletions
diff --git a/FL/Fl_Text_Editor.H b/FL/Fl_Text_Editor.H index 44e881a9d..c688f6260 100644 --- a/FL/Fl_Text_Editor.H +++ b/FL/Fl_Text_Editor.H @@ -31,18 +31,18 @@ #define FL_TEXT_EDITOR_ANY_STATE (-1L) /** - 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. + 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. */ class FL_EXPORT Fl_Text_Editor : public Fl_Text_Display { public: - /** Key function binding callback type */ + /** Key function binding callback type. */ typedef int (*Key_Func)(int key, Fl_Text_Editor* editor); - /** Simple linked list associating a key/state to a function */ + /** Simple linked list item associating a key/state to a function. */ struct Key_Binding { int key; ///< the key pressed int state; ///< the state of key modifiers @@ -67,7 +67,7 @@ class FL_EXPORT Fl_Text_Editor : public Fl_Text_Display { int insert_mode() { return insert_mode_; } void add_key_binding(int key, int state, Key_Func f, Key_Binding** list); - /** Adds a key of state "state" with the function "function" */ + /** Adds a \p key of state \p state with the function \p f. */ void add_key_binding(int key, int state, Key_Func f) { add_key_binding(key, state, f, &key_bindings); } void remove_key_binding(int key, int state, Key_Binding** list); @@ -119,7 +119,18 @@ class FL_EXPORT Fl_Text_Editor : public Fl_Text_Display { #ifndef FL_DOXYGEN int insert_mode_; Key_Binding* key_bindings; +#endif + + /** Global key binding list. + + Derived classes can add key bindings for all Fl_Text_Editor widgets + by adding a Key_Binding to this list. + + \see add_key_binding(int key, int state, Key_Func f, Key_Binding** list); + */ static Key_Binding* global_key_bindings; + +#ifndef FL_DOXYGEN Key_Func default_key_function_; #endif }; diff --git a/src/Fl_Text_Editor.cxx b/src/Fl_Text_Editor.cxx index 2854bfa88..891f162bf 100644 --- a/src/Fl_Text_Editor.cxx +++ b/src/Fl_Text_Editor.cxx @@ -192,7 +192,13 @@ void Fl_Text_Editor::remove_all_key_bindings(Key_Binding** list) { *list = 0; } -/** Removes the key binding associated with the key "key" of state "state" */ +/** Removes the key binding associated with the key \p key of state \p state + from the Key_Binding list \p 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. +*/ void Fl_Text_Editor::remove_key_binding(int key, int state, Key_Binding** list) { Key_Binding *cur, *last = 0; for (cur = *list; cur; last = cur, cur = cur->next) @@ -202,7 +208,14 @@ void Fl_Text_Editor::remove_key_binding(int key, int state, Key_Binding** list) else *list = cur->next; delete cur; } -/** Adds a key of state "state" with the function "function" */ + +/** Adds a \p key of state \p state with the function \p function to an + arbitrary key binding list \p 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. +*/ void Fl_Text_Editor::add_key_binding(int key, int state, Key_Func function, Key_Binding** list) { Key_Binding* kb = new Key_Binding; |
