QScintilla/SearchReplaceWidget.py

Sat, 05 Jul 2014 15:02:45 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 05 Jul 2014 15:02:45 +0200
changeset 3682
2543741b47b7
parent 3656
441956d8fce5
child 3685
7c83da3cc0bf
permissions
-rw-r--r--

Changed a few files to reference eric6.

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
3160
209a07d7e401 Updated copyright for 2014.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3069
diff changeset
3 # Copyright (c) 2008 - 2014 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
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3591
diff changeset
12 from PyQt5.QtCore import pyqtSignal, Qt, pyqtSlot
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
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.viewmanager = vm
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 self.replace = replace
2362
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
48 self.__sliding = sliding
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
49 if sliding:
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
50 self.__topWidget = parent
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.findHistory = vm.getSRHistory('search')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 if replace:
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2375
diff changeset
54 from .Ui_ReplaceWidget import Ui_ReplaceWidget
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 self.replaceHistory = vm.getSRHistory('replace')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.ui = Ui_ReplaceWidget()
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
57 whatsThis = self.tr(
3017
6a8cb7632448 Updated translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
58 r"""<b>Find and Replace</b>
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
59 <p>This dialog is used to find some text and replace it with another text.
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
60 By checking the various checkboxes, the search can be made more specific.
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
61 The search string might be a regular expression. In a regular expression,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
62 special characters interpreted are:</p>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 else:
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2375
diff changeset
66 from .Ui_SearchWidget import Ui_SearchWidget
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 self.ui = Ui_SearchWidget()
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
68 whatsThis = self.tr(
3017
6a8cb7632448 Updated translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
69 r"""<b>Find</b>
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
70 <p>This dialog is used to find some text. By checking the various checkboxes,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
71 the search can be made more specific. The search string might be a regular
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
72 expression. In a regular expression, special characters interpreted are:</p>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 self.ui.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 if not replace:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.ui.wrapCheckBox.setChecked(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
79 whatsThis += self.tr(
3017
6a8cb7632448 Updated translations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3011
diff changeset
80 r"""<table border="0">
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 <tr><td><code>.</code></td><td>Matches any character</td></tr>
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
82 <tr><td><code>\(</code></td><td>This marks the start of a region for tagging a
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
83 match.</td></tr>
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
84 <tr><td><code>\)</code></td><td>This marks the end of a tagged region.
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
85 </td></tr>
1232
ed31e909cf2e Harmonisation of some display strings related to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
86 <tr><td><code>\\n</code></td>
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
87 <td>Where <code>n</code> is 1 through 9 refers to the first through ninth
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
88 tagged region when replacing. For example, if the search string was
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
89 <code>Fred\([1-9]\)XXX</code> and the replace string was <code>Sam\1YYY</code>,
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
90 when applied to <code>Fred2XXX</code> this would generate <code>Sam2YYY</code>.
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
91 </td></tr>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 <tr><td><code>\&lt;</code></td>
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
93 <td>This matches the start of a word using Scintilla's definitions of words.
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
94 </td></tr>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 <tr><td><code>\&gt;</code></td>
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
96 <td>This matches the end of a word using Scintilla's definition of words.
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
97 </td></tr>
1232
ed31e909cf2e Harmonisation of some display strings related to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1131
diff changeset
98 <tr><td><code>\\x</code></td>
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
99 <td>This allows you to use a character x that would otherwise have a special
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
100 meaning. For example, \\[ would be interpreted as [ and not as the start of a
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
101 character set.</td></tr>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 <tr><td><code>[...]</code></td>
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
103 <td>This indicates a set of characters, for example, [abc] means any of the
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
104 characters a, b or c. You can also use ranges, for example [a-z] for any lower
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
105 case character.</td></tr>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 <tr><td><code>[^...]</code></td>
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
107 <td>The complement of the characters in the set. For example, [^A-Za-z] means
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
108 any character except an alphabetic character.</td></tr>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 <tr><td><code>^</code></td>
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
110 <td>This matches the start of a line (unless used inside a set, see above).
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
111 </td></tr>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 <tr><td><code>$</code></td> <td>This matches the end of a line.</td></tr>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 <tr><td><code>*</code></td>
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
114 <td>This matches 0 or more times. For example, <code>Sa*m</code> matches
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
115 <code>Sm</code>, <code>Sam</code>, <code>Saam</code>, <code>Saaam</code>
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
116 and so on.</td></tr>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 <tr><td><code>+</code></td>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 <td>This matches 1 or more times. For example, <code>Sa+m</code> matches
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 <code>Sam</code>, <code>Saam</code>, <code>Saaam</code> and so on.</td></tr>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 </table>
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
121 """) # __IGNORE_WARNING__
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 self.setWhatsThis(whatsThis)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 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
125 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
126 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
127 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
128 UI.PixmapCache.getIcon("1rightarrow.png"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 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
131 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
132 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
133 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
134 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
135 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
136 UI.PixmapCache.getIcon("editReplaceAll.png"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
138 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
139 self.__findByReturnPressed)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 if replace:
482
4650a72c307a Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 454
diff changeset
141 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
142 self.on_replaceButton_clicked)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
144 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
145 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
146 self.tr('Find Next'),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
147 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
148 self.findNextAct.triggered.connect(self.on_findNextButton_clicked)
143
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
149 self.findNextAct.setEnabled(False)
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
150 self.ui.findtextCombo.addAction(self.findNextAct)
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
151
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
152 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
153 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
154 self.tr('Find Prev'),
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
155 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
156 self.findPrevAct.triggered.connect(self.on_findPrevButton_clicked)
143
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
157 self.findPrevAct.setEnabled(False)
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
158 self.ui.findtextCombo.addAction(self.findPrevAct)
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
159
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 self.havefound = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 self.__pos = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 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
163 self.__selections = []
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 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
165
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
166 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
167 """
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
168 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
169
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
170 @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
171 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
172 @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
173 (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
174 """
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
175 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
176 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
177 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
178 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
179 [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
180 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
181 [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
182 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
183 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
184 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
185 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
186 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
187
5b834d76f617 Added code to limit the search function of the editor to rectangular selections as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2650
diff changeset
188 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
189
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 def on_findtextCombo_editTextChanged(self, txt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 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
193
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2689
diff changeset
194 @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
195 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 if not txt:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 self.ui.findNextButton.setEnabled(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
198 self.findNextAct.setEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 self.ui.findPrevButton.setEnabled(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
200 self.findPrevAct.setEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201 if self.replace:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 self.ui.replaceButton.setEnabled(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
203 self.ui.replaceSearchButton.setEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 self.ui.replaceAllButton.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
206 self.ui.findNextButton.setEnabled(True)
143
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
207 self.findNextAct.setEnabled(True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 self.ui.findPrevButton.setEnabled(True)
143
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
209 self.findPrevAct.setEnabled(True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 if self.replace:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 self.ui.replaceButton.setEnabled(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
212 self.ui.replaceSearchButton.setEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 self.ui.replaceAllButton.setEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 def on_findNextButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 Private slot to find the next occurrence of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 self.findNext()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 def findNext(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 Public slot to find the next occurrence of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 if not self.havefound or not self.ui.findtextCombo.currentText():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 self.show(self.viewmanager.textForFind())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 self.__findBackwards = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 txt = self.ui.findtextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 # 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
234 # of the list and updates the combobox
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 if txt in self.findHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 self.findHistory.remove(txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 self.findHistory.insert(0, txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 self.ui.findtextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 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
240 self.searchListChanged.emit()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 ok = self.__findNextPrev(txt, False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 if ok:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 if self.replace:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 self.ui.replaceButton.setEnabled(True)
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
246 self.ui.replaceSearchButton.setEnabled(True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
248 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
249 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
250 self.tr("'{0}' was not found.").format(txt))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 def on_findPrevButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 Private slot to find the previous occurrence of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 self.findPrev()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
258
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 def findPrev(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 Public slot to find the next previous of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 if not self.havefound or not self.ui.findtextCombo.currentText():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 self.show(self.viewmanager.textForFind())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 self.__findBackwards = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 txt = self.ui.findtextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 # 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
271 # of the list and updates the combobox
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 if txt in self.findHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 self.findHistory.remove(txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 self.findHistory.insert(0, txt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 self.ui.findtextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 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
277 self.searchListChanged.emit()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 ok = self.__findNextPrev(txt, True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 if ok:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 if self.replace:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 self.ui.replaceButton.setEnabled(True)
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
283 self.ui.replaceSearchButton.setEnabled(True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
285 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
286 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
287 self.tr("'{0}' was not found.").format(txt))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
288
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 def __findByReturnPressed(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
291 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
292 combobox.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 if self.__findBackwards:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 self.findPrev()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 self.findNext()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 def __markOccurrences(self, txt):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301 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
302
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 @param txt text to search for (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 aw = self.viewmanager.activeWindow()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 lineFrom = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 indexFrom = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 lineTo = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 indexTo = -1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 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
311 lineFrom, indexFrom, lineTo, indexTo = self.__selectionBoundary()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 aw.clearSearchIndicators()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
314 ok = aw.findFirstTarget(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
315 txt,
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
316 self.ui.regexpCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
317 self.ui.caseCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
318 self.ui.wordCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
319 lineFrom, indexFrom, lineTo, indexTo)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
320 while ok:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 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
322 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
323 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
324 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
325 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
326 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
327 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
328 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
329 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
330 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
331 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
332 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
333 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
334 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
335 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
336 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
337 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
338 aw.setSearchIndicator(tgtPos, tgtLen)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 ok = aw.findNextTarget()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 def __findNextPrev(self, txt, backwards):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 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
344
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 @param txt text to search for (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 @param backwards flag indicating a backwards search (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
347 @return flag indicating success (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
348 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
349 self.__finding = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 if Preferences.getEditor("SearchMarkersEnabled"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
352 self.__markOccurrences(txt)
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 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
355 aw.hideFindIndicator()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 cline, cindex = aw.getCursorPosition()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 ok = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 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
360 boundary = self.__selectionBoundary()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 if backwards:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 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
363 (lineFrom, indexFrom, lineTo, indexTo) == boundary:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
364 # 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
365 line, index = boundary[2:]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 else:
1530
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
367 if (lineFrom, indexFrom) == (-1, -1):
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
368 # no selection present
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
369 line = cline
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
370 index = cindex
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
371 else:
e008f34c245b Fixed an issue searching backwards in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1527
diff changeset
372 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
373 index = indexFrom
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 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
375 line == boundary[0] and \
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 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
377 index < boundary[1]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 ok = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 if ok and index < 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 line -= 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 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
383 if line < boundary[0]:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 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
385 line, index = boundary[2:]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 ok = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 index = aw.lineLength(line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 if line < 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 if self.ui.wrapCheckBox.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 line = aw.lines() - 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 index = aw.lineLength(line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 ok = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 index = aw.lineLength(line)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400 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
401 (lineFrom, indexFrom, lineTo, indexTo) == boundary:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402 # 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
403 line, index = boundary[:2]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 line = lineTo
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 index = indexTo
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 if ok:
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
409 ok = aw.findFirst(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
410 txt,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 self.ui.regexpCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 self.ui.caseCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 self.ui.wordCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414 self.ui.wrapCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 not backwards,
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 line, index)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 if ok and self.ui.selectionCheckBox.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 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
420 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
421 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
422 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
423 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
424 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
425 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
426 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
427 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
428 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
429 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
430 (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
431 (lineFrom == boundary[2] and indexFrom <= boundary[3]):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432 ok = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 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
434 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
435 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
436 # 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
437 while not ok and \
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
438 ((backwards and lineFrom >= boundary[0]) or
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
439 (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
440 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
441 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
442 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
443 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
444 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
445 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
446 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
447 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
448 line, index = \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
449 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
450 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
451 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
452 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
453 line, index = \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
454 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
455 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
456 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
457 break
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 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
459 break
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
460 ok = aw.findFirst(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
461 txt,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 self.ui.regexpCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463 self.ui.caseCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464 self.ui.wordCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 self.ui.wrapCheckBox.isChecked(),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 not backwards,
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 line, index)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468 if ok:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
469 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
470 aw.getSelection()
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
471 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
472 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
473 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
474 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
475 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
476 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
477 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
478 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
479 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
480 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
481 # 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
482 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
483 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
484 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
485 line, index = boundary[:2]
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
486 ok = aw.findFirst(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
487 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
488 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
489 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
490 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
491 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
492 not 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
493 line, 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
494 if ok:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
495 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
496 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
497 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
498 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
499 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
500 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
501 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
502 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
503 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
504 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
505 ok = False
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
506 elif (lineFrom == boundary[0] and
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
507 indexFrom >= boundary[1]) or \
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
508 (lineFrom > boundary[0] and
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
509 lineFrom < boundary[2]) or \
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3030
diff changeset
510 (lineFrom == boundary[2]
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
511 and indexFrom <= boundary[3]):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
512 ok = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
513 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
514 ok = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
515 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516 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
517
5b834d76f617 Added 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 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
519 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
520 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
521 aw.ensureCursorVisible()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
522
3069
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
523 if ok:
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
524 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
525 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
526
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527 self.__finding = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
528
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529 return ok
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
531 def __showFind(self, text=''):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
532 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
533 Private method to display this widget in find mode.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
535 @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
536 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
537 self.replace = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
538
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539 self.ui.findtextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
540 self.ui.findtextCombo.addItems(self.findHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541 self.ui.findtextCombo.setEditText(text)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 self.ui.findtextCombo.lineEdit().selectAll()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543 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
544 self.on_findtextCombo_editTextChanged(text)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546 self.ui.caseCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
547 self.ui.wordCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 self.ui.wrapCheckBox.setChecked(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549 self.ui.regexpCheckBox.setChecked(False)
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 aw = self.viewmanager.activeWindow()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
552 self.updateSelectionCheckBox(aw)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553
143
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
554 self.findNextAct.setShortcut(self.viewmanager.searchNextAct.shortcut())
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
555 self.findNextAct.setAlternateShortcut(
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
556 self.viewmanager.searchNextAct.alternateShortcut())
145
96d12f8ab3d7 Fixed an issue introduced by the F3 change of the embedded search widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 143
diff changeset
557 self.findNextAct.setShortcutContext(Qt.WidgetShortcut)
143
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
558 self.findPrevAct.setShortcut(self.viewmanager.searchPrevAct.shortcut())
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
559 self.findPrevAct.setAlternateShortcut(
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
560 self.viewmanager.searchPrevAct.alternateShortcut())
145
96d12f8ab3d7 Fixed an issue introduced by the F3 change of the embedded search widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 143
diff changeset
561 self.findPrevAct.setShortcutContext(Qt.WidgetShortcut)
143
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
562
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563 self.havefound = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
564 self.__findBackwards = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
565
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
566 def selectionChanged(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
568 Public slot tracking changes of selected text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
569 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570 aw = self.sender()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
571 self.updateSelectionCheckBox(aw)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
572
486
e4711a55e482 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 482
diff changeset
573 @pyqtSlot(Editor)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
574 def updateSelectionCheckBox(self, editor):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
575 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
576 Public slot to update the selection check box.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
577
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
578 @param editor reference to the editor (Editor)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
579 """
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
580 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
581 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
582 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
583 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
584 self.__selectionBoundary(selections)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
585 if line1 != line2:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
586 self.ui.selectionCheckBox.setEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
587 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
588 self.__selections = selections
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
589 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
590
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
591 self.ui.selectionCheckBox.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
592 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
593 self.__selections = []
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
594
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
595 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
596 def on_replaceButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
597 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
598 Private slot to replace one occurrence of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
599 """
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
600 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
601
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
602 @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
603 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
604 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
605 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
606 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
607 """
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
608 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
609
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
610 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
611 """
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
612 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
613
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
614 @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
615 (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
616 """
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
617 self.__finding = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
618
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
619 # 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
620 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
621 not self.ui.replaceSearchButton.isEnabled():
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
622 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
623
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
624 ftxt = self.ui.findtextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
625 rtxt = self.ui.replacetextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
626
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
627 # 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
628 # of the list and updates the combobox
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
629 if rtxt in self.replaceHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
630 self.replaceHistory.remove(rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
631 self.replaceHistory.insert(0, rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
632 self.ui.replacetextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
633 self.ui.replacetextCombo.addItems(self.replaceHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
634
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
635 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
636 aw.hideFindIndicator()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
637 aw.replace(rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
638
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
639 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
640 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
641
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
642 if not ok:
b60af978f526 Added the capability to replace just the selected occurence of the search text.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
643 self.ui.replaceButton.setEnabled(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
644 self.ui.replaceSearchButton.setEnabled(False)
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
645 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
646 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
647 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
648 else:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
649 self.ui.replaceButton.setEnabled(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
650 self.ui.replaceSearchButton.setEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
651
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
652 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
653
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
654 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
655 def on_replaceAllButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
656 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
657 Private slot to replace all occurrences of text.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
658 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
659 self.__finding = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
660
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
661 replacements = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
662 ftxt = self.ui.findtextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
663 rtxt = self.ui.replacetextCombo.currentText()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
664
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
665 # 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
666 # of the list and updates the combobox
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
667 if ftxt in self.findHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
668 self.findHistory.remove(ftxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
669 self.findHistory.insert(0, ftxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
670 self.ui.findtextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
671 self.ui.findtextCombo.addItems(self.findHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
672
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
673 if rtxt in self.replaceHistory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
674 self.replaceHistory.remove(rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
675 self.replaceHistory.insert(0, rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
676 self.ui.replacetextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
677 self.ui.replacetextCombo.addItems(self.replaceHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
678
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
679 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
680 aw.hideFindIndicator()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
681 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
682 boundary = self.__selectionBoundary()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
683 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
684 line, index = boundary[:2]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
685 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
686 line = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
687 index = 0
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
688 ok = aw.findFirst(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
689 ftxt,
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
690 self.ui.regexpCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
691 self.ui.caseCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
692 self.ui.wordCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
693 False, True, line, index)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
694
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
695 if ok and self.ui.selectionCheckBox.isChecked():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
696 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
697 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
698 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
699 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
700 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
701 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
702 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
703 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
704 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
705 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
706 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
707 (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
708 (lineFrom == boundary[2] and indexFrom <= boundary[3]):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
709 ok = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
710 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
711 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
712 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
713 # 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
714 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
715 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
716 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
717 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
718 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
719 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
720 line, index = \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
721 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
722 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
723 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
724 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
725 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
726 break
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
727 ok = aw.findFirst(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
728 ftxt,
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
729 self.ui.regexpCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
730 self.ui.caseCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
731 self.ui.wordCheckBox.isChecked(),
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
732 False, True, line, index)
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
733 if ok:
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
734 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
735 aw.getSelection()
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
736 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
737 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
738 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
739 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
740 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
741 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
742 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
743 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
744
0fd6f92ab2dd Added code to support a replace operation in rectangular selections in the editor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2660
diff changeset
745 if not ok:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
746 aw.selectAll(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
747 aw.setCursorPosition(cline, cindex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
748 aw.ensureCursorVisible()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
749
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
750 found = ok
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
751
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
752 aw.beginUndoAction()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
753 wordWrap = self.ui.wrapCheckBox.isChecked()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
754 self.ui.wrapCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
755 while ok:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
756 aw.replace(rtxt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
757 replacements += 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
758 ok = self.__findNextPrev(ftxt, self.__findBackwards)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
759 self.__finding = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
760 aw.endUndoAction()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
761 if wordWrap:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
762 self.ui.wrapCheckBox.setChecked(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
763 self.ui.replaceButton.setEnabled(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
764 self.ui.replaceSearchButton.setEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
765
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
766 if found:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
767 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
768 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
769 self.tr("Replaced {0} occurrences.")
3039
8dd0165d805d Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
770 .format(replacements))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
771 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
772 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3017
diff changeset
773 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
774 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
775 .format(ftxt))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
776
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
777 aw.setCursorPosition(cline, cindex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
778 aw.ensureCursorVisible()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
779
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
780 self.__finding = False
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 def __showReplace(self, text=''):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
783 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
784 Private slot to display this widget in replace mode.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
785
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
786 @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
787 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
788 self.replace = True
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 self.ui.findtextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
791 self.ui.findtextCombo.addItems(self.findHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
792 self.ui.findtextCombo.setEditText(text)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
793 self.ui.findtextCombo.lineEdit().selectAll()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
794 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
795 self.on_findtextCombo_editTextChanged(text)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
796
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
797 self.ui.replacetextCombo.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
798 self.ui.replacetextCombo.addItems(self.replaceHistory)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
799 self.ui.replacetextCombo.setEditText('')
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
800
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
801 self.ui.caseCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
802 self.ui.wordCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
803 self.ui.regexpCheckBox.setChecked(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
804
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
805 self.havefound = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
806
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
807 aw = self.viewmanager.activeWindow()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
808 self.updateSelectionCheckBox(aw)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
809 if aw.hasSelectedText():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
810 line1, index1, line2, index2 = aw.getSelection()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
811 if line1 == line2:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
812 aw.setSelection(line1, index1, line1, index1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
813 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
814
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
815 self.findNextAct.setShortcut(self.viewmanager.searchNextAct.shortcut())
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
816 self.findNextAct.setAlternateShortcut(
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
817 self.viewmanager.searchNextAct.alternateShortcut())
145
96d12f8ab3d7 Fixed an issue introduced by the F3 change of the embedded search widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 143
diff changeset
818 self.findNextAct.setShortcutContext(Qt.WidgetShortcut)
143
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
819 self.findPrevAct.setShortcut(self.viewmanager.searchPrevAct.shortcut())
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
820 self.findPrevAct.setAlternateShortcut(
06952f173018 Fixed the F3 not working when focus is in search widget issue.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 97
diff changeset
821 self.viewmanager.searchPrevAct.alternateShortcut())
145
96d12f8ab3d7 Fixed an issue introduced by the F3 change of the embedded search widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 143
diff changeset
822 self.findPrevAct.setShortcutContext(Qt.WidgetShortcut)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
823
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
824 def show(self, text=''):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
825 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
826 Public slot to show the widget.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
827
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
828 @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
829 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
830 if self.replace:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
831 self.__showReplace(text)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
832 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
833 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
834 super(SearchReplaceWidget, self).show()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
835 self.activateWindow()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
836
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
837 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
838 def on_closeButton_clicked(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
839 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
840 Private slot to close the widget.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
841 """
3069
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
842 aw = self.viewmanager.activeWindow()
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
843 if aw:
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
844 aw.hideFindIndicator()
8a9579bbf583 Added support for find indicators to the editor (QScintilla >= 2.8).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3039
diff changeset
845
2362
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
846 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
847 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
848 else:
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
849 self.close()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
850
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
851 def keyPressEvent(self, event):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
852 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
853 Protected slot to handle key press events.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
854
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
855 @param event reference to the key press event (QKeyEvent)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
856 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
857 if event.key() == Qt.Key_Escape:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
858 aw = self.viewmanager.activeWindow()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
859 if aw:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
860 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
861 aw.hideFindIndicator()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
862 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
863 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
864 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
865 else:
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
866 self.close()
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
867
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
868
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
869 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
870 """
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
871 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
872
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
873 @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
874 """
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
875 searchListChanged = pyqtSignal()
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
876
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
877 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
878 """
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
879 Constructor
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
880
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
881 @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
882 @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
883 @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
884 """
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
885 super(SearchReplaceSlidingWidget, self).__init__(parent)
2362
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
886
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
887 self.__searchReplaceWidget = \
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
888 SearchReplaceWidget(replace, vm, self, True)
2362
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
889 srHeight = self.__searchReplaceWidget.height()
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
890
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
891 self.__layout = QHBoxLayout(self)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
892 self.setLayout(self.__layout)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
893 self.__layout.setContentsMargins(0, 0, 0, 0)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
894 self.__layout.setAlignment(Qt.AlignTop)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
895
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
896 self.__leftButton = QToolButton(self)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
897 self.__leftButton.setArrowType(Qt.LeftArrow)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
898 self.__leftButton.setSizePolicy(
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
899 QSizePolicy.Minimum, QSizePolicy.MinimumExpanding)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
900 self.__leftButton.setAutoRepeat(True)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
901
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
902 self.__scroller = QScrollArea(self)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
903 self.__scroller.setWidget(self.__searchReplaceWidget)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
904 self.__scroller.setSizePolicy(
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
905 QSizePolicy.Expanding, QSizePolicy.Minimum)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
906 self.__scroller.setMaximumHeight(srHeight)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
907 self.__scroller.setFrameShape(QFrame.NoFrame)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
908 self.__scroller.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
909 self.__scroller.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
910 self.__scroller.setWidgetResizable(False)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
911
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
912 self.__rightButton = QToolButton(self)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
913 self.__rightButton.setArrowType(Qt.RightArrow)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
914 self.__rightButton.setSizePolicy(
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
915 QSizePolicy.Minimum, QSizePolicy.MinimumExpanding)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
916 self.__rightButton.setAutoRepeat(True)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
917
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
918 self.__layout.addWidget(self.__leftButton)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
919 self.__layout.addWidget(self.__scroller)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
920 self.__layout.addWidget(self.__rightButton)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
921
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
922 self.setMaximumHeight(srHeight)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
923
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
924 self.__searchReplaceWidget.searchListChanged.connect(
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
925 self.searchListChanged)
3345
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
926 self.__leftButton.clicked.connect(self.__slideLeft)
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
927 self.__rightButton.clicked.connect(self.__slideRight)
2362
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
928
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
929 def findNext(self):
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
930 """
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
931 Public slot to find the next occurrence of text.
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
932 """
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
933 self.__searchReplaceWidget.findNext()
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
934
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
935 def findPrev(self):
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
936 """
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
937 Public slot to find the next previous of text.
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
938 """
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
939 self.__searchReplaceWidget.findPrev()
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
940
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
941 def selectionChanged(self):
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
942 """
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
943 Public slot tracking changes of selected text.
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
944 """
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
945 editor = self.sender()
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
946 self.__searchReplaceWidget.updateSelectionCheckBox(editor)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
947
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
948 @pyqtSlot(Editor)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
949 def updateSelectionCheckBox(self, editor):
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
950 """
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
951 Public slot to update the selection check box.
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
952
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
953 @param editor reference to the editor (Editor)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
954 """
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
955 self.__searchReplaceWidget.updateSelectionCheckBox(editor)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
956
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
957 def show(self, text=''):
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
958 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
959 Public slot to show the widget.
2362
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
960
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
961 @param text text to be shown in the findtext edit (string)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
962 """
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
963 self.__searchReplaceWidget.show(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
964 super(SearchReplaceSlidingWidget, self).show()
2365
7e176de4c462 Little improvement to the scroller widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2362
diff changeset
965 self.__enableScrollerButtons()
2362
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
966
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
967 def __slideLeft(self):
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
968 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
969 Private slot to move the widget to the left, i.e. show contents to the
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
970 right.
2362
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
971 """
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
972 self.__slide(True)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
973
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
974 def __slideRight(self):
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
975 """
3011
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
976 Private slot to move the widget to the right, i.e. show contents to
18292228c724 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
977 the left.
2362
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
978 """
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
979 self.__slide(False)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
980
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
981 def __slide(self, toLeft):
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
982 """
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
983 Private method to move the sliding widget.
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
984
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
985 @param toLeft flag indicating to move to the left (boolean)
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
986 """
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
987 scrollBar = self.__scroller.horizontalScrollBar()
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
988 stepSize = scrollBar.singleStep()
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
989 if toLeft:
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
990 stepSize = -stepSize
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
991 newValue = scrollBar.value() + stepSize
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
992 if newValue < 0:
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
993 newValue = 0
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
994 elif newValue > scrollBar.maximum():
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
995 newValue = scrollBar.maximum()
68a92d01c1cc Made the search and replace widgets scrollable (customisation for smaller screens).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
996 scrollBar.setValue(newValue)
2365
7e176de4c462 Little improvement to the scroller widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2362
diff changeset
997 self.__enableScrollerButtons()
7e176de4c462 Little improvement to the scroller widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2362
diff changeset
998
7e176de4c462 Little improvement to the scroller widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2362
diff changeset
999 def __enableScrollerButtons(self):
7e176de4c462 Little improvement to the scroller widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2362
diff changeset
1000 """
7e176de4c462 Little improvement to the scroller widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2362
diff changeset
1001 Private method to set the enabled state of the scroll buttons.
7e176de4c462 Little improvement to the scroller widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2362
diff changeset
1002 """
7e176de4c462 Little improvement to the scroller widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2362
diff changeset
1003 scrollBar = self.__scroller.horizontalScrollBar()
7e176de4c462 Little improvement to the scroller widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2362
diff changeset
1004 self.__leftButton.setEnabled(scrollBar.value() > 0)
7e176de4c462 Little improvement to the scroller widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2362
diff changeset
1005 self.__rightButton.setEnabled(scrollBar.value() < scrollBar.maximum())
2375
22e547cab2da Fixed an issue in the new widget scroller.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2365
diff changeset
1006
22e547cab2da Fixed an issue in the new widget scroller.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2365
diff changeset
1007 def resizeEvent(self, evt):
22e547cab2da Fixed an issue in the new widget scroller.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2365
diff changeset
1008 """
22e547cab2da Fixed an issue in the new widget scroller.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2365
diff changeset
1009 Protected method to handle resize events.
22e547cab2da Fixed an issue in the new widget scroller.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2365
diff changeset
1010
22e547cab2da Fixed an issue in the new widget scroller.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2365
diff changeset
1011 @param evt reference to the resize event (QResizeEvent)
22e547cab2da Fixed an issue in the new widget scroller.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2365
diff changeset
1012 """
22e547cab2da Fixed an issue in the new widget scroller.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2365
diff changeset
1013 self.__enableScrollerButtons()
22e547cab2da Fixed an issue in the new widget scroller.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2365
diff changeset
1014
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
1015 super(SearchReplaceSlidingWidget, self).resizeEvent(evt)

eric ide

mercurial