%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/rich/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/rich/__pycache__/_win32_console.cpython-312.pyc

�

"T�eY�
��UdZddlZddlZddlmZdZeed<ejdk(rejej�Zne
e�d���ddlZddlm
Z
mZmZddlmZmZmZmZdd	lmZdd
lmZdZdZej4ZGd
�de�ZGd�de�ZGd�de
�ZGd�dej�Z ejBjDZ#ejHge#_%ejLe#_'efde(dejLfd�Z"ejBjRZ*ejLejVge*_%ejXe*_'dejLde(fd�Z)ejBjZZ.ejLej^ejHeeee�ej`ejH�ge._%ejXe._'dejLde1de(dede(f
d�Z2ejBjfZ4ejLejjejHeeee�ej`ejH�ge4_%ejXe4_'dejLde(de(dede(f
d�Z3ejBjlZ7ejLejjge7_%ejXe7_'dejLdejjde8fd �Z6ejBjrZ:ejLej`e�ge:_%ejXe:_'dejLdefd!�Z9ejBjvZ<ejLeeee�ge<_%ejXe<_'dejLd"ede8fd#�Z;ejBjzZ>ejLej`e �ge>_%ejXe>_'dejLd$e de8fd%�Z=ejBj~Z@ejLej`e �ge@_%ejXe@_'dejLd$e de8fd&�Z?ejBj�ZBej�geB_%ejXeB_'d'e1de8fd(�ZDGd)�d*�ZEed+k(�r�e"�ZFdd,lGmHZHeH�ZIeEej��ZKeKj�d-�ed.d/�0�ZMej�d1�ZOeIj�d2�eIj�d3�eIj�d4�eIj�d5�eIj�d6�eIj�d7�eIj�d8�eIj�d9�eIj�d:�eIj�d;�eIj�d<�eIj�d=�eIj�d>�eIj�d?�eIj�d@�eIj�dA�eIj�dB�eIj��eKj��eKj��eKj�dC�ej�dD�eKj��eKj�dE�ej�dD�eKj��eKj�dF�ej�dD�eKj��eKj��eKj��eKj�dG�ej�dD�eKj��eKj��eKj��eKj�dH�ej�dD�eKj��eIj��eIj�dI�eIj�dJ�eKj�dK�ej�dD�eKj�dL�eKj�dMej�dN��eKj��ej�dD�eKj��ej�dD�eIj�dO�eKj�dK�ej�dD�eKj�dL�eKj�dPej�dN��ej�dD�eKj��ej�dD�eIj�dQ�eKj�dRej�dS��T�ej�dD�eKj��eKj��eQdU�yy)Vz�Light wrapper around the Win32 Console API - this module should only be imported on Windows

The API that this module wraps is documented at https://docs.microsoft.com/en-us/windows/console/console-functions
�N)�Any�windll�win32z  can only be imported on Windows)�	Structure�byref�wintypes)�IO�
NamedTuple�Type�cast)�ColorSystem)�Stylei�����c��eZdZy)�LegacyWindowsErrorN)�__name__�
__module__�__qualname__���5/usr/lib/python3/dist-packages/rich/_win32_console.pyrrs��rrc�@�eZdZUdZeed<eed<edddefd��Zy)�WindowsCoordinatesz�Coordinates in the Windows Console API are (y, x), not (x, y).
    This class is intended to prevent that confusion.
    Rows and columns are indexed from 0.
    This class can be used in place of wintypes._COORD in arguments and argtypes.
    �row�col�value�returnc�B�t|j|j�S)aEConverts a WindowsCoordinates into a wintypes _COORD structure.
        This classmethod is internally called by ctypes to perform the conversion.

        Args:
            value (WindowsCoordinates): The input coordinates to convert.

        Returns:
            wintypes._COORD: The converted coordinates struct.
        )�COORDrr)�clsrs  r�
from_paramzWindowsCoordinates.from_param*s���U�Y�Y��	�	�*�*rN)	rrr�__doc__�int�__annotations__�classmethodrr!rrrrr s4���

�H�	�H��
+�3�
+��
+��
+rrc�V�eZdZdefdefdej
fdejfdefgZy)�CONSOLE_SCREEN_BUFFER_INFO�dwSize�dwCursorPosition�wAttributes�srWindow�dwMaximumWindowSizeN)rrrrr�WORD�
SMALL_RECT�_fields_rrrr'r'8s;��	�5��	�U�#�	��
�
�&�	�X�(�(�)�	��&��Hrr'c�D�eZdZdejfdej
fgZy)�CONSOLE_CURSOR_INFOr(�bVisibleN)rrrr�DWORD�BOOLr/rrrr1r1Bs���8�>�>�*�Z����,G�H�Hrr1�handlerc�H�ttjt|��S)z�Retrieves a handle to the specified standard device (standard input, standard output, or standard error).

    Args:
        handle (int): Integer identifier for the handle. Defaults to -11 (stdout).

    Returns:
        wintypes.HANDLE: The handle
    )rr�HANDLE�
