ó
    &ÝNjÔ  ã                   óÚ  • S r SSKJr  SSKJrJrJrJr  SSKrSSK	r	SSK
r
SSKJrJr  \
R                  S:H  r \
R                  S:X  a  SSKrSSKJrJrJrJrJr  SS	KJrJrJr  OSSKrSSKrSSKrSSKr\
R                  S:X  a  S
\\\   \\   4   4S jr OS
\\\   \\   4   4S jr S
\\\4   4S jr!S\S
\"4S jr#S\S
\"4S jr$\S\S
\S   4S j5       r%S\S
\"4S jr&S\S
\4S jr'g)zî
Utility functions surrounding terminal devices & I/O.

Much of this code performs platform-sensitive branching, e.g. Windows support.

This is its own module to abstract away what would otherwise be distracting
logic-flow interruptions.
é    )Úcontextmanager)Ú	GeneratorÚIOÚOptionalÚTupleNé   )Ú
has_filenoÚisattyÚwin32)Ú	StructureÚc_ushortÚwindllÚPOINTERÚbyref)ÚHANDLEÚ_COORDÚ_SMALL_RECTÚreturnc                  óâ  •  " S S[         5      n [        R                  R                  n[        R                  R                  n[
        Ul        [
        [        U 5      /Ul        U" S5      nU " 5       nU" U[        U5      5      nU(       ac  UR                  R                  UR                  R                  -
  S-   nUR                  R                  UR                  R                  -
  S-   nXg4$ g)Nc                   ó6   • \ rS rSrS\4S\4S\4S\4S\4/rSrg)	Ú-_pty_size.<locals>.CONSOLE_SCREEN_BUFFER_INFOé3   ÚdwSizeÚdwCursorPositionÚwAttributesÚsrWindowÚdwMaximumWindowSize© N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r   r   Ú_fields_Ú__static_attributes__r   ó    ÚM/home/mande/repo/quber/.venv/lib/python3.13/site-packages/invoke/terminals.pyÚCONSOLE_SCREEN_BUFFER_INFOr   3   s1   † à˜6Ð"Ø# VÐ,Ø Ð)Ø˜[Ð)Ø&¨Ð/ð‹Hr%   r'   iõÿÿÿr   ©NN)r   r   Úkernel32ÚGetStdHandleÚGetConsoleScreenBufferInfor   Úrestyper   Úargtypesr   r   ÚRightÚLeftÚBottomÚTop)r'   r*   r+   ÚhstdÚcsbiÚretÚsizexÚsizeys           r&   Ú	_pty_sizer7   2   sÆ   € ô	¬ô 	ô —‘×3Ñ3ˆÜ%+§_¡_×%OÑ%OÐ"Ü%ˆÔäÜÐ.Ó/ð/
Ð"Ô+ñ
 ˜CÓ ˆÙ)Ó+ˆÙ(¨¬u°T«{Ó;ˆæØ—M‘M×'Ñ'¨$¯-©-×*<Ñ*<Ñ<¸qÑ@ˆEØ—M‘M×(Ñ(¨4¯=©=×+<Ñ+<Ñ<¸qÑ@ˆEØ�<Ðàr%   c                  ó4  • Sn Sn[         R                  " USSSS5      n [        R                  " [        R
                  [        R                  U5      n[         R                  " X5      tpEnXT4$ ! [         R                  [        [        [        4 a     U $ f = f)z;
Suitable for most POSIX platforms.

.. versionadded:: 1.0
r(   ÚHHHHr   )ÚstructÚpackÚfcntlÚioctlÚsysÚstdoutÚtermiosÚ
TIOCGWINSZÚunpackÚerrorÚ	TypeErrorÚIOErrorÚAttributeError)ÚsizeÚfmtÚbufÚresultÚrowsÚcolsÚ_s          r&   r7   r7   Q   s‰   € ð ˆð ˆä�kŠk˜#˜q ! Q¨Ó*ˆð	Ü—[’[¤§¡¬W×-?Ñ-?ÀÓEˆFô $Ÿ]š]¨3Ó7ˆNˆD˜Ø�<Ðøô —‘œi¬´.ÐAó 	ØØˆð	ús    AA/ Á/$BÂBc                  óF   • [        5       u  pU =(       d    SU=(       d    S4$ )zá
Determine current local pseudoterminal dimensions.

:returns:
    A ``(num_cols, num_rows)`` two-tuple describing PTY size. Defaults to
    ``(80, 24)`` if unable to get a sensible result dynamically.

.. versionadded:: 1.0
éP   é   )r7   )rL   rK   s     r&   Úpty_sizerQ   t   s    € ô “�J€Dà�J�B˜Ÿ
 Ð#Ð#r%   Ústreamc                 ó˜   • [        U 5      (       d  g[        R                  " 5       [        R                  " U R	                  5       5      :H  $ )a·  
Detect if given stdin ``stream`` seems to be in the foreground of a TTY.

Specifically, compares the current Python process group ID to that of the
stream's file descriptor to see if they match; if they do not match, it is
likely that the process has been placed in the background.

This is used as a test to determine whether we should manipulate an active
stdin so it runs in a character-buffered mode; touching the terminal in
this way when the process is backgrounded, causes most shells to pause
execution.

.. note::
    Processes that aren't attached to a terminal to begin with, will always
    fail this test, as it starts with "do you have a real ``fileno``?".

.. versionadded:: 1.0
F)r	   ÚosÚgetpgrpÚ	tcgetpgrpÚfileno)rR   s    r&   Ústdin_is_foregrounded_ttyrX   ƒ   s2   € ô& �f×ÑØÜ�:Š:‹<œ2Ÿ<š<¨¯©«Ó8Ñ8Ð8r%   c                 ó6  • [         R                  " U 5      nUS   US   p2[        U[         R                  -  5      n[        U[         R                  -  5      nU(       + U(       + U[         R
                     S;   U[         R                     S;   4n[        U5      $ )Né   é   )r   ó   )r   ó    )r@   Ú	tcgetattrÚboolÚECHOÚICANONÚVMINÚVTIMEÚall)rR   ÚattrsÚlflagsÚccÚechoÚicanonÚ	sentinelss          r&   Úcbreak_already_setrk   ›   sŠ   € ô ×Ò˜fÓ%€EØ�q‘˜5 ™8ˆBÜ�œŸ™Ñ%Ó&€DÜ�&œ7Ÿ>™>Ñ)Ó*€Fð
 ŒØŒ
