ruby-changes:64407
From: U.Nakamura <ko1@a...>
Date: Mon, 21 Dec 2020 17:30:37 +0900 (JST)
Subject: [ruby-changes:64407] 09f939d3a0 (master): Enable escape sequence on Windows10 console
https://git.ruby-lang.org/ruby.git/commit/?id=09f939d3a0 From 09f939d3a0140478f2e547f45b4becd05247d360 Mon Sep 17 00:00:00 2001 From: "U.Nakamura" <usa@r...> Date: Mon, 21 Dec 2020 17:29:09 +0900 Subject: Enable escape sequence on Windows10 console * win32/win32.c (init_stdhandle): enable escape sequence on Windows10 console to show `ruby --help` colors correctly. 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) https://github.com/ruby/ruby/blob/trunk/win32/win32.c#L2687 } 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/