_GetStdHandle)r5s r�GetStdHandler9Ms�������v�!6�7�7r�
std_handlec��tj�}tt||��}|st	d��|j
S)aRetrieves the current input mode of a console's input buffer
    or the current output mode of a console screen buffer.

    Args:
        std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.

    Raises:
        LegacyWindowsError: If any error occurs while calling the Windows console API.

    Returns:
        int: Value representing the current console mode as documented at
            https://docs.microsoft.com/en-us/windows/console/getconsolemode#parameters
    z)Unable to get legacy Windows Console Mode)rr3�bool�_GetConsoleModerr)r:�console_mode�successs   r�GetConsoleModer@^s<���>�>�#�L��?�:�|�<�=�G�� �!L�M�M����r�char�length�startc	���tj|j��}tj|�}tjd�}t||||t
|��|jS)a�Writes a character to the console screen buffer a specified number of times, beginning at the specified coordinates.

    Args:
        std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
        char (str): The character to write. Must be a string of length 1.
        length (int): The number of times to write the character.
        start (WindowsCoordinates): The coordinates to start writing at.

    Returns:
        int: The number of characters written.
    r)�ctypes�c_char�encoderr3�_FillConsoleOutputCharacterWrr)r:rArBrC�	character�num_characters�num_writtens       r�FillConsoleOutputCharacterrLs^��"�
�
�d�k�k�m�,�I��^�^�F�+�N��.�.��#�K� ����
�
�k������r�
attributesc	���tj|�}tj|�}tjd�}t||||t	|��|j
S)alSets the character attributes for a specified number of character cells,
    beginning at the specified coordinates in a screen buffer.

    Args:
        std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
        attributes (int): Integer value representing the foreground and background colours of the cells.
        length (int): The number of cells to set the output attribute of.
        start (WindowsCoordinates): The coordinates of the first cell whose attributes are to be set.

    Returns:
        int: The number of cells whose attributes were actually set.
    r)rr3r-�_FillConsoleOutputAttributerr)r:rMrBrC�	num_cells�style_attrsrKs       r�FillConsoleOutputAttributerR�sT��$���v�&�I��-�-�
�+�K��.�.��#�K���K��E�5��3E�����rc�,�tt||��S)a|Set the colour attributes for all text written after this function is called.

    Args:
        std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
        attributes (int): Integer value representing the foreground and background colours.


    Returns:
        bool: True if the attribute was set successfully, otherwise False.
    )r<�_SetConsoleTextAttribute)r:rMs  r�SetConsoleTextAttributerU�s���(��Z�@�A�Arc�D�t�}t|t|��|S)aqRetrieves information about the specified console screen buffer.

    Args:
        std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.

    Returns:
        CONSOLE_SCREEN_BUFFER_INFO: A CONSOLE_SCREEN_BUFFER_INFO ctype struct contain information about
            screen size, cursor position, colour attributes, and more.)r'�_GetConsoleScreenBufferInfor)r:�console_screen_buffer_infos  r�GetConsoleScreenBufferInforY�s#��"<�!=���
�E�2L�,M�N�%�%r�coordsc�,�tt||��S)aESet the position of the cursor in the console screen

    Args:
        std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
        coords (WindowsCoordinates): The coordinates to move the cursor to.

    Returns:
        bool: True if the function succeeds, otherwise False.
    )r<�_SetConsoleCursorPosition)r:rZs  r�SetConsoleCursorPositionr]�s���)�*�f�=�>�>r�cursor_infoc�>�tt|t|���S)a�Get the cursor info - used to get cursor visibility and width

    Args:
        std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
        cursor_info (CONSOLE_CURSOR_INFO): CONSOLE_CURSOR_INFO ctype struct that receives information
            about the console's cursor.

    Returns:
          bool: True if the function succeeds, otherwise False.
    )r<�_GetConsoleCursorInfor�r:r^s  r�GetConsoleCursorInforbs���%�j�%��2D�E�F�Frc�>�tt|t|���S)awSet the cursor info - used for adjusting cursor visibility and width

    Args:
        std_handle (wintypes.HANDLE): A handle to the console input buffer or the console screen buffer.
        cursor_info (CONSOLE_CURSOR_INFO): CONSOLE_CURSOR_INFO ctype struct containing the new cursor info.

    Returns:
          bool: True if the function succeeds, otherwise False.
    )r<�_SetConsoleCursorInforras  r�SetConsoleCursorInfore*s���%�j�%��2D�E�F�Fr�titlec�*�tt|��S)z�Sets the title of the current console window

    Args:
        title (str): The new title of the console window.

    Returns:
        bool: True if the function succeeds, otherwise False.
    )r<�_SetConsoleTitle)rfs r�SetConsoleTitleri>s��� ��'�(�(rc��eZdZdZdZgd�Zdd�Zedefd��Z	edefd��Z
