o
    û›h@"  ã                   @   s¨   d Z ddlZddlZddlmZ g d¢Zeƒ ZdZdd„ Z	G dd	„ d	ƒZ
G d
d„ dƒZe	eƒ G dd„ dƒZeD ]
\ZZeeedƒ q8G dd„ dƒZG dd„ deƒZdS )z+Tools for coloring text in ANSI terminals.
é    N)ÚStruct)Ú
TermColorsÚInputTermColorsÚColorSchemeÚColorSchemeTable))ÚBlackz0;30)ÚRedz0;31)ÚGreenz0;32)ÚBrownz0;33)ÚBluez0;34)ÚPurplez0;35)ÚCyanz0;36)Ú	LightGrayz0;37)ÚDarkGrayz1;30)ÚLightRedz1;31)Ú
LightGreenz1;32)ÚYellowz1;33)Ú	LightBluez1;34)ÚLightPurplez1;35)Ú	LightCyanz1;36)ÚWhitez1;37)Ú
BlinkBlackz5;30)ÚBlinkRedz5;31)Ú
BlinkGreenz5;32)ÚBlinkYellowz5;33)Ú	BlinkBluez5;34)ÚBlinkPurplez5;35)Ú	BlinkCyanz5;36)ÚBlinkLightGrayz5;37c                 C   s$   t D ]\}}t| || j| ƒ qdS )z‹Build a set of color attributes in a class.

    Helper function for building the :class:`TermColors` and
    :class`InputTermColors`.
    N)Úcolor_templatesÚsetattrÚ_base)Zin_classÚnameÚvalue© r$   úMc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/utils/coloransi.pyÚmake_color_table3   s   ÿr&   c                   @   sx   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdS )r   ac  Color escape sequences.

    This class defines the escape sequences for all the standard (ANSI?)
    colors in terminals. Also defines a NoColor escape which is just the null
    string, suitable for defining 'dummy' color schemes in terminals which get
    confused by color escapes.

    This class should be used as a mixin for building color schemes.Ú ú[0mz[0;30mz[0;31mz[0;32mz[0;33mz[0;34mz[0;35mz[0;36mz[0;37mz[1;30mz[1;31mz[1;32mz[1;33mz[1;34mz[1;35mz[1;36mz[1;37mz[5;30mz[5;31mz[5;32mz[5;33mz[5;34mz[5;35mz[5;36mz[5;37mN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚNoColorÚNormalr   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$   r%   r   <   s8    	r   c                   @   sD   e Zd ZdZdZejdkrej dd¡dkrdZ	dZ
dS d	Z	d
Z
dS )r   a¢  Color escape sequences for input prompts.

    This class is similar to TermColors, but the escapes are wrapped in \001
    and \002 so that readline can properly know the length of each line and
    can wrap lines accordingly.  Use this class for any colored text which
    needs to be used in input prompts, such as in calls to raw_input().

    This class defines the escape sequences for all the standard (ANSI?)
    colors in terminals. Also defines a NoColor escape which is just the null
    string, suitable for defining 'dummy' color schemes in terminals which get
    confused by color escapes.

    This class should be used as a mixin for building color schemes.r'   ÚntÚTERMÚdumbÚemacsr(   z[%smz[0mz[%smN)r)   r*   r+   r,   r-   Úosr"   ÚenvironÚgetr.   r!   r$   r$   r$   r%   r   f   s    r   c                   @   s   e Zd ZdZdZdZdS )ÚNoColorsz�This defines all the same names as the colour classes, but maps them to
    empty strings, so it can easily be substituted to turn off colours.r'   N)r)   r*   r+   r,   r-   r.   r$   r$   r$   r%   r6   ‚   s    r6   r'   c                   @   s6   e Zd ZU dZeed< eed< d	dd„Zd	dd„ZdS )
r   z5Generic color scheme class. Just a name and a Struct.r"   ÚcolorsNc                 K   sD   || _ |rtjdtdd� |d u rtdi |¤Ž| _d S t|ƒ| _d S )NzðPassing each colors as a kwarg to ColorScheme is considered for deprecation. Please pass a a single dict as second parameter. If you are using thisfeature, please comment an subscribe to issue https://github.com/ipython/ipython/issues/14304é   ©Ú
stacklevelr$   )r"   ÚwarningsÚwarnÚPendingDeprecationWarningr   r7   )ÚselfZ_ColorScheme__scheme_name_Z	colordictZcolormapr$   r$   r%   Ú__init__‘   s   ù	zColorScheme.__init__c                 C   s   |du r| j }t|| j ¡ ƒS )z9Return a full copy of the object, optionally renaming it.N)r"   r   r7   Údict)r>   r"   r$   r$   r%   Úcopy¢   s   zColorScheme.copy©N)	r)   r*   r+   r,   ÚstrÚ__annotations__r   r?   rA   r$   r$   r$   r%   r   ‹   s   
 
r   c                       sP   e Zd ZdZddd„Zdd„ Zded	ef‡ fd
d„Zdd„ Z	e
fdd„Z‡  ZS )r   a  General class to handle tables of color schemes.

    It's basically a dict of color schemes with a couple of shorthand
    attributes and some convenient methods.

    active_scheme_name -> obvious
    active_colors -> actual color table of the active schemeNr'   c                 C   sF   d| _ d| _|r!|dkrtdƒ‚|D ]}|  |¡ q|  |¡ dS dS )zâCreate a table of color schemes.

        The table can be created empty and manually filled or it can be
        created with a list of valid color schemes AND the specification for
        the default active scheme.
        r'   Nz)you must specify the default color scheme)Úactive_scheme_nameÚactive_colorsÚ
ValueErrorÚ
add_schemeÚset_active_scheme)r>   Zscheme_listZdefault_schemeÚschemer$   r$   r%   r?   ±   s   	ûzColorSchemeTable.__init__c                 C   s   t |  ¡ | jƒS )zReturn full copy of object)r   ÚvaluesrE   )r>   r$   r$   r%   rA   Ä   s   zColorSchemeTable.copyÚkeyr#   c                    s.   t |tƒsJ ‚t |tƒsJ ‚tƒ  ||¡ d S rB   )Ú
isinstancerC   r   ÚsuperÚ__setitem__)r>   rL   r#   ©Ú	__class__r$   r%   rO   È   s   zColorSchemeTable.__setitem__c                 C   s    t |tƒs	tdƒ‚|| |j< dS )z$Add a new color scheme to the table.z3ColorSchemeTable only accepts ColorScheme instancesN)rM   r   rG   r"   )r>   Ú
new_schemer$   r$   r%   rH   Í   s   
zColorSchemeTable.add_schemec           	   
   C   sÂ   |t u rd}ntjdtdd� t|  ¡ ƒ}|r|}|}ndd„ |D ƒ}| ¡ }z| |¡}W n tyK } ztd| d t	|ƒ 
d	d
¡ ƒ|‚d}~ww || }|| _| | j| _| | | d
< dS )z³Set the currently active scheme.

        Names are by default compared in a case-insensitive way, but this can
        be changed by setting the parameter case_sensitive to true.Fz´set_active_scheme(case_sensitive=...) is Pending deprecation. Please comment on https://github.com/ipython/ipython/issues/14306 to let the ipython maintainer that you are affected.r8   r9   c                 S   s   g | ]}|  ¡ ‘qS r$   )Úlower)Ú.0Úsr$   r$   r%   Ú
<listcomp>ê   s    z6ColorSchemeTable.set_active_scheme.<locals>.<listcomp>zUnrecognized color scheme: z
Valid schemes: z'', r'   N)Ú	_sentinelr;   r<   r=   ÚlistÚkeysrS   ÚindexrG   rC   ÚreplacerE   r7   rF   )	r>   rJ   Úcase_sensitiveZscheme_namesZvalid_schemesZscheme_testZ
scheme_idxÚeÚactiver$   r$   r%   rI   Ó   s:   ú	ÿÿÿ€ÿz"ColorSchemeTable.set_active_scheme)Nr'   )r)   r*   r+   r,   r?   rA   rC   r   rO   rH   rW   rI   Ú__classcell__r$   r$   rP   r%   r   ¨   s    
r   )r,   r3   r;   ZIPython.utils.ipstructr   Ú__all__ÚobjectrW   r   r&   r   r   r6   r"   r#   r    r   r@   r   r$   r$   r$   r%   Ú<module>   s     	*