HEX
Server: Apache
System: Linux srv1.prosuiteplus.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: prosuiteplus (1001)
PHP: 8.3.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/pygments/formatters/__pycache__/terminal256.cpython-38.pyc
U

`a�[*�@sjdZddlZddlmZddlmZddlmZddgZGdd	�d	�Z	Gd
d�de�Z
Gdd�de
�ZdS)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-2017 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
�N)�	Formatter)�codes)�
ansicolors�Terminal256Formatter�TerminalTrueColorFormatterc@s6eZdZd
dd�Zdd�Zdd�Zd	d
�Zdd�ZdS)�EscapeSequenceNFcCs||_||_||_||_dS�N)�fg�bg�bold�	underline)�selfr	r
rr�r�A/usr/lib/python3/dist-packages/pygments/formatters/terminal256.py�__init__&szEscapeSequence.__init__cCst|�rdd�|�dSdS)Nz[�;�m�)�len�join�r
�attrsrrr�escape,szEscapeSequence.escapecCs�g}|jdk	rb|jtkrLt|jdd�}d|kr8d|_|�|dd��n|�ddd|jf�|jdk	r�|jtkr�t|jdd�}|�tt|dd��d	��n|�d
dd|jf�|jr�|�d�|j	r�|�d�|�
|�S)
N�z;01mT���38�5z%i�
�48�01�04)r	rrr�append�extendr
�str�intrr)r
rZescrrr�color_string1s$



 

zEscapeSequence.color_stringc	Cs�g}|jr<|�ddt|jd�t|jd�t|jd�f�|jrt|�ddt|jd�t|jd�t|jd�f�|jr�|�d�|jr�|�d�|�|�S)	Nr�2r�rrr r!)r	r#r$r
rr"rrrrrr�true_color_stringIs22

z EscapeSequence.true_color_stringcCsLg}|jdk	r|�d�|jdk	r,|�d�|js8|jrB|�d�|�|�S)NZ39Z49Z00)r	r"r
rrrrrrr�reset_stringUs




zEscapeSequence.reset_string)NNFF)�__name__�
__module__�__qualname__rrr&r)r*rrrrr%s

rc@sZeZdZdZdZdddgZgZdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dS)raO
    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.

    Options accepted:

    `style`
        The style to use, can be a string or a Style subclass (default:
        ``'default'``).
    ZTerminal256Zterminal256Z
console256Z256cKsHtj|f|�g|_i|_i|_d|k|_d|k|_|��|��dS)NZnoboldZnounderline)	rr�xterm_colors�
best_match�style_string�usebold�useunderline�_build_color_table�
_setup_styles)r
Zoptionsrrrr{s

zTerminal256Formatter.__init__cCsD|j�d�|j�d�|j�d�|j�d�|j�d�|j�d�|j�d�|j�d�|j�d	�|j�d
�|j�d�|j�d�|j�d
�|j�d�|j�d�|j�d�d}td�D]B}||dd}||dd}||d}|j�|||f�q�tdd�D]$}d|d}|j�|||f��qdS)N)rrr)��rr)rr5r)r5r5r)rr��)r5rr5)rr5r5)��r7r7)�r8r8)�rr)rr9r)r9r9r)�\r:r9)r9rr9)rr9r9)r9r9r9)r�_����r9���$�r(��r)r.r"�range)r
Z
valuerange�i�r�g�b�vrrrr3�s2z'Terminal256Formatter._build_color_tablecCsrd}d}tdd�D]Z}|j|}||d}||d}	||d}
|||	|	|
|
}||kr|}|}q|S)Nir�r(r)rDr.)r
rFrGrHZdistance�matchrE�valuesZrdZgdZbd�drrr�_closest_color�s
z#Terminal256Formatter._closest_colorcCs�|j�|d�}|tkr$|}||j|<|dkr�ztt|�d�}Wntk
rVd}YnX|d?d@}|d?d@}|d@}|�|||�}||j|<|S)N�rr9rC)r/�getrr%r$�
ValueErrorrN)r
�color�index�rgbrFrGrHrrr�_color_index�s


z!Terminal256Formatter._color_indexcCs�|jD]�\}}t�}|dr.|�|d�|_n|drF|�|d�|_|dr`|�|d�|_n|drx|�|d�|_|jr�|dr�d|_|jr�|dr�d|_|�	�|�
�f|jt|�<qdS)NZ	ansicolorrRZbgansicolor�bgcolorrTr)
�stylerrUr	r
r1rr2rr&r*r0r$�r
�ttypeZndefrrrrr4�s"�z"Terminal256Formatter._setup_stylescCsB|js4t|d�r4t|d�r4|��r4tjdkr4|j|_t�|||�S)N�encoding�isatty)�)rZ�hasattrr[�sys�version_infor�format)r
�tokensource�outfilerrrr`�s���zTerminal256Formatter.formatc
	Cs�|D]�\}}d}|r�|r�zt|jt|�\}}|�d�}|dd�D]$}	|	r\|�||	|�|�d�qB|dr�|�||d|�d}Wqtk
r�|dd�}YqXq|r|�|�qdS)NT�
���F)r0r$�split�write�KeyError)
r
rarbrY�valueZ	not_foundZonZoffZspl�linerrr�format_unencoded�s"
z%Terminal256Formatter.format_unencodedN)r+r,r-�__doc__�name�aliases�	filenamesrr3rNrUr4r`rjrrrrr`s

$	c@s:eZdZdZdZdddgZgZdd�Zdd	�Zd
d�Z	dS)
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'``).
    ZTerminalTrueColorZterminal16mZ
console16mZ16mcCsdSrr)r
rrrr3sz-TerminalTrueColorFormatter._build_color_tablecCsTztt|�d�}Wntk
r(YdSX|d?d@}|d?d@}|d@}|||fS)NrOr9rC)r%r$rQ)r
rRrTrFrGrHrrr�_color_tuplesz'TerminalTrueColorFormatter._color_tuplecCs�|jD]�\}}t�}|dr,|�|d�|_|drD|�|d�|_|jrX|drXd|_|jrl|drld|_|�	�|�
�f|jt|�<qdS)NrRrVrTr)
rWrror	r
r1rr2rr)r*r0r$rXrrrr4)s�z(TerminalTrueColorFormatter._setup_stylesN)
r+r,r-rkrlrmrnr3ror4rrrrr
s


)rkr^Zpygments.formatterrZpygments.consolerZpygments.styler�__all__rrrrrrr�<module>s;+