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

Thorsten Kampe thorsten@thorstenkampe...
Mon Apr 2 02:59:15 CDT 2007


* Fernando Perez (Sun, 1 Apr 2007 14:54:20 -0600)
> On 4/1/07, Thorsten Kampe <thorsten@thorstenkampe.de> wrote:
> > * Thorsten Kampe (Wed, 28 Mar 2007 22:30:25 +0100)
> > > [IPython 0.7.3 and 0.7.4]
> > >
> > > Hi,
> > >
> > > "\#" (maybe other special escapes, too) ignores the colour escape codes
> > > in prompts. See for instance [1]. The "\#" is printed in green (although
> > > it should be white. Same goes for the out prompt where it's printed in
> > > red.
> > >
> > > Thorsten
> > > [1] prompt_in1 '\C_White[\#\C_White]\C_LightCyan>>> '
> >
> > Can someone confirm that this is a bug?
> 
> Well, it's more of a design limitation, or a not-implemented feature
> than a 'oops, little bug we missed' kind of thing.  The original
> coloring code, when I wrote it, hardcoded a color scheme for certain
> items.

Well, if you had mentioned that in the documentation, you wouldn't 
have had to write a patch ;-P .

> But if you update to SVN, I just added a new prompt escape,
> 
> \N
> 
> which is identical to \# but does NOT apply any coloring.  Using \N
> instead of \# lets you then apply your own colors at will.

Works like a charm in Cygwin rxvt (using readline) and Windows IPython 
(using pyreadline).

By the way (introducing a new bug(?): if I run Cygwin IPython (meaning 
"Linux" Python and GNU readline) the output prompt shows the colour 
escape sequences as coloured faces. This only happens with the 
standard Windows console and the well-known "Console"[1].

The paradox thing is that prompt_in1 and prompt_in2 display fine - 
it's just prompt_out that has this mistake. Is there some special code 
in IPython that constructs the in prompts differently than the out 
prompt?!

Thorsten

[1] http://sourceforge.net/projects/console/



More information about the IPython-user mailing list