ericwa / ericw-tools

Quake/Hexen 2 Map compiling tools - branch of http://disenchant.net/utils
http://ericwa.github.io/ericw-tools
GNU General Public License v2.0
329 stars 57 forks source link

Enable support for ANSI color codes on Windows 10 and newer, without … #337

Closed TTimo closed 1 year ago

TTimo commented 1 year ago

…needing to enable system wide. Good for CreateProcess CREATE_NEW_CONSOLE situations.

cc @Paril

ericwa commented 1 year ago

Thanks! This fixes the colored output not working in some contexts for me (e.g. CLion's "run" window).

The only issue I'm seeing is arrow keys stop working in Windows Terminal after I run light.exe - instead of cycling through history like normal, they print escape sequences.

There's some mention of this issue here: https://stackoverflow.com/a/52608157

It seems to not happen if I comment out:

//    HANDLE hInput = GetStdHandle(STD_INPUT_HANDLE);
//    SetConsoleMode(hInput, ENABLE_VIRTUAL_TERMINAL_INPUT);

, and the colored output still works, so maybe the hOutput lines are enough?

TTimo commented 1 year ago

Ah yes, just hOutput may be enough. My setup is just a run window like CLion so I never got to test the input side.