a
    õ£BeÅ  ã                   @  s    d Z ddlmZ ddlmZmZmZ ddlmZ ddl	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dœdd„ƒZdS )z
Abstraction of CLI Input.
é    )Úannotations)ÚABCMetaÚabstractmethodÚabstractproperty)Úcontextmanager)ÚCallableÚContextManagerÚ	Generator)ÚKeyPress)ÚInputÚ	PipeInputÚ
DummyInputc                   @  sÌ   e Zd ZdZeddœdd„ƒZeddœdd„ƒZed	dœd
d„ƒZd	dœdd„Zddœdd„Z	e
ddœdd„ƒZeddœdd„ƒZeddœdd„ƒZedddœdd„ƒZeddœdd„ƒZd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`.
    Úint©Úreturnc                 C  s   dS )z;
        Fileno for putting this in an event loop.
        N© ©Úselfr   r   ú\/home/yuhw/wc/wire-cell-python/wcpy/lib/python3.9/site-packages/prompt_toolkit/input/base.pyÚfileno   s    zInput.filenoÚstrc                 C  s   dS )z@
        Identifier for storing type ahead key presses.
        Nr   r   r   r   r   Útypeahead_hash"   s    zInput.typeahead_hashúlist[KeyPress]c                 C  s   dS )zT
        Return a list of Key objects which are read/parsed from the input.
        Nr   r   r   r   r   Ú	read_keys(   s    zInput.read_keysc                 C  s   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  s   dS )z>The event loop can call this when the input has to be flushed.Nr   r   r   r   r   Úflush5   s    zInput.flushÚboolc                 C  s   dS )z/Should be true when the input stream is closed.Fr   r   r   r   r   Úclosed9   s    zInput.closedúContextManager[None]c                 C  s   dS )zE
        Context manager that turns the input into raw mode.
        Nr   r   r   r   r   Úraw_mode>   s    zInput.raw_modec                 C  s   dS )zH
        Context manager that turns the input into cooked mode.
        Nr   r   r   r   r   Úcooked_modeD   s    zInput.cooked_modeúCallable[[], None]©Úinput_ready_callbackr   c                 C  s   dS )zj
        Return a context manager that makes this input active in the current
        event loop.
        Nr   ©r   r$   r   r   r   ÚattachJ   s    zInput.attachc                 C  s   dS )z{
        Return a context manager that makes sure that this input is not active
        in the current event loop.
        Nr   r   r   r   r   ÚdetachQ   s    zInput.detachc                 C  s   dS )zClose input.Nr   r   r   r   r   ÚcloseX   s    zInput.closeN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r    r!   r&   r'   r(   r   r   r   r   r      s(   r   )Ú	metaclassc                   @  s8   e Zd ZdZedddœdd„ƒZedddœdd	„ƒZd
S )r   z%
    Abstraction for pipe input.
    Úbytesr   )Údatar   c                 C  s   dS )zFeed byte string into the pipeNr   ©r   r/   r   r   r   Ú
send_bytesb   s    zPipeInput.send_bytesr   c                 C  s   dS )z Feed a text string into the pipeNr   r0   r   r   r   Ú	send_textf   s    zPipeInput.send_textN)r)   r*   r+   r,   r   r1   r2   r   r   r   r   r   ]   s
   r   c                   @  s†   e Zd ZdZddœdd„Zddœdd„Zd	dœd
d„Zeddœdd„ƒZddœdd„Z	ddœdd„Z
dddœdd„Zd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 ‚d S ©N)ÚNotImplementedErrorr   r   r   r   r   s   s    zDummyInput.filenor   c                 C  s   dt | ƒ S )Nzdummy-%s)Úidr   r   r   r   r   v   s    zDummyInput.typeahead_hashr   c                 C  s   g S r3   r   r   r   r   r   r   y   s    zDummyInput.read_keysr   c                 C  s   dS )NTr   r   r   r   r   r   |   s    zDummyInput.closedr   c                 C  s   t ƒ S r3   ©Ú_dummy_context_managerr   r   r   r   r    ‚   s    zDummyInput.raw_modec                 C  s   t ƒ S r3   r6   r   r   r   r   r!   …   s    zDummyInput.cooked_moder"   r#   c                 C  s   |ƒ  t ƒ S r3   r6   r%   r   r   r   r&   ˆ   s    zDummyInput.attachc                 C  s   t ƒ S r3   r6   r   r   r   r   r'   ’   s    zDummyInput.detachN)r)   r*   r+   r,   r   r   r   Úpropertyr   r    r!   r&   r'   r   r   r   r   r   k   s   
r   zGenerator[None, None, None]r   c                   c  s
   d V  d S r3   r   r   r   r   r   r7   –   s    r7   N)r,   Ú
__future__r   Úabcr   r   r   Ú
contextlibr   Útypingr   r   r	   Zprompt_toolkit.key_bindingr
   Ú__all__r   r   r   r7   r   r   r   r   Ú<module>   s   J+