From 5d3083dde2a4fb03fab20d66fda1a5881801c757 Mon Sep 17 00:00:00 2001 From: Liu Hao Date: Tue, 14 Aug 2018 10:04:10 +0000 Subject: [PATCH] pretty-print.c (eat_esc_sequence): Swap the foreground and background colors if... * gcc/pretty-print.c (eat_esc_sequence): Swap the foreground and background colors if the COMMON_LVB_REVERSE_VIDEO flag is set, and clear it thereafter, as it only works for DBCS. From-SVN: r263531 --- gcc/ChangeLog | 6 ++++++ gcc/pretty-print.c | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ec466dece37..1e108ef35b2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-08-13 Liu Hao + + * pretty-print.c (eat_esc_sequence): Swap the foreground and + background colors if the COMMON_LVB_REVERSE_VIDEO flag is set, + and clear it thereafter, as it only works for DBCS. + 2018-08-13 Liu Hao * pretty-print.c (mingw_ansi_fputs): Do not call _close() on the diff --git a/gcc/pretty-print.c b/gcc/pretty-print.c index 31eb8893f2a..02967d05f75 100644 --- a/gcc/pretty-print.c +++ b/gcc/pretty-print.c @@ -640,6 +640,16 @@ sgr_set_it: { attrib_add |= sb.wAttributes & ~attrib_rm; } + if (attrib_add & COMMON_LVB_REVERSE_VIDEO) + { + /* COMMON_LVB_REVERSE_VIDEO is only effective for DBCS. + * Swap foreground and background colors by hand. + */ + attrib_add = (attrib_add & 0xFF00) + | ((attrib_add & 0x00F0) >> 4) + | ((attrib_add & 0x000F) << 4); + attrib_add &= ~COMMON_LVB_REVERSE_VIDEO; + } SetConsoleTextAttribute (h, attrib_add); break; } -- 2.30.2