d	eddfd
�Zd	ede
ddfd�Zd
eddfd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdeddfd�Zdd�Zdd�Zdd�Zdeddfd�Zdefd�Zy)�LegacyWindowsTerma�This class allows interaction with the legacy Windows Console API. It should only be used in the context
    of environments where virtual terminal processing is not available. However, if it is used in a Windows environment,
    the entire API should work.

    Args:
        file (IO[str]): The file which the Windows Console API HANDLE is retrieved from, defaults to sys.stdout.
    �)rr������rl��
��	�
��rNc�*�tt�}||_t|�j}||_|dz|_|dz	dz|_|j|jdzz|_||_	|j|_
|j|_y)Nrrr)r9�STDOUT�_handlerYr*�
_default_text�
_default_fore�
_default_back�_default_attrs�_file�write�flush)�self�filer5�default_texts    r�__init__zLegacyWindowsTerm.__init__is����f�%�����1�&�9�E�E��)���)�A�-���*�a�/�1�4���"�0�0�D�4F�4F�!�4K�L�����
��Z�Z��
��Z�Z��
rc��t|j�j}tt	t
|j�t	t
|j���S)z�Returns the current position of the cursor (0-based)

        Returns:
            WindowsCoordinates: The current cursor position.
        �rr)rYr|r)rrr#�Y�X)r��coords  r�cursor_positionz!LegacyWindowsTerm.cursor_positionws;��2�$�,�,�?�P�P��!�d�3����&8�d�3����>P�Q�Qrc��t|j�j}tt	t
|j�t	t
|j���S)z�Returns the current size of the console screen buffer, in character columns and rows

        Returns:
            WindowsCoordinates: The width and height of the screen as WindowsCoordinates.
        r�)rYr|r(rrr#r�r�)r��screen_sizes  rr�zLegacyWindowsTerm.screen_size�s@��8����E�L�L��!��S�+�-�-�(�d�3��
�
�.F�
�	
r�textc�F�|j|�|j�y)z�Write text directly to the terminal without any modification of styles

        Args:
            text (str): The text to write to the console
        N)r�r�)r�r�s  r�
write_textzLegacyWindowsTerm.write_text�s��	
�
�
�4���
�
�r�stylec���|j}|j}|jr||}}|rv|jtj
�j}|�|nd}|jr||jz}|jr||jz}|j|}n|j}|r?|jtj
�j}|�|nd}|j|}n|j}|�J�|�J�t|jtj ||dzz���|j#|�t|j|j$��y)z�Write styled text to the terminal.

        Args:
            text (str): The text to write
            style (Style): The style of the text
        Nrrrr)rM)�color�bgcolor�reverse�	downgrader
�WINDOWS�number�bold�
BRIGHT_BIT�dim�ANSI_TO_WINDOWSr~rrUr|rE�c_ushortr�r})r�r�r�r�r��fore�backs       r�write_styledzLegacyWindowsTerm.write_styled�s:�������-�-���=�=�$�e�7�E���?�?�;�#6�#6�7�>�>�D��+�4��D��z�z��d�o�o�-���y�y��t���.�.���'�'��-�D��%�%�D���$�$�[�%8�%8�9�@�@�D��+�4��D��'�'��-�D��%�%�D�����������L�L�V�_�_�T�T�Q�Y�5G�%H�	
�	
����������9K�9K�Lr�new_positionc�p�|jdks|jdkryt|j|��y)z�Set the position of the cursor

        Args:
            new_position (WindowsCoordinates): The WindowsCoordinates representing the new position of the cursor.
        rN�rZ)rrr]r|)r�r�s  r�move_cursor_toz LegacyWindowsTerm.move_cursor_to�s0�����a��<�#3�#3�a�#7�� ����l�Crc���|j}|j}|j}t|jd��}t|jd||��t|j|j||��y)z@Erase all content on the line the cursor is currently located atrr�� �rBrCN)	r�r�rrrrLr|rRr�)r�r�r��cells_to_erase�start_coordinatess     r�
