%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__/syntax.cpython-312.pyc

�

"T�e'����UddlZddlZddlZddlZddlZddlmZmZddl	m
Z
ddlmZm
Z
mZmZmZmZmZmZmZmZmZddlmZddlmZmZddlmZddlm Z dd	l!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+dd
l,m-Z-ddl.m/Z/ddl0m1Z1m2Z2d
dl3m4Z4d
dl5m6Z6d
dl7m8Z8m9Z9d
dl:m;Z;m<Z<m=Z=m>Z>d
dl?m@Z@d
dlAmBZBd
dlCmDZDmEZEd
dlFmZmGZGd
dlHmIZIeeJdfZKej��dk(ZMdZNie*e��e+ed���e"ed���e"j�ed���e%ed���e%j*ed���e(j�ed ���e&j�ed���e&j�ed!���e&j�edd�"��e&j�ed!d�"��e&j�ed���e&j�ed d�#��e&j�ed$���e&j�ed$���e&j�ed���e&j�ed%���e)ed&��e'ed��e$j�ed'��e$j�ed!��e$j�ed�(�e$j�ed d�#�e$j�ed�(�e$jFed'��e#ed$d�"�i	�Z`e
eKefead)<ie*e��e+ed*���e"ed���e"j�ed+���e%ed%���e%j*ed+���e(j�ed,���e&j�ed+���e&j�ed-���e&j�ed+d�"��e&j�ed-d�"��e&j�ed+���e&j�ed,d�#��e&j�ed'���e&j�ed'���e&j�ed+���e&j�ed%���e)ed&��e'ed%��e$j�ed'��e$j�ed-��e$j�ed�(�e$j�ed,d�#�e$j�ed�(�e$jFed'��e#ed$d�"�i	�Zbe
eKefead.<e`ebd/�Zcd0ZdGd1�d2e�ZeGd3�d4ee�ZfGd5�d6ee�ZgeehehfZiGd7�d8e�ZjGd9�d:e@�Zkd;eehd<eid=eehfd>�Zlemd?k(�r�ddlnZnddlZenj�d@�A�Zpepj�dBdCdD�E�epj�dFdGdHdIddJ�K�epj�dLdMdNdIdOdP�K�epj�dQdRdSdIdT�U�epj�dVdWehdXddY�Z�epj�d[d\d]dIdOd^�K�epj�d_d`dIdadOdb�c�epj�dddedfddg�h�epj�didjdkddl�h�epj�dmdnddodp�q�epj�drdsehddtdu�v�epj�dwehddxdy�v�epj��Zsddzltm;Z;e;esj�esj��{�Z:esj�d|k(r�ej�j��Zzekezesj�esj�esj�esj�esj�es�jes�jes�jh�}�	Z�nyek�j	esj�esj�esj�esj�esj�esj�es�jes�jes�jh�~�	Z�e:�je�es�j��yy)��N)�ABC�abstractmethod)�Path)�Any�Dict�Iterable�List�
NamedTuple�Optional�Sequence�Set�Tuple�Type�Union)�Lexer)�get_lexer_by_name�guess_lexer_for_filename)�Style)�get_style_by_name)
�Comment�Error�Generic�Keyword�Name�Number�Operator�String�Token�
Whitespace)�
ClassNotFound)�Lines)�Padding�PaddingDimensions�)�
loop_first��cell_len)�Color�	blend_rgb)�Console�ConsoleOptions�
JustifyMethod�RenderResult)�JupyterMixin)�Measurement)�Segment�Segments)r�	StyleType)�Text.�Windows�monokai�white��colorT��dim�cyan�blue�magenta�green)r8�	underline)r8�bold�red�bright_blue�yellow�
bright_red)r@�
ANSI_LIGHT�bright_black�bright_cyan�bright_magenta�bright_green�	ANSI_DARK)�
ansi_light�	ansi_dark�c�@�eZdZdZededefd��Zedefd��Zy)�SyntaxThemezBase class for a syntax theme.�
token_type�returnc��t�)z'Get a style for a given Pygments token.��NotImplementedError)�selfrPs  �-/usr/lib/python3/dist-packages/rich/syntax.py�get_style_for_tokenzSyntaxTheme.get_style_for_token~�
��"�!�c��t�)zGet the background color.rS�rUs rV�get_background_stylez SyntaxTheme.get_background_style�rXrYN)	�__name__�
__module__�__qualname__�__doc__r�	TokenTyperrWr\�rYrVrOrO{s@��(��"�i�"�E�"��"��"�e�"��"rYrOc�L�eZdZdZdeeeefddfd�Zde	de
fd�Zde
fd�Zy)	�PygmentsSyntaxThemez.Syntax theme that delegates to Pygments theme.�themerQNc��i|_t|t�r	t|�|_n||_|jj|_t|j��|_	y#t
$rtd�|_Y�RwxYw)N�default��bgcolor)
�_style_cache�
isinstance�strr�_pygments_style_classr �background_color�_background_colorr�_background_style)rUres  rV�__init__zPygmentsSyntaxTheme.__init__�sx��46����e�S�!�
J�->�u�-E��*�*/�D�&�!%�!;�!;�!L�!L���!&�t�/E�/E�!F����
!�
J�->�y�-I��*�
J�s�A(�(B�BrPc	�V�	|j|S#t$r�	|jj|�}|d}|d}t	|rd|znd|rd|zn|j
|d|d|d��}n##t$rt	j�}YnwxYw||j|<Y|SwxYw)	z"Get a style from a Pygments class.r8ri�#z#000000r@�italicr?)r8rir@rtr?)rj�KeyErrorrm�style_for_tokenrro�null)rUrP�pygments_styler8ri�styles      rVrWz'PygmentsSyntaxTheme.get_style_for_token�s���	2��$�$�Z�0�0���	2�

�!%�!;�!;�!K�!K�J�!W��'�w�/��(��3���).�#��+�I�-4�C�'�M�$�:P�:P�'��/�)�(�3�,�[�9�����
%��
�
���
%��-2�D���j�)���!	2�s1��	B(�A2�<B(�2B�B(�B�B(�'B(c��|jS�N�rpr[s rVr\z(PygmentsSyntaxTheme.get_background_style�����%�%�%rY)
r]r^r_r`rrlr�
PygmentsStylerqrarrWr\rbrYrVrdrd�sI��8�G�e�C��m�)<�$<�=�G�$�G��i��E��,&�e�&rYrdc�F�eZdZdZdeeefddfd�Zdedefd�Zdefd�Z	y)	�ANSISyntaxThemez$Syntax theme to use standard colors.�	style_maprQNc��||_tj�|_tj�|_i|_yr{)r�rrw�_missing_stylerprj)rUr�s  rVrqzANSISyntaxTheme.__init__�s-��"���#�j�j�l���!&������46��rYrPc���	|j|S#t$rX|jj}t	|�}|j
}|r||�}|�|}n|dd}|r�||j|<|cYSwxYw)zLook up style in the style map.N���)rjrur��get�tupler�)rUrP�	get_style�tokenry�_styles      rVrWz#ANSISyntaxTheme.get_style_for_token�s���	��$�$�Z�0�0���	����*�*�I��*�%�E��'�'�E��"�5�)���%�"�E���c�r�
���-2�D���j�)��L�	�s��AA2�A2�1A2c��|jSr{r|r[s rVr\z$ANSISyntaxTheme.get_background_style�r}rY)
r]r^r_r`rrarrqrWr\rbrYrVr�r��sA��.�7�$�y�%�'7�"8�7�T�7��i��E��(&�e�&rYr�c�0�eZdZUdZeed<eed<eed<y)�_SyntaxHighlightRangez�
    A range to highlight in a Syntax object.
    `start` and `end` are 2-integers tuples, where the first integer is the line number
    (starting from 1) and the second integer is the column index (starting from 0).
    ry�start�endN)r]r^r_r`r2�__annotations__�SyntaxPositionrbrYrVr�r��s�������	�rYr�c"� �eZdZUdZeeed<eed<ede	e
efdefd��Zedddd	d	d	d
dd	ddd�d
e
de	e
e
fde	e
efdedededeeeeeefdeeedeedededee
dededd	fd�Zedd	eddd	dd	d	d
dd	ddfde
de
dee	e
e
fde	e
efdededeeeefdedeeedeedededee
dededdf d��Zed7de
d
ee
de
fd ��Zdefd!�Zd"edeefd#�Zedee
fd$��Zede
fd%��Z	d7d
e
deeeeeefdefd&�Z d'e!d(e"d)e"dd	fd*�Z#d8d+e$defd,�Z%edefd-��Z&d.e'deeeeffd/�Z(						d9d1�Z)d.e'd0e*de+fd2�Z,d.e'd0e*de-e.fd3�Z/d4edd	fd5�Z0d
e
deee
ffd6�Z1y	):�Syntaxa�Construct a Syntax object to render syntax highlighted code.

    Args:
        code (str): Code to highlight.
        lexer (Lexer | str): Lexer to use (see https://pygments.org/docs/lexers/)
        theme (str, optional): Color theme, aka Pygments style (see https://pygments.org/docs/styles/#getting-a-list-of-available-styles). Defaults to "monokai".
        dedent (bool, optional): Enable stripping of initial whitespace. Defaults to False.
        line_numbers (bool, optional): Enable rendering of line numbers. Defaults to False.
        start_line (int, optional): Starting number for line numbers. Defaults to 1.
        line_range (Tuple[int | None, int | None], optional): If given should be a tuple of the start and end line to render.
            A value of None in the tuple indicates the range is open in that direction.
        highlight_lines (Set[int]): A set of line numbers to highlight.
        code_width: Width of code to render (not including line numbers), or ``None`` to use all available width.
        tab_size (int, optional): Size of tabs. Defaults to 4.
        word_wrap (bool, optional): Enable word wrapping.
        background_color (str, optional): Optional background color, or None to use theme color. Defaults to None.
        indent_guides (bool, optional): Show indent guides. Defaults to False.
        padding (PaddingDimensions): Padding to apply around the syntax. Defaults to 0 (no padding).
    rm�_theme�namerQc�x�t|t�r|S|tvrtt|�}|St	|�}|S)zGet a syntax theme instance.)rkrO�RICH_SYNTAX_THEMESr�rd)�clsr�res   rV�	get_themezSyntax.get_theme�sD���d�K�(��K��%�%�#�$6�t�$<�=�E���(��-�E��rYFr$N�r)re�dedent�line_numbers�
start_line�
line_range�highlight_lines�
code_width�tab_size�	word_wraprn�
indent_guides�padding�code�lexerrer�r�r�r�r�r�r�r�rnr�r�c�F�||_||_||_||_||_||_|xs
t
�|_|	|_|
|_	||_
||_|rt|��n	t�|_
|
|_||_|j!|�|_g|_y)Nrh)r��_lexerr�r�r�r��setr�r�r�r�rnr�background_styler�r�r�r��_stylized_ranges)rUr�r�rer�r�r�r�r�r�r�r�rnr�r�s               rVrqzSyntax.__init__s���$��	�������(���$���$���.�7�#�%���$��� ��
�"��� 0���/?�E�*�+�U�W�	
��+�������n�n�U�+���=?��rYzutf-8�path�encodingc��t|�j|��}|s|j||��}|||||||||	|
|||
||��S)aConstruct a Syntax object from a file.

        Args:
            path (str): Path to file to highlight.
            encoding (str): Encoding of file.
            lexer (str | Lexer, optional): Lexer to use. If None, lexer will be auto-detected from path/file content.
            theme (str, optional): Color theme, aka Pygments style (see https://pygments.org/docs/styles/#getting-a-list-of-available-styles). Defaults to "emacs".
            dedent (bool, optional): Enable stripping of initial whitespace. Defaults to True.
            line_numbers (bool, optional): Enable rendering of line numbers. Defaults to False.
            start_line (int, optional): Starting number for line numbers. Defaults to 1.
            line_range (Tuple[int, int], optional): If given should be a tuple of the start and end line to render.
            highlight_lines (Set[int]): A set of line numbers to highlight.
            code_width: Width of code to render (not including line numbers), or ``None`` to use all available width.
            tab_size (int, optional): Size of tabs. Defaults to 4.
            word_wrap (bool, optional): Enable word wrapping of code.
            background_color (str, optional): Optional background color, or None to use theme color. Defaults to None.
            indent_guides (bool, optional): Show indent guides. Defaults to False.
            padding (PaddingDimensions): Padding to apply around the syntax. Defaults to 0 (no padding).

        Returns:
            [Syntax]: A Syntax object that may be printed to the console
        )r�)r�)rer�r�r�r�r�r�r�r�rnr�r�)r�	read_text�guess_lexer)r�r�r�r�rer�r�r�r�r�r�r�r�rnr�r�r�s                 rV�	from_pathzSyntax.from_path-sh��R�D�z�#�#�X�#�6����O�O�D�t�O�4�E������%�!�!�+�!���-�'��
�	
rYc�`�d}d}|r
	t||�}|sO	tjj	|�\}}|r*|jd�j
