HOME


Mini Shell 1.0
DIR: /usr/lib/python3/dist-packages/pygments/formatters/__pycache__/
Upload File :
Current File : //usr/lib/python3/dist-packages/pygments/formatters/__pycache__/terminal256.cpython-312.pyc
�

|�e�-��t�dZddlmZddlmZddlmZddgZGd�d�ZGd	�de�Z	Gd
�de	�Z
y)a�
    pygments.formatters.terminal256
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Formatter for 256-color terminal output with ANSI sequences.

    RGB-to-XTERM color conversion routines adapted from xterm256-conv
    tool (http://frexx.de/xterm-256-notes/data/xterm256-conv2.tar.bz2)
    by Wolfgang Frisch.

    Formatter version 1.

    :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
�)�	Formatter)�codes)�
ansicolors�Terminal256Formatter�TerminalTrueColorFormatterc�,�eZdZdd�Zd�Zd�Zd�Zd�Zy)�EscapeSequenceNc�J�||_||_||_||_||_y�N)�fg�bg�bold�	underline�italic)�selfrr
rrrs      �A/usr/lib/python3/dist-packages/pygments/formatters/terminal256.py�__init__zEscapeSequence.__init__#s%����������	�"������c�H�t|�rddj|�zdzSy)Nz[�;�m�)�len�join�r�attrss  r�escapezEscapeSequence.escape*s$���u�:��S�X�X�e�_�,�s�2�2�rc	���g}|j�v|jtvrCt|jjdd�}d|vrd|_|j|dd�n!|j
ddd	|jzf�|j��|jtvrMt|jjdd�}|jtt|dd�d
z��n!|j
ddd	|jzf�|jr|jd�|jr|jd
�|jr|jd�|j|�S)N�ansirz;01mT���38�5z%i�
�48�01�04�03)
rrr�replacer�append�extendr
�str�intrrr)rr�escs   r�color_stringzEscapeSequence.color_string/s#�����7�7���w�w�*�$��D�G�G�O�O�F�2�6�7���S�=� $�D�I����S��1�X�&����d�C������8�9��7�7���w�w�*�$��D�G�G�O�O�F�2�6�7�����S��S��1�X��r�!1�2�3����d�C������8�9��9�9��L�L����>�>��L�L����;�;��L�L����{�{�5�!�!rc
�f�g}|jrX|jddt|jd�t|jd�t|jd�f�|jrX|jddt|jd�t|jd�t|jd�f�|jr|jd�|jr|jd�|jr|jd	�|j|�S)
Nr"�2r�r r%r&r'r()	rr+r,r
rr*rrrrs  r�true_color_stringz EscapeSequence.true_color_stringIs������7�7��L�L�$��S������_�c�$�'�'�!�*�o�s�4�7�7�ST�:��W�X��7�7��L�L�$��S������_�c�$�'�'�!�*�o�s�4�7�7�ST�:��W�X��9�9��L�L����>�>��L�L����;�;��L�L����{�{�5�!�!rc��g}|j�|jd�|j�|jd�|js|js|j
r|jd�|j
|�S)N�39�49�00)rr*r
rrrrrs  r�reset_stringzEscapeSequence.reset_stringWsa�����7�7���L�L����7�7���L�L����9�9����$�+�+��L�L����{�{�5�!�!r)NNFFF)�__name__�
__module__�__qualname__rrr/r3r8�rrr	r	"s����
"�4"�"rr	c�P�eZdZdZdZgd�ZgZd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zy)
ra�
    Format tokens with ANSI color sequences, for output in a 256-color
    terminal or console.  Like in `TerminalFormatter` color sequences
    are terminated at newlines, so that paging the output works correctly.

    The formatter takes colors from a style defined by the `style` option
    and converts them to nearest ANSI 256-color escape sequences. Bold and
    underline attributes from the style are preserved (and displayed).

    .. versionadded:: 0.9

    .. versionchanged:: 2.2
       If the used style defines foreground colors in the form ``#ansi*``, then
       `Terminal256Formatter` will map these to non extended foreground color.
       See :ref:`AnsiTerminalStyle` for more information.

    .. versionchanged:: 2.4
       The ANSI color names have been updated with names that are easier to
       understand and align with colornames of other projects and terminals.
       See :ref:`this table <new-ansi-color-names>` for more information.


    Options accepted:

    `style`
        The style to use, can be a string or a Style subclass (default:
        ``'default'``).

    `linenos`
        Set to ``True`` to have line numbers on the terminal output as well
        (default: ``False`` = no line numbers).
    �Terminal256)�terminal256�
console256�256c��tj|fi|��g|_i|_i|_d|v|_d|v|_d|v|_|j�|j�|jdd�|_d|_y)N�nobold�nounderline�noitalic�linenosFr)
rr�xterm_colors�
best_match�style_string�usebold�useunderline�	useitalic�_build_color_table�
_setup_styles�getrF�_lineno)r�optionss  rrzTerminal256Formatter.__init__�s������4�+�7�+�����������w�.���)��8���#�7�2������!������{�{�9�e�4�����rc�n�|jjd�|jjd�|jjd�|jjd�|jjd�|jjd�|jjd�|jjd�|jjd	�|jjd
�|jjd�|jjd�|jjd
�|jjd�|jjd�|jjd�d}td�D]>}||dzdz}||dzdz}||dz}|jj|||f��@tdd�D](}d|dzz}|jj|||f��*y)N)rrr)��rr)rrSr)rSrSr)rr��)rSrrS)rrSrS)��rUrU)�rVrV)�rr)rrWr)rWrWr)�\rXrW)rWrrW)rrWrW)rWrWrW)r�_����rW���$�r2��r$)rGr*�range)r�
valuerange�i�r�g�b�vs       rrMz'Terminal256Formatter._build_color_table�s���	
��� � �!3�4���� � �!3�4���� � �!3�4���� � �!3�4���� � �!3�4���� � �!3�4���� � �!3�4���� � �!3�4���� � �!3�4���� � �!3�4���� � �!3�4���� � �!3�4���� � �!3�4���� � �!3�4���� � �!3�4���� � �!3�4�:�
��s��	0�A��A��G�q�=�)�A��A��F�a�<�(�A��1�q�5�!�A����$�$�a��A�Y�/�		0��q�"��	0�A��A��F�
�A����$�$�a��A�Y�/�	0rc��d}d}tdd�D]D}|j|}||dz
}||dz
}	||dz
}
||z|	|	zz|
|
zz}||ks�A|}|}�F|S)Nir�r2r )rbrG)rrerfrg�distance�matchrd�values�rd�gd�bd�ds            r�_closest_colorz#Terminal256Formatter._closest_color�s��������q�#��
	�A��&�&�q�)�F��V�A�Y��B��V�A�Y��B��V�A�Y��B��2���2��
��2��%�A��8�|�����
	��rc�0�|jj|d�}|tvr|}||j|<|�M	tt	|�d�}|dz	dz}|dz	dz}|dz}|j
