Skip to content

Commit

Permalink
Do the windows ANSI color fix properly
Browse files Browse the repository at this point in the history
  • Loading branch information
anzz1 committed Mar 18, 2023
1 parent b64ca1c commit f69062f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -887,11 +887,12 @@ 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);

// Windows console ANSI color fix
DWORD mode;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
if (hConsole && hConsole != INVALID_HANDLE_VALUE && GetConsoleMode(hConsole, &mode))
SetConsoleMode(hConsole, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
#endif

fprintf(stderr, "%s: interactive mode on.\n", __func__);
Expand Down

0 comments on commit f69062f

Please sign in to comment.