#NEWLINE# def do_replace( self ) : #NEWLINE# #INDENT# prog = self . engine . getprog ( ) #NEWLINE# if ( not prog ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# text = self . text #NEWLINE# try : #NEWLINE# #INDENT# first = pos = text . index ( 'sel.first' ) #NEWLINE# last = text . index ( 'sel.last' ) #NEWLINE# #UNINDENT# except TclError : #NEWLINE# #INDENT# pos = None #NEWLINE# #UNINDENT# if ( not pos ) : #NEWLINE# #INDENT# first = last = pos = text . index ( 'insert' ) #NEWLINE# #UNINDENT# ( line , col ) = SearchEngine . get_line_col ( pos ) #NEWLINE# chars = text . get ( ( '%d.0' % line ) , ( '%d.0' % ( line + 1 ) ) ) #NEWLINE# m = prog . match ( chars , col ) #NEWLINE# if ( not prog ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# new = self . _replace_expand ( m , self . replvar . get ( ) ) #NEWLINE# if ( new is None ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# text . mark_set ( 'insert' , first ) #NEWLINE# text . undo_block_start ( ) #NEWLINE# if m . group ( ) : #NEWLINE# #INDENT# text . delete ( first , last ) #NEWLINE# #UNINDENT# if new : #NEWLINE# #INDENT# text . insert ( first , new ) #NEWLINE# #UNINDENT# text . undo_block_stop ( ) #NEWLINE# self . show_hit ( m , text . index ( 'insert' ) ) #NEWLINE# self . ok = 0 #NEWLINE# return True