# HG changeset patch # User Torsten # Date 1452194234 -3600 # Node ID e2fdbdd00ef9ffcb2fb2644853b7c65e574063ef # Parent 10071454a4ba168319c8c15af884152d023922ca center line when setting a breakpoint only if line is at top or at bottom * file-editor-tab.cc (goto_line): use center_current_line with new argument; (center_current_line): new argument whether the line is always centered or only if the line is at the top or at the bottom of the editor window * file-editor-tab.h: center_current_line with boolean parameter diff --git a/libgui/src/m-editor/file-editor-tab.cc b/libgui/src/m-editor/file-editor-tab.cc --- a/libgui/src/m-editor/file-editor-tab.cc +++ b/libgui/src/m-editor/file-editor-tab.cc @@ -1105,7 +1105,7 @@ else // go to given line without dialog _edit_area->setCursorPosition (line-1, 0); - center_current_line (); + center_current_line (false); // only center line if at top or bottom } void @@ -2326,7 +2326,7 @@ void -file_editor_tab::center_current_line () +file_editor_tab::center_current_line (bool always) { long int visible_lines = _edit_area->SendScintilla (QsciScintillaBase::SCI_LINESONSCREEN); @@ -2337,9 +2337,12 @@ _edit_area->getCursorPosition (&line, &index); int first_line = _edit_area->firstVisibleLine (); - first_line = first_line + (line - first_line - (visible_lines-1)/2); - _edit_area->SendScintilla (2613,first_line); // SCI_SETFIRSTVISIBLELINE + if (always || line == first_line || line > first_line + visible_lines - 2) + { + first_line = first_line + (line - first_line - (visible_lines-1)/2); + _edit_area->SendScintilla (2613,first_line); // SCI_SETFIRSTVISIBLELINE + } } } diff --git a/libgui/src/m-editor/file-editor-tab.h b/libgui/src/m-editor/file-editor-tab.h --- a/libgui/src/m-editor/file-editor-tab.h +++ b/libgui/src/m-editor/file-editor-tab.h @@ -240,7 +240,7 @@ void add_breakpoint_callback (const bp_info& info); void remove_breakpoint_callback (const bp_info& info); void remove_all_breakpoints_callback (const bp_info& info); - void center_current_line (); + void center_current_line (bool always=true); void add_octave_apis (octave_value_list key_ovl); QString get_function_name ();