
                             S r SSKJr  SSKJrJr  SSKJrJr  SSK	J
r
  SSKrSSKrSSKr\" 5       (       a	  SSKJrJr  OSSKJrJr  S	r " S
 S\
" \\5      5      r " S S\5      r " S S\5      rg)z
Abstraction of CLI Input.
    )unicode_literals   )DummyContext
is_windows)ABCMetaabstractmethod)with_metaclassN)raw_modecooked_mode)Input
StdinInput	PipeInputc                   X    \ rS rSrSr\S 5       r\S 5       r\S 5       r\S 5       r	Sr
g)	r      z
Abstraction for any input.

An instance of this class can be given to the constructor of a
:class:`~prompt_toolkit.interface.CommandLineInterface` and will also be
passed to the :class:`~prompt_toolkit.eventloop.base.EventLoop`.
c                     g)z+
Fileno for putting this in an event loop.
N selfs    'lib/third_party/prompt_toolkit/input.pyfilenoInput.fileno"           c                     g)z
Return text from the input.
Nr   r   s    r   read
Input.read(   r   r   c                     g)z5
Context manager that turns the input into raw mode.
Nr   r   s    r   r
   Input.raw_mode.   r   r   c                     g)z8
Context manager that turns the input into cooked mode.
Nr   r   s    r   r   Input.cooked_mode4   r   r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   r   r
   r   __static_attributes__r   r   r   r   r      sW      
  
  
  r   r   c                   @    \ rS rSrSrSS jrS rS rS rS r	S	 r
S
rg)r   ;   z
Simple wrapper around stdin.
Nc                 h   U=(       d    [         R                  U l        U R                  R                  5       (       d   e U R                  R                  5         g ! [        R
                   aA    S[         R                  ;   a  [        R
                  " S5      e[        R
                  " S5      ef = f)Nzidlelib.runz<Stdin is not a terminal. Running from Idle is not supported.zStdin is not a terminal.)sysstdinisattyr   ioUnsupportedOperationmodules)r   r+   s     r   __init__StdinInput.__init__?   s    'cii
 zz  """"	JJJ&& 	J+--RT T --.HII	Js   A AB1c                 $    SU R                   < S3$ )NzStdinInput(stdin=)r+   r   s    r   __repr__StdinInput.__repr__Q   s    )-55r   c                 H    [        U R                  R                  5       5      $ N)r
   r+   r   r   s    r   r
   StdinInput.raw_modeT   s    

))+,,r   c                 H    [        U R                  R                  5       5      $ r8   )r   r+   r   r   s    r   r   StdinInput.cooked_modeW   s    4::,,.//r   c                 6    U R                   R                  5       $ r8   )r+   r   r   s    r   r   StdinInput.filenoZ   s    zz  ""r   c                 6    U R                   R                  5       $ r8   )r+   r   r   s    r   r   StdinInput.read]   s    zz  r   r4   r8   )r!   r"   r#   r$   r%   r0   r5   r
   r   r   r   r&   r   r   r   r   r   ;   s&    J$6-0#!r   r   c                   F    \ rS rSrSrS rS rS rS r\r	S r
S rS	 rS
rg)r   a   z
Input that is send through a pipe.
This is useful if we want to send the input programatically into the
interface, but still use the eventloop.

Usage::

    input = PipeInput()
    input.send('inputdata')
c                 H    [         R                  " 5       u  U l        U l        g r8   )ospipe_r_wr   s    r   r0   PipeInput.__init__l   s    779r   c                     U R                   $ r8   )rE   r   s    r   r   PipeInput.filenoo   s    wwr   c                 B    [         R                  " U R                  5      $ r8   )rC   r   rE   r   s    r   r   PipeInput.readr   s    wwtwwr   c                 d    [         R                  " U R                  UR                  S5      5        g)zSend text to the input. zutf-8N)rC   writerF   encode)r   datas     r   	send_textPipeInput.send_textu   s    
$++g./r   c                     [        5       $ r8   r   r   s    r   r
   PipeInput.raw_mode|   
    ~r   c                     [        5       $ r8   rS   r   s    r   r   PipeInput.cooked_mode   rU   r   c                     [         R                  " U R                  5        [         R                  " U R                  5        SU l        SU l        g)zClose pipe fds. N)rC   closerE   rF   r   s    r   rY   PipeInput.close   s0    

r   )rE   rF   N)r!   r"   r#   r$   r%   r0   r   r   rP   sendr
   r   rY   r&   r   r   r   r   r   a   s1    	% 0
 Dr   r   )r%   
__future__r   utilsr   r   abcr   r   sixr	   r-   rC   r*   terminal.win32_inputr
   r   terminal.vt100_input__all__objectr   r   r   r   r   r   <module>rd      se    ( + '  	 	 
<<;;;N7F+ B#! #!L& &r   