ó
±xYc           @  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
 d d l Z d d l Z d d l Z e ƒ  r˜ d d l m Z m Z n d d l m Z m Z d Z d e
 e e ƒ f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   u   
Abstraction of CLI Input.
iÿÿÿÿ(   t   unicode_literalsi   (   t   DummyContextt
   is_windows(   t   ABCMetat   abstractmethod(   t   with_metaclassN(   t   raw_modet   cooked_modeu   Inputu
   StdinInputu	   PipeInputt   Inputc           B  sJ   e  Z d  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z RS(   uú   
    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         C  s   d S(   u;   
        Fileno for putting this in an event loop.
        N(    (   t   self(    (    s3   lib/python2.7/site-packages/prompt_toolkit/input.pyt   fileno"   s    c         C  s   d S(   u-   
        Return text from the input.
        N(    (   R	   (    (    s3   lib/python2.7/site-packages/prompt_toolkit/input.pyt   read(   s    c         C  s   d S(   uE   
        Context manager that turns the input into raw mode.
        N(    (   R	   (    (    s3   lib/python2.7/site-packages/prompt_toolkit/input.pyR   .   s    c         C  s   d S(   uH   
        Context manager that turns the input into cooked mode.
        N(    (   R	   (    (    s3   lib/python2.7/site-packages/prompt_toolkit/input.pyR   4   s    (   t   __name__t
   __module__t   __doc__R   R
   R   R   R   (    (    (    s3   lib/python2.7/site-packages/prompt_toolkit/input.pyR      s
   t
   StdinInputc           B  sG   e  Z d  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   u&   
    Simple wrapper around stdin.
    c         C  sƒ   | p t  j |  _ |  j j ƒ  s' t ‚ y |  j j ƒ  WnD t j k
 r~ d t  j k rl t j d ƒ ‚ q t j d ƒ ‚ n Xd  S(   Nu   idlelib.runu<   Stdin is not a terminal. Running from Idle is not supported.u   Stdin is not a terminal.(   t   syst   stdint   isattyt   AssertionErrorR
   t   iot   UnsupportedOperationt   modules(   R	   R   (    (    s3   lib/python2.7/site-packages/prompt_toolkit/input.pyt   __init__?   s    c         C  s   d |  j  f S(   Nu   StdinInput(stdin=%r)(   R   (   R	   (    (    s3   lib/python2.7/site-packages/prompt_toolkit/input.pyt   __repr__Q   s    c         C  s   t  |  j j ƒ  ƒ S(   N(   R   R   R
   (   R	   (    (    s3   lib/python2.7/site-packages/prompt_toolkit/input.pyR   T   s    c         C  s   t  |  j j ƒ  ƒ S(   N(   R   R   R
   (   R	   (    (    s3   lib/python2.7/site-packages/prompt_toolkit/input.pyR   W   s    c         C  s   |  j  j ƒ  S(   N(   R   R
   (   R	   (    (    s3   lib/python2.7/site-packages/prompt_toolkit/input.pyR
   Z   s    c         C  s   |  j  j ƒ  S(   N(   R   R   (   R	   (    (    s3   lib/python2.7/site-packages/prompt_toolkit/input.pyR   ]   s    N(
   R   R   R   t   NoneR   R   R   R   R
   R   (    (    (    s3   lib/python2.7/site-packages/prompt_toolkit/input.pyR   ;   s   				t	   PipeInputc           B  sS   e  Z d  Z d „  Z d „  Z d „  Z d „  Z e Z d „  Z d „  Z	 d „  Z
 RS(   uë   
    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         C  s   t  j ƒ  \ |  _ |  _ d  S(   N(   t   ost   pipet   _rt   _w(   R	   (    (    s3   lib/python2.7/site-packages/prompt_toolkit/input.pyR   l   s    c         C  s   |  j  S(   N(   R   (   R	   (    (    s3   lib/python2.7/site-packages/prompt_toolkit/input.pyR
   o   s    c         C  s   t  j |  j ƒ S(   N(   R   R   R   (   R	   (    (    s3   lib/python2.7/site-packages/prompt_toolkit/input.pyR   r   s    c         C  s    t  j |  j | j d ƒ ƒ d S(   u    Send text to the input. u   utf-8N(   R   t   writeR   t   encode(   R	   t   data(    (    s3   lib/python2.7/site-packages/prompt_toolkit/input.pyt	   send_textu   s    c         C  s   t  ƒ  S(   N(   R   (   R	   (    (    s3   lib/python2.7/site-packages/prompt_toolkit/input.pyR   |   s    c         C  s   t  ƒ  S(   N(   R   (   R	   (    (    s3   lib/python2.7/site-packages/prompt_toolkit/input.pyR      s    c         C  s6   t  j |  j ƒ t  j |  j ƒ d |  _ d |  _ d S(   u    Close pipe fds. N(   R   t   closeR   R   R   (   R	   (    (    s3   lib/python2.7/site-packages/prompt_toolkit/input.pyR#   ‚   s    	(   R   R   R   R   R
   R   R"   t   sendR   R   R#   (    (    (    s3   lib/python2.7/site-packages/prompt_toolkit/input.pyR   a   s   
						(   u   Inputu
   StdinInputu	   PipeInput(   R   t
   __future__R    t   utilsR   R   t   abcR   R   t   sixR   R   R   R   t   terminal.win32_inputR   R   t   terminal.vt100_inputt   __all__t   objectR   R   R   (    (    (    s3   lib/python2.7/site-packages/prompt_toolkit/input.pyt   <module>   s    	  !&