U
    ouf                     @  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 ddd	g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   =/tmp/pip-unpacked-wheel-8milen2s/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(   )	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
   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   
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+