#NEWLINE# def subseg( self , text , start , end ) : #NEWLINE# #INDENT# '\n        Return a "sub-segment" list containing segment structures \n        that make up a portion of this segment.\n\n        A list is returned to handle cases where wide characters\n        need to be replaced with a space character at either edge\n        so two or three segments will be returned.\n        ' #NEWLINE# if ( start < 0 ) : #NEWLINE# #INDENT# start = 0 #NEWLINE# #UNINDENT# if ( end > self . sc ) : #NEWLINE# #INDENT# end = self . sc #NEWLINE# #UNINDENT# if ( start >= end ) : #NEWLINE# #INDENT# return [ ] #NEWLINE# #UNINDENT# if self . text : #NEWLINE# #INDENT# ( spos , epos , pad_left , pad_right ) = calc_trim_text ( self . text , 0 , len ( self . text ) , start , end ) #NEWLINE# return [ ( ( end - start ) , self . offs , ( ( bytes ( ) . ljust ( pad_left ) + self . text [ spos : epos ] ) + bytes ( ) . ljust ( pad_right ) ) ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if self . end : #NEWLINE# #INDENT# ( spos , epos , pad_left , pad_right ) = calc_trim_text ( text , self . offs , self . end , start , end ) #NEWLINE# l = [ ] #NEWLINE# if pad_left : #NEWLINE# #INDENT# l . append ( ( 1 , ( spos - 1 ) ) ) #NEWLINE# #UNINDENT# l . append ( ( ( ( ( self - start ) - pad_left ) - pad_right ) , spos , epos ) ) #NEWLINE# if pad_right : #NEWLINE# #INDENT# l . append ( ( 1 , epos ) ) #NEWLINE# #UNINDENT# return l #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return [ ( ( end - start ) , self . offs ) ]