
    5h-                     t    S r SSKJr  SSKJr  SSKJr  SS/r " S S5      r " S	 S\5      r	 " S
 S\	5      r
g)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                   6    \ rS rSrS	S jrS rS rS rS rSr	g)
EscapeSequence"   Nc                 @    Xl         X l        X0l        X@l        XPl        g N)fgbgbold	underlineitalic)selfr   r   r   r   r   s         j/var/www/html/cementerio_25MayoBackend/env/lib/python3.13/site-packages/pygments/formatters/terminal256.py__init__EscapeSequence.__init__#   s    	"    c                 R    [        U5      (       a  SSR                  U5      -   S-   $ g)Nz[;m )lenjoinr   attrss     r   escapeEscapeSequence.escape*   s&    u::SXXe_,s22r   c           	          / nU R                   bz  U R                   [        ;   aE  [        U R                   R                  SS5         nSU;   a  SU l        UR                  USS 5        O!UR                  SSS	U R                   -  45        U R                  b  U R                  [        ;   aM  [        U R                  R                  SS5         nUR                  [        [        USS 5      S
-   5      5        O!UR                  SSS	U R                  -  45        U R                  (       a  UR                  S5        U R                  (       a  UR                  S5        U R                  (       a  UR                  S5        U R                  U5      $ )Nansir   z;01mT      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1X&dC8977ww*$DGGOOF267SS1Xr!123dC8999LL>>LL;;LL{{5!!r   c           
         / nU R                   (       aX  UR                  SS[        U R                   S   5      [        U R                   S   5      [        U R                   S   5      45        U R                  (       aX  UR                  SS[        U R                  S   5      [        U R                  S   5      [        U R                  S   5      45        U R                  (       a  UR                  S5        U R                  (       a  UR                  S5        U R                  (       a  UR                  S	5        U R                  U5      $ )
Nr%   2r      r#   r(   r)   r*   r+   )	r   r.   r/   r   r   r-   r   r   r   r   s     r   true_color_string EscapeSequence.true_color_stringI   s    77LL$S_c$''!*os477ST:WX77LL$S_c$''!*os477ST:WX99LL>>LL;;LL{{5!!r   c                 (   / nU R                   b  UR                  S5        U R                  b  UR                  S5        U R                  (       d"  U R                  (       d  U R
                  (       a  UR                  S5        U R                  U5      $ )N394900)r   r-   r   r   r   r   r   r   s     r   reset_stringEscapeSequence.reset_stringW   sa    77LL77LL99$++LL{{5!!r   )r   r   r   r   r   )NNFFF)
__name__
__module____qualname____firstlineno__r   r   r2   r7   r=   __static_attributes__ r   r   r	   r	   "   s    
"4""r   r	   c                   X    \ rS rSrSrSr/ SQr/ rS rS r	S r
S rS	 rS
 rS rS rSrg)r   b   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).
Terminal256)terminal256
console256256c                    [         R                  " U 40 UD6  / U l        0 U l        0 U l        SU;  U l        SU;  U l        SU;  U l        U R                  5         U R                  5         UR                  SS5      U l        SU l        g )NnoboldnounderlinenoitaliclinenosFr   )r   r   xterm_colors
best_matchstyle_stringusebolduseunderline	useitalic_build_color_table_setup_stylesgetrO   _lineno)r   optionss     r   r   Terminal256Formatter.__init__   s    4+7+w.)8#72!{{9e4r   c                 l   U R                   R                  S5        U R                   R                  S5        U R                   R                  S5        U R                   R                  S5        U R                   R                  S5        U R                   R                  S5        U R                   R                  S5        U R                   R                  S5        U R                   R                  S	5        U R                   R                  S
5        U R                   R                  S5        U R                   R                  S5        U R                   R                  S5        U R                   R                  S5        U R                   R                  S5        U R                   R                  S5        Sn[        S5       H;  nXS-  S-     nXS-  S-     nXS-     nU R                   R                  X4U45        M=     [        SS5       H(  nSUS-  -   nU R                   R                  XfU45        M*     g )N)r   r   r   )   r   r   )r   r]   r   )r]   r]   r   )r   r      )r]   r   r]   )r   r]   r]   )   r_   r_   )   r`   r`   )   r   r   )r   ra   r   )ra   ra   r   )\   rb   ra   )ra   r   ra   )r   ra   ra   )ra   ra   ra   )r   _            ra      $      r6         r'   )rP   r-   range)r   
valuerangeirgbvs          r   rV   '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                     SnSn[        SS5       H@  nU R                  U   nXS   -
  nX'S   -
  n	X7S   -
  n
X-  X-  -   X-  -   nX:  d  M<  UnUnMB     U$ )Ni r      r6   r#   )rl   rP   )r   ro   rp   rq   distancematchrn   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                 2   U R                   R                  US 5      nU[        ;   a  UnX R                   U'   UcK   [        [	        U5      S5      nUS-	  S-  nUS-	  S-  nUS-  nU R                  XEU5      nX R                   U'   U$ ! [
         a    Sn NEf = f)N   r   ra   rk   )rQ   rX   r   r0   r/   
ValueErrorr}   )r   colorindexrgbro   rp   rq   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                    U R                    GH:  u  p[        5       nUS   (       a  U R                  US   5      Ul        O#US   (       a  U R                  US   5      Ul        US   (       a  U R                  US   5      Ul        O#US   (       a  U R                  US   5      Ul        U R
                  (       a  US   (       a  SUl        U R                  (       a  US   (       a  SUl        U R                  (       a  US   (       a  SUl
        UR                  5       UR                  5       4U R                  [        U5      '   GM=     g )	N	ansicolorr   bgansicolorbgcolorr   Tr   r   )styler	   r   r   r   rS   r   rT   r   rU   r   r2   r=   rR   r/   r   ttypendefr   s       r   rW   "Terminal256Formatter._setup_styles   s   ::KE#%FK  --d;.?@	g --d7m<	M" --d=.AB	i --d9o>	||V"  T+%6#' ~~$x. $-3-@-@-B-3-@-@-B-DDc%j)# &r   c                     U =R                   S-  sl         UR                  SU R                   S:g  =(       a    S=(       d    SU R                   4-  5        g )Nr6   z%s%04d: 
r   )rY   write)r   outfiles     r   _write_lineno"Terminal256Formatter._write_lineno   s=    jDLLA$5$>$$D"dll#SSTr   c                 0    [         R                  " XU5      $ r   )r   format)r   tokensourcer   s      r   r   Terminal256Formatter.format   s    7;;r   c                    U R                   (       a  U R                  U5        U H  u  p4SnU(       a  U(       a   U R                  [        U5         u  pgUR	                  S5      nUS S  HU  n	U	(       a  UR                  Xi-   U-   5        U R                   (       a  U R                  U5        MD  UR                  S5        MW     US   (       a  UR                  XhS   -   U-   5        SnU(       a	  U(       a  M  U(       d  M  UR                  U5        M     U R                   (       a  UR                  S5        g g ! [         a    UR                  n Njf = f)NTr   F)rO   r   rR   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$/ !) 2wbr7lS&89 %I' II6 ye$= (@ <<MM$    )!LLE)s   B.D;;EE)rY   rQ   rO   rR   rS   rU   rT   rP   N)r?   r@   rA   rB   __doc__namealiases	filenamesr   rV   r}   r   rW   r   r   r   rC   rD   r   r   r   r   b   sD    @ D2GI""0H"&D*U<% r   c                   :    \ rS rSrSrSr/ SQr/ rS rS r	S r
Srg	)
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'``).
TerminalTrueColor)terminal16m
console16m16mc                     g r   rD   )r   s    r   rV   -TerminalTrueColorFormatter._build_color_table7  s    r   c                      [        [        U5      S5      nUS-	  S-  nUS-	  S-  nUS-  nX4U4$ ! [         a     g f = f)Nr   ra   rk   )r0   r/   r   )r   r   r   ro   rp   rq   s         r   _color_tuple'TerminalTrueColorFormatter._color_tuple:  s\    	c%j"%C BY$AX$Jay  		s   0 
==c                    U R                    H  u  p[        5       nUS   (       a  U R                  US   5      Ul        US   (       a  U R                  US   5      Ul        U R
                  (       a  US   (       a  SUl        U R                  (       a  US   (       a  SUl        U R                  (       a  US   (       a  SUl
        UR                  5       UR                  5       4U R                  [        U5      '   M     g )Nr   r   r   Tr   r   )r   r	   r   r   r   rS   r   rT   r   rU   r   r7   r=   rR   r/   r   s       r   rW   (TerminalTrueColorFormatter._setup_stylesD  s    ::KE#%FG} --d7m<	I --d9o>	||V"  T+%6#' ~~$x. $-3-E-E-G-3-@-@-B-DDc%j) &r   rD   N)r?   r@   rA   rB   r   r   r   r   rV   r   rW   rC   rD   r   r   r   r   %  s(     D2GIDr   N)r   pygments.formatterr   pygments.consoler   pygments.styler   __all__r	   r   r   rD   r   r   <module>r      sK   2 ) " % "#?
@=" ="@ 9  F-D!5 -Dr   