From 6c54b06dd8f81a4a593a194e7af4ece8d7310d42 Mon Sep 17 00:00:00 2001 From: Greg Ercolano Date: Sun, 20 Sep 2009 19:24:24 +0000 Subject: Fixes STR #2169: Adds missing cursor movement to OSX: CLOVERLEAF-LEFT move cursor to beginning of line, CLOVERLEAF-RIGHT move cursor to end of line, CLOVERLEAF-UP move to top line CLOVERLEAD-DOWN move to end line ..and SHIFT combos with those will do a 'text selection' equivalents. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6893 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- FL/Fl_Text_Editor.H | 2 ++ src/Fl_Text_Editor.cxx | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/FL/Fl_Text_Editor.H b/FL/Fl_Text_Editor.H index 17d601adc..c9294a457 100644 --- a/FL/Fl_Text_Editor.H +++ b/FL/Fl_Text_Editor.H @@ -103,6 +103,8 @@ class FL_EXPORT Fl_Text_Editor : public Fl_Text_Display { static int kf_shift_move(int c, Fl_Text_Editor* e); static int kf_ctrl_move(int c, Fl_Text_Editor* e); static int kf_c_s_move(int c, Fl_Text_Editor* e); + static int kf_meta_move(int c, Fl_Text_Editor* e); + static int kf_m_s_move(int c, Fl_Text_Editor* e); static int kf_home(int, Fl_Text_Editor* e); static int kf_end(int c, Fl_Text_Editor* e); static int kf_left(int c, Fl_Text_Editor* e); diff --git a/src/Fl_Text_Editor.cxx b/src/Fl_Text_Editor.cxx index bd56eeb6c..567b28a12 100644 --- a/src/Fl_Text_Editor.cxx +++ b/src/Fl_Text_Editor.cxx @@ -156,6 +156,14 @@ static struct { { '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__ { 0, 0, 0 } @@ -352,6 +360,40 @@ int Fl_Text_Editor::kf_ctrl_move(int c, Fl_Text_Editor* e) { return 1; } +/** Moves the current text cursor in the direction indicated by meta key */ +int Fl_Text_Editor::kf_meta_move(int c, Fl_Text_Editor* e) { + if (!e->buffer()->selected()) + e->dragPos = e->insert_position(); + if (c != FL_Up && c != FL_Down) { + e->buffer()->unselect(); + e->show_insert_position(); + } + switch (c) { + case FL_Up: // top of buffer + e->insert_position(0); + e->scroll(0, 0); + break; + case FL_Down: // end of buffer + e->insert_position(e->buffer()->length()); + e->scroll(e->count_lines(0, e->buffer()->length(), 1), 0); + break; + case FL_Left: // beginning of line + e->insert_position(e->buffer()->line_start(e->insert_position())); + break; + case FL_Right: // end of line + e->insert_position(e->buffer()->line_end(e->insert_position())); + break; + } + return 1; +} + +/** Extends the current selection in the direction indicated by meta key c. */ +int Fl_Text_Editor::kf_m_s_move(int c, Fl_Text_Editor* e) { + kf_meta_move(c, e); + fl_text_drag_me(e->insert_position(), e); + return 1; +} + /** Extends the current selection in the direction indicated by control key c. */ int Fl_Text_Editor::kf_c_s_move(int c, Fl_Text_Editor* e) { kf_ctrl_move(c, e); -- cgit v1.2.3