コード例 #1
0
    def _highlight_textbox_matches(self, textbox, select_match=True):
        buff = textbox.buffer
        buffstr = textbox.get_text()
        unescaped = markup.unescape(buffstr)

        # Make sure the 'search_highlight' tag in the textbox's tag table
        # is "fresh".
        try:
            tagtable = buff.get_tag_table()
            tag = tagtable.lookup('search_highlight')
            if tag:
                tagtable.remove(tag)
            tagtable.add(self._make_highlight_tag())
        except ValueError, ve:
            logging.exception("(Re-)adding search highlighting tag exception:")
コード例 #2
0
        def select_match_text():
            textbox.grab_focus()
            buff = textbox.buffer
            buffstr = textbox.get_text()
            unescaped = markup.unescape(buffstr)

            start, end = self._escaped_indexes(unescaped, match.start, match.end)
            if hasattr(textbox.elem, 'gui_info'):
                start = textbox.elem.gui_info.tree_to_gui_index(start)
                end = textbox.elem.gui_info.tree_to_gui_index(end)
            start_iter = buff.get_iter_at_offset(start)
            end_iter = buff.get_iter_at_offset(end)

            buff.select_range(end_iter, start_iter)
            return False