�}t|�}|r)|jr|jd}|S|j}|S#t$rY��wxYw#t$rY�GwxYw)a�Guess the alias of the Pygments lexer to use based on a path and an optional string of code.
        If code is supplied, it will use a combination of the code and the filename to determine the
        best lexer to use. For example, if the file is ``index.html`` and the file contains Django
        templating syntax, then "html+django" will be returned. If the file is ``index.html``, and no
        templating language is used, the "html" lexer will be used. If no string of code
        is supplied, the lexer will be chosen based on the file extension..

        Args:
             path (AnyStr): The path to the file containing the code you wish to know the lexer for.
             code (str, optional): Optional string of code that will be used as a fallback if no lexer
                is found for the supplied path.

        Returns:
            str: The name of the Pygments lexer that best matches the supplied path/code.
        Nrg�.r)
rr �osr��splitext�lstrip�lowerr�aliasesr�)r�r�r�r��
lexer_name�_�ext�	extensions        rVr�zSyntax.guess_lexerls���""&���
��
�0��t�<���
����)�)�$�/���3�� #�
�
�3�� 5� 5� 7�I�-�i�8�E���}�}�"�]�]�1�-�
���#�Z�Z�
����%!�
��
��!�
��
�s#�B�AB!�	B�B�!	B-�,B-c�T�|jj�|jz}|S)zGet the base style.)r�r\r�)rU�
default_styles  rV�_get_base_stylezSyntax._get_base_style�s%�����8�8�:�T�=R�=R�R�
��rYrPc�P�|jj|�}|jS)z�Get a color (if any) for the given token.

        Args:
            token_type (TokenType): A token type tuple from Pygments.

        Returns:
            Optional[Color]: Color from theme, or None for no color.
        )r�rWr8)rUrPrys   rV�_get_token_colorzSyntax._get_token_color�s"�����/�/�
