diff options
author | Peter Damianov <peter0x44@disroot.org> | 2024-06-03 10:07:08 -0700 |
---|---|---|
committer | Jonathan Yong <10walls@gmail.com> | 2024-06-16 01:24:38 +0000 |
commit | e943a5da40cd4799908d3d29001e1325eb00b755 (patch) | |
tree | 8a0766980bf8d9f11f8dc552cc0d73ea6295639c /gcc | |
parent | dff55a5a0e17f202814e432bdcc5917b65292b44 (diff) | |
download | gcc-e943a5da40cd4799908d3d29001e1325eb00b755.zip gcc-e943a5da40cd4799908d3d29001e1325eb00b755.tar.gz gcc-e943a5da40cd4799908d3d29001e1325eb00b755.tar.bz2 |
diagnostics: Enable escape sequence processing on windows consoles
Since windows 10 release v1511, the windows console has had support for VT100
escape sequences. We should try to enable this, and utilize it where possible.
gcc/ChangeLog:
* diagnostic-color.cc (should_colorize): Enable processing of VT100
escape sequences on windows consoles
Signed-off-by: Peter Damianov <peter0x44@disroot.org>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/diagnostic-color.cc | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/gcc/diagnostic-color.cc b/gcc/diagnostic-color.cc index cbe57ce..261a14b 100644 --- a/gcc/diagnostic-color.cc +++ b/gcc/diagnostic-color.cc @@ -300,12 +300,23 @@ should_colorize (void) pp_write_text_to_stream() in pretty-print.cc calls fputs() on that stream. However, the code below for non-Windows doesn't seem to care about it either... */ - HANDLE h; - DWORD m; + HANDLE handle; + DWORD mode; + BOOL isconsole = false; - h = GetStdHandle (STD_ERROR_HANDLE); - return (h != INVALID_HANDLE_VALUE) && (h != NULL) - && GetConsoleMode (h, &m); + handle = GetStdHandle (STD_ERROR_HANDLE); + + if ((handle != INVALID_HANDLE_VALUE) && (handle != NULL)) + isconsole = GetConsoleMode (handle, &mode); + + if (isconsole) + { + /* Try to enable processing of VT100 escape sequences */ + mode |= ENABLE_PROCESSED_OUTPUT | ENABLE_VIRTUAL_TERMINAL_PROCESSING; + SetConsoleMode (handle, mode); + } + + return isconsole; #else char const *t = getenv ("TERM"); /* emacs M-x shell sets TERM="dumb". */ |