
    tni                     B    d Z ddlZddlZddlmZ ddlmZmZ defdZ	dS )z
Unified getchar implementation for all platforms.

Combines approaches from:
- Textual (Unix/Linux): Copyright (c) 2023 Textualize Inc., MIT License
- Click (Windows fallback): Copyright 2014 Pallets, BSD-3-Clause License
    N)getincrementaldecoder)OptionalTextIOreturnc                     t           j        dk    r	 ddl} n/# t          $ r" t           j                            d          cY S w xY w| j        } |            }|dv r| |            z  }|S |g}d}t          |          |k     rs|                                 r_ |            }|dv rnP|	                    |           |dk    rt                      t          |          |k     r|                                 _d                    |          }d|v rt                      |S ddl}ddl}d}	t           j                                        s$t          d	          }	|	                                }
nt           j                                        }
	 |                    |
          }	 |                    |
          }||j        xx         |j        |j        z  |j        z  |j        z   z  cc<   ||j        xx         |j        |j        z  |j        z  |j        z  |j        z   z  cc<   d||j                 |j        <   |                    |
|j         |           tC          j        |
d          } tE          d
                      }|#                    |d          }d|v rt                      ||                    |
|j         |           t           j$        %                                 |	|	&                                 S S # |                    |
|j         |           t           j$        %                                 |	|	&                                 w w xY w# |j'        $ r" t           j                            d          cY S w xY w)a.  
    Read input from stdin with support for longer pasted text.

    On Windows:
    - Uses msvcrt for native Windows console input
    - Handles special keys that send two-byte sequences
    - Reads up to 4096 characters for paste support

    On Unix/Linux:
    - Uses Textual's approach with manual termios configuration
    - Reads up to 4096 bytes with proper UTF-8 decoding
    - Provides fine-grained terminal control

    Returns:
        str: The input character(s) read from stdin

    Raises:
        KeyboardInterrupt: When CTRL+C is pressed
    win32r   N   )    ài    z/dev/ttyzutf-8T)final)(sysplatformmsvcrtImportErrorstdinreadgetwchlenkbhitappendKeyboardInterruptjointermiosttyisattyopenfileno	tcgetattrLFLAGECHOICANONIEXTENISIGIFLAGIXONIXOFFICRNLINLCRIGNCRCCVMIN	tcsetattrTCSANOWosr   decodestdoutflushcloseerror)r   funcrvchars	max_chars	next_charresultr   r   ffdattrs_beforenewattrraw_datadecoders                  R/var/www/html/gpu-tools/venv/lib/python3.11/site-packages/rich_toolkit/_getchar.pygetcharrC      s   ( |w	%MMMM 	% 	% 	%9>>!$$$$$	%
 } TVV !!!$$&&LBI 	 %jj9$$$I ,,,LL### F""'))) %jj9$$$  V#%%% 	


" y!! 	$Z  ABB!!##B<	%",,R00L4!++B// 	"""L7>1GNBW\Q' """ 	"""Lm$m$ m$ m	$' """ 12- !!"gow??? 72x00 9/88:: == V##+--- !!"go|DDD
  """=GGIIII ! !!"go|DDD
  """=GGIIII ! } 	% 	% 	%9>>!$$$$$	%s<    )AA
M  D
K< *AM <AMM )M>=M>)
__doc__r0   r   codecsr   typingr   r   strrC        rB   <module>rJ      sy     
			 



 ( ( ( ( ( ( # # # # # # # #N% N% N% N% N% N% N%rI   