Mercurial > octave
changeset 28365:2969b94cac9f
simplify code for replacing all highlighted occurrences in the editor
* octave-qscintilla.cc (keyPressEvent): remove code which has been
copied into the new methid replace_all which was added for
removing all triling white spaces and add the related function
call
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Mon, 25 May 2020 22:28:38 +0200 |
parents | 44f2d73df4b3 |
children | d4b71e99c2be |
files | libgui/src/m-editor/octave-qscintilla.cc |
diffstat | 1 files changed, 2 insertions(+), 53 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/octave-qscintilla.cc Sun May 24 22:45:29 2020 +0200 +++ b/libgui/src/m-editor/octave-qscintilla.cc Mon May 25 22:28:38 2020 +0200 @@ -1130,59 +1130,8 @@ if (key == Qt::Key_Return && modifiers == Qt::ShiftModifier) { - // get the resulting cursor position - // (required if click was beyond a line ending) - int pos, line, col; - get_current_position (&pos, &line, &col); - - // remember first visible line for restoring the view afterwards - int first_line = firstVisibleLine (); - - // search for first occurrence of the detected word - bool find_result_available - = findFirst (m_selection, - false, // no regexp - true, // case sensitive - true, // whole words only - false, // do not wrap - true, // forward - 0, 0, // from the beginning - false -#if defined (HAVE_QSCI_VERSION_2_6_0) - , true -#endif - ); - - while (find_result_available) - { - replace (m_selection_replacement); - - // FIXME: is this the right thing to do? findNext doesn't - // work properly if the length of the replacement text is - // different from the original. - - int new_line, new_col; - get_current_position (&pos, &new_line, &new_col); - - find_result_available - = findFirst (m_selection, - false, // no regexp - true, // case sensitive - true, // whole words only - false, // do not wrap - true, // forward - new_line, new_col, // from new pos - false -#if defined (HAVE_QSCI_VERSION_2_6_0) - , true -#endif - ); - } - - // restore the visible area of the file, the cursor position, - // and the selection - setFirstVisibleLine (first_line); - setCursorPosition (line, col); + replace_all (m_selection, m_selection_replacement, + false, true, true); // Clear the selection. set_word_selection ();