#NEWLINE# def replace( self , old_start , old_end , new_start , new_end ) : #NEWLINE# #INDENT# old = self . _old [ old_start : old_end ] #NEWLINE# new = self . _new [ new_start : new_end ] #NEWLINE# for ( idx , ( old_event , new_event ) ) in enumerate ( longzip ( old , new ) ) : #NEWLINE# #INDENT# if ( old_event is None ) : #NEWLINE# #INDENT# self . insert ( ( new_start + idx ) , ( new_end + idx ) ) #NEWLINE# break #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( new_event is None ) : #NEWLINE# #INDENT# self . delete ( ( old_start + idx ) , ( old_end + idx ) ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# if ( old_event [ 0 ] == new_event [ 0 ] ) : #NEWLINE# #INDENT# type = old_event [ 0 ] #NEWLINE# if ( type == START ) : #NEWLINE# #INDENT# ( _ , ( tag , attrs ) , pos ) = new_event #NEWLINE# self . enter_mark_replaced ( pos , tag , attrs ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( type == END ) : #NEWLINE# #INDENT# ( _ , tag , pos ) = new_event #NEWLINE# if ( not self . leave ( pos , tag ) ) : #NEWLINE# #INDENT# self . leave ( pos , old_event [ 1 ] ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( type == TEXT ) : #NEWLINE# #INDENT# ( _ , new_text , pos ) = new_event #NEWLINE# self . diff_text ( pos , old_event [ 1 ] , new_text ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . append ( * new_event ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( old_event [ 0 ] == TEXT ) and ( old_start [ 0 ] in ( START , END ) ) ) : #NEWLINE# #INDENT# ( _ , text , pos ) = old_event #NEWLINE# self . mark_text ( pos , text , 'del' ) #NEWLINE# ( type , data , pos ) = new_event #NEWLINE# if ( type == START ) : #NEWLINE# #INDENT# self . enter ( pos , * data ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . leave ( pos , data ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( old_event [ 0 ] in ( START , END ) ) and ( new_event [ 0 ] == TEXT ) ) : #NEWLINE# #INDENT# ( _ , text , pos ) = new_event #NEWLINE# self . mark_text ( pos , text , 'ins' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# pass