o
    �õ±j+  ã                   @  s˜   d Z ddlmZ ddlmZmZ ddlmZmZ ddl	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dd„ƒZdS )z
Abstraction of CLI Input.
é    )Úannotations)ÚABCMetaÚabstractmethod)ÚCallableÚ	Generator)ÚAbstractContextManagerÚcontextmanager)ÚKeyPress)ÚInputÚ	PipeInputÚ
DummyInputc                   @  s¢   e Zd ZdZed"dd„ƒZed#dd„ƒZed$d
d„ƒZd$dd„Zd%dd„Z	e
ed&dd„ƒƒZed'dd„ƒZed'dd„ƒZed(dd„ƒZed'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`.
    ÚreturnÚintc                 C  ó   dS )z;
        Fileno for putting this in an event loop.
        N© ©Úselfr   r   úŒ/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/prompt_toolkit/input/base.pyÚfileno   ó    zInput.filenoÚstrc                 C  r   )z@
        Identifier for storing type ahead key presses.
        Nr   r   r   r   r   Útypeahead_hash#   r   zInput.typeahead_hashúlist[KeyPress]c                 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_keysÚNonec                 C  r   )z>The event loop can call this when the input has to be flushed.Nr   r   r   r   r   Úflush6   ó   zInput.flushÚboolc                 C  r   )z/Should be true when the input stream is closed.Fr   r   r   r   r   Úclosed:   ó   zInput.closedúAbstractContextManager[None]c                 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_modeF   r   zInput.cooked_modeÚinput_ready_callbackúCallable[[], None]c                 C  r   )zj
        Return a context manager that makes this input active in the current
        event loop.
        Nr   ©r   r%   r   r   r   ÚattachL   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   ÚdetachU   r   zInput.detachc                 C  r   )zClose input.Nr   r   r   r   r   Úclose\   r   zInput.closeN©r   r   ©r   r   ©r   r   )r   r   ©r   r   ©r   r"   ©r%   r&   r   r"   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   Úpropertyr    r#   r$   r(   r)   r*   r   r   r   r   r
      s,    

r
   )Ú	metaclassc                   @  s,   e Zd ZdZeddd„ƒZedd	d
„ƒZdS )r   z%
    Abstraction for pipe input.
    ÚdataÚbytesr   r   c                 C  r   )zFeed byte string into the pipeNr   ©r   r7   r   r   r   Ú
send_bytesf   r   zPipeInput.send_bytesr   c                 C  r   )z Feed a text string into the pipeNr   r9   r   r   r   Ú	send_textj   r   zPipeInput.send_textN)r7   r8   r   r   )r7   r   r   r   )r1   r2   r3   r4   r   r:   r;   r   r   r   r   r   a   s    r   c                   @  sd   e Zd ZdZddd„Zddd„Zdd
d„Zeddd„ƒZddd„Z	ddd„Z
d dd„Zd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   r   c                 C  s   t ‚©N)ÚNotImplementedErrorr   r   r   r   r   w   ó   zDummyInput.filenor   c                 C  s   dt | ƒ› �S )Nzdummy-)Úidr   r   r   r   r   z   s   zDummyInput.typeahead_hashr   c                 C  r   r<   r   r   r   r   r   r   }   r>   zDummyInput.read_keysr   c                 C  r   )NTr   r   r   r   r   r    €   r!   zDummyInput.closedr"   c                 C  ó   t ƒ S r<   ©Ú_dummy_context_managerr   r   r   r   r#   †   ó   zDummyInput.raw_modec                 C  r@   r<   rA   r   r   r   r   r$   ‰   rC   zDummyInput.cooked_moder%   r&   c                 C  s   |ƒ  t ƒ S r<   rA   r'   r   r   r   r(   Œ   s   zDummyInput.attachc                 C  r@   r<   rA   r   r   r   r   r)   ˜   rC   zDummyInput.detachNr+   r,   r-   r.   r/   r0   )r1   r2   r3   r4   r   r   r   r5   r    r#   r$   r(   r)   r   r   r   r   r   o   s    





r   r   úGenerator[None, None, None]c                   c  s   � d V  d S r<   r   r   r   r   r   rB   œ   s   €
rB   N)r   rD   )r4   Ú
__future__r   Úabcr   r   Úcollections.abcr   r   Ú
contextlibr   r   Úprompt_toolkit.key_bindingr	   Ú__all__r
   r   r   rB   r   r   r   r   Ú<module>   s    M-