Skip to content
Myr

Possibly enable color output on Windows (#1494)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

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.

authored by Jason Hood · committed by Nico Williams · parent 605bfb3 · Browse files · 1 file+11 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+11 added−0 removed

  • other:+11 added−0 removed

1 file+11 added−0 removed

modified:src/main.c+11 added
536 unmodified lines
537#ifndef WIN32538 /* Disable color by default on Windows builds as Windows539 terminals tend not to display it correctly */540 dumpopts |= JV_PRINT_COLOR;541#else542 // Unless ANSICON is installed, or it's Windows 10543 if (getenv("ANSICON") != NULL)544 dumpopts |= JV_PRINT_COLOR;545 else {546 DWORD mode;547 HANDLE con = GetStdHandle(STD_OUTPUT_HANDLE);548 if (GetConsoleMode(con, &mode) &&549 SetConsoleMode(con, mode | 4/*ENABLE_VIRTUAL_TERMINAL_PROCESSING*/))550 dumpopts |= JV_PRINT_COLOR;551 }552#endif553 }554#endif555 if (options & SORTED_OUTPUT) dumpopts |= JV_PRINT_SORTED;
145 unmodified lines