From 4135215df501dba3cb9fe484595c012e56aa7d48 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Wed, 2 Jan 2019 03:00:07 +0100 Subject: [PATCH] Improved PC encoding for Cygwin and Linux --- ChangeLog | 3 + examples/ui.cpp | 6 +- finalcut.spec.in | 2 +- src/fbuttongroup.cpp | 66 ++++++------- src/flineedit.cpp | 13 +-- src/foptiattr.cpp | 4 +- src/fterm.cpp | 99 ++++++++++++++------ src/ftermlinux.cpp | 78 +++++++++------- src/ftextview.cpp | 4 +- src/fvterm.cpp | 22 +++-- src/include/final/fbuttongroup.h | 8 +- src/include/final/fc.h | 15 ++- src/include/final/fcharmap.h | 155 +++++++++++++++++++++++++++++-- src/include/final/foptiattr.h | 9 +- src/include/final/fterm.h | 11 ++- src/include/final/ftermlinux.h | 4 +- src/include/final/fvterm.h | 4 +- 17 files changed, 353 insertions(+), 150 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2f8ee43b..55a206e8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2019-01-02 Markus Gans + * Improved PC encoding for Cygwin and Linux + 2018-12-31 Markus Gans * Use the override specifier diff --git a/examples/ui.cpp b/examples/ui.cpp index 45fe1c2d..1d78b0a2 100644 --- a/examples/ui.cpp +++ b/examples/ui.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2012-2018 Markus Gans * +* Copyright 2012-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 * @@ -780,7 +780,7 @@ void MyDialog::cb_about (finalcut::FWidget*, FDataPtr) finalcut::FMessageBox info ( "About" , line + L" The Final Cut " + line + "\n\n" L"Version " + libver + "\n\n" - L"(c) 2018 by Markus Gans" + L"(c) 2019 by Markus Gans" , finalcut::FMessageBox::Ok, 0, 0, this ); info.setCenterText(); info.show(); @@ -1002,7 +1002,7 @@ int main (int argc, char* argv[]) const finalcut::FString ver = F_VERSION; // Library version const finalcut::FString title = "The FINAL CUT " + ver - + " (C) 2018 by Markus Gans"; + + " (C) 2019 by Markus Gans"; // Create the application object app finalcut::FApplication app(argc, argv); diff --git a/finalcut.spec.in b/finalcut.spec.in index 96e07370..2b249aef 100644 --- a/finalcut.spec.in +++ b/finalcut.spec.in @@ -1,7 +1,7 @@ # # spec file for package finalcut # -# Copyright (c) 2018 by Markus Gans +# Copyright (c) 2019 by Markus Gans # %define sover 0 diff --git a/src/fbuttongroup.cpp b/src/fbuttongroup.cpp index 0d08b8d1..75216ba7 100644 --- a/src/fbuttongroup.cpp +++ b/src/fbuttongroup.cpp @@ -4,7 +4,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2014-2018 Markus Gans * +* Copyright 2014-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 * @@ -380,38 +380,6 @@ void FButtonGroup::onFocusIn (FFocusEvent* in_ev) } } -//---------------------------------------------------------------------- -void FButtonGroup::cb_buttonToggled (FWidget* widget, FDataPtr) -{ - auto button = static_cast(widget); - - if ( ! button->isChecked() ) - return; - - if ( buttonlist.empty() ) - return; - - auto iter = buttonlist.begin(); - auto last = buttonlist.end(); - - while ( iter != last ) - { - auto toggle_button = static_cast(*iter); - - if ( toggle_button != button - && toggle_button->isChecked() - && isRadioButton(toggle_button) ) - { - toggle_button->unsetChecked(); - - if ( toggle_button->isVisible() && toggle_button->isShown() ) - toggle_button->redraw(); - } - - ++iter; - } -} - // protected methods of FButtonGroup //---------------------------------------------------------------------- @@ -659,4 +627,36 @@ void FButtonGroup::directFocus() } } +//---------------------------------------------------------------------- +void FButtonGroup::cb_buttonToggled (FWidget* widget, FDataPtr) +{ + auto button = static_cast(widget); + + if ( ! button->isChecked() ) + return; + + if ( buttonlist.empty() ) + return; + + auto iter = buttonlist.begin(); + auto last = buttonlist.end(); + + while ( iter != last ) + { + auto toggle_button = static_cast(*iter); + + if ( toggle_button != button + && toggle_button->isChecked() + && isRadioButton(toggle_button) ) + { + toggle_button->unsetChecked(); + + if ( toggle_button->isVisible() && toggle_button->isShown() ) + toggle_button->redraw(); + } + + ++iter; + } +} + } // namespace finalcut diff --git a/src/flineedit.cpp b/src/flineedit.cpp index 94974ac9..7fc6c3bf 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2012-2018 Markus Gans * +* Copyright 2012-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 * @@ -730,16 +730,7 @@ void FLineEdit::drawInputField() show_text = text.mid(1 + text_offset, getWidth() - 2); - if ( isLinuxTerm() && hasUTF8() ) - { - setUTF8(true); - - if ( show_text ) - print (show_text); - - setUTF8(false); - } - else if ( show_text ) + if ( show_text ) print (show_text); x = show_text.getLength(); diff --git a/src/foptiattr.cpp b/src/foptiattr.cpp index 87a9c2f6..68c9a7c4 100644 --- a/src/foptiattr.cpp +++ b/src/foptiattr.cpp @@ -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 * @@ -557,7 +557,7 @@ char* FOptiAttr::changeAttribute (charData*& term, charData*& next) // Simulate invisible characters if ( ! F_enter_secure_mode.cap && next->attr.bit.invisible ) - next->code = ' '; + next->encoded_code = ' '; // Look for no changes if ( ! (switchOn() || switchOff() || hasColorChanged(term, next)) ) diff --git a/src/fterm.cpp b/src/fterm.cpp index 75dc76f9..9c1f0df6 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2012-2018 Markus Gans * +* Copyright 2012-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 * @@ -151,6 +151,9 @@ void FTerm::setInsertCursor (bool enable) //---------------------------------------------------------------------- void FTerm::redefineDefaultColors (bool enable) { + if ( isNewFont() ) // NewFont need the reverse-video attribute + return; + xterm->redefineDefaultColors (enable); } @@ -693,26 +696,69 @@ std::string FTerm::getEncodingString() } //---------------------------------------------------------------------- -bool FTerm::charEncodable (uInt c) +bool FTerm::charEncodable (wchar_t c) { - uInt ch = charEncode(c); + wchar_t ch = charEncode(c); return bool(ch > 0 && ch != c); } //---------------------------------------------------------------------- -uInt FTerm::charEncode (uInt c) +wchar_t FTerm::charEncode (wchar_t c) { return charEncode (c, data->getTermEncoding()); } //---------------------------------------------------------------------- -uInt FTerm::charEncode (uInt c, fc::encoding enc) +wchar_t FTerm::charEncode (wchar_t c, fc::encoding enc) { - for (std::size_t i = 0; i <= uInt(fc::lastCharItem); i++) + wchar_t ch_enc = c; + + for (std::size_t i = 0; i <= fc::lastCharItem; i++) { - if ( fc::character[i][fc::UTF8] == c ) + if ( fc::character[i][fc::UTF8] == uInt(c) ) { - c = fc::character[i][enc]; + ch_enc = wchar_t(fc::character[i][enc]); + break; + } + } + + if ( enc == fc::PC && ch_enc == c ) + ch_enc = FTerm::unicode_to_cp437(c); + + return ch_enc; +} + +//---------------------------------------------------------------------- +wchar_t FTerm::cp437_to_unicode (uChar c) +{ + constexpr std::size_t CP437 = 0; + constexpr std::size_t UNICODE = 1; + wchar_t ucs = wchar_t(c); + + for (std::size_t i = 0; i <= fc::lastCP437Item; i++) + { + if ( fc::cp437_to_ucs[i][CP437] == c ) // found + { + ucs = fc::cp437_to_ucs[UNICODE][1]; + break; + } + } + + return ucs; +} + +//---------------------------------------------------------------------- +uChar FTerm::unicode_to_cp437 (wchar_t ucs) +{ + constexpr std::size_t CP437 = 0; + constexpr std::size_t UNICODE = 1; + uChar c = '?'; + + for (std::size_t i = 0; i <= fc::lastCP437Item; i++) + { + if ( fc::cp437_to_ucs[i][UNICODE] == ucs ) // found + { + c = fc::cp437_to_ucs[i][CP437]; break; } } @@ -1044,15 +1090,27 @@ void FTerm::init_pc_charset() //---------------------------------------------------------------------- void FTerm::init_cygwin_charmap() { - // Replace don't printable characters in a Cygwin terminal + // Replace don't printable PC charset characters in a Cygwin terminal if ( ! isCygwinTerminal() ) return; for (std::size_t i = 0; i <= fc::lastCharItem; i++ ) { - if ( fc::character[i][fc::UTF8] == fc::BlackUpPointingTriangle // ▲ - || fc::character[i][fc::UTF8] == fc::BlackDownPointingTriangle // ▼ + if ( fc::character[i][fc::UTF8] == fc::BlackUpPointingTriangle ) // ▲ + fc::character[i][fc::PC] = 0x18; + + if ( fc::character[i][fc::UTF8] == fc::BlackDownPointingTriangle ) // ▼ + fc::character[i][fc::PC] = 0x19; + + if ( fc::character[i][fc::UTF8] == fc::InverseBullet // ◘ + || fc::character[i][fc::UTF8] == fc::InverseWhiteCircle // ◙ + || fc::character[i][fc::UTF8] == fc::UpDownArrow // ↕ + || fc::character[i][fc::UTF8] == fc::LeftRightArrow // ↔ + || fc::character[i][fc::UTF8] == fc::DoubleExclamationMark // ‼ + || fc::character[i][fc::UTF8] == fc::BlackRectangle // ▬ + || fc::character[i][fc::UTF8] == fc::RightwardsArrow // → + || fc::character[i][fc::UTF8] == fc::Section // § || fc::character[i][fc::UTF8] == fc::SquareRoot ) // SquareRoot √ fc::character[i][fc::PC] = fc::character[i][fc::ASCII]; } @@ -1350,7 +1408,7 @@ void FTerm::init_individual_term_encoding() data->setTermEncoding (fc::PC); Fputchar = &FTerm::putchar_ASCII; // function pointer - if ( hasUTF8() ) + if ( hasUTF8() && init_values.encoding == fc::UNKNOWN ) { if ( isLinuxTerm() ) setUTF8(false); @@ -1989,23 +2047,6 @@ void FTerm::finish_encoding() #endif } -//---------------------------------------------------------------------- -uInt FTerm::cp437_to_unicode (uChar c) -{ - uInt ucs = uInt(c); - - for (std::size_t i = 0; i <= fc::lastCP437Item; i++) - { - if ( fc::cp437_to_ucs[i][0] == c ) // found - { - ucs = fc::cp437_to_ucs[i][1]; - break; - } - } - - return ucs; -} - //---------------------------------------------------------------------- void FTerm::setSignalHandler() { diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index 8c6d5aeb..2a9fbe1d 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2018 Markus Gans * +* Copyright 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 * @@ -191,7 +191,7 @@ void FTermLinux::init() //---------------------------------------------------------------------- void FTermLinux::initCharMap (uInt char_map[][fc::NUM_OF_ENCODINGS]) { - uInt c1, c2, c3, c4, c5; + constexpr sInt16 NOT_FOUND = -1; if ( new_font || vga_font ) return; @@ -200,43 +200,16 @@ void FTermLinux::initCharMap (uInt char_map[][fc::NUM_OF_ENCODINGS]) { for (std::size_t i = 0; i <= fc::lastCharItem; i++ ) { - bool known_unicode = false; + wchar_t ucs = char_map[i][fc::UTF8]; + sInt16 fontpos = getFontPos(ucs); - for (std::size_t n = 0; n < screen_unicode_map.entry_ct; n++) - { - if ( char_map[i][fc::UTF8] == screen_unicode_map.entries[n].unicode ) - { - if ( screen_unicode_map.entries[n].fontpos < 256 ) - known_unicode = true; - - break; - } - } - - if ( ! known_unicode ) + // 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]; } } - c1 = fc::UpperHalfBlock; - c2 = fc::LowerHalfBlock; - c3 = fc::FullBlock; - - if ( FTerm::charEncode(c1, fc::PC) == FTerm::charEncode(c1, fc::ASCII) - || FTerm::charEncode(c2, fc::PC) == FTerm::charEncode(c2, fc::ASCII) - || FTerm::charEncode(c3, fc::PC) == FTerm::charEncode(c3, fc::ASCII) ) - { - shadow_character = false; - } - - c4 = fc::RightHalfBlock; - c5 = fc::LeftHalfBlock; - - if ( FTerm::charEncode(c4, fc::PC) == FTerm::charEncode(c4, fc::ASCII) - || FTerm::charEncode(c5, fc::PC) == FTerm::charEncode(c5, fc::ASCII) ) - { - half_block_character = false; - } + initSpecialCharacter(); } //---------------------------------------------------------------------- @@ -1187,6 +1160,43 @@ FKey FTermLinux::shiftCtrlAltKeyCorrection (const FKey& key_id) return key_id; } } + +//---------------------------------------------------------------------- +inline void FTermLinux::initSpecialCharacter() +{ + uInt c1 = fc::UpperHalfBlock; + uInt c2 = fc::LowerHalfBlock; + uInt c3 = fc::FullBlock; + + if ( FTerm::charEncode(c1, fc::PC) == FTerm::charEncode(c1, fc::ASCII) + || FTerm::charEncode(c2, fc::PC) == FTerm::charEncode(c2, fc::ASCII) + || FTerm::charEncode(c3, fc::PC) == FTerm::charEncode(c3, fc::ASCII) ) + { + shadow_character = false; + } + + uInt c4 = fc::RightHalfBlock; + uInt c5 = fc::LeftHalfBlock; + + if ( FTerm::charEncode(c4, fc::PC) == FTerm::charEncode(c4, fc::ASCII) + || FTerm::charEncode(c5, fc::PC) == FTerm::charEncode(c5, fc::ASCII) ) + { + half_block_character = false; + } +} + +//---------------------------------------------------------------------- +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 -1; +} + #endif // defined(__linux__) } // namespace finalcut diff --git a/src/ftextview.cpp b/src/ftextview.cpp index bb894813..27a2b1a4 100644 --- a/src/ftextview.cpp +++ b/src/ftextview.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2014-2018 Markus Gans * +* Copyright 2014-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 * @@ -745,7 +745,7 @@ void FTextView::drawText() // only printable and 1 column per character if ( ( (utf8 && std::iswprint(wint_t(ch))) - || (!utf8 && ch < 256 && std::isprint(ch)) ) + || (!utf8 && std::isprint(ch)) ) && wcwidth(ch) == 1 ) { print (ch); diff --git a/src/fvterm.cpp b/src/fvterm.cpp index 450b8577..41b07aa8 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -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 * @@ -2725,8 +2725,8 @@ inline void FVTerm::newFontChanges (charData*& next_char) case fc::NF_rev_down_pointing_triangle2: case fc::NF_rev_menu_button3: case fc::NF_rev_border_line_right_and_left: - // swap foreground and background color - std::swap (next_char->fg_color, next_char->bg_color); + // Show in reverse video + next_char->attr.bit.reverse = true; break; default: @@ -2738,22 +2738,24 @@ inline void FVTerm::newFontChanges (charData*& next_char) //---------------------------------------------------------------------- inline void FVTerm::charsetChanges (charData*& next_char) { + wchar_t& code = next_char->code; + next_char->encoded_code = code; + if ( getEncoding() == fc::UTF8 ) return; - uInt code = uInt(next_char->code); - uInt ch_enc = FTerm::charEncode(code); + wchar_t ch_enc = FTerm::charEncode(code); if ( ch_enc == code ) return; if ( ch_enc == 0 ) { - next_char->code = int(FTerm::charEncode(code, fc::ASCII)); + next_char->encoded_code = wchar_t(FTerm::charEncode(code, fc::ASCII)); return; } - next_char->code = int(ch_enc); + next_char->encoded_code = ch_enc; if ( getEncoding() == fc::VT100 ) next_char->attr.bit.alt_charset = true; @@ -2767,10 +2769,10 @@ inline void FVTerm::charsetChanges (charData*& next_char) if ( isXTerminal() && ch_enc < 0x20 ) // Character 0x00..0x1f { if ( hasUTF8() ) - next_char->code = int(FTerm::charEncode(code, fc::ASCII)); + next_char->encoded_code = int(FTerm::charEncode(code, fc::ASCII)); else { - next_char->code += 0x5f; + next_char->encoded_code += 0x5f; next_char->attr.bit.alt_charset = true; } } @@ -2799,7 +2801,7 @@ inline void FVTerm::appendChar (charData*& next_char) charsetChanges (next_char); appendAttributes (next_char); - appendOutputBuffer (next_char->code); + appendOutputBuffer (next_char->encoded_code); } //---------------------------------------------------------------------- diff --git a/src/include/final/fbuttongroup.h b/src/include/final/fbuttongroup.h index b5456c61..5c6a590f 100644 --- a/src/include/final/fbuttongroup.h +++ b/src/include/final/fbuttongroup.h @@ -4,7 +4,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2014-2018 Markus Gans * +* Copyright 2014-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 * @@ -116,9 +116,6 @@ class FButtonGroup : public FScrollView virtual void onAccel (FAccelEvent*) override; virtual void onFocusIn (FFocusEvent*) override; - // Callback method - void cb_buttonToggled (FWidget*, FDataPtr); - protected: // Accessor uChar getHotkey(); @@ -143,6 +140,9 @@ class FButtonGroup : public FScrollView void drawText (wchar_t[], std::size_t, std::size_t); void directFocus(); + // Callback method + void cb_buttonToggled (FWidget*, FDataPtr); + // Data Members FString text{}; FObjectList buttonlist{}; diff --git a/src/include/final/fc.h b/src/include/final/fc.h index 3f6d9cda..d3aebe64 100644 --- a/src/include/final/fc.h +++ b/src/include/final/fc.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 * @@ -141,8 +141,19 @@ enum SpecialCharacter : wchar_t { Euro = 0x20ac, // € Pound = 0x00a3, // £ + Section = 0x00a7, // § Pi = 0x03c0, // π - SuperscriptLatinSmallLetterN = 0x207F, // ⁿ + InverseBullet = 0x25d8, // ◘ + InverseWhiteCircle = 0x25d9, // ◙ + UpDownArrow = 0x2195, // ↕ + LeftRightArrow = 0x2194, // ↔ + BlackRectangle = 0x25ac, // ▬ + UpwardsArrow = 0x2191, // ↑ + DownwardsArrow = 0x2193, // ↓ + RightwardsArrow = 0x2192, // → + LeftwardsArrow = 0x2190, // ← + DoubleExclamationMark = 0x203c, // ‼ + SuperscriptLatinSmallLetterN = 0x207f, // ⁿ GreaterThanOrEqualTo = 0x2265, // ≥ LessThanOrEqualTo = 0x2264, // ≤ NotEqualTo = 0x2260, // ≠ diff --git a/src/include/final/fcharmap.h b/src/include/final/fcharmap.h index 91ebf7fc..4ad6f3c8 100644 --- a/src/include/final/fcharmap.h +++ b/src/include/final/fcharmap.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 * @@ -45,6 +45,17 @@ static uInt character[][fc::NUM_OF_ENCODINGS] = // | | | | {0x20ac, 0, 0xee, 'E'}, // € - Euro {0x00a3, '}', 0x9c, 'P'}, // £ - Pound + {0x00a7, '$', 0x15, '$'}, // § - Section + {0x25d8, '*', 0x08, '*'}, // ◘ - InverseBullet + {0x25d9, '*', 0x0a, '*'}, // ◙ - InverseWhiteCircle + {0x203c, '!', 0x13, '!'}, // ‼ - DoubleExclamationMark + {0x2195, 'I', 0x12, 'I'}, // ↕ - UpDownArrow + {0x2194, '-', 0x1d, '-'}, // ↔ - LeftRightArrow + {0x25ac, '_', 0x16, '_'}, // ▬ - BlackRectangle + {0x2191, '^', 0x18, '^'}, // ↑ - UpwardsArrow + {0x2193, 'v', 0x19, 'v'}, // ↓ - DownwardsArrow + {0x2192, '>', 0x1a, '>'}, // → - RightwardsArrow + {0x2190, '<', 0x1b, '<'}, // ← - LeftwardsArrow {0x03c0, '{', 0xe3, 'n'}, // π - Pi {0x207F, 'I', 0xfc, ' '}, // ⁿ - SuperscriptLatinSmallLetterN {0x2265, 'z', 0xf2, '>'}, // ≥ - GreaterThanOrEqualTo @@ -144,7 +155,8 @@ static uInt character[][fc::NUM_OF_ENCODINGS] = * (2) Only supported in use with newfont */ -const int lastCharItem = int(sizeof(character) / sizeof(character[0])) - 1; +constexpr auto lastCharItem = \ + std::size_t((sizeof(character) / sizeof(character[0])) - 1); static int vt100_key_to_utf8[][2] = @@ -190,12 +202,140 @@ static int vt100_key_to_utf8[][2] = {fc::vt100_key_diamond , fc::Bullet} // ◆ }; -const int lastKeyItem = int ( sizeof(vt100_key_to_utf8) - / sizeof(vt100_key_to_utf8[0]) ) - 1; +constexpr auto lastKeyItem = \ + std::size_t((sizeof(vt100_key_to_utf8) / sizeof(vt100_key_to_utf8[0])) - 1); -static uInt cp437_to_ucs[][2] = +static wchar_t cp437_to_ucs[][2] = { + {0x00, 0x0000}, // null + {0x01, 0x263a}, // white smiling face + {0x02, 0x263b}, // black smiling face + {0x03, 0x2665}, // black heart suit + {0x04, 0x2666}, // black diamond suit + {0x05, 0x2663}, // black club suit + {0x06, 0x2660}, // black spade suit + {0x07, 0x2022}, // bullet + {0x08, 0x25d8}, // inverse bullet + {0x09, 0x25cb}, // white circle + {0x0a, 0x25d9}, // inverse white circle + {0x0b, 0x2642}, // male sign + {0x0c, 0x2640}, // female sign + {0x0d, 0x266a}, // eighth note + {0x0e, 0x266b}, // beamed eighth notes + {0x0f, 0x263c}, // white sun with rays + {0x10, 0x25ba}, // black right-pointing pointer + {0x11, 0x25c4}, // black left-pointing pointer + {0x12, 0x2195}, // up down arrow + {0x13, 0x203c}, // double exclamation mark + {0x14, 0x00b6}, // pilcrow sign + {0x15, 0x00a7}, // section sign + {0x16, 0x25ac}, // black rectangle + {0x17, 0x21a8}, // up down arrow with base + {0x18, 0x2191}, // upwards arrow + {0x19, 0x2193}, // downwards arrow + {0x1a, 0x2192}, // rightwards arrow + {0x1b, 0x2190}, // leftwards arrow + {0x1c, 0x221f}, // right angle + {0x1d, 0x2194}, // left right arrow + {0x1e, 0x25b2}, // black up-pointing triangle + {0x1f, 0x25bc}, // black down-pointing triangle + {0x20, 0x0020}, // space + {0x21, 0x0021}, // exclamation mark + {0x22, 0x0022}, // quotation mark + {0x23, 0x0023}, // number sign + {0x24, 0x0024}, // dollar sign + {0x25, 0x0025}, // percent sign + {0x26, 0x0026}, // ampersand + {0x27, 0x0027}, // apostrophe + {0x28, 0x0028}, // left parenthesis + {0x29, 0x0029}, // right parenthesis + {0x2a, 0x002a}, // asterisk + {0x2b, 0x002b}, // plus sign + {0x2c, 0x002c}, // comma + {0x2d, 0x002d}, // hyphen-minus + {0x2e, 0x002e}, // full stop + {0x2f, 0x002f}, // solidus + {0x30, 0x0030}, // digit zero + {0x31, 0x0031}, // digit one + {0x32, 0x0032}, // digit two + {0x33, 0x0033}, // digit three + {0x34, 0x0034}, // digit four + {0x35, 0x0035}, // digit five + {0x36, 0x0036}, // digit six + {0x37, 0x0037}, // digit seven + {0x38, 0x0038}, // digit eight + {0x39, 0x0039}, // digit nine + {0x3a, 0x003a}, // colon + {0x3b, 0x003b}, // semicolon + {0x3c, 0x003c}, // less-than sign + {0x3d, 0x003d}, // equals sign + {0x3e, 0x003e}, // greater-than sign + {0x3f, 0x003f}, // question mark + {0x40, 0x0040}, // commercial at + {0x41, 0x0041}, // latin capital letter a + {0x42, 0x0042}, // latin capital letter b + {0x43, 0x0043}, // latin capital letter c + {0x44, 0x0044}, // latin capital letter d + {0x45, 0x0045}, // latin capital letter e + {0x46, 0x0046}, // latin capital letter f + {0x47, 0x0047}, // latin capital letter g + {0x48, 0x0048}, // latin capital letter h + {0x49, 0x0049}, // latin capital letter i + {0x4a, 0x004a}, // latin capital letter j + {0x4b, 0x004b}, // latin capital letter k + {0x4c, 0x004c}, // latin capital letter l + {0x4d, 0x004d}, // latin capital letter m + {0x4e, 0x004e}, // latin capital letter n + {0x4f, 0x004f}, // latin capital letter o + {0x50, 0x0050}, // latin capital letter p + {0x51, 0x0051}, // latin capital letter q + {0x52, 0x0052}, // latin capital letter r + {0x53, 0x0053}, // latin capital letter s + {0x54, 0x0054}, // latin capital letter t + {0x55, 0x0055}, // latin capital letter u + {0x56, 0x0056}, // latin capital letter v + {0x57, 0x0057}, // latin capital letter w + {0x58, 0x0058}, // latin capital letter x + {0x59, 0x0059}, // latin capital letter y + {0x5a, 0x005a}, // latin capital letter z + {0x5b, 0x005b}, // left square bracket + {0x5c, 0x005c}, // reverse solidus + {0x5d, 0x005d}, // right square bracket + {0x5e, 0x005e}, // circumflex accent + {0x5f, 0x005f}, // low line + {0x60, 0x0060}, // grave accent + {0x61, 0x0061}, // latin small letter a + {0x62, 0x0062}, // latin small letter b + {0x63, 0x0063}, // latin small letter c + {0x64, 0x0064}, // latin small letter d + {0x65, 0x0065}, // latin small letter e + {0x66, 0x0066}, // latin small letter f + {0x67, 0x0067}, // latin small letter g + {0x68, 0x0068}, // latin small letter h + {0x69, 0x0069}, // latin small letter i + {0x6a, 0x006a}, // latin small letter j + {0x6b, 0x006b}, // latin small letter k + {0x6c, 0x006c}, // latin small letter l + {0x6d, 0x006d}, // latin small letter m + {0x6e, 0x006e}, // latin small letter n + {0x6f, 0x006f}, // latin small letter o + {0x70, 0x0070}, // latin small letter p + {0x71, 0x0071}, // latin small letter q + {0x72, 0x0072}, // latin small letter r + {0x73, 0x0073}, // latin small letter s + {0x74, 0x0074}, // latin small letter t + {0x75, 0x0075}, // latin small letter u + {0x76, 0x0076}, // latin small letter v + {0x77, 0x0077}, // latin small letter w + {0x78, 0x0078}, // latin small letter x + {0x79, 0x0079}, // latin small letter y + {0x7a, 0x007a}, // latin small letter z + {0x7b, 0x007b}, // left curly bracket + {0x7c, 0x007c}, // vertical line + {0x7d, 0x007d}, // right curly bracket + {0x7e, 0x007e}, // tilde + {0x7f, 0x007f}, // house {0x80, 0x00c7}, // latin capital letter c with cedilla {0x81, 0x00fc}, // latin small letter u with diaeresis {0x82, 0x00e9}, // latin small letter e with acute @@ -326,8 +466,9 @@ static uInt cp437_to_ucs[][2] = {0xff, 0x00a0} // no-break space }; -constexpr uInt lastCP437Item = uInt ( sizeof(cp437_to_ucs) - / sizeof(cp437_to_ucs[0]) ) - 1; +constexpr auto lastCP437Item = \ + std::size_t((sizeof(cp437_to_ucs) / sizeof(cp437_to_ucs[0])) - 1); + } // namespace fc } // namespace finalcut diff --git a/src/include/final/foptiattr.h b/src/include/final/foptiattr.h index d8a6484b..f1562d68 100644 --- a/src/include/final/foptiattr.h +++ b/src/include/final/foptiattr.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 * @@ -77,9 +77,10 @@ class FOptiAttr // Typedefs typedef struct { - wchar_t code; // character code - FColor fg_color; // foreground color - FColor bg_color; // background color + wchar_t code; // character code + wchar_t encoded_code; // encoded output character + FColor fg_color; // foreground color + FColor bg_color; // background color union attribute { diff --git a/src/include/final/fterm.h b/src/include/final/fterm.h index 6d06582a..4ec07e3d 100644 --- a/src/include/final/fterm.h +++ b/src/include/final/fterm.h @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2012-2018 Markus Gans * +* Copyright 2012-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 * @@ -257,9 +257,11 @@ class FTerm static void setEncoding (fc::encoding); static fc::encoding getEncoding(); static std::string getEncodingString(); - static bool charEncodable (uInt); - static uInt charEncode (uInt); - static uInt charEncode (uInt, fc::encoding); + static bool charEncodable (wchar_t); + static wchar_t charEncode (wchar_t); + static wchar_t charEncode (wchar_t, fc::encoding); + static wchar_t cp437_to_unicode (uChar); + static uChar unicode_to_cp437 (wchar_t); static bool scrollTermForward(); static bool scrollTermReverse(); @@ -383,7 +385,6 @@ class FTerm void finish(); void finishOSspecifics1(); void finish_encoding(); - static uInt cp437_to_unicode (uChar); static void setSignalHandler(); static void resetSignalHandler(); static void signal_handler (int); diff --git a/src/include/final/ftermlinux.h b/src/include/final/ftermlinux.h index 87d8b961..9e7e1a48 100644 --- a/src/include/final/ftermlinux.h +++ b/src/include/final/ftermlinux.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 * @@ -166,6 +166,8 @@ class FTermLinux static FKey shiftAltKeyCorrection (const FKey&); static FKey ctrlAltKeyCorrection (const FKey&); static FKey shiftCtrlAltKeyCorrection (const FKey&); + static sInt16 getFontPos (wchar_t ucs); + static void initSpecialCharacter(); // Data Members #if defined(__linux__) diff --git a/src/include/final/fvterm.h b/src/include/final/fvterm.h index fbc1b29c..72c48026 100644 --- a/src/include/final/fvterm.h +++ b/src/include/final/fvterm.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 * @@ -502,7 +502,7 @@ class FVTerm static charData s_ch; // shadow character static charData i_ch; // inherit background character static FPoint* term_pos; // terminal cursor position - static FTermcap::tcap_map* tcap; + static FTermcap::tcap_map* tcap; static FKeyboard* keyboard; static bool terminal_update_complete; static bool terminal_update_pending;