�;���{�{�rYc��t|jt�r|jS	t|jdd|j��S#t
$rYywxYw)z�The lexer for this syntax, or None if no lexer was found.

        Tries to find the lexer by name if a string was passed to the constructor.
        FT��stripnl�ensurenl�tabsizeN)rkr�rrr�r r[s rVr�zSyntax.lexer�sV���d�k�k�5�)��;�;��	�$�������
�
�	�
���	��	�s�"A�	A�Ac�4�tddd|j��S)z;A Pygments Lexer to use if one is not specified or invalid.�textFTr�)rr�r[s rV�
default_lexerzSyntax.default_lexer�s!��!�����M�M�	
�	
rYc������	�
��|j�}|jrdnd}t|||j|j��}|j
j�|jxs|j���|j��n�|rg|\�
�	dttttff��fd��dtttttff��	�
�fd�}|j!|��n)|j!�fd��j#��D��|j$�|j'd|j$���|j(r|j+|�|S)	aHighlight code and return a Text instance.

        Args:
            code (str): Code to highlight.
            line_range(Tuple[int, int], optional): Optional line range to highlight.

        Returns:
            Text: A text instance containing highlighted syntax.
        rg�left)�justifyryr��no_wraprQc3��K��sJ��j��D])\}}|s�	|jd�\}}}|||zf��|r�!�+y�w)zSplit tokens to one per line.�
N)�
get_tokens�	partition)rPr��
line_token�new_liner�r�s    ��rV�
line_tokenizez'Syntax.highlight.<locals>.line_tokenize�s\����� �L�5�-2�-=�-=�d�-C�D�)�
�E�#�:?�/�/�$�:O�7�J��%�",�j�8�.C�"C�C�$�D�s�A� A�Ac3�<�K�t�	��}d}�r�dz
nd}||kr1	t|�\}}|df��|jd�r|dz
}||kr�1|D]2\}}|�|�f��|jd�s�$|dz
}�s�,|�k\s�2yy#t$rY�CwxYw�w)zConvert tokens to spans.rr$Nr�)�iter�next�
StopIteration�endswith)
�tokens�line_no�_line_start�_token_typer�rP�_get_theme_style�line_end�
line_startr�s
      ����rV�tokens_to_spansz)Syntax.highlight.<locals>.tokens_to_spans�s������!�-�/�2�F��G�4>�*�q�.�A�K�"�K�/�"�15�f��.�K�� %�d�m�+� �>�>�$�/�#�q�L�G�"�K�/�.4�&�)�
�E�$�&6�z�&B�C�C� �>�>�$�/�#�q�L�G�'�G�x�,?� %�&��
 -�"�!�"�s?�!B�B
