eric6/QScintilla/SearchReplaceWidget.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 8130
5fe4ff181b68
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

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