summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorU.Nakamura <usa@ruby-lang.org>2020-12-21 17:29:09 +0900
committerU.Nakamura <usa@ruby-lang.org>2020-12-21 17:29:09 +0900
commit09f939d3a0140478f2e547f45b4becd05247d360 (patch)
treea33c718d8c45bf382623f108809a7aba22fc6260 /win32
parent95ce5c0ee9baa692d419dd45f0e00cbd5cee4d4c (diff)
Enable escape sequence on Windows10 console
* win32/win32.c (init_stdhandle): enable escape sequence on Windows10 console to show `ruby --help` colors correctly.
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 5934d7d..5985875 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