From 0fefcd81c2c81064f97f28e641d279125f7d95e9 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Fri, 30 Apr 2021 00:28:05 +0200 Subject: [PATCH] Fixes Linux console bug from February 20, 2021 --- ChangeLog | 3 + src/flogger.cpp | 2 +- src/fstatusbar.cpp | 12 +- src/fterm.cpp | 2 +- src/ftermlinux.cpp | 12 +- src/include/final/flogger.h | 2 +- src/include/final/ftermdata.h | 2 +- src/include/final/ftermlinux.h | 2 +- test/ftermlinux-test.cpp | 604 ++++++++++++++++++++++++++++++++- 9 files changed, 624 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5725e959..172e3cb2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2021-04-30 Markus Gans + * Fixes Linux console bug from February 20, 2021 + 2021-04-27 Markus Gans * Code optimization at widget focus diff --git a/src/flogger.cpp b/src/flogger.cpp index 31fcae27..fb021268 100644 --- a/src/flogger.cpp +++ b/src/flogger.cpp @@ -67,7 +67,7 @@ std::string FLogger::getTimeString() const } //---------------------------------------------------------------------- -std::string FLogger::getEOL() +std::string FLogger::getEOL() const { if ( getEnding() == LineEnding::LF ) return "\n"; diff --git a/src/fstatusbar.cpp b/src/fstatusbar.cpp index 6461a693..751eba9d 100644 --- a/src/fstatusbar.cpp +++ b/src/fstatusbar.cpp @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2014-2020 Markus Gans * +* Copyright 2014-2021 Markus Gans * * * * FINAL CUT is free software; you can redistribute it and/or modify * * it under the terms of the GNU Lesser General Public License as * @@ -685,8 +685,14 @@ void FStatusBar::drawActiveKey (FKeyList::const_iterator iter) { print (item->getText()); x++; - setColor (wc->statusbar_bg, wc->statusbar_active_hotkey_bg); - print (UniChar::RightHalfBlock); // ▌ + + if ( FTerm::hasHalfBlockCharacter() ) + { + setColor (wc->statusbar_bg, wc->statusbar_active_hotkey_bg); + print (UniChar::RightHalfBlock); // ▌ + } + else + print (' '); } else { diff --git a/src/fterm.cpp b/src/fterm.cpp index b2a63bd3..ae3f33aa 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -700,7 +700,7 @@ int FTerm::openConsole() int fd = data->getTTYFileDescriptor(); const auto& termfilename = data->getTermFileName(); - if ( ! termfilename.empty() ) + if ( termfilename.empty() ) return 0; if ( fd >= 0 ) // console is already opened diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index f53fa2f2..0af0bb74 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -1132,15 +1132,15 @@ inline void FTermLinux::shiftCtrlAltKeyCorrection() inline void FTermLinux::initSpecialCharacter() const { const auto& fterm_data = FTerm::getFTermData(); - const auto c1 = wchar_t(UniChar::UpperHalfBlock); - const auto c2 = wchar_t(UniChar::LowerHalfBlock); - const auto c3 = wchar_t(UniChar::FullBlock); + const auto c1 = wchar_t(UniChar::UpperHalfBlock); // ▀ + const auto c2 = wchar_t(UniChar::LowerHalfBlock); // ▄ + const auto c3 = wchar_t(UniChar::FullBlock); // █ if ( FTerm::charEncode(c1, Encoding::PC) == FTerm::charEncode(c1, Encoding::ASCII) || FTerm::charEncode(c2, Encoding::PC) == FTerm::charEncode(c2, Encoding::ASCII) || FTerm::charEncode(c3, Encoding::PC) == FTerm::charEncode(c3, Encoding::ASCII) ) { - fterm_data->supportShadowCharacter (false); + fterm_data->supportShadowCharacter (false); // disable support } const auto c4 = wchar_t(UniChar::RightHalfBlock); @@ -1149,7 +1149,7 @@ inline void FTermLinux::initSpecialCharacter() const if ( FTerm::charEncode(c4, Encoding::PC) == FTerm::charEncode(c4, Encoding::ASCII) || FTerm::charEncode(c5, Encoding::PC) == FTerm::charEncode(c5, Encoding::ASCII) ) { - fterm_data->supportHalfBlockCharacter (false); + fterm_data->supportHalfBlockCharacter (false); // disable support } } @@ -1169,7 +1169,7 @@ sInt16 FTermLinux::getFontPos (wchar_t ucs) const //---------------------------------------------------------------------- void FTermLinux::characterFallback ( wchar_t ucs - , std::vector fallback ) const + , const std::vector& fallback ) const { constexpr sInt16 NOT_FOUND = -1; const auto& fterm_data = FTerm::getFTermData(); diff --git a/src/include/final/flogger.h b/src/include/final/flogger.h index 605c0463..a6119327 100644 --- a/src/include/final/flogger.h +++ b/src/include/final/flogger.h @@ -87,7 +87,7 @@ class FLogger : public FLog // Methods void newlineReplace (std::string&, const std::string&) const; std::string getTimeString() const; - std::string getEOL(); + std::string getEOL() const; void printLogLine (const std::string&); // Data member diff --git a/src/include/final/ftermdata.h b/src/include/final/ftermdata.h index 6e4d5ac6..2fc5ce8d 100644 --- a/src/include/final/ftermdata.h +++ b/src/include/final/ftermdata.h @@ -138,7 +138,7 @@ class FTermData final FString exit_message{}; Encoding term_encoding{Encoding::Unknown}; int fd_tty{-1}; // Teletype (tty) file descriptor - // is still undefined + // is still undefined #if DEBUG int framebuffer_bpp{-1}; #endif diff --git a/src/include/final/ftermlinux.h b/src/include/final/ftermlinux.h index d119c0c7..f9d0b89b 100644 --- a/src/include/final/ftermlinux.h +++ b/src/include/final/ftermlinux.h @@ -221,7 +221,7 @@ class FTermLinux final void shiftCtrlAltKeyCorrection(); void initSpecialCharacter() const; sInt16 getFontPos (wchar_t ucs) const; - void characterFallback (wchar_t, std::vector) const; + void characterFallback (wchar_t, const std::vector&) const; // Data members #if defined(__linux__) diff --git a/test/ftermlinux-test.cpp b/test/ftermlinux-test.cpp index 55df8a0e..b02f9567 100644 --- a/test/ftermlinux-test.cpp +++ b/test/ftermlinux-test.cpp @@ -98,6 +98,12 @@ class FSystemTest : public finalcut::FSystem data }; + enum class Codeset + { + cp437, + lat15 + }; + // Constructor FSystemTest(); @@ -123,6 +129,7 @@ class FSystemTest : public finalcut::FSystem console_font_op& getConsoleFont(); ShiftState& getShiftState(); std::string& getCharacters(); + void setCodeset (Codeset); private: // Methods @@ -151,8 +158,10 @@ class FSystemTest : public finalcut::FSystem bool palette_addr_source_field{true}; uChar port_3cc{0x67}; // Miscellaneous output uChar port_3da{0}; // Input status 1 + Codeset codeset{Codeset::cp437}; static uChar vga8x16[]; static struct unipair unicode_cp437_pairs[]; + static struct unipair unicode_lat15_pairs[]; }; @@ -950,6 +959,487 @@ struct unipair FSystemTest::unicode_cp437_pairs[] = {0x266c, 0x0e} }; +struct unipair FSystemTest::unicode_lat15_pairs[] = +{ + // .----------- unicode + // | .---- fontpos + // | | + {0x0020, 0x20}, + {0x0021, 0x21}, + {0x0022, 0x22}, + {0x0023, 0x23}, + {0x0024, 0x24}, + {0x0025, 0x25}, + {0x0026, 0x26}, + {0x0027, 0x27}, + {0x0028, 0x28}, + {0x0029, 0x29}, + {0x002a, 0x2a}, + {0x002b, 0x2b}, + {0x002c, 0x2c}, + {0x002d, 0x2d}, + {0x002e, 0x2e}, + {0x002f, 0x2f}, + {0x0030, 0x30}, + {0x0031, 0x31}, + {0x0032, 0x32}, + {0x0033, 0x33}, + {0x0034, 0x34}, + {0x0035, 0x35}, + {0x0036, 0x36}, + {0x0037, 0x37}, + {0x0038, 0x38}, + {0x0039, 0x39}, + {0x003a, 0x3a}, + {0x003b, 0x3b}, + {0x003c, 0x3c}, + {0x003d, 0x3d}, + {0x003e, 0x3e}, + {0x003f, 0x3f}, + {0x0040, 0x40}, + {0x0041, 0x41}, + {0x0042, 0x42}, + {0x0043, 0x43}, + {0x0044, 0x44}, + {0x0045, 0x45}, + {0x0046, 0x46}, + {0x0047, 0x47}, + {0x0048, 0x48}, + {0x0049, 0x49}, + {0x004a, 0x4a}, + {0x004b, 0x4b}, + {0x004c, 0x4c}, + {0x004d, 0x4d}, + {0x004e, 0x4e}, + {0x004f, 0x4f}, + {0x0050, 0x50}, + {0x0051, 0x51}, + {0x0052, 0x52}, + {0x0053, 0x53}, + {0x0054, 0x54}, + {0x0055, 0x55}, + {0x0056, 0x56}, + {0x0057, 0x57}, + {0x0058, 0x58}, + {0x0059, 0x59}, + {0x005a, 0x5a}, + {0x005b, 0x5b}, + {0x005c, 0x5c}, + {0x005d, 0x5d}, + {0x005e, 0x5e}, + {0x005f, 0x5f}, + {0x0060, 0x60}, + {0x0061, 0x61}, + {0x0062, 0x62}, + {0x0063, 0x63}, + {0x0064, 0x64}, + {0x0065, 0x65}, + {0x0066, 0x66}, + {0x0067, 0x67}, + {0x0068, 0x68}, + {0x0069, 0x69}, + {0x006a, 0x6a}, + {0x006b, 0x6b}, + {0x006c, 0x6c}, + {0x006d, 0x6d}, + {0x006e, 0x6e}, + {0x006f, 0x6f}, + {0x0070, 0x70}, + {0x0071, 0x71}, + {0x0072, 0x72}, + {0x0073, 0x73}, + {0x0074, 0x74}, + {0x0075, 0x75}, + {0x0076, 0x76}, + {0x0077, 0x77}, + {0x0078, 0x78}, + {0x0079, 0x79}, + {0x007a, 0x7a}, + {0x007b, 0x7b}, + {0x007c, 0x7c}, + {0x007d, 0x7d}, + {0x007e, 0x7e}, + {0x00a0, 0x20}, + {0x00a1, 0xad}, + {0x00a2, 0x9b}, + {0x00a3, 0x9c}, + {0x00a4, 0x11}, + {0x00a5, 0x9d}, + {0x00a6, 0x12}, + {0x00a7, 0x15}, + {0x00a8, 0x16}, + {0x00a9, 0x00}, + {0x00aa, 0xa6}, + {0x00ab, 0xae}, + {0x00ac, 0xaa}, + {0x00ad, 0x2d}, + {0x00ae, 0x01}, + {0x00af, 0x17}, + {0x00b0, 0xf8}, + {0x00b1, 0xf1}, + {0x00b2, 0xfd}, + {0x00b3, 0x1c}, + {0x00b4, 0x1d}, + {0x00b5, 0xe6}, + {0x00b6, 0x14}, + {0x00b7, 0xfa}, + {0x00b8, 0x1e}, + {0x00b9, 0x1f}, + {0x00ba, 0xa7}, + {0x00bb, 0xaf}, + {0x00bc, 0xac}, + {0x00bd, 0xab}, + {0x00be, 0x7f}, + {0x00bf, 0xa8}, + {0x00c0, 0xa9}, + {0x00c1, 0xb2}, + {0x00c2, 0xb5}, + {0x00c3, 0xb6}, + {0x00c4, 0x8e}, + {0x00c5, 0x8f}, + {0x00c6, 0x92}, + {0x00c7, 0x80}, + {0x00c8, 0xb7}, + {0x00c9, 0x90}, + {0x00ca, 0xb8}, + {0x00cb, 0xb9}, + {0x00cc, 0xba}, + {0x00cd, 0xbb}, + {0x00ce, 0xbc}, + {0x00cf, 0xbd}, + {0x00d0, 0xbe}, + {0x00d1, 0xa5}, + {0x00d2, 0xc6}, + {0x00d3, 0xc7}, + {0x00d4, 0xc8}, + {0x00d5, 0xc9}, + {0x00d6, 0x99}, + {0x00d7, 0xca}, + {0x00d8, 0xcb}, + {0x00d9, 0xcc}, + {0x00da, 0xcd}, + {0x00db, 0xcf}, + {0x00dc, 0x9a}, + {0x00dd, 0x02}, + {0x00de, 0xd0}, + {0x00df, 0xe1}, + {0x00e0, 0x85}, + {0x00e1, 0xa0}, + {0x00e2, 0x83}, + {0x00e3, 0xd1}, + {0x00e4, 0x84}, + {0x00e5, 0x86}, + {0x00e6, 0x91}, + {0x00e7, 0x87}, + {0x00e8, 0x8a}, + {0x00e9, 0x82}, + {0x00ea, 0x88}, + {0x00eb, 0x89}, + {0x00ec, 0x8d}, + {0x00ed, 0xa1}, + {0x00ee, 0x8c}, + {0x00ef, 0x8b}, + {0x00f0, 0xd2}, + {0x00f1, 0xa4}, + {0x00f2, 0x95}, + {0x00f3, 0xa2}, + {0x00f4, 0x93}, + {0x00f5, 0xd3}, + {0x00f6, 0x94}, + {0x00f7, 0xf6}, + {0x00f8, 0xd4}, + {0x00f9, 0x97}, + {0x00fa, 0xa3}, + {0x00fb, 0x96}, + {0x00fc, 0x81}, + {0x00fd, 0xd5}, + {0x00fe, 0xd6}, + {0x00ff, 0x98}, + {0x0110, 0xbe}, + {0x011e, 0xd7}, + {0x011f, 0xdc}, + {0x0130, 0xdd}, + {0x0131, 0xde}, + {0x0152, 0x03}, + {0x0153, 0x05}, + {0x015e, 0xdf}, + {0x015f, 0xe0}, + {0x0160, 0xe2}, + {0x0161, 0xe4}, + {0x0178, 0x06}, + {0x017d, 0xe5}, + {0x017e, 0xe7}, + {0x0192, 0x9f}, + {0x02c6, 0xe8}, + {0x02c9, 0x17}, + {0x02dc, 0xe9}, + {0x0391, 0x41}, + {0x0392, 0x42}, + {0x0395, 0x45}, + {0x0396, 0x5a}, + {0x0397, 0x48}, + {0x0399, 0x49}, + {0x039a, 0x4b}, + {0x039c, 0x4d}, + {0x039d, 0x4e}, + {0x039f, 0x4f}, + {0x03a1, 0x50}, + {0x03a4, 0x54}, + {0x03a7, 0x58}, + {0x03bc, 0xe6}, + {0x03c0, 0xe3}, + {0x0401, 0xb9}, + {0x0405, 0x53}, + {0x0406, 0x49}, + {0x0407, 0xbd}, + {0x0408, 0x4a}, + {0x0410, 0x41}, + {0x0412, 0x42}, + {0x0415, 0x45}, + {0x041a, 0x4b}, + {0x041c, 0x4d}, + {0x041d, 0x48}, + {0x041e, 0x4f}, + {0x0420, 0x50}, + {0x0421, 0x43}, + {0x0422, 0x54}, + {0x0425, 0x58}, + {0x0430, 0x61}, + {0x0435, 0x65}, + {0x043e, 0x6f}, + {0x0440, 0x70}, + {0x0441, 0x63}, + {0x0443, 0x79}, + {0x0445, 0x78}, + {0x0451, 0x89}, + {0x0455, 0x73}, + {0x0456, 0x69}, + {0x0457, 0x8b}, + {0x0458, 0x6a}, + {0x04ae, 0x59}, + {0x2000, 0x20}, + {0x2001, 0x20}, + {0x2002, 0x20}, + {0x2003, 0x20}, + {0x2004, 0x20}, + {0x2005, 0x20}, + {0x2006, 0x20}, + {0x2007, 0x20}, + {0x2008, 0x20}, + {0x2009, 0x20}, + {0x200a, 0x20}, + {0x2010, 0x2d}, + {0x2011, 0x2d}, + {0x2012, 0x2d}, + {0x2013, 0x2d}, + {0x2014, 0x07}, + {0x2015, 0x07}, + {0x2018, 0xea}, + {0x2019, 0xeb}, + {0x201a, 0xec}, + {0x201c, 0xed}, + {0x201d, 0xee}, + {0x201e, 0xef}, + {0x2020, 0x08}, + {0x2021, 0x09}, + {0x2022, 0x0a}, + {0x2026, 0x0b}, + {0x202f, 0x20}, + {0x2030, 0x0c}, + {0x2039, 0xf4}, + {0x203a, 0xf5}, + {0x203c, 0x13}, + {0x207f, 0xfc}, + {0x20a7, 0x9e}, + {0x20ac, 0xf9}, + {0x20ae, 0x0f}, + {0x2116, 0x0e}, + {0x2122, 0x0d}, + {0x212a, 0x4b}, + {0x212b, 0x8f}, + {0x2190, 0x1b}, + {0x2191, 0x18}, + {0x2192, 0x1a}, + {0x2193, 0x19}, + {0x2205, 0x10}, + {0x2208, 0xff}, + {0x2212, 0x2d}, + {0x2248, 0xf7}, + {0x2260, 0xfb}, + {0x2261, 0xf0}, + {0x2264, 0xf3}, + {0x2265, 0xf2}, + {0x226a, 0xae}, + {0x226b, 0xaf}, + {0x2295, 0x25}, + {0x2296, 0x2d}, + {0x2298, 0x2f}, + {0x2299, 0x2e}, + {0x229b, 0x2a}, + {0x229c, 0x3d}, + {0x2460, 0x31}, + {0x2461, 0x32}, + {0x2462, 0x33}, + {0x2463, 0x34}, + {0x2464, 0x35}, + {0x2465, 0x36}, + {0x2466, 0x37}, + {0x2467, 0x38}, + {0x2468, 0x39}, + {0x24b6, 0x41}, + {0x24b7, 0x42}, + {0x24b8, 0x43}, + {0x24b9, 0x44}, + {0x24ba, 0x45}, + {0x24bb, 0x46}, + {0x24bc, 0x47}, + {0x24bd, 0x48}, + {0x24be, 0x49}, + {0x24bf, 0x4a}, + {0x24c0, 0x4b}, + {0x24c1, 0x4c}, + {0x24c2, 0x4d}, + {0x24c3, 0x4e}, + {0x24c4, 0x4f}, + {0x24c5, 0x50}, + {0x24c6, 0x51}, + {0x24c7, 0x52}, + {0x24c8, 0x53}, + {0x24c9, 0x54}, + {0x24ca, 0x55}, + {0x24cb, 0x56}, + {0x24cc, 0x57}, + {0x24cd, 0x58}, + {0x24ce, 0x59}, + {0x24cf, 0x5a}, + {0x24d0, 0x61}, + {0x24d1, 0x62}, + {0x24d2, 0x63}, + {0x24d3, 0x64}, + {0x24d4, 0x65}, + {0x24d5, 0x66}, + {0x24d6, 0x67}, + {0x24d7, 0x68}, + {0x24d8, 0x69}, + {0x24d9, 0x6a}, + {0x24da, 0x6b}, + {0x24db, 0x6c}, + {0x24dc, 0x6d}, + {0x24dd, 0x6e}, + {0x24de, 0x6f}, + {0x24df, 0x70}, + {0x24e0, 0x71}, + {0x24e1, 0x72}, + {0x24e2, 0x73}, + {0x24e3, 0x74}, + {0x24e4, 0x75}, + {0x24e5, 0x76}, + {0x24e6, 0x77}, + {0x24e7, 0x78}, + {0x24e8, 0x79}, + {0x24e9, 0x7a}, + {0x24ea, 0x30}, + {0x2500, 0xc4}, + {0x2501, 0xc4}, + {0x2502, 0xb3}, + {0x2503, 0xb3}, + {0x250c, 0xda}, + {0x250d, 0xda}, + {0x250e, 0xda}, + {0x250f, 0xda}, + {0x2510, 0xbf}, + {0x2511, 0xbf}, + {0x2512, 0xbf}, + {0x2513, 0xbf}, + {0x2514, 0xc0}, + {0x2515, 0xc0}, + {0x2516, 0xc0}, + {0x2517, 0xc0}, + {0x2518, 0xd9}, + {0x2519, 0xd9}, + {0x251a, 0xd9}, + {0x251b, 0xd9}, + {0x251c, 0xc3}, + {0x251d, 0xc3}, + {0x251e, 0xc3}, + {0x251f, 0xc3}, + {0x2520, 0xc3}, + {0x2521, 0xc3}, + {0x2522, 0xc3}, + {0x2523, 0xc3}, + {0x2524, 0xb4}, + {0x2525, 0xb4}, + {0x2526, 0xb4}, + {0x2527, 0xb4}, + {0x2528, 0xb4}, + {0x2529, 0xb4}, + {0x252a, 0xb4}, + {0x252b, 0xb4}, + {0x252c, 0xc2}, + {0x252d, 0xc2}, + {0x252e, 0xc2}, + {0x252f, 0xc2}, + {0x2530, 0xc2}, + {0x2531, 0xc2}, + {0x2532, 0xc2}, + {0x2533, 0xc2}, + {0x2534, 0xc1}, + {0x2535, 0xc1}, + {0x2536, 0xc1}, + {0x2537, 0xc1}, + {0x2538, 0xc1}, + {0x2539, 0xc1}, + {0x253a, 0xc1}, + {0x253b, 0xc1}, + {0x253c, 0xc5}, + {0x253d, 0xc5}, + {0x253e, 0xc5}, + {0x253f, 0xc5}, + {0x2540, 0xc5}, + {0x2541, 0xc5}, + {0x2542, 0xc5}, + {0x2543, 0xc5}, + {0x2544, 0xc5}, + {0x2545, 0xc5}, + {0x2546, 0xc5}, + {0x2547, 0xc5}, + {0x2548, 0xc5}, + {0x2549, 0xc5}, + {0x254a, 0xc5}, + {0x254b, 0xc5}, + {0x256a, 0xd8}, + {0x256c, 0xce}, + {0x2574, 0xc4}, + {0x2575, 0xb3}, + {0x2576, 0xc4}, + {0x2577, 0xb3}, + {0x2578, 0xc4}, + {0x2579, 0xb3}, + {0x257a, 0xc4}, + {0x257b, 0xb3}, + {0x257c, 0xc4}, + {0x257d, 0xb3}, + {0x257e, 0xc4}, + {0x257f, 0xb3}, + {0x2588, 0xdb}, + {0x2591, 0xb0}, + {0x2592, 0xb1}, + {0x25a0, 0xfe}, + {0x25ae, 0xfe}, + {0x25b2, 0x18}, + {0x25b4, 0x18}, + {0x25b6, 0x1a}, + {0x25b8, 0x1a}, + {0x25bc, 0x19}, + {0x25be, 0x19}, + {0x25c0, 0x1b}, + {0x25c2, 0x1b}, + {0x25c8, 0x04}, + {0x25cf, 0x0a}, + {0x2666, 0x04}, + {0xfffd, 0x04} +}; + FSystemTest::RGB FSystemTest::terminal_color[16] { }; FSystemTest::RGB FSystemTest::defaultColor[16] @@ -1210,15 +1700,22 @@ int FSystemTest::ioctl (int fd, uLong request, ...) { req_string = "GIO_UNIMAP"; unimapdesc* umap = static_cast(argp); - std::size_t pairs = sizeof(unicode_cp437_pairs) / sizeof(unipair); - std::size_t pairs_size = pairs * sizeof(unipair); + std::size_t unipair_size = sizeof(unipair); + std::size_t pairs = ( codeset == Codeset::cp437 ) + ? sizeof(unicode_cp437_pairs) / unipair_size + : sizeof(unicode_lat15_pairs) / unipair_size; + std::size_t pairs_size = pairs * unipair_size; // Sets the default unicode map of the terminal on the first call if ( ! terminal_unicode_map.entries ) { terminal_unicode_map.entry_ct = pairs; terminal_unicode_map.entries = new unipair[pairs](); - std::memcpy (terminal_unicode_map.entries, &unicode_cp437_pairs, pairs_size); + + if ( codeset == Codeset::cp437 ) + std::memcpy (terminal_unicode_map.entries, &unicode_cp437_pairs, pairs_size); + else + std::memcpy (terminal_unicode_map.entries, &unicode_lat15_pairs, pairs_size); } umap->entry_ct = terminal_unicode_map.entry_ct; @@ -1433,6 +1930,13 @@ std::string& FSystemTest::getCharacters() return characters; } +//---------------------------------------------------------------------- +void FSystemTest::setCodeset (Codeset cs) +{ + codeset = cs; +} + + // private methods of FSystemTest //---------------------------------------------------------------------- void FSystemTest::initVScreenInfo() @@ -1520,6 +2024,7 @@ class FTermLinuxTest : public CPPUNIT_NS::TestFixture, test::ConEmu protected: void classNameTest(); void linuxConsoleTest(); + void linuxConsoleLat15Test(); void linuxCursorStyleTest(); void linuxColorPaletteTest(); void linuxFontTest(); @@ -1532,6 +2037,7 @@ class FTermLinuxTest : public CPPUNIT_NS::TestFixture, test::ConEmu // Add a methods to the test suite CPPUNIT_TEST (classNameTest); CPPUNIT_TEST (linuxConsoleTest); + CPPUNIT_TEST (linuxConsoleLat15Test); CPPUNIT_TEST (linuxCursorStyleTest); CPPUNIT_TEST (linuxColorPaletteTest); CPPUNIT_TEST (linuxFontTest); @@ -1660,7 +2166,99 @@ void FTermLinuxTest::linuxConsoleTest() CPPUNIT_ASSERT ( character_map[wchar_t(finalcut::UniChar::BlackCircle)] == L'*' ); CPPUNIT_ASSERT ( character_map[wchar_t(finalcut::UniChar::Times)] == L'x' ); CPPUNIT_ASSERT ( character_map[L'ˣ'] == L'ⁿ' ); + linux.finish(); + closeConEmuStdStreams(); + exit(EXIT_SUCCESS); + } + else // Parent + { + // Start the terminal emulation + startConEmuTerminal (ConEmu::console::linux_con); + + if ( waitpid(pid, 0, WUNTRACED) != pid ) + std::cerr << "waitpid error" << std::endl; + } +} + +//---------------------------------------------------------------------- +void FTermLinuxTest::linuxConsoleLat15Test() +{ + std::unique_ptr fsys = finalcut::make_unique(); + auto fsystest = static_cast(fsys.get()); + fsystest->setCodeset(test::FSystemTest::Codeset::lat15); + finalcut::FTerm::setFSystem(fsys); + std::cout << "\n"; + const auto& data = finalcut::FTerm::getFTermData(); + + auto& encoding_list = data->getEncodingList(); + encoding_list["UTF-8"] = finalcut::Encoding::UTF8; + encoding_list["UTF8"] = finalcut::Encoding::UTF8; + encoding_list["VT100"] = finalcut::Encoding::VT100; + encoding_list["PC"] = finalcut::Encoding::PC; + encoding_list["ASCII"] = finalcut::Encoding::ASCII; + + data->setTermEncoding(finalcut::Encoding::PC); + data->setBaudrate(38400); + data->setTermType("linux"); + data->setTermFileName("/dev/tty3"); + data->setTTYFileDescriptor(0); + +#if DEBUG + data->setFramebufferBpp(32); +#endif + + data->supportShadowCharacter (true); + data->supportHalfBlockCharacter (true); + data->supportCursorOptimisation (true); + data->setCursorHidden (true); + data->useAlternateScreen (false); + data->setASCIIConsole (true); + data->setVT100Console (false); + data->setUTF8Console (false); + data->setUTF8 (false); + data->setNewFont (false); + data->setVGAFont (false); + data->setMonochron (false); + data->setTermResized (false); + + const auto& term_detection = finalcut::FTerm::getFTermDetection(); + finalcut::FTermLinux linux; + + // setupterm is needed for tputs in ncurses >= 6.1 + setupterm (static_cast(0), 1, static_cast(0)); + term_detection->setLinuxTerm(true); + + pid_t pid = forkConEmu(); + + if ( isConEmuChildProcess(pid) ) + { + setenv ("TERM", "linux", 1); + setenv ("COLUMNS", "90", 1); + setenv ("LINES", "30", 1); + unsetenv("TERMCAP"); + unsetenv("COLORTERM"); + unsetenv("COLORFGBG"); + unsetenv("VTE_VERSION"); + unsetenv("XTERM_VERSION"); + unsetenv("ROXTERM_ID"); + unsetenv("KONSOLE_DBUS_SESSION"); + unsetenv("KONSOLE_DCOP"); + unsetenv("TMUX"); + + term_detection->detect(); + + linux.init(); + linux.initCharMap(); + CPPUNIT_ASSERT ( finalcut::FTerm::isLinuxTerm() ); + CPPUNIT_ASSERT ( ! data->hasShadowCharacter() ); + CPPUNIT_ASSERT ( ! data->hasHalfBlockCharacter() ); + auto& character_map = data->getCharSubstitutionMap(); + CPPUNIT_ASSERT ( character_map.size() == 4 ); + CPPUNIT_ASSERT ( character_map[wchar_t(finalcut::UniChar::SquareRoot)] == L'x' ); + CPPUNIT_ASSERT ( character_map[wchar_t(finalcut::UniChar::BlackLeftPointingPointer)] == L'◀' ); + CPPUNIT_ASSERT ( character_map[wchar_t(finalcut::UniChar::BlackRightPointingPointer)] == L'▶' ); + CPPUNIT_ASSERT ( character_map[L'ˣ'] == L'ⁿ' ); linux.finish(); closeConEmuStdStreams();