Skip to content

Commit

Permalink
Merge pull request #40 from rupeshs/windows-console-ansi-color-fix
Browse files Browse the repository at this point in the history
Windows console ANSI color issue fixed
  • Loading branch information
antimatter15 authored Mar 18, 2023
2 parents 4a524c5 + a83e2e7 commit b64ca1c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <unistd.h>
#elif defined (_WIN32)
#include <signal.h>
#include <Windows.h>
#endif

#define ANSI_COLOR_RED "\x1b[31m"
Expand Down Expand Up @@ -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__);
Expand Down

0 comments on commit b64ca1c

Please sign in to comment.