+8
-2
@@ -504,6 +504,7 @@ class GuiDocEditor(QTextEdit):
|
|||||||
def _beginReplace(self):
|
def _beginReplace(self):
|
||||||
"""Opens the replace line of the search bar and sets the replace text.
|
"""Opens the replace line of the search bar and sets the replace text.
|
||||||
"""
|
"""
|
||||||
|
self._beginSearch()
|
||||||
self.theParent.searchBar.setReplaceText("")
|
self.theParent.searchBar.setReplaceText("")
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -536,8 +537,9 @@ class GuiDocEditor(QTextEdit):
|
|||||||
with the replace text. Wraps back to the top if not found.
|
with the replace text. Wraps back to the top if not found.
|
||||||
"""
|
"""
|
||||||
theCursor = self.textCursor()
|
theCursor = self.textCursor()
|
||||||
|
searchFor = self.theParent.searchBar.getSearchText()
|
||||||
replWith = self.theParent.searchBar.getReplaceText()
|
replWith = self.theParent.searchBar.getReplaceText()
|
||||||
if theCursor.hasSelection():
|
if theCursor.hasSelection() and theCursor.selectedText() == searchFor:
|
||||||
xPos = theCursor.selectionStart()
|
xPos = theCursor.selectionStart()
|
||||||
theCursor.beginEditBlock()
|
theCursor.beginEditBlock()
|
||||||
theCursor.removeSelectedText()
|
theCursor.removeSelectedText()
|
||||||
@@ -545,7 +547,11 @@ class GuiDocEditor(QTextEdit):
|
|||||||
theCursor.endEditBlock()
|
theCursor.endEditBlock()
|
||||||
theCursor.setPosition(xPos)
|
theCursor.setPosition(xPos)
|
||||||
self.setTextCursor(theCursor)
|
self.setTextCursor(theCursor)
|
||||||
self._findNext()
|
logger.verbose("Replaced occurrence of '%s' with '%s' on line %d" % (
|
||||||
|
searchFor, replWith, theCursor.blockNumber()
|
||||||
|
))
|
||||||
|
if searchFor != "":
|
||||||
|
self._findNext()
|
||||||
return
|
return
|
||||||
|
|
||||||
# END Class GuiDocEditor
|
# END Class GuiDocEditor
|
||||||
|
|||||||
+1
-5
@@ -81,15 +81,11 @@ class GuiSearchBar(QFrame):
|
|||||||
##
|
##
|
||||||
|
|
||||||
def setSearchText(self, theText):
|
def setSearchText(self, theText):
|
||||||
|
|
||||||
if not self.isVisible():
|
if not self.isVisible():
|
||||||
self.setVisible(True)
|
self.setVisible(True)
|
||||||
|
|
||||||
self.searchBox.setText(theText)
|
self.searchBox.setText(theText)
|
||||||
self.searchBox.setFocus(True)
|
self.searchBox.setFocus(True)
|
||||||
|
logger.verbose("Setting search text to '%s'" % theText)
|
||||||
logger.debug("Setting search text to '%s'" % theText)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def setReplaceText(self, theText):
|
def setReplaceText(self, theText):
|
||||||
|
|||||||
Reference in New Issue
Block a user