diff options
author | elfmz <fenix1905@tut.by> | 2022-11-07 19:35:02 +0300 |
---|---|---|
committer | elfmz <fenix1905@tut.by> | 2022-11-07 19:35:02 +0300 |
commit | 8a3550ad514179509ff5a60eafb7c550881861c1 (patch) | |
tree | a37143f1cf527e43f8e4d613faba7ce1bfb2de43 | |
parent | b7939dfb235b07a580326dc48252d99a55fdd8d4 (diff) |
TTY/truecolor: another some colors broken (fix #1391)
-rw-r--r-- | WinPort/src/Backend/TTY/TTYOutput.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/WinPort/src/Backend/TTY/TTYOutput.cpp b/WinPort/src/Backend/TTY/TTYOutput.cpp index 9c6f79e0..c8b0c5d2 100644 --- a/WinPort/src/Backend/TTY/TTYOutput.cpp +++ b/WinPort/src/Backend/TTY/TTYOutput.cpp @@ -73,10 +73,19 @@ void TTYOutput::WriteUpdatedAttributes(DWORD64 attr, bool is_space) _tmp_attrs+= (attr & FOREGROUND_INTENSITY) ? "1;" : "22;"; } + bool emit_tc_fore = + ((attr & FOREGROUND_TRUECOLOR) != 0 && (GET_RGB_FORE(xa) != 0 || (xa & FOREGROUND_TRUECOLOR) != 0)); + + bool emit_tc_back = + ((attr & BACKGROUND_TRUECOLOR) != 0 && (GET_RGB_BACK(xa) != 0 || (xa & BACKGROUND_TRUECOLOR) != 0)); + if ( ((xa & (FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY)) != 0) || ((_prev_attr & FOREGROUND_TRUECOLOR) != 0 && (attr & FOREGROUND_TRUECOLOR) == 0) ) { _tmp_attrs+= (attr & FOREGROUND_INTENSITY) ? '9' : '3'; AppendAnsiColorSuffix<FOREGROUND_RED, FOREGROUND_GREEN, FOREGROUND_BLUE>(_tmp_attrs, attr); + if ((attr & FOREGROUND_TRUECOLOR) != 0) { + emit_tc_fore = true; + } } if ( ((xa & (BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY)) != 0) @@ -87,14 +96,17 @@ void TTYOutput::WriteUpdatedAttributes(DWORD64 attr, bool is_space) _tmp_attrs+= '4'; } AppendAnsiColorSuffix<BACKGROUND_RED, BACKGROUND_GREEN, BACKGROUND_BLUE>(_tmp_attrs, attr); + if ((attr & BACKGROUND_TRUECOLOR) != 0) { + emit_tc_back = true; + } } - if ((attr & FOREGROUND_TRUECOLOR) != 0 && (GET_RGB_FORE(xa) != 0 || (xa & FOREGROUND_TRUECOLOR) != 0)) { + if (emit_tc_fore) { _tmp_attrs+= "38;"; _true_colors.AppendSuffix(_tmp_attrs, GET_RGB_FORE(attr)); } - if ((attr & BACKGROUND_TRUECOLOR) != 0 && (GET_RGB_BACK(xa) != 0 || (xa & BACKGROUND_TRUECOLOR) != 0)) { + if (emit_tc_back) { _tmp_attrs+= "48;"; _true_colors.AppendSuffix(_tmp_attrs, GET_RGB_BACK(attr)); } |