[IPython-dev] Re: A few remaining coloring bugs?
Fernando Perez
Fernando.Perez at colorado.edu
Thu Jan 27 03:36:35 EST 2005
Hi everyone,
Gary Bishop has been helping me track down a problem with syntax-highlighted
source under Windows. A simple way to see the problem is to do
import code
code??
You should see nicely syntax-highlighted source:
http://ipython.scipy.org/screenshots/syntax_highlight.png
Instead, win32 users get strangely broken lines with incorrect colors and
visible escape sequences. Here is some of what Gary has found:
Gary Bishop wrote:
> A little more debugging.
>
>>From outside my code, ipython calls "write" on my file object. The CR
> characters are already in the string at that time. So it looks to me
> like the CR's are coming from your code. So, it looks like they are
> already in there. This is output from od -c
>
> 0012720 m \r \r \n 033 [ 1 ; 3 2 m f r o m 033
> 0012740 [ 0 m 033 [ 1 ; 3 7 m c o d e o
> 0012760 p 033 [ 0 m 033 [ 1 ; 3 2 m i m p
> 0013000 o r t 033 [ 0 m 033 [ 1 ; 3 7 m C
> 0013020 o m m a n d C o m p i l e r 033 [
> 0013040 0 m 033 [ \r \r \n 1 ; 3 3 m , 033 [ 0
> 0013060 m 033 [ 1 ; 3 7 m c o m p i l e
> 0013100 _ c o m m a n d 033 [ 0 m \r \r \n \r
> 0013120 \r \n 033 [ 1 ; 3 7 m _ _ a l l _ _
> 0013140 033 [ 0 m 033 [ 1 ; 3 3 m = 033 [ 0
> 0013160 m 033 [ 1 ; 3 3 m [ 033 [ 0 m 033 [
[...]
> No, I think the key problem is the \r's are embedded inside the escape
> sequence. I have an RE that is scanning for the escape sequences. It
> doesn't allow embedded \r\n characters. I guess it could. But I'm
> amazed that escape sequences allow embedded control characters.
Unfortunately, my debugging efforts came to a screeching halt today, as the
old win32 laptop I was trying to use seems to have finally died. It has a bad
screen, and today I just couldn't turn it on anymore. Since I don't have an
external screen at home I can plug into it, for now I'm stuck.
But looking at the code, I think I have a good idea of where the problem
might be. I was wondering if I ask anyone on the lists with win32 access to
help me track this down, by running a simple test for me.
Please replace PyColorize.py in the site-packages/IPython directory with the
one I'm sending here. I've basically replaced all explicit '\n' references in
the tokenizer call to os.linesep. This might prevent it from inserting things
in the wrong places, though I'm not 100% sure it can fix it.
If this works, I think we'll finally have an ipython which under win32 would
really provide _all_ the functionality of the linux version.
Thanks in advance for any help.
Best,
f
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PyColorize.py
Type: text/x-python
Size: 9293 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20050127/93176f20/attachment.py>
More information about the IPython-dev
mailing list