[IPython-dev] [IPython-user] bug in coloured prompt

Fernando Perez fperez.net at gmail.com
Fri Apr 6 12:53:55 EDT 2007


On 4/6/07, Thorsten Kampe <thorsten at thorstenkampe.de> wrote:

> I still think that the problem could be quite simple. Just one more
> question and I will stop nagging and being a PITA:
>
> 1. Does IPython wrap the colour prompt
> a) just in a single "\001invisible\002plain" or
> b) in something like "\001\001invisible\001\002plain"?
>
> 2. If b) then where does that happen in the source code?

See

http://projects.scipy.org/ipython/ipython/browser/ipython/trunk/IPython/ColorANSI.py#L87

the code is:
    else:
        Normal = '\001\033[0m\002'   # Reset normal coloring
        _base  = '\001\033[%sm\002'  # Template for all other colors

This is a template, where *each* ANSI escape is expanded (that's the
%s part) to form actual color schemes (that code comes right after).

This module builds the classes for color handling, and the explicit
color schemes are built where needed (see Prompts.py for prompt
colors, excolors for exception colors and PyColorize for source
highlihting colors).

Regards,

f



More information about the IPython-dev mailing list