#NEWLINE# def set_run( self , start , end , value ) : #NEWLINE# #INDENT# 'Set the value of a range of characters.\n\n        :Parameters:\n            `start` : int\n                Start index of range.\n            `end` : int\n                End of range, exclusive.\n            `value` : object\n                Value to set over the range.\n\n        ' #NEWLINE# if ( ( end - start ) <= 0 ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# i = 0 #NEWLINE# start_i = None #NEWLINE# start_trim = 0 #NEWLINE# end_i = None #NEWLINE# end_trim = 0 #NEWLINE# for ( run_i , run ) in enumerate ( self . runs ) : #NEWLINE# #INDENT# count = run . count #NEWLINE# if ( i < start < ( i + count ) ) : #NEWLINE# #INDENT# start_i = run_i #NEWLINE# start_trim = ( start - i ) #NEWLINE# #UNINDENT# if ( i < end < ( i + count ) ) : #NEWLINE# #INDENT# end_i = run_i #NEWLINE# end_trim = ( end - i ) #NEWLINE# #UNINDENT# i += count #NEWLINE# #UNINDENT# if ( start_i is not None ) : #NEWLINE# #INDENT# run = self . runs [ start_i ] #NEWLINE# self . runs . insert ( start_i , _Run ( run . value , start_trim ) ) #NEWLINE# run . count -= start_trim #NEWLINE# if ( end_i is not None ) : #NEWLINE# #INDENT# if ( end_i == start_i ) : #NEWLINE# #INDENT# end_trim -= start_trim #NEWLINE# #UNINDENT# end_i += 1 #NEWLINE# #UNINDENT# #UNINDENT# if ( end_i is not None ) : #NEWLINE# #INDENT# run = self . runs [ end_i ] #NEWLINE# self . runs . insert ( end_i , _Run ( run . value , end_trim ) ) #NEWLINE# run . count -= end_trim #NEWLINE# #UNINDENT# i = 0 #NEWLINE# for run in self . runs : #NEWLINE# #INDENT# if ( ( start <= i ) and ( ( i + run . count ) <= end ) ) : #NEWLINE# #INDENT# run . value = value #NEWLINE# #UNINDENT# i += run . count #NEWLINE# #UNINDENT# last_run = self . runs [ 0 ] #NEWLINE# for run in self . runs [ 1 : ] : #NEWLINE# #INDENT# if ( run . value == last_run . value ) : #NEWLINE# #INDENT# run . count += last_run . count #NEWLINE# last_run . count = 0 #NEWLINE# #UNINDENT# last_run = run #NEWLINE# #UNINDENT# self . runs = [ r for r in self . runs if ( r . count > 0 ) ]