diff options
author | elfmz <fenix1905@tut.by> | 2022-11-06 01:55:06 +0300 |
---|---|---|
committer | elfmz <fenix1905@tut.by> | 2022-11-06 01:55:06 +0300 |
commit | 67c57c7e7c27f237f9d36609836ae0f2c6363543 (patch) | |
tree | 28dd7b1dee636323b5a11a3a0fabc1678ad4900b | |
parent | 66510d32bfb94bb26371b068643d8e3ecb320da2 (diff) |
make truecolor work in VT history viewer (fix #1388)
-rw-r--r-- | far2l/src/console/AnsiEsc.hpp | 2 | ||||
-rw-r--r-- | far2l/src/console/interf.cpp | 6 | ||||
-rw-r--r-- | far2l/src/console/interf.hpp | 4 | ||||
-rw-r--r-- | far2l/src/vt/vtlog.cpp | 26 |
4 files changed, 27 insertions, 11 deletions
diff --git a/far2l/src/console/AnsiEsc.hpp b/far2l/src/console/AnsiEsc.hpp index 084a002d..f2278682 100644 --- a/far2l/src/console/AnsiEsc.hpp +++ b/far2l/src/console/AnsiEsc.hpp @@ -47,7 +47,7 @@ namespace AnsiEsc private: Parser _parser; FontState _font_state; - WORD _initial_attr; + DWORD64 _initial_attr; wchar_t _last_char = L' '; void EnforceStateColor(); diff --git a/far2l/src/console/interf.cpp b/far2l/src/console/interf.cpp index 2cd2503c..695a4ded 100644 --- a/far2l/src/console/interf.cpp +++ b/far2l/src/console/interf.cpp @@ -54,7 +54,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. BOOL WINAPI CtrlHandler(DWORD CtrlType); static int CurX,CurY; -static int CurColor; +static DWORD64 CurColor; static volatile DWORD CtrlHandlerEvent = std::numeric_limits<uint32_t>::max(); static CONSOLE_CURSOR_INFO InitialCursorInfo; @@ -778,7 +778,7 @@ void SetColor(int Color, bool ApplyToConsole) } } -void SetRealColor(WORD wAttributes, bool ApplyToConsole) +void SetRealColor(DWORD64 wAttributes, bool ApplyToConsole) { CurColor = wAttributes; if (ApplyToConsole) { @@ -786,7 +786,7 @@ void SetRealColor(WORD wAttributes, bool ApplyToConsole) } } -WORD GetRealColor() +DWORD64 GetRealColor() { return CurColor; } diff --git a/far2l/src/console/interf.hpp b/far2l/src/console/interf.hpp index 35e05e64..f22d336e 100644 --- a/far2l/src/console/interf.hpp +++ b/far2l/src/console/interf.hpp @@ -101,8 +101,8 @@ void SetScreen(int X1,int Y1,int X2,int Y2,wchar_t Ch,int Color); void MakeShadow(int X1,int Y1,int X2,int Y2); void ChangeBlockColor(int X1,int Y1,int X2,int Y2,int Color); void SetColor(int Color, bool ApplyToConsole = false); -void SetRealColor(WORD wAttributes, bool ApplyToConsole = false); -WORD GetRealColor(); +void SetRealColor(DWORD64 wAttributes, bool ApplyToConsole = false); +DWORD64 GetRealColor(); void ClearScreen(int Color); int GetColor(); diff --git a/far2l/src/vt/vtlog.cpp b/far2l/src/vt/vtlog.cpp index 0dbb5539..36364b78 100644 --- a/far2l/src/vt/vtlog.cpp +++ b/far2l/src/vt/vtlog.cpp @@ -57,27 +57,43 @@ namespace VTLog static void EncodeLine(std::string &out, unsigned int Width, const CHAR_INFO *Chars, bool colored) { - WORD attr_prev = 0xffff; + DWORD64 attr_prev = (DWORD64)-1; for (unsigned int i = 0; i < Width; ++i) { - const WORD attr_now = Chars[i].Attributes&0xff; + const DWORD64 attr_now = Chars[i].Attributes; if ( colored && attr_now != attr_prev) { + const bool tc_back_now = (attr_now & BACKGROUND_TRUECOLOR) != 0; + const bool tc_back_prev = (attr_prev & BACKGROUND_TRUECOLOR) != 0; + const bool tc_fore_now = (attr_now & FOREGROUND_TRUECOLOR) != 0; + const bool tc_fore_prev = (attr_prev & FOREGROUND_TRUECOLOR) != 0; + out+= "\033["; - if ( attr_prev == 0xffff + if ( attr_prev == (DWORD64)-1 || (attr_prev&FOREGROUND_INTENSITY) != (attr_now&FOREGROUND_INTENSITY)) { out+= (attr_now&FOREGROUND_INTENSITY) ? "1;" : "22;"; } - if ( attr_prev == 0xffff + if ( attr_prev == (DWORD64)-1 || (tc_fore_prev && !tc_fore_now) || (attr_prev&(FOREGROUND_INTENSITY|FOREGROUND_RGB)) != (attr_now&(FOREGROUND_INTENSITY|FOREGROUND_RGB))) { out+= (attr_now&FOREGROUND_INTENSITY) ? '9' : '3'; out+= '0' + TranslateForegroundColor(attr_now); out+= ';'; } - if ( attr_prev == 0xffff + if ( attr_prev == (DWORD64)-1 || (tc_back_prev && !tc_back_now) || (attr_prev&(BACKGROUND_INTENSITY|BACKGROUND_RGB)) != (attr_now&(BACKGROUND_INTENSITY|BACKGROUND_RGB))) { out+= (attr_now&BACKGROUND_INTENSITY) ? "10" : "4"; out+= '0' + TranslateBackgroundColor(attr_now); out+= ';'; } + + if (tc_fore_now && (!tc_fore_prev || GET_RGB_FORE(attr_prev) != GET_RGB_FORE(attr_now))) { + const DWORD rgb = GET_RGB_FORE(attr_now); + out+= StrPrintf("38;2;%u;%u;%u;", rgb & 0xff, (rgb >> 8) & 0xff, (rgb >> 16) & 0xff); + } + + if (tc_back_now && (!tc_back_prev || GET_RGB_BACK(attr_prev) != GET_RGB_BACK(attr_now))) { + const DWORD rgb = GET_RGB_BACK(attr_now); + out+= StrPrintf("48;2;%u;%u;%u;", rgb & 0xff, (rgb >> 8) & 0xff, (rgb >> 16) & 0xff); + } + assert(out.back() == ';'); out.back() = 'm'; attr_prev = attr_now; |