Mercurial > octave
annotate libgui/src/m-editor/find-dialog.cc @ 27923:bd51beb6205e
update formatting of copyright notices
* Use <https://octave.org/copyright/> instead of
<https://octave.org/COPYRIGHT.html/>.
* For consistency with other comments in the Octave sources, use
C++-style comments for copyright blocks in C and C++ files.
* Use delimiters above and below copyright blocks that are appropriate
for the language used in the file.
* Eliminate extra spacing inside copyright blocks.
* lex.ll (looks_like_copyright): Also allow newlines and carriage
returns before the word "Copyright".
* scripts/mk-doc.pl (gethelp): Also skip empty comment lines.
* bp-table.cc, type.m: Adjust tests.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 08 Jan 2020 11:59:41 -0500 |
parents | 1891570abac8 |
children | 265b386f8b20 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 // Find dialog derived from an example from Qt Toolkit (license below (**)) |
16520
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
2 |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
3 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // Copyright (C) 2009-2020 The Octave Project Developers |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // All rights reserved. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // Contact: Nokia Corporation (qt-info@nokia.com) |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
25 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
26 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
27 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
28 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
29 // ** This file is part of the examples of the Qt Toolkit. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
30 // ** |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
31 // ** $QT_BEGIN_LICENSE:LGPL$ |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
32 // ** Commercial Usage |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
33 // ** Licensees holding valid Qt Commercial licenses may use this file in |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
34 // ** accordance with the Qt Commercial License Agreement provided with the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
35 // ** Software or, alternatively, in accordance with the terms contained in |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
36 // ** a written agreement between you and Nokia. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
37 // ** |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
38 // ** GNU Lesser General Public License Usage |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
39 // ** Alternatively, this file may be used under the terms of the GNU Lesser |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
40 // ** General Public License version 2.1 as published by the Free Software |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
41 // ** Foundation and appearing in the file LICENSE.LGPL included in the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
42 // ** packaging of this file. Please review the following information to |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
43 // ** ensure the GNU Lesser General Public License version 2.1 requirements |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
44 // ** will be met: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
45 // ** |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
46 // ** In addition, as a special exception, Nokia gives you certain additional |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
47 // ** rights. These rights are described in the Nokia Qt LGPL Exception |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
48 // ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
49 // ** |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
50 // ** GNU General Public License Usage |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
51 // ** Alternatively, this file may be used under the terms of the GNU |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
52 // ** General Public License version 3.0 as published by the Free Software |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
53 // ** Foundation and appearing in the file LICENSE.GPL included in the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
54 // ** packaging of this file. Please review the following information to |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
55 // ** ensure the GNU General Public License version 3.0 requirements will be |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
56 // ** met: https://www.gnu.org/copyleft/gpl.html. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
57 // ** |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
58 // ** If you have questions regarding the use of this file, please contact |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
59 // ** Nokia at qt-info@nokia.com. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
60 // ** $QT_END_LICENSE$ |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
61 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
62 //////////////////////////////////////////////////////////////////////// |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
63 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21706
diff
changeset
|
64 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21203
diff
changeset
|
65 # include "config.h" |
15286
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15257
diff
changeset
|
66 #endif |
ae9079bbc627
Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents:
15257
diff
changeset
|
67 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21706
diff
changeset
|
68 #if defined (HAVE_QSCINTILLA) |
15873
7d300b85ee25
allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents:
15368
diff
changeset
|
69 |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22169
diff
changeset
|
70 #include <QCheckBox> |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22169
diff
changeset
|
71 #include <QCheckBox> |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
72 #include <QCompleter> |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22169
diff
changeset
|
73 #include <QDialogButtonBox> |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22169
diff
changeset
|
74 #include <QGridLayout> |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
75 #include <QIcon> |
22250
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22169
diff
changeset
|
76 #include <QLabel> |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22169
diff
changeset
|
77 #include <QLineEdit> |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22169
diff
changeset
|
78 #include <QMessageBox> |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22169
diff
changeset
|
79 #include <QPushButton> |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22169
diff
changeset
|
80 #include <QVBoxLayout> |
2fd4f1a3f4a8
allow building with Qt5 (bug #40252)
John W. Eaton <jwe@octave.org>
parents:
22169
diff
changeset
|
81 |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
82 #include "find-dialog.h" |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
83 #include "gui-preferences-ed.h" |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
84 #include "resource-manager.h" |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
85 #include "octave-qobject.h" |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
86 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
87 namespace octave |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
88 { |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
89 find_dialog::find_dialog (base_qobject& oct_qobj, |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
90 octave_dock_widget *ed, QWidget *p) |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
91 : QDialog (p), m_octave_qobj (oct_qobj), m_editor (ed), |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
92 m_in_sel (false), m_sel_beg (-1), m_sel_end (-1) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
93 { |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
94 setWindowTitle (tr ("Editor: Find and Replace")); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
95 setWindowIcon (QIcon (":/actions/icons/find.png")); |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
96 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
97 _search_label = new QLabel (tr ("Find &what:")); |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
98 _search_line_edit = new QComboBox (this); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
99 _search_line_edit->setToolTip (tr ("Enter text to search for")); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
100 _search_line_edit->setEditable (true); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
101 _search_line_edit->setMaxCount (m_mru_length); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
102 _search_line_edit->completer ()->setCaseSensitivity (Qt::CaseSensitive); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
103 _search_label->setBuddy (_search_line_edit); |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
104 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
105 _replace_label = new QLabel (tr ("Re&place with:")); |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
106 _replace_line_edit = new QComboBox (this); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
107 _replace_line_edit->setToolTip (tr ("Enter new text replacing search hits")); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
108 _replace_line_edit->setEditable (true); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
109 _replace_line_edit->setMaxCount (m_mru_length); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
110 _replace_line_edit->completer ()->setCaseSensitivity (Qt::CaseSensitive); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
111 _replace_label->setBuddy (_replace_line_edit); |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
112 |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
113 int width = QFontMetrics (_search_line_edit->font ()).averageCharWidth(); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
114 _search_line_edit->setFixedWidth (20*width); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
115 _replace_line_edit->setFixedWidth (20*width); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
116 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
117 _case_check_box = new QCheckBox (tr ("Match &case")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
118 _from_start_check_box = new QCheckBox (tr ("Search from &start")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
119 _wrap_check_box = new QCheckBox (tr ("&Wrap while searching")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
120 _wrap_check_box->setChecked (true); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
121 _find_next_button = new QPushButton (tr ("&Find Next")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
122 _find_prev_button = new QPushButton (tr ("Find &Previous")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
123 _replace_button = new QPushButton (tr ("&Replace")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
124 _replace_all_button = new QPushButton (tr ("Replace &All")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
125 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
126 _more_button = new QPushButton (tr ("&More...")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
127 _more_button->setCheckable (true); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
128 _more_button->setAutoDefault (false); |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
129 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
130 _button_box = new QDialogButtonBox (Qt::Vertical); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
131 _button_box->addButton (_find_next_button, QDialogButtonBox::ActionRole); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
132 _button_box->addButton (_find_prev_button, QDialogButtonBox::ActionRole); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
133 _button_box->addButton (_replace_button, QDialogButtonBox::ActionRole); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
134 _button_box->addButton (_replace_all_button, QDialogButtonBox::ActionRole); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
135 _button_box->addButton (_more_button, QDialogButtonBox::ActionRole); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
136 _button_box->addButton (QDialogButtonBox::Close); |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
137 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
138 _extension = new QWidget (this); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
139 _whole_words_check_box = new QCheckBox (tr ("&Whole words")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
140 _regex_check_box = new QCheckBox (tr ("Regular E&xpressions")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
141 _backward_check_box = new QCheckBox (tr ("Search &backward")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
142 _search_selection_check_box = new QCheckBox (tr ("Search se&lection")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
143 _search_selection_check_box->setCheckable (true); |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
144 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
145 connect (_find_next_button, SIGNAL (clicked ()), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
146 this, SLOT (find_next ())); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
147 connect (_find_prev_button, SIGNAL (clicked ()), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
148 this, SLOT (find_prev ())); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
149 connect (_more_button, SIGNAL (toggled (bool)), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
150 _extension, SLOT (setVisible (bool))); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
151 connect (_replace_button, SIGNAL (clicked ()), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
152 this, SLOT (replace ())); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
153 connect (_replace_all_button, SIGNAL (clicked ()), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
154 this, SLOT (replace_all ())); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
155 connect (_backward_check_box, SIGNAL (stateChanged (int)), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
156 this, SLOT (handle_backward_search_changed (int))); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
157 connect (_button_box, SIGNAL (rejected ()), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
158 this, SLOT (close ())); |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
159 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
160 connect (_search_selection_check_box, SIGNAL (stateChanged (int)), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
161 this, SLOT (handle_sel_search_changed (int))); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
162 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
163 QVBoxLayout *extension_layout = new QVBoxLayout (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
164 extension_layout->setMargin (0); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
165 extension_layout->addWidget (_whole_words_check_box); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
166 extension_layout->addWidget (_backward_check_box); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
167 extension_layout->addWidget (_search_selection_check_box); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
168 _extension->setLayout (extension_layout); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
169 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
170 QGridLayout *top_left_layout = new QGridLayout; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
171 top_left_layout->addWidget (_search_label, 1, 1); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
172 top_left_layout->addWidget (_search_line_edit, 1, 2); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
173 top_left_layout->addWidget (_replace_label, 2, 1); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
174 top_left_layout->addWidget (_replace_line_edit, 2, 2); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
175 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
176 QVBoxLayout *left_layout = new QVBoxLayout; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
177 left_layout->addLayout (top_left_layout); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
178 left_layout->insertStretch (1, 5); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
179 left_layout->addWidget (_case_check_box); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
180 left_layout->addWidget (_from_start_check_box); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
181 left_layout->addWidget (_wrap_check_box); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
182 left_layout->addWidget (_regex_check_box); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
183 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
184 QGridLayout *main_layout = new QGridLayout; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
185 main_layout->setSizeConstraint (QLayout::SetFixedSize); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
186 main_layout->addLayout (left_layout, 0, 0); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
187 main_layout->addWidget (_button_box, 0, 1); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
188 main_layout->addWidget (_extension, 1, 0); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
189 setLayout (main_layout); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
190 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
191 _extension->hide (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
192 _find_next_button->setDefault (true); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
193 _find_result_available = false; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
194 _rep_all = 0; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
195 _rep_active = false; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
196 |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
197 // Connect required external signals |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
198 connect (ed, SIGNAL (edit_area_changed (octave_qscintilla*)), |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
199 this, SLOT (update_edit_area (octave_qscintilla*))); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
200 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
201 setWindowModality (Qt::NonModal); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
202 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
203 setAttribute(Qt::WA_ShowWithoutActivating); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
204 setAttribute(Qt::WA_DeleteOnClose); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
205 } |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
206 |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
207 // The edit_area has changed: update relevant data of the file dialog |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
208 void find_dialog::update_edit_area (octave_qscintilla* edit_area) |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
209 { |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
210 _edit_area = edit_area; |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
211 _search_selection_check_box->setEnabled (edit_area->hasSelectedText ()); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
212 |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
213 connect (_edit_area, SIGNAL (copyAvailable (bool)), |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
214 this, SLOT (handle_selection_changed (bool)), |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
215 Qt::UniqueConnection); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
216 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
217 |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
218 void find_dialog::save_settings () |
27089
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
219 { |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
220 resource_manager& rmgr = m_octave_qobj.get_resource_manager (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
221 gui_settings *s = rmgr.get_settings (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
222 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
223 // Save position and fix offset it by the frame geometry |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
224 int fy = 2; |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
225 if (m_editor->isFloating ()) |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
226 fy = 1; |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
227 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
228 int dy = geometry ().y () - frameGeometry ().y (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
229 QPoint dlg_pos = pos (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
230 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
231 m_last_position = QPoint (dlg_pos.x (), dlg_pos.y () + fy*dy); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
232 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
233 s->setValue (ed_fdlg_pos.key, m_last_position); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
234 |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
235 // Is current search/replace text in the mru list? |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
236 mru_update (_search_line_edit); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
237 mru_update (_replace_line_edit); |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
238 |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
239 // Store mru lists |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
240 QStringList mru; |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
241 for (int i = 0; i < _search_line_edit->count (); i++) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
242 mru.append (_search_line_edit->itemText (i)); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
243 s->setValue (ed_fdlg_search.key, mru); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
244 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
245 mru.clear (); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
246 for (int i = 0; i < _replace_line_edit->count (); i++) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
247 mru.append (_replace_line_edit->itemText (i)); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
248 s->setValue (ed_fdlg_replace.key, mru); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
249 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
250 // Store dialog's options |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
251 int opts = 0 |
27089
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
252 + _extension->isVisible () * FIND_DLG_MORE |
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
253 + _case_check_box->isChecked () * FIND_DLG_CASE |
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
254 + _from_start_check_box->isChecked () * FIND_DLG_START |
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
255 + _wrap_check_box->isChecked () * FIND_DLG_WRAP |
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
256 + _regex_check_box->isChecked () * FIND_DLG_REGX |
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
257 + _whole_words_check_box->isChecked () * FIND_DLG_WORDS |
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
258 + _backward_check_box->isChecked () * FIND_DLG_BACK |
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
259 + _search_selection_check_box->isChecked () * FIND_DLG_SEL; |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
260 s->setValue (ed_fdlg_opts.key, opts); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
261 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
262 s->sync (); |
27089
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
263 } |
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
264 |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
265 void find_dialog::restore_settings (QPoint ed_bottom_right) |
27089
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
266 { |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
267 resource_manager& rmgr = m_octave_qobj.get_resource_manager (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
268 gui_settings *s = rmgr.get_settings (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
269 |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
270 // Get mru lists for search and replace text |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
271 QStringList mru = s->value (ed_fdlg_search.key).toStringList (); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
272 while (mru.length () > m_mru_length) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
273 mru.removeLast (); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
274 _search_line_edit->addItems (mru); |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
275 |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
276 mru = s->value (ed_fdlg_replace.key).toStringList (); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
277 while (mru.length () > m_mru_length) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
278 mru.removeLast (); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
279 _replace_line_edit->addItems (mru); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
280 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
281 // Get the dialog's options |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
282 int opts = s->value (ed_fdlg_opts.key, ed_fdlg_opts.def).toInt (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
283 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
284 _extension->setVisible (FIND_DLG_MORE & opts); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
285 _case_check_box->setChecked (FIND_DLG_CASE & opts); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
286 _from_start_check_box->setChecked (FIND_DLG_START & opts); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
287 _wrap_check_box->setChecked (FIND_DLG_WRAP & opts); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
288 _regex_check_box->setChecked (FIND_DLG_REGX & opts); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
289 _whole_words_check_box->setChecked (FIND_DLG_WORDS & opts); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
290 _backward_check_box->setChecked (FIND_DLG_BACK & opts); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
291 _search_selection_check_box->setChecked (FIND_DLG_SEL & opts); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
292 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
293 // Position: lower right of editor's position |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
294 int xp = ed_bottom_right.x () - sizeHint ().width (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
295 int yp = ed_bottom_right.y () - sizeHint ().height (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
296 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
297 m_last_position = s->value (ed_fdlg_pos.key, QPoint (xp,yp)).toPoint (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
298 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
299 move (m_last_position); |
27089
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
300 } |
9326c2258e60
fix visibility of find dialog when editor is docked/undocked (bug #5)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
301 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
302 // set text of "search from start" depending on backward search |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
303 void find_dialog::handle_backward_search_changed (int backward) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
304 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
305 if (backward) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
306 _from_start_check_box->setText (tr ("Search from end")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
307 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
308 _from_start_check_box->setText (tr ("Search from start")); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
309 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
310 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
311 // search text has changed: reset the search |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
312 void find_dialog::handle_search_text_changed (void) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
313 { |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
314 // Return if nothing has changed |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
315 if (_search_line_edit->currentText () == _search_line_edit->itemText (0)) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
316 return; |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
317 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
318 if (_search_selection_check_box->isChecked ()) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
319 _find_result_available = false; |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
320 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
321 mru_update (_search_line_edit); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
322 } |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
323 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
324 // replaced text has changed: reset the search |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
325 void find_dialog::handle_replace_text_changed (void) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
326 { |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
327 // Return if nothing has changed |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
328 if (_replace_line_edit->currentText () |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
329 == _replace_line_edit->itemText (0)) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
330 return; |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
331 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
332 mru_update (_replace_line_edit); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
333 } |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
334 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
335 // Update the mru list |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
336 void find_dialog::mru_update (QComboBox *mru) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
337 { |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
338 // Remove possible empty entries from the mru list |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
339 int index; |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
340 while ((index = mru->findText (QString ())) >= 0) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
341 mru->removeItem (index); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
342 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
343 // Get current text and return if it is empty |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
344 QString text = mru->currentText (); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
345 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
346 if (text.isEmpty ()) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
347 return; |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
348 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
349 // Remove occurrences of the current text in the mru list |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
350 while ((index = mru->findText (text)) >= 0) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
351 mru->removeItem (index); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
352 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
353 // Remove the last entry from the end if the list is full |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
354 if (mru->count () == m_mru_length) |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
355 mru->removeItem (m_mru_length -1); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
356 |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
357 // Insert new item at the beginning and set it as current item |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
358 mru->insertItem (0, text); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
359 mru->setCurrentIndex (0); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
360 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
361 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
362 void find_dialog::handle_sel_search_changed (int selected) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
363 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
364 _from_start_check_box->setEnabled (! selected); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
365 _find_result_available = false; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
366 } |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
367 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
368 void find_dialog::handle_selection_changed (bool has_selected) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
369 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
370 if (_rep_active) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
371 return; |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
372 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
373 _search_selection_check_box->setEnabled (has_selected); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
374 _find_result_available = false; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
375 } |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
376 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
377 // initialize search text with selected text if this is in one single line |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
378 void find_dialog::init_search_text (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
379 { |
26454
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
380 if (_edit_area && _edit_area->hasSelectedText ()) |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
381 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
382 int lbeg, lend, cbeg, cend; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
383 _edit_area->getSelection (&lbeg,&cbeg,&lend,&cend); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
384 if (lbeg == lend) |
27842
e79999c5d782
fix Qt4 build errors (bug #57420)
John W. Eaton <jwe@octave.org>
parents:
27837
diff
changeset
|
385 #if defined (HAVE_QCOMBOBOX_SETCURRENTTEXT) |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
386 _search_line_edit->setCurrentText (_edit_area->selectedText ()); |
27842
e79999c5d782
fix Qt4 build errors (bug #57420)
John W. Eaton <jwe@octave.org>
parents:
27837
diff
changeset
|
387 #else |
e79999c5d782
fix Qt4 build errors (bug #57420)
John W. Eaton <jwe@octave.org>
parents:
27837
diff
changeset
|
388 if (_search_line_edit->isEditable ()) |
e79999c5d782
fix Qt4 build errors (bug #57420)
John W. Eaton <jwe@octave.org>
parents:
27837
diff
changeset
|
389 { |
e79999c5d782
fix Qt4 build errors (bug #57420)
John W. Eaton <jwe@octave.org>
parents:
27837
diff
changeset
|
390 _search_line_edit->setEditText (_edit_area->selectedText ()); |
e79999c5d782
fix Qt4 build errors (bug #57420)
John W. Eaton <jwe@octave.org>
parents:
27837
diff
changeset
|
391 } |
e79999c5d782
fix Qt4 build errors (bug #57420)
John W. Eaton <jwe@octave.org>
parents:
27837
diff
changeset
|
392 else |
e79999c5d782
fix Qt4 build errors (bug #57420)
John W. Eaton <jwe@octave.org>
parents:
27837
diff
changeset
|
393 { |
e79999c5d782
fix Qt4 build errors (bug #57420)
John W. Eaton <jwe@octave.org>
parents:
27837
diff
changeset
|
394 int i = _search_line_edit->findText (_edit_area->selectedText ()); |
e79999c5d782
fix Qt4 build errors (bug #57420)
John W. Eaton <jwe@octave.org>
parents:
27837
diff
changeset
|
395 |
e79999c5d782
fix Qt4 build errors (bug #57420)
John W. Eaton <jwe@octave.org>
parents:
27837
diff
changeset
|
396 if (i > -1) |
e79999c5d782
fix Qt4 build errors (bug #57420)
John W. Eaton <jwe@octave.org>
parents:
27837
diff
changeset
|
397 _search_line_edit->setCurrentIndex (i); |
e79999c5d782
fix Qt4 build errors (bug #57420)
John W. Eaton <jwe@octave.org>
parents:
27837
diff
changeset
|
398 } |
e79999c5d782
fix Qt4 build errors (bug #57420)
John W. Eaton <jwe@octave.org>
parents:
27837
diff
changeset
|
399 #endif |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
400 } |
20445
d3f39abe119b
GUI-Find: keep focus on Find What and select all text when dialog opens
Rafael Monteiro <rafaelgomesmonteiro@gmail.com>
parents:
20181
diff
changeset
|
401 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
402 // set focus to "Find what" and select all text |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
403 _search_line_edit->setFocus (); |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
404 _search_line_edit->lineEdit ()->selectAll (); |
21706
cce4eb3f6f7c
Prevent find dialog defaulting to "replace all" (bug #47561).
Lachlan Andrew <lachlanbis@gmail.com>
parents:
21301
diff
changeset
|
405 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
406 // Default to "find" next time. |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
407 // Otherwise, it defaults to the last action, which may be "replace all". |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
408 _find_next_button->setDefault (true); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
409 } |
15988
38348a6c3db0
gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents:
15873
diff
changeset
|
410 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
411 void find_dialog::find_next (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
412 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
413 find (! _backward_check_box->isChecked ()); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
414 } |
15988
38348a6c3db0
gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents:
15873
diff
changeset
|
415 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
416 void find_dialog::find_prev (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
417 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
418 find (_backward_check_box->isChecked ()); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
419 } |
16520
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
420 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
421 void find_dialog::find (bool forward) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
422 { |
26454
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
423 if (! _edit_area) |
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
424 return; |
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
425 |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
426 handle_search_text_changed (); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
427 |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
428 // line adn col: -1 means search starts at current position |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
429 int line = -1, col = -1; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
430 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
431 bool do_wrap = _wrap_check_box->isChecked (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
432 bool do_forward = forward; |
16511
eee1b78d031f
gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents:
15988
diff
changeset
|
433 |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
434 // Initialize the selection begin and end if it is the first search |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
435 if (! _find_result_available) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
436 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
437 if (_search_selection_check_box->isChecked () |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
438 && _edit_area->hasSelectedText ()) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
439 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
440 int l1, c1, l2, c2; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
441 _edit_area->getSelection (&l1, &c1, &l2, &c2); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
442 |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
443 // Store the position of the selection |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
444 m_sel_beg = _edit_area->positionFromLineIndex (l1, c1); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
445 m_sel_end = _edit_area->positionFromLineIndex (l2, c2); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
446 m_in_sel = true; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
447 } |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
448 else |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
449 m_in_sel = false; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
450 } |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
451 |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
452 // Get the correct line/col for beginning the search |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
453 if (_rep_all) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
454 { |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
455 // Replace All |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
456 if (_rep_all == 1) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
457 { |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
458 // Start at the beginning of file/sel if it is the first try |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
459 if (m_in_sel) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
460 _edit_area->lineIndexFromPosition (m_sel_beg, &line, &col); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
461 else |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
462 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
463 line = 0; |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
464 col = 0; |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
465 } |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
466 } |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
467 do_wrap = false; // Never wrap when replacing all |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
468 } |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
469 else |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
470 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
471 // Normal search (not replace all): calculate start position of |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
472 // search (in file or selection) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
473 if (_from_start_check_box->isChecked () |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
474 || (m_in_sel && (! _find_result_available))) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
475 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
476 // From the beginning or the end of file/sel |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
477 if (do_forward) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
478 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
479 // From the beginning |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
480 if (m_in_sel) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
481 _edit_area->lineIndexFromPosition (m_sel_beg, &line, &col); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
482 else |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
483 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
484 line = 0; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
485 col = 0; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
486 } |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
487 } |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
488 else |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
489 { |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
490 // From the end |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
491 if (m_in_sel) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
492 _edit_area->lineIndexFromPosition (m_sel_end, &line, &col); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
493 else |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
494 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
495 line = _edit_area->lines () - 1; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
496 col = _edit_area->text (line).length () - 1; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
497 if (col == -1) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
498 col = 0; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
499 } |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
500 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
501 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
502 else if (! do_forward) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
503 { |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
504 // Start from where the cursor is. Fix QScintilla's cursor |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
505 // positioning |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
506 _edit_area->getCursorPosition (&line,&col); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
507 if (_find_result_available && _edit_area->hasSelectedText ()) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
508 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
509 int currpos = _edit_area->positionFromLineIndex (line,col); |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
510 currpos -= (_search_line_edit->currentText ().length ()); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
511 if (currpos < 0) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
512 currpos = 0; |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
513 _edit_area->lineIndexFromPosition (currpos, &line, &col); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
514 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
515 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
516 } |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
517 |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
518 // Do the search |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27133
diff
changeset
|
519 _find_result_available |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
520 = _edit_area->findFirst (_search_line_edit->currentText (), |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27133
diff
changeset
|
521 _regex_check_box->isChecked (), |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27133
diff
changeset
|
522 _case_check_box->isChecked (), |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27133
diff
changeset
|
523 _whole_words_check_box->isChecked (), |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27133
diff
changeset
|
524 do_wrap, |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27133
diff
changeset
|
525 do_forward, |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27133
diff
changeset
|
526 line,col, |
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27133
diff
changeset
|
527 true |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
528 #if defined (HAVE_QSCI_VERSION_2_6_0) |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27133
diff
changeset
|
529 , true |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
530 #endif |
27276
7455523fdf01
style fixes: avoid breaking lines immediately after '('
John W. Eaton <jwe@octave.org>
parents:
27133
diff
changeset
|
531 ); |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
532 |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
533 if (_find_result_available) |
26454
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
534 { |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
535 // Search successful: reset search-from-start box and check for |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
536 // the current selection |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
537 _from_start_check_box->setChecked (0); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
538 |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
539 if (m_in_sel) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
540 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
541 _edit_area->getCursorPosition (&line,&col); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
542 int pos = _edit_area->positionFromLineIndex (line, col); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
543 |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
544 int l1, c1, l2, c2; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
545 _edit_area->lineIndexFromPosition (m_sel_beg, &l1, &c1); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
546 _edit_area->lineIndexFromPosition (m_sel_end, &l2, &c2); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
547 _edit_area->show_selection_markers (l1, c1, l2, c2); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
548 |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
549 // Check if new start position is still wihtin the selection |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
550 _find_result_available = pos >= m_sel_beg && pos <= m_sel_end; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
551 } |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
552 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
553 |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
554 // No more search hits |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
555 if (! _find_result_available) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
556 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
557 if (m_in_sel) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
558 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
559 // Restore real selection and remove marker for selection |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
560 int l1, c1, l2, c2; |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
561 _edit_area->lineIndexFromPosition (m_sel_beg, &l1, &c1); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
562 _edit_area->lineIndexFromPosition (m_sel_end, &l2, &c2); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
563 _edit_area->setSelection (l1, c1, l2, c2); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
564 _edit_area->clear_selection_markers (); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
565 } |
26454
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
566 |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
567 // Display message if not replace all |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
568 if (! _rep_all) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
569 no_matches_message (); |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
570 } |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
571 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
572 } |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
573 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
574 void find_dialog::do_replace (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
575 { |
26454
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
576 if (_edit_area) |
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
577 { |
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
578 _rep_active = true; // changes in selection not made by the user |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
579 |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
580 _edit_area->replace (_replace_line_edit->currentText ()); |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
581 if (m_in_sel) |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
582 { |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
583 // Update the length of the selection |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
584 m_sel_end = m_sel_end |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
585 - _search_line_edit->currentText ().toUtf8 ().size () |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
586 + _replace_line_edit->currentText ().toUtf8 ().size (); |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
587 } |
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
588 |
26454
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
589 _rep_active = false; |
aced09cc1721
fix utilize pointer before verifying in find dialog (bug #55347)
Torsten <mttl@mailbox.org>
parents:
26376
diff
changeset
|
590 } |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
591 } |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
592 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
593 void find_dialog::replace (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
594 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
595 if (_edit_area) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
596 { |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
597 handle_replace_text_changed (); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
598 |
27455
e92bab9a7f26
fix editors search and replace in selection (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27127
diff
changeset
|
599 // Do the replace if we have selected text |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
600 if (_find_result_available && _edit_area->hasSelectedText ()) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
601 do_replace (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
602 |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
603 find_next (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
604 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
605 } |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
606 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
607 void find_dialog::replace_all (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
608 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
609 int line, col; |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
610 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
611 if (_edit_area) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
612 { |
27837
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
613 handle_replace_text_changed (); |
6bbff502f89d
add mru lists for search/replace texts in editor find dialog (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27787
diff
changeset
|
614 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
615 _edit_area->getCursorPosition (&line,&col); |
15177
d52bac6b9813
find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15105
diff
changeset
|
616 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
617 _rep_all = 1; |
27893
465ac679e976
Fix typos and grammar errors in comments in libgui (patch #9790)
Andrew Janke <andrew@apjanke.net>
parents:
27842
diff
changeset
|
618 find_next (); // find first occurrence (forward) |
27127
8854d65e3bcc
undo a complete replace all action in the editor (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
619 |
8854d65e3bcc
undo a complete replace all action in the editor (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
620 _edit_area->beginUndoAction (); |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
621 while (_find_result_available) // while search string is found |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
622 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
623 do_replace (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
624 _rep_all++; // inc counter |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
625 find_next (); // find next |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
626 } |
27127
8854d65e3bcc
undo a complete replace all action in the editor (bug #56405)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
26454
diff
changeset
|
627 _edit_area->endUndoAction (); |
18184
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
628 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
629 QMessageBox msg_box (QMessageBox::Information, tr ("Replace Result"), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
630 tr ("%1 items replaced").arg (_rep_all-1), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
631 QMessageBox::Ok, this); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
632 msg_box.exec (); |
18184
5f7f58866922
fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents:
17790
diff
changeset
|
633 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
634 _rep_all = 0; |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
635 _find_result_available = false; |
18854
0a66861d8069
implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents:
18283
diff
changeset
|
636 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
637 if (! _search_selection_check_box->isChecked ()) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
638 _edit_area->setCursorPosition (line,col); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
639 } |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
640 } |
15873
7d300b85ee25
allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents:
15368
diff
changeset
|
641 |
24716
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
642 void find_dialog::no_matches_message (void) |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
643 { |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
644 QMessageBox msg_box (QMessageBox::Information, tr ("Find Result"), |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
645 tr ("No more matches found"), QMessageBox::Ok, this); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
646 msg_box.exec (); |
2b3e0b570e77
move GUI file editor classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
647 } |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
648 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
649 void find_dialog::reject () |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
650 { |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
651 close (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
652 } |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
653 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
654 void find_dialog::closeEvent (QCloseEvent *e) |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
655 { |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
656 save_settings (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
657 e->accept (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
658 } |
16520
086b5e81245b
find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents:
16516
diff
changeset
|
659 |
27787
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
660 // Show and hide with (re-)storing position, otherwise there is always |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
661 // a small shift each time the dialog is shown again |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
662 void find_dialog::set_visible (bool visible) |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
663 { |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
664 if (visible) |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
665 { |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
666 show (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
667 move (m_last_position); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
668 } |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
669 else |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
670 { |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
671 m_last_position = pos (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
672 hide (); |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
673 } |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
674 } |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
675 |
5169ed0ff0f0
only one find dialog for all editor tabs (bug #57238)
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27461
diff
changeset
|
676 } |
15873
7d300b85ee25
allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents:
15368
diff
changeset
|
677 #endif |