mirror of https://github.com/fltk/fltk
Document Fl_Text_Editor::global_key_bindings and related methods.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10830 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
9bedf7ab8f
commit
0650563c7b
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue