Mercurial > hg > octave-jordi
changeset 21043:e2fdbdd00ef9
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
author | Torsten <ttl@justmail.de> |
---|---|
date | Thu, 07 Jan 2016 20:17:14 +0100 |
parents | 10071454a4ba |
children | 43b498b8c38c |
files | libgui/src/m-editor/file-editor-tab.cc libgui/src/m-editor/file-editor-tab.h |
diffstat | 2 files changed, 8 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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 + } } }
--- 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 ();