
    ^hA                       % S SK Jr  S SKJr  S SKJr  S SKJrJrJ	r	  \(       a  S SK
Jr  S SKJr  SSKJr  / S	Qr " S
 S5      r\" S\" 5       S9rS\S'   SS jrSS jrSS jr\SS j5       r\ S     SS jj5       r\SS j5       rg)    )annotations)contextmanager)
ContextVar)TYPE_CHECKINGAny	Generator)Input)Output   )Application)
AppSessionget_app_sessionget_appget_app_or_noneset_appcreate_app_sessioncreate_app_session_from_ttyc                  d    \ rS rSrSr S	     S
S jjrSS jr\SS j5       r\SS j5       r	Sr
g)r      a-  
An AppSession is an interactive session, usually connected to one terminal.
Within one such session, interaction with many applications can happen, one
after the other.

The input/output device is not supposed to change during one session.

Warning: Always use the `create_app_session` function to create an
instance, so that it gets activated correctly.

:param input: Use this as a default input for all applications
    running in this session, unless an input is passed to the `Application`
    explicitly.
:param output: Use this as a default output.
Nc                *    Xl         X l        S U l        g N_input_outputapp)selfinputoutputs      \/home/james-whalen/.local/lib/python3.13/site-packages/prompt_toolkit/application/current.py__init__AppSession.__init__)   s      -1    c                $    SU R                   < S3$ )NzAppSession(app=))r   )r   s    r   __repr__AppSession.__repr__3   s     A..r"   c                X    U R                   c  SSKJn  U" 5       U l         U R                   $ )Nr   create_input)r   prompt_toolkit.input.defaultsr)   )r   r)   s     r   r   AppSession.input6   s"    ;;B&.DK{{r"   c                X    U R                   c  SSKJn  U" 5       U l         U R                   $ )Nr   create_output)r   prompt_toolkit.output.defaultsr.   )r   r.   s     r   r   AppSession.output>   s"    <<D(?DL||r"   r   NN)r   Input | Noner   Output | NonereturnNone)r4   str)r4   r	   )r4   r
   )__name__
__module____qualname____firstlineno____doc__r    r%   propertyr   r   __static_attributes__ r"   r   r   r      sX    " CG1!12?1	1/    r"   r   _current_app_session)defaultzContextVar[AppSession]c                 *    [         R                  5       $ r   )r?   getr>   r"   r   r   r   L   s    ##%%r"   c                 v    [         R                  5       n U R                  b  U R                  $ SSKJn  U" 5       $ )a  
Get the current active (running) Application.
An :class:`.Application` is active during the
:meth:`.Application.run_async` call.

We assume that there can only be one :class:`.Application` active at the
same time. There is only one terminal window, with only one stdin and
stdout. This makes the code significantly easier than passing around the
:class:`.Application` everywhere.

If no :class:`.Application` is running, then return by default a
:class:`.DummyApplication`. For practical reasons, we prefer to not raise
an exception. This way, we don't have to check all over the place whether
an actual `Application` was returned.

(For applications like pymux where we can have more than one `Application`,
we'll use a work-around to handle that.)
r   )DummyApplication)r?   rB   r   dummyrD   )sessionrD   s     r   r   r   P   s2    & #&&(G{{{{'r"   c                 B    [         R                  5       n U R                  $ )z^
Get the current active (running) Application, or return `None` if no
application is running.
r?   rB   r   )rF   s    r   r   r   l   s    
 #&&(G;;r"   c              #     #    [         R                  5       nUR                  nXl         Sv   X!l        g! X!l        f = f7f)a  
Context manager that sets the given :class:`.Application` active in an
`AppSession`.

This should only be called by the `Application` itself.
The application will automatically be active while its running. If you want
the application to be active in other threads/coroutines, where that's not
the case, use `contextvars.copy_context()`, or use `Application.context` to
run it in the appropriate context.
NrH   )r   rF   previous_apps      r   r   r   u   s5      #&&(G;;LK#"ls   'A 5 A =A Nc              #    #    U c  [        5       R                  n Uc  [        5       R                  n[        XS9n[        R                  U5      n Uv   [        R                  U5        g! [        R                  U5        f = f7f)z
Create a separate AppSession.

This is useful if there can be multiple individual ``AppSession``'s going
on. Like in the case of a Telnet/SSH server.
Nr   r   )r   r   r   r   r?   setreset)r   r   rF   tokens       r   r   r      sp     $ }!((~ "** u4G $$W-E*""5)""5)s   ABA* B*BBc               #     #    SSK Jn   SSKJn  U " SS9nU" SS9n[	        X#S9 nUv   SSS5        g! , (       d  f       g= f7f)am  
Create `AppSession` that always prefers the TTY input/output.

Even if `sys.stdin` and `sys.stdout` are connected to input/output pipes,
this will still use the terminal for interaction (because `sys.stderr` is
still connected to the terminal).

Usage::

    from prompt_toolkit.shortcuts import prompt

    with create_app_session_from_tty():
        prompt('>')
r   r(   r-   T)always_prefer_ttyrL   N)r*   r)   r/   r.   r   )r)   r.   r   r   app_sessions        r   r   r      s<       ;<40ET2F	%	7; 
8	7	7s   "A2	A
A A)r4   r   )r4   Application[Any])r4   zApplication[Any] | None)r   rS   r4   zGenerator[None, None, None]r1   )r   r2   r   r3   r4   !Generator[AppSession, None, None])r4   rT   )
__future__r   
contextlibr   contextvarsr   typingr   r   r   prompt_toolkit.input.baser	   prompt_toolkit.output.baser
   applicationr   __all__r   r?   __annotations__r   r   r   r   r   r   r>   r"   r   <module>r^      s    " % " 0 0/1(, ,^ 0:JL0 , 
&8 # #* 8<**(5*&* *@  r"   