#NEWLINE# def content( self , trim_left = 0 , trim_top = 0 , cols = None , rows = None , attr_map = None ) : #NEWLINE# #INDENT# '\n        Return the canvas content as a list of rows where each row\n        is a list of (attr, cs, text) tuples.\n\n        trim_left, trim_top, cols, rows may be set by \n        CompositeCanvas when rendering a partially obscured\n        canvas.\n        ' #NEWLINE# ( maxcol , maxrow ) = ( self . cols ( ) , self . rows ( ) ) #NEWLINE# if ( not cols ) : #NEWLINE# #INDENT# cols = ( maxcol - trim_left ) #NEWLINE# #UNINDENT# if ( not rows ) : #NEWLINE# #INDENT# rows = ( maxrow - trim_top ) #NEWLINE# #UNINDENT# assert ( ( trim_left >= 0 ) and ( trim_left < maxcol ) ) #NEWLINE# assert ( ( cols > 0 ) and ( ( trim_left + cols ) <= maxcol ) ) #NEWLINE# assert ( ( trim_top >= 0 ) and ( trim_top < maxrow ) ) #NEWLINE# assert ( ( rows > 0 ) and ( ( trim_top + rows ) <= maxrow ) ) #NEWLINE# if ( trim_top or ( rows < maxrow ) ) : #NEWLINE# #INDENT# text_attr_cs = zip ( self . _text [ trim_top : ( trim_top + rows ) ] , self . _attr [ trim_top : ( trim_top + rows ) ] , self . _cs [ trim_top : ( trim_top + rows ) ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# text_attr_cs = zip ( self . _text , self . _attr , self . _cs ) #NEWLINE# #UNINDENT# for ( text , a_row , cs_row ) in i : #NEWLINE# #INDENT# if ( trim_left or ( cols < self . _maxcol ) ) : #NEWLINE# #INDENT# ( text , a_row , cs_row ) = trim_text_attr_cs ( text , a_row , cs_row , trim_left , ( trim_left + cols ) ) #NEWLINE# #UNINDENT# attr_cs = rle_product ( a_row , cs_row ) #NEWLINE# i = 0 #NEWLINE# row = [ ] #NEWLINE# for ( ( a , cs ) , run ) in attr_cs : #NEWLINE# #INDENT# if ( attr_map and ( a in attr_map ) ) : #NEWLINE# #INDENT# a = attr_map [ a ] #NEWLINE# #UNINDENT# row . append ( ( a , cs , text [ i : ( i + run ) ] ) ) #NEWLINE# i += run #NEWLINE# #UNINDENT# ( yield row )