#NEWLINE# def run_sub_application( self , application , done_callback = None ) : #NEWLINE# #INDENT# "\n        Run a sub :class:`~prompt_toolkit.application.Application`.\n\n        This will suspend the main application and display the sub application\n        until that one returns a value. The value is returned by calling\n        `done_callback` with the result.\n\n        The sub application will share the same I/O of the main application.\n        That means, it uses the same input and output channels and it shares\n        the same event loop.\n\n        .. note:: Technically, it gets another Eventloop instance, but that is\n            only a proxy to our main event loop. The reason is that calling\n            'stop' --which returns the result of an application when it's\n            done-- is handled differently.\n        " #NEWLINE# assert isinstance ( application , Application ) #NEWLINE# assert ( ( done_callback is None ) or callable ( done_callback ) ) #NEWLINE# if ( self . _sub_cli is not None ) : #NEWLINE# #INDENT# raise RuntimeError ( 'Another sub application started already.' ) #NEWLINE# #UNINDENT# self . renderer . erase ( ) #NEWLINE# def done( ) : #NEWLINE# #INDENT# sub_cli . _redraw ( ) #NEWLINE# sub_cli . renderer . reset ( ) #NEWLINE# sub_cli . _is_running = False #NEWLINE# self . _sub_cli = None #NEWLINE# self . renderer . request_absolute_cursor_position ( ) #NEWLINE# self . _redraw ( ) #NEWLINE# if done_callback : #NEWLINE# #INDENT# done_callback ( sub_cli . return_value ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# sub_cli = CommandLineInterface ( application = application , eventloop = _SubApplicationEventLoop ( self , done ) , input = self . input , output = self . output ) #NEWLINE# sub_cli . _is_running = True #NEWLINE# sub_cli . _redraw ( ) #NEWLINE# self . _sub_cli = sub_cli