Ø
Œ7�<‰<Ñ˜LÑ(Ø
Œ7�=‰=Ñ˜\Ñ)ð	€Iô ˆy‹>Ðr%   )NNNc              #   ó�  #   • [         (       d0  [        U 5      (       a   [        U 5      (       a  [        U 5      (       a  Sv •  g[        R
                  " U 5      n[        R                  " U 5         Sv •  [        R                  " U [        R                  U5        g! [        R                  " U [        R                  U5        f = f7f)z›
Force local terminal ``stream`` be character, not line, buffered.

Only applies to Unix-based systems; on Windows this is a no-op.

.. versionadded:: 1.0
N)
ÚWINDOWSr
   rX   rk   r@   r^   ÚttyÚ	setcbreakÚ	tcsetattrÚ	TCSADRAIN)rR   Úold_settingss     r&   Úcharacter_bufferedrs   ±   sƒ   é € ÷ 	ŠÜ�f�~‰~Ü(¨×0Ñ0Ü˜f×%Ñ%ää×(Ò(¨Ó0ˆÜ�Š�fÔð	GÛä×Ò˜f¤g×&7Ñ&7¸ÕFøŒG×Ò˜f¤g×&7Ñ&7¸ÕFüs   ‚A-CÁ0B Á4'CÂ(CÃCÚinput_c                 óä   • [        U 5      (       d  g[        R                  S:X  a  [        R                  " 5       $ [
        R
                  " U // / S5      u  n  n[        U=(       a    US   U L 5      $ )zÍ
Test ``input_`` to determine whether a read action will succeed.

:param input_: Input stream object (file-like).

:returns: ``True`` if a read should succeed, ``False`` otherwise.

.. versionadded:: 1.0
Tr   g        r   )r	   r>   ÚplatformÚmsvcrtÚkbhitÚselectr_   )rt   ÚreadsrM   s      r&   Úready_for_readingr{   Ì   s_   € ô �f×ÑØÜ
‡|�|�wÓÜ�|Š|‹~Ðä—m’m V H¨b°"°cÓ:‰ˆˆq�!Ü�E×0˜e A™h¨&Ð0Ó1Ð1r%   c                 óì   • [         (       di  [        U 5      (       aY  [        U 5      (       aI  [        R                  " U [
        R                  S5      n[        [        R                  " SU5      S   5      $ g)aX  
Query stream ``input_`` to see how many bytes may be readable.

.. note::
    If we are unable to tell (e.g. if ``input_`` isn't a true file
    descriptor or isn't a valid TTY) we fall back to suggesting reading 1
    byte only.

:param input: Input stream object (file-like).

:returns: `int` number of bytes to read.

.. versionadded:: 1.0
s     Úhr   r   )
rm   r
   r	   r<   r=   r@   ÚFIONREADÚintr:   rB   )rt   Úfionreads     r&   Úbytes_to_readr�   ã   sQ   € ÷$ Š7”v˜f—~‘~¬*°V×*<Ñ*<Ü—;’;˜v¤w×'7Ñ'7¸Ó?ˆÜ”6—=’=  hÓ/°Ñ2Ó3Ð3Ør%   )(Ú__doc__Ú
contextlibr   Útypingr   r   r   r   rT   ry   r>   Úutilr	   r
   rv   rm   rw   Úctypesr   r   r   r   r   Úctypes.wintypesr   r   r   r<   r:   r@   rn   r   r7   rQ   r_   rX   rk   rs   r{   r�   r   r%   r&   Ú<module>rˆ      s@  ðñõ &ß 1Ó 1Û 	Û Û 
÷ %ð �,‰,˜'Ñ
!€ðð ‡<�<�7ÓÛ÷õ ÷ <Ò;ãÛÛÛð ‡<�<�7Óð �u˜X c™]¨H°S©MÐ9Ñ:õ  ð> �u˜X c™]¨H°S©MÐ9Ñ:ô  ðF$�%˜˜S˜‘/ô $ð9 bð 9¨Tô 9ð0˜rð  dô ð, ðGØðGàÐÑ óGó ðGð42˜bð 2 Tô 2ð.˜"ð  õ r%   