Exemple #1
0
 def slotReplaceAll(self):
     view = self.currentView()
     if view:
         replaced = False
         cursors = self._positions
         if view.textCursor().hasSelection():
             cursors = [cursor for cursor in cursors if cursortools.contains(view.textCursor(), cursor)]
         with cursortools.compress_undo(view.textCursor()):
             for cursor in cursors:
                 if self.doReplace(cursor):
                     replaced = True
         if replaced:
             self.highlightingOn()
Exemple #2
0
 def slotReplaceAll(self):
     view = self.currentView()
     if view:
         replaced = False
         cursors = self._positions
         if view.textCursor().hasSelection():
             cursors = [cursor for cursor in cursors if cursortools.contains(view.textCursor(), cursor)]
         view.textCursor().beginEditBlock()
         for cursor in cursors:
             if self.doReplace(cursor):
                 replaced = True
         view.textCursor().endEditBlock()
         if replaced:
             viewhighlighter.highlighter(view).highlight("search", self._positions, 1)
Exemple #3
0
 def slotReplaceAll(self):
     """Called when the user clicks Replace All."""
     view = self.currentView()
     if view:
         replaced = False
         cursors = self._positions
         if view.textCursor().hasSelection():
             cursors = [cursor for cursor in cursors if cursortools.contains(view.textCursor(), cursor)]
         with cursortools.compress_undo(view.textCursor()):
             for cursor in cursors:
                 if self.doReplace(cursor):
                     replaced = True
         if replaced:
             self.highlightingOn()
Exemple #4
0
 def slotSearchChanged(self):
     self.updatePositions()
     self.highlightingOn()
     if not self._replace and self._positions:
         positions = [c.position() for c in self._positions]
         cursor = self.currentView().textCursor()
         index = bisect.bisect_left(positions, cursor.selectionStart())
         if index == len(positions):
             index -= 1
         elif index > 0:
             # it might be possible that the text cursor currently already
             # is in a search result. This happens when the search is pop up
             # with an empty text and the current word is then set as search
             # text.
             if cursortools.contains(self._positions[index-1], cursor):
                 index -= 1
         self.currentView().setTextCursor(self._positions[index])
Exemple #5
0
 def slotSearchChanged(self):
     self.updatePositions()
     self.highlightingOn()
     if not self._replace and self._positions:
         positions = [c.position() for c in self._positions]
         cursor = self.currentView().textCursor()
         index = bisect.bisect_left(positions, cursor.selectionStart())
         if index == len(positions):
             index -= 1
         elif index > 0:
             # it might be possible that the text cursor currently already
             # is in a search result. This happens when the search is pop up
             # with an empty text and the current word is then set as search
             # text.
             if cursortools.contains(self._positions[index - 1], cursor):
                 index -= 1
         self.currentView().gotoTextCursor(self._positions[index])