
    ,h-                     t    d Z ddlmZ ddlmZ ddlmZ ddgZ G d d      Z G d	 de      Z	 G d
 de	      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-2025 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
    )	Formatter)codes)
ansicolorsTerminal256FormatterTerminalTrueColorFormatterc                   ,    e Zd ZddZd Zd Zd Zd Zy)EscapeSequenceNc                 J    || _         || _        || _        || _        || _        y N)fgbgbold	underlineitalic)selfr   r   r   r   r   s         a/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/pygments/formatters/terminal256.py__init__zEscapeSequence.__init__#   s%    	"    c                 H    t        |      rddj                  |      z   dz   S y)Nz[;m )lenjoinr   attrss     r   escapezEscapeSequence.escape*   s$    u:SXXe_,s22r   c           	         g }| j                   v| j                   t        v rCt        | j                   j                  dd         }d|v rd| _        |j                  |dd        n!|j                  ddd	| j                   z  f       | j                  | j                  t        v rMt        | j                  j                  dd         }|j                  t        t        |dd       d
z                n!|j                  ddd	| j                  z  f       | j                  r|j                  d       | j                  r|j                  d       | j                  r|j                  d       | j                  |      S )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_stringz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           
      f   g }| j                   rX|j                  ddt        | j                   d         t        | j                   d         t        | j                   d         f       | j                  rX|j                  ddt        | j                  d         t        | j                  d         t        | j                  d         f       | j                  r|j                  d       | j                  r|j                  d       | j                  r|j                  d	       | j                  |      S )
Nr"   2r      r    r%   r&   r'   r(   )	r   r+   r,   r   r   r*   r   r   r   r   s     r   true_color_stringz 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                    g }| j                   |j                  d       | j                  |j                  d       | j                  s| j                  s| j
                  r|j                  d       | j                  |      S )N394900)r   r*   r   r   r   r   r   r   s     r   reset_stringzEscapeSequence.reset_stringW   sa    77LL77LL99$++LL{{5!!r   )NNFFF)__name__
__module____qualname__r   r   r/   r3   r8    r   r   r	   r	   "   s    
"4""r   r	   c                   P    e Zd ZdZdZg dZg Zd Zd Zd Z	d Z
d Zd	 Zd
 Zd Zy)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).
    Terminal256)terminal256
console256256c                    t        j                  | fi | g | _        i | _        i | _        d|v| _        d|v| _        d|v| _        | j                          | j                          |j                  dd      | _        d| _        y )NnoboldnounderlinenoitaliclinenosFr   )r   r   xterm_colors
best_matchstyle_stringusebolduseunderline	useitalic_build_color_table_setup_stylesgetrF   _lineno)r   optionss     r   r   zTerminal256Formatter.__init__   s    4+7+w.)8#72!{{9e4r   c                 n   | j                   j                  d       | j                   j                  d       | j                   j                  d       | j                   j                  d       | j                   j                  d       | j                   j                  d       | j                   j                  d       | j                   j                  d       | j                   j                  d	       | j                   j                  d
       | j                   j                  d       | j                   j                  d       | j                   j                  d       | j                   j                  d       | j                   j                  d       | j                   j                  d       d}t        d      D ]>  }||dz  dz     }||dz  dz     }||dz     }| j                   j                  |||f       @ t        dd      D ](  }d|dz  z   }| j                   j                  |||f       * y )N)r   r   r   )   r   r   )r   rS   r   )rS   rS   r   )r   r      )rS   r   rS   )r   rS   rS   )   rU   rU   )   rV   rV   )   r   r   )r   rW   r   )rW   rW   r   )\   rX   rW   )rW   r   rW   )r   rW   rW   )rW   rW   rW   )r   _            rW      $      r2         r$   )rG   r*   range)r   
valuerangeirgbvs          r   rM   z'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 	0AAGq=)AAFa<(A1q5!A$$aAY/		0 q" 	0AAF
A$$aAY/	0r   c                     d}d}t        dd      D ]D  }| j                  |   }||d   z
  }||d   z
  }	||d   z
  }
