Ñò
ÎÑAHc           @   sÎ   d  Z  d d k l Z d e i d Z e i Z d d d d g Z d d	 k Z d d
 k	 l
 Z
 d „  Z d d d „  ƒ  YZ e e ƒ d d d „  ƒ  YZ e e ƒ d d d „  ƒ  YZ d e f d „  ƒ  YZ d	 S(   s`   Tools for coloring text in ANSI terminals.

$Id: ColorANSI.py 2167 2007-03-21 06:57:50Z fperez $iÿÿÿÿ(   t   Releases   %s <%s>t   Fernandot
   TermColorst   InputTermColorst   ColorSchemet   ColorSchemeTableN(   t   Structc         C   sh   d" d# d$ d% d& d' d( d) d* d+ d, d- d. d/ d0 d1 f } x+ | D]# \ } } t  |  | |  i | ƒ q= Wd! S(2   sf   Build a set of color attributes in a class.

    Helper function for building the *TermColors classes.t   Blacks   0;30t   Reds   0;31t   Greens   0;32t   Browns   0;33t   Blues   0;34t   Purples   0;35t   Cyans   0;36t	   LightGrays   0;37t   DarkGrays   1;30t   LightReds   1;31t
   LightGreens   1;32t   Yellows   1;33t	   LightBlues   1;34t   LightPurples   1;35t	   LightCyans   1;36t   Whites   1;37N(   s   Blacks   0;30(   s   Reds   0;31(   s   Greens   0;32(   R
   s   0;33(   s   Blues   0;34(   R   s   0;35(   s   Cyans   0;36(   R   s   0;37(   R   s   1;30(   s   LightReds   1;31(   s
   LightGreens   1;32(   s   Yellows   1;33(   s	   LightBlues   1;34(   R   s   1;35(   s	   LightCyans   1;36(   s   Whites   1;37(   t   setattrt   _base(   t   in_classt   color_templatest   namet   value(    (    sI   /u/d/b/dbachman/web/work/lib/python2.3/site-packages/IPython/ColorANSI.pyt   make_color_table   s&    	 c           B   s    e  Z d  Z d Z d Z d Z RS(   sd  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.t    s   [0ms   [%sm(   t   __name__t
   __module__t   __doc__t   NoColort   NormalR   (    (    (    sI   /u/d/b/dbachman/web/work/lib/python2.3/site-packages/IPython/ColorANSI.pyR   1   s   c           B   s\   e  Z d  Z d Z e i d j o, e i i d d ƒ d j o d Z d Z	 n d Z d	 Z	 RS(
   s  Color escape sequences for input prompts.

    This class is similar to TermColors, but the escapes are wrapped in 
    and  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   t   ntt   TERMt   dumbt   emacss   [0ms   [%sms   [0ms   [%sm(
   R   R    R!   R"   t   osR   t   environt   getR#   R   (    (    (    sI   /u/d/b/dbachman/web/work/lib/python2.3/site-packages/IPython/ColorANSI.pyR   B   s   ,
c           B   s&   e  Z d  Z d d „ Z d d „ Z RS(   s5   Generic color scheme class. Just a name and a Struct.c         K   s<   | |  _  | d  j o t |   |  _ n t | ƒ |  _ d  S(   N(   R   t   NoneR   t   colors(   t   selft   _ColorScheme__scheme_name_t	   colordictt   colormap(    (    sI   /u/d/b/dbachman/web/work/lib/python2.3/site-packages/IPython/ColorANSI.pyt   __init__`   s    	c         C   s-   | d j o |  i } n t | |  i i ƒ S(   s9   Return a full copy of the object, optionally renaming it.N(   R+   R   R   R,   t   __dict__(   R-   R   (    (    sI   /u/d/b/dbachman/web/work/lib/python2.3/site-packages/IPython/ColorANSI.pyt   copyg   s    N(   R   R    R!   R+   R1   R3   (    (    (    sI   /u/d/b/dbachman/web/work/lib/python2.3/site-packages/IPython/ColorANSI.pyR   ^   s   c           B   s;   e  Z d  Z d d d „ Z d „  Z d „  Z d d „ Z RS(   s  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 schemeR   c         C   sf   d |  _  d |  _ | oI | d j o t d ‚ n x | D] } |  i | ƒ q: W|  i | ƒ n d S(   sâ   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   s)   you must specify the default color schemeN(   t   active_scheme_nameR+   t   active_colorst
   ValueErrort
   add_schemet   set_active_scheme(   R-   t   scheme_listt   default_schemet   scheme(    (    sI   /u/d/b/dbachman/web/work/lib/python2.3/site-packages/IPython/ColorANSI.pyR1   v   s    			 c         C   s   t  |  i ƒ  |  i ƒ S(   s   Return full copy of object(   R   t   valuesR4   (   R-   (    (    sI   /u/d/b/dbachman/web/work/lib/python2.3/site-packages/IPython/ColorANSI.pyR3   ‰   s    c         C   s.   t  | t ƒ p t d ‚ n | |  | i <d S(   s$   Add a new color scheme to the table.s3   ColorSchemeTable only accepts ColorScheme instancesN(   t
   isinstanceR   R6   R   (   R-   t
   new_scheme(    (    sI   /u/d/b/dbachman/web/work/lib/python2.3/site-packages/IPython/ColorANSI.pyR7      s    i    c   
      C   sÛ   |  i  ƒ  } | o | } | } n4 g  } | D] } | | i ƒ  q. ~ } | i ƒ  } y | i | ƒ } Wn: t j
 o. t d | d t | ƒ i d d ƒ ‚ n3 X| | }	 |	 |  _ |  |	 i |  _ |  |	 |  d <d S(   s³   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.s   Unrecognized color scheme: s   
Valid schemes: s   '', R   N(	   t   keyst   lowert   indexR6   t   strt   replaceR4   R,   R5   (
   R-   R;   t   case_sensitivet   scheme_namest   valid_schemest   scheme_testt   _[1]t   st
   scheme_idxt   active(    (    sI   /u/d/b/dbachman/web/work/lib/python2.3/site-packages/IPython/ColorANSI.pyR8   “   s    
')
	N(   R   R    R!   R+   R1   R3   R7   R8   (    (    (    sI   /u/d/b/dbachman/web/work/lib/python2.3/site-packages/IPython/ColorANSI.pyR   m   s
   		(    (    (    (   R!   t   IPythonR    t   authorst
   __author__t   licenset   __license__t   __all__R(   t   IPython.ipstructR   R   R   R   R   t   dictR   (    (    (    sI   /u/d/b/dbachman/web/work/lib/python2.3/site-packages/IPython/ColorANSI.pyt   <module>   s   			

