
    }e<                         d Z g dZddlZddlmZ dZd Z G d d      Z ee        G d	 d
      Z ee        G d d      Z	eD ]  \  Z
Z ee	e
d         G d d      Z G d de      Zy)z+Tools for coloring text in ANSI terminals.
)
TermColorsInputTermColorsColorSchemeColorSchemeTable    N)Struct))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                 T    t         D ]  \  }}t        | || j                  |z         ! y)zBuild a set of color attributes in a class.

    Helper function for building the :class:`TermColors` and
    :class`InputTermColors`.
    N)color_templatessetattr_base)in_classnamevalues      9/usr/lib/python3/dist-packages/IPython/utils/coloransi.pymake_color_tabler(   0   s,     & 6
Uhnnu456    c                       e Zd ZdZdZdZdZy)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. [0m[%smN)__name__
__module____qualname____doc__NoColorNormalr#    r)   r'   r   r   9   s    H GFEr)   r   c                       e Zd ZdZdZej                  dk(  r$ej                  j                  dd      dk(  rdZ	dZ
yd	Z	d
Z
y)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,   r-   z[0mz[%smN)r.   r/   r0   r1   r2   osr%   environgetr3   r#   r4   r)   r'   r   r   J   sD    H G	ww$2::>>&8GC"#r)   r   c                       e Zd ZdZdZdZy)NoColorszThis 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/   r0   r1   r2   r3   r4   r)   r'   r>   r>   f   s    KGFr)   r>   r+   c                        e Zd ZdZddZddZy)r   z5Generic color scheme class. Just a name and a Struct.Nc                 X    || _         |t        di || _        y t        |      | _        y )Nr4   )r%   r   colors)self_ColorScheme__scheme_name_	colordictcolormaps       r'   __init__zColorScheme.__init__q   s*    "	 ,8,DK +DKr)   c                 f    || j                   }t        || j                  j                               S )z9Return a full copy of the object, optionally renaming it.)r%   r   rA   dict)rB   r%   s     r'   copyzColorScheme.copyx   s*    <99D4!1!1!344r)   )N)r.   r/   r0   r1   rF   rI   r4   r)   r'   r   r   o   s    ?,5r)   r   c                   ,    e Zd ZdZddZd Zd ZddZy)	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 schemeNc                     d| _         d| _        |r:|dk(  rt        d      |D ]  }| j                  |        | j	                  |       yy)zCreate 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)rB   scheme_listdefault_schemeschemes       r'   rF   zColorSchemeTable.__init__   sY     #%!# !LMM% ('("">2 r)   c                 J    t        | j                         | j                        S )zReturn full copy of object)r   valuesrL   )rB   s    r'   rI   zColorSchemeTable.copy   s    d.E.EFFr)   c                 X    t        |t              st        d      || |j                  <   y)z$Add a new color scheme to the table.z3ColorSchemeTable only accepts ColorScheme instancesN)
isinstancer   rN   r%   )rB   
new_schemes     r'   rO   zColorSchemeTable.add_scheme   s&    *[1RSS *Z__r)   c                    t        | j                               }|r|}|}n-|D cg c]  }|j                          }}|j                         }	 |j                  |      }||   }|| _        | |   j
                  | _        | |   | d<   yc c}w # t        $ r3}	t        d|z   dz   t        |      j                  dd      z         |	d}	~	ww xY w)zSet 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.r+   zUnrecognized color scheme: z
Valid schemes: z'', N)
listkeyslowerindexrL   rA   rM   rN   strreplace)
rB   rS   case_sensitivescheme_namesvalid_schemesscheme_tests
scheme_idxactivees
             r'   rP   z"ColorSchemeTable.set_active_scheme   s     DIIK((M K0<=1QWWY=M= ,,.K
	$&,,[9J
 "*-F&,D#!%f!4!4DF|DH >  	S:VC%&&),&7&?&?r&JK LQRS	Ss   B	B 	C
.CC
)Nr+   )r   )r.   r/   r0   r1   rF   rI   rO   rP   r4   r)   r'   r   r   ~   s    @3&G+$r)   r   )r1   __all__r:   IPython.utils.ipstructr   r!   r(   r   r   r>   r%   r&   r"   r   rH   r   r4   r)   r'   <module>rj      s    L 	 )
<6   $ $4  !  #  KD%HdB 5 5=$t =$r)   