diff -r 3d14633f6261 -r e28b89693f37 src/eric7/QScintilla/SearchReplaceWidget.py --- a/src/eric7/QScintilla/SearchReplaceWidget.py Tue Dec 19 09:31:02 2023 +0100 +++ b/src/eric7/QScintilla/SearchReplaceWidget.py Tue Dec 19 11:04:03 2023 +0100 @@ -21,7 +21,7 @@ QWidget, ) -from eric7 import Preferences +from eric7 import Preferences, Utilities from eric7.EricGui import EricPixmapCache from eric7.EricGui.EricAction import EricAction from eric7.EricWidgets import EricMessageBox @@ -480,6 +480,30 @@ self.__setReplaceAndSearchEnabled(False) self.__setReplaceAllEnabled(enable) + @pyqtSlot(bool) + def on_regexpCheckBox_toggled(self, checked): + """ + Private slot handling a change of the regexp selector. + + @param checked state of the regexp selector + @type bool + """ + if checked: + # only one of regexp or escape can be selected + self.escapeCheckBox.setChecked(False) + + @pyqtSlot(bool) + def on_escapeCheckBox_toggled(self, checked): + """ + Private slot handling a change of the escape selector. + + @param checked state of the escape selector + @type bool + """ + if checked: + # only one of regexp or escape can be selected + self.regexpCheckBox.setChecked(False) + @pyqtSlot(str) def __quickSearch(self, txt): """ @@ -491,6 +515,10 @@ if Preferences.getEditor("QuickSearchEnabled"): aw = self.__viewmanager.activeWindow() aw.hideFindIndicator() + + if self.escapeCheckBox.isChecked(): + txt = Utilities.unslash(txt) + if Preferences.getEditor("QuickSearchMarkersEnabled"): self.__quickSearchMarkOccurrences(txt) @@ -498,7 +526,14 @@ lineFrom, indexFrom, lineTo, indexTo = self.__selectionBoundary() aw.highlightSearchSelection(lineFrom, indexFrom, lineTo, indexTo) else: - lineFrom, indexFrom, lineTo, indexTo = 0, 0, -1, -1 + # start quick search at the current cursor position adjusted to a + # previous quicksearch + lineFrom, indexFrom = aw.getCursorPosition() + sline, sindex, eline, eindex = aw.getSelection() + if (lineFrom, indexFrom) == (eline, eindex): + lineFrom, indexFrom = sline, sindex + lineTo = lineFrom + indexTo = indexFrom - 1 if bool(indexFrom) else 0 posixMode = ( Preferences.getEditor("SearchRegexpMode") == 0 and self.regexpCheckBox.isChecked() @@ -793,6 +828,9 @@ """ self.__finding = True + if self.escapeCheckBox.isChecked(): + txt = Utilities.unslash(txt) + if Preferences.getEditor("SearchMarkersEnabled"): self.__markOccurrences(txt) @@ -1149,7 +1187,10 @@ aw = self.__viewmanager.activeWindow() aw.hideFindIndicator() - aw.replace(rtxt) + if self.escapeCheckBox.isChecked(): + aw.replace(Utilities.unslash(rtxt)) + else: + aw.replace(rtxt) if searchNext: ok = self.__findNextPrev(ftxt, self.__findBackwards) @@ -1220,6 +1261,9 @@ Preferences.getEditor("SearchRegexpMode") == 1 and self.regexpCheckBox.isChecked() ) + if self.escapeCheckBox.isChecked(): + ftxt = Utilities.unslash(ftxt) + ok = aw.findFirst( ftxt, self.regexpCheckBox.isChecked(), @@ -1299,6 +1343,9 @@ aw.beginUndoAction() wordWrap = self.wrapCheckBox.isChecked() self.wrapCheckBox.setChecked(False) + if self.escapeCheckBox.isChecked(): + rtxt = Utilities.unslash(rtxt) + while ok: aw.replace(rtxt) replacements += 1