From a83e2e7a2447d782ed41810535a94d4c73b3dc8f Mon Sep 17 00:00:00 2001 From: Rupesh Sreeraman Date: Sat, 18 Mar 2023 16:41:20 +0530 Subject: [PATCH] Windows console ANSI color issue fixed --- chat.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/chat.cpp b/chat.cpp index 596a806d3..f2ccf12fc 100644 --- a/chat.cpp +++ b/chat.cpp @@ -16,6 +16,7 @@ #include #elif defined (_WIN32) #include +#include #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__);