Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Support for colored output in Windows shell #21
Hi, thank you a lot for your contribution!
I was reading about ANSI on Wikipedia and saw that DOS and pre-NT Windows supported ANSI escape codes so I thought this would be valid also for current Windows versions... I should have been reading more carefully, because
In fact, I had tested it on AppVeyor CI and it miraculously worked there (in contrast to the Win32 console) so I didn't expect any problem elsewhere :( However, it seems that AppVeyor doesn't and won't support the "proper" way (they say it's way too deep in Windows so it's impossible to capture the color info) so with your fix the colors are there no more :( It would be wonderful to have colors both on AppVeyor and normal Win32 console, but I guess that's kinda impossible.
The test was there just to verify that I'm putting the ANSI escape codes at proper places. From the look of it, I assume there is no way to do an unit test for the Windows implementation?
Yes, this whole Windows console color thing seems like a mess. :(
But nevertheless it seems that there are some consoles on Windows which support coloring with ANSI escape codes. So it would probably be better to not mutually exclude ANSI coloring and Win32.
One possible solution could be to always use Win32 API on windows and ANSI escape sequences dependant on the
Or is there any other solution you would prefer?
(Sorry, got interrupted and wasn't able to write everything at once.)
Hm... thinking about this, the coloring will work only when the program prints directly to the console without anything in betweeen. Which makes it all a lot less useful, because for example when I run unit tests via
If you can then please have a look into resetting the colors into the previous state and I'll merge this. I will make the ANSI/WINAPI switch a compile-time option later so the user can select between two options with different levels of sanity. Having a runtime switch or DLL injection seems too hacky, yeah.
Also, just a coding style nitpick, can you please indent the preprocessor