�!B�%B�;B�B�	B�
	B�B�B�Bc3�8�K�|]\}}|�|�f���y�wr{rb)�.0rPr�r�s   �rV�	<genexpr>z#Syntax.highlight.<locals>.<genexpr>
s(�����#�)�
�E��,�Z�8�9�#�s�zon )r��transparent_backgroundr3r�r�r�rWr�r��appendrrrrlrr�
append_tokensr�rn�stylizer��_apply_stylized_ranges)rUr�r��
base_styler�r�r�r�r�r�r�r�s `     @@@@@rV�	highlightzSyntax.highlight�sL����)�)�+�
�#�:�:�I��	�����]�]����&�	
�� �;�;�:�:���
�
�0�d�0�0���=��K�K����(2�$�
�H�D�x��c�3�h��'@�D�&��%��X�e�_�8L�2M�)N�&�&�.�"�"�?�#4�5��"�"�#�-2�-=�-=�d�-C�#���$�$�0����s�4�#8�#8�"9�:�;�� � ��'�'��-��rYryr�r�c�P�|jjt|||��y)a�
        Adds a custom style on a part of the code, that will be applied to the syntax display when it's rendered.
        Line numbers are 1-based, while column indexes are 0-based.

        Args:
            style (StyleType): The style to apply.
            start (Tuple[int, int]): The start of the range, in the form `[line number, column index]`.
            end (Tuple[int, int]): The end of the range, in the form `[line number, column index]`.
        N)r�r�r�)rUryr�r�s    rV�
stylize_rangezSyntax.stylize_ranges"��	
���$�$�%:�5�%��%M�NrY�blendc��|jj�|jz}|j}|�|jrtj�S|jtj�}|�|jr|xstj�St|j�|j�|��}tj|�S)N)�
cross_fade)
r�r\r�ri�is_system_definedr(rgr�rr3r)�
get_truecolor�from_triplet)rUr�r�rn�foreground_color�	new_colors      rV�_get_line_numbers_colorzSyntax._get_line_numbers_color's����;�;�;�;�=��@U�@U�U��+�3�3���#�'7�'I�'I��=�=�?�"��0�0����<���#�'7�'I�'I�#�6�u�}�}��6���*�*�,��*�*�,��
�	�
�!�!�)�,�,rYc��d}|jrAtt|j|jjd�z��tz}|S)z?Get the number of characters used to render the numbers column.rr�)r��lenrlr�r��count�NUMBERS_COLUMN_DEFAULT_PADDING)rU�column_widths  rV�_numbers_column_widthzSyntax._numbers_column_width6sJ��������C����$�)�)�/�/�$�*?�?�@�A�0�1�
��rY�consolec
��|j�}|jr3tj�td��tj�fS|jdvr�tj
||jjtj�t|j���|j�}tj
||jjtj�td|jd���|j�}n|td��z}|td��z}|||fS)z>Get background, number, and highlight styles for line numbers.Tr9)�256�	truecolorr7g�������?)r@r8F)r�r�rrw�color_system�chainr�rWrr3r�r�)rUr�r��number_style�highlight_number_styles     rV�_get_number_styleszSyntax._get_number_stylesAs����/�/�1���2�2��:�:�<��4��%�*�*�,�>�>����#7�7� �;�;� ����/�/��
�
�;��D�8�8�:�;��%�%�	�L�&+�[�[� ����/�/��
�
�;��4�t�'C�'C�C�'H�I��%�%�	&�"�,�e��o�=�L�%5��%�8H�%H�"���/E�E�ErY�optionsc��tj|j�\}}}}||z}|j�5|j|jz|zdz}t|j|�S|jj�}|j|z|rtd�|D��ndz}|jr|dz
}t|j|�S)Nr$c3�2K�|]}t|����y�wr{r&)r��lines  rVr�z*Syntax.__rich_measure__.<locals>.<genexpr>ds����4�d�8�D�>�4�s�r)
r"�unpackr�r�r�r/r��
splitlines�maxr�)	rUr�rr��rightr�r��width�liness	         rV�__rich_measure__zSyntax.__rich_measure__Xs���$�N�N�4�<�<�8���5�!�T���,���?�?�&��O�O�d�&@�&@�@�7�J�Q�N�E��t�9�9�5�A�A��	�	�$�$�&���&�&��
�8=�s�4�e�4�4�1�
F�	�
����Q�J�E��4�5�5�u�=�=rYc#��K�t|j||��}|jr3t||jj�|j����y|��y�w)N�ry�pad)r1�_get_syntaxr�r"r�r\)rUr�r�segmentss    rV�__rich_console__zSyntax.__rich_console__jsR�����D�,�,�W�g�>�?���<�<������ @� @� B�����
��N�s�A A"c#�|	K�|j�j}|j�4|jr|j|j
z
dz
n|jn|j}|j
|j�\}}|j||j�}|j�s/|j�s"|j�s|s|jd�|j�|jjt�ztd��z|j z}|j"r0|j$s$|j'|j(|��}d|_|jr,|j-||j/|���	�Ed{���y|j1||j/|dd
��|j dd��}	|	D]}
|
Ed{����y|jxsd
\}}d}
|rt3d|dz
�}
|j5d|��}|jr|
t7|�kDry||
|}|j"r�|j$s�|j�|jjt�ztd��z|j z}t9d�j;|�j'|j(|td��z��j5dd��}|j
}|j/|��}|j<j>}t@}|d�}|jBrdnd}|jE|�\}}}tG||jH|
z�D�]@\}}|jr(|j1||j/dd
��||��}nMtK|j-|d���}|jLr|g}n!|jO||j||��g}|jr�|d|zdz|�}tQ|�D]y\}}|r`tS|�jU|dz
�dz}||�r!||td�����|||���n|d|���|||���n|��|Ed{���|���{��,|D]}|Ed{���|�����Cy7��7���7�+7��w)zc
        Get the Segments for the Syntax object, excluding any vertical/horizontal padding
        Nr$r�Tr9)ry�crop)r)rr�)r�heightr�)ryr�	new_lines)NNr)�allow_blankF)rtz> u❱ )rr�r�)r�� rMrAr7z  )+r�r�r�r��	max_widthr��
