nghung270192 / colorama

Automatically exported from code.google.com/p/colorama
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Add support for Windows xterm emulators. #16

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Launch python.exe win32 binary under xterm, rxvt, or mintty terminal 
emulators for Cygwin.
2. Execute an script with colorama.init() and ANSI escape sequences.

What is the expected output? What do you see instead?
It should show colored output, but it strips the escape sequences.
I guess it should work with the Python Cygwin port as the value of 
sys.platform, according to the Python docs, is 'cygwin' and not 'win32'.

What version of the product are you using? On what operating system?
The last version of colorama module, Python 2.7 Win32 (not that from the Cygwin 
package) and Windows XP SP3.

Please provide any additional information below.
I've resolved this adding these lines to my example code:

import os
from colorama import init

terminal = os.getenv('TERM')

if terminal is None or 'rxvt' not in terminal:
    init(autoreset=True)
else:
    init(autoreset=True, convert=False, strip=False)

print "\033[45m" "HOLA"
print "HOLA"

This example code outputs the same result either under CMD.EXE or under Cygwin 
default console or under rxvt terminal, only the first HOLA is magenta.

I think it would be great to support the Windows xterm emulators in colorama.

Regards.

Original issue reported on code.google.com by del...@gmail.com on 24 Jul 2010 at 11:39

GoogleCodeExporter commented 9 years ago
Thanks for the bug report and all the detail. I'll have a crack at this in the 
next couple of weeks.

Original comment by tart...@gmail.com on 25 Jul 2010 at 4:13

GoogleCodeExporter commented 9 years ago
from wiggin15 on github:

When calling 'init' under Cygwin, colorama stops working (it works if we don't 
call it). Our current work around is:

if 'TERM' not in environ:  # this is how we recognize real Windows (init should 
only be called there)
        init()

Original comment by tart...@gmail.com on 22 Apr 2014 at 3:15

GoogleCodeExporter commented 9 years ago
Closing as per Wiggin's comment on https://github.com/tartley/colorama/issues/25

Original comment by tart...@gmail.com on 16 Feb 2015 at 12:06