winpty icon indicating copy to clipboard operation
winpty copied to clipboard

Missing text colors in MINGW64 when program runs with winpty

Open chella2 opened this issue 2 years ago • 2 comments

Hi,

I use MINGW64 and wonder how to get colored text output from programs started with winpty.

Example: Colored text works when program is not using winpty: image

But for programs started with winpty the text colors are missing image

I use winpty version 0.4.3 image

Thanks!

chella2 avatar Oct 25 '21 16:10 chella2

Try this:

$ winpty python -c "from ctypes import *; windll.kernel32.SetConsoleMode(windll.kernel32.GetStdHandle(-11), 7); print('\033[32mGreen\033[m')"

For detail, see the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag of SetConsoleMode().

k-takata avatar Oct 25 '21 17:10 k-takata

With colorama it can work without Windows 10:

winpty python -c "from colorama import init; init(); ..."

andry81 avatar Oct 25 '21 18:10 andry81