diff options
| author | Manolo Gouy <Manolo> | 2016-04-01 14:49:29 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2016-04-01 14:49:29 +0000 |
| commit | 20b00f29ce8097565e329638e19a25ab16a86e16 (patch) | |
| tree | dc8ec8a66f5ec9d428e21feb876e31f02e268ee5 /src | |
| parent | 88ab084e9aea8fa2d5ceeab0b8bc030c02eedf1f (diff) | |
Rewrite Fl_Text_Editor.cxx under the driver model.
Fl_Cocoa_Screen_Driver contains the Mac OS-specific text editor key bindings.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11497 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
| -rw-r--r-- | src/Fl_Screen_Driver.cxx | 2 | ||||
| -rw-r--r-- | src/Fl_Text_Editor.cxx | 37 | ||||
| -rw-r--r-- | src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H | 1 | ||||
| -rw-r--r-- | src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx | 23 |
4 files changed, 35 insertions, 28 deletions
diff --git a/src/Fl_Screen_Driver.cxx b/src/Fl_Screen_Driver.cxx index 09621d6a4..083922c89 100644 --- a/src/Fl_Screen_Driver.cxx +++ b/src/Fl_Screen_Driver.cxx @@ -28,7 +28,7 @@ char Fl_Screen_Driver::fg_set = 0; Fl_Screen_Driver::Fl_Screen_Driver() : -num_screens(-1) +num_screens(-1), text_editor_extra_key_bindings(NULL) { } diff --git a/src/Fl_Text_Editor.cxx b/src/Fl_Text_Editor.cxx index 5e4735866..09435d2e3 100644 --- a/src/Fl_Text_Editor.cxx +++ b/src/Fl_Text_Editor.cxx @@ -26,12 +26,6 @@ #include <FL/Fl_Screen_Driver.H> #include <FL/fl_ask.H> -#if defined(WIN32) || defined(__APPLE__) // PORTME: Fl_Screen_Driver - platform editor -#elif defined(FL_PORTING) -# pragma message "FL_PORTING: add common shortcut for your platform here" -#else -#endif - /* Keyboard Control Matrix key\modifier plain Ctrl Alt Meta @@ -146,24 +140,6 @@ static struct { { 'v', FL_CTRL, Fl_Text_Editor::kf_paste }, { FL_Insert, FL_SHIFT, Fl_Text_Editor::kf_paste }, { 'a', FL_CTRL, Fl_Text_Editor::kf_select_all }, - -#ifdef __APPLE__ // PORTME: Fl_Screen_Driver - platform editor feel - // Define CMD+key accelerators... - { 'z', FL_COMMAND, Fl_Text_Editor::kf_undo }, - { 'x', FL_COMMAND, Fl_Text_Editor::kf_cut }, - { 'c', FL_COMMAND, Fl_Text_Editor::kf_copy }, - { 'v', FL_COMMAND, Fl_Text_Editor::kf_paste }, - { 'a', FL_COMMAND, Fl_Text_Editor::kf_select_all }, - { FL_Left, FL_COMMAND, Fl_Text_Editor::kf_meta_move }, - { FL_Right, FL_COMMAND, Fl_Text_Editor::kf_meta_move }, - { FL_Up, FL_COMMAND, Fl_Text_Editor::kf_meta_move }, - { FL_Down, FL_COMMAND, Fl_Text_Editor::kf_meta_move }, - { FL_Left, FL_COMMAND|FL_SHIFT, Fl_Text_Editor::kf_m_s_move }, - { FL_Right, FL_COMMAND|FL_SHIFT, Fl_Text_Editor::kf_m_s_move }, - { FL_Up, FL_COMMAND|FL_SHIFT, Fl_Text_Editor::kf_m_s_move }, - { FL_Down, FL_COMMAND|FL_SHIFT, Fl_Text_Editor::kf_m_s_move }, -#endif // __APPLE__ // PORTME: Fl_Screen_Driver - platform editor feel - { 0, 0, 0 } }; @@ -175,6 +151,15 @@ void Fl_Text_Editor::add_default_key_bindings(Key_Binding** list) { default_key_bindings[i].func, list); } + Key_Binding *extra_key_bindings = Fl::screen_driver()->text_editor_extra_key_bindings; + if (extra_key_bindings) { // add platform-specific key bindings, if any + for (int i = 0; extra_key_bindings[i].key; i++) { + add_key_binding(extra_key_bindings[i].key, + extra_key_bindings[i].state, + extra_key_bindings[i].function, + list); + } + } } /** Returns the function associated with a key binding.*/ @@ -544,12 +529,10 @@ int Fl_Text_Editor::handle_key() { if (insert_mode()) insert(Fl::event_text()); else overstrike(Fl::event_text()); } -#ifdef __APPLE__ // PORTME: Fl_Screen_Driver - platform compose - if (Fl::compose_state) { + if (Fl::screen_driver()->has_marked_text() && Fl::compose_state) { int pos = this->insert_position(); this->buffer()->select(pos - Fl::compose_state, pos); } -#endif show_insert_position(); set_changed(); if (when()&FL_WHEN_CHANGED) do_callback(); diff --git a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H index 0c0d64566..34bf6b6ce 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H +++ b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.H @@ -53,6 +53,7 @@ protected: static int insertion_point_height; static bool insertion_point_location_is_valid; public: + Fl_Cocoa_Screen_Driver(); // --- display management // --- screen configuration virtual void init(); diff --git a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx index 470aa2c77..6f616cb56 100644 --- a/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx +++ b/src/drivers/Cocoa/Fl_Cocoa_Screen_Driver.cxx @@ -43,6 +43,29 @@ Fl_Screen_Driver *Fl_Screen_Driver::newScreenDriver() return new Fl_Cocoa_Screen_Driver(); } +static Fl_Text_Editor::Key_Binding extra_bindings[] = { + // Define CMD+key accelerators... + { 'z', FL_COMMAND, Fl_Text_Editor::kf_undo ,0}, + { 'x', FL_COMMAND, Fl_Text_Editor::kf_cut ,0}, + { 'c', FL_COMMAND, Fl_Text_Editor::kf_copy ,0}, + { 'v', FL_COMMAND, Fl_Text_Editor::kf_paste ,0}, + { 'a', FL_COMMAND, Fl_Text_Editor::kf_select_all ,0}, + { FL_Left, FL_COMMAND, Fl_Text_Editor::kf_meta_move ,0}, + { FL_Right, FL_COMMAND, Fl_Text_Editor::kf_meta_move ,0}, + { FL_Up, FL_COMMAND, Fl_Text_Editor::kf_meta_move ,0}, + { FL_Down, FL_COMMAND, Fl_Text_Editor::kf_meta_move ,0}, + { FL_Left, FL_COMMAND|FL_SHIFT, Fl_Text_Editor::kf_m_s_move ,0}, + { FL_Right, FL_COMMAND|FL_SHIFT, Fl_Text_Editor::kf_m_s_move ,0}, + { FL_Up, FL_COMMAND|FL_SHIFT, Fl_Text_Editor::kf_m_s_move ,0}, + { FL_Down, FL_COMMAND|FL_SHIFT, Fl_Text_Editor::kf_m_s_move ,0}, + { 0, 0, 0 ,0} +}; + + +Fl_Cocoa_Screen_Driver::Fl_Cocoa_Screen_Driver() { + text_editor_extra_key_bindings = extra_bindings; +} + void Fl_Cocoa_Screen_Driver::init() { |
