From 838ba23c46a3ded64d4dfe42a1407f6335183a99 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Thu, 3 Jan 2019 07:36:18 +0100 Subject: [PATCH] Integration of an output filter to replace missing characters --- ChangeLog | 5 ++- examples/mouse.cpp | 4 +- examples/scrollview.cpp | 4 +- examples/treeview.cpp | 4 +- src/fmenu.cpp | 6 +-- src/fterm.cpp | 7 +-- src/ftermios.cpp | 6 +-- src/ftermlinux.cpp | 68 +++++++++++++++++++++++------- src/fvterm.cpp | 11 ++++- src/include/final/fc.h | 1 + src/include/final/fcharmap.h | 1 + src/include/final/fcheckmenuitem.h | 4 +- src/include/final/flistview.h | 4 +- src/include/final/fmouse.h | 10 ++--- src/include/final/fradiomenuitem.h | 8 ++-- src/include/final/fscrollview.h | 4 +- src/include/final/fterm.h | 6 +++ src/include/final/ftermcap.h | 4 +- src/include/final/ftermdata.h | 13 ++++-- src/include/final/ftermlinux.h | 9 ++++ src/include/final/fvterm.h | 5 ++- src/include/final/fwidget.h | 12 +++--- test/ftermdata-test.cpp | 16 ++++++- 23 files changed, 151 insertions(+), 61 deletions(-) diff --git a/ChangeLog b/ChangeLog index 55a206e8..ccd563be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ -2019-01-02 Markus Gans +2019-01-03 Markus Gans * Improved PC encoding for Cygwin and Linux + * Integration of an output filter to replace missing characters + * Better Linux console support for UTF-8 encoding + (Default is PC charset encoding) 2018-12-31 Markus Gans * Use the override specifier diff --git a/examples/mouse.cpp b/examples/mouse.cpp index 9219552e..7ff85c74 100644 --- a/examples/mouse.cpp +++ b/examples/mouse.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2017-2018 Markus Gans * +* Copyright 2017-2019 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -324,7 +324,7 @@ class MouseDraw : public finalcut::FDialog MouseDraw& operator = (const MouseDraw&) = delete; // Methods - void setGeometry (int, int, std::size_t, std::size_t, bool = true); + void setGeometry (int, int, std::size_t, std::size_t, bool = true) override; // Event handlers virtual void onAccel (finalcut::FAccelEvent*) override; diff --git a/examples/scrollview.cpp b/examples/scrollview.cpp index 37138c34..8f75aebf 100644 --- a/examples/scrollview.cpp +++ b/examples/scrollview.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2017-2018 Markus Gans * +* Copyright 2017-2019 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -46,7 +46,7 @@ class Scrollview : public finalcut::FScrollView Scrollview& operator = (const Scrollview&) = delete; // Mutator - void setScrollSize (std::size_t, std::size_t); + void setScrollSize (std::size_t, std::size_t) override; private: // Method diff --git a/examples/treeview.cpp b/examples/treeview.cpp index 2eef467d..7f9d8846 100644 --- a/examples/treeview.cpp +++ b/examples/treeview.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2017-2018 Markus Gans * +* Copyright 2017-2019 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -134,7 +134,7 @@ class Treeview : public finalcut::FDialog virtual void adjustSize() override; // Event handler - void onClose (finalcut::FCloseEvent*); + void onClose (finalcut::FCloseEvent*) override; // Data Members bool initialized{false}; diff --git a/src/fmenu.cpp b/src/fmenu.cpp index 065557e5..da249403 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2015-2018 Markus Gans * +* Copyright 2015-2019 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -1358,7 +1358,7 @@ inline void FMenu::drawCheckMarkPrefix (FMenuItem* menuitem) if ( isNewFont() ) print (fc::NF_Bullet); // NF_Bullet ● else - print (fc::Bullet); // Bullet ● + print (fc::BlackCircle); // BlackCircle ● } else { @@ -1396,7 +1396,7 @@ inline void FMenu::drawMenuText (menuText& data) if ( ! isNewFont() && ( int(data.text[z]) < fc::NF_rev_left_arrow2 || int(data.text[z]) > fc::NF_check_mark ) - && ! charEncodable(uInt(data.text[z])) ) + && ! charEncodable(wchar_t(data.text[z])) ) { data.text[z] = L' '; } diff --git a/src/fterm.cpp b/src/fterm.cpp index 9c1f0df6..249ad834 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -21,7 +21,7 @@ ***********************************************************************/ #include -#include +#include #include #include @@ -758,7 +758,7 @@ uChar FTerm::unicode_to_cp437 (wchar_t ucs) { if ( fc::cp437_to_ucs[i][UNICODE] == ucs ) // found { - c = fc::cp437_to_ucs[i][CP437]; + c = uChar(fc::cp437_to_ucs[i][CP437]); break; } } @@ -987,7 +987,7 @@ void FTerm::init_alt_charset() { // Read the used VT100 pairs - std::map vt100_alt_char; + std::unordered_map vt100_alt_char; if ( TCAP(fc::t_acs_chars) ) { @@ -1902,6 +1902,7 @@ void FTerm::init (bool disable_alt_screen) void FTerm::initOSspecifics() { #if defined(__linux__) + linux->setFTermData(data); linux->setFTermDetection(term_detection); linux->init(); // Initialize Linux console diff --git a/src/ftermios.cpp b/src/ftermios.cpp index e7f5706a..cb18c3f1 100644 --- a/src/ftermios.cpp +++ b/src/ftermios.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2018 Markus Gans * +* Copyright 2018-2019 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -24,7 +24,7 @@ #undef __STRICT_ANSI__ // need for fileno #endif -#include +#include #include "final/ftermios.h" #include "final/fterm.h" @@ -209,7 +209,7 @@ bool FTermios::setRawMode (bool enable) //---------------------------------------------------------------------- uInt FTermios::getBaudRate() { - std::map outspeed; + std::unordered_map outspeed; outspeed[B0] = 0; // hang up outspeed[B50] = 50; // 50 baud outspeed[B75] = 75; // 75 baud diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index 2a9fbe1d..1ac7c85b 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -44,6 +44,7 @@ namespace finalcut bool FTermLinux::half_block_character = true; bool FTermLinux::has_saved_palette = false; + FTermData* FTermLinux::fterm_data = nullptr; FTermDetection* FTermLinux::term_detection = nullptr; fc::linuxConsoleCursorStyle FTermLinux::linux_console_cursor_style; FTermLinux::ColorMap FTermLinux::saved_color_map; @@ -200,12 +201,27 @@ void FTermLinux::initCharMap (uInt char_map[][fc::NUM_OF_ENCODINGS]) { for (std::size_t i = 0; i <= fc::lastCharItem; i++ ) { - wchar_t ucs = char_map[i][fc::UTF8]; + auto ucs = wchar_t(char_map[i][fc::UTF8]); sInt16 fontpos = getFontPos(ucs); // Fix for a non-cp437 Linux console with PC charset encoding if ( fontpos > 255 || fontpos == NOT_FOUND ) char_map[i][fc::PC] = char_map[i][fc::ASCII]; + + // Character substitutions for missing characters + if ( fontpos == NOT_FOUND ) + { + characterFallback (ucs, { L'▲', L'↑', L'^' }); + characterFallback (ucs, { L'▼', L'↓', L'v' }); + characterFallback (ucs, { L'►', L'▶', L'→', L'>' }); + characterFallback (ucs, { L'◄', L'◀', L'←', L'<' }); + characterFallback (ucs, { L'●', L'◆', L'⬤', L'*' }); + characterFallback (ucs, { L'•', L'●', L'◆', L'⬤', L'*' }); + characterFallback (ucs, { L'×', L'❌', L'x' }); + characterFallback (ucs, { L'÷', L'➗', L'/' }); + characterFallback (ucs, { L'√', L'✓', L'x' }); + characterFallback (ucs, { L'ˣ', L'ⁿ', L'ˆ', L'`' }); + } } } @@ -856,14 +872,14 @@ bool FTermLinux::resetVGAPalette() { rgb defaultColor[16] = { - {0x00, 0x00, 0x00}, {0xAA, 0x00, 0x00}, - {0x00, 0xAA, 0x00}, {0xAA, 0x55, 0x00}, - {0x00, 0x00, 0xAA}, {0xAA, 0x00, 0xAA}, - {0x00, 0xAA, 0xAA}, {0xAA, 0xAA, 0xAA}, - {0x55, 0x55, 0x55}, {0xFF, 0x55, 0x55}, - {0x55, 0xFF, 0x55}, {0xFF, 0xFF, 0x55}, - {0x55, 0x55, 0xFF}, {0xFF, 0x55, 0xFF}, - {0x55, 0xFF, 0xFF}, {0xFF, 0xFF, 0xFF} + {0x00, 0x00, 0x00}, {0xaa, 0x00, 0x00}, + {0x00, 0xaa, 0x00}, {0xaa, 0x55, 0x00}, + {0x00, 0x00, 0xaa}, {0xaa, 0x00, 0xaa}, + {0x00, 0xaa, 0xaa}, {0xaa, 0xaa, 0xaa}, + {0x55, 0x55, 0x55}, {0xff, 0x55, 0x55}, + {0x55, 0xff, 0x55}, {0xff, 0xff, 0x55}, + {0x55, 0x55, 0xff}, {0xff, 0x55, 0xff}, + {0x55, 0xff, 0xff}, {0xff, 0xff, 0xff} }; for (std::size_t index = 0; index < 16; index++) @@ -1164,9 +1180,9 @@ FKey FTermLinux::shiftCtrlAltKeyCorrection (const FKey& key_id) //---------------------------------------------------------------------- inline void FTermLinux::initSpecialCharacter() { - uInt c1 = fc::UpperHalfBlock; - uInt c2 = fc::LowerHalfBlock; - uInt c3 = fc::FullBlock; + wchar_t c1 = fc::UpperHalfBlock; + wchar_t c2 = fc::LowerHalfBlock; + wchar_t c3 = fc::FullBlock; if ( FTerm::charEncode(c1, fc::PC) == FTerm::charEncode(c1, fc::ASCII) || FTerm::charEncode(c2, fc::PC) == FTerm::charEncode(c2, fc::ASCII) @@ -1175,8 +1191,8 @@ inline void FTermLinux::initSpecialCharacter() shadow_character = false; } - uInt c4 = fc::RightHalfBlock; - uInt c5 = fc::LeftHalfBlock; + wchar_t c4 = fc::RightHalfBlock; + wchar_t c5 = fc::LeftHalfBlock; if ( FTerm::charEncode(c4, fc::PC) == FTerm::charEncode(c4, fc::ASCII) || FTerm::charEncode(c5, fc::PC) == FTerm::charEncode(c5, fc::ASCII) ) @@ -1191,12 +1207,34 @@ sInt16 FTermLinux::getFontPos (wchar_t ucs) for (std::size_t n = 0; n < screen_unicode_map.entry_ct; n++) { if ( screen_unicode_map.entries[n].unicode == ucs ) - return screen_unicode_map.entries[n].fontpos; + return sInt16(screen_unicode_map.entries[n].fontpos); } return -1; } +//---------------------------------------------------------------------- +void FTermLinux::characterFallback ( wchar_t ucs + , std::vector fallback ) +{ + constexpr sInt16 NOT_FOUND = -1; + characterSub& sub_map = fterm_data->getCharSubstitutionMap(); + + if ( fallback.size() < 2 || ucs != fallback[0] ) + return; + + for (auto iter = fallback.begin() + 1; iter != fallback.end(); iter++) + { + sInt16 pos = getFontPos(*iter); + + if ( pos != NOT_FOUND ) + { + sub_map[ucs] = *iter; + return; + } + } +} + #endif // defined(__linux__) } // namespace finalcut diff --git a/src/fvterm.cpp b/src/fvterm.cpp index 41b07aa8..589cbfc2 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -2799,8 +2799,8 @@ inline void FVTerm::appendChar (charData*& next_char) { newFontChanges (next_char); charsetChanges (next_char); - appendAttributes (next_char); + characterFilter (next_char); appendOutputBuffer (next_char->encoded_code); } @@ -2878,6 +2878,15 @@ int FVTerm::appendLowerRight (charData*& screen_char) return screen_char->code; } +//---------------------------------------------------------------------- +inline void FVTerm::characterFilter (charData*& next_char) +{ + FTerm::characterSub& sub_map = fterm->getCharSubstitutionMap(); + + if ( sub_map[next_char->encoded_code] ) + next_char->encoded_code = sub_map[next_char->encoded_code]; +} + //---------------------------------------------------------------------- inline void FVTerm::appendOutputBuffer (const std::string& s) { diff --git a/src/include/final/fc.h b/src/include/final/fc.h index d3aebe64..1971e82c 100644 --- a/src/include/final/fc.h +++ b/src/include/final/fc.h @@ -163,6 +163,7 @@ enum SpecialCharacter : wchar_t BlackVerticalRectangle = 0x25ae, // ▮ (1) SmallBullet = 0x00b7, // · BlackDiamondSuit = 0x2666, // ◆ + BlackCircle = 0x25cf, // ● SymbolForNewline = 0x2424, // ␤ (1) SymbolForVerticalTab = 0x240b, // ␋ (1) SymbolForHorizontalTab = 0x2409, // ␉ (1) diff --git a/src/include/final/fcharmap.h b/src/include/final/fcharmap.h index 4ad6f3c8..82add2d3 100644 --- a/src/include/final/fcharmap.h +++ b/src/include/final/fcharmap.h @@ -68,6 +68,7 @@ static uInt character[][fc::NUM_OF_ENCODINGS] = {0x00b0, 'f', 0xb0, 'o'}, // ° - Degree {0x2022, '`', 0x04, '*'}, // • - Bullet {0x00b7, '`', 0xfa, '.'}, // · - small Bullet + {0x25cf, '`', 0x04, '*'}, // ● - BlackCircle {0x2666, '`', 0x04, '*'}, // ◆ - BlackDiamondSuit {0x2424, 'h', ' ', ' '}, // ␤ - SymbolForNewline (1) {0x240b, 'i', ' ', ' '}, // ␋ - SymbolForVerticalTab (1) diff --git a/src/include/final/fcheckmenuitem.h b/src/include/final/fcheckmenuitem.h index 9394b4b9..5c818844 100644 --- a/src/include/final/fcheckmenuitem.h +++ b/src/include/final/fcheckmenuitem.h @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2015-2018 Markus Gans * +* Copyright 2015-2019 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -92,7 +92,7 @@ class FCheckMenuItem : public FMenuItem // Methods void init (FWidget*); void processToggle(); - void processClicked(); + virtual void processClicked() override; }; #pragma pack(pop) diff --git a/src/include/final/flistview.h b/src/include/final/flistview.h index fe3f2197..8642dbed 100644 --- a/src/include/final/flistview.h +++ b/src/include/final/flistview.h @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2017-2018 Markus Gans * +* Copyright 2017-2019 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -215,7 +215,7 @@ class FListViewIterator bool operator != (const FListViewIterator&) const; // Accessor - virtual const char* getClassName() const; + const char* getClassName() const; int getPosition() const; // Methods diff --git a/src/include/final/fmouse.h b/src/include/final/fmouse.h index 24d1e22d..7419be9c 100644 --- a/src/include/final/fmouse.h +++ b/src/include/final/fmouse.h @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2018 Markus Gans * +* Copyright 2018-2019 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -202,7 +202,7 @@ class FMouseGPM : public FMouse virtual ~FMouseGPM(); // Accessors - virtual const char* getClassName() const; + virtual const char* getClassName() const override; // Mutators void setStdinNo(int); @@ -274,7 +274,7 @@ class FMouseX11 : public FMouse virtual ~FMouseX11() = default; // Accessors - virtual const char* getClassName() const; + virtual const char* getClassName() const override; // Inquiry virtual bool hasData() override; @@ -337,7 +337,7 @@ class FMouseSGR : public FMouse virtual ~FMouseSGR() = default; // Accessors - virtual const char* getClassName() const; + virtual const char* getClassName() const override; // Inquiry virtual bool hasData() override; @@ -400,7 +400,7 @@ class FMouseUrxvt : public FMouse virtual ~FMouseUrxvt() = default; // Accessors - virtual const char* getClassName() const; + virtual const char* getClassName() const override; // Inquiry virtual bool hasData() override; diff --git a/src/include/final/fradiomenuitem.h b/src/include/final/fradiomenuitem.h index 69f807c2..41d4dd65 100644 --- a/src/include/final/fradiomenuitem.h +++ b/src/include/final/fradiomenuitem.h @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2015-2018 Markus Gans * +* Copyright 2015-2019 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -90,9 +90,9 @@ class FRadioMenuItem : public FMenuItem private: // Methods - void init (FWidget*); - void processToggle(); - void processClicked(); + void init (FWidget*); + void processToggle(); + virtual void processClicked() override; }; #pragma pack(pop) diff --git a/src/include/final/fscrollview.h b/src/include/final/fscrollview.h index aee895e9..85ba7b90 100644 --- a/src/include/final/fscrollview.h +++ b/src/include/final/fscrollview.h @@ -4,7 +4,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2017-2018 Markus Gans * +* Copyright 2017-2019 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -147,7 +147,7 @@ class FScrollView : public FWidget using FVTerm::clearArea; // Accessor - term_area* getPrintArea(); + virtual term_area* getPrintArea() override; // Method virtual void adjustSize() override; diff --git a/src/include/final/fterm.h b/src/include/final/fterm.h index 4ec07e3d..fd0dc0a6 100644 --- a/src/include/final/fterm.h +++ b/src/include/final/fterm.h @@ -156,6 +156,7 @@ class FTerm public: // Typedefs typedef FOptiAttr::charData charData; + typedef FTermData::characterSub characterSub; struct initializationValues; // forward declaration @@ -185,6 +186,7 @@ class FTerm static int getTabstop(); static int getMaxColor(); initializationValues& getInitValues(); + characterSub& getCharSubstitutionMap(); #if DEBUG FTermDebugData& getFTermDebugData(); @@ -452,6 +454,10 @@ inline int FTerm::getMaxColor() inline FTerm::initializationValues& FTerm::getInitValues() { return init_values; } +//---------------------------------------------------------------------- +inline FTerm::characterSub& FTerm::getCharSubstitutionMap() +{ return data->getCharSubstitutionMap(); } + #if DEBUG //---------------------------------------------------------------------- inline FTermDebugData& FTerm::getFTermDebugData() diff --git a/src/include/final/ftermcap.h b/src/include/final/ftermcap.h index 43eb6219..d53e489f 100644 --- a/src/include/final/ftermcap.h +++ b/src/include/final/ftermcap.h @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2016-2018 Markus Gans * +* Copyright 2016-2019 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -93,7 +93,7 @@ class FTermcap ~FTermcap() = default; // Accessors - virtual const char* getClassName() const; + const char* getClassName() const; static tcap_map* getTermcapMap() { diff --git a/src/include/final/ftermdata.h b/src/include/final/ftermdata.h index f1179644..70d0dd5c 100644 --- a/src/include/final/ftermdata.h +++ b/src/include/final/ftermdata.h @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2018 Markus Gans * +* Copyright 2018-2019 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -35,7 +35,7 @@ #error "Only can be included directly." #endif -#include +#include #include #include "final/fc.h" @@ -57,7 +57,8 @@ class FTermData { public: // Typedefs - typedef std::map encodingMap; + typedef std::unordered_map encodingMap; + typedef std::unordered_map characterSub; // Constructors FTermData() = default; @@ -74,6 +75,7 @@ class FTermData // Accessors const char* getClassName() const; encodingMap& getEncodingList(); + characterSub& getCharSubstitutionMap(); fc::encoding getTermEncoding() const; FRect& getTermGeometry(); int getTTYFileDescriptor() const; @@ -129,6 +131,7 @@ class FTermData private: // Data Members encodingMap encoding_list{}; + characterSub char_substitution_map{}; fc::encoding term_encoding{fc::UNKNOWN}; FRect term_geometry{}; // current terminal geometry int fd_tty{-1}; // Teletype (tty) file descriptor is still undefined @@ -166,6 +169,10 @@ inline const char* FTermData::getClassName() const inline FTermData::encodingMap& FTermData::getEncodingList() { return encoding_list; } +//---------------------------------------------------------------------- +inline FTermData::characterSub& FTermData::getCharSubstitutionMap() +{ return char_substitution_map; } + //---------------------------------------------------------------------- inline fc::encoding FTermData::getTermEncoding() const { return term_encoding; } diff --git a/src/include/final/ftermlinux.h b/src/include/final/ftermlinux.h index 9e7e1a48..25d1f982 100644 --- a/src/include/final/ftermlinux.h +++ b/src/include/final/ftermlinux.h @@ -87,6 +87,7 @@ class FTermLinux static int getFramebufferBpp(); // Mutators + static void setFTermData (FTermData*); static void setFTermDetection (FTermDetection*); static char* setCursorStyle (fc::linuxConsoleCursorStyle, bool); static bool setPalette (FColor, int, int, int); @@ -136,6 +137,8 @@ class FTermLinux rgb color[16]; } ColorMap; + typedef FTermData::characterSub characterSub; + // Accessors static int getFramebuffer_bpp(); static bool getScreenFont(); @@ -168,6 +171,7 @@ class FTermLinux static FKey shiftCtrlAltKeyCorrection (const FKey&); static sInt16 getFontPos (wchar_t ucs); static void initSpecialCharacter(); + static void characterFallback (wchar_t, std::vector); // Data Members #if defined(__linux__) @@ -176,6 +180,7 @@ class FTermLinux static bool shadow_character; static bool half_block_character; static bool has_saved_palette; + static FTermData* fterm_data; static FTermDetection* term_detection; static fc::linuxConsoleCursorStyle linux_console_cursor_style; @@ -198,6 +203,10 @@ inline const char* FTermLinux::getClassName() const inline int FTermLinux::getFramebufferBpp() { return framebuffer_bpp; } +//---------------------------------------------------------------------- +inline void FTermLinux::setFTermData (FTermData* data) +{ fterm_data = data; } + //---------------------------------------------------------------------- inline void FTermLinux::setFTermDetection (FTermDetection* td) { term_detection = td; } diff --git a/src/include/final/fvterm.h b/src/include/final/fvterm.h index 72c48026..d781fffd 100644 --- a/src/include/final/fvterm.h +++ b/src/include/final/fvterm.h @@ -315,7 +315,7 @@ class FVTerm virtual term_area* getPrintArea(); std::size_t getLineNumber(); std::size_t getColumnNumber(); - static bool charEncodable (uInt); + static bool charEncodable (wchar_t); static FKeyboard* getKeyboard(); static FMouseControl* getMouseControl(); FTerm::initializationValues& getInitValues(); @@ -486,6 +486,7 @@ class FVTerm void appendChar (charData*&); void appendAttributes (charData*&); int appendLowerRight (charData*&); + static void characterFilter (charData*&); static void appendOutputBuffer (const std::string&); static void appendOutputBuffer (const char[]); @@ -1071,7 +1072,7 @@ inline std::size_t FVTerm::getColumnNumber() { return FTerm::getColumnNumber(); } //---------------------------------------------------------------------- -inline bool FVTerm::charEncodable (uInt c) +inline bool FVTerm::charEncodable (wchar_t c) { return FTerm::charEncodable(c); } //---------------------------------------------------------------------- diff --git a/src/include/final/fwidget.h b/src/include/final/fwidget.h index 3e87123f..9f9b61e6 100644 --- a/src/include/final/fwidget.h +++ b/src/include/final/fwidget.h @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2015-2018 Markus Gans * +* Copyright 2015-2019 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -362,10 +362,10 @@ class FWidget : public FVTerm, public FObject typedef std::vector MemberCallbackObjects; // Accessor - term_area* getPrintArea(); - void addPreprocessingHandler ( FVTerm* - , FPreprocessingHandler ); - void delPreprocessingHandler (FVTerm*); + virtual term_area* getPrintArea() override; + virtual void addPreprocessingHandler ( FVTerm* + , FPreprocessingHandler ) override; + virtual void delPreprocessingHandler (FVTerm*) override; // Inquiry bool isChildPrintArea() const; @@ -381,7 +381,7 @@ class FWidget : public FVTerm, public FObject virtual bool focusPrevChild(); // ...focus // Event handlers - virtual bool event (FEvent*); + virtual bool event (FEvent*) override; virtual void onKeyPress (FKeyEvent*); virtual void onKeyUp (FKeyEvent*); virtual void onKeyDown (FKeyEvent*); diff --git a/test/ftermdata-test.cpp b/test/ftermdata-test.cpp index b8374334..5bfa647e 100644 --- a/test/ftermdata-test.cpp +++ b/test/ftermdata-test.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2018 Markus Gans * +* Copyright 2018-2019 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -153,6 +153,20 @@ void FTermDataTest::dataTest() data.setTermEncoding(finalcut::fc::UNKNOWN); CPPUNIT_ASSERT ( data.getTermEncoding() == finalcut::fc::UNKNOWN ); + CPPUNIT_ASSERT ( data.getCharSubstitutionMap().size() == 0 ); + auto& character_map = data.getCharSubstitutionMap(); + character_map[L'€'] = 'E'; + character_map[L'µ'] = L'u'; + character_map[finalcut::fc::Bullet] = '*'; + character_map[finalcut::fc::FullBlock] = finalcut::fc::MediumShade; + auto& char_map = data.getCharSubstitutionMap(); + CPPUNIT_ASSERT ( char_map.size() == 4 ); + CPPUNIT_ASSERT ( char_map[L'€'] == 'E' ); + CPPUNIT_ASSERT ( char_map[L'µ'] == L'u' ); + CPPUNIT_ASSERT ( char_map[finalcut::fc::Bullet] == '*' ); + CPPUNIT_ASSERT ( char_map[finalcut::fc::FullBlock] + == finalcut::fc::MediumShade ); + CPPUNIT_ASSERT ( data.getTermGeometry() == finalcut::FRect() ); data.getTermGeometry().setSize(10, 10); data.getTermGeometry().setPos(3, 5);