_process_coder�r�r�r��
remove_suffixr�rWrrr�r��
ascii_only�with_indent_guidesr��overflow�render�update�render_linesr�splitr�r3�joinr��__contains__r0�legacy_windowsr�	enumerater��listr��adjust_line_lengthr%rl�rjust) rUr�rr�r��
ends_on_nl�processed_coder�ry�syntax_lines�syntax_liner��end_line�line_offsetr�numbers_column_width�render_options�highlight_line�_Segmentr��line_pointerr�rrr�r	�
wrapped_linesr�wrapped_line_left_pad�first�wrapped_line�line_columns                                 rVrzSyntax._get_syntaxus�����"&�!5�!5�!7�!N�!N�����&��$�$��"�"�T�%?�%?�?�!�C��&�&����	�&*�%7�%7��	�	�%B�"�
�N��~�~�n�d�o�o�>��� � ���������"�"�4�(��$�$�&��+�+�1�1�'�:�;��D�/�"��'�'�(�
��!�!�'�*<�*<��.�.�t�}�}�E�.�J�� &��
��+�+�"�>�>��'�.�.�z�.�"B�*����
� '�3�3���N�N��D�&�N�Q��/�/��"� 4� ��$0�+�K�*�*�*�+��#���>�,��
�H�����a��a��0�K�*.�*�*�T�z�*�*R���?�?��S��Z�'���+�h�/�E����g�&8�&8��$�$�&��+�+�1�1�'�:�;��D�/�"��'�'�(�
��T�
���e��#�#�D�M�M���e�AT�9T�#�U���t���.�	
� $�9�9�� ���j��9���-�-�:�:�����D�>��&�5�5�t�6��
�#�#�G�,�		
���"�'�u�d�o�o��.K�L�*	#�M�G�T��~�~� '� 4� 4��"�)�)��v�)�F�*�2�2�	!5�!�
� ����G��� <�=���?�?�%-�J�M�!�3�3�$�*�4�4�"2�$:� :�	4��%�M�� � �(0��.�.��4�6F�)�%�,6�m�+D�#�'�E�<��&)�'�l�&8�&8�9M�PQ�9Q�&R�UX�&X��)�'�2�"*�<��U�9K�"L�L�"*�;�8N�"O�O�"*�4�1G�"H�H�"*�;��"E�E�3�3�+�+�+�"�N�#�%2�#�L�+�+�+�"�N�#�Q*	#�m��+��^,��,�sJ�FR<�R2�AR<�R5�J4R<�R8�
R<�#R:�$R<�5R<�8R<�:R<r�c��|j}dgtjd|tj��D�cgc]}|j	�dz��c}�t|�dz�}|jD]Q}t||j�}t||j�}|��2|��5|j|j||��Sycc}w)z�
        Apply stylized ranges to a text instance,
        using the given code to determine the right portion to apply the style to.

        Args:
            text (Text): Text instance to apply the style to.
        rr�)�flagsr$N)�plain�re�finditer�	MULTILINEr�r�r��#_get_code_index_for_syntax_positionr�r�ry)rUr�r��match�newlines_offsets�stylized_ranger�r�s        rVr�zSyntax._apply_stylized_ranges�s����z�z��
