eric6/QScintilla/SearchReplaceWidget.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7781
607a6098cb44
child 8129
52c76e6cb35b
permissions
-rw-r--r--

Updated copyright for 2021.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2008 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the search and replace widget.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
4068
cb91ccf0104d Fixed another issue with the editor search bar and replace bar related to resizing upon usage of large fonts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4061
diff changeset
10 from PyQt5.QtCore import pyqtSignal, Qt, pyqtSlot, QEvent
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
11 from PyQt5.QtWidgets import (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
12 QWidget, QHBoxLayout, QToolButton, QScrollArea, QSizePolicy, QFrame
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
13 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
486
e4711a55e482 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 482
diff changeset
15 from .Editor import Editor
e4711a55e482 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 482
diff changeset
16
143
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
17 from E5Gui.E5Action import E5Action
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
18 from E5Gui import E5MessageBox
143
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
19
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 import Preferences
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 import UI.PixmapCache
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
24
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 class SearchReplaceWidget(QWidget):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Class implementing the search and replace widget.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
501
5c615a85241a Finished porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 500
diff changeset
29 @signal searchListChanged() emitted to indicate a change of the search list
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
31 searchListChanged = pyqtSignal()
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
32
2362
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
33 def __init__(self, replace, vm, parent=None, sliding=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 @param replace flag indicating a replace widget is called
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 @param vm reference to the viewmanager object
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 @param parent parent widget of this widget (QWidget)
2362
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
40 @param sliding flag indicating the widget is embedded in the
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
41 sliding widget (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2409
diff changeset
43 super(SearchReplaceWidget, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
45 self.__viewmanager = vm
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
46 self.__isMiniEditor = vm is parent
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
47 self.__replace = replace
2362
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
48 self.__sliding = sliding
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
49 if sliding:
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
50 self.__topWidget = parent
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.findHistory = vm.getSRHistory('search')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 if replace:
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2375
diff changeset
54 from .Ui_ReplaceWidget import Ui_ReplaceWidget
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 self.replaceHistory = vm.getSRHistory('replace')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.ui = Ui_ReplaceWidget()
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
57 whatsThis = self.tr(
6571
feb72cfc7807 Editor: fixed am issue related to replacing found text using a match and fixed some typos in some help text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6116
diff changeset
58 """<b>Find and Replace</b>
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
59 <p>This dialog is used to find some text and replace it with another text.
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
60 By checking the various checkboxes, the search can be made more specific.
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
61 The search string might be a regular expression. In a regular expression,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
62 special characters interpreted are:</p>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 else:
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2375
diff changeset
66 from .Ui_SearchWidget import Ui_SearchWidget
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 self.ui = Ui_SearchWidget()
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
68 whatsThis = self.tr(
6571
feb72cfc7807 Editor: fixed am issue related to replacing found text using a match and fixed some typos in some help text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6116
diff changeset
69 """<b>Find</b>
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
70 <p>This dialog is used to find some text. By checking the various checkboxes,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
71 the search can be made more specific. The search string might be a regular
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
72 expression. In a regular expression, special characters interpreted are:</p>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 self.ui.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 if not replace:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.ui.wrapCheckBox.setChecked(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
79 whatsThis += self.tr(
6571
feb72cfc7807 Editor: fixed am issue related to replacing found text using a match and fixed some typos in some help text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6116
diff changeset
80 """<table border="0">
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 <tr><td><code>.</code></td><td>Matches any character</td></tr>
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6571
diff changeset
82 <tr><td><code>(</code></td><td>This marks the start of a region for tagging a
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
83 match.</td></tr>
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6571
diff changeset
84 <tr><td><code>)</code></td><td>This marks the end of a tagged region.
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
85 </td></tr>
1232
ed31e909cf2e Harmonisation of some display strings related to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
86 <tr><td><code>\\n</code></td>
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
87 <td>Where <code>n</code> is 1 through 9 refers to the first through ninth
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
88 tagged region when replacing. For example, if the search string was
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6571
diff changeset
89 <code>Fred([1-9])XXX</code> and the replace string was
6571
feb72cfc7807 Editor: fixed am issue related to replacing found text using a match and fixed some typos in some help text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6116
diff changeset
90 <code>Sam\\1YYY</code>, when applied to <code>Fred2XXX</code> this would
feb72cfc7807 Editor: fixed am issue related to replacing found text using a match and fixed some typos in some help text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6116
diff changeset
91 generate <code>Sam2YYY</code>.</td></tr>
feb72cfc7807 Editor: fixed am issue related to replacing found text using a match and fixed some typos in some help text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6116
diff changeset
92 <tr><td><code>\\&lt;</code></td>
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
93 <td>This matches the start of a word using Scintilla's definitions of words.
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
94 </td></tr>
6571
feb72cfc7807 Editor: fixed am issue related to replacing found text using a match and fixed some typos in some help text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6116
diff changeset
95 <tr><td><code>\\&gt;</code></td>
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
96 <td>This matches the end of a word using Scintilla's definition of words.
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
97 </td></tr>
1232
ed31e909cf2e Harmonisation of some display strings related to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
98 <tr><td><code>\\x</code></td>
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
99 <td>This allows you to use a character x that would otherwise have a special
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
100 meaning. For example, \\[ would be interpreted as [ and not as the start of a
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
101 character set.</td></tr>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 <tr><td><code>[...]</code></td>
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
103 <td>This indicates a set of characters, for example, [abc] means any of the
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
104 characters a, b or c. You can also use ranges, for example [a-z] for any lower
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
105 case character.</td></tr>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 <tr><td><code>[^...]</code></td>
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
107 <td>The complement of the characters in the set. For example, [^A-Za-z] means
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
108 any character except an alphabetic character.</td></tr>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 <tr><td><code>^</code></td>
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
110 <td>This matches the start of a line (unless used inside a set, see above).
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
111 </td></tr>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 <tr><td><code>$</code></td> <td>This matches the end of a line.</td></tr>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 <tr><td><code>*</code></td>
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
114 <td>This matches 0 or more times. For example, <code>Sa*m</code> matches
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
115 <code>Sm</code>, <code>Sam</code>, <code>Saam</code>, <code>Saaam</code>
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
116 and so on.</td></tr>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 <tr><td><code>+</code></td>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 <td>This matches 1 or more times. For example, <code>Sa+m</code> matches
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 <code>Sam</code>, <code>Saam</code>, <code>Saaam</code> and so on.</td></tr>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 </table>
6841
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
121 <p>When using the Extended (C++11) regular expression mode more features are
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
122 available, generally similar to regular expression support in JavaScript. See
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
123 the documentation of your C++ runtime for details on what is supported.<p>
4435
9f6555d3c3c0 Fixed some code style issues and removed code no longer needed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4304
diff changeset
124 """
9f6555d3c3c0 Fixed some code style issues and removed code no longer needed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4304
diff changeset
125 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 self.setWhatsThis(whatsThis)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
128 # set icons
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
129 self.ui.closeButton.setIcon(UI.PixmapCache.getIcon("close"))
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
130 self.ui.findPrevButton.setIcon(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
131 UI.PixmapCache.getIcon("1leftarrow"))
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
132 self.ui.findNextButton.setIcon(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
133 UI.PixmapCache.getIcon("1rightarrow"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 if replace:
1527
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
136 self.ui.replaceButton.setIcon(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
137 UI.PixmapCache.getIcon("editReplace"))
1527
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
138 self.ui.replaceSearchButton.setIcon(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
139 UI.PixmapCache.getIcon("editReplaceSearch"))
1527
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
140 self.ui.replaceAllButton.setIcon(
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
141 UI.PixmapCache.getIcon("editReplaceAll"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
143 # set line edit completers
3685
7c83da3cc0bf Set autocompletion for comboboxes in search widgets to off.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
144 self.ui.findtextCombo.setCompleter(None)
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
145 self.ui.findtextCombo.lineEdit().returnPressed.connect(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
146 self.__findByReturnPressed)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 if replace:
3685
7c83da3cc0bf Set autocompletion for comboboxes in search widgets to off.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
148 self.ui.replacetextCombo.setCompleter(None)
482
4650a72c307a Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
149 self.ui.replacetextCombo.lineEdit().returnPressed.connect(
4650a72c307a Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
150 self.on_replaceButton_clicked)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
152 # define actions
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
153 self.findNextAct = E5Action(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
154 self.tr('Find Next'),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
155 self.tr('Find Next'),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
156 0, 0, self, 'search_widget_find_next')
3345
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
157 self.findNextAct.triggered.connect(self.on_findNextButton_clicked)
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
158 self.findNextAct.setShortcutContext(Qt.WidgetWithChildrenShortcut)
143
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
159
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
160 self.findPrevAct = E5Action(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
161 self.tr('Find Prev'),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
162 self.tr('Find Prev'),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
163 0, 0, self, 'search_widget_find_prev')
3345
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
164 self.findPrevAct.triggered.connect(self.on_findPrevButton_clicked)
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
165 self.findPrevAct.setShortcutContext(Qt.WidgetWithChildrenShortcut)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
166
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
167 if replace:
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
168 self.replaceAndSearchAct = E5Action(
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
169 self.tr("Replace and Search"),
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
170 self.tr("Replace and Search"),
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
171 0, 0, self, "replace_widget_replace_search")
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
172 self.replaceAndSearchAct.triggered.connect(
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
173 self.on_replaceSearchButton_clicked)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
174 self.replaceAndSearchAct.setEnabled(False)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
175 self.replaceAndSearchAct.setShortcutContext(
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
176 Qt.WidgetWithChildrenShortcut)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
177
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
178 self.replaceSelectionAct = E5Action(
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
179 self.tr("Replace Occurrence"),
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
180 self.tr("Replace Occurrence"),
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
181 0, 0, self, "replace_widget_replace_occurrence")
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
182 self.replaceSelectionAct.triggered.connect(
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
183 self.on_replaceButton_clicked)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
184 self.replaceSelectionAct.setEnabled(False)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
185 self.replaceSelectionAct.setShortcutContext(
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
186 Qt.WidgetWithChildrenShortcut)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
187
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
188 self.replaceAllAct = E5Action(
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
189 self.tr("Replace All"),
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
190 self.tr("Replace All"),
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
191 0, 0, self, "replace_widget_replace_all")
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
192 self.replaceAllAct.triggered.connect(
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
193 self.on_replaceAllButton_clicked)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
194 self.replaceAllAct.setEnabled(False)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
195 self.replaceAllAct.setShortcutContext(
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
196 Qt.WidgetWithChildrenShortcut)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
197
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
198 self.addAction(self.findNextAct)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
199 self.addAction(self.findPrevAct)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
200 if replace:
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
201 self.addAction(self.replaceAndSearchAct)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
202 self.addAction(self.replaceSelectionAct)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
203 self.addAction(self.replaceAllAct)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
204
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
205 # disable search and replace buttons and actions
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
206 self.__setFindNextEnabled(False)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
207 self.__setFindPrevEnabled(False)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
208 if replace:
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
209 self.__setReplaceAndSearchEnabled(False)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
210 self.__setReplaceSelectionEnabled(False)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
211 self.__setReplaceAllEnabled(False)
143
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
212
4086
822f456652c5 Adjust size of the SearchReplaceWidget and SearchReplaceSlidingWidget to properlyreflect font size changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4068
diff changeset
213 self.adjustSize()
4061
8880a520e932 Fixed an issue with the editor search bar and replace bar related to resizing upon usage of large fonts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
214
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 self.havefound = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 self.__pos = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 self.__findBackwards = False
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
218 self.__selections = []
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 self.__finding = False
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
220
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
221 def __setShortcuts(self):
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
222 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
223 Private method to set the local action's shortcuts to the same key
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
224 sequences as in the view manager.
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
225 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
226 if not self.__isMiniEditor:
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
227 self.findNextAct.setShortcuts(
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
228 self.__viewmanager.searchNextAct.shortcuts())
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
229 self.findPrevAct.setShortcuts(
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
230 self.__viewmanager.searchPrevAct.shortcuts())
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
231
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
232 if self.__replace:
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
233 self.replaceAndSearchAct.setShortcuts(
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
234 self.__viewmanager.replaceAndSearchAct.shortcuts())
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
235 self.replaceSelectionAct.setShortcuts(
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
236 self.__viewmanager.replaceSelectionAct.shortcuts())
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
237 self.replaceAllAct.setShortcuts(
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
238 self.__viewmanager.replaceAllAct.shortcuts())
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
239
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
240 def __setFindNextEnabled(self, enable):
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
241 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
242 Private method to set the enabled state of "Find Next".
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
243
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
244 @param enable flag indicating the enable state to be set
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
245 @type bool
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
246 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
247 self.ui.findNextButton.setEnabled(enable)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
248 self.findNextAct.setEnabled(enable)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
249
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
250 def __setFindPrevEnabled(self, enable):
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
251 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
252 Private method to set the enabled state of "Find Prev".
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
253
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
254 @param enable flag indicating the enable state to be set
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
255 @type bool
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
256 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
257 self.ui.findPrevButton.setEnabled(enable)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
258 self.findPrevAct.setEnabled(enable)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
259
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
260 def __setReplaceAndSearchEnabled(self, enable):
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
261 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
262 Private method to set the enabled state of "Replace And Search".
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
263
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
264 @param enable flag indicating the enable state to be set
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
265 @type bool
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
266 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
267 self.ui.replaceSearchButton.setEnabled(enable)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
268 self.replaceAndSearchAct.setEnabled(enable)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
269
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
270 def __setReplaceSelectionEnabled(self, enable):
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
271 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
272 Private method to set the enabled state of "Replace Occurrence".
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
273
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
274 @param enable flag indicating the enable state to be set
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
275 @type bool
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
276 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
277 self.ui.replaceButton.setEnabled(enable)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
278 self.replaceSelectionAct.setEnabled(enable)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
279
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
280 def __setReplaceAllEnabled(self, enable):
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
281 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
282 Private method to set the enabled state of "Replace All".
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
283
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
284 @param enable flag indicating the enable state to be set
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
285 @type bool
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
286 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
287 self.ui.replaceAllButton.setEnabled(enable)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
288 self.replaceAllAct.setEnabled(enable)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
289
4068
cb91ccf0104d Fixed another issue with the editor search bar and replace bar related to resizing upon usage of large fonts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4061
diff changeset
290 def changeEvent(self, evt):
cb91ccf0104d Fixed another issue with the editor search bar and replace bar related to resizing upon usage of large fonts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4061
diff changeset
291 """
cb91ccf0104d Fixed another issue with the editor search bar and replace bar related to resizing upon usage of large fonts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4061
diff changeset
292 Protected method handling state changes.
cb91ccf0104d Fixed another issue with the editor search bar and replace bar related to resizing upon usage of large fonts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4061
diff changeset
293
cb91ccf0104d Fixed another issue with the editor search bar and replace bar related to resizing upon usage of large fonts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4061
diff changeset
294 @param evt event containing the state change (QEvent)
cb91ccf0104d Fixed another issue with the editor search bar and replace bar related to resizing upon usage of large fonts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4061
diff changeset
295 """
cb91ccf0104d Fixed another issue with the editor search bar and replace bar related to resizing upon usage of large fonts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4061
diff changeset
296 if evt.type() == QEvent.FontChange:
4086
822f456652c5 Adjust size of the SearchReplaceWidget and SearchReplaceSlidingWidget to properlyreflect font size changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4068
diff changeset
297 self.adjustSize()
4068
cb91ccf0104d Fixed another issue with the editor search bar and replace bar related to resizing upon usage of large fonts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4061
diff changeset
298
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
299 def __selectionBoundary(self, selections=None):
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
300 """
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
301 Private method to calculate the current selection boundary.
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
302
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
303 @param selections optional parameter giving the selections to
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
304 calculate the boundary for (list of tuples of four integer)
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
305 @return tuple of start line and index and end line and index
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
306 (tuple of four integer)
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
307 """
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
308 if selections is None:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
309 selections = self.__selections
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
310 if selections:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
311 lineNumbers = (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
312 [sel[0] for sel in selections] +
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
313 [sel[2] for sel in selections]
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
314 )
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
315 indexNumbers = (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
316 [sel[1] for sel in selections] +
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
317 [sel[3] for sel in selections]
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
318 )
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
319 startLine, startIndex, endLine, endIndex = (
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
320 min(lineNumbers), min(indexNumbers),
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
321 max(lineNumbers), max(indexNumbers))
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
322 else:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
323 startLine, startIndex, endLine, endIndex = -1, -1, -1, -1
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
324
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
325 return startLine, startIndex, endLine, endIndex
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
326
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 def on_findtextCombo_editTextChanged(self, txt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 Private slot to enable/disable the find buttons.
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2689
diff changeset
330
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2689
diff changeset
331 @param txt text of the find text combo (string)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 if not txt:
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
334 self.__setFindNextEnabled(False)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
335 self.__setFindPrevEnabled(False)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
336 if self.__replace:
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
337 self.__setReplaceSelectionEnabled(False)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
338 self.__setReplaceAndSearchEnabled(False)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
339 self.__setReplaceAllEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 else:
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
341 self.__setFindNextEnabled(True)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
342 self.__setFindPrevEnabled(True)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
343 if self.__replace:
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
344 self.__setReplaceSelectionEnabled(False)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
345 self.__setReplaceAndSearchEnabled(False)
5822
c61cd6803da2 Fixed a silly issue in the editor search and replace widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5742
diff changeset
346 self.__setReplaceAllEnabled(True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 def on_findNextButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 Private slot to find the next occurrence of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 self.findNext()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355 def findNext(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 Public slot to find the next occurrence of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 if not self.havefound or not self.ui.findtextCombo.currentText():
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
360 if self.__replace:
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
361 self.__viewmanager.showReplaceWidget()
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
362 else:
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
363 self.__viewmanager.showSearchWidget()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 self.__findBackwards = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 txt = self.ui.findtextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 # This moves any previous occurrence of this statement to the head
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 # of the list and updates the combobox
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 if txt in self.findHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 self.findHistory.remove(txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 self.findHistory.insert(0, txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 self.ui.findtextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 self.ui.findtextCombo.addItems(self.findHistory)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
376 self.searchListChanged.emit()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 ok = self.__findNextPrev(txt, False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379 if ok:
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
380 if self.__replace:
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
381 self.__setReplaceSelectionEnabled(True)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
382 self.__setReplaceAndSearchEnabled(True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
384 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
385 self, self.windowTitle(),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
386 self.tr("'{0}' was not found.").format(txt))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 def on_findPrevButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 Private slot to find the previous occurrence of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 self.findPrev()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 def findPrev(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 Public slot to find the next previous of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 if not self.havefound or not self.ui.findtextCombo.currentText():
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
400 self.show(self.__viewmanager.textForFind())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 self.__findBackwards = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 txt = self.ui.findtextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 # This moves any previous occurrence of this statement to the head
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 # of the list and updates the combobox
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 if txt in self.findHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 self.findHistory.remove(txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410 self.findHistory.insert(0, txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 self.ui.findtextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 self.ui.findtextCombo.addItems(self.findHistory)
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
413 self.searchListChanged.emit()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 ok = self.__findNextPrev(txt, True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 if ok:
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
417 if self.__replace:
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
418 self.__setReplaceSelectionEnabled(True)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
419 self.__setReplaceAndSearchEnabled(True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
421 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
422 self, self.windowTitle(),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
423 self.tr("'{0}' was not found.").format(txt))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 def __findByReturnPressed(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
427 Private slot to handle the returnPressed signal of the findtext
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
428 combobox.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
430 if self.__findBackwards:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431 self.findPrev()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 self.findNext()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435 def __markOccurrences(self, txt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 Private method to mark all occurrences of the search text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 @param txt text to search for (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440 """
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
441 aw = self.__viewmanager.activeWindow()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442 lineFrom = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 indexFrom = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 lineTo = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 indexTo = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 if self.ui.selectionCheckBox.isChecked():
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
447 lineFrom, indexFrom, lineTo, indexTo = self.__selectionBoundary()
6841
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
448 posixMode = (Preferences.getEditor("SearchRegexpMode") == 0 and
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
449 self.ui.regexpCheckBox.isChecked())
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
450 cxx11Mode = (Preferences.getEditor("SearchRegexpMode") == 1 and
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
451 self.ui.regexpCheckBox.isChecked())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453 aw.clearSearchIndicators()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
454 ok = aw.findFirstTarget(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
455 txt,
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
456 self.ui.regexpCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
457 self.ui.caseCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
458 self.ui.wordCheckBox.isChecked(),
6841
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
459 lineFrom, indexFrom, lineTo, indexTo,
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
460 posix=posixMode, cxx11=cxx11Mode)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 while ok:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 tgtPos, tgtLen = aw.getFoundTarget()
1120
5c90fd188a24 Fixed a bug in the search & replace widget causing and endless loop [issue19].
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1112
diff changeset
463 if tgtLen == 0:
5c90fd188a24 Fixed a bug in the search & replace widget causing and endless loop [issue19].
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1112
diff changeset
464 break
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
465 if len(self.__selections) > 1:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
466 lineFrom, indexFrom = aw.lineIndexFromPosition(tgtPos)
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
467 lineTo, indexTo = aw.lineIndexFromPosition(tgtPos + tgtLen)
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
468 for sel in self.__selections:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
469 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
470 lineFrom == sel[0] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
471 indexFrom >= sel[1] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
472 indexTo <= sel[3]
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
473 ):
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
474 indicate = True
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
475 break
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
476 else:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
477 indicate = False
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
478 else:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
479 indicate = True
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
480 if indicate:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
481 aw.setSearchIndicator(tgtPos, tgtLen)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 ok = aw.findNextTarget()
4757
866050e987de Fixed a serious bug in the editor search widget causing a traceback in the mini editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
483 try:
866050e987de Fixed a serious bug in the editor search widget causing a traceback in the mini editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
484 aw.updateMarkerMap()
866050e987de Fixed a serious bug in the editor search widget causing a traceback in the mini editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
485 except AttributeError:
866050e987de Fixed a serious bug in the editor search widget causing a traceback in the mini editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
486 # MiniEditor doesn't have this, ignore it
866050e987de Fixed a serious bug in the editor search widget causing a traceback in the mini editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
487 pass
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
488
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489 def __findNextPrev(self, txt, backwards):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 Private method to find the next occurrence of the search text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
492
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
493 @param txt text to search for (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
494 @param backwards flag indicating a backwards search (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495 @return flag indicating success (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 self.__finding = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 if Preferences.getEditor("SearchMarkersEnabled"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 self.__markOccurrences(txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
502 aw = self.__viewmanager.activeWindow()
3069
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
503 aw.hideFindIndicator()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 cline, cindex = aw.getCursorPosition()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
506 ok = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507 lineFrom, indexFrom, lineTo, indexTo = aw.getSelection()
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
508 boundary = self.__selectionBoundary()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509 if backwards:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
510 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
511 self.ui.selectionCheckBox.isChecked() and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
512 (lineFrom, indexFrom, lineTo, indexTo) == boundary
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
513 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
514 # initial call
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
515 line, index = boundary[2:]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516 else:
1530
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
517 if (lineFrom, indexFrom) == (-1, -1):
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
518 # no selection present
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
519 line = cline
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
520 index = cindex
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
521 else:
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
522 line = lineFrom
2663
37b3ec77f2c4 Fixed a bug causing an incorrect bachwards search if the search patterns are directly netx to each other.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2661
diff changeset
523 index = indexFrom
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
524 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
525 self.ui.selectionCheckBox.isChecked() and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
526 line == boundary[0] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
527 index >= 0 and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
528 index < boundary[1]
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
529 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530 ok = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
531
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
532 if ok and index < 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
533 line -= 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534 if self.ui.selectionCheckBox.isChecked():
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
535 if line < boundary[0]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
536 if self.ui.wrapCheckBox.isChecked():
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
537 line, index = boundary[2:]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
538 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539 ok = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
540 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541 index = aw.lineLength(line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543 if line < 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544 if self.ui.wrapCheckBox.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545 line = aw.lines() - 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546 index = aw.lineLength(line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
547 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 ok = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550 index = aw.lineLength(line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551 else:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
552 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
553 self.ui.selectionCheckBox.isChecked() and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
554 (lineFrom, indexFrom, lineTo, indexTo) == boundary
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
555 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
556 # initial call
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
557 line, index = boundary[:2]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
558 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
559 line = lineTo
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
560 index = indexTo
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
562 if ok:
6841
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
563 posixMode = (Preferences.getEditor("SearchRegexpMode") == 0 and
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
564 self.ui.regexpCheckBox.isChecked())
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
565 cxx11Mode = (Preferences.getEditor("SearchRegexpMode") == 1 and
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
566 self.ui.regexpCheckBox.isChecked())
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
567 ok = aw.findFirst(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
568 txt,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
569 self.ui.regexpCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570 self.ui.caseCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
571 self.ui.wordCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
572 self.ui.wrapCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
573 not backwards,
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6571
diff changeset
574 line, index,
6841
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
575 posix=posixMode,
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
576 cxx11=cxx11Mode)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
577
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
578 if ok and self.ui.selectionCheckBox.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
579 lineFrom, indexFrom, lineTo, indexTo = aw.getSelection()
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
580 if len(self.__selections) > 1:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
581 for sel in self.__selections:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
582 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
583 lineFrom == sel[0] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
584 indexFrom >= sel[1] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
585 indexTo <= sel[3]
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
586 ):
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
587 ok = True
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
588 break
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
589 else:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
590 ok = False
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
591 elif (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
592 (lineFrom == boundary[0] and indexFrom >= boundary[1]) or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
593 (lineFrom > boundary[0] and lineFrom < boundary[2]) or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
594 (lineFrom == boundary[2] and indexFrom <= boundary[3])
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
595 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
596 ok = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
597 else:
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
598 ok = False
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
599 if not ok and len(self.__selections) > 1:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
600 # try again
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
601 while (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
602 not ok and
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
603 ((backwards and lineFrom >= boundary[0]) or
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
604 (not backwards and lineFrom <= boundary[2]))
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
605 ):
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
606 for ind in range(len(self.__selections)):
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
607 if lineFrom == self.__selections[ind][0]:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
608 after = indexTo > self.__selections[ind][3]
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
609 if backwards:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
610 if after:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
611 line, index = self.__selections[ind][2:]
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
612 else:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
613 if ind > 0:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
614 line, index = (
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
615 self.__selections[ind - 1][2:]
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
616 )
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
617 else:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
618 if after:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
619 if ind < len(self.__selections) - 1:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
620 line, index = (
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
621 self.__selections[ind + 1][:2]
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
622 )
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
623 else:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
624 line, index = self.__selections[ind][:2]
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
625 break
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
626 else:
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
627 break
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
628 ok = aw.findFirst(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
629 txt,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
630 self.ui.regexpCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
631 self.ui.caseCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
632 self.ui.wordCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
633 self.ui.wrapCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
634 not backwards,
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6571
diff changeset
635 line, index,
6841
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
636 posix=posixMode,
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
637 cxx11=cxx11Mode)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
638 if ok:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
639 lineFrom, indexFrom, lineTo, indexTo = (
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
640 aw.getSelection()
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
641 )
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
642 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
643 lineFrom < boundary[0] or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
644 lineFrom > boundary[2] or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
645 indexFrom < boundary[1] or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
646 indexFrom > boundary[3] or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
647 indexTo < boundary[1] or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
648 indexTo > boundary[3]
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
649 ):
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
650 ok = False
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
651 break
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
652 if not ok:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
653 if self.ui.wrapCheckBox.isChecked():
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
654 # try it again
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
655 if backwards:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
656 line, index = boundary[2:]
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
657 else:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
658 line, index = boundary[:2]
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
659 ok = aw.findFirst(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
660 txt,
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
661 self.ui.regexpCheckBox.isChecked(),
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
662 self.ui.caseCheckBox.isChecked(),
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
663 self.ui.wordCheckBox.isChecked(),
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
664 self.ui.wrapCheckBox.isChecked(),
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
665 not backwards,
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6571
diff changeset
666 line, index,
6841
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
667 posix=posixMode,
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
668 cxx11=cxx11Mode)
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
669 if ok:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
670 lineFrom, indexFrom, lineTo, indexTo = (
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
671 aw.getSelection()
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
672 )
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
673 if len(self.__selections) > 1:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
674 for sel in self.__selections:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
675 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
676 lineFrom == sel[0] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
677 indexFrom >= sel[1] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
678 indexTo <= sel[3]
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
679 ):
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
680 ok = True
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
681 break
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
682 else:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
683 ok = False
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
684 elif (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
685 (lineFrom == boundary[0] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
686 indexFrom >= boundary[1]) or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
687 (lineFrom > boundary[0] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
688 lineFrom < boundary[2]) or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
689 (lineFrom == boundary[2] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
690 indexFrom <= boundary[3])
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
691 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
692 ok = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
693 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
694 ok = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
695 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
696 ok = False
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
697
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
698 if not ok:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
699 aw.selectAll(False)
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
700 aw.setCursorPosition(cline, cindex)
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
701 aw.ensureCursorVisible()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
702
3069
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
703 if ok:
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
704 sline, sindex, eline, eindex = aw.getSelection()
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
705 aw.showFindIndicator(sline, sindex, eline, eindex)
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
706
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
707 self.__finding = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
708
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
709 return ok
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
710
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
711 def __showFind(self, text=''):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
712 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
713 Private method to display this widget in find mode.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
714
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
715 @param text text to be shown in the findtext edit (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
716 """
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
717 self.__replace = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
718
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
719 self.ui.findtextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
720 self.ui.findtextCombo.addItems(self.findHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
721 self.ui.findtextCombo.setEditText(text)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
722 self.ui.findtextCombo.lineEdit().selectAll()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
723 self.ui.findtextCombo.setFocus()
1527
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
724 self.on_findtextCombo_editTextChanged(text)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
725
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
726 self.ui.caseCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
727 self.ui.wordCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
728 self.ui.wrapCheckBox.setChecked(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
729 self.ui.regexpCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
730
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
731 aw = self.__viewmanager.activeWindow()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
732 self.updateSelectionCheckBox(aw)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
733
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
734 self.havefound = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
735 self.__findBackwards = False
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
736
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
737 self.__setShortcuts()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
738
6116
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
739 def selectionChanged(self, editor):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
740 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
741 Public slot tracking changes of selected text.
6116
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
742
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
743 @param editor reference to the editor
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
744 @type Editor
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
745 """
6116
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
746 self.updateSelectionCheckBox(editor)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
747
486
e4711a55e482 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 482
diff changeset
748 @pyqtSlot(Editor)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
749 def updateSelectionCheckBox(self, editor):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
750 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
751 Public slot to update the selection check box.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
752
6116
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
753 @param editor reference to the editor
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
754 @type Editor
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
755 """
2689
dc0b8301523d Fixed code in the search and replace widget that can possibly through an exception.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2663
diff changeset
756 if not self.__finding and isinstance(editor, Editor):
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
757 if editor.hasSelectedText():
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
758 selections = editor.getSelections()
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
759 line1, index1, line2, index2 = (
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
760 self.__selectionBoundary(selections)
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
761 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
762 if line1 != line2:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
763 self.ui.selectionCheckBox.setEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
764 self.ui.selectionCheckBox.setChecked(True)
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
765 self.__selections = selections
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
766 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
767
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
768 self.ui.selectionCheckBox.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
769 self.ui.selectionCheckBox.setChecked(False)
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
770 self.__selections = []
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
771
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
772 def replace(self):
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
773 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
774 Public method to replace the current selection.
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
775 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
776 if self.ui.replaceButton.isEnabled():
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
777 self.__doReplace(False)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
778
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
779 def replaceSearch(self):
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
780 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
781 Public method to replace the current selection and search again.
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
782 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
783 if self.ui.replaceSearchButton.isEnabled():
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
784 self.__doReplace(True)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
785
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
786 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
787 def on_replaceButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
788 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
789 Private slot to replace one occurrence of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
790 """
1527
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
791 self.__doReplace(False)
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
792
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
793 @pyqtSlot()
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
794 def on_replaceSearchButton_clicked(self):
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
795 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
796 Private slot to replace one occurrence of text and search for the next
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
797 one.
1527
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
798 """
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
799 self.__doReplace(True)
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
800
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
801 def __doReplace(self, searchNext):
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
802 """
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
803 Private method to replace one occurrence of text.
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
804
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
805 @param searchNext flag indicating to search for the next occurrence
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
806 (boolean).
1527
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
807 """
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
808 self.__finding = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
809
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
810 # Check enabled status due to dual purpose usage of this method
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
811 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
812 not self.ui.replaceButton.isEnabled() and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
813 not self.ui.replaceSearchButton.isEnabled()
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
814 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
815 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
816
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
817 ftxt = self.ui.findtextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
818 rtxt = self.ui.replacetextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
819
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
820 # This moves any previous occurrence of this statement to the head
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
821 # of the list and updates the combobox
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
822 if rtxt in self.replaceHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
823 self.replaceHistory.remove(rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
824 self.replaceHistory.insert(0, rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
825 self.ui.replacetextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
826 self.ui.replacetextCombo.addItems(self.replaceHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
827
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
828 aw = self.__viewmanager.activeWindow()
3069
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
829 aw.hideFindIndicator()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
830 aw.replace(rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
831
1527
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
832 if searchNext:
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
833 ok = self.__findNextPrev(ftxt, self.__findBackwards)
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
834
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
835 if not ok:
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
836 self.__setReplaceSelectionEnabled(False)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
837 self.__setReplaceAndSearchEnabled(False)
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
838 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
839 self, self.windowTitle(),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
840 self.tr("'{0}' was not found.").format(ftxt))
1527
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
841 else:
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
842 self.__setReplaceSelectionEnabled(False)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
843 self.__setReplaceAndSearchEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
844
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
845 self.__finding = False
1527
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
846
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
847 def replaceAll(self):
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
848 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
849 Public method to replace all occurrences.
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
850 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
851 if self.ui.replaceAllButton.isEnabled():
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
852 self.on_replaceAllButton_clicked()
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
853
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
854 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
855 def on_replaceAllButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
856 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
857 Private slot to replace all occurrences of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
858 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
859 self.__finding = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
860
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
861 replacements = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
862 ftxt = self.ui.findtextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
863 rtxt = self.ui.replacetextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
864
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
865 # This moves any previous occurrence of this statement to the head
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
866 # of the list and updates the combobox
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
867 if ftxt in self.findHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
868 self.findHistory.remove(ftxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
869 self.findHistory.insert(0, ftxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
870 self.ui.findtextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
871 self.ui.findtextCombo.addItems(self.findHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
872
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
873 if rtxt in self.replaceHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
874 self.replaceHistory.remove(rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
875 self.replaceHistory.insert(0, rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
876 self.ui.replacetextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
877 self.ui.replacetextCombo.addItems(self.replaceHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
878
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
879 aw = self.__viewmanager.activeWindow()
3069
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
880 aw.hideFindIndicator()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
881 cline, cindex = aw.getCursorPosition()
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
882 boundary = self.__selectionBoundary()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
883 if self.ui.selectionCheckBox.isChecked():
2660
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
884 line, index = boundary[:2]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
885 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
886 line = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
887 index = 0
6841
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
888 posixMode = (Preferences.getEditor("SearchRegexpMode") == 0 and
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
889 self.ui.regexpCheckBox.isChecked())
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
890 cxx11Mode = (Preferences.getEditor("SearchRegexpMode") == 1 and
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
891 self.ui.regexpCheckBox.isChecked())
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
892 ok = aw.findFirst(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
893 ftxt,
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
894 self.ui.regexpCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
895 self.ui.caseCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
896 self.ui.wordCheckBox.isChecked(),
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6571
diff changeset
897 False, True, line, index,
6841
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
898 posix=posixMode,
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
899 cxx11=cxx11Mode)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
900
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
901 if ok and self.ui.selectionCheckBox.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
902 lineFrom, indexFrom, lineTo, indexTo = aw.getSelection()
2661
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
903 if len(self.__selections) > 1:
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
904 for sel in self.__selections:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
905 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
906 lineFrom == sel[0] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
907 indexFrom >= sel[1] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
908 indexTo <= sel[3]
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
909 ):
2661
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
910 ok = True
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
911 break
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
912 else:
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
913 ok = False
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
914 elif (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
915 (lineFrom == boundary[0] and indexFrom >= boundary[1]) or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
916 (lineFrom > boundary[0] and lineFrom < boundary[2]) or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
917 (lineFrom == boundary[2] and indexFrom <= boundary[3])
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
918 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
919 ok = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
920 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
921 ok = False
2661
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
922 if not ok and len(self.__selections) > 1:
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
923 # try again
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
924 while not ok and lineFrom <= boundary[2]:
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
925 for ind in range(len(self.__selections)):
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
926 if lineFrom == self.__selections[ind][0]:
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
927 after = indexTo > self.__selections[ind][3]
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
928 if after:
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
929 if ind < len(self.__selections) - 1:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
930 line, index = (
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
931 self.__selections[ind + 1][:2]
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
932 )
2661
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
933 else:
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
934 line, index = self.__selections[ind][:2]
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
935 break
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
936 else:
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
937 break
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
938 ok = aw.findFirst(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
939 ftxt,
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
940 self.ui.regexpCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
941 self.ui.caseCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
942 self.ui.wordCheckBox.isChecked(),
6573
ccac2d1f6858 SearchReplaceWidget: changed the regexp search to use QScintilla's POSIX mode
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6571
diff changeset
943 False, True, line, index,
6841
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
944 posix=posixMode,
43af1e698c9d Editor: added extended regular expression support (C++11) as of QScintilla 2.11.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
945 cxx11=cxx11Mode)
2661
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
946 if ok:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
947 lineFrom, indexFrom, lineTo, indexTo = (
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
948 aw.getSelection()
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
949 )
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
950 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
951 lineFrom < boundary[0] or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
952 lineFrom > boundary[2] or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
953 indexFrom < boundary[1] or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
954 indexFrom > boundary[3] or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
955 indexTo < boundary[1] or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
956 indexTo > boundary[3]
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
957 ):
2661
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
958 ok = False
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
959 break
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
960
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
961 if not ok:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
962 aw.selectAll(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
963 aw.setCursorPosition(cline, cindex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
964 aw.ensureCursorVisible()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
965
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
966 found = ok
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
967
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
968 aw.beginUndoAction()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
969 wordWrap = self.ui.wrapCheckBox.isChecked()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
970 self.ui.wrapCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
971 while ok:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
972 aw.replace(rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
973 replacements += 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
974 ok = self.__findNextPrev(ftxt, self.__findBackwards)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
975 self.__finding = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
976 aw.endUndoAction()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
977 if wordWrap:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
978 self.ui.wrapCheckBox.setChecked(True)
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
979 self.__setReplaceSelectionEnabled(False)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
980 self.__setReplaceAndSearchEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
981
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
982 if found:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
983 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
984 self, self.windowTitle(),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
985 self.tr("Replaced {0} occurrences.")
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
986 .format(replacements))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
987 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
988 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
989 self, self.windowTitle(),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
990 self.tr("Nothing replaced because '{0}' was not found.")
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
991 .format(ftxt))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
992
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
993 aw.setCursorPosition(cline, cindex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
994 aw.ensureCursorVisible()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
995
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
996 self.__finding = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
997
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
998 def __showReplace(self, text=''):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
999 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1000 Private slot to display this widget in replace mode.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1001
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1002 @param text text to be shown in the findtext edit
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1003 """
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
1004 self.__replace = True
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1005
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1006 self.ui.findtextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1007 self.ui.findtextCombo.addItems(self.findHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1008 self.ui.findtextCombo.setEditText(text)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1009 self.ui.findtextCombo.lineEdit().selectAll()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1010 self.ui.findtextCombo.setFocus()
1527
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
1011 self.on_findtextCombo_editTextChanged(text)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1012
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1013 self.ui.replacetextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1014 self.ui.replacetextCombo.addItems(self.replaceHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1015 self.ui.replacetextCombo.setEditText('')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1016
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1017 self.ui.caseCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1018 self.ui.wordCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1019 self.ui.regexpCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1020
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1021 self.havefound = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1022
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
1023 aw = self.__viewmanager.activeWindow()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1024 self.updateSelectionCheckBox(aw)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1025 if aw.hasSelectedText():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1026 line1, index1, line2, index2 = aw.getSelection()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1027 if line1 == line2:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1028 aw.setSelection(line1, index1, line1, index1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1029 self.findNext()
143
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
1030
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
1031 self.__setShortcuts()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1032
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1033 def show(self, text=''):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1034 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
1035 Public slot to show the widget.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1036
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1037 @param text text to be shown in the findtext edit (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1038 """
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
1039 if self.__replace:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1040 self.__showReplace(text)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1041 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1042 self.__showFind(text)
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2409
diff changeset
1043 super(SearchReplaceWidget, self).show()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1044 self.activateWindow()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1045
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1046 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1047 def on_closeButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1048 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1049 Private slot to close the widget.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1050 """
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
1051 aw = self.__viewmanager.activeWindow()
3069
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
1052 if aw:
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
1053 aw.hideFindIndicator()
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
1054