eric6/QScintilla/SearchReplaceWidget.py

Sun, 14 Apr 2019 15:09:21 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 14 Apr 2019 15:09:21 +0200
changeset 6942
2602857055c5
parent 6841
QScintilla/SearchReplaceWidget.py@43af1e698c9d
child 7229
53054eb5b15a
permissions
-rw-r--r--

Major restructuring of the source tree to get prepared for a setup.py based installation.

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
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6574
diff changeset
3 # Copyright (c) 2008 - 2019 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
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3080
diff changeset
10 from __future__ import unicode_literals
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
11
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
12 from PyQt5.QtCore import pyqtSignal, Qt, pyqtSlot, QEvent
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
13 from PyQt5.QtWidgets import QWidget, QHBoxLayout, QToolButton, QScrollArea, \
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
14 QSizePolicy, QFrame
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
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 self.ui.closeButton.setIcon(UI.PixmapCache.getIcon("close.png"))
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(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
132 UI.PixmapCache.getIcon("1leftarrow.png"))
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(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
134 UI.PixmapCache.getIcon("1rightarrow.png"))
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(
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
138 UI.PixmapCache.getIcon("editReplace.png"))
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(
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
140 UI.PixmapCache.getIcon("editReplaceSearch.png"))
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(
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
142 UI.PixmapCache.getIcon("editReplaceAll.png"))
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:
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
312 lineNumbers = [sel[0] for sel in 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
313 [sel[2] for sel in 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
314 indexNumbers = [sel[1] for sel in 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
315 [sel[3] for sel in 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
316 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
317 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
318 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
319 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
320 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
321
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 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
323
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 def on_findtextCombo_editTextChanged(self, txt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 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
327
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2689
diff changeset
328 @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
329 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 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
331 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
332 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
333 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
334 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
335 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
336 self.__setReplaceAllEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 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
338 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
339 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
340 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
341 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
342 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
343 self.__setReplaceAllEnabled(True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
344
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 def on_findNextButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 Private slot to find the next occurrence of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 self.findNext()
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 def findNext(self):
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 Public slot to find the next occurrence of text.
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 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
357 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
358 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
359 else:
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
360 self.__viewmanager.showSearchWidget()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 self.__findBackwards = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 txt = self.ui.findtextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 # 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
367 # of the list and updates the combobox
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 if txt in self.findHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 self.findHistory.remove(txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 self.findHistory.insert(0, txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 self.ui.findtextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 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
373 self.searchListChanged.emit()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 ok = self.__findNextPrev(txt, False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 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
377 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
378 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
379 self.__setReplaceAndSearchEnabled(True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
381 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
382 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
383 self.tr("'{0}' was not found.").format(txt))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 def on_findPrevButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 Private slot to find the previous occurrence of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 self.findPrev()
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 def findPrev(self):
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 Public slot to find the next previous of text.
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 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
397 self.show(self.__viewmanager.textForFind())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 return
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 self.__findBackwards = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 txt = self.ui.findtextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 # 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
404 # of the list and updates the combobox
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 if txt in self.findHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 self.findHistory.remove(txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 self.findHistory.insert(0, txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 self.ui.findtextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 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
410 self.searchListChanged.emit()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 ok = self.__findNextPrev(txt, True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 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
414 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
415 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
416 self.__setReplaceAndSearchEnabled(True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
418 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
419 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
420 self.tr("'{0}' was not found.").format(txt))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 def __findByReturnPressed(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
424 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
425 combobox.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 if self.__findBackwards:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 self.findPrev()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
430 self.findNext()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432 def __markOccurrences(self, txt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434 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
435
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 @param txt text to search for (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 """
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
438 aw = self.__viewmanager.activeWindow()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 lineFrom = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440 indexFrom = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
441 lineTo = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442 indexTo = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 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
444 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
445 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
446 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
447 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
448 self.ui.regexpCheckBox.isChecked())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
450 aw.clearSearchIndicators()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
451 ok = aw.findFirstTarget(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
452 txt,
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
453 self.ui.regexpCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
454 self.ui.caseCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
455 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
456 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
457 posix=posixMode, cxx11=cxx11Mode)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 while ok:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 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
460 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
461 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
462 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
463 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
464 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
465 for sel in 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
466 if lineFrom == sel[0] and \
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 indexFrom >= sel[1] and \
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 indexTo <= sel[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
469 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
470 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
471 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
472 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
473 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
474 indicate = True
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
475 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
476 aw.setSearchIndicator(tgtPos, tgtLen)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477 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
478 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
479 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
480 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
481 # 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
482 pass
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
484 def __findNextPrev(self, txt, backwards):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
485 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
486 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
487
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
488 @param txt text to search for (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489 @param backwards flag indicating a backwards search (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490 @return flag indicating success (boolean)
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 self.__finding = True
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 if Preferences.getEditor("SearchMarkersEnabled"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495 self.__markOccurrences(txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
497 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
498 aw.hideFindIndicator()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 cline, cindex = aw.getCursorPosition()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501 ok = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 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
503 boundary = self.__selectionBoundary()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
504 if backwards:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 if self.ui.selectionCheckBox.isChecked() and \
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
506 (lineFrom, indexFrom, lineTo, indexTo) == boundary:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507 # 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
508 line, index = boundary[2:]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509 else:
1530
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
510 if (lineFrom, indexFrom) == (-1, -1):
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
511 # no selection present
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
512 line = cline
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
513 index = cindex
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
514 else:
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
515 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
516 index = indexFrom
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
517 if self.ui.selectionCheckBox.isChecked() and \
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
518 line == boundary[0] and \
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
519 index >= 0 and \
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
520 index < boundary[1]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
521 ok = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
522
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523 if ok and index < 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
524 line -= 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525 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
526 if line < boundary[0]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527 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
528 line, index = boundary[2:]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530 ok = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
531 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
532 index = aw.lineLength(line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
533 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534 if line < 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
535 if self.ui.wrapCheckBox.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
536 line = aw.lines() - 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
537 index = aw.lineLength(line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
538 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539 ok = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
540 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541 index = aw.lineLength(line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543 if self.ui.selectionCheckBox.isChecked() and \
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
544 (lineFrom, indexFrom, lineTo, indexTo) == boundary:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545 # 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
546 line, index = boundary[:2]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
547 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 line = lineTo
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549 index = indexTo
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
551 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
552 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
553 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
554 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
555 self.ui.regexpCheckBox.isChecked())
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
556 ok = aw.findFirst(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
557 txt,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
558 self.ui.regexpCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
559 self.ui.caseCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
560 self.ui.wordCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561 self.ui.wrapCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
562 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
563 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
564 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
565 cxx11=cxx11Mode)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
566
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567 if ok and self.ui.selectionCheckBox.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
568 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
569 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
570 for sel in 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
571 if lineFrom == sel[0] and \
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
572 indexFrom >= sel[1] and \
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
573 indexTo <= sel[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
574 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
575 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
576 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
577 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
578 elif (lineFrom == boundary[0] and indexFrom >= boundary[1]) or \
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
579 (lineFrom > boundary[0] and lineFrom < boundary[2]) or \
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
580 (lineFrom == boundary[2] and indexFrom <= boundary[3]):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
581 ok = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
582 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
583 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
584 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
585 # try 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
586 while not ok and \
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
587 ((backwards and lineFrom >= boundary[0]) or
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
588 (not backwards and lineFrom <= boundary[2])):
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
589 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
590 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
591 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
592 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
593 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
594 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
595 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
596 if ind > 0:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
597 line, index = \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
598 self.__selections[ind - 1][2:]
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 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
600 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
601 if ind < len(self.__selections) - 1:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
602 line, index = \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
603 self.__selections[ind + 1][:2]
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
604 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
605 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
606 break
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
607 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
608 break
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
609 ok = aw.findFirst(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
610 txt,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
611 self.ui.regexpCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
612 self.ui.caseCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
613 self.ui.wordCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
614 self.ui.wrapCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
615 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
616 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
617 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
618 cxx11=cxx11Mode)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
619 if ok:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
620 lineFrom, indexFrom, lineTo, indexTo = \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
621 aw.getSelection()
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
622 if lineFrom < boundary[0] or \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
623 lineFrom > boundary[2] or \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
624 indexFrom < boundary[1] or \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
625 indexFrom > boundary[3] or \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
626 indexTo < boundary[1] or \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
627 indexTo > boundary[3]:
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 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
629 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
630 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
631 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
632 # 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
633 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
634 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
635 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
636 line, index = boundary[:2]
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
637 ok = aw.findFirst(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
638 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
639 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
640 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
641 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
642 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
643 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
644 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
645 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
646 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
647 if ok:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
648 lineFrom, indexFrom, lineTo, indexTo = \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
649 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
650 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
651 for sel in 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
652 if lineFrom == sel[0] and \
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 indexFrom >= sel[1] and \
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 indexTo <= sel[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
655 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
656 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
657 else:
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
658 ok = False
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
659 elif (lineFrom == boundary[0] and
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
660 indexFrom >= boundary[1]) or \
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
661 (lineFrom > boundary[0] and
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
662 lineFrom < boundary[2]) or \
4830
f609a22f43bd Fixed a few code style issues detected by the updated pep8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4757
diff changeset
663 (lineFrom == boundary[2] and
f609a22f43bd Fixed a few code style issues detected by the updated pep8 checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4757
diff changeset
664 indexFrom <= boundary[3]):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
665 ok = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
666 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
667 ok = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
668 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
669 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
670
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
671 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
672 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
673 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
674 aw.ensureCursorVisible()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
675
3069
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
676 if ok:
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
677 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
678 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
679
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
680 self.__finding = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
681
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
682 return ok
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
683
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
684 def __showFind(self, text=''):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
685 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
686 Private method to display this widget in find mode.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
687
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
688 @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
689 """
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
690 self.__replace = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
691
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
692 self.ui.findtextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
693 self.ui.findtextCombo.addItems(self.findHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
694 self.ui.findtextCombo.setEditText(text)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
695 self.ui.findtextCombo.lineEdit().selectAll()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
696 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
697 self.on_findtextCombo_editTextChanged(text)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
698
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
699 self.ui.caseCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
700 self.ui.wordCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
701 self.ui.wrapCheckBox.setChecked(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
702 self.ui.regexpCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
703
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
704 aw = self.__viewmanager.activeWindow()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
705 self.updateSelectionCheckBox(aw)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
706
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
707 self.havefound = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
708 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
709
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
710 self.__setShortcuts()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
711
6116
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
712 def selectionChanged(self, editor):
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 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
715
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
716 @param editor reference to the editor
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
717 @type Editor
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
718 """
6116
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
719 self.updateSelectionCheckBox(editor)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
720
486
e4711a55e482 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 482
diff changeset
721 @pyqtSlot(Editor)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
722 def updateSelectionCheckBox(self, editor):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
723 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
724 Public slot to update the selection check box.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
725
6116
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
726 @param editor reference to the editor
f3d3c996c193 Continued removing the use of QObject.sender().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
727 @type Editor
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
728 """
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
729 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
730 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
731 selections = editor.getSelections()
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
732 line1, index1, line2, index2 = \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
733 self.__selectionBoundary(selections)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
734 if line1 != line2:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
735 self.ui.selectionCheckBox.setEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
736 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
737 self.__selections = selections
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
738 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
739
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
740 self.ui.selectionCheckBox.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
741 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
742 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
743
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
744 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
745 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
746 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
747 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
748 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
749 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
750
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
751 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
752 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
753 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
754 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
755 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
756 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
757
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
758 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
759 def on_replaceButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
760 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
761 Private slot to replace one occurrence of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
762 """
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
763 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
764
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
765 @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
766 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
767 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
768 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
769 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
770 """
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
771 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
772
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
773 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
774 """
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
775 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
776
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
777 @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
778 (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
779 """
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
780 self.__finding = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
781
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
782 # Check enabled status due to dual purpose usage of this method
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
783 if not self.ui.replaceButton.isEnabled() and \
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
784 not self.ui.replaceSearchButton.isEnabled():
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
785 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
786
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
787 ftxt = self.ui.findtextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
788 rtxt = self.ui.replacetextCombo.currentText()
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 # 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
791 # of the list and updates the combobox
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
792 if rtxt in self.replaceHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
793 self.replaceHistory.remove(rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
794 self.replaceHistory.insert(0, rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
795 self.ui.replacetextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
796 self.ui.replacetextCombo.addItems(self.replaceHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
797
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
798 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
799 aw.hideFindIndicator()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
800 aw.replace(rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
801
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
802 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
803 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
804
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 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
806 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
807 self.__setReplaceAndSearchEnabled(False)
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
808 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
809 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
810 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
811 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
812 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
813 self.__setReplaceAndSearchEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
814
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
815 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
816
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
817 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
818 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
819 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
820 """
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
821 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
822 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
823
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
824 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
825 def on_replaceAllButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
826 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
827 Private slot to replace all occurrences of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
828 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
829 self.__finding = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
830
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
831 replacements = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
832 ftxt = self.ui.findtextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
833 rtxt = self.ui.replacetextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
834
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
835 # 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
836 # of the list and updates the combobox
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
837 if ftxt in self.findHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
838 self.findHistory.remove(ftxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
839 self.findHistory.insert(0, ftxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
840 self.ui.findtextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
841 self.ui.findtextCombo.addItems(self.findHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
842
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
843 if rtxt in self.replaceHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
844 self.replaceHistory.remove(rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
845 self.replaceHistory.insert(0, rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
846 self.ui.replacetextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
847 self.ui.replacetextCombo.addItems(self.replaceHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
848
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
849 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
850 aw.hideFindIndicator()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
851 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
852 boundary = self.__selectionBoundary()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
853 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
854 line, index = boundary[:2]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
855 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
856 line = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
857 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
858 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
859 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
860 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
861 self.ui.regexpCheckBox.isChecked())
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
862 ok = aw.findFirst(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
863 ftxt,
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
864 self.ui.regexpCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
865 self.ui.caseCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
866 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
867 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
868 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
869 cxx11=cxx11Mode)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
870
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
871 if ok and self.ui.selectionCheckBox.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
872 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
873 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
874 for sel in 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
875 if lineFrom == sel[0] and \
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
876 indexFrom >= sel[1] and \
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
877 indexTo <= sel[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
878 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
879 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
880 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
881 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
882 elif (lineFrom == boundary[0] and indexFrom >= boundary[1]) or \
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
883 (lineFrom > boundary[0] and lineFrom < boundary[2]) or \
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
884 (lineFrom == boundary[2] and indexFrom <= boundary[3]):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
885 ok = True
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 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
888 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
889 # 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
890 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
891 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
892 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
893 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
894 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
895 if ind < len(self.__selections) - 1:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
896 line, index = \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
897 self.__selections[ind + 1][:2]
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
898 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
899 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
900 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
901 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
902 break
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
903 ok = aw.findFirst(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
904 ftxt,
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
905 self.ui.regexpCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
906 self.ui.caseCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
907 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
908 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
909 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
910 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
911 if ok:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
912 lineFrom, indexFrom, lineTo, indexTo = \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
913 aw.getSelection()
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
914 if lineFrom < boundary[0] or \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
915 lineFrom > boundary[2] or \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
916 indexFrom < boundary[1] or \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
917 indexFrom > boundary[3] or \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
918 indexTo < boundary[1] or \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
919 indexTo > boundary[3]:
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
920 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
921 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
922
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:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
924 aw.selectAll(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
925 aw.setCursorPosition(cline, cindex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
926 aw.ensureCursorVisible()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
927
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
928 found = ok
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
929
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
930 aw.beginUndoAction()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
931 wordWrap = self.ui.wrapCheckBox.isChecked()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
932 self.ui.wrapCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
933 while ok:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
934 aw.replace(rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
935 replacements += 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
936 ok = self.__findNextPrev(ftxt, self.__findBackwards)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
937 self.__finding = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
938 aw.endUndoAction()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
939 if wordWrap:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
940 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
941 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
942 self.__setReplaceAndSearchEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
943
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
944 if found:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
945 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
946 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
947 self.tr("Replaced {0} occurrences.")
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
948 .format(replacements))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
949 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
950 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
951 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
952 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
953 .format(ftxt))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
954
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
955 aw.setCursorPosition(cline, cindex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
956 aw.ensureCursorVisible()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
957
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
958 self.__finding = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
959
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
960 def __showReplace(self, text=''):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
961 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
962 Private slot to display this widget in replace mode.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
963
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
964 @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
965 """
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
966 self.__replace = True
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
967
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
968 self.ui.findtextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
969 self.ui.findtextCombo.addItems(self.findHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
970 self.ui.findtextCombo.setEditText(text)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
971 self.ui.findtextCombo.lineEdit().selectAll()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
972 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
973 self.on_findtextCombo_editTextChanged(text)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
974
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
975 self.ui.replacetextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
976 self.ui.replacetextCombo.addItems(self.replaceHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
977 self.ui.replacetextCombo.setEditText('')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
978
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
979 self.ui.caseCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
980 self.ui.wordCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
981 self.ui.regexpCheckBox.setChecked(False)
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 self.havefound = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
984
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
985 aw = self.__viewmanager.activeWindow()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
986 self.updateSelectionCheckBox(aw)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
987 if aw.hasSelectedText():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
988 line1, index1, line2, index2 = aw.getSelection()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
989 if line1 == line2:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
990 aw.setSelection(line1, index1, line1, index1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
991 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
992
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
993 self.__setShortcuts()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
994
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
995 def show(self, text=''):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
996 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
997 Public slot to show the widget.
0
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 @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
1000 """
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
1001 if self.__replace:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1002 self.__showReplace(text)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1003 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1004 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
1005 super(SearchReplaceWidget, self).show()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1006 self.activateWindow()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1007
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1008 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1009 def on_closeButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1010 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1011 Private slot to close the widget.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1012 """
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
1013 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
1014 if aw:
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
1015 aw.hideFindIndicator()
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
1016
2362
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1017 if self.__sliding:
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1018 self.__topWidget.close()
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1019 else:
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1020 self.close()
0
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 def keyPressEvent(self, event):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1023 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1024 Protected slot to handle key press events.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1025
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1026 @param event reference to the key press event (QKeyEvent)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1027 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1028 if event.key() == Qt.Key_Escape:
5742
dc9cd8059221 Added the capability to perform the various replace methods via keyboard shortcuts.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
1029 aw = self.__viewmanager.activeWindow()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1030 if aw:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1031 aw.setFocus(Qt.ActiveWindowFocusReason)
3069
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
1032 aw.hideFindIndicator()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1033 event.accept()
2362
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1034 if self.__sliding:
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1035 self.__topWidget.close()
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1036 else:
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1037 self.close()
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1038
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1039
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1040 class SearchReplaceSlidingWidget(QWidget):
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1041 """
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1042 Class implementing the search and replace widget with sliding behavior.
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1043
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1044 @signal searchListChanged() emitted to indicate a change of the search list
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1045 """
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1046 searchListChanged = pyqtSignal()
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1047
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1048 def __init__(self, replace, vm, parent=None):
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1049 """
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1050 Constructor
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1051
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1052 @param replace flag indicating a replace widget is called
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1053 @param vm reference to the viewmanager object
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
1054 @param parent parent widget of this widget (QWidget)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset