From 97b9464f59e87bc33009336b3a5b9b37ae06292e Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Thu, 24 Feb 2005 20:35:07 +0000 Subject: [PATCH] Fl_Multiline_Input now scrolls the full height of the widget instead of 5 lines when the user presses PageUp or PageDown (STR #727) src/Fl_Input.cxx: - Set repeat_num to h()/textsize() instead of 5. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4049 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CHANGES | 3 +++ src/Fl_Input.cxx | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index c254419f8..3c0780446 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ CHANGES IN FLTK 1.1.7 - Documentation fixes (STR #648, STR #692) + - Fl_Multiline_Input now scrolls the full height of the + widget instead of 5 lines when the user presses PageUp + or PageDown (STR #727) - CMake build fixes (STR #724) - Fl_Browser::swap() didn't handle redraws properly when the swapped lines had different heights (STR #729) diff --git a/src/Fl_Input.cxx b/src/Fl_Input.cxx index 690ff3883..5db16f1c9 100644 --- a/src/Fl_Input.cxx +++ b/src/Fl_Input.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Input.cxx,v 1.10.2.15.2.19 2004/04/11 04:38:57 easysw Exp $" +// "$Id$" // // Input widget for the Fast Light Tool Kit (FLTK). // @@ -108,13 +108,15 @@ int Fl_Input::handle_key() { case FL_Right: ascii = ctrl('F'); break; case FL_Page_Up: - repeat_num=5; //temporary hack - //TODO: find number of lines in window and use it instead 5 + 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'); break; case FL_Page_Down: - repeat_num=5; //temporary hack - //TODO: find number of lines in window and use it instead 5 + fl_font(textfont(),textsize()); + repeat_num=h()/fl_height(); + if (!repeat_num) repeat_num=1; case FL_Down: ascii = ctrl('N'); break; case FL_Home: @@ -202,18 +204,20 @@ int Fl_Input::handle_key() { return copy_cuts(); case ctrl('N'): i = position(); + if (line_end(i) >= size()) return NORMAL_INPUT_MOVE; while (repeat_num--) { i = line_end(i); - if (i >= size()) return NORMAL_INPUT_MOVE; + if (i >= size()) break; i++; } shift_up_down_position(i); return 1; case ctrl('P'): i = position(); + if (!line_start(i)) return NORMAL_INPUT_MOVE; while(repeat_num--) { i = line_start(i); - if (!i) return NORMAL_INPUT_MOVE; + if (!i) break; i--; } shift_up_down_position(line_start(i)); @@ -414,5 +418,5 @@ Fl_Input::Fl_Input(int X, int Y, int W, int H, const char *l) } // -// End of "$Id: Fl_Input.cxx,v 1.10.2.15.2.19 2004/04/11 04:38:57 easysw Exp $". +// End of "$Id$". //