|||�}||j|<|S#t
$rd}Y�FwxYw)N�rrWra)rHrOrr-r,�
ValueErrorrr)r�color�index�rgbrerfrgs       r�_color_indexz!Terminal256Formatter._color_index�s������#�#�E�4�0���J���E�%*�D�O�O�E�"��=�
��#�e�*�b�)�����d�"�A����T�!�A��d�
�A��'�'��1�a�0�E�%*�D�O�O�E�"�����
���
�s�B�B�Bc�4�|jD�]\}}t�}|dr|j|d�|_n|dr|j|d�|_|dr|j|d�|_n|dr|j|d�|_|j
r|drd|_|jr|drd|_|jr|drd|_
|j�|j�f|jt|�<��y)	N�	ansicolorrv�bgansicolor�bgcolorrTrr)�styler	ryrr
rJrrKrrLrr/r8rIr,�r�ttype�ndefrs    rrNz"Terminal256Formatter._setup_styles�s
���:�:�	D�K�E�4�#�%�F��K� � �-�-�d�;�.?�@��	��g�� �-�-�d�7�m�<��	��M�"� �-�-�d�=�.A�B��	��i�� �-�-�d�9�o�>��	��|�|��V��"���� � �T�+�%6�#'�� ��~�~�$�x�.� $��
�-3�-@�-@�-B�-3�-@�-@�-B�-D�D���c�%�j�)�#	Drc��|xjdz
c_|jd|jdk7xrdxsd|jfz�y)Nr2z%s%04d: �
r)rP�write)r�outfiles  r�
_write_linenoz"Terminal256Formatter._write_lineno�s=���������
�
�j�D�L�L�A�$5�$>�$�$D�"�d�l�l�#S�S�Trc�0�tj|||�Sr)r�format)r�tokensourcer�s   rr�zTerminal256Formatter.format�s������k�7�;�;rc�B�|jr|j|�|D]�\}}d}|r�|r�	|jt|�\}}|j	d�}|ddD]J}	|	r|j||	z|z�|jr|j|��:|jd��L|dr|j||dz|z�d}|r|r��|s��|j|���|jr|jd�yy#t$r|j}Y�QwxYw)NTr����F)rFr�rIr,�splitr��KeyError�parent)
rr�r�r��value�	not_found�on�off�spl�lines
          r�format_unencodedz%Terminal256Formatter.format_unencoded�s"���<�<����w�'�'�	%�L�E�5��I��I�)�"�/�/��E�
�;�G�B�� �+�+�d�+�C� #�C�R��0���#�M�M�"�t�)�c�/�:��<�<� �.�.�w�7�#�M�M�$�/�
0��2�w��
�
�b�3�r�7�l�S�&8�9� %�I�'�I�6��
�
�e�$�=	%�@�<�<��M�M�$���� �)�!�L�L�E�)�s�BD�D�DN)r9r:r;�__doc__�name�aliases�	filenamesrrMrrryrNr�r�r�r<rrrrbsD���@�D�2�G��I��""0�H�"�&D�*U�<�% rc�2�eZdZdZdZgd�ZgZd�Zd�Zd�Z	y)ra}
    Format tokens with ANSI color sequences, for output in a true-color
    terminal or console.  Like in `TerminalFormatter` color sequences
    are terminated at newlines, so that paging the output works correctly.

    .. versionadded:: 2.1

    Options accepted:

    `style`
        The style to use, can be a string or a Style subclass (default:
        ``'default'``).
    �TerminalTrueColor)�terminal16m�
console16m�16mc��yrr<)rs rrMz-TerminalTrueColorFormatter._build_color_table7s��rc��	tt|�d�}|dz	dz}|dz	dz}|dz}|||fS#t$rYywxYw)NrtrWra)r-r,ru)rrvrxrerfrgs      r�_color_tuplez'TerminalTrueColorFormatter._color_tuple:s^��	��c�%�j�"�%�C��B�Y�$���
�A�X�����$�J���1�a�y����	��	�s�1�	=�=c��|jD]�\}}t�}|dr|j|d�|_|dr|j|d�|_|j
r|drd|_|jr|drd|_|jr|drd|_
|j�|j�f|jt|�<��y)Nrvr}rTrr)r~r	r�rr
rJrrKrrLrr3r8rIr,rs    rrNz(TerminalTrueColorFormatter._setup_stylesDs����:�:�
	D�K�E�4�#�%�F��G�}� �-�-�d�7�m�<��	��I�� �-�-�d�9�o�>��	��|�|��V��"���� � �T�+�%6�#'�� ��~�~�$�x�.� $��
�-3�-E�-E�-G�-3�-@�-@�-B�-D�D���c�%�j�)�
	DrN)
r9r:r;r�r�r�r�rMr�rNr<rrrr%s(����D�2�G��I�
��DrN)r��pygments.formatterr�pygments.consoler�pygments.styler�__all__r	rrr<rr�<module>r�sK���2)�"�%�"�#?�
@��="�="�@ �9� �F-D�!5�-Dr