o
    ˷e                     @   s   d Z ddlmZ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 g dZG dd ded	ZG d
d deZG dd deZede
d fddZdS )z
Abstraction of CLI Input.
    )ABCMetaabstractmethodabstractproperty)contextmanager)CallableContextManager	GeneratorList)KeyPress)Input	PipeInput
DummyInputc                   @   s   e Zd ZdZedefddZedefddZede	e
 fddZde	e
 fd	d
ZdddZedefddZeded fddZeded fddZedeg df ded fddZeded fddZdddZdS )r   z
    Abstraction for any input.

    An instance of this class can be given to the constructor of a
    :class:`~prompt_toolkit.application.Application` and will also be
    passed to the :class:`~prompt_toolkit.eventloop.base.EventLoop`.
    returnc                 C      dS )z;
        Fileno for putting this in an event loop.
        N selfr   r   P/var/www/ideatree/venv/lib/python3.10/site-packages/prompt_toolkit/input/base.pyfileno       zInput.filenoc                 C   r   )z@
        Identifier for storing type ahead key presses.
        Nr   r   r   r   r   typeahead_hash    r   zInput.typeahead_hashc                 C   r   )zT
        Return a list of Key objects which are read/parsed from the input.
        Nr   r   r   r   r   	read_keys&   r   zInput.read_keysc                 C      g S )zk
        Flush the underlying parser. and return the pending keys.
        (Used for vt100 input.)
        r   r   r   r   r   
flush_keys,   s   zInput.flush_keysNc                 C   r   )z>The event loop can call this when the input has to be flushed.Nr   r   r   r   r   flush3      zInput.flushc                 C   r   )z/Should be true when the input stream is closed.Fr   r   r   r   r   closed7   s   zInput.closedc                 C   r   )zE
        Context manager that turns the input into raw mode.
        Nr   r   r   r   r   raw_mode<   r   zInput.raw_modec                 C   r   )zH
        Context manager that turns the input into cooked mode.
        Nr   r   r   r   r   cooked_modeB   r   zInput.cooked_modeinput_ready_callbackc                 C   r   )zj
        Return a context manager that makes this input active in the current
        event loop.
        Nr   r   r   r   r   r   attachH   r   zInput.attachc                 C   r   )z{
        Return a context manager that makes sure that this input is not active
        in the current event loop.
        Nr   r   r   r   r   detachO   r   zInput.detachc                 C   r   )zClose input.Nr   r   r   r   r   closeV   r   zInput.close)r   N)__name__
__module____qualname____doc__r   intr   strr   r	   r
   r   r   r   r   boolr   r   r   r   r   r!   r"   r#   r   r   r   r   r      s*    
 r   )	metaclassc                   @   s<   e Zd ZdZededdfddZededdfddZdS )	r   z%
    Abstraction for pipe input.
    datar   Nc                 C   r   )zFeed byte string into the pipeNr   r   r,   r   r   r   
send_bytes`   r   zPipeInput.send_bytesc                 C   r   )z Feed a text string into the pipeNr   r-   r   r   r   	send_textd   r   zPipeInput.send_text)	r$   r%   r&   r'   r   bytesr.   r)   r/   r   r   r   r   r   [   s    r   c                   @   s   e Zd ZdZdefddZdefddZdee	 fddZ
edefd	d
Zded fddZded fddZdeg df ded fddZded fddZdS )r   z
    Input for use in a `DummyApplication`

    If used in an actual application, it will make the application render
    itself once and exit immediately, due to an `EOFError`.
    r   c                 C   s   t N)NotImplementedErrorr   r   r   r   r   q      zDummyInput.filenoc                 C   s   dt |  S )Nzdummy-%s)idr   r   r   r   r   t   s   zDummyInput.typeahead_hashc                 C   r   r1   r   r   r   r   r   r   w   r3   zDummyInput.read_keysc                 C   r   )NTr   r   r   r   r   r   z   s   zDummyInput.closedNc                 C      t  S r1   _dummy_context_managerr   r   r   r   r         zDummyInput.raw_modec                 C   r5   r1   r6   r   r   r   r   r      r8   zDummyInput.cooked_moder   c                 C   s   |  t  S r1   r6   r    r   r   r   r!      s   zDummyInput.attachc                 C   r5   r1   r6   r   r   r   r   r"      r8   zDummyInput.detach)r$   r%   r&   r'   r(   r   r)   r   r	   r
   r   propertyr*   r   r   r   r   r   r!   r"   r   r   r   r   r   i   s    
r   r   )NNNc                   c   s    d V  d S r1   r   r   r   r   r   r7      s   
r7   N)r'   abcr   r   r   
contextlibr   typingr   r   r   r	   prompt_toolkit.key_bindingr
   __all__r   r   r   r7   r   r   r   r   <module>   s    J+