eric6/QScintilla/SearchReplaceWidget.py

Sun, 12 Apr 2020 19:07:49 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 12 Apr 2020 19:07:49 +0200
changeset 7533
88261c96484b
parent 7360
9190402e4505
child 7781
607a6098cb44
permissions
-rw-r--r--

Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.

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
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7267
diff changeset
3 # Copyright (c) 2008 - 2020 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
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
10
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
11 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
12 from PyQt5.QtWidgets import (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
13 QWidget, QHBoxLayout, QToolButton, QScrollArea, QSizePolicy, QFrame
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
14 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
486
e4711a55e482 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 482
diff changeset
16 from .Editor import Editor
e4711a55e482 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 482
diff changeset
17
143
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
18 from E5Gui.E5Action import E5Action
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
19 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
20
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 import Preferences
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 import UI.PixmapCache
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
25
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 class SearchReplaceWidget(QWidget):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 Class implementing the search and replace widget.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
501
5c615a85241a Finished porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 500
diff changeset
30 @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
31 """
500
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
32 searchListChanged = pyqtSignal()
c3abc7895a01 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 486
diff changeset
33
2362
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
34 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
35 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 @param replace flag indicating a replace widget is called
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 @param vm reference to the viewmanager object
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 @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
41 @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
42 sliding widget (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 """
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
44 super(SearchReplaceWidget, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
5742
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.__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
47 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
48 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
49 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
50 if sliding:
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
51 self.__topWidget = parent
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.findHistory = vm.getSRHistory('search')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 if replace:
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2375
diff changeset
55 from .Ui_ReplaceWidget import Ui_ReplaceWidget
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.replaceHistory = vm.getSRHistory('replace')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 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
58 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
59 """<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
60 <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
61 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
62 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
63 special characters interpreted are:</p>
0
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 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 else:
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2375
diff changeset
67 from .Ui_SearchWidget import Ui_SearchWidget
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 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
69 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
70 """<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
71 <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
72 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
73 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
74 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.ui.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 if not replace:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 self.ui.wrapCheckBox.setChecked(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
80 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
81 """<table border="0">
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 <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
83 <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
84 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
85 <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
86 </td></tr>
1232
ed31e909cf2e Harmonisation of some display strings related to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
87 <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
88 <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
89 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
90 <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
91 <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
92 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
93 <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
94 <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
95 </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
96 <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
97 <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
98 </td></tr>
1232
ed31e909cf2e Harmonisation of some display strings related to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
99 <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
100 <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
101 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
102 character set.</td></tr>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 <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
104 <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
105 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
106 case character.</td></tr>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 <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
108 <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
109 any character except an alphabetic character.</td></tr>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
110 <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
111 <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
112 </td></tr>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 <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
114 <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
115 <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
116 <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
117 and so on.</td></tr>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 <tr><td><code>+</code></td>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 <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
120 <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
121 </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
122 <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
123 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
124 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
125 """
9f6555d3c3c0 Fixed some code style issues and removed code no longer needed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4304
diff changeset
126 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 self.setWhatsThis(whatsThis)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
129 # 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
130 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
131 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
132 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
133 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
134 UI.PixmapCache.getIcon("1rightarrow"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 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
137 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
138 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
139 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
140 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
141 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
142 UI.PixmapCache.getIcon("editReplaceAll"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
144 # 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
145 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
146 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
147 self.__findByReturnPressed)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 if replace:
3685
7c83da3cc0bf Set autocompletion for comboboxes in search widgets to off.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
149 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
150 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
151 self.on_replaceButton_clicked)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
153 # define actions
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
154 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
155 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
156 self.tr('Find Next'),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
157 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
158 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
159 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
160
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
161 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
162 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
163 self.tr('Find Prev'),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
164 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
165 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
166 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
167
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
168 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
169 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
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 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
172 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
173 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
174 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
175 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
176 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
177 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
178
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.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
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 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
182 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
183 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
184 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
185 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
186 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
187 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
188
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.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
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 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
192 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
193 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
194 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
195 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
196 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
197 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
198
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.findNextAct)
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
200 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
201 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
202 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
203 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
204 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
205
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
206 # 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
207 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
208 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
209 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
210 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
211 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
212 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
213
4086
822f456652c5 Adjust size of the SearchReplaceWidget and SearchReplaceSlidingWidget to properlyreflect font size changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4068
diff changeset
214 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
215
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 self.havefound = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 self.__pos = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 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
219 self.__selections = []
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 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
221
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
222 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
223 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
224 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
225 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
226 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
227 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
228 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
229 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
230 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
231 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
232
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
233 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
234 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
235 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
236 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
237 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
238 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
239 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
240
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
241 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
242 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
243 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
244
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
245 @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
246 @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
247 """
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.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
249 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
250
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
251 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
252 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
253 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
254
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
255 @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
256 @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
257 """
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.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
259 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
260
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
261 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
262 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
263 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
264
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
265 @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
266 @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
267 """
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.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
269 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
270
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
271 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
272 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
273 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
274
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
275 @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
276 @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
277 """
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.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
279 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
280
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
281 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
282 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
283 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
284
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
285 @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
286 @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
287 """
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.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
289 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
290
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
291 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
292 """
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 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
294
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 @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
296 """
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
297 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
298 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
299
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
300 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
301 """
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 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
303
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 @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
305 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
306 @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
307 (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
308 """
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 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
310 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
311 if selections:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
312 lineNumbers = (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
313 [sel[0] for sel in selections] +
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
314 [sel[2] for sel in selections]
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
315 )
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
316 indexNumbers = (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
317 [sel[1] for sel in selections] +
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
318 [sel[3] for sel in selections]
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
319 )
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
320 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
321 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
322 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
323 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
324 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
325
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 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
327
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328 def on_findtextCombo_editTextChanged(self, txt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 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
331
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2689
diff changeset
332 @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
333 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
334 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
335 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
336 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
337 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
338 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
339 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
340 self.__setReplaceAllEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 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
342 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
343 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
344 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
345 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
346 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
347 self.__setReplaceAllEnabled(True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 def on_findNextButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 Private slot to find the next occurrence of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 self.findNext()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 def findNext(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 Public slot to find the next occurrence of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 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
361 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
362 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
363 else:
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
364 self.__viewmanager.showSearchWidget()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 self.__findBackwards = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 txt = self.ui.findtextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 # 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
371 # of the list and updates the combobox
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 if txt in self.findHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 self.findHistory.remove(txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 self.findHistory.insert(0, txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 self.ui.findtextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 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
377 self.searchListChanged.emit()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379 ok = self.__findNextPrev(txt, False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 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
381 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
382 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
383 self.__setReplaceAndSearchEnabled(True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
385 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
386 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
387 self.tr("'{0}' was not found.").format(txt))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 def on_findPrevButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 Private slot to find the previous occurrence of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 self.findPrev()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 def findPrev(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 Public slot to find the next previous of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400 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
401 self.show(self.__viewmanager.textForFind())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 self.__findBackwards = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 txt = self.ui.findtextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 # 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
408 # of the list and updates the combobox
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 if txt in self.findHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410 self.findHistory.remove(txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 self.findHistory.insert(0, txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 self.ui.findtextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 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
414 self.searchListChanged.emit()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 ok = self.__findNextPrev(txt, True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 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
418 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
419 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
420 self.__setReplaceAndSearchEnabled(True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
422 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
423 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
424 self.tr("'{0}' was not found.").format(txt))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 def __findByReturnPressed(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
428 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
429 combobox.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
430 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431 if self.__findBackwards:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432 self.findPrev()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434 self.findNext()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 def __markOccurrences(self, txt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 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
439
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440 @param txt text to search for (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441 """
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
442 aw = self.__viewmanager.activeWindow()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 lineFrom = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 indexFrom = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 lineTo = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446 indexTo = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 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
448 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
449 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
450 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
451 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
452 self.ui.regexpCheckBox.isChecked())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 aw.clearSearchIndicators()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
455 ok = aw.findFirstTarget(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
456 txt,
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
457 self.ui.regexpCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
458 self.ui.caseCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
459 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
460 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
461 posix=posixMode, cxx11=cxx11Mode)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 while ok:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463 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
464 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
465 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
466 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
467 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
468 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
469 for sel in self.__selections:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
470 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
471 lineFrom == sel[0] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
472 indexFrom >= sel[1] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
473 indexTo <= sel[3]
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
474 ):
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
475 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
476 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
477 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
478 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
479 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
480 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
481 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
482 aw.setSearchIndicator(tgtPos, tgtLen)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483 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
484 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
485 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
486 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
487 # 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
488 pass
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490 def __findNextPrev(self, txt, backwards):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
492 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
493
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
494 @param txt text to search for (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495 @param backwards flag indicating a backwards search (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 @return flag indicating success (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498 self.__finding = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 if Preferences.getEditor("SearchMarkersEnabled"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501 self.__markOccurrences(txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
503 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
504 aw.hideFindIndicator()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 cline, cindex = aw.getCursorPosition()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
506
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507 ok = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508 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
509 boundary = self.__selectionBoundary()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
510 if backwards:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
511 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
512 self.ui.selectionCheckBox.isChecked() and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
513 (lineFrom, indexFrom, lineTo, indexTo) == boundary
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
514 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
515 # 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
516 line, index = boundary[2:]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
517 else:
1530
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
518 if (lineFrom, indexFrom) == (-1, -1):
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
519 # no selection present
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
520 line = cline
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
521 index = cindex
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
522 else:
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
523 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
524 index = indexFrom
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
525 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
526 self.ui.selectionCheckBox.isChecked() and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
527 line == boundary[0] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
528 index >= 0 and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
529 index < boundary[1]
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
530 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
531 ok = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
532
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
533 if ok and index < 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534 line -= 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
535 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
536 if line < boundary[0]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
537 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
538 line, index = boundary[2:]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
540 ok = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 index = aw.lineLength(line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544 if line < 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545 if self.ui.wrapCheckBox.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546 line = aw.lines() - 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
547 index = aw.lineLength(line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549 ok = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551 index = aw.lineLength(line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
552 else:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
553 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
554 self.ui.selectionCheckBox.isChecked() and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
555 (lineFrom, indexFrom, lineTo, indexTo) == boundary
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
556 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
557 # 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
558 line, index = boundary[:2]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
559 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
560 line = lineTo
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561 index = indexTo
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
562
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563 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
564 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
565 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
566 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
567 self.ui.regexpCheckBox.isChecked())
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
568 ok = aw.findFirst(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
569 txt,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570 self.ui.regexpCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
571 self.ui.caseCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
572 self.ui.wordCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
573 self.ui.wrapCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
574 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
575 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
576 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
577 cxx11=cxx11Mode)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
578
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
579 if ok and self.ui.selectionCheckBox.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
580 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
581 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
582 for sel in self.__selections:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
583 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
584 lineFrom == sel[0] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
585 indexFrom >= sel[1] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
586 indexTo <= sel[3]
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
587 ):
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
588 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
589 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
590 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
591 ok = False
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
592 elif (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
593 (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
594 (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
595 (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
596 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
597 ok = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
598 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
599 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
600 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
601 # try again
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
602 while (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
603 not ok and
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
604 ((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
605 (not backwards and lineFrom <= boundary[2]))
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
606 ):
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
607 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
608 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
609 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
610 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
611 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
612 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
613 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
614 if ind > 0:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
615 line, index = (
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
616 self.__selections[ind - 1][2:]
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
617 )
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
618 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
619 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
620 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
621 line, index = (
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
622 self.__selections[ind + 1][:2]
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
623 )
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
624 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
625 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
626 break
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
627 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
628 break
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
629 ok = aw.findFirst(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
630 txt,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
631 self.ui.regexpCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
632 self.ui.caseCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
633 self.ui.wordCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
634 self.ui.wrapCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
635 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
636 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
637 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
638 cxx11=cxx11Mode)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
639 if ok:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
640 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
641 aw.getSelection()
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
642 )
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
643 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
644 lineFrom < boundary[0] or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
645 lineFrom > boundary[2] or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
646 indexFrom < boundary[1] or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
647 indexFrom > boundary[3] or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
648 indexTo < boundary[1] or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
649 indexTo > boundary[3]
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
650 ):
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
651 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
652 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
653 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
654 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
655 # 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
656 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
657 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
658 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
659 line, index = boundary[:2]
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
660 ok = aw.findFirst(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
661 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
662 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
663 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
664 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
665 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
666 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
667 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
668 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
669 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
670 if ok:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
671 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
672 aw.getSelection()
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
673 )
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
674 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
675 for sel in self.__selections:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
676 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
677 lineFrom == sel[0] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
678 indexFrom >= sel[1] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
679 indexTo <= sel[3]
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
680 ):
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
681 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
682 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
683 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
684 ok = False
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
685 elif (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
686 (lineFrom == boundary[0] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
687 indexFrom >= boundary[1]) or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
688 (lineFrom > boundary[0] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
689 lineFrom < boundary[2]) or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
690 (lineFrom == boundary[2] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
691 indexFrom <= boundary[3])
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
692 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
693 ok = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
694 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
695 ok = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
696 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
697 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
698
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 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
700 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
701 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
702 aw.ensureCursorVisible()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
703
3069
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
704 if ok:
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
705 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
706 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
707
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
708 self.__finding = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
709
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
710 return ok
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
711
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
712 def __showFind(self, text=''):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
713 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
714 Private method to display this widget in find mode.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
715
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
716 @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
717 """
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
718 self.__replace = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
719
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
720 self.ui.findtextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
721 self.ui.findtextCombo.addItems(self.findHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
722 self.ui.findtextCombo.setEditText(text)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
723 self.ui.findtextCombo.lineEdit().selectAll()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
724 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
725 self.on_findtextCombo_editTextChanged(text)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
726
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
727 self.ui.caseCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
728 self.ui.wordCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
729 self.ui.wrapCheckBox.setChecked(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
730 self.ui.regexpCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
731
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
732 aw = self.__viewmanager.activeWindow()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
733 self.updateSelectionCheckBox(aw)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
734
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
735 self.havefound = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
736 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
737
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
738 self.__setShortcuts()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
739
6116
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
740 def selectionChanged(self, editor):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
741 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
742 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
743
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
744 @param editor reference to the editor
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
745 @type Editor
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
746 """
6116
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
747 self.updateSelectionCheckBox(editor)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
748
486
e4711a55e482 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 482
diff changeset
749 @pyqtSlot(Editor)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
750 def updateSelectionCheckBox(self, editor):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
751 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
752 Public slot to update the selection check box.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
753
6116
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
754 @param editor reference to the editor
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
755 @type Editor
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
756 """
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
757 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
758 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
759 selections = editor.getSelections()
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
760 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
761 self.__selectionBoundary(selections)
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
762 )
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
763 if line1 != line2:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
764 self.ui.selectionCheckBox.setEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
765 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
766 self.__selections = selections
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
767 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
768
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
769 self.ui.selectionCheckBox.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
770 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
771 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
772
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
773 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
774 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
775 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
776 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
777 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
778 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
779
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
780 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
781 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
782 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
783 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
784 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
785 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
786
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
787 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
788 def on_replaceButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
789 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
790 Private slot to replace one occurrence of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
791 """
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
792 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
793
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 @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
795 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
796 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
797 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
798 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
799 """
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 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
801
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 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
803 """
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 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
805
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
806 @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
807 (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
808 """
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
809 self.__finding = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
810
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
811 # 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
812 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
813 not self.ui.replaceButton.isEnabled() and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
814 not self.ui.replaceSearchButton.isEnabled()
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
815 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
816 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
817
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
818 ftxt = self.ui.findtextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
819 rtxt = self.ui.replacetextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
820
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
821 # 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
822 # of the list and updates the combobox
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
823 if rtxt in self.replaceHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
824 self.replaceHistory.remove(rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
825 self.replaceHistory.insert(0, rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
826 self.ui.replacetextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
827 self.ui.replacetextCombo.addItems(self.replaceHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
828
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
829 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
830 aw.hideFindIndicator()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
831 aw.replace(rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
832
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
833 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
834 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
835
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
836 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
837 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
838 self.__setReplaceAndSearchEnabled(False)
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
839 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
840 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
841 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
842 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
843 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
844 self.__setReplaceAndSearchEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
845
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
846 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
847
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
848 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
849 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
850 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
851 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
852 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
853 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
854
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
855 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
856 def on_replaceAllButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
857 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
858 Private slot to replace all occurrences of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
859 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
860 self.__finding = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
861
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
862 replacements = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
863 ftxt = self.ui.findtextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
864 rtxt = self.ui.replacetextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
865
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
866 # 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
867 # of the list and updates the combobox
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
868 if ftxt in self.findHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
869 self.findHistory.remove(ftxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
870 self.findHistory.insert(0, ftxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
871 self.ui.findtextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
872 self.ui.findtextCombo.addItems(self.findHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
873
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
874 if rtxt in self.replaceHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
875 self.replaceHistory.remove(rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
876 self.replaceHistory.insert(0, rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
877 self.ui.replacetextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
878 self.ui.replacetextCombo.addItems(self.replaceHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
879
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
880 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
881 aw.hideFindIndicator()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
882 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
883 boundary = self.__selectionBoundary()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
884 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
885 line, index = boundary[:2]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
886 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
887 line = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
888 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
889 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
890 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
891 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
892 self.ui.regexpCheckBox.isChecked())
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
893 ok = aw.findFirst(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
894 ftxt,
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
895 self.ui.regexpCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
896 self.ui.caseCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
897 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
898 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
899 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
900 cxx11=cxx11Mode)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
901
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
902 if ok and self.ui.selectionCheckBox.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
903 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
904 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
905 for sel in self.__selections:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
906 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
907 lineFrom == sel[0] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
908 indexFrom >= sel[1] and
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
909 indexTo <= sel[3]
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
910 ):
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
911 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
912 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
913 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
914 ok = False
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
915 elif (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
916 (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
917 (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
918 (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
919 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
920 ok = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
921 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
922 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
923 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
924 # 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
925 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
926 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
927 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
928 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
929 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
930 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
931 line, index = (
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
932 self.__selections[ind + 1][:2]
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
933 )
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
934 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
935 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
936 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
937 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
938 break
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
939 ok = aw.findFirst(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
940 ftxt,
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
941 self.ui.regexpCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
942 self.ui.caseCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
943 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
944 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
945 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
946 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
947 if ok:
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
948 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
949 aw.getSelection()
7267
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
950 )
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
951 if (
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
952 lineFrom < boundary[0] or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
953 lineFrom > boundary[2] or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
954 indexFrom < boundary[1] or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
955 indexFrom > boundary[3] or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
956 indexTo < boundary[1] or
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
957 indexTo > boundary[3]
aedc309827c7 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
958 ):
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
959 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
960 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
961
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
962 if not ok:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
963 aw.selectAll(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
964 aw.setCursorPosition(cline, cindex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
965 aw.ensureCursorVisible()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
966
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
967 found = ok
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
968
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
969 aw.beginUndoAction()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
970 wordWrap = self.ui.wrapCheckBox.isChecked()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
971 self.ui.wrapCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
972 while ok:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
973 aw.replace(rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
974 replacements += 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
975 ok = self.__findNextPrev(ftxt, self.__findBackwards)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
976 self.__finding = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
977 aw.endUndoAction()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
978 if wordWrap:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
979 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
980 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
981 self.__setReplaceAndSearchEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
982
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
983 if found:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
984 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
985 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
986 self.tr("Replaced {0} occurrences.")
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
987 .format(replacements))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
988 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
989 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
990 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
991 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
992 .format(ftxt))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
993
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
994 aw.setCursorPosition(cline, cindex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
995 aw.ensureCursorVisible()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
996
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
997 self.__finding = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
998
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
999 def __showReplace(self, text=''):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1000 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1001 Private slot to display this widget in replace mode.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1002
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1003 @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
1004 """
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
1005 self.__replace = True
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1006
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1007 self.ui.findtextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1008 self.ui.findtextCombo.addItems(self.findHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1009 self.ui.findtextCombo.setEditText(text)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1010 self.ui.findtextCombo.lineEdit().selectAll()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1011 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
1012 self.on_findtextCombo_editTextChanged(text)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1013
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1014 self.ui.replacetextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1015 self.ui.replacetextCombo.addItems(self.replaceHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1016 self.ui.replacetextCombo.setEditText('')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1017
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1018 self.ui.caseCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1019 self.ui.wordCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1020 self.ui.regexpCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1021
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1022 self.havefound = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1023
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
1024 aw = self.__viewmanager.activeWindow()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1025 self.updateSelectionCheckBox(aw)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1026 if aw.hasSelectedText():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1027 line1, index1, line2, index2 = aw.getSelection()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1028 if line1 == line2:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1029 aw.setSelection(line1, index1, line1, index1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1030 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
1031
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
1032 self.__setShortcuts()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1033
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1034 def show(self, text=''):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1035 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
1036 Public slot to show the widget.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1037
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1038 @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
1039 """
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
1040 if self.__replace:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1041 self.__showReplace(text)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1042 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1043 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
1044 super(SearchReplaceWidget, self).show()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1045 self.activateWindow()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1046
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1047 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1048 def on_closeButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1049 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1050 Private slot to close the widget.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1051 """
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
1052 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
1053 if aw:
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
1054