+
    TBi-                     v    R t ^ RIHt ^ RIHt ^ RIHt RR.t ! R R4      t ! R R]4      t	 ! R	 R]	4      t
R
# )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-2025 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
)	Formatter)codes)
ansicolorsTerminal256FormatterTerminalTrueColorFormatterc                   B   a  ] tR t^"t o RR ltR tR tR tR tRt	V t
R# )	EscapeSequenceNc                B    Wn         W n        W0n        W@n        WPn        R # N)fgbgbold	underlineitalic)selfr   r   r   r   r   s   &&&&&&D/usr/lib/python3.14/site-packages/pygments/formatters/terminal256.py__init__EscapeSequence.__init__#   s    	"    c                f    \        V4      '       d    R RP                  V4      ,           R,           # R# )z[;m )lenjoinr   attrss   &&r   escapeEscapeSequence.escape*   s&    u::SXXe_,s22r   c                h   . pV P                   e   V P                   \        9   dO   \        V P                   P                  RR4      ,          pRV9   d   RV n        VP                  VR,          4       M%VP                  RRRV P                   ,          34       V P                  e   V P                  \        9   dZ   \        V P                  P                  RR4      ,          pVP                  \        \        VR,          4      ^
,           4      4       M%VP                  R	RRV P                  ,          34       V P                  '       d   VP                  R
4       V P                  '       d   VP                  R4       V P                  '       d   VP                  R4       V P                  V4      # )Nansir   z;01mT:      N385z%i48010403)r   r   r   replacer   appendextendr   strintr   r   r   )r   r   escs   &  r   color_stringEscapeSequence.color_string/   s%   77ww*$DGGOOF267S= $DISX&dC8977ww*$DGGOOF267SSXr!123dC89999LL>>>LL;;;LL{{5!!r   c           
        . pV P                   '       de   VP                  R R\        V P                   ^ ,          4      \        V P                   ^,          4      \        V P                   ^,          4      34       V P                  '       de   VP                  RR\        V P                  ^ ,          4      \        V P                  ^,          4      \        V P                  ^,          4      34       V P                  '       d   VP                  R4       V P                  '       d   VP                  R4       V P                  '       d   VP                  R4       V P                  V4      # )r#   2r%   r&   r'   r(   )	r   r+   r,   r   r   r*   r   r   r   r   s   & r   true_color_string EscapeSequence.true_color_stringI   s    777LL$S_c$''!*os477ST:WX777LL$S_c$''!*os477ST:WX999LL>>>LL;;;LL{{5!!r   c                2   . pV P                   e   VP                  R4       V P                  e   VP                  R4       V P                  '       g%   V P                  '       g   V P
                  '       d   VP                  R4       V P                  V4      # )N394900)r   r*   r   r   r   r   r   r   s   & r   reset_stringEscapeSequence.reset_stringW   sg    77LL77LL999$+++LL{{5!!r   )r   r   r   r   r   )NNFFF)__name__
__module____qualname____firstlineno__r   r   r/   r3   r9   __static_attributes____classdictcell____classdict__s   @r   r   r   "   s#     
"4"" "r   r   c                   d   a  ] tR t^bt o RtRt. ROt. tR tR t	R t
R tR tR tR	 tR
 tRtV tR# )r   a  
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).
Terminal256c                   \         P                  ! V 3/ VB  . V n        / V n        / V n        R V9  V n        RV9  V n        RV9  V n        V P                  4        V P                  4        VP                  RR4      V n        ^ V n        R# )noboldnounderlinenoitaliclinenosFN)r   r   xterm_colors
best_matchstyle_stringusebolduseunderline	useitalic_build_color_table_setup_stylesgetrI   _lineno)r   optionss   &,r   r   Terminal256Formatter.__init__   s    4+7+w.)8#72!{{9e4r   c                   V P                   P                  R4       V P                   P                  R4       V P                   P                  R4       V P                   P                  R4       V P                   P                  R4       V P                   P                  R4       V P                   P                  R4       V P                   P                  R	4       V P                   P                  R
4       V P                   P                  R4       V P                   P                  R4       V P                   P                  R4       V P                   P                  R4       V P                   P                  R4       V P                   P                  R4       V P                   P                  R4       Rp\        ^4       F[  pW^$,          ^,          ,          pW^,          ^,          ,          pW^,          ,          pV P                   P                  W4V34       K]  	  \        ^^4       F0  p^V^
,          ,           pV P                   P                  WfV34       K2  	  R# )    N)rW   rW   rW   )   rW   rW   )rW   rX   rW   )rX   rX   rW   )rW   rW      )rX   rW   rX   )rW   rX   rX   )   rZ   rZ   )   r[   r[   )   rW   rW   )rW   r\   rW   )r\   r\   rW   )\   r]   r\   )r\   rW   r\   )rW   r\   r\   )r\   r\   r\   )rW   _            r\   )rJ   r*   range)r   
valuerangeirgbvs   &      r   rP   '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AGq=)AFa<(Aq5!A$$aAY/	  q"AAF
A$$aAY/ r   c                   Rp^ p\        ^ ^4       Fq  pV P                  V,          pW^ ,          ,
          pW'^,          ,
          p	W7^,          ,
          p
