QScintilla/SearchReplaceWidget.py

changeset 6573
ccac2d1f6858
parent 6571
feb72cfc7807
child 6574
c13af8becbf4
equal deleted inserted replaced
6572:dd7ed346b052 6573:ccac2d1f6858
21 import Preferences 21 import Preferences
22 22
23 import UI.PixmapCache 23 import UI.PixmapCache
24 24
25 25
26 # TODO: add support for more POSIX like regexp support of QScintilla
26 class SearchReplaceWidget(QWidget): 27 class SearchReplaceWidget(QWidget):
27 """ 28 """
28 Class implementing the search and replace widget. 29 Class implementing the search and replace widget.
29 30
30 @signal searchListChanged() emitted to indicate a change of the search list 31 @signal searchListChanged() emitted to indicate a change of the search list
78 self.ui.wrapCheckBox.setChecked(True) 79 self.ui.wrapCheckBox.setChecked(True)
79 80
80 whatsThis += self.tr( 81 whatsThis += self.tr(
81 """<table border="0"> 82 """<table border="0">
82 <tr><td><code>.</code></td><td>Matches any character</td></tr> 83 <tr><td><code>.</code></td><td>Matches any character</td></tr>
83 <tr><td><code>\\(</code></td><td>This marks the start of a region for tagging a 84 <tr><td><code>(</code></td><td>This marks the start of a region for tagging a
84 match.</td></tr> 85 match.</td></tr>
85 <tr><td><code>\\)</code></td><td>This marks the end of a tagged region. 86 <tr><td><code>)</code></td><td>This marks the end of a tagged region.
86 </td></tr> 87 </td></tr>
87 <tr><td><code>\\n</code></td> 88 <tr><td><code>\\n</code></td>
88 <td>Where <code>n</code> is 1 through 9 refers to the first through ninth 89 <td>Where <code>n</code> is 1 through 9 refers to the first through ninth
89 tagged region when replacing. For example, if the search string was 90 tagged region when replacing. For example, if the search string was
90 <code>Fred\\([1-9]\\)XXX</code> and the replace string was 91 <code>Fred([1-9])XXX</code> and the replace string was
91 <code>Sam\\1YYY</code>, when applied to <code>Fred2XXX</code> this would 92 <code>Sam\\1YYY</code>, when applied to <code>Fred2XXX</code> this would
92 generate <code>Sam2YYY</code>.</td></tr> 93 generate <code>Sam2YYY</code>.</td></tr>
93 <tr><td><code>\\&lt;</code></td> 94 <tr><td><code>\\&lt;</code></td>
94 <td>This matches the start of a word using Scintilla's definitions of words. 95 <td>This matches the start of a word using Scintilla's definitions of words.
95 </td></tr> 96 </td></tr>
546 self.ui.regexpCheckBox.isChecked(), 547 self.ui.regexpCheckBox.isChecked(),
547 self.ui.caseCheckBox.isChecked(), 548 self.ui.caseCheckBox.isChecked(),
548 self.ui.wordCheckBox.isChecked(), 549 self.ui.wordCheckBox.isChecked(),
549 self.ui.wrapCheckBox.isChecked(), 550 self.ui.wrapCheckBox.isChecked(),
550 not backwards, 551 not backwards,
551 line, index) 552 line, index,
553 posix=self.ui.regexpCheckBox.isChecked())
552 554
553 if ok and self.ui.selectionCheckBox.isChecked(): 555 if ok and self.ui.selectionCheckBox.isChecked():
554 lineFrom, indexFrom, lineTo, indexTo = aw.getSelection() 556 lineFrom, indexFrom, lineTo, indexTo = aw.getSelection()
555 if len(self.__selections) > 1: 557 if len(self.__selections) > 1:
556 for sel in self.__selections: 558 for sel in self.__selections:
597 self.ui.regexpCheckBox.isChecked(), 599 self.ui.regexpCheckBox.isChecked(),
598 self.ui.caseCheckBox.isChecked(), 600 self.ui.caseCheckBox.isChecked(),
599 self.ui.wordCheckBox.isChecked(), 601 self.ui.wordCheckBox.isChecked(),
600 self.ui.wrapCheckBox.isChecked(), 602 self.ui.wrapCheckBox.isChecked(),
601 not backwards, 603 not backwards,
602 line, index) 604 line, index,
605 posix=self.ui.regexpCheckBox.isChecked())
603 if ok: 606 if ok:
604 lineFrom, indexFrom, lineTo, indexTo = \ 607 lineFrom, indexFrom, lineTo, indexTo = \
605 aw.getSelection() 608 aw.getSelection()
606 if lineFrom < boundary[0] or \ 609 if lineFrom < boundary[0] or \
607 lineFrom > boundary[2] or \ 610 lineFrom > boundary[2] or \
623 self.ui.regexpCheckBox.isChecked(), 626 self.ui.regexpCheckBox.isChecked(),
624 self.ui.caseCheckBox.isChecked(), 627 self.ui.caseCheckBox.isChecked(),
625 self.ui.wordCheckBox.isChecked(), 628 self.ui.wordCheckBox.isChecked(),
626 self.ui.wrapCheckBox.isChecked(), 629 self.ui.wrapCheckBox.isChecked(),
627 not backwards, 630 not backwards,
628 line, index) 631 line, index,
632 posix=self.ui.regexpCheckBox.isChecked())
629 if ok: 633 if ok:
630 lineFrom, indexFrom, lineTo, indexTo = \ 634 lineFrom, indexFrom, lineTo, indexTo = \
631 aw.getSelection() 635 aw.getSelection()
632 if len(self.__selections) > 1: 636 if len(self.__selections) > 1:
633 for sel in self.__selections: 637 for sel in self.__selections:
840 ok = aw.findFirst( 844 ok = aw.findFirst(
841 ftxt, 845 ftxt,
842 self.ui.regexpCheckBox.isChecked(), 846 self.ui.regexpCheckBox.isChecked(),
843 self.ui.caseCheckBox.isChecked(), 847 self.ui.caseCheckBox.isChecked(),
844 self.ui.wordCheckBox.isChecked(), 848 self.ui.wordCheckBox.isChecked(),
845 False, True, line, index) 849 False, True, line, index,
850 posix=self.ui.regexpCheckBox.isChecked())
846 851
847 if ok and self.ui.selectionCheckBox.isChecked(): 852 if ok and self.ui.selectionCheckBox.isChecked():
848 lineFrom, indexFrom, lineTo, indexTo = aw.getSelection() 853 lineFrom, indexFrom, lineTo, indexTo = aw.getSelection()
849 if len(self.__selections) > 1: 854 if len(self.__selections) > 1:
850 for sel in self.__selections: 855 for sel in self.__selections:
879 ok = aw.findFirst( 884 ok = aw.findFirst(
880 ftxt, 885 ftxt,
881 self.ui.regexpCheckBox.isChecked(), 886 self.ui.regexpCheckBox.isChecked(),
882 self.ui.caseCheckBox.isChecked(), 887 self.ui.caseCheckBox.isChecked(),
883 self.ui.wordCheckBox.isChecked(), 888 self.ui.wordCheckBox.isChecked(),
884 False, True, line, index) 889 False, True, line, index,
890 posix=self.ui.regexpCheckBox.isChecked())
885 if ok: 891 if ok:
886 lineFrom, indexFrom, lineTo, indexTo = \ 892 lineFrom, indexFrom, lineTo, indexTo = \
887 aw.getSelection() 893 aw.getSelection()
888 if lineFrom < boundary[0] or \ 894 if lineFrom < boundary[0] or \
889 lineFrom > boundary[2] or \ 895 lineFrom > boundary[2] or \

eric ide

mercurial