1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Enable escape sequence on Windows10 console

* win32/win32.c (init_stdhandle): enable escape sequence on
	  Windows10 console to show `ruby --help` colors correctly.
This commit is contained in:
U.Nakamura 2020-12-21 17:29:09 +09:00
parent 95ce5c0ee9
commit 09f939d3a0

View file

@ -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