erase_linezLegacyWindowsTerm.erase_line�sj���&�&���.�.��$����.�?�3F�3F�A�N��"��L�L�#�n�<M�	
�	#��L�L����!�#�		
rc���|j}|jj|jz
}t|jd||��t|j|j||��y)zBErase all content from the cursor position to the end of that liner�r�N)r�r�rrLr|rRr�)r�r�r�s   r�erase_end_of_linez#LegacyWindowsTerm.erase_end_of_line�s^���.�.���)�)�-�-��0C�0C�C��"��L�L�#�n�O�	
�	#��L�L����!�!�		
rc��|j\}}t|d�}t|jd||��t	|j|j
||��y)zDErase all content from the cursor position to the start of that linerr�r�N)r�rrLr|rRr�)r�rrrCs    r�erase_start_of_linez%LegacyWindowsTerm.erase_start_of_line�sJ���'�'���S�"�3��*��"�4�<�<��S��N�"��L�L�$�-�-�c��	
rc��|j}t|jt|jdz
|j
����y)z Move the cursor up a single cellror�r�N�r�r]r|rrr�r�r�s  r�move_cursor_upz LegacyWindowsTerm.move_cursor_up�s:���.�.�� ��L�L�%�#�'�'�!�+��1D�1D��	
rc��|j}t|jt|jdz|j
����y)z"Move the cursor down a single cellror�r�Nr�r�s  r�move_cursor_downz"LegacyWindowsTerm.move_cursor_down�s;���.�.�� ��L�L�%�#�'�'�!�+�#�'�'��	
rc��|j\}}||jjdz
k(r|dz
}d}n|dz
}t|jt||����y)zIMove the cursor forward a single cell. Wrap to the next line if required.rorr�r�N�r�r�rr]r|r�r�rrs   r�move_cursor_forwardz%LegacyWindowsTerm.move_cursor_forwardsZ���'�'���S��$�"�"�&�&��*�*��1�H�C��C��1�H�C� ��L�L�!3���!E�	
r�columnc�d�|j\}}t|jt||���y)z�Move cursor to the column specified by the zero-based column index, staying on the same row

        Args:
            column (int): The zero-based column index to move the cursor to.
        r�N)r�r]r|r)r�r�r�_s    r�move_cursor_to_columnz'LegacyWindowsTerm.move_cursor_to_columns)���%�%���Q� ����6H��f�6U�Vrc��|j\}}|dk(r|dz}|jjdz
}n|dz}t|jt||����y)zNMove the cursor backward a single cell. Wrap to the previous line if required.rror�r�Nr�r�s   r�move_cursor_backwardz&LegacyWindowsTerm.move_cursor_backwardsY���'�'���S��!�8��1�H�C��"�"�&�&��*�C��1�H�C� ��L�L�!3���!E�	
rc�l�|j�}t|d��}t|j|��y)zHide the cursorr�r(r2�r^N��_get_cursor_sizer1rer|)r��current_cursor_size�invisible_cursors   r�hide_cursorzLegacyWindowsTerm.hide_cursor$s/��"�3�3�5��.�6I�TU�V���T�\�\�7G�Hrc�l�|j�}t|d��}t|j|��y)zShow the cursorror�r�Nr�)r�r��visible_cursors   r�show_cursorzLegacyWindowsTerm.show_cursor*s-��"�3�3�5��,�4G�RS�T���T�\�\�~�Frrfc�D�t|�dksJd��t|�y)zySet the title of the terminal window

        Args:
            title (str): The new title of the console window
        �z.Console title must be less than 255 charactersN)�lenri)r�rfs  r�	set_titlezLegacyWindowsTerm.set_title0s$���5�z�C��Q�!Q�Q����rc�n�t�}t|j|��t|j�S)zEGet the percentage of the character cell that is filled by the cursorr�)r1rbr|r#r()r�r^s  rr�z"LegacyWindowsTerm._get_cursor_size9s)��)�+���T�\�\�{�C��;�%�%�&�&r)r�zIO[str]rN)rN)rrrr"r�r�r��propertyrr�r��strr�rr�r�r�r�r�r�r�r�r#r�r�r�r�r�r�rrrrkrkJs����J��O�& ��R�!3�R��R��	
�/�	
��	
��s��t��%M��%M�U�%M�t�%M�ND�+=�D�$�D�
� 
�
�
�	
�

