Beispiel #1
0
    def __call__(self, select_after=True, bounds=None):
        """
        When bounds is not None then it is assumed that the user wants to replace
        the given bounds for the replaced text, thus they are not verified if they
        have 0 length(no bounds problem).
        """
        buff = self.get_parent()
        if bounds is None:
            bounds = buff.get_selection_bounds()

            # Check if there's selected text and if it matches the search text
            if get_buffer_selection(buff) != self.search_text:
                return False

        # If it does get the selection bounds
        start, end = bounds
        # Delete the old text
        buff.delete(start, end)
        # Insert the new text
        buff.insert(start, self._replace_text)

        # Select the replaced text
        if select_after:
            start = buff.get_iter_at_mark(buff.get_insert())
            start.backward_chars(len(self.replace_text))

        return True
Beispiel #2
0
 def __call__(self, select_after=True, bounds=None):
     """
     When bounds is not None then it is assumed that the user wants to replace
     the given bounds for the replaced text, thus they are not verified if they
     have 0 length(no bounds problem).
     """
     buff = self.get_parent()
     if bounds is None:
         bounds = buff.get_selection_bounds()
     
         # Check if there's selected text and if it matches the search text
         if get_buffer_selection(buff) != self.search_text:
             return False
     
     # If it does get the selection bounds
     start, end = bounds
     # Delete the old text
     buff.delete(start, end)
     # Insert the new text
     buff.insert(start, self._replace_text)
     
     # Select the replaced text
     if select_after:
         start = buff.get_iter_at_mark(buff.get_insert())
         start.backward_chars(len(self.replace_text))
     
     return True
Beispiel #3
0
    def on_show(self, dialog):
        buff = self.buffer
        
        selected_text = get_buffer_selection(buff)
        if selected_text != "":
            # There's some selected text, copy it to the search entry
            self.entry.set_text(selected_text)
        else:
            # Select some text on the buffer
            self.find_forward.activate()
            
        # Select text entry and focus on it
        self.entry.select_region(0, -1)
        self.entry.grab_focus()

        buff.search_highlight = True
Beispiel #4
0
 def get_selected_text(self):
     return get_buffer_selection(self.buffer)
Beispiel #5
0
 def get_selected_text(self):
     return get_buffer_selection(self.buffer)