diff options
author | U.Nakamura <usa@ruby-lang.org> | 2020-12-21 17:29:09 +0900 |
---|---|---|
committer | U.Nakamura <usa@ruby-lang.org> | 2020-12-21 17:29:09 +0900 |
commit | 09f939d3a0140478f2e547f45b4becd05247d360 (patch) | |
tree | a33c718d8c45bf382623f108809a7aba22fc6260 | |
parent | 95ce5c0ee9baa692d419dd45f0e00cbd5cee4d4c (diff) |
Enable escape sequence on Windows10 console
* win32/win32.c (init_stdhandle): enable escape sequence on
Windows10 console to show `ruby --help` colors correctly.
-rw-r--r-- | win32/win32.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/win32/win32.c b/win32/win32.c index 5934d7de28..5985875fe2 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -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 |