diff options
author | Jason Hood <jadoxa@yahoo.com.au> | 2019-02-12 18:34:37 +1000 |
---|---|---|
committer | Nico Williams <nico@cryptonector.com> | 2019-02-16 20:40:41 -0600 |
commit | def42a31caef46dbc122cb41f213784d915d318e (patch) | |
tree | 3899500185e8fd90d34e304ceb7fa1be9f38eaa4 | |
parent | 605bfb35772833db0bd69927181c934d79b96d2e (diff) |
Possibly enable color output on Windows (#1494)
Windows 10 supports color output, but it must be explicitly enabled;
ANSICON provides support for other versions. Enable color if either of
those are available. Resolves #1494.
-rw-r--r-- | src/main.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -538,6 +538,17 @@ int main(int argc, char* argv[]) { /* Disable color by default on Windows builds as Windows terminals tend not to display it correctly */ dumpopts |= JV_PRINT_COLOR; +#else + // Unless ANSICON is installed, or it's Windows 10 + if (getenv("ANSICON") != NULL) + dumpopts |= JV_PRINT_COLOR; + else { + DWORD mode; + HANDLE con = GetStdHandle(STD_OUTPUT_HANDLE); + if (GetConsoleMode(con, &mode) && + SetConsoleMode(con, mode | 4/*ENABLE_VIRTUAL_TERMINAL_PROCESSING*/)) + dumpopts |= JV_PRINT_COLOR; + } #endif } #endif |