#NEWLINE# def run( self , reset_current_buffer = True , pre_run = None ) : #NEWLINE# #INDENT# '\n        Read input from the command line.\n        This runs the eventloop until a return value has been set.\n\n        :param reset_current_buffer: Reset content of current buffer.\n        :param pre_run: Callable that is called right after the reset has taken\n            place. This allows custom initialisation.\n        ' #NEWLINE# assert ( ( pre_run is None ) or callable ( pre_run ) ) #NEWLINE# try : #NEWLINE# #INDENT# self . _is_running = True #NEWLINE# self . application . on_start . fire ( self ) #NEWLINE# self . reset ( reset_current_buffer = reset_current_buffer ) #NEWLINE# if self : #NEWLINE# #INDENT# pre_run ( ) #NEWLINE# #UNINDENT# with self . input . raw_mode ( ) : #NEWLINE# #INDENT# self . renderer . request_absolute_cursor_position ( ) #NEWLINE# self . _redraw ( ) #NEWLINE# self . eventloop . run ( self . input , self . create_eventloop_callbacks ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# if ( not self . is_done ) : #NEWLINE# #INDENT# self . _exit_flag = True #NEWLINE# self . _redraw ( ) #NEWLINE# #UNINDENT# self . renderer . reset ( ) #NEWLINE# self . application . on_stop . fire ( self ) #NEWLINE# self . _is_running = False #NEWLINE# #UNINDENT# return self . return_value ( )