
    ^hV                        S SK Jr  S SKr\R                  S:w  d   eS SKrS SKJr  S SKJrJ	r	J
r
Jr  SSKJr  SS	KJr  SS
KJr  S/r " S S5      r " S S\\5      rg)    )annotationsNwin32)contextmanager)ContextManagerIteratorTextIOcast   DummyContext   )	PipeInput)
Vt100InputPosixPipeInputc                  @    \ rS rSrSrS	S jrS	S jrS	S jrS	S jrSr	g)
_Pipe   zCWrapper around os.pipe, that ensures we don't double close any end.c                d    [         R                  " 5       u  U l        U l        SU l        SU l        g )NF)ospiperead_fdwrite_fd_read_closed_write_closedselfs    Y/home/james-whalen/.local/lib/python3.13/site-packages/prompt_toolkit/input/posix_pipe.py__init___Pipe.__init__   s&    &(ggi#dm!"    c                v    U R                   (       a  g[        R                  " U R                  5        SU l         g)z!Close read-end if not yet closed.NT)r   r   closer   r   s    r   
close_read_Pipe.close_read   s&    
 r    c                v    U R                   (       a  g[        R                  " U R                  5        SU l         g)z"Close write-end if not yet closed.NT)r   r   r"   r   r   s    r   close_write_Pipe.close_write$   s&    
!r    c                D    U R                  5         U R                  5         g)zClose both read and write ends.N)r#   r&   r   s    r   r"   _Pipe.close,   s    r    )r   r   r   r   NreturnNone)
__name__
__module____qualname____firstlineno____doc__r   r#   r&   r"   __static_attributes__ r    r   r   r      s    I#
!"r    r   c                     ^  \ rS rSrSrSrSSU 4S jjjr\\SSS jj5       5       r	SS jr
SS jrSS jrSS	 jrSS
 jrSS jrSrU =r$ )r   2   z
Input that is send through a pipe.
This is useful if we want to send the input programmatically into the
application. Mostly useful for unit testing.

Usage::

    with PosixPipeInput.create() as input:
        input.send_text('inputdata')
r   c                
  >^  UT l          " U 4S jS5      n[        TT ]	  [        [        U" 5       5      5        T R                  U5        T R                  =R                  S-  sl        T R                  R                  T l        g )Nc                  4   > \ rS rSrSrSS jrSU 4S jjrSrg)	&PosixPipeInput.__init__.<locals>.StdinD   utf-8c                    g)NTr3   )stdins    r   isatty-PosixPipeInput.__init__.<locals>.Stdin.isattyG   s    r    c                0   > TR                   R                  $ N)r   r   )r<   r   s    r   fileno-PosixPipeInput.__init__.<locals>.Stdin.filenoJ   s    yy(((r    r3   N)r+   bool)r+   int)r-   r.   r/   r0   encodingr=   rA   r2   r   s   r   Stdinr8   D   s    H) )r    rF   r   )r   superr   r	   r   	send_text	__class___id)r   _pipe_textrF   rI   s   `   r   r   PosixPipeInput.__init__@   s`    		) 	) 	feg./u 	a>>%%r    c              #     #    [        5       n [        X!S9v   UR                  5         g ! UR                  5         f = f7f)N)rK   rL   )r   r   r"   )clstextr   s      r   createPosixPipeInput.createT   s0      w	 t88JJLDJJLs   ?* ?<?c                Z    [         R                  " U R                  R                  U5        g r@   )r   writer   r   r   datas     r   
send_bytesPosixPipeInput.send_bytes]   s    
##T*r    c                x    [         R                  " U R                  R                  UR	                  S5      5        g)zSend text to the input.r:   N)r   rT   r   r   encoderU   s     r   rH   PosixPipeInput.send_text`   s#    
##T[[%9:r    c                    [        5       $ r@   r   r   s    r   raw_modePosixPipeInput.raw_moded   
    ~r    c                    [        5       $ r@   r   r   s    r   cooked_modePosixPipeInput.cooked_modeg   r_   r    c                8    U R                   R                  5         g)zClose pipe fds.N)r   r&   r   s    r   r"   PosixPipeInput.closej   s     			r    c                     SU R                    3$ )z0
This needs to be unique for every `PipeInput`.
zpipe-input-)rJ   r   s    r   typeahead_hashPosixPipeInput.typeahead_hashr   s     TXXJ''r    )rJ   r   ) )rK   r   rL   strr+   r,   )rP   ri   r+   zIterator[PosixPipeInput])rV   bytesr+   r,   )rV   ri   r+   r,   )r+   zContextManager[None]r*   )r+   ri   )r-   r.   r/   r0   r1   rJ   r   classmethodr   rQ   rW   rH   r]   ra   r"   rf   r2   __classcell__)rI   s   @r   r   r   2   sX    	 C& &(   +; ( (r    )
__future__r   sysplatformr   
contextlibr   typingr   r   r   r	   utilsr   baser   vt100r   __all__r   r   r3   r    r   <module>rv      sX    " 

||w  	 % 9 9     
 <D(Z D(r    