Skip to content

Commit

Permalink
Enable escape sequence on Windows10 console
Browse files Browse the repository at this point in the history
	* win32/win32.c (init_stdhandle): enable escape sequence on
	  Windows10 console to show `ruby --help` colors correctly.
  • Loading branch information
unak committed Dec 21, 2020
1 parent 95ce5c0 commit 09f939d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions win32/win32.c
Expand Up @@ -2687,6 +2687,17 @@ init_stdhandle(void)
}
if (nullfd >= 0 && !keep) close(nullfd);
setvbuf(stderr, NULL, _IONBF, 0);

{
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD m;
if (GetConsoleMode(h, &m)) {
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x200
#endif
SetConsoleMode(h, m | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
}
}
}

#undef getsockopt
Expand Down

0 comments on commit 09f939d

Please sign in to comment.