
    Mh                        d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	m
Z
mZmZ ddlmZ ddlmZ d	d
gZ ed          Z	 dddZeddd            ZdS )zV
Tools for running functions on the terminal above the current application or prompt.
    )annotations)Futureensure_future)asynccontextmanager)AsyncGenerator	AwaitableCallableTypeVar)run_in_executor_with_context   )get_app_or_nonerun_in_terminalin_terminal_TFfuncCallable[[], _T]render_cli_doneboolin_executorreturnAwaitable[_T]c                F     d fd}t           |                      S )ah  
    Run function on the terminal above the current application or prompt.

    What this does is first hiding the prompt, then running this callable
    (which can safely output to the terminal), and then again rendering the
    prompt which causes the output of this function to scroll above the
    prompt.

    ``func`` is supposed to be a synchronous function. If you need an
    asynchronous version of this function, use the ``in_terminal`` context
    manager directly.

    :param func: The callable to execute.
    :param render_cli_done: When True, render the interface in the
            'Done' state first, then execute the function. If False,
            erase the interface first.
    :param in_executor: When True, run in executor. (Use this for long
        blocking functions, when you don't want to block the event loop.)

    :returns: A `Future`.
    r   r   c                    K   t                    4 d {V  r't                      d {V cd d d           d {V  S               cd d d           d {V  S # 1 d {V swxY w Y   d S )N)r   )r   r   )r   r   r   s   j/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/prompt_toolkit/application/run_in_terminal.pyrunzrun_in_terminal.<locals>.run0   sL     ??? 	 	 	 	 	 	 	 	 9$????????	 	 	 	 	 	 	 	 	 	 	 	 	 	 tvv		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   A 	A  
A*-A*)r   r   )r   )r   r   r   r   s   ``` r   r   r      sC    2            AsyncGenerator[None, None]c                 K   t                      }||j        sdW V  dS |j        }t                      }||_        || d{V  |j        j        r|j                                         d{V  | r|                    d           n|j        	                                 d|_
        	 |j                                        5  |j                                        5  dW V  ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   	 d|_
        |j                                         |                                 |                                 |                                s|                    d           dS dS # |                                s|                    d           w w xY w# 	 d|_
        |j                                         |                                 |                                 |                                s|                    d           w w # |                                s|                    d           w w xY wxY w)a  
    Asynchronous context manager that suspends the current application and runs
    the body in the terminal.

    .. code::

        async def f():
            async with in_terminal():
                call_some_function()
                await call_some_async_function()
    NT)render_as_doneF)r   _is_running_running_in_terminal_fr   outputresponds_to_cprrendererwait_for_cpr_responses_redrawerase_running_in_terminalinputdetachcooked_modereset!_request_absolute_cursor_positiondone
set_result)r   appprevious_run_in_terminal_fnew_run_in_terminal_fs       r   r   r   :   s      

C
{#/{ "%!;*0((!6C "-((((((((
 z! 4l11333333333  4((((  $C7Y 	 	&&((                	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
		7',C$L   11333KKMMM )--// 7%00666667 7(--// 7%0066667		7',C$L   11333KKMMM )--// 7%0066667(--// 7%0066667sz   ,F8 DC1%D1C5	5D8C5	9D<F8 DF8 DF8 AF	 	,F58I:AH-+I-,IIN)FF)r   r   r   r   r   r   r   r   )F)r   r   r   r   )__doc__
__future__r   asyncior   r   
contextlibr   typingr   r   r	   r
   prompt_toolkit.eventloopr   currentr   __all__r   r   r    r   r   <module>r<      s    # " " " " " ) ) ) ) ) ) ) ) * * * * * * ? ? ? ? ? ? ? ? ? ? ? ? A A A A A A $ $ $ $ $ $ 
 WT]] PU              F :7 :7 :7 :7 :7 :7 :7r   