Merge pull request #40 from rupeshs/windows-console-ansi-color-fix

Windows console ANSI color issue fixed
This commit is contained in:
Kevin Kwok 2023-03-18 07:37:29 -07:00 committed by GitHub
commit b64ca1c07c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -16,6 +16,7 @@
#include <unistd.h>
#elif defined (_WIN32)
#include <signal.h>
#include <Windows.h>
#endif
#define ANSI_COLOR_RED "\x1b[31m"
@ -886,6 +887,11 @@ int main(int argc, char ** argv) {
sigaction(SIGINT, &sigint_action, NULL);
#elif defined (_WIN32)
signal(SIGINT, sigint_handler);
//Windows console ANSI color fix
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD mode;
GetConsoleMode(hConsole, &mode);
SetConsoleMode(hConsole, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
#endif
fprintf(stderr, "%s: interactive mode on.\n", __func__);