�W�C�W�D�W�

�I�G��s��t��'�#�'rrk�__main__)�ConsolezWin32 Console Examples�black�red)r�r�zblack on greenzChecking colour outputz[on red]on red!z[blue]blue!z[yellow]yellow!z[bold yellow]bold yellow!z[bright_yellow]bright_yellow!z%[dim bright_yellow]dim bright_yellow!z[italic cyan]italic cyan!z'[bold white on blue]bold white on blue!z7[reverse bold white on blue]reverse bold white on blue!z'[bold black on cyan]bold black on cyan!z[black on green]black on green!z[blue on green]blue on green!z[white on black]white on black!z[black on white]black on white!z'[#1BB152 on #DA812D]#1BB152 on #DA812D!zChecking cursor movementz"went back and wrapped to prev linerozwe go upzand downzwe went up and back 2zwe went down and back 2zChecking line erasingz(
...Deleting to the start of the line...z?The red arrow shows the cursor location, and direction of erase��<zblack on redz"

...And to the end of the line...�>z)

...Now the whole line will be erased...zI'm going to disappear!z
black on cyan)r��
)^r"rE�sys�typingrrr$�platform�
LibraryLoader�WinDLL�ImportErrorr�timerrrr	r
rr�
rich.colorr
�
rich.stylerr{�"ENABLE_VIRTUAL_TERMINAL_PROCESSING�_COORDr�	Exceptionrrr'r1�kernel32r9r8r3�argtypesr7�restyper#r@r=�LPDWORDr4�FillConsoleOutputCharacterWrHrF�POINTERr�rLrRrOr-rUrTr<rYrWr]r\rbr`rerd�SetConsoleTitleWrh�LPCWSTRrirkr5�rich.consoler��console�stdout�termr�r��parse�heading�rule�printr�r��sleepr�r�r�r�r�r�r�r�r�rrr�<module>r�sj����
�������<�<�7��
!�V�
!�
!�&�-�-�
0�F�
��
�"B�C�
D�D��-�-�-�-�"��	��%&�"�����	��	�+��+�0���I�&�*�*�I����,�,�
��N�N��
��!���
�� &�	8��	8�(�/�/�	8��/�/�0�0��$�O�O�X�-=�-=�>���"�-�-����x����3��, &���J�J���O�O�
�M�M��N�N���e��(�)��F�N�N�8�>�>�"�)��%�(0�}�}��$������

��
���	�
	��<%�o�o�H�H���O�O��M�M��N�N���e��(�)��F�N�N�8�>�>�"�(��$�'/�m�m��#��������
���	�
	��6"�?�?�B�B���O�O��M�M�%��!�$,�=�=�� �
B����
B�-5�]�]�
B�	�
B� %�o�o�H�H���O�O��F�N�N�-�.�(��$�'/�m�m��#�
&����
&��
&� #�O�O�D�D���O�O���e��(�)�&��"�%-�M�M��!�?����?�);�?�	�?����<�<���O�O��F�N�N�&�'�"���!)�
�
���
G����
G�.A�
G�	�
G� ���<�<���O�O��F�N�N�&�'�"���!)�
�
���G����G�.A�G�	�G��?�?�3�3��%�-�-�.���#�=�=���	)�3�	)�4�	)�s'�s'�l�z��
�^�F�$��i�G��S�Z�Z�(�D��N�N�+�,����/�E��e�k�k�*�+�G��L�L�)�*��M�M�#�$��M�M�-� ��M�M�#�$��M�M�-�.��M�M�1�2��M�M�9�:��M�M�-�.��M�M�;�<��M�M�K�L��M�M�;�<��M�M�3�4��M�M�1�2��M�M�3�4��M�M�3�4��M�M�;�<��L�L�+�,��M�M�O����������O�O�8�9��D�J�J�q�M������O�O�J���D�J�J�q�M������O�O�J���D�J�J�q�M��������������O�O�+�,��D�J�J�q�M��������������O�O�-�.��D�J�J�q�M�	�����M�M�O��L�L�(�)��M�M�=�>��O�O�U�V��D�J�J�q�M����r�"����c�;�5�;�;�~�6�7������D�J�J�q�M������D�J�J�q�M��M�M�8�9��O�O�U�V��D�J�J�q�M����r�"����c�;�5�;�;�~�6�7��D�J�J�q�M������D�J�J�q�M��M�M�?�@����/�{�u�{�{�?�7S��T��D�J�J�q�M��O�O������	�$�K�mr

Zerion Mini Shell 1.0