
                         F    S SK Jr  S SKJr  S SKrS SKrSr " S S\5      rg)    )unicode_literals)getincrementaldecoderN)PosixStdinReaderc                   T    \ rS rSrSr\R                  (       a  SOS4S jrS	S jrSr	g)
r      a  
Wrapper around stdin which reads (nonblocking) the next available 1024
bytes and decodes it.

Note that you can't be sure that the input file is closed if the ``read``
function returns an empty string. When ``errors=ignore`` is passed,
``read`` can return an empty string if all malformed input was replaced by
an empty string. (We can't block here and wait for more input.) So, because
of that, check the ``closed`` attribute, to be sure that the file has been
closed.

:param stdin_fd: File descriptor from which we read.
:param errors:  Can be 'ignore', 'strict' or 'replace'.
    On Python3, this can be 'surrogateescape', which is the default.

    'surrogateescape' is preferred, because this allows us to transfer
    unrecognised bytes to the key bindings. Some terminals, like lxterminal
    and Guake, use the 'Mxx' notation to send mouse events, where each 'x'
    can be any possible byte.
ignoresurrogateescapec                     [        U[        5      (       d   eXl        X l        [	        S5      U l        U R                  US9U l        SU l        g )Nzutf-8)errorsF)
isinstanceintstdin_fdr   r   _stdin_decoder_cls_stdin_decoderclosed)selfr   r   s      7lib/third_party/prompt_toolkit/eventloop/posix_utils.py__init__PosixStdinReader.__init__%   sM    (C(((( 
 #8"@"55V5D     c                     U R                   (       a  g [        R                  " U R                  U5      nUS:X  a  SU l         g U R
                  R                  U5      $ ! [         a    Sn N)f = f)z
Read the input and return it as a string.

Return the text. Note that this can return an empty string, even when
the input stream was not yet closed. This means that something went
wrong during the decoding.
r   T )r   osreadr   OSErrorr   decode)r   countdatas      r   r   PosixStdinReader.read4   sn     ;;		774==%0D s{"  ""))$//	  	D	s   .A A.-A.)r   r   r   r   r   N)i   )
__name__
__module____qualname____firstlineno____doc__sixPY2r   r   __static_attributes__ r   r   r   r      s    2 &)WW2C0r   r   )	
__future__r   codecsr   r   r%   __all__objectr   r(   r   r   <module>r-      s&    ' ( 	 

F0v F0r   