Attempting to parse free-form ANSI text.

Michael B. Trausch mike$#at^&nospam!%trauschus
Tue Oct 24 16:29:55 EDT 2006


Jean-Paul Calderone wrote:
> On Sun, 22 Oct 2006 00:34:14 -0400, "Michael B. Trausch"
> <mike$#at^&nospam!%trauschus at bag.python.org> wrote:
>> Alright... I am attempting to find a way to parse ANSI text from a
>> telnet application.  However, I am experiencing a bit of trouble.
>>
>> What I want to do is have all ANSI sequences _removed_ from the output,
>> save for those that manage color codes or text presentation (in short,
>> the ones that are ESC[#m (with additional #s separated by ; characters).
>> The ones that are left, the ones that are the color codes, I want to
>> act on, and remove from the text stream, and display the text.
> 
> http://originalgamer.cvs.sourceforge.net/originalgamer/originalgamer/originalgamer/ansi.py?revision=1.12&view=markup
> may be of some interest.
> 

This was actually very useful.  I was able to cleanly implement this for
a subset of ANSI colors.  I have to figure out yet how to get bold
implemented the way that ANSI users expect it to be, but that shouldn't
be that hard.  I am just going to have to rework the way that I handle
colors for the TextCtrl widget, since it assumes that bold really means
to overstrike the text as to make it bold.

	Thanks!
	Mike



More information about the Python-list mailing list