�	
� �[�[��t�2�<�<�H������
��!��		
�
��I��M�	
��#�3�3�	?�N�7� �.�"6�"6��E�6� �.�"4�"4��C�� �S�_����^�1�1�5�#�>�	?��s�Cc��|jd�}|r|n|dz}|jrtj|�n|}|j|j�}||fS)a�
        Applies various processing to a raw code string
        (normalises it so it always ends with a line return, dedents it if necessary, etc.)

        Args:
            code (str): The raw code string to process

        Returns:
            Tuple[bool, str]: the boolean indicates whether the raw code ends with a line return,
                while the string is the processed code.
        r�)r�r��textwrap�
expandtabsr�)rUr�r/r0s    rVrzSyntax._process_codesY���]�]�4�(�
�!+������/3�{�{�H�O�O�N�+��	�(�2�2�4�=�=�A���>�)�)rYr{)g333333�?)r�r*rr+rQr/)2r]r^r_r`rr~r�rO�classmethodrrlr��
DEFAULT_THEMEr�bool�intrrr
r#rqr�r�rr�rar(r��propertyr�r�r3r�r2r�r��floatr�r�r*rrr+r-rrr0rr�rrbrYrVr�r��sA���( �
�.�.����	�U�3��#3�4�	��	��	� *7��"��DH�.2�$(���*.�#�%&�!$@��$@��U�C�Z� �$@�
�S�+�%�&�$@��
$@��$@��$@��U�8�C�=�(�3�-�#?�@�A�$@�"�#�c�(�+�$@��S�M�$@��$@��$@�#�3�-�$@��$@� #�!$@�"
�#$@�L� �-1�)6��"�04��.2�$(���*.�#�%&�!<
��<
��<
���e�S�j�)�*�	<
�
�S�+�%�&�<
��
<
��<
��U�3��8�_�-�<
��<
�"�#�c�(�+�<
��S�M�<
��<
��<
�#�3�-�<
��<
� #�!<
�"
�#<
��<
�|�'�s�'�(�3�-�'�3�'��'�R���

�9�
��%��
���x������$�
�u�
��
�EI�S��S��U�8�C�=�(�3�-�#?�@�A�S�
�	S�jO��O�'5�O�<J�O�	
�O�
-�U�
-�U�
-���s����F�'�F�e�E�5�%�<O�6P�F�.>� �>�+;�>�	�>�$	��	�)7�	�	�	�D#��D#� �D#�
�'�	�	D#�L?�4�?�D�?�<*�#�*�%��c�	�*:�*rYr�rG�positionrQc��t|�}|\}}||kDst|�|dzkry|dz
}||dz||z
dz
}t||�}|||zS)a
    Returns the index of the code string for the given positions.

    Args:
        newlines_offsets (Sequence[int]): The offset of each newline character found in the code snippet.
        position (SyntaxPosition): The position to search for.

    Returns:
        Optional[int]: The index of the code string for this position, or `None`
            if the given position's line number is out of range (if it's the column that is out of range
            we silently clamp its value so that it reaches the end of the line)
    r$N)r��min)rGrR�lines_count�line_number�column_index�
line_index�line_lengths       rVrErE.sy���&�'�K� (��K���[� �C�(8�$9�[�1�_�$M���q��J�"�:��>�2�5E�j�5Q�Q�TU�U�K��{�L�1�L��J�'�,�6�6rY�__main__z&Render syntax to the console with Rich)�descriptionr��PATHzpath to file, or - for stdin)�metavar�helpz-cz
--force-color�force_color�
store_truezforce color for non-terminals)�dest�actionrgr^z-iz--indent-guidesr�Fzdisplay indent guidesz-lz--line-numbersr�zrender line numbers)rarbr^z-wz--widthrz*width of output (default will auto-detect))�typerargr^z-rz--wrapr�zword wrap long linesz-sz--soft-wrap�	soft_wrapzenable soft wrapping mode)rbrargr^z-tz--themerezpygments theme)rargr^z-bz--background-colorrnzOverride background colorz-xz--lexerr�z
Lexer name)rgrar^z-pz	--paddingr�r")rcrgrar^z--highlight-liner7z)The line number (not index!) to highlight)r*)�force_terminalr�-)	r�r�r�r�rernr�r�r�)r�r�r�rernr�r�r�)rd)��os.pathr��platformrB�sysrJ�abcrr�pathlibr�typingrrrr	r
rrr
rrr�pygments.lexerr�pygments.lexersrr�pygments.stylerr~�pygments.stylesr�pygments.tokenrrrrrrrrrr�
pygments.utilr �rich.containersr!�rich.paddingr"r#�_loopr%�cellsr'r8r(r)r�r*r+r,r-�jupyterr.�measurer/�segmentr0r1ryr2r�r3rlra�system�WINDOWSrM�Preproc�Word�Builtin�Function�	Namespace�Class�	Exception�	Decorator�Variable�Constant�	Attribute�Tag�Deleted�Inserted�Heading�
Subheading�PromptrEr�rJr�r�rOrdr�rOr�r�r�rEr]�argparse�ArgumentParser�parser�add_argument�
parse_args�args�rich.consoler_rr��stdin�readr�r�r�r�rernr�r�r7�syntaxr��printrdrbrYrV�<module>r�s�����	�
��#������!�G�1�-����(�!�3���#�I�I�!� �&�#���#�s�(�O�	�
�(�/�/�
�y�
(���
�
&�	�5�7�&���G�$�&��U�t�_�&��O�O�U��(�	&�
�U��
 �&��L�L�%�f�%�
&�
�M�M�5�y�)�&�	�L�L�%�f�%�&�	�M�M�5�w�'�&�	�N�N�E��$�7�&�	�J�J��G�t�4�&�	�N�N�E��'�&�	�N�N�E�	��5�&�	�M�M�5�u�%�&�	�M�M�5�u�%�&� 	�N�N�E��'�!&�"	�H�H�e�-�(�#&�$�E��!�
�E����O�O�U��.����e�'�*��O�O�U��%�����I�D�9��N�N�E�t�$��M�M�5�|�,�	�5�u��-�5&�
�D��E�!�"��:%�	�5�7�%���N�+�%��U�t�_�%��O�O�U��/�	%�
�U��
'�%��L�L�%�m�,�
%�
�M�M�5�/�0�%�	�L�L�%�m�,�%�	�M�M�5�~�.�%�	�N�N�E�
��>�%�	�J�J��N�d�;�%�	�N�N�E�
�.�%�	�N�N�E� 0�t�<�%�	�M�M�5�|�,�%�	�M�M�5�|�,�%� 	�N�N�E�
�.�!%�"	�H�H�e�-�(�#%�$�E��!�
�E�
�&��O�O�U��.����e�.�1��O�O�U��%�����$4�4�@��N�N�E�t�$��M�M�5�|�,�	�5�u��-�5%�	�4�	�5� �!��:%/�Y�G��!"��"�#�"�'&�+�'&�T&�k�&�B�s�C�x���	�J�	�H	*�\�H	*�V7��s�m�7�/=�7�
�c�]�7�6�z����
$�X�
$�
$�<��F������
+���
�����
���
,�
�������
���
$�
�������
��
"��������
�
��
9�
�������
���
#�
��������
��
(�
������i�g�y�?O��������
��
(���������
�
�������k��Q�Y�Y�������
��
�
8�������D�$��T�%5�%5�T�Z�Z�H�G��y�y�C���y�y�~�~������/�/��*�*��n�n��*�*�!�2�2��,�,��L�L�!�0�0�1�

���!�!��I�I��/�/��*�*��n�n��*�*�!�2�2��,�,��L�L�!�0�0�1�"�

���M�M�&�D�N�N�M�3�krY

Zerion Mini Shell 1.0