#NEWLINE# def _scroll_without_linewrapping( self , ui_content , width , height , cli ) : #NEWLINE# #INDENT# '\n        Scroll to make sure the cursor position is visible and that we maintain\n        the requested scroll offset.\n\n        Set `self.horizontal_scroll/vertical_scroll`.\n        ' #NEWLINE# cursor_position = ( ui_content . cursor_position or Point ( 0 , 0 ) ) #NEWLINE# self . vertical_scroll_2 = 0 #NEWLINE# if ( width . line_count == 0 ) : #NEWLINE# #INDENT# self . vertical_scroll = 0 #NEWLINE# self . horizontal_scroll = 0 #NEWLINE# return #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# current_line_text = token_list_to_text ( ui_content . get_line ( cursor_position . y ) ) #NEWLINE# #UNINDENT# def do_scroll( current_scroll , scroll_offset_start , scroll_offset_end , cursor_pos , window_size , content_size ) : #NEWLINE# #INDENT# ' Scrolling algorithm. Used for both horizontal and vertical scrolling. ' #NEWLINE# scroll_offset_start = int ( min ( scroll_offset_start , ( window_size / 2 ) , cursor_pos ) ) #NEWLINE# scroll_offset_end = int ( min ( scroll_offset_end , ( window_size / 2 ) , ( ( content_size - 1 ) - cursor_pos ) ) ) #NEWLINE# if ( current_scroll < 0 ) : #NEWLINE# #INDENT# current_scroll = 0 #NEWLINE# #UNINDENT# if ( ( not self . allow_scroll_beyond_bottom ( cli ) ) and ( current_scroll > ( content_size - window_size ) ) ) : #NEWLINE# #INDENT# current_scroll = max ( 0 , ( content_size - window_size ) ) #NEWLINE# #UNINDENT# if ( current_scroll > ( cursor_pos - scroll_offset_start ) ) : #NEWLINE# #INDENT# current_scroll = max ( 0 , ( cursor_pos - scroll_offset_start ) ) #NEWLINE# #UNINDENT# if ( current_scroll < ( ( ( cursor_pos + 1 ) - window_size ) + scroll_offset_end ) ) : #NEWLINE# #INDENT# current_scroll = ( ( ( cursor_pos + 1 ) - window_size ) + scroll_offset_end ) #NEWLINE# #UNINDENT# return current_scroll #NEWLINE# #UNINDENT# if self . get_vertical_scroll : #NEWLINE# #INDENT# self . vertical_scroll = self . get_vertical_scroll ( self ) #NEWLINE# assert isinstance ( self . vertical_scroll , int ) #NEWLINE# #UNINDENT# if self . get_horizontal_scroll : #NEWLINE# #INDENT# self . horizontal_scroll = self . get_horizontal_scroll ( self ) #NEWLINE# assert isinstance ( self . horizontal_scroll , int ) #NEWLINE# #UNINDENT# offsets = self . scroll_offsets #NEWLINE# self . vertical_scroll = do_scroll ( current_scroll = self . vertical_scroll , scroll_offset_start = offsets . top , scroll_offset_end = offsets . bottom , cursor_pos = ui_content . cursor_position . y , window_size = height , content_size = ui_content . line_count ) #NEWLINE# self . horizontal_scroll = do_scroll ( current_scroll = self . horizontal_scroll , scroll_offset_start = offsets . left , scroll_offset_end = offsets . right , cursor_pos = get_cwidth ( current_line_text [ : ui_content . cursor_position . x ] ) , window_size = width , content_size = max ( get_cwidth ( current_line_text ) , ( self . horizontal_scroll + width ) ) )