From b214cef3a8d2d9ecf0df7bef7d10dcdfbca4d9d3 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Tue, 14 Apr 2009 08:18:52 +0000 Subject: Implemented the full OS X navigation support for Fl_Input minus scrolling. Improved navigation on other systems (word fwd, backwd). git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6764 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Input.cxx | 140 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 107 insertions(+), 33 deletions(-) (limited to 'src/Fl_Input.cxx') diff --git a/src/Fl_Input.cxx b/src/Fl_Input.cxx index 71434a25e..1ebda7d85 100644 --- a/src/Fl_Input.cxx +++ b/src/Fl_Input.cxx @@ -140,83 +140,157 @@ int Fl_Input::handle_key() { return 1; } + unsigned int mods = Fl::event_state() & (FL_META|FL_CTRL|FL_ALT); switch (Fl::event_key()) { case FL_Insert: if (Fl::event_state() & FL_CTRL) ascii = ctrl('C'); else if (Fl::event_state() & FL_SHIFT) ascii = ctrl('V'); break; - case FL_Delete: + case FL_Delete: // FIXME if (Fl::event_state() & FL_SHIFT) ascii = ctrl('X'); else ascii = ctrl('D'); break; case FL_Left: - ascii = ctrl('B'); #ifdef __APPLE__ - if (Fl::event_state() & (FL_META|FL_CTRL) ) ascii = ctrl('A'); - // FIXME backward one word is missing (Alt-Left) -#endif // __APPLE__ + if (mods==0) { // char left + ascii = ctrl('B'); + } else if (mods==FL_ALT) { // word left + shift_position(word_start(position())); + return 1; + } else if (mods==FL_CTRL || mods==FL_META) { // start of line + shift_position(line_start(position())); + return 1; + } else return 1; +#else + if (mods==0) { // char left + ascii = ctrl('B'); + } else if (mods==FL_CTRL) { // word left + shift_position(word_start(position())); + return 1; + } else return 1; +#endif break; case FL_Right: - ascii = ctrl('F'); #ifdef __APPLE__ - if (Fl::event_state() & (FL_META|FL_CTRL) ) ascii = ctrl('E'); - // FIXME advance one word is missing (Alt-Right) + if (mods==0) { // char right + ascii = ctrl('F'); + } else if (mods==FL_ALT) { // word right + shift_position(word_end(position())); + return 1; + } else if (mods==FL_CTRL || mods==FL_META) { // end of line + shift_position(line_end(position())); + return 1; + } else return 1; +#else + if (mods==0) { // char right + ascii = ctrl('F'); + } else if (mods==FL_CTRL) { // word right + shift_position(word_end(position())); + return 1; + } else return 1; #endif // __APPLE__ break; - case FL_Page_Up: + case FL_Page_Up: // FIXME fl_font(textfont(),textsize()); //ensure current font is set to ours repeat_num=h()/fl_height(); // number of lines to scroll if (!repeat_num) repeat_num=1; case FL_Up: - ascii = ctrl('P'); #ifdef __APPLE__ - if (Fl::event_state() & (FL_META) ) { - shift_position(0); - return 1; - } - if (Fl::event_state() & (FL_ALT) ) { + if (mods==0) { // line up + ascii = ctrl('P'); + } else if (mods==FL_CTRL) { + return 1; // FIXME scroll text down one page + // FIXME Fl_Inut_ does not support an independent scroll value + // (heck, it doesn't even support a scrollbar - what do you expect ;-) + } else if (mods==FL_ALT) { // line start and up if (line_start(position())==position() && position()>0) return shift_position(line_start(position()-1)) + NORMAL_INPUT_MOVE; else return shift_position(line_start(position())) + NORMAL_INPUT_MOVE; - } -#endif // __APPLE__ + } else if (mods==FL_META) { // start of document + shift_position(0); + return 1; + } else return 1; +#else + if (mods==0) { // line up + ascii = ctrl('P'); + } else if (mods==FL_CTRL) { + return 1; // FIXME scroll text down one line + } else return 1; +#endif break; - case FL_Page_Down: + case FL_Page_Down: // FIXME fl_font(textfont(),textsize()); repeat_num=h()/fl_height(); if (!repeat_num) repeat_num=1; case FL_Down: - ascii = ctrl('N'); #ifdef __APPLE__ - if (Fl::event_state() & (FL_META) ) { - shift_position(size()); - return 1; - } - if (Fl::event_state() & (FL_ALT) ) { + if (mods==0) { // line down + ascii = ctrl('N'); + } else if (mods==FL_CTRL) { + return 1; // FIXME scroll text up one page + } else if (mods==FL_ALT) { // line end and down if (line_end(position())==position() && position()