From 82eb9509e9e273e8e9e7e584553ccc49f476d4a3 Mon Sep 17 00:00:00 2001 From: Jedidiah Barber Date: Mon, 20 Jan 2025 00:42:19 +1300 Subject: Filled holes in Fl_Text_Editor binding and make key/modifier/shortcut/flag representations more in line with C++ --- src/c_fl_text_editor.cpp | 93 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 89 insertions(+), 4 deletions(-) (limited to 'src/c_fl_text_editor.cpp') diff --git a/src/c_fl_text_editor.cpp b/src/c_fl_text_editor.cpp index d148676..6138cb2 100644 --- a/src/c_fl_text_editor.cpp +++ b/src/c_fl_text_editor.cpp @@ -18,6 +18,17 @@ extern "C" int widget_handle_hook(void * ud, int e); +// Non-friend protected access + +class Friend_Text_Editor : Fl_Text_Editor { +public: + using Fl_Text_Editor::handle_key; + using Fl_Text_Editor::maybe_do_callback; +}; + + + + // Attaching all relevant hooks and friends class My_Text_Editor : public Fl_Text_Editor { @@ -249,15 +260,81 @@ void fl_text_editor_ctrl_shift_up(TEXTEDITOR te) { +void fl_text_editor_meta_home(TEXTEDITOR te) { + Fl_Text_Editor::kf_meta_move(FL_Home, static_cast(te)); +} + +void fl_text_editor_meta_end(TEXTEDITOR te) { + Fl_Text_Editor::kf_meta_move(FL_End, static_cast(te)); +} + +void fl_text_editor_meta_page_down(TEXTEDITOR te) { + Fl_Text_Editor::kf_meta_move(FL_Page_Down, static_cast(te)); +} + +void fl_text_editor_meta_page_up(TEXTEDITOR te) { + Fl_Text_Editor::kf_meta_move(FL_Page_Up, static_cast(te)); +} + +void fl_text_editor_meta_down(TEXTEDITOR te) { + Fl_Text_Editor::kf_meta_move(FL_Down, static_cast(te)); +} + +void fl_text_editor_meta_left(TEXTEDITOR te) { + Fl_Text_Editor::kf_meta_move(FL_Left, static_cast(te)); +} + +void fl_text_editor_meta_right(TEXTEDITOR te) { + Fl_Text_Editor::kf_meta_move(FL_Right, static_cast(te)); +} + +void fl_text_editor_meta_up(TEXTEDITOR te) { + Fl_Text_Editor::kf_meta_move(FL_Up, static_cast(te)); +} + + + + +void fl_text_editor_meta_shift_home(TEXTEDITOR te) { + Fl_Text_Editor::kf_m_s_move(FL_Home, static_cast(te)); +} + +void fl_text_editor_meta_shift_end(TEXTEDITOR te) { + Fl_Text_Editor::kf_m_s_move(FL_End, static_cast(te)); +} + +void fl_text_editor_meta_shift_page_down(TEXTEDITOR te) { + Fl_Text_Editor::kf_m_s_move(FL_Page_Down, static_cast(te)); +} + +void fl_text_editor_meta_shift_page_up(TEXTEDITOR te) { + Fl_Text_Editor::kf_m_s_move(FL_Page_Up, static_cast(te)); +} + +void fl_text_editor_meta_shift_down(TEXTEDITOR te) { + Fl_Text_Editor::kf_m_s_move(FL_Down, static_cast(te)); +} + +void fl_text_editor_meta_shift_left(TEXTEDITOR te) { + Fl_Text_Editor::kf_m_s_move(FL_Left, static_cast(te)); +} + +void fl_text_editor_meta_shift_right(TEXTEDITOR te) { + Fl_Text_Editor::kf_m_s_move(FL_Right, static_cast(te)); +} + +void fl_text_editor_meta_shift_up(TEXTEDITOR te) { + Fl_Text_Editor::kf_m_s_move(FL_Up, static_cast(te)); +} + + + + void fl_text_editor_add_key_binding(TEXTEDITOR te, int k, int s, void * f) { static_cast(te)->add_key_binding (k, s, reinterpret_cast(f)); } -void fl_text_editor_remove_key_binding(TEXTEDITOR te, int k, int s) { - static_cast(te)->remove_key_binding(k, s); -} - void fl_text_editor_remove_all_key_bindings(TEXTEDITOR te) { static_cast(te)->remove_all_key_bindings(); } @@ -310,4 +387,12 @@ int fl_text_editor_handle(TEXTEDITOR te, int e) { return static_cast(te)->Fl_Text_Editor::handle(e); } +int fl_text_editor_handle_key(TEXTEDITOR te) { + return (static_cast(te)->*(&Friend_Text_Editor::handle_key))(); +} + +void fl_text_editor_maybe_do_callback(TEXTEDITOR te) { + (static_cast(te)->*(&Friend_Text_Editor::maybe_do_callback))(); +} + -- cgit