||z  |	|	z  z   |
|
z  z   }||k  sA|}|}F |S )Ni r      r2   r    )rb   rG   )r   re   rf   rg   distancematchrd   valuesrdgdbdds               r   _closest_colorz#Terminal256Formatter._closest_color   s    q# 
	A&&q)FVAYBVAYBVAYB222%A8|
	 r   c                 0   | j                   j                  |d       }|t        v r|}|| j                   |<   |M	 t        t	        |      d      }|dz	  dz  }|dz	  dz  }|dz  }| j                  |||      }|| j                   |<   |S # t
        $ r d}Y Fw xY w)N   r   rW   ra   )rH   rO   r   r-   r,   
ValueErrorrr   )r   colorindexrgbre   rf   rg   s          r   _color_indexz!Terminal256Formatter._color_index   s    ##E40JE%*DOOE"=#e*b) d"AT!Ad
A''1a0E%*DOOE"  s   B BBc                 4   | j                   D ]  \  }}t               }|d   r| j                  |d         |_        n|d   r| j                  |d         |_        |d   r| j                  |d         |_        n|d   r| j                  |d         |_        | j
                  r|d   rd|_        | j                  r|d   rd|_        | j                  r|d   rd|_
        |j                         |j                         f| j                  t        |      <    y )	N	ansicolorrv   bgansicolorbgcolorr   Tr   r   )styler	   ry   r   r   rJ   r   rK   r   rL   r   r/   r8   rI   r,   r   ttypendefr   s       r   rN   z"Terminal256Formatter._setup_styles   s
   :: 	DKE4#%FK  --d;.?@	g --d7m<	M" --d=.AB	i --d9o>	||V"  T+%6#' ~~$x. $-3-@-@-B-3-@-@-B-DDc%j)#	Dr   c                     | xj                   dz  c_         |j                  d| j                   dk7  xr dxs d| j                   fz         y )Nr2   z%s%04d: 
r   )rP   write)r   outfiles     r   _write_linenoz"Terminal256Formatter._write_lineno   s=    jDLLA$5$>$$D"dll#SSTr   c                 0    t        j                  | ||      S r   )r   format)r   tokensourcer   s      r   r   zTerminal256Formatter.format   s    k7;;r   c                 B   | j                   r| j                  |       |D ]  \  }}d}|r|r	 | j                  t        |         \  }}|j	                  d      }|d d D ]J  }	|	r|j                  ||	z   |z          | j                   r| j                  |       :|j                  d       L |d   r|j                  ||d   z   |z          d}|r|r|s|j                  |        | j                   r|j                  d       y y # t        $ r |j                  }Y Qw xY w)NTr   F)rF   r   rI   r,   splitr   KeyErrorparent)
r   r   r   r   value	not_foundonoffspllines
             r   format_unencodedz%Terminal256Formatter.format_unencoded   s"   <<w'' 	%LE5II)"//E
;GB  ++d+C #CR 0#MM"t)c/:<< ..w7#MM$/0 2wb3r7lS&89 %I' I6 e$=	%@ <<MM$    )!LLE)s   BDDDN)r9   r:   r;   __doc__namealiases	filenamesr   rM   rr   ry   rN   r   r   r   r<   r   r   r   r   b   sD    @ D2GI""0H"&D*U<% r   c                   2    e Zd ZdZdZg dZg Zd Zd Zd Z	y)r   a}  
    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                      y r   r<   )r   s    r   rM   z-TerminalTrueColorFormatter._build_color_table7  s    r   c                     	 t        t        |      d      }|dz	  dz  }|dz	  dz  }|dz  }|||fS # t        $ r Y y w xY w)Nrt   rW   ra   )r-   r,   ru   )r   rv   rx   re   rf   rg   s         r   _color_tuplez'TerminalTrueColorFormatter._color_tuple:  s^    	c%j"%C BY$AX$J1ay  		s   1 	==c                    | j                   D ]  \  }}t               }|d   r| j                  |d         |_        |d   r| j                  |d         |_        | j
                  r|d   rd|_        | j                  r|d   rd|_        | j                  r|d   rd|_
        |j                         |j                         f| j                  t        |      <    y )Nrv   r}   r   Tr   r   )r~   r	   r   r   r   rJ   r   rK   r   rL   r   r3   r8   rI   r,   r   s       r   rN   z(TerminalTrueColorFormatter._setup_stylesD  s    :: 	DKE4#%FG} --d7m<	I --d9o>	||V"  T+%6#' ~~$x. $-3-E-E-G-3-@-@-B-DDc%j)	Dr   N)
r9   r:   r;   r   r   r   r   rM   r   rN   r<   r   r   r   r   %  s(     D2GI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   