annotate libgui/src/m-editor/find-dialog.cc @ 20445:d3f39abe119b stable

GUI-Find: keep focus on Find What and select all text when dialog opens * find-dialog.cc (init_search_text): set focus and select all text in line edit
author Rafael Monteiro <rafaelgomesmonteiro@gmail.com>
date Mon, 15 Jun 2015 09:15:44 -0400
parents aa36fb998a4d
children 642ce72cf1ab
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
1 /****************************************************************************
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
2
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
3 Find dialog derived from an example from Qt Toolkit (license below (**))
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
4
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19592
diff changeset
5 Copyright (C) 2012-2015 Torsten <ttl@justmail.de>
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
6 Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
7 All rights reserved.
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
8 Contact: Nokia Corporation (qt-info@nokia.com)
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
9
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
10 This file is part of Octave.
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
11
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
12 Octave is free software; you can redistribute it and/or modify it
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
13 under the terms of the GNU General Public License as published by the
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
14 Free Software Foundation; either version 3 of the License, or (at your
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
15 option) any later version.
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
16
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
17 Octave is distributed in the hope that it will be useful, but WITHOUT
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
19 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
20 for more details.
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
21
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
22 You should have received a copy of the GNU General Public License
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
23 along with Octave; see the file COPYING. If not, see
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
24 <http://www.gnu.org/licenses/>.
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
25
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
26 ** This file is part of the examples of the Qt Toolkit.
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
27 **
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
28 ** $QT_BEGIN_LICENSE:LGPL$
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
29 ** Commercial Usage
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
30 ** Licensees holding valid Qt Commercial licenses may use this file in
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
31 ** accordance with the Qt Commercial License Agreement provided with the
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
32 ** Software or, alternatively, in accordance with the terms contained in
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
33 ** a written agreement between you and Nokia.
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
34 **
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
35 ** GNU Lesser General Public License Usage
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
36 ** Alternatively, this file may be used under the terms of the GNU Lesser
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
37 ** General Public License version 2.1 as published by the Free Software
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
38 ** Foundation and appearing in the file LICENSE.LGPL included in the
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
39 ** packaging of this file. Please review the following information to
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
40 ** ensure the GNU Lesser General Public License version 2.1 requirements
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
41 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
42 **
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
43 ** In addition, as a special exception, Nokia gives you certain additional
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
44 ** rights. These rights are described in the Nokia Qt LGPL Exception
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
45 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
46 **
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
47 ** GNU General Public License Usage
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
48 ** Alternatively, this file may be used under the terms of the GNU
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
49 ** General Public License version 3.0 as published by the Free Software
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
50 ** Foundation and appearing in the file LICENSE.GPL included in the
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
51 ** packaging of this file. Please review the following information to
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
52 ** ensure the GNU General Public License version 3.0 requirements will be
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
53 ** met: http://www.gnu.org/copyleft/gpl.html.
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
54 **
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
55 ** If you have questions regarding the use of this file, please contact
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
56 ** Nokia at qt-info@nokia.com.
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
57 ** $QT_END_LICENSE$
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
58 **
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
59 ****************************************************************************/
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
60
15286
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15257
diff changeset
61 #ifdef HAVE_CONFIG_H
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15257
diff changeset
62 #include <config.h>
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15257
diff changeset
63 #endif
ae9079bbc627 Add '#include <config.h>' to C++ files in libgui/src
Rik <rik@octave.org>
parents: 15257
diff changeset
64
15873
7d300b85ee25 allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents: 15368
diff changeset
65 #ifdef HAVE_QSCINTILLA
7d300b85ee25 allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents: 15368
diff changeset
66
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
67 #include <QtGui>
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
68 #include <QIcon>
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
69 #include "find-dialog.h"
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
70
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
71 find_dialog::find_dialog (QsciScintilla* edit_area, QWidget *p)
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15367
diff changeset
72 : QDialog (p)
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
73 {
18283
12291fb903de fix missing translations (bug #41200)
Torsten <ttl@justmail.de>
parents: 18269
diff changeset
74 setWindowTitle (tr ("Find and Replace"));
18261
09ef57c61b3b update some icnons of the gui
Torsten <ttl@justmail.de>
parents: 18257
diff changeset
75 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
76
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
77 _search_label = new QLabel (tr ("Find &what:"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
78 _search_line_edit = new QLineEdit;
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
79 _search_label->setBuddy (_search_line_edit);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
80 _replace_label = new QLabel (tr ("Re&place with:"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
81 _replace_line_edit = new QLineEdit;
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
82 _replace_label->setBuddy (_replace_line_edit);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
83
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
84 _case_check_box = new QCheckBox (tr ("Match &case"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
85 _from_start_check_box = new QCheckBox (tr ("Search from &start"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
86 _wrap_check_box = new QCheckBox (tr ("&Wrap while searching"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
87 _wrap_check_box->setChecked(true);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
88 _find_next_button = new QPushButton (tr ("&Find Next"));
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
89 _find_prev_button = new QPushButton (tr ("Find &Previous"));
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
90 _replace_button = new QPushButton (tr ("&Replace"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
91 _replace_all_button = new QPushButton (tr ("Replace &All"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
92
18257
cae24b7cfaf4 minor fix of text strings and related translations (part of bug #41201)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
93 _more_button = new QPushButton (tr ("&More..."));
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
94 _more_button->setCheckable (true);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
95 _more_button->setAutoDefault (false);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
96
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
97 _button_box = new QDialogButtonBox (Qt::Vertical);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
98 _button_box->addButton (_find_next_button, QDialogButtonBox::ActionRole);
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
99 _button_box->addButton (_find_prev_button, QDialogButtonBox::ActionRole);
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
100 _button_box->addButton (_replace_button, QDialogButtonBox::ActionRole);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
101 _button_box->addButton (_replace_all_button, QDialogButtonBox::ActionRole);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
102 _button_box->addButton (_more_button, QDialogButtonBox::ActionRole);
16516
7af39cc90982 * find-dialog.cc(constructor): add close button to the find dialog
Torsten <ttl@justmail.de>
parents: 16511
diff changeset
103 _button_box->addButton (QDialogButtonBox::Close);
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
104
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
105 _extension = new QWidget (this);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
106 _whole_words_check_box = new QCheckBox (tr ("&Whole words"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
107 _regex_check_box = new QCheckBox (tr ("Regular E&xpressions"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
108 _backward_check_box = new QCheckBox (tr ("Search &backward"));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
109 _search_selection_check_box = new QCheckBox (tr ("Search se&lection"));
18854
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
110 #ifdef HAVE_QSCI_FINDSELECTION
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
111 _search_selection_check_box->setCheckable (true);
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
112 _search_selection_check_box->setEnabled (edit_area->hasSelectedText ());
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
113 #else
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
114 _search_selection_check_box->setCheckable (false);
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
115 _search_selection_check_box->setEnabled (false);
18854
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
116 #endif
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
117
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
118 _edit_area = edit_area;
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
119 connect (_find_next_button, SIGNAL (clicked ()),
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
120 this, SLOT (find_next ()));
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
121 connect (_find_prev_button, SIGNAL (clicked ()),
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
122 this, SLOT (find_prev ()));
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
123 connect (_more_button, SIGNAL (toggled (bool)),
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
124 _extension, SLOT (setVisible (bool)));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
125 connect (_replace_button, SIGNAL (clicked ()),
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
126 this, SLOT (replace ()));
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
127 connect (_replace_all_button, SIGNAL (clicked ()),
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
128 this, SLOT (replace_all ()));
16511
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
129 connect (_backward_check_box, SIGNAL (stateChanged (int)),
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
130 this, SLOT (handle_backward_search_changed (int)));
16516
7af39cc90982 * find-dialog.cc(constructor): add close button to the find dialog
Torsten <ttl@justmail.de>
parents: 16511
diff changeset
131 connect (_button_box, SIGNAL (rejected ()),
7af39cc90982 * find-dialog.cc(constructor): add close button to the find dialog
Torsten <ttl@justmail.de>
parents: 16511
diff changeset
132 this, SLOT (close ()));
18854
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
133 connect (_search_line_edit, SIGNAL (textChanged (QString)),
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
134 this, SLOT (handle_search_text_changed (QString)));
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
135
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
136 #ifdef HAVE_QSCI_FINDSELECTION
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
137 connect (_edit_area, SIGNAL (copyAvailable (bool)),
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
138 this, SLOT (handle_selection_changed (bool)));
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
139 connect (_search_selection_check_box, SIGNAL (stateChanged (int)),
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
140 this, SLOT (handle_sel_search_changed (int)));
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
141 #endif
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
142
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
143 QVBoxLayout *extension_layout = new QVBoxLayout ();
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
144 extension_layout->setMargin (0);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
145 extension_layout->addWidget (_whole_words_check_box);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
146 extension_layout->addWidget (_backward_check_box);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
147 extension_layout->addWidget (_search_selection_check_box);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
148 _extension->setLayout (extension_layout);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
149
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
150 QGridLayout *top_left_layout = new QGridLayout;
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
151 top_left_layout->addWidget (_search_label, 1, 1);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
152 top_left_layout->addWidget (_search_line_edit, 1, 2);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
153 top_left_layout->addWidget (_replace_label, 2, 1);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
154 top_left_layout->addWidget (_replace_line_edit, 2, 2);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
155
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
156 QVBoxLayout *left_layout = new QVBoxLayout;
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
157 left_layout->addLayout (top_left_layout);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
158 left_layout->insertStretch (1, 5);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
159 left_layout->addWidget (_case_check_box);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
160 left_layout->addWidget (_from_start_check_box);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
161 left_layout->addWidget (_wrap_check_box);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
162 left_layout->addWidget (_regex_check_box);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
163
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
164 QGridLayout *main_layout = new QGridLayout;
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
165 main_layout->setSizeConstraint (QLayout::SetFixedSize);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
166 main_layout->addLayout (left_layout, 0, 0);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
167 main_layout->addWidget (_button_box, 0, 1);
16516
7af39cc90982 * find-dialog.cc(constructor): add close button to the find dialog
Torsten <ttl@justmail.de>
parents: 16511
diff changeset
168 main_layout->addWidget (_extension, 1, 0);
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
169 setLayout (main_layout);
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
170
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
171 _extension->hide ();
16516
7af39cc90982 * find-dialog.cc(constructor): add close button to the find dialog
Torsten <ttl@justmail.de>
parents: 16511
diff changeset
172 _find_next_button->setDefault (true);
16511
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
173 _find_result_available = false;
18184
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
174 _rep_all = 0;
18854
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
175 _rep_active = false;
16511
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
176
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17007
diff changeset
177 // move dialog to side of the parent if there is room on the desktop to do so.
19441
521d4959fc42 fix positioning issues of editor find dialog (bug #43174)
Torsten <ttl@justmail.de>
parents: 18854
diff changeset
178 int xp = p->x () +20;
521d4959fc42 fix positioning issues of editor find dialog (bug #43174)
Torsten <ttl@justmail.de>
parents: 18854
diff changeset
179 int yp = p->y () + p->frameGeometry ().height () - sizeHint ().height () -20;
521d4959fc42 fix positioning issues of editor find dialog (bug #43174)
Torsten <ttl@justmail.de>
parents: 18854
diff changeset
180
521d4959fc42 fix positioning issues of editor find dialog (bug #43174)
Torsten <ttl@justmail.de>
parents: 18854
diff changeset
181 if (yp < 0)
521d4959fc42 fix positioning issues of editor find dialog (bug #43174)
Torsten <ttl@justmail.de>
parents: 18854
diff changeset
182 yp = 0;
17007
c2e43dd6eb70 Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents: 16736
diff changeset
183
c2e43dd6eb70 Dont display find dialog out of desktop bounds (bug #39518)
John Donoghue <john.donoghue@ieee.org>
parents: 16736
diff changeset
184 move (xp, yp);
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
185
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
186 }
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
187
16511
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
188 // set text of "search from start" depending on backward search
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
189 void
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
190 find_dialog::handle_backward_search_changed (int backward)
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
191 {
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
192 if (backward)
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
193 _from_start_check_box->setText (tr ("Search from end"));
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
194 else
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
195 _from_start_check_box->setText (tr ("Search from start"));
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
196 }
15988
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
197
18854
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
198 // search text has changed: reset the search
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
199 void
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
200 find_dialog::handle_search_text_changed (QString)
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
201 {
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
202 if (_search_selection_check_box->isChecked ())
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
203 _find_result_available = false;
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
204 }
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
205
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
206 #ifdef HAVE_QSCI_FINDSELECTION
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
207 void
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
208 find_dialog::handle_sel_search_changed (int selected)
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
209 {
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
210 _from_start_check_box->setEnabled (! selected);
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
211 _find_result_available = false;
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
212 }
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
213
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
214 void
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
215 find_dialog::handle_selection_changed (bool has_selected)
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
216 {
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
217 if (_rep_active)
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
218 return;
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
219
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
220 _search_selection_check_box->setEnabled (has_selected);
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
221 _find_result_available = false;
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
222 if (! has_selected)
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
223 _search_selection_check_box->setChecked (false);
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
224 }
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
225 #endif
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
226
15988
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
227 // initialize search text with selected text if this is in one single line
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
228 void
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
229 find_dialog::init_search_text ()
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
230 {
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
231 if (_edit_area->hasSelectedText ())
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
232 {
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
233 int lbeg, lend, cbeg, cend;
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
234 _edit_area->getSelection(&lbeg,&cbeg,&lend,&cend);
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
235 if (lbeg == lend)
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
236 _search_line_edit->setText (_edit_area->selectedText ());
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
237 }
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
238
d3f39abe119b GUI-Find: keep focus on Find What and select all text when dialog opens
Rafael Monteiro <rafaelgomesmonteiro@gmail.com>
parents: 20181
diff changeset
239 // set focus to "Find what" and select all text
d3f39abe119b GUI-Find: keep focus on Find What and select all text when dialog opens
Rafael Monteiro <rafaelgomesmonteiro@gmail.com>
parents: 20181
diff changeset
240 _search_line_edit->setFocus();
d3f39abe119b GUI-Find: keep focus on Find What and select all text when dialog opens
Rafael Monteiro <rafaelgomesmonteiro@gmail.com>
parents: 20181
diff changeset
241 _search_line_edit->selectAll();
15988
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
242 }
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
243
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
244 void
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
245 find_dialog::find_next ()
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
246 {
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
247 find (!_backward_check_box->isChecked ());
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
248 }
15988
38348a6c3db0 gui: initialize search text in the find dialog with selected text in editor file
Torsten <ttl@justmail.de>
parents: 15873
diff changeset
249
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
250 void
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
251 find_dialog::find_prev ()
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
252 {
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
253 find (_backward_check_box->isChecked ());
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
254 }
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
255
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
256 void
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
257 find_dialog::find (bool forward)
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
258 {
18101
36063e43c511 Follow coding convention of defining and initializing only 1 variable per line in libgui.
Rik <rik@octave.org>
parents: 17790
diff changeset
259 int line, col;
36063e43c511 Follow coding convention of defining and initializing only 1 variable per line in libgui.
Rik <rik@octave.org>
parents: 17790
diff changeset
260 line = col = -1;
16511
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
261 bool do_wrap = _wrap_check_box->isChecked ();
18184
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
262 bool do_forward = forward;
16511
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
263
18184
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
264 if (_rep_all)
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
265 {
18184
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
266 if (_rep_all == 1)
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
267 {
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
268 line = 0;
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
269 col = 0;
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
270 }
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
271 do_wrap = false;
18854
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
272 // The following line is a workaround for the issue that when replacing
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
273 // a text with a new one with different size within the selection,
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
274 // the selection is not updated leading to missing or extra replacements.
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
275 // This does not happen, when the selection is search backwards
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
276 do_forward = ! _search_selection_check_box->isChecked ();
18184
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
277 }
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
278 else
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
279 {
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
280 if (_from_start_check_box->isChecked ())
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
281 {
18854
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
282 if (do_forward)
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
283 {
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
284 line = 0;
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
285 col = 0;
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
286 }
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
287 else
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
288 {
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
289 line = _edit_area->lines () - 1;
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
290 col = _edit_area->text (line).length () - 1;
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
291 if (col == -1)
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
292 col = 0;
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
293 }
18184
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
294 }
19532
b0ba6653305a find_dialog: search from previous character position when searching backward (Bug #43917)
John Donoghue <john.donoghue@ieee.org>
parents: 19441
diff changeset
295 else if (! do_forward)
b0ba6653305a find_dialog: search from previous character position when searching backward (Bug #43917)
John Donoghue <john.donoghue@ieee.org>
parents: 19441
diff changeset
296 {
19912
b8ce2f42815c gui: when search backward, start from beginning of previous text (Bug #44439)
John D
parents: 19697
diff changeset
297 // search from position before search characters text length
b8ce2f42815c gui: when search backward, start from beginning of previous text (Bug #44439)
John D
parents: 19697
diff changeset
298 // if search backward on existing results,
19587
7bb80c927af5 fix cursor positioning when searching backwards (bug #44039)
Torsten <ttl@justmail.de>
parents: 19532
diff changeset
299 _edit_area->getCursorPosition (&line,&col);
19912
b8ce2f42815c gui: when search backward, start from beginning of previous text (Bug #44439)
John D
parents: 19697
diff changeset
300 if (_find_result_available && _edit_area->hasSelectedText ())
b8ce2f42815c gui: when search backward, start from beginning of previous text (Bug #44439)
John D
parents: 19697
diff changeset
301 {
b8ce2f42815c gui: when search backward, start from beginning of previous text (Bug #44439)
John D
parents: 19697
diff changeset
302 int currpos = _edit_area->positionFromLineIndex(line,col);
b8ce2f42815c gui: when search backward, start from beginning of previous text (Bug #44439)
John D
parents: 19697
diff changeset
303 currpos -= (_search_line_edit->text ().length ());
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 19912
diff changeset
304 if (currpos < 0)
19912
b8ce2f42815c gui: when search backward, start from beginning of previous text (Bug #44439)
John D
parents: 19697
diff changeset
305 currpos = 0;
b8ce2f42815c gui: when search backward, start from beginning of previous text (Bug #44439)
John D
parents: 19697
diff changeset
306 _edit_area->lineIndexFromPosition(currpos, &line,&col);
b8ce2f42815c gui: when search backward, start from beginning of previous text (Bug #44439)
John D
parents: 19697
diff changeset
307 }
19532
b0ba6653305a find_dialog: search from previous character position when searching backward (Bug #43917)
John Donoghue <john.donoghue@ieee.org>
parents: 19441
diff changeset
308 }
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
309 }
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
310
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
311 if (_edit_area)
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
312 {
18854
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
313 if (_edit_area->hasSelectedText ()
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
314 && _search_selection_check_box->isChecked ())
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
315 {
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
316 #ifdef HAVE_QSCI_FINDSELECTION
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
317 if (_find_result_available)
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
318 _find_result_available = _edit_area->findNext ();
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
319 else
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
320 _find_result_available
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
321 = _edit_area->findFirstInSelection (
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
322 _search_line_edit->text (),
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
323 _regex_check_box->isChecked (),
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
324 _case_check_box->isChecked (),
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
325 _whole_words_check_box->isChecked (),
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
326 do_forward,
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
327 true
16736
68ca4122e568 * find-dialog.cc(find): fix ifdef for qscintilla version according to cset 16733
Torsten <ttl@justmail.de>
parents: 16520
diff changeset
328 #ifdef HAVE_QSCI_VERSION_2_6_0
18854
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
329 , true
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
330 #endif
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
331 );
15257
7ee62f559a73 Fix compilation under Windows with GUI and LLVM enabled.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15196
diff changeset
332 #endif
18854
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
333 }
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
334 else
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
335 {
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
336 _find_result_available
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
337 = _edit_area->findFirst (_search_line_edit->text (),
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
338 _regex_check_box->isChecked (),
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
339 _case_check_box->isChecked (),
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
340 _whole_words_check_box->isChecked (),
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
341 do_wrap,
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
342 do_forward,
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
343 line,col,
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
344 true
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
345 #ifdef HAVE_QSCI_VERSION_2_6_0
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
346 , true
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
347 #endif
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
348 );
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
349 }
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
350 }
18854
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
351
16511
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
352 if (_find_result_available)
eee1b78d031f gui: fix backward search in find dialog
Torsten <ttl@justmail.de>
parents: 15988
diff changeset
353 _from_start_check_box->setChecked (0);
18184
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
354 else if (! _rep_all)
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
355 no_matches_message ();
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
356 }
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
357
18854
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
358 void
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
359 find_dialog::do_replace ()
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
360 {
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
361 _rep_active = true; // changes in selection not made by the user
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
362 _edit_area->replace (_replace_line_edit->text ());
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
363 _rep_active = false;
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
364 }
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
365
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
366 void
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
367 find_dialog::replace ()
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
368 {
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
369 if (_edit_area)
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
370 {
18854
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
371 // The following line is a workaround for the issue that when replacing
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
372 // a text with a new one with different size within the selection,
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
373 // the selection is not updated leading to missing or extra replacements.
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
374 // This does not happen, when the selection is search backwards
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
375 if (_search_selection_check_box->isChecked ())
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
376 _backward_check_box->setChecked (true);
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
377
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
378 // do the replace if we have selected text
18184
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
379 if (_find_result_available && _edit_area->hasSelectedText ())
18854
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
380 do_replace ();
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
381
18184
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
382 find_next ();
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
383 }
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
384 }
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
385
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
386 void
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
387 find_dialog::replace_all ()
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
388 {
18184
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
389 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
390
18184
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
391 if (_edit_area)
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
392 {
18184
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
393 _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
394
18184
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
395 _rep_all = 1;
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
396 find_next (); // find first occurence (forward)
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
397 while (_find_result_available) // while search string is found
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
398 {
18854
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
399 do_replace ();
18184
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
400 _rep_all++; // inc counter
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
401 find_next (); // find next
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
402 }
18184
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
403
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
404 QMessageBox msg_box (QMessageBox::Information, tr ("Replace Result"),
18184
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
405 tr ("%1 items replaced").arg(_rep_all-1),
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
406 QMessageBox::Ok, this);
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
407 msg_box.exec ();
18184
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
408
5f7f58866922 fix search and replace all in find dialog (bug #41051)
Torsten <ttl@justmail.de>
parents: 17790
diff changeset
409 _rep_all = 0;
18854
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
410 _find_result_available = false;
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
411
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
412 if (! _search_selection_check_box->isChecked ())
0a66861d8069 implementation of search in selection in gui editor (bbug #41196)
Torsten <ttl@justmail.de>
parents: 18283
diff changeset
413 _edit_area->setCursorPosition (line,col);
15177
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
414 }
d52bac6b9813 find-dialog.{h,cc}: Get rid of DOS newlines
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15105
diff changeset
415 }
15873
7d300b85ee25 allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents: 15368
diff changeset
416
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
417 void
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
418 find_dialog::no_matches_message ()
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
419 {
17790
86c6ae5f969e Use GNU style coding conventions for code in libgui/
Rik <rik@octave.org>
parents: 17007
diff changeset
420 QMessageBox msg_box (QMessageBox::Information, tr ("Find Result"),
16520
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
421 tr ("No more matches found"), QMessageBox::Ok, this);
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
422 msg_box.exec ();
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
423 }
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
424
086b5e81245b find-dialog: find previous button and initial position next to the editor
Torsten <ttl@justmail.de>
parents: 16516
diff changeset
425
15873
7d300b85ee25 allow build to proceed if either Qt or QScintilla is missing
John W. Eaton <jwe@octave.org>
parents: 15368
diff changeset
426 #endif