W,          W,          ,           W,          ,           pW8  g   Km  TpTpKs  	  V# )i  i )rb   rJ   )r   re   rf   rg   distancematchrd   valuesrdgdbdds   &&&&        r   _closest_color#Terminal256Formatter._closest_color   sw    q#A&&q)FAYBAYBAYB%A|  r   c                `   V P                   P                  VR 4      pV\        9   d   TpW P                   V&   Vf`    \        \	        V4      ^4      pV^,	          ^,          pV^,	          ^,          pV^,          pV P                  WEV4      pW P                   V&   V#   \
         d    ^ p LZi ; ir
   )rK   rR   r   r-   r,   
ValueErrorrr   )r   colorindexrgbre   rf   rg   s   &&     r   _color_index!Terminal256Formatter._color_index   s    ##E40JE%*OOE"=#e*b) d"AT!Ad
A''a0E%*OOE"  s   B B-,B-c                   V P                    EFp  w  r\        4       pVR ,          '       d   V P                  VR ,          4      Vn        M,VR,          '       d   V P                  VR,          4      Vn        VR,          '       d   V P                  VR,          4      Vn        M,VR,          '       d   V P                  VR,          4      Vn        V P
                  '       d   VR,          '       d   RVn        V P                  '       d   VR,          '       d   RVn        V P                  '       d   VR,          '       d   RVn
        VP                  4       VP                  4       3V P                  \        V4      &   EKs  	  R# )		ansicolorrv   bgansicolorbgcolorr   Tr   r   N)styler   ry   r   r   rM   r   rN   r   rO   r   r/   r9   rL   r,   r   ttypendefr   s   &   r   rQ   "Terminal256Formatter._setup_styles   s   ::KE#%FK   --d;.?@	g --d7m<	M"" --d=.AB	i --d9o>	|||V"   T+%6%6#' ~~~$x.. $-3-@-@-B-3-@-@-B-DDc%j)# &r   c                    V ;P                   ^,          un         TP                  RV P                   ^8g  ;'       d    R;'       g    RV P                   3,          4       R# )   z%s%04d: 
r   N)rS   write)r   outfiles   &&r   _write_lineno"Terminal256Formatter._write_lineno   sC    jDLLA$5$>$>$$D$D"dll#SSTr   c                0    \         P                  ! WV4      # r
   )r   format)r   tokensourcer   s   &&&r   r   Terminal256Formatter.format   s    7;;r   c                   V P                   '       d   V P                  V4       V EF  w  r4R pV'       d   V'       d    V P                  \        V4      ,          w  rgVP	                  R4      pVRR  F_  p	V	'       d   VP                  Wi,           V,           4       V P                   '       d   V P                  V4       KN  VP                  R4       Ka  	  VR,          '       d&   VP                  WhR,          ,           V,           4       RpK  V'       g   K  VP                  V4       EK  	  V P                   '       d   VP                  R4       R# R#   \         d    TP                  p EKB  i ; i)Tr   NF)rI   r   rL   r,   splitr   KeyErrorparent)
r   r   r   r   value	not_foundonoffspllines
   &&&       r   format_unencoded%Terminal256Formatter.format_unencoded   s   <<<w''LEII)"//E
;GB  ++d+C #CR#MM")c/:<<< ..w7#MM$/ !) 2wwbr7lS&89 %I ye$= (@ <<<MM$    )!LLE)s   A.E.AEE10E1)rS   rK   rI   rL   rM   rO   rN   rJ   N)terminal256
console256256)r;   r<   r=   r>   __doc__namealiases	filenamesr   rP   rr   ry   rQ   r   r   r   r?   r@   rA   s   @r   r   r   b   sL     @ D2GI""0H"&D*U<%  % r   c                   F   a  ] tR tRt o RtRt. R	Ot. tR tR t	R t
RtV tR# )
r   i%  aY  
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'``).
TerminalTrueColorc                    R # r
    )r   s   &r   rP   -TerminalTrueColorFormatter._build_color_table7  s    r   c                     \        \        V4      ^4      pT^,	          ^,          pT^,	          ^,          pT^,          pY4T3#   \         d     R# i ; i)   N)r-   r,   ru   )r   rv   rx   re   rf   rg   s   &&    r   _color_tuple'TerminalTrueColorFormatter._color_tuple:  s\    	c%j"%C BY$AX$Jay  		s   A AAc                T   V P                    EF  w  r\        4       pVR ,          '       d   V P                  VR ,          4      Vn        VR,          '       d   V P                  VR,          4      Vn        V P
                  '       d   VR,          '       d   RVn        V P                  '       d   VR,          '       d   RVn        V P                  '       d   VR,          '       d   RVn
        VP                  4       VP                  4       3V P                  \        V4      &   EK  	  R# )rv   r~   r   Tr   r   N)r   r   r   r   r   rM   r   rN   r   rO   r   r3   r9   rL   r,   r   s   &   r   rQ   (TerminalTrueColorFormatter._setup_stylesD  s    ::KE#%FG}} --d7m<	I --d9o>	|||V"   T+%6%6#' ~~~$x.. $-3-E-E-G-3-@-@-B-DDc%j) &r   r   N)terminal16m
console16m16m)r;   r<   r=   r>   r   r   r   r   rP   r   rQ   r?   r@   rA   s   @r   r   r   %  s1      D2GID Dr   N)r   pygments.formatterr   pygments.consoler   pygments.styler   __all__r   r   r   r   r   r   <module>r      sK   2 ) " % "#?
@=" ="@ 9  F-D!5 -Dr   