(self)
return True
Replace search pattern in text with replacement value.
Replace search pattern in text with replacement value.
Replace search pattern in text with replacement value .
def do_replace(self):
        "Replace search pattern in text with replacement value."
        prog = self.engine.getprog()
        if not prog:
            return False
        text = self.text
        try:
            first = pos = text.index("sel.first")
            last = text.index("sel.last")
        except TclError:
            pos = None
        if not pos:
            first = last = pos = text.index("insert")
        line, col = searchengine.get_line_col(pos)
        chars = text.get("%d.0" % line, "%d.0" % (line+1))
        m = prog.match(chars, col)
        if not prog:
            return False
        new = self._replace_expand(m, self.replvar.get())
        if new is None:
            return False
        text.mark_set("insert", first)
        text.undo_block_start()
        if m.group():
            text.delete(first, last)
        if new:
            text.insert(first, new, self.insert_tags)
        text.undo_block_stop()
        self.show_hit(first, text.index("insert"))
        self.ok = False
        return True
def do_replace ( self ) : prog = self . engine . getprog ( ) if not prog : return False text = self . text try : first = pos = text . index ( "sel.first" ) last = text . index ( "sel.last" ) except TclError : pos = None if not pos : first = last = pos = text . index ( "insert" ) line , col = searchengine . get_line_col ( pos ) chars = text . get ( "%d.0" % line , "%d.0" % ( line + 1 ) ) m = prog . match ( chars , col ) if not prog : return False new = self . _replace_expand ( m , self . replvar . get ( ) ) if new is None : return False text . mark_set ( "insert" , first ) text . undo_block_start ( ) if m . group ( ) : text . delete ( first , last ) if new : text . insert ( first , new , self . insert_tags ) text . undo_block_stop ( ) self . show_hit ( first , text . index ( "insert" ) ) self . ok = False return True