From 5092244b81bb2b0b9c301cde1888ad378ceacb43 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Fri, 18 Sep 2020 17:13:52 +0200 Subject: [PATCH 01/30] FDataPtr was replaced by the template class FData --- ChangeLog | 4 + doc/first-steps.md | 65 ++++++------ examples/background-color.cpp | 8 +- examples/listbox.cpp | 17 ++-- examples/windows.cpp | 8 +- fonts/bdf2code.sh | 2 +- fonts/newfont_8x16.h | 2 +- fonts/newfont_9x16.h | 2 +- fonts/unicodemap.h | 4 +- fonts/vgafont.h | 2 +- src/fapplication.cpp | 12 +++ src/fcharmap.cpp | 8 +- src/fevent.cpp | 13 +-- src/fkey_map.cpp | 4 +- src/flistbox.cpp | 13 +-- src/flistview.cpp | 42 -------- src/fmenuitem.cpp | 69 ++++++------- src/fstring.cpp | 14 +-- src/fswitch.cpp | 12 +-- src/ftermlinux.cpp | 8 +- src/fvterm.cpp | 17 ++-- src/fwidget.cpp | 4 + src/include/final/fapplication.h | 2 + src/include/final/fcallback.h | 132 ++++++++++++------------ src/include/final/fcharmap.h | 6 +- src/include/final/fcombobox.h | 32 +++--- src/include/final/fdata.h | 170 ++++++++++++++++++++++++++----- src/include/final/fevent.h | 46 ++++++++- src/include/final/fkey_map.h | 6 +- src/include/final/flistbox.h | 125 ++++++++++++++++------- src/include/final/flistview.h | 135 +++++++++++++++++------- src/include/final/fmouse.h | 4 +- src/include/final/fscrollbar.h | 5 +- src/include/final/fscrollview.h | 4 +- src/include/final/fstring.h | 4 +- src/include/final/fterm.h | 8 +- src/include/final/ftermbuffer.h | 8 +- src/include/final/ftermcap.h | 26 ++--- src/include/final/ftermlinux.h | 2 +- src/include/final/ftextview.h | 8 +- src/include/final/ftypes.h | 12 ++- src/include/final/fvterm.h | 4 +- src/include/final/fwidget.h | 12 +-- test/fcallback-test.cpp | 4 +- test/fobject-test.cpp | 10 +- 45 files changed, 679 insertions(+), 416 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4b93c1e1..b41173c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2020-09-18 Markus Gans + * The generic data type FDataPtr is now deprecated and was + completely replaced by the template class FData + 2020-09-11 Markus Gans * Fixes a problem with mouse input in Cygwin in non-blocking read mode diff --git a/doc/first-steps.md b/doc/first-steps.md index 67c99515..6b5b158f 100644 --- a/doc/first-steps.md +++ b/doc/first-steps.md @@ -431,7 +431,7 @@ class extendedApplication : public FApplication || last_avg[2] != load_avg[2] ) { FUserEvent user_event(fc::User_Event, 0); - user_event.setData (FDataPtr(&load_avg)); + user_event.setData (load_avg); FApplication::sendEvent (getMainWidget(), &user_event); } @@ -458,8 +458,7 @@ class dialogWidget final : public FDialog private: void onUserEvent (FUserEvent* ev) override { - FDataPtr dataPtr = ev->getData(); - auto& lavg = *(reinterpret_cast(dataPtr)); + const auto& lavg = ev->getData(); std::setlocale(LC_NUMERIC, "C"); loadavg_label.clear(); loadavg_label << "Load average: " << lavg[0] << ", " @@ -530,9 +529,9 @@ to other widget objects. 1. For calling functions or static methods via a pointer: ```cpp -template::type = nullptr - , typename... Args> +template< typename Function + , typename FunctionPointer::type = nullptr + , typename... Args > void FWidget::addCallback ( const FString& cb_signal , Function&& cb_function , Args&&... args) @@ -542,9 +541,9 @@ void FWidget::addCallback ( const FString& cb_signal 2. For calling functions or static methods via a reference: ```cpp -template::type = nullptr - , typename... Args> +template< typename Function + , typename FunctionReference::type = nullptr + , typename... Args > void FWidget::addCallback ( const FString& cb_signal , Function& cb_function , Args&&... args) @@ -554,11 +553,11 @@ void FWidget::addCallback ( const FString& cb_signal 3. For calling a member method of a specific instance: ```cpp -template::type = nullptr - , typename MemberFunctionPointer::type = nullptr - , typename... Args> +template< typename Object + , typename Function + , typename ObjectPointer::type = nullptr + , typename MemberFunctionPointer::type = nullptr + , typename... Args > void FWidget::addCallback ( const FString& cb_signal , Object&& cb_instance , Function&& cb_member @@ -568,9 +567,9 @@ void FWidget::addCallback ( const FString& cb_signal 4. For calling a std::bind call wrapper or a lambda expression: ```cpp -template::type = nullptr - , typename... Args> +template< typename Function + , typename ClassObject::type = nullptr + , typename... Args > void FWidget::addCallback ( const FString& cb_signal , Function&& cb_function , Args&&... args) @@ -580,11 +579,11 @@ void FWidget::addCallback ( const FString& cb_signal 5. For calling a std::bind call wrapper to a specific instance: ```cpp -template::type = nullptr - , typename ClassObject::type = nullptr - , typename... Args> +template< typename Object + , typename Function + , typename ObjectPointer::type = nullptr + , typename ClassObject::type = nullptr + , typename... Args > void FWidget::addCallback ( const FString& cb_signal , Object&& cb_instance , Function&& cb_function @@ -596,9 +595,9 @@ void FWidget::addCallback ( const FString& cb_signal with the keyword auto: ```cpp -template::type = nullptr - , typename... Args> +template< typename Function + , typename ClassObject::type = nullptr + , typename... Args > void FWidget::addCallback ( const FString& cb_signal , Function& cb_function , Args&&... args) @@ -612,8 +611,8 @@ remove all existing callbacks from an object. 1. To delete functions or static methods callbacks via a pointer: ```cpp -template::type = nullptr> +template< typename FunctionPtr + , typename FunctionPointer::type = nullptr > void FWidget::delCallback (FunctionPtr&& cb_func_ptr) {...} ``` @@ -621,8 +620,8 @@ void FWidget::delCallback (FunctionPtr&& cb_func_ptr) 2. To delete functions or static methods callbacks via a reference: ```cpp -template::type = nullptr> +template< typename Function + , typename FunctionReference::type = nullptr > void FWidget::delCallback (Function& cb_function) {...} ``` @@ -630,8 +629,8 @@ void FWidget::delCallback (Function& cb_function) 3. To delete all callbacks from a specific instance: ```cpp -template::type = nullptr> +template< typename Object + , typename ObjectPointer::type = nullptr > void FWidget::delCallback (Object&& cb_instance) {...} ``` @@ -646,8 +645,8 @@ void delCallback (const FString& cb_signal) 5. To delete all callbacks of a signal and specific instance: ```cpp -template::type = nullptr> +template< typename Object + , typename ObjectPointer::type = nullptr > void delCallback (const FString& cb_signal, Object&& cb_instance) {...} ``` diff --git a/examples/background-color.cpp b/examples/background-color.cpp index 0894b8ea..186bdd20 100644 --- a/examples/background-color.cpp +++ b/examples/background-color.cpp @@ -108,8 +108,7 @@ Background::Background (finalcut::FWidget* parent) for (auto& c : color_list) { - FDataPtr data_ptr = reinterpret_cast(&c.second); - finalcut::FListBoxItem item (c.first, data_ptr); + finalcut::FListBoxItem item (c.first, c.second); color_choice.insert(item); } @@ -199,9 +198,8 @@ void Background::cb_choice() uChar r{}; uChar g{}; uChar b{}; - const FDataPtr data_ptr = color_choice.getItemData(); - const RGB* rgb = reinterpret_cast(data_ptr); - std::tie(r, g, b) = *rgb; + const RGB rgb = color_choice.getItemData(); + std::tie(r, g, b) = rgb; red.setValue(r); green.setValue(g); blue.setValue(b); diff --git a/examples/listbox.cpp b/examples/listbox.cpp index da66a48b..210315cd 100644 --- a/examples/listbox.cpp +++ b/examples/listbox.cpp @@ -38,8 +38,8 @@ static std::weak_ptr temp_str; // Function prototypes void doubleToItem ( FListBoxItem& - , FDataPtr container - , int index); + , FDataAccess* container + , std::size_t index); FString& doubleToString (std::list::const_iterator iter); FString& mapToString ( std::map::const_iterator iter ); @@ -47,14 +47,15 @@ FString& mapToString ( std::map* double_list_ptr; - double_list_ptr dbllist = static_cast(container); - std::list::iterator iter = dbllist->begin(); + typedef std::list DblList; + DblList& dbl_list = FListBoxHelper::getContainer(container); + std::list::iterator iter = dbl_list.begin(); std::advance (iter, index); item.setText (FString() << *iter); - item.setData (FDataPtr(&(*iter))); + item.setData (*iter); } // Insert converter functions @@ -129,7 +130,7 @@ Listbox::Listbox (FWidget* parent) // // Insert via lazy conversion on print // - list2.insert (&double_list, doubleToItem); + list2.insert (double_list, doubleToItem); // (container, converter) // // Direct insert of the complete list diff --git a/examples/windows.cpp b/examples/windows.cpp index e7785f23..1283e6f2 100644 --- a/examples/windows.cpp +++ b/examples/windows.cpp @@ -199,7 +199,9 @@ class Window final : public finalcut::FDialog void configureDialogButtons(); void activateWindow (finalcut::FDialog*) const; void adjustSize() override; - template + template void addClickedCallback ( finalcut::FWidget* , InstanceT&&, CallbackT&&, Args&&... ); template @@ -378,7 +380,9 @@ void Window::adjustSize() } //---------------------------------------------------------------------- -template +template void Window::addClickedCallback ( finalcut::FWidget* widget , InstanceT&& instance , CallbackT&& callback diff --git a/fonts/bdf2code.sh b/fonts/bdf2code.sh index 9c842194..1a2922f3 100755 --- a/fonts/bdf2code.sh +++ b/fonts/bdf2code.sh @@ -10,7 +10,7 @@ function create_code_file () echo -e "#define ${INCLUDE_GUARD}\\n" echo -e "namespace finalcut\\n{\\n" echo -e "namespace fc\\n{\\n" - echo -e "static unsigned char ${NAME}[] =\\n{" + echo -e "constexpr unsigned char ${NAME}[] =\\n{" grep -A"${HEIGHT}" "^BITMAP" "$NEWFONTFILE" \ | tr '\n' ',' \ diff --git a/fonts/newfont_8x16.h b/fonts/newfont_8x16.h index bc24802b..e9f377bc 100644 --- a/fonts/newfont_8x16.h +++ b/fonts/newfont_8x16.h @@ -9,7 +9,7 @@ namespace finalcut namespace fc { -static unsigned char __8x16graph[] = +constexpr unsigned char __8x16graph[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */ 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, /* 1 */ diff --git a/fonts/newfont_9x16.h b/fonts/newfont_9x16.h index cfec8120..78f6a8aa 100644 --- a/fonts/newfont_9x16.h +++ b/fonts/newfont_9x16.h @@ -9,7 +9,7 @@ namespace finalcut namespace fc { -static unsigned char __9x16graph[] = +constexpr unsigned char __9x16graph[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */ 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, /* 1 */ diff --git a/fonts/unicodemap.h b/fonts/unicodemap.h index 8b01d63d..09f9703d 100644 --- a/fonts/unicodemap.h +++ b/fonts/unicodemap.h @@ -17,7 +17,7 @@ namespace finalcut namespace fc { -static struct unipair unicode_cp437_pairs[] = +constexpr struct unipair unicode_cp437_pairs[] = { // .----------- unicode // | .---- fontpos @@ -306,7 +306,7 @@ static struct unipair unicode_cp437_pairs[] = {0x266c, 0x0e} }; -static struct unipair unicode_newfont_pairs[] = +constexpr struct unipair unicode_newfont_pairs[] = { // .----------- unicode // | .---- fontpos diff --git a/fonts/vgafont.h b/fonts/vgafont.h index bd0852ec..c4532aad 100644 --- a/fonts/vgafont.h +++ b/fonts/vgafont.h @@ -9,7 +9,7 @@ namespace finalcut namespace fc { -static unsigned char __8x16std[] = +constexpr unsigned char __8x16std[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */ 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0x81, 0xbd, 0x99, 0x81, 0x81, 0x7e, 0x00, 0x00, 0x00, 0x00, /* 1 */ diff --git a/src/fapplication.cpp b/src/fapplication.cpp index ec2b6680..70e5b008 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -121,6 +121,12 @@ FApplication* FApplication::getApplicationObject() return app_object; } +//---------------------------------------------------------------------- +FWidget* FApplication::getKeyboardWidget() +{ + return keyboard_widget; +} + //---------------------------------------------------------------------- FApplication::FLogPtr& FApplication::getLog() { @@ -306,6 +312,12 @@ void FApplication::setDarkTheme() setColorTheme(); } +//---------------------------------------------------------------------- +void FApplication::setKeyboardWidget (FWidget* widget) +{ + keyboard_widget = widget; +} + //---------------------------------------------------------------------- void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev) { diff --git a/src/fcharmap.cpp b/src/fcharmap.cpp index 23bb8753..ad782f45 100644 --- a/src/fcharmap.cpp +++ b/src/fcharmap.cpp @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2015-2019 Markus Gans * +* Copyright 2015-2020 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 * @@ -163,7 +163,7 @@ const std::size_t lastCharItem = \ std::size_t((sizeof(character) / sizeof(character[0])) - 1); -int vt100_key_to_utf8[][2] = +constexpr int vt100_key_to_utf8[][2] = { {fc::vt100_key_rarrow , fc::BlackRightPointingPointer}, // ► {fc::vt100_key_larrow , fc::BlackLeftPointingPointer}, // ◄ @@ -210,7 +210,7 @@ const std::size_t lastKeyItem = \ std::size_t((sizeof(vt100_key_to_utf8) / sizeof(vt100_key_to_utf8[0])) - 1); -wchar_t cp437_ucs[][2] = +constexpr wchar_t cp437_ucs[][2] = { {0x00, 0x0000}, // null {0x01, 0x263a}, // white smiling face @@ -474,7 +474,7 @@ const std::size_t lastCP437Item = \ std::size_t((sizeof(cp437_ucs) / sizeof(cp437_ucs[0])) - 1); // Based on http://www.unicode.org/charts/PDF/UFF00.pdf -const wchar_t halfWidth_fullWidth[][2] = +constexpr wchar_t halfWidth_fullWidth[][2] = { // Fullwidth ASCII variants {0x0020, 0x3000}, // ' ' -> ' ' diff --git a/src/fevent.cpp b/src/fevent.cpp index d9d1468f..588a9e83 100644 --- a/src/fevent.cpp +++ b/src/fevent.cpp @@ -366,18 +366,13 @@ FUserEvent::FUserEvent (fc::events ev_type, int user_event_id) // constructor //---------------------------------------------------------------------- FUserEvent::~FUserEvent() // destructor -{ } +{ + if ( ! external_data_pointer && data_pointer ) + delete data_pointer; +} //---------------------------------------------------------------------- int FUserEvent::getUserId() const { return uid; } -//---------------------------------------------------------------------- -FDataPtr FUserEvent::getData() const -{ return data_pointer; } - -//---------------------------------------------------------------------- -void FUserEvent::setData (FDataPtr data) -{ data_pointer = data; } - } // namespace finalcut diff --git a/src/fkey_map.cpp b/src/fkey_map.cpp index 95a291f0..ea1e0089 100644 --- a/src/fkey_map.cpp +++ b/src/fkey_map.cpp @@ -214,7 +214,7 @@ FKeyMap fkey[] = { 0 , nullptr, "\0" } }; -FMetakeyMap fmetakey[] = +constexpr FMetakeyMap fmetakey[] = { { fc::Fmkey_ic , "\033[2;3~" }, // M-insert { fc::Fmkey_ic , "\033\033[2~" }, // M-insert @@ -447,7 +447,7 @@ FMetakeyMap fmetakey[] = { 0 , "\0" } }; -FKeyName fkeyname[] = +constexpr FKeyName fkeyname[] = { { fc::Fckey_a , "Ctrl+A" }, { fc::Fckey_b , "Ctrl+B" }, diff --git a/src/flistbox.cpp b/src/flistbox.cpp index 163f03ba..4cdf4130 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -51,12 +51,6 @@ FListBoxItem::FListBoxItem (const FListBoxItem& item) , selected{item.selected} { } -//---------------------------------------------------------------------- -FListBoxItem::FListBoxItem (const FString& txt, FDataPtr data) - : text{txt} - , data_pointer{data} -{ } - //---------------------------------------------------------------------- FListBoxItem::~FListBoxItem() // destructor { } @@ -95,6 +89,9 @@ FListBox::FListBox (FWidget* parent) //---------------------------------------------------------------------- FListBox::~FListBox() // destructor { + if ( source_container ) + delete source_container; // for lazy conversion + delOwnTimers(); } @@ -1729,12 +1726,12 @@ void FListBox::changeOnResize() const } //---------------------------------------------------------------------- -void FListBox::lazyConvert(listBoxItems::iterator iter, int y) +void FListBox::lazyConvert(listBoxItems::iterator iter, std::size_t y) { if ( conv_type != lazy_convert || ! iter->getText().isNull() ) return; - lazy_inserter (*iter, source_container, y + yoffset); + lazy_inserter (*iter, source_container, y + std::size_t(yoffset)); const auto column_width = getColumnWidth(iter->text); recalculateHorizontalBar (column_width, hasBrackets(iter)); diff --git a/src/flistview.cpp b/src/flistview.cpp index 77fb518d..7bcb30e2 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -198,21 +198,6 @@ FListViewItem::FListViewItem (iterator parent_iter) insert (this, parent_iter); } -//---------------------------------------------------------------------- -FListViewItem::FListViewItem ( const FStringList& cols - , FDataPtr data - , iterator parent_iter ) - : FObject{nullptr} - , column_list{cols} - , data_pointer{data} -{ - if ( cols.empty() ) - return; - - replaceControlCodes(); - insert (this, parent_iter); -} - //---------------------------------------------------------------------- FListViewItem::~FListViewItem() // destructor { @@ -895,33 +880,6 @@ FObject::iterator FListView::insert ( FListViewItem* item return item_iter; } -//---------------------------------------------------------------------- -FObject::iterator FListView::insert ( const FStringList& cols - , FDataPtr d - , iterator parent_iter ) -{ - FListViewItem* item; - - if ( cols.empty() || parent_iter == getNullIterator() ) - return getNullIterator(); - - if ( ! *parent_iter ) - parent_iter = root; - - try - { - item = new FListViewItem (cols, d, getNullIterator()); - } - catch (const std::bad_alloc&) - { - badAllocOutput ("FListViewItem"); - return getNullIterator(); - } - - item->replaceControlCodes(); - return insert(item, parent_iter); -} - //---------------------------------------------------------------------- void FListView::remove (FListViewItem* item) { diff --git a/src/fmenuitem.cpp b/src/fmenuitem.cpp index 1ebc09c4..2dee3015 100644 --- a/src/fmenuitem.cpp +++ b/src/fmenuitem.cpp @@ -605,47 +605,42 @@ void FMenuItem::createDialogList (FMenu* winmenu) const while ( iter != getDialogList()->end() && *iter ) { auto win = static_cast(*iter); + FMenuItem* win_item{}; + const uInt32 n = uInt32(std::distance(first, iter)); + // get the dialog title + const auto& name = win->getText(); - if ( win ) + try { - FMenuItem* win_item{}; - const uInt32 n = uInt32(std::distance(first, iter)); - // get the dialog title - const auto& name = win->getText(); - - try - { - // create a new dialog list item - win_item = new FMenuItem (name, winmenu); - } - catch (const std::bad_alloc&) - { - badAllocOutput ("FMenuItem"); - return; - } - - if ( n < 9 ) - win_item->addAccelerator (fc::Fmkey_1 + n); // Meta + 1..9 - - win_item->addCallback - ( - "clicked", - static_cast::type>(win_item), - &FMenuItem::cb_switchToDialog, - win - ); - - win->addCallback - ( - "destroy", - static_cast::type>(win_item), - &FMenuItem::cb_destroyDialog, - win - ); - - win_item->associated_window = win; + // create a new dialog list item + win_item = new FMenuItem (name, winmenu); + } + catch (const std::bad_alloc&) + { + badAllocOutput ("FMenuItem"); + return; } + if ( n < 9 ) + win_item->addAccelerator (fc::Fmkey_1 + n); // Meta + 1..9 + + win_item->addCallback + ( + "clicked", + static_cast::type>(win_item), + &FMenuItem::cb_switchToDialog, + win + ); + + win->addCallback + ( + "destroy", + static_cast::type>(win_item), + &FMenuItem::cb_destroyDialog, + win + ); + + win_item->associated_window = win; ++iter; } } diff --git a/src/fstring.cpp b/src/fstring.cpp index 0caa249d..b5be91ad 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp @@ -1212,7 +1212,7 @@ inline void FString::_initLength (std::size_t len) try { - string = new wchar_t[bufsize](); + string = new wchar_t[bufsize]; std::wmemset (string, L'\0', bufsize); } catch (const std::bad_alloc&) @@ -1244,7 +1244,7 @@ void FString::_assign (const wchar_t s[]) try { - string = new wchar_t[bufsize](); + string = new wchar_t[bufsize]; } catch (const std::bad_alloc&) { @@ -1272,7 +1272,7 @@ void FString::_insert (std::size_t len, const wchar_t s[]) try { - string = new wchar_t[bufsize](); + string = new wchar_t[bufsize]; } catch (const std::bad_alloc&) { @@ -1319,7 +1319,7 @@ void FString::_insert ( std::size_t pos try { - sptr = new wchar_t[bufsize](); // generate new string + sptr = new wchar_t[bufsize]; // generate new string } catch (const std::bad_alloc&) { @@ -1363,7 +1363,7 @@ void FString::_remove (std::size_t pos, std::size_t len) try { - sptr = new wchar_t[bufsize](); // generate new string + sptr = new wchar_t[bufsize]; // generate new string } catch (const std::bad_alloc&) { @@ -1417,7 +1417,7 @@ inline const char* FString::_to_cstring (const wchar_t s[]) const try { - c_string = new char[size](); + c_string = new char[size]; // pre-initialiaze the whole string with '\0' std::memset (c_string, '\0', size); @@ -1467,7 +1467,7 @@ inline const wchar_t* FString::_to_wcstring (const char s[]) const try { - dest = new wchar_t[size](); + dest = new wchar_t[size]; // pre-initialiaze the whole string with '\0' std::wmemset (dest, L'\0', size); } diff --git a/src/fswitch.cpp b/src/fswitch.cpp index 58274d2d..b3d4618f 100644 --- a/src/fswitch.cpp +++ b/src/fswitch.cpp @@ -141,15 +141,15 @@ void FSwitch::drawCheckButton() //---------------------------------------------------------------------- inline void FSwitch::drawChecked() { - wchar_t on[6]{L" On "}; - const wchar_t off[6]{L" Off "}; + FString on{L" On "}; + const FString off{L" Off "}; const auto& wc = getColorTheme(); if ( hasFocus() && ! button_pressed ) { if ( FTerm::isMonochron() ) { - std::wcsncpy (on, L" ", 6); + on.setString(L" "); setBold(true); } else if ( FTerm::getMaxColor() < 16 ) @@ -191,8 +191,8 @@ inline void FSwitch::drawChecked() //---------------------------------------------------------------------- inline void FSwitch::drawUnchecked() { - const wchar_t on[6]{L" On "}; - wchar_t off[6]{L" Off "}; + const FString on{L" On "}; + FString off{L" Off "}; const auto& wc = getColorTheme(); setColor (wc->button_inactive_fg, wc->button_inactive_bg); @@ -206,7 +206,7 @@ inline void FSwitch::drawUnchecked() { if ( FTerm::isMonochron() ) { - std::wcsncpy (off, L"", 6); + off.setString(L""); setBold(true); } else if ( FTerm::getMaxColor() < 16 ) diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index 8023a248..046de52b 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -278,7 +278,7 @@ bool FTermLinux::loadVGAFont() struct unimapdesc unimap; unimap.entry_ct = uInt16 ( sizeof(fc::unicode_cp437_pairs) / sizeof(unipair) ); - unimap.entries = &fc::unicode_cp437_pairs[0]; + unimap.entries = const_cast(&fc::unicode_cp437_pairs[0]); setUnicodeMap(&unimap); } else @@ -327,7 +327,7 @@ bool FTermLinux::loadNewFont() struct unimapdesc unimap; unimap.entry_ct = uInt16 ( sizeof(fc::unicode_newfont_pairs) / sizeof(unipair) ); - unimap.entries = &fc::unicode_newfont_pairs[0]; + unimap.entries = const_cast(&fc::unicode_newfont_pairs[0]); setUnicodeMap(&unimap); } else @@ -660,7 +660,7 @@ FTermLinux::modifier_key& FTermLinux::getModifierKey() } //---------------------------------------------------------------------- -int FTermLinux::setScreenFont ( uChar fontdata[], uInt count +int FTermLinux::setScreenFont ( const uChar fontdata[], uInt count , uInt fontwidth, uInt fontheight , bool direct) { @@ -681,7 +681,7 @@ int FTermLinux::setScreenFont ( uChar fontdata[], uInt count font.charcount = count; if ( direct ) - font.data = fontdata; + font.data = const_cast(fontdata); else { const std::size_t bytes_per_line = font.width / 8; diff --git a/src/fvterm.cpp b/src/fvterm.cpp index 0b94b853..a9611754 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -1471,20 +1471,17 @@ FVTerm::covered_state FVTerm::isCovered ( const FPoint& pos if ( FWidget::getWindowList() && ! FWidget::getWindowList()->empty() ) { - bool found( area == vdesktop ); + bool found{ area == vdesktop }; for (auto& win_obj : *FWidget::getWindowList()) { const auto& win = win_obj->getVWin(); - if ( ! win ) + if ( ! (win && win->visible) ) continue; - if ( ! win->visible ) - continue; - - const int win_x = win->offset_left; - const int win_y = win->offset_top; + const int& win_x = win->offset_left; + const int& win_y = win->offset_top; const FRect geometry { win_x , win_y , std::size_t(win->width) + std::size_t(win->right_shadow) , std::size_t(win->height) + std::size_t(win->bottom_shadow) }; @@ -1492,9 +1489,9 @@ FVTerm::covered_state FVTerm::isCovered ( const FPoint& pos if ( found && geometry.contains(pos) ) { const int width = win->width + win->right_shadow; - const int x = pos.getX(); - const int y = pos.getY(); - auto tmp = &win->data[(y - win_y) * width + (x - win_x)]; + const int& x = pos.getX(); + const int& y = pos.getY(); + const auto& tmp = &win->data[(y - win_y) * width + (x - win_x)]; if ( tmp->attr.bit.color_overlay ) { diff --git a/src/fwidget.cpp b/src/fwidget.cpp index d3afc904..e5442eb9 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -109,6 +109,10 @@ FWidget::~FWidget() // destructor if ( this == getClickedWidget() ) setClickedWidget(nullptr); + // unset keyboard widget + if ( this == FApplication::getKeyboardWidget() ) + FApplication::setKeyboardWidget(nullptr); + // unset the local window widget focus if ( flags.focus ) { diff --git a/src/include/final/fapplication.h b/src/include/final/fapplication.h index 40a49f8b..d67f2e71 100644 --- a/src/include/final/fapplication.h +++ b/src/include/final/fapplication.h @@ -114,6 +114,7 @@ class FApplication : public FWidget int getArgc() const; char** getArgv() const; static FApplication* getApplicationObject(); + static FWidget* getKeyboardWidget(); static FLogPtr& getLog(); // Mutator @@ -136,6 +137,7 @@ class FApplication : public FWidget void initTerminal() override; static void setDefaultTheme(); static void setDarkTheme(); + static void setKeyboardWidget (FWidget*); static void closeConfirmationDialog (FWidget*, FCloseEvent*); // Callback method diff --git a/src/include/final/fcallback.h b/src/include/final/fcallback.h index 765c8b38..12829d09 100644 --- a/src/include/final/fcallback.h +++ b/src/include/final/fcallback.h @@ -58,7 +58,7 @@ struct FCallbackData FCallbackData() { } - template + template FCallbackData (const FString& s, FWidget* i, FuncPtr m, const FCall& c) : cb_signal(s) , cb_instance(i) @@ -88,7 +88,7 @@ class FCallback { public: // Using-declaration - template + template using ObjectPointer = typename std::enable_if< ! std::is_member_function_pointer::value && ! std::is_function::type>::value @@ -97,7 +97,7 @@ class FCallback && std::is_object::value && ! std::is_class::value , std::nullptr_t >; - template + template using ClassObject = typename std::enable_if< ! std::is_member_function_pointer::value && ! std::is_function::type>::value @@ -106,7 +106,7 @@ class FCallback && std::is_object::value && std::is_class::value , std::nullptr_t >; - template + template using MemberFunctionPointer = typename std::enable_if< std::is_member_function_pointer::value && ! std::is_function::type>::value @@ -115,7 +115,7 @@ class FCallback && std::is_object::value && ! std::is_class::value , std::nullptr_t >; - template + template using FunctionPointer = typename std::enable_if< ! std::is_member_function_pointer::value && std::is_function::type>::value @@ -124,7 +124,7 @@ class FCallback && std::is_object::value && ! std::is_class::value , std::nullptr_t >; - template + template using FunctionReference = typename std::enable_if< ! std::is_member_function_pointer::value && std::is_function::type>::value @@ -151,61 +151,61 @@ class FCallback std::size_t getCallbackCount() const; // Methods - template::type = nullptr - , typename MemberFunctionPointer::type = nullptr - , typename... Args> + template ::type = nullptr + , typename MemberFunctionPointer::type = nullptr + , typename... Args> void addCallback ( const FString& cb_signal , Object&& cb_instance , Function&& cb_member , Args&&... args) noexcept; - template::type = nullptr - , typename ClassObject::type = nullptr - , typename... Args> + template ::type = nullptr + , typename ClassObject::type = nullptr + , typename... Args> void addCallback ( const FString& cb_signal , Object&& cb_instance , Function&& cb_function , Args&&... args) noexcept; - template::type = nullptr - , typename... Args> + template < typename Function + , typename ClassObject::type = nullptr + , typename... Args> void addCallback ( const FString& cb_signal , Function&& cb_function , Args&&... args) noexcept; - template::type = nullptr - , typename... Args> + template ::type = nullptr + , typename... Args> void addCallback ( const FString& cb_signal , Function& cb_function , Args&&... args) noexcept; - template::type = nullptr - , typename... Args> + template ::type = nullptr + , typename... Args> void addCallback ( const FString& cb_signal , Function& cb_function , Args&&... args) noexcept; - template::type = nullptr - , typename... Args> + template ::type = nullptr + , typename... Args> void addCallback ( const FString& cb_signal , Function&& cb_function , Args&&... args) noexcept; - template::type = nullptr> + template ::type = nullptr> void delCallback (Object&& cb_instance) noexcept; void delCallback (const FString& cb_signal); - template::type = nullptr> + template ::type = nullptr> void delCallback ( const FString& cb_signal , Object&& cb_instance ) noexcept; - template::type = nullptr> + template ::type = nullptr> void delCallback (FunctionPtr&& cb_func_ptr) noexcept; - template::type = nullptr> + template ::type = nullptr> void delCallback (const Function& cb_function); void delCallback(); void emitCallback (const FString& emit_signal) const; @@ -228,11 +228,11 @@ inline std::size_t FCallback::getCallbackCount() const { return callback_objects.size(); } //---------------------------------------------------------------------- -template::type - , typename FCallback::MemberFunctionPointer::type - , typename... Args> +template ::type + , typename FCallback::MemberFunctionPointer::type + , typename... Args> inline void FCallback::addCallback ( const FString& cb_signal , Object&& cb_instance , Function&& cb_member @@ -249,11 +249,11 @@ inline void FCallback::addCallback ( const FString& cb_signal } //---------------------------------------------------------------------- -template::type - , typename FCallback::ClassObject::type - , typename... Args> +template ::type + , typename FCallback::ClassObject::type + , typename... Args> inline void FCallback::addCallback ( const FString& cb_signal , Object&& cb_instance , Function&& cb_function @@ -267,9 +267,9 @@ inline void FCallback::addCallback ( const FString& cb_signal } //---------------------------------------------------------------------- -template::type - , typename... Args> +template ::type + , typename... Args> inline void FCallback::addCallback ( const FString& cb_signal , Function&& cb_function , Args&&... args) noexcept @@ -283,9 +283,9 @@ inline void FCallback::addCallback ( const FString& cb_signal } //---------------------------------------------------------------------- -template::type - , typename... Args> +template ::type + , typename... Args> inline void FCallback::addCallback ( const FString& cb_signal , Function& cb_function , Args&&... args) noexcept @@ -298,9 +298,9 @@ inline void FCallback::addCallback ( const FString& cb_signal } //---------------------------------------------------------------------- -template::type - , typename... Args> +template ::type + , typename... Args> inline void FCallback::addCallback ( const FString& cb_signal , Function& cb_function , Args&&... args) noexcept @@ -314,9 +314,9 @@ inline void FCallback::addCallback ( const FString& cb_signal } //---------------------------------------------------------------------- -template::type - , typename... Args> +template ::type + , typename... Args> inline void FCallback::addCallback ( const FString& cb_signal , Function&& cb_function , Args&&... args) noexcept @@ -331,8 +331,8 @@ inline void FCallback::addCallback ( const FString& cb_signal } //---------------------------------------------------------------------- -template::type> +template ::type> inline void FCallback::delCallback (Object&& cb_instance) noexcept { // Deletes entries with the given instance from the callback list @@ -352,8 +352,8 @@ inline void FCallback::delCallback (Object&& cb_instance) noexcept } //---------------------------------------------------------------------- -template::type> +template ::type> inline void FCallback::delCallback ( const FString& cb_signal , Object&& cb_instance ) noexcept { @@ -376,8 +376,8 @@ inline void FCallback::delCallback ( const FString& cb_signal } //---------------------------------------------------------------------- -template::type> +template ::type> inline void FCallback::delCallback (FunctionPtr&& cb_func_ptr) noexcept { // Deletes entries with the given function pointer @@ -399,8 +399,8 @@ inline void FCallback::delCallback (FunctionPtr&& cb_func_ptr) noexcept } //---------------------------------------------------------------------- -template::type> +template ::type> inline void FCallback::delCallback (const Function& cb_function) { // Deletes entries with the given function reference diff --git a/src/include/final/fcharmap.h b/src/include/final/fcharmap.h index 009c4a76..02caf1c2 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-2019 Markus Gans * +* Copyright 2015-2020 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 * @@ -39,10 +39,10 @@ namespace fc extern uInt character[][fc::NUM_OF_ENCODINGS]; extern const std::size_t lastCharItem; -extern int vt100_key_to_utf8[][2]; +extern const int vt100_key_to_utf8[][2]; extern const std::size_t lastKeyItem; -extern wchar_t cp437_ucs[][2]; +extern const wchar_t cp437_ucs[][2]; extern const std::size_t lastCP437Item; extern const wchar_t halfWidth_fullWidth[][2]; diff --git a/src/include/final/fcombobox.h b/src/include/final/fcombobox.h index 8078a85b..18411d0f 100644 --- a/src/include/final/fcombobox.h +++ b/src/include/final/fcombobox.h @@ -150,7 +150,8 @@ class FComboBox : public FWidget const FString getClassName() const override; std::size_t getCount() const; FString getText() const; - FDataPtr getItemData(); + template + clean_fdata_t
& getItemData(); FLineEdit::label_o getLabelOrientation() const; // Mutators @@ -182,11 +183,13 @@ class FComboBox : public FWidget // Methods void insert (const FListBoxItem&); - template + template void insert ( const std::initializer_list& list - , FDataPtr = nullptr ); - template - void insert (const ItemT&, FDataPtr = nullptr); + , DT&& = DT() ); + template + void insert (const ItemT&, DT&& = DT()); void remove (std::size_t); void reserve (std::size_t); void clear(); @@ -247,10 +250,11 @@ inline FString FComboBox::getText() const { return input_field.getText(); } //---------------------------------------------------------------------- -inline FDataPtr FComboBox::getItemData() +template +inline clean_fdata_t
& FComboBox::getItemData() { const std::size_t index = list_window.list.currentItem(); - return list_window.list.getItem(index).getData(); + return list_window.list.getItem(index).getData
(); } //---------------------------------------------------------------------- @@ -298,21 +302,23 @@ inline bool FComboBox::hasShadow() const { return getFlags().shadow; } //---------------------------------------------------------------------- -template -void FComboBox::insert (const std::initializer_list& list, FDataPtr d) +template +void FComboBox::insert (const std::initializer_list& list, DT&& d) { for (auto& item : list) { - FListBoxItem listItem (FString() << item, d); + FListBoxItem listItem (FString() << item, std::forward
(d)); insert (listItem); } } //---------------------------------------------------------------------- -template -void FComboBox::insert (const ItemT& item, FDataPtr d) +template +void FComboBox::insert (const ItemT& item, DT&& d) { - FListBoxItem listItem (FString() << item, d); + FListBoxItem listItem (FString() << item, std::forward
(d)); insert (listItem); } diff --git a/src/include/final/fdata.h b/src/include/final/fdata.h index 02e974eb..9272b07a 100644 --- a/src/include/final/fdata.h +++ b/src/include/final/fdata.h @@ -20,6 +20,19 @@ * . * ***********************************************************************/ +/* Inheritance diagram + * ═══════════════════ + * + * ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▏ + * ▕ FDataAccess ▏ + * ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▏ + * ▲ + * │ + * ▕▔▔▔▔▔▔▔▏ + * ▕ FData ▏ + * ▕▁▁▁▁▁▁▁▏ + */ + #ifndef FDATA_H #define FDATA_H @@ -29,11 +42,55 @@ #include -template -struct FData +namespace finalcut { - explicit FData (T v) // constructor + + +//---------------------------------------------------------------------- +// struct FDataAccess +//---------------------------------------------------------------------- + +template +struct FData; // Class forward declaration + +struct FDataAccess +{ + public: + virtual ~FDataAccess(); + + template + const T& get() const + { + return static_cast&>(*this).get(); + } + + template + void set (const V& v) + { + static_cast&>(*this).set(v); + } +}; + +//---------------------------------------------------------------------- +inline FDataAccess::~FDataAccess() +{ } + + +//---------------------------------------------------------------------- +// struct FData +//---------------------------------------------------------------------- + +template +struct FData : public FDataAccess +{ + explicit FData (T& v) // constructor + : value_ref{v} + { } + + explicit FData (T&& v) // constructor : value{v} + , value_ref{value} { } ~FData() // destructor @@ -41,64 +98,131 @@ struct FData FData (const FData& d) // Copy constructor : value{d.value} + , value_ref{d.value_ref} { } FData& operator = (const FData& d) // Copy assignment operator (=) { value = d.value; - return *this; - } - - FData (FData&& d) noexcept // Move constructor - : value{std::move(d.value)} - { } - - FData& operator = (FData&& d) noexcept // Move assignment operator (=) - { - value = std::move(d.value); + value_ref = d.value_ref; return *this; } T operator () () const { - return value; + return value_ref; } - template + template T operator () (Args... args) const { - return value(args...); + return value_ref(args...); } explicit operator T () const { - return value; + return value_ref; } T& get() { - return value; + return value_ref; } void set (const T& v) { - value = v; + value_ref = v; + } + + bool isInitializedCopy() + { + return bool(value); + } + + bool isInitializedReference() + { + return ! isInitializedCopy(); } FData& operator << (const T& v) { - value = v; + value_ref = v; return *this; } friend std::ostream& operator << (std::ostream &os, const FData& data) { - os << data.value; + os << data.value_ref; return os; } - T value; + private: + T value{}; + + public: + T& value_ref; }; -#endif // FDATA_H +// non-member functions +//---------------------------------------------------------------------- +namespace internal +{ + +template ::value + , bool isFunction = std::is_function::value> +struct cleanCondition; + +//---------------------------------------------------------------------- +template +struct cleanCondition +{ + // Leave the type untouched + typedef T type; +}; + +//---------------------------------------------------------------------- +template +struct cleanCondition +{ + // Array to pointer + typedef typename std::remove_extent::type* type; +}; + +//---------------------------------------------------------------------- +template +struct cleanCondition +{ + // Add pointer to function + typedef typename std::add_pointer::type type; +}; + +} // namespace internal + +//---------------------------------------------------------------------- +template +class cleanFData +{ + private: + typedef typename std::remove_reference::type remove_ref; + + public: + // Similar to std::decay, but keeps const and volatile + typedef typename internal::cleanCondition::type type; +}; + +//---------------------------------------------------------------------- +template +using clean_fdata_t = typename cleanFData::type; + +//---------------------------------------------------------------------- +template +constexpr FData>* makeFData (T&& data) +{ + return new FData>(std::forward(data)); +} + +} // namespace finalcut + +#endif // FDATA_H diff --git a/src/include/final/fevent.h b/src/include/final/fevent.h index b4c8873b..e22d098f 100644 --- a/src/include/final/fevent.h +++ b/src/include/final/fevent.h @@ -342,15 +342,51 @@ class FUserEvent : public FEvent // user event // Disable copy assignment operator (=) FUserEvent& operator = (const FUserEvent&) = delete; - int getUserId() const; - FDataPtr getData() const; - void setData (FDataPtr); + int getUserId() const; + template + FData&& getFDataObject() const; + template + clean_fdata_t& getData() const; + template + void setFDataObject (T&&); + template + void setData (T&&); private: - int uid{0}; - FDataPtr data_pointer{nullptr}; + int uid{0}; + FDataAccess* data_pointer{nullptr}; + bool external_data_pointer{false}; }; +//---------------------------------------------------------------------- +template +inline FData&& FUserEvent::getFDataObject() const +{ + return static_cast&&>(*data_pointer); +} + +//---------------------------------------------------------------------- +template +inline clean_fdata_t& FUserEvent::getData() const +{ + return static_cast>&>(*data_pointer).get(); +} + +//---------------------------------------------------------------------- +template +inline void FUserEvent::setFDataObject (T&& fdata) +{ + external_data_pointer = true; + data_pointer = &(std::forward(fdata)); +} +//---------------------------------------------------------------------- +template +inline void FUserEvent::setData (T&& data) +{ + external_data_pointer = false; + data_pointer = makeFData(std::forward(data)); +} + } // namespace finalcut #endif // FEVENT_H diff --git a/src/include/final/fkey_map.h b/src/include/final/fkey_map.h index 5a623e42..12dfaa57 100644 --- a/src/include/final/fkey_map.h +++ b/src/include/final/fkey_map.h @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2015-2019 Markus Gans * +* Copyright 2015-2020 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 * @@ -34,8 +34,8 @@ namespace fc { extern FKeyMap fkey[]; -extern FMetakeyMap fmetakey[]; -extern FKeyName fkeyname[]; +extern const FMetakeyMap fmetakey[]; +extern const FKeyName fkeyname[]; } // namespace fc diff --git a/src/include/final/flistbox.h b/src/include/final/flistbox.h index e5100a8c..58c2aaea 100644 --- a/src/include/final/flistbox.h +++ b/src/include/final/flistbox.h @@ -72,7 +72,8 @@ class FListBoxItem // Constructors FListBoxItem (); FListBoxItem (const FListBoxItem&); // copy constructor - explicit FListBoxItem (const FString&, FDataPtr = nullptr); + template + explicit FListBoxItem (const FString&, DT&& = DT() ); // Destructor virtual ~FListBoxItem(); @@ -83,11 +84,13 @@ class FListBoxItem // Accessors virtual const FString getClassName() const; virtual FString getText() const; - virtual FDataPtr getData() const; + template + clean_fdata_t
& getData() const; // Mutators void setText (const FString&); - void setData (FDataPtr); + template + void setData (DT&&); // Methods void clear(); @@ -95,7 +98,7 @@ class FListBoxItem private: // Data members FString text{}; - FDataPtr data_pointer{nullptr}; + FDataAccess* data_pointer{nullptr}; fc::brackets_type brackets{fc::NoBrackets}; bool selected{false}; @@ -105,6 +108,13 @@ class FListBoxItem // FListBoxItem inline functions +//---------------------------------------------------------------------- +template +inline FListBoxItem::FListBoxItem (const FString& txt, DT&& data) + : text{txt} + , data_pointer{makeFData(std::forward
(data))} +{ } + //---------------------------------------------------------------------- inline const FString FListBoxItem::getClassName() const { return "FListBoxItem"; } @@ -114,16 +124,22 @@ inline FString FListBoxItem::getText() const { return text; } //---------------------------------------------------------------------- -inline FDataPtr FListBoxItem::getData() const -{ return data_pointer; } +template +inline clean_fdata_t
& FListBoxItem::getData() const +{ + return static_cast>&>(*data_pointer).get(); +} //---------------------------------------------------------------------- inline void FListBoxItem::setText (const FString& txt) { text.setString(txt); } //---------------------------------------------------------------------- -inline void FListBoxItem::setData (FDataPtr data) -{ data_pointer = data; } +template +inline void FListBoxItem::setData (DT&& data) +{ + data_pointer = makeFData(std::forward
(data)); +} //---------------------------------------------------------------------- inline void FListBoxItem::clear() @@ -145,9 +161,11 @@ class FListBox : public FWidget // Constructor explicit FListBox (FWidget* = nullptr); - template + template FListBox (Iterator, Iterator, InsertConverter, FWidget* = nullptr); - template + template FListBox (Container, LazyConverter, FWidget* = nullptr); // Disable copy constructor @@ -197,21 +215,30 @@ class FListBox : public FWidget // Methods void hide() override; - template - void insert (Iterator, Iterator, InsertConverter); - template - void insert (Container, LazyConverter); + template + void insert ( Iterator, Iterator + , const InsertConverter& ); + template + void insert ( const Container& + , const LazyConverter& ); + template + void insert (Container*, const LazyConverter&); void insert (const FListBoxItem&); - template + template void insert ( const std::initializer_list& list , fc::brackets_type = fc::NoBrackets , bool = false - , FDataPtr = nullptr ); - template + , DT&& = DT() ); + template void insert ( const ItemT& , fc::brackets_type = fc::NoBrackets , bool = false - , FDataPtr = nullptr ); + , DT&& = DT() ); void remove (std::size_t); void reserve (std::size_t); void clear(); @@ -236,7 +263,7 @@ class FListBox : public FWidget // Typedefs typedef std::unordered_map> keyMap; typedef std::unordered_map> keyMapResult; - typedef std::function lazyInsert; + typedef std::function lazyInsert; // Enumeration enum convert_type @@ -305,7 +332,7 @@ class FListBox : public FWidget void processSelect() const; void processChanged() const; void changeOnResize() const; - void lazyConvert (listBoxItems::iterator, int); + void lazyConvert (listBoxItems::iterator, std::size_t); listBoxItems::iterator index2iterator (std::size_t); listBoxItems::const_iterator index2iterator (std::size_t index) const; // Callback methods @@ -317,7 +344,7 @@ class FListBox : public FWidget // Data members listBoxItems itemlist{}; - FDataPtr source_container{nullptr}; + FDataAccess* source_container{nullptr}; FScrollbarPtr vbar{nullptr}; FScrollbarPtr hbar{nullptr}; FString text{}; @@ -342,10 +369,23 @@ class FListBox : public FWidget bool click_on_list{false}; }; +// non-member function +//---------------------------------------------------------------------- +namespace FListBoxHelper +{ + +template +constexpr clean_fdata_t& getContainer(FDataAccess* container) +{ + return static_cast>&>(*container).get(); +} + +} // namespace FListBoxHelper // FListBox inline functions //---------------------------------------------------------------------- -template +template inline FListBox::FListBox ( Iterator first , Iterator last , InsertConverter convert @@ -362,7 +402,8 @@ inline FListBox::FListBox ( Iterator first } //---------------------------------------------------------------------- -template +template inline FListBox::FListBox ( Container container , LazyConverter convert , FWidget* parent ) @@ -475,10 +516,11 @@ inline void FListBox::reserve (std::size_t new_cap) { itemlist.reserve(new_cap); } //---------------------------------------------------------------------- -template +template inline void FListBox::insert ( Iterator first , Iterator last - , InsertConverter convert ) + , const InsertConverter& convert ) { conv_type = direct_convert; @@ -490,13 +532,14 @@ inline void FListBox::insert ( Iterator first } //---------------------------------------------------------------------- -template -void FListBox::insert (Container container, LazyConverter convert) +template +void FListBox::insert (const Container& container, const LazyConverter& converter) { conv_type = lazy_convert; - source_container = container; - lazy_inserter = convert; - const std::size_t size = container->size(); + source_container = makeFData(container); + lazy_inserter = converter; + const std::size_t size = container.size(); if ( size > 0 ) itemlist.resize(size); @@ -505,15 +548,24 @@ void FListBox::insert (Container container, LazyConverter convert) } //---------------------------------------------------------------------- -template +template +void FListBox::insert (Container* container, const LazyConverter& converter) +{ + insert (*container, converter); +} + +//---------------------------------------------------------------------- +template void FListBox::insert ( const std::initializer_list& list , fc::brackets_type b , bool s - , FDataPtr d ) + , DT&& d ) { for (auto& item : list) { - FListBoxItem listItem (FString() << item, d); + FListBoxItem listItem (FString() << item, std::forward
(d)); listItem.brackets = b; listItem.selected = s; insert (listItem); @@ -521,13 +573,14 @@ void FListBox::insert ( const std::initializer_list& list } //---------------------------------------------------------------------- -template +template void FListBox::insert ( const ItemT& item , fc::brackets_type b , bool s - , FDataPtr d ) + , DT&& d ) { - FListBoxItem listItem (FString() << item, d); + FListBoxItem listItem (FString() << item, std::forward
(d)); listItem.brackets = b; listItem.selected = s; insert (listItem); diff --git a/src/include/final/flistview.h b/src/include/final/flistview.h index 6bb84a90..dad678a6 100644 --- a/src/include/final/flistview.h +++ b/src/include/final/flistview.h @@ -54,6 +54,7 @@ #include "final/fscrollbar.h" #include "final/ftermbuffer.h" +#include "final/ftypes.h" #include "final/fwidget.h" namespace finalcut @@ -74,9 +75,8 @@ class FListViewItem : public FObject // Constructor FListViewItem (const FListViewItem&); // copy constructor explicit FListViewItem (iterator); - FListViewItem ( const FStringList& - , FDataPtr - , iterator ); + template + FListViewItem (const FStringList&, DT&&, iterator); // Destructor ~FListViewItem() override; @@ -89,12 +89,14 @@ class FListViewItem : public FObject uInt getColumnCount() const; int getSortColumn() const; FString getText (int) const; - FDataPtr getData() const; + template + clean_fdata_t
& getData() const; uInt getDepth() const; // Mutators void setText (int, const FString&); - void setData (FDataPtr); + template + void setData (DT&&); void setCheckable (bool); void setChecked (bool); @@ -124,7 +126,7 @@ class FListViewItem : public FObject // Data members FStringList column_list{}; - FDataPtr data_pointer{nullptr}; + FDataAccess* data_pointer{nullptr}; iterator root{}; std::size_t visible_lines{1}; bool expandable{false}; @@ -139,6 +141,22 @@ class FListViewItem : public FObject // FListViewItem inline functions +//---------------------------------------------------------------------- +template +inline FListViewItem::FListViewItem ( const FStringList& cols + , DT&& data + , iterator parent_iter ) + : FObject{nullptr} + , column_list{cols} + , data_pointer{makeFData(std::forward
(data))} +{ + if ( cols.empty() ) + return; + + replaceControlCodes(); + insert (this, parent_iter); +} + //---------------------------------------------------------------------- inline const FString FListViewItem::getClassName() const { return "FListViewItem"; } @@ -148,12 +166,18 @@ inline uInt FListViewItem::getColumnCount() const { return uInt(column_list.size()); } //---------------------------------------------------------------------- -inline FDataPtr FListViewItem::getData() const -{ return data_pointer; } +template +inline clean_fdata_t
& FListViewItem::getData() const +{ + return static_cast>&>(*data_pointer).get(); +} //---------------------------------------------------------------------- -inline void FListViewItem::setData (FDataPtr data) -{ data_pointer = data; } +template +inline void FListViewItem::setData (DT&& data) +{ + data_pointer = makeFData(std::forward
(data)); +} //---------------------------------------------------------------------- inline void FListViewItem::setChecked (bool checked) @@ -312,32 +336,38 @@ class FListView : public FWidget void hide() override; iterator insert (FListViewItem*); iterator insert (FListViewItem*, iterator); + template iterator insert ( const FStringList& - , FDataPtr = nullptr ); + , DT&& = DT() ); iterator insert ( const FStringList& , iterator ); + template iterator insert ( const FStringList& - , FDataPtr + , DT&& , iterator ); - template + template iterator insert ( const std::initializer_list& - , FDataPtr = nullptr ); + , DT&& = DT() ); template iterator insert ( const std::initializer_list& , iterator ); - template + template iterator insert ( const std::initializer_list& - , FDataPtr + , DT&& , iterator ); - template + template iterator insert ( const std::vector& - , FDataPtr = nullptr ); + , DT&& = DT() ); template iterator insert ( const std::vector& , iterator ); - template + template iterator insert ( const std::vector& - , FDataPtr + , DT&& , iterator ); void remove (FListViewItem*); void clear(); @@ -560,9 +590,10 @@ inline FObject::iterator FListView::insert (FListViewItem* item) { return insert (item, root); } //---------------------------------------------------------------------- +template inline FObject::iterator - FListView::insert (const FStringList& cols, FDataPtr d) -{ return insert (cols, d, root); } + FListView::insert (const FStringList& cols, DT&& d) +{ return insert (cols, std::forward
(d), root); } //---------------------------------------------------------------------- inline FObject::iterator @@ -571,23 +602,53 @@ inline FObject::iterator { return insert (cols, nullptr, parent_iter); } //---------------------------------------------------------------------- -template -inline FObject::iterator - FListView::insert (const std::initializer_list& list, FDataPtr d) -{ return insert (list, d, root); } +template +inline FObject::iterator FListView::insert ( const FStringList& cols + , DT&& d + , iterator parent_iter ) +{ + FListViewItem* item; + + if ( cols.empty() || parent_iter == getNullIterator() ) + return getNullIterator(); + + if ( ! *parent_iter ) + parent_iter = root; + + try + { + item = new FListViewItem (cols, std::forward
(d), getNullIterator()); + } + catch (const std::bad_alloc&) + { + badAllocOutput ("FListViewItem"); + return getNullIterator(); + } + + item->replaceControlCodes(); + return insert(item, parent_iter); +} //---------------------------------------------------------------------- -template +template +inline FObject::iterator + FListView::insert (const std::initializer_list& list, DT&& d) +{ return insert (list, std::forward
(d), root); } + +//---------------------------------------------------------------------- +template inline FObject::iterator FListView::insert ( const std::initializer_list& list , iterator parent_iter ) { return insert (list, 0, parent_iter); } //---------------------------------------------------------------------- -template +template FObject::iterator FListView::insert ( const std::initializer_list& list - , FDataPtr d + , DT&& d , iterator parent_iter ) { FStringList str_cols; @@ -602,15 +663,16 @@ FObject::iterator } ); - auto item_iter = insert (str_cols, d, parent_iter); + auto item_iter = insert (str_cols, std::forward
(d), parent_iter); return item_iter; } //---------------------------------------------------------------------- -template +template inline FObject::iterator - FListView::insert (const std::vector& cols, FDataPtr d) -{ return insert (cols, d, root); } + FListView::insert (const std::vector& cols, DT&& d) +{ return insert (cols, std::forward
(d), root); } //---------------------------------------------------------------------- template @@ -620,10 +682,11 @@ inline FObject::iterator { return insert (cols, 0, parent_iter); } //---------------------------------------------------------------------- -template +template FObject::iterator FListView::insert ( const std::vector& cols - , FDataPtr d + , DT&& d , iterator parent_iter ) { FStringList str_cols; @@ -638,7 +701,7 @@ FObject::iterator } ); - auto item_iter = insert (str_cols, d, parent_iter); + auto item_iter = insert (str_cols, std::forward
(d), parent_iter); return item_iter; } diff --git a/src/include/final/fmouse.h b/src/include/final/fmouse.h index e182c9b7..7d912232 100644 --- a/src/include/final/fmouse.h +++ b/src/include/final/fmouse.h @@ -130,7 +130,7 @@ class FMouse bool isInputDataPending() const; // Methods - template + template static FMouse* createMouseObject (); void clearButtonState(); virtual void setRawData (FKeyboard::keybuffer&) = 0; @@ -193,7 +193,7 @@ class FMouse }; //---------------------------------------------------------------------- -template +template inline FMouse* FMouse::createMouseObject() { return new ClassT; diff --git a/src/include/final/fscrollbar.h b/src/include/final/fscrollbar.h index 5433ff4d..856cc7c5 100644 --- a/src/include/final/fscrollbar.h +++ b/src/include/final/fscrollbar.h @@ -170,9 +170,10 @@ class FScrollbar : public FWidget }; -// non-member function forward declarations +// non-member function //---------------------------------------------------------------------- -template +template void initScrollbar ( FScrollbarPtr& bar , fc::orientation o , Instance cb_instance diff --git a/src/include/final/fscrollview.h b/src/include/final/fscrollview.h index ad90716f..fa3195b8 100644 --- a/src/include/final/fscrollview.h +++ b/src/include/final/fscrollview.h @@ -163,7 +163,7 @@ class FScrollView : public FWidget void init(); void mapKeyFunctions(); void calculateScrollbarPos() const; - template + template void initScrollbar ( FScrollbarPtr& , fc::orientation , Callback ); @@ -268,7 +268,7 @@ inline void FScrollView::print (const FPoint& pos) } //---------------------------------------------------------------------- -template +template inline void FScrollView::initScrollbar ( FScrollbarPtr& bar , fc::orientation o , Callback cb_handler ) diff --git a/src/include/final/fstring.h b/src/include/final/fstring.h index 5a89b97b..78379176 100644 --- a/src/include/final/fstring.h +++ b/src/include/final/fstring.h @@ -177,7 +177,7 @@ class FString wchar_t front() const; wchar_t back() const; - template + template FString& sprintf (const FString&, Args&&...); FString clear(); @@ -416,7 +416,7 @@ inline wchar_t FString::back() const } //---------------------------------------------------------------------- -template +template inline FString& FString::sprintf (const FString& format, Args&&... args) { static constexpr int BUFSIZE = 4096; diff --git a/src/include/final/fterm.h b/src/include/final/fterm.h index 3a04d361..d11fa5bd 100644 --- a/src/include/final/fterm.h +++ b/src/include/final/fterm.h @@ -278,7 +278,7 @@ class FTerm final static void saveColorMap(); static void resetColorMap(); static void setPalette (FColor, int, int, int); - template + template static void setColorPaletteTheme (const FSetPalette& = &FTerm::setPalette); static void setBeep (int, int); static void resetBeep(); @@ -295,7 +295,7 @@ class FTerm final static bool scrollTermReverse(); static defaultPutChar& putchar(); // function pointer - template + template static void putstringf (const char[], Args&&...); static void putstring (const char[], int = 1); static int putchar_ASCII (int); @@ -443,7 +443,7 @@ inline bool FTerm::unsetUTF8() { return setUTF8(false); } //---------------------------------------------------------------------- -template +template inline void FTerm::setColorPaletteTheme (const FSetPalette& f) { getColorPaletteTheme() = std::make_shared(f); @@ -451,7 +451,7 @@ inline void FTerm::setColorPaletteTheme (const FSetPalette& f) } //---------------------------------------------------------------------- -template +template inline void FTerm::putstringf (const char format[], Args&&... args) { const int size = std::snprintf (nullptr, 0, format, args...) + 1; diff --git a/src/include/final/ftermbuffer.h b/src/include/final/ftermbuffer.h index 5d53d733..f3976b9e 100644 --- a/src/include/final/ftermbuffer.h +++ b/src/include/final/ftermbuffer.h @@ -63,7 +63,7 @@ class FTermBuffer // Constructor FTermBuffer() = default; - template + template FTermBuffer (Iterator, Iterator); // Destructor @@ -95,7 +95,7 @@ class FTermBuffer FChar back() const; const FString toString() const; void clear(); - template + template int writef (const FString&, Args&&...); int write (const FString&); int write (wchar_t); @@ -114,7 +114,7 @@ class FTermBuffer // FTermBuffer inline functions //---------------------------------------------------------------------- -template +template inline FTermBuffer::FTermBuffer(Iterator first, Iterator last) { data.assign(first, last); @@ -216,7 +216,7 @@ inline void FTermBuffer::clear() } //---------------------------------------------------------------------- -template +template inline int FTermBuffer::writef (const FString& format, Args&&... args) { FString str{}; diff --git a/src/include/final/ftermcap.h b/src/include/final/ftermcap.h index e5b1e9b7..852ad862 100644 --- a/src/include/final/ftermcap.h +++ b/src/include/final/ftermcap.h @@ -96,17 +96,18 @@ class FTermcap final // Accessors const FString getClassName() const; - template + template static bool getFlag (const CharT&); - template + template static int getNumber (const CharT&); - template + template static char* getString (const CharT&); - template + template static char* encodeMotionParameter (const CharT&, int, int); - template + template static char* encodeParameter (const CharT&, Args&&...); - template + template static int paddingPrint (const CharT&, int, fn_putc); // Inquiry @@ -159,42 +160,43 @@ inline const FString FTermcap::getClassName() const { return "FTermcap"; } //---------------------------------------------------------------------- -template +template bool FTermcap::getFlag (const CharT& cap) { return ::tgetflag(C_STR(cap)); } //---------------------------------------------------------------------- -template +template int FTermcap::getNumber (const CharT& cap) { return ::tgetnum(C_STR(cap)); } //---------------------------------------------------------------------- -template +template char* FTermcap::getString (const CharT& cap) { return ::tgetstr(C_STR(cap), reinterpret_cast(&string_buf)); } //---------------------------------------------------------------------- -template +template char* FTermcap::encodeMotionParameter (const CharT& cap, int col, int row) { return ::tgoto(C_STR(cap), col, row); } //---------------------------------------------------------------------- -template +template inline char* FTermcap::encodeParameter (const CharT& cap, Args&&... args) { return ::tparm (C_STR(cap), std::forward(args)...); } //---------------------------------------------------------------------- -template +template int FTermcap::paddingPrint (const CharT& str, int affcnt, fn_putc putc) { return _tputs (C_STR(str), affcnt, putc); diff --git a/src/include/final/ftermlinux.h b/src/include/final/ftermlinux.h index 52e043ee..4cfc6219 100644 --- a/src/include/final/ftermlinux.h +++ b/src/include/final/ftermlinux.h @@ -152,7 +152,7 @@ class FTermLinux final modifier_key& getModifierKey(); // Mutators - int setScreenFont ( uChar[], uInt, uInt, uInt + int setScreenFont ( const uChar[], uInt, uInt, uInt , bool = false ); int setUnicodeMap (struct unimapdesc*); void setLinuxCursorStyle (fc::linuxConsoleCursorStyle) const; diff --git a/src/include/final/ftextview.h b/src/include/final/ftextview.h index 7d687cbb..090280a7 100644 --- a/src/include/final/ftextview.h +++ b/src/include/final/ftextview.h @@ -112,10 +112,10 @@ class FTextView : public FWidget // Methods void hide() override; - template + template void append (const std::initializer_list&); void append (const FString&); - template + template void insert (const std::initializer_list&, int); void insert (const FString&, int); void replaceRange (const FString&, int, int); @@ -232,7 +232,7 @@ inline void FTextView::scrollTo (const FPoint& pos) { scrollTo(pos.getX(), pos.getY()); } //---------------------------------------------------------------------- -template +template void FTextView::append (const std::initializer_list& list) { for (auto& str : list) @@ -240,7 +240,7 @@ void FTextView::append (const std::initializer_list& list) } //---------------------------------------------------------------------- -template +template void FTextView::insert (const std::initializer_list& list, int pos) { for (auto& str : list) diff --git a/src/include/final/ftypes.h b/src/include/final/ftypes.h index cecfaa8b..5312905e 100644 --- a/src/include/final/ftypes.h +++ b/src/include/final/ftypes.h @@ -75,7 +75,11 @@ typedef std::function FCall; namespace finalcut { -template +namespace internal +{ + +template struct is_negative { inline bool operator () (const T& x) const @@ -93,10 +97,12 @@ struct is_negative } }; +} // namespace internal + template -inline bool isNegative (const T& x) +constexpr bool isNegative (const T& x) { - return is_negative::is_signed>()(x); + return internal::is_negative::is_signed>()(x); } template diff --git a/src/include/final/fvterm.h b/src/include/final/fvterm.h index b6d39abf..c62004af 100644 --- a/src/include/final/fvterm.h +++ b/src/include/final/fvterm.h @@ -259,7 +259,7 @@ class FVTerm virtual void addPreprocessingHandler ( const FVTerm* , const FPreprocessingFunction& ); virtual void delPreprocessingHandler (const FVTerm*); - template + template int printf (const FString&, Args&&...); int print (const FString&); int print (FTermArea*, const FString&); @@ -926,7 +926,7 @@ inline bool FVTerm::isInheritBackground() { return next_attribute.attr.bit.inherit_background; } //---------------------------------------------------------------------- -template +template inline int FVTerm::printf (const FString& format, Args&&... args) { FString str{}; diff --git a/src/include/final/fwidget.h b/src/include/final/fwidget.h index dcb36328..61cdc3f9 100644 --- a/src/include/final/fwidget.h +++ b/src/include/final/fwidget.h @@ -240,7 +240,7 @@ class FWidget : public FVTerm, public FObject static void setMoveSizeWidget (FWidget*); static void setActiveWindow (FWidget*); static void setOpenMenu (FWidget*); - template + template static void setColorTheme(); FAcceleratorList& setAcceleratorList(); virtual void setStatusbarMessage (const FString&); @@ -317,9 +317,9 @@ class FWidget : public FVTerm, public FObject int numOfFocusableChildren(); virtual bool close(); void clearStatusbarMessage(); - template + template void addCallback (const FString&, Args&&...) noexcept; - template + template void delCallback (Args&&...) noexcept; void emitCallback (const FString&) const; void addAccelerator (FKey); @@ -770,7 +770,7 @@ inline void FWidget::setOpenMenu (FWidget* obj) { open_menu = obj; } //---------------------------------------------------------------------- -template +template inline void FWidget::setColorTheme() { getColorTheme() = std::make_shared(); @@ -984,14 +984,14 @@ inline void FWidget::clearStatusbarMessage() { statusbar_message.clear(); } //---------------------------------------------------------------------- -template +template inline void FWidget::addCallback (const FString& cb_signal, Args&&... args) noexcept { callback_impl.addCallback (cb_signal, std::forward(args)...); } //---------------------------------------------------------------------- -template +template inline void FWidget::delCallback (Args&&... args) noexcept { callback_impl.delCallback(std::forward(args)...); diff --git a/test/fcallback-test.cpp b/test/fcallback-test.cpp index 6f21c34e..666b6399 100644 --- a/test/fcallback-test.cpp +++ b/test/fcallback-test.cpp @@ -39,13 +39,13 @@ class Widget { public: - template + template void addCallback (const finalcut::FString& cb_signal, Args&&... args) { cb.addCallback (cb_signal, std::forward(args)...); } - template + template void delCallback (Args&&... args) { cb.delCallback (std::forward(args)...); diff --git a/test/fobject-test.cpp b/test/fobject-test.cpp index eb356b10..28d74480 100644 --- a/test/fobject-test.cpp +++ b/test/fobject-test.cpp @@ -122,7 +122,12 @@ class FObject_userEvent : public finalcut::FObject virtual void onUserEvent (finalcut::FUserEvent* ev) { if ( ev->getUserId() == 42 ) - value = *(static_cast(ev->getData())); + { + value = ev->getData(); + + if ( ev->getFDataObject().isInitializedReference() ) + ev->getData()++; // this has external effects + } } private: @@ -625,9 +630,10 @@ void FObjectTest::userEventTest() int n = 9; finalcut::FUserEvent user_ev (finalcut::fc::User_Event, 42); - user_ev.setData( (void*)(&n) ); + user_ev.setData(n); finalcut::FApplication::sendEvent (&user, &user_ev); CPPUNIT_ASSERT ( user.getValue() == 9 ); + CPPUNIT_ASSERT ( n == 10 ); } // Put the test suite in the registry From ff2e29b246d6daf8ffdc6db7756b97cfd27651a3 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Fri, 18 Sep 2020 22:40:51 +0200 Subject: [PATCH 02/30] FData optimization --- examples/listbox.cpp | 2 +- src/flistbox.cpp | 2 +- src/include/final/fdata.h | 123 +++++++++++++++-------------------- src/include/final/flistbox.h | 2 +- 4 files changed, 54 insertions(+), 75 deletions(-) diff --git a/examples/listbox.cpp b/examples/listbox.cpp index 210315cd..017b4f5a 100644 --- a/examples/listbox.cpp +++ b/examples/listbox.cpp @@ -51,7 +51,7 @@ void doubleToItem ( FListBoxItem& item , std::size_t index ) { typedef std::list DblList; - DblList& dbl_list = FListBoxHelper::getContainer(container); + DblList& dbl_list = flistboxhelper::getContainer(container); std::list::iterator iter = dbl_list.begin(); std::advance (iter, index); item.setText (FString() << *iter); diff --git a/src/flistbox.cpp b/src/flistbox.cpp index 4cdf4130..8709dcb0 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -834,7 +834,7 @@ void FListBox::drawList() const bool lineHasBrackets = hasBrackets(iter); // Import data via lazy conversion - lazyConvert (iter, int(y)); + lazyConvert (iter, y); // Set screen position and attributes setLineAttributes ( int(y), isSelected(iter), lineHasBrackets diff --git a/src/include/final/fdata.h b/src/include/final/fdata.h index 9272b07a..2bf5f725 100644 --- a/src/include/final/fdata.h +++ b/src/include/final/fdata.h @@ -51,13 +51,11 @@ namespace finalcut //---------------------------------------------------------------------- template -struct FData; // Class forward declaration +class FData; // Class forward declaration -struct FDataAccess +class FDataAccess { public: - virtual ~FDataAccess(); - template const T& get() const { @@ -72,94 +70,75 @@ struct FDataAccess } }; -//---------------------------------------------------------------------- -inline FDataAccess::~FDataAccess() -{ } - //---------------------------------------------------------------------- // struct FData //---------------------------------------------------------------------- template -struct FData : public FDataAccess +class FData : public FDataAccess { - explicit FData (T& v) // constructor - : value_ref{v} - { } + public: + explicit FData (T& v) // constructor + : value_ref{v} + { } - explicit FData (T&& v) // constructor - : value{v} - , value_ref{value} - { } + explicit FData (T&& v) // constructor + : value{std::move(v)} + , value_ref{value} + { } - ~FData() // destructor - { } + T operator () () const + { + return value_ref; + } - FData (const FData& d) // Copy constructor - : value{d.value} - , value_ref{d.value_ref} - { } + template + T operator () (Args... args) const + { + return value_ref(args...); + } - FData& operator = (const FData& d) // Copy assignment operator (=) - { - value = d.value; - value_ref = d.value_ref; - return *this; - } + explicit operator T () const + { + return value_ref; + } - T operator () () const - { - return value_ref; - } + T& get() + { + return value_ref; + } - template - T operator () (Args... args) const - { - return value_ref(args...); - } + void set (const T& v) + { + value_ref = v; + } - explicit operator T () const - { - return value_ref; - } + bool isInitializedCopy() + { + return bool(value); + } - T& get() - { - return value_ref; - } + bool isInitializedReference() + { + return ! isInitializedCopy(); + } - void set (const T& v) - { - value_ref = v; - } + FData& operator << (const T& v) + { + value_ref = v; + return *this; + } - bool isInitializedCopy() - { - return bool(value); - } - - bool isInitializedReference() - { - return ! isInitializedCopy(); - } - - FData& operator << (const T& v) - { - value_ref = v; - return *this; - } - - friend std::ostream& operator << (std::ostream &os, const FData& data) - { - os << data.value_ref; - return os; - } + friend std::ostream& operator << (std::ostream &os, const FData& data) + { + os << data.value_ref; + return os; + } private: + // Data members T value{}; - - public: T& value_ref; }; diff --git a/src/include/final/flistbox.h b/src/include/final/flistbox.h index 58c2aaea..2e628cd0 100644 --- a/src/include/final/flistbox.h +++ b/src/include/final/flistbox.h @@ -371,7 +371,7 @@ class FListBox : public FWidget // non-member function //---------------------------------------------------------------------- -namespace FListBoxHelper +namespace flistboxhelper { template From 44d6d8cdb9d1adfddbaed0a39c2b9bdd7e499acc Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 20 Sep 2020 14:11:35 +0200 Subject: [PATCH 03/30] Fixes minor bugs --- README.md | 39 +++++++----- doc/class-diagram.txt | 39 +++++++----- examples/calculator.cpp | 9 ++- src/fwidget.cpp | 12 +++- src/include/final/fcheckmenuitem.h | 6 +- src/include/final/fcombobox.h | 1 + src/include/final/fdata.h | 38 +++++++++--- src/include/final/fevent.h | 7 ++- src/include/final/final.h | 1 + src/include/final/flistbox.h | 7 ++- src/include/final/flistview.h | 7 ++- src/include/final/ftypes.h | 2 - src/include/final/fwidget.h | 1 + test/fcallback-test.cpp | 2 +- test/fdata-test.cpp | 98 ++++++++++++++++++++++++++++++ 15 files changed, 211 insertions(+), 58 deletions(-) create mode 100644 test/fdata-test.cpp diff --git a/README.md b/README.md index a4fbc267..23fd22ab 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,10 @@ printf(...) ## Class digramm
-              1┌──────────────┐
+              1┌────────────┐
+   ┌-----------┤ FTermLinux │
+   :           └────────────┘
+   :          1┌──────────────┐
    ┌-----------┤ FTermFreeBSD │
    :           └──────────────┘
    :          1┌──────────────┐
@@ -172,12 +175,15 @@ printf(...)
    :          1┌───────────────┐   │    ┌─────────────┐
    ┌-----------┤ FMouseControl │   ├────┤ FTimerEvent │
    :           └───────────────┘   │    └─────────────┘
-   :          1┌─────────┐         │       ┌──────┐   ┌─────────┐
-   ┌-----------┤ FSystem │         │       │ FLog │◄──┤ FLogger │
-   :           └─────────┘         │       └──┬───┘   └─────────┘
-   :          *┌─────────┐         │          :1
-   :  ┌--------┤ FString │         │       ┌──┴───────────┐
-   :  :        └─────────┘         │  ┌────┤ FApplication │
+   :          1┌─────────┐         │    ┌────────────┐1    1┌───────┐
+   ┌-----------┤ FSystem │         ├────┤ FUserEvent ├------┤ FData │
+   :           └─────────┘         │    └────────────┘      └───────┘
+   :          *┌─────────┐         │       ┌──────┐   ┌─────────┐
+   :  ┌--------┤ FString │         │       │ FLog │◄──┤ FLogger │
+   :  :        └─────────┘         │       └──┬───┘   └─────────┘
+   :  :       *┌───────────────┐   │          :1
+   :  ┌--------┤ FStringStream │   │       ┌──┴───────────┐
+   :  :        └───────────────┘   │  ┌────┤ FApplication │
    :  :       *┌────────┐          │  │    └──────────────┘
    :  ┌--------┤ FPoint │          │  │    ┌────────┐
    :  :        └────────┘          │  ├────┤ FLabel │
@@ -209,15 +215,16 @@ printf(...)
                                       │    ┌───────────┐1    1┌──────────────────┐
                                       ├────┤ FComboBox ├------┤ FDropDownListBox │
                                       │    └───────────┘      └──────────────────┘
- ┌─────────────┐1                     │    ┌──────────┐1     *┌──────────────┐
- │ FTermBuffer ├----------------------├────┤ FListBox ├-------┤ FListBoxItem │
- └─────────────┘                      │    └──────────┘       └──────────────┘
-                                      │   1┌───────────┐1    *┌───────────────┐
-                                      ├────┤ FListView ├------┤ FListViewItem │
-                                      │    └───────────┘      └───────────────┘
-                                      │    ┌─────────────┐
-                                      ├────┤ FScrollView │
-                                      │    └─────────────┘
+ ┌─────────────┐1                     │    ┌──────────┐1     *┌──────────────┐1
+ │ FTermBuffer ├----------------------├────┤ FListBox ├-------┤ FListBoxItem ├--┐
+ └─────────────┘                      │    └──────────┘       └──────────────┘  :
+                                      │   1┌───────────┐1    *┌───────────────┐ :
+                                      ├────┤ FListView ├------┤ FListViewItem │ :
+                                      │    └───────────┘      └────────┬──────┘ :
+                                      │    ┌─────────────┐             :1       :
+                                      ├────┤ FScrollView │         ┌───┴───┐1   :
+                                      │    └─────────────┘         │ FData ├----┘
+                                      │                            └───────┘
                                       │    ┌────────────┐1   *┌────────────┐
                                       │ ┌──┤ FStatusBar ├-----┤ FStatusKey │
                                       │ │  └────────────┘     └────────────┘
diff --git a/doc/class-diagram.txt b/doc/class-diagram.txt
index a34f10e0..4dbf7181 100644
--- a/doc/class-diagram.txt
+++ b/doc/class-diagram.txt
@@ -1,7 +1,10 @@
 ══════════════════════════════════════════════════════════════════════════════
                                  Class digramm
 ══════════════════════════════════════════════════════════════════════════════
-              1┌──────────────┐
+              1┌────────────┐
+   ┌-----------┤ FTermLinux │
+   :           └────────────┘
+   :          1┌──────────────┐
    ┌-----------┤ FTermFreeBSD │
    :           └──────────────┘
    :          1┌──────────────┐
@@ -37,12 +40,15 @@
    :          1┌───────────────┐   │    ┌─────────────┐
    ┌-----------┤ FMouseControl │   ├────┤ FTimerEvent │
    :           └───────────────┘   │    └─────────────┘
-   :          1┌─────────┐         │       ┌──────┐   ┌─────────┐
-   ┌-----------┤ FSystem │         │       │ FLog │◄──┤ FLogger │
-   :           └─────────┘         │       └──┬───┘   └─────────┘
-   :          *┌─────────┐         │          :1
-   :  ┌--------┤ FString │         │       ┌──┴───────────┐
-   :  :        └─────────┘         │  ┌────┤ FApplication │
+   :          1┌─────────┐         │    ┌────────────┐1    1┌───────┐
+   ┌-----------┤ FSystem │         ├────┤ FUserEvent ├------┤ FData │
+   :           └─────────┘         │    └────────────┘      └───────┘
+   :          *┌─────────┐         │       ┌──────┐   ┌─────────┐
+   :  ┌--------┤ FString │         │       │ FLog │◄──┤ FLogger │
+   :  :        └─────────┘         │       └──┬───┘   └─────────┘
+   :  :       *┌───────────────┐   │          :1
+   :  ┌--------┤ FStringStream │   │       ┌──┴───────────┐
+   :  :        └───────────────┘   │  ┌────┤ FApplication │
    :  :       *┌────────┐          │  │    └──────────────┘
    :  ┌--------┤ FPoint │          │  │    ┌────────┐
    :  :        └────────┘          │  ├────┤ FLabel │
@@ -74,15 +80,16 @@
                                       │    ┌───────────┐1    1┌──────────────────┐
                                       ├────┤ FComboBox ├------┤ FDropDownListBox │
                                       │    └───────────┘      └──────────────────┘
- ┌─────────────┐1                     │    ┌──────────┐1     *┌──────────────┐
- │ FTermBuffer ├----------------------├────┤ FListBox ├-------┤ FListBoxItem │
- └─────────────┘                      │    └──────────┘       └──────────────┘
-                                      │   1┌───────────┐1    *┌───────────────┐
-                                      ├────┤ FListView ├------┤ FListViewItem │
-                                      │    └───────────┘      └───────────────┘
-                                      │    ┌─────────────┐
-                                      ├────┤ FScrollView │
-                                      │    └─────────────┘
+ ┌─────────────┐1                     │    ┌──────────┐1     *┌──────────────┐1
+ │ FTermBuffer ├----------------------├────┤ FListBox ├-------┤ FListBoxItem ├--┐
+ └─────────────┘                      │    └──────────┘       └──────────────┘  :
+                                      │   1┌───────────┐1    *┌───────────────┐ :
+                                      ├────┤ FListView ├------┤ FListViewItem │ :
+                                      │    └───────────┘      └────────┬──────┘ :
+                                      │    ┌─────────────┐             :1       :
+                                      ├────┤ FScrollView │         ┌───┴───┐1   :
+                                      │    └─────────────┘         │ FData ├----┘
+                                      │                            └───────┘
                                       │    ┌────────────┐1   *┌────────────┐
                                       │ ┌──┤ FStatusBar ├-----┤ FStatusKey │
                                       │ │  └────────────┘     └────────────┘
diff --git a/examples/calculator.cpp b/examples/calculator.cpp
index 8160f41e..ae3f2b9f 100644
--- a/examples/calculator.cpp
+++ b/examples/calculator.cpp
@@ -213,6 +213,7 @@ class Calc final : public finalcut::FDialog
 
     // Event handlers
     void           onKeyPress (finalcut::FKeyEvent*) override;
+    void           onShow (finalcut::FShowEvent*) override;
     void           onClose (finalcut::FCloseEvent*) override;
 
     // Callback method
@@ -255,7 +256,6 @@ Calc::Calc (FWidget* parent)
 
   mapKeyFunctions();
   clearInfixOperator();
-  std::setlocale(LC_NUMERIC, "C");
 
   for (button key{Sine}; key < Calc::NUM_OF_BUTTONS; key = button(key + 1))
   {
@@ -357,6 +357,13 @@ void Calc::onKeyPress (finalcut::FKeyEvent* ev)
   }
 }
 
+//----------------------------------------------------------------------
+void Calc::onShow (finalcut::FShowEvent*)
+{
+  // Overwrites the initialized value of LC_NUMERIC
+  std::setlocale(LC_NUMERIC, "C");
+}
+
 //----------------------------------------------------------------------
 void Calc::onClose (finalcut::FCloseEvent* ev)
 {
diff --git a/src/fwidget.cpp b/src/fwidget.cpp
index e5442eb9..216423a3 100644
--- a/src/fwidget.cpp
+++ b/src/fwidget.cpp
@@ -102,8 +102,7 @@ FWidget::~FWidget()  // destructor
 {
   processDestroy();
   delCallback();
-  auto app_object = FApplication::getApplicationObject();
-  app_object->removeQueuedEvent(this);
+  removeQueuedEvent();
 
   // unset clicked widget
   if ( this == getClickedWidget() )
@@ -2015,6 +2014,15 @@ void FWidget::destroyColorTheme()
   delete theme;
 }
 
+//----------------------------------------------------------------------
+void FWidget::removeQueuedEvent()
+{
+  auto app_object = FApplication::getApplicationObject();
+
+  if ( app_object )
+    app_object->removeQueuedEvent(this);
+}
+
 //----------------------------------------------------------------------
 void FWidget::setStatusbarText (bool enable) const
 {
diff --git a/src/include/final/fcheckmenuitem.h b/src/include/final/fcheckmenuitem.h
index f313c41d..82cb04ec 100644
--- a/src/include/final/fcheckmenuitem.h
+++ b/src/include/final/fcheckmenuitem.h
@@ -40,9 +40,9 @@
  *      ▕▁▁▁▁▁▁▁▁▁▁▁▏
  *            ▲
  *            │
- *    ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏*       1▕▔▔▔▔▔▔▔▏
- *    ▕ FCheckMenuItem ▏- - - - -▕ FMenu ▏
- *    ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏         ▕▁▁▁▁▁▁▁▏
+ *    ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏*     1▕▔▔▔▔▔▔▔▏
+ *    ▕ FCheckMenuItem ▏- - - -▕ FMenu ▏
+ *    ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏       ▕▁▁▁▁▁▁▁▏
  */
 
 #ifndef FCHECKMENUITEM_H
diff --git a/src/include/final/fcombobox.h b/src/include/final/fcombobox.h
index 18411d0f..b6758717 100644
--- a/src/include/final/fcombobox.h
+++ b/src/include/final/fcombobox.h
@@ -47,6 +47,7 @@
   #error "Only  can be included directly."
 #endif
 
+#include "final/fdata.h"
 #include "final/flineedit.h"
 #include "final/flistbox.h"
 #include "final/fwidget.h"
diff --git a/src/include/final/fdata.h b/src/include/final/fdata.h
index 2bf5f725..91ed9984 100644
--- a/src/include/final/fdata.h
+++ b/src/include/final/fdata.h
@@ -42,10 +42,11 @@
 
 #include 
 
+#include "final/fstring.h"
+
 namespace finalcut
 {
 
-
 //----------------------------------------------------------------------
 // struct FDataAccess
 //----------------------------------------------------------------------
@@ -56,12 +57,23 @@ class FData;  // Class forward declaration
 class FDataAccess
 {
   public:
+    // Destructor
+    virtual ~FDataAccess()
+    { }
+
+    // Accessors
+    virtual const FString getClassName() const
+    {
+      return "FDataAccess";
+    }
+
     template 
     const T& get() const
     {
       return static_cast&>(*this).get();
     }
 
+    // Mutator
     template 
     void set (const V& v)
@@ -79,6 +91,7 @@ template 
 class FData : public FDataAccess
 {
   public:
+    // Constructors
     explicit FData (T& v)  // constructor
       : value_ref{v}
     { }
@@ -88,6 +101,7 @@ class FData : public FDataAccess
       , value_ref{value}
     { }
 
+    // Overloaded operators
     T operator () () const
     {
       return value_ref;
@@ -104,16 +118,30 @@ class FData : public FDataAccess
       return value_ref;
     }
 
+    FData& operator << (const T& v)
+    {
+      value_ref = v;
+      return *this;
+    }
+
+    // Accessors
+    const FString getClassName() const override
+    {
+      return "FData";
+    }
+
     T& get()
     {
       return value_ref;
     }
 
+    // Mutator
     void set (const T& v)
     {
       value_ref = v;
     }
 
+    // Inquiries
     bool isInitializedCopy()
     {
       return bool(value);
@@ -124,12 +152,7 @@ class FData : public FDataAccess
       return ! isInitializedCopy();
     }
 
-    FData& operator << (const T& v)
-    {
-      value_ref = v;
-      return *this;
-    }
-
+    // Friend Non-member operator functions
     friend std::ostream& operator << (std::ostream &os, const FData& data)
     {
       os << data.value_ref;
@@ -142,7 +165,6 @@ class FData : public FDataAccess
     T& value_ref;
 };
 
-
 // non-member functions
 //----------------------------------------------------------------------
 namespace internal
diff --git a/src/include/final/fevent.h b/src/include/final/fevent.h
index e22d098f..da0313cf 100644
--- a/src/include/final/fevent.h
+++ b/src/include/final/fevent.h
@@ -68,9 +68,9 @@
  *      ├─────▏FTimerEvent ▏
  *      │    ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▏
  *      │
- *      │    ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▏
- *      └─────▏FUserEvent  ▏
- *           ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▏
+ *      │    ▕▔▔▔▔▔▔▔▔▔▔▔▔▏1     1▕▔▔▔▔▔▔▔▏
+ *      └─────▏FUserEvent ▏- - - -▕ FData ▏
+ *           ▕▁▁▁▁▁▁▁▁▁▁▁▁▏       ▕▁▁▁▁▁▁▁▏
  */
 
 #ifndef FEVENT_H
@@ -81,6 +81,7 @@
 #endif
 
 #include "final/fc.h"
+#include "final/fdata.h"
 #include "final/fpoint.h"
 #include "final/ftypes.h"
 
diff --git a/src/include/final/final.h b/src/include/final/final.h
index dc363458..248f5627 100644
--- a/src/include/final/final.h
+++ b/src/include/final/final.h
@@ -34,6 +34,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/src/include/final/flistbox.h b/src/include/final/flistbox.h
index 2e628cd0..7c923e0a 100644
--- a/src/include/final/flistbox.h
+++ b/src/include/final/flistbox.h
@@ -35,9 +35,9 @@
  *       ▕▁▁▁▁▁▁▁▁▁▏
  *            ▲
  *            │
- *       ▕▔▔▔▔▔▔▔▔▔▔▏1     *▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
- *       ▕ FListBox ▏- - - -▕ FListBoxItem ▏
- *       ▕▁▁▁▁▁▁▁▁▁▁▏       ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
+ *       ▕▔▔▔▔▔▔▔▔▔▔▏1     *▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏1     1▕▔▔▔▔▔▔▔▏
+ *       ▕ FListBox ▏- - - -▕ FListBoxItem ▏- - - -▕ FData ▏
+ *       ▕▁▁▁▁▁▁▁▁▁▁▏       ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏       ▕▁▁▁▁▁▁▁▏
  *
  */
 
@@ -51,6 +51,7 @@
 #include 
 #include 
 
+#include "final/fdata.h"
 #include "final/fscrollbar.h"
 #include "final/fwidget.h"
 
diff --git a/src/include/final/flistview.h b/src/include/final/flistview.h
index dad678a6..5052fbea 100644
--- a/src/include/final/flistview.h
+++ b/src/include/final/flistview.h
@@ -35,9 +35,9 @@
  *       ▕▁▁▁▁▁▁▁▁▁▏           ▕▁▁▁▁▁▁▁▁▁▏
  *            ▲                     ▲
  *            │                     │
- *      ▕▔▔▔▔▔▔▔▔▔▔▔▏1     *▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
- *      ▕ FListView ▏- - - -▕ FListViewItem ▏
- *      ▕▁▁▁▁▁▁▁▁▁▁▁▏       ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
+ *      ▕▔▔▔▔▔▔▔▔▔▔▔▏1     *▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏1     1▕▔▔▔▔▔▔▔▏
+ *      ▕ FListView ▏- - - -▕ FListViewItem ▏- - - -▕ FData ▏
+ *      ▕▁▁▁▁▁▁▁▁▁▁▁▏       ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏       ▕▁▁▁▁▁▁▁▏
  */
 
 #ifndef FLISTVIEW_H
@@ -52,6 +52,7 @@
 #include 
 #include 
 
+#include "final/fdata.h"
 #include "final/fscrollbar.h"
 #include "final/ftermbuffer.h"
 #include "final/ftypes.h"
diff --git a/src/include/final/ftypes.h b/src/include/final/ftypes.h
index 5312905e..6aa4028a 100644
--- a/src/include/final/ftypes.h
+++ b/src/include/final/ftypes.h
@@ -36,8 +36,6 @@
 #include 
 #include 
 
-#include 
-
 #define null nullptr
 
 #define badAllocOutput(object_name)                            \
diff --git a/src/include/final/fwidget.h b/src/include/final/fwidget.h
index 61cdc3f9..1af03bfe 100644
--- a/src/include/final/fwidget.h
+++ b/src/include/final/fwidget.h
@@ -452,6 +452,7 @@ class FWidget : public FVTerm, public FObject
     static bool              isDefaultTheme();
     static void              initColorTheme();
     void                     destroyColorTheme();
+    void                     removeQueuedEvent();
     void                     setStatusbarText (bool) const;
 
     // Data members
diff --git a/test/fcallback-test.cpp b/test/fcallback-test.cpp
index 666b6399..ed7e83b1 100644
--- a/test/fcallback-test.cpp
+++ b/test/fcallback-test.cpp
@@ -1,5 +1,5 @@
 /***********************************************************************
-* callback-test.cpp - FCallback unit tests                             *
+* fcallback-test.cpp - FCallback unit tests                            *
 *                                                                      *
 * This file is part of the FINAL CUT widget toolkit                    *
 *                                                                      *
diff --git a/test/fdata-test.cpp b/test/fdata-test.cpp
new file mode 100644
index 00000000..8ca52d6e
--- /dev/null
+++ b/test/fdata-test.cpp
@@ -0,0 +1,98 @@
+/***********************************************************************
+* fdata-test.cpp - FCallback unit tests                                *
+*                                                                      *
+* This file is part of the FINAL CUT widget toolkit                    *
+*                                                                      *
+* Copyright 2020 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       *
+* published by the Free Software Foundation; either version 3 of       *
+* the License, or (at your option) any later version.                  *
+*                                                                      *
+* FINAL CUT is distributed in the hope that it will be useful, but     *
+* WITHOUT ANY WARRANTY; without even the implied warranty of           *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
+* GNU Lesser General Public License for more details.                  *
+*                                                                      *
+* You should have received a copy of the GNU Lesser General Public     *
+* License along with this program.  If not, see                        *
+* .                                      *
+***********************************************************************/
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+//----------------------------------------------------------------------
+// functions
+//----------------------------------------------------------------------
+/*void cb_function_ptr (int* value)
+{
+  (*value)++;
+}
+
+//----------------------------------------------------------------------
+void cb_function_ref (int& value)
+{
+  value += 2;
+}*/
+
+//----------------------------------------------------------------------
+// class FDataTest
+//----------------------------------------------------------------------
+
+class FDataTest : public CPPUNIT_NS::TestFixture
+{
+  public:
+    FDataTest()
+    { }
+
+  protected:
+    void classNameTest();
+    void dataTest();
+
+  private:
+    // Adds code needed to register the test suite
+    CPPUNIT_TEST_SUITE (FDataTest);
+
+    // Add a methods to the test suite
+    CPPUNIT_TEST (classNameTest);
+    CPPUNIT_TEST (dataTest);
+
+    // End of test suite definition
+    CPPUNIT_TEST_SUITE_END();
+
+    // Data member
+    static finalcut::FWidget root_widget;
+};
+
+// static class attributes
+finalcut::FWidget FDataTest::root_widget{nullptr};
+
+//----------------------------------------------------------------------
+void FDataTest::classNameTest()
+{
+  const finalcut::FCallback d;
+  const finalcut::FString& classname = d.getClassName();
+  CPPUNIT_ASSERT ( classname == "FData" );
+}
+
+//----------------------------------------------------------------------
+void FDataTest::dataTest()
+{
+
+}
+// Put the test suite in the registry
+CPPUNIT_TEST_SUITE_REGISTRATION (FDataTest);
+
+// The general unit test main part
+#include 

From d10e2888accf2a05e2650dad26aa3ec8ee97f240 Mon Sep 17 00:00:00 2001
From: Markus Gans 
Date: Tue, 22 Sep 2020 01:04:36 +0200
Subject: [PATCH 04/30] Bugfix in FDialog::setSize()

---
 ChangeLog                        |  4 +++
 doc/first-steps.md               | 11 ++------
 src/fapplication.cpp             | 46 ++++++++++++++++----------------
 src/fdialog.cpp                  |  9 ++++---
 src/fwidget.cpp                  |  2 +-
 src/include/final/fapplication.h |  2 +-
 src/include/final/fwidget.h      |  2 +-
 test/fdata-test.cpp              |  2 +-
 test/fobject-test.cpp            | 13 +++++++++
 9 files changed, 52 insertions(+), 39 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b41173c1..287dd6bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2020-09-22  Markus Gans  
+	* Bugfix in FDialog::setSize(): Automatic size adjustment and 
+	  simultaneous widget movement are now possible.
+
 2020-09-18  Markus Gans  
 	* The generic data type FDataPtr is now deprecated and was 
 	  completely replaced by the template class FData
diff --git a/doc/first-steps.md b/doc/first-steps.md
index 6b5b158f..473cd941 100644
--- a/doc/first-steps.md
+++ b/doc/first-steps.md
@@ -1236,19 +1236,12 @@ class dialogWidget : public FDialog
       FDialog::adjustSize();
       // Centers the dialog in the terminal
       centerDialog();
-    }
-
-    void setSize (const FSize& size, bool) override
-    {
-      // Calling super class methods setSize() + adjustSize()
-      FDialog::setSize (size, false);
-      FDialog::adjustSize();
+      // Adjust widgets before drawing
+      adjustWidgets();
     }
 
     void draw() override
     {
-      adjustWidgets();  // Adjust widgets before drawing 
-
       // Calling super class method draw()
       FDialog::draw();
 
diff --git a/src/fapplication.cpp b/src/fapplication.cpp
index 70e5b008..ec644f0c 100644
--- a/src/fapplication.cpp
+++ b/src/fapplication.cpp
@@ -312,6 +312,29 @@ void FApplication::setDarkTheme()
     setColorTheme();
 }
 
+//----------------------------------------------------------------------
+void FApplication::setLogFile (const FString& filename)
+{
+  auto& log_stream = getStartOptions().logfile_stream;
+  log_stream.open(filename, std::ofstream::out);
+
+  if ( log_stream.is_open() )
+  {
+    // Get the global logger object
+    FLog& log = *FApplication::getLog();
+    log.setOutputStream(log_stream);
+    log.enableTimestamp();
+    log.setLineEnding (finalcut::FLog::LF);
+  }
+  else
+  {
+    auto ftermdata = FTerm::getFTermData();
+    ftermdata->setExitMessage ( "Could not open log file \""
+                              + filename + "\"" );
+    exit(EXIT_FAILURE);
+  }
+}
+
 //----------------------------------------------------------------------
 void FApplication::setKeyboardWidget (FWidget* widget)
 {
@@ -416,29 +439,6 @@ void FApplication::setTerminalEncoding (const FString& enc_str)
   }
 }
 
-//----------------------------------------------------------------------
-void FApplication::setLogFile (const FString& filename)
-{
-  auto& log_stream = getStartOptions().logfile_stream;
-  log_stream.open(filename, std::ofstream::out);
-
-  if ( log_stream.is_open() )
-  {
-    // Get the global logger object
-    FLog& log = *FApplication::getLog();
-    log.setOutputStream(log_stream);
-    log.enableTimestamp();
-    log.setLineEnding (finalcut::FLog::LF);
-  }
-  else
-  {
-    auto ftermdata = FTerm::getFTermData();
-    ftermdata->setExitMessage ( "Could not open log file \""
-                              + filename + "\"" );
-    exit(EXIT_FAILURE);
-  }
-}
-
 //----------------------------------------------------------------------
 void FApplication::cmd_options (const int& argc, char* argv[])
 {
diff --git a/src/fdialog.cpp b/src/fdialog.cpp
index d87708cb..1a300d1c 100644
--- a/src/fdialog.cpp
+++ b/src/fdialog.cpp
@@ -323,7 +323,7 @@ void FDialog::setSize (const FSize& size, bool adjust)
   const int dw = int(getWidth()) - int(size.getWidth());
   const int dh = int(getHeight()) - int(size.getHeight());
   const auto& shadow = getShadow();
-  FWindow::setSize (size, adjust);
+  FWindow::setSize (size, false);
 
   // get adjust width and height
   const std::size_t w = getWidth() + shadow.getWidth();
@@ -346,6 +346,9 @@ void FDialog::setSize (const FSize& size, bool adjust)
   if ( dh > 0 )
     restoreVTerm ({x, y + int(h), w + d_width, d_height});  // restore bottom
 
+  if ( adjust )    // Adjust the size after restoreVTerm(),
+    adjustSize();  // because adjustSize() can also change x and y
+
   redraw();
 
   // handle overlaid windows
@@ -1069,13 +1072,13 @@ inline void FDialog::drawRestoreSizeButton()
     if ( FTerm::isMonochron() )
     {
       print ('[');
-      print (fc::BlackDownPointingTriangle);  // ▼
+      print (fc::BlackDiamondSuit);  // ◆
       print (']');
     }
     else
     {
       print (' ');
-      print (fc::BlackDownPointingTriangle);  // ▼
+      print (fc::BlackDiamondSuit);  // ◆
       print (' ');
     }
   }
diff --git a/src/fwidget.cpp b/src/fwidget.cpp
index 216423a3..a1843529 100644
--- a/src/fwidget.cpp
+++ b/src/fwidget.cpp
@@ -2015,7 +2015,7 @@ void FWidget::destroyColorTheme()
 }
 
 //----------------------------------------------------------------------
-void FWidget::removeQueuedEvent()
+void FWidget::removeQueuedEvent() const
 {
   auto app_object = FApplication::getApplicationObject();
 
diff --git a/src/include/final/fapplication.h b/src/include/final/fapplication.h
index d67f2e71..db7efbdb 100644
--- a/src/include/final/fapplication.h
+++ b/src/include/final/fapplication.h
@@ -137,6 +137,7 @@ class FApplication : public FWidget
     void                  initTerminal() override;
     static void           setDefaultTheme();
     static void           setDarkTheme();
+    static void           setLogFile (const FString&);
     static void           setKeyboardWidget (FWidget*);
     static void           closeConfirmationDialog (FWidget*, FCloseEvent*);
 
@@ -154,7 +155,6 @@ class FApplication : public FWidget
     // Methods
     void                  init();
     static void           setTerminalEncoding (const FString&);
-    static void           setLogFile (const FString&);
     static void           cmd_options (const int&, char*[]);
     static FStartOptions& getStartOptions();
     static void           showParameterUsage();
diff --git a/src/include/final/fwidget.h b/src/include/final/fwidget.h
index 1af03bfe..1a54c839 100644
--- a/src/include/final/fwidget.h
+++ b/src/include/final/fwidget.h
@@ -452,7 +452,7 @@ class FWidget : public FVTerm, public FObject
     static bool              isDefaultTheme();
     static void              initColorTheme();
     void                     destroyColorTheme();
-    void                     removeQueuedEvent();
+    void                     removeQueuedEvent() const;
     void                     setStatusbarText (bool) const;
 
     // Data members
diff --git a/test/fdata-test.cpp b/test/fdata-test.cpp
index 8ca52d6e..206cdc14 100644
--- a/test/fdata-test.cpp
+++ b/test/fdata-test.cpp
@@ -1,5 +1,5 @@
 /***********************************************************************
-* fdata-test.cpp - FCallback unit tests                                *
+* fdata-test.cpp - FData unit tests                                    *
 *                                                                      *
 * This file is part of the FINAL CUT widget toolkit                    *
 *                                                                      *
diff --git a/test/fobject-test.cpp b/test/fobject-test.cpp
index 28d74480..60d48637 100644
--- a/test/fobject-test.cpp
+++ b/test/fobject-test.cpp
@@ -394,6 +394,19 @@ void FObjectTest::addTest()
   CPPUNIT_ASSERT ( child->hasParent() );
   CPPUNIT_ASSERT ( child->getParent() == obj );
 
+  // Switch of the parent by a second addChild
+  auto obj2 = new finalcut::FObject();
+  obj2->addChild(child);
+  CPPUNIT_ASSERT ( child->hasParent() );
+  CPPUNIT_ASSERT ( ! obj->hasChildren() );
+  CPPUNIT_ASSERT ( obj->numOfChildren() == 0 );
+  CPPUNIT_ASSERT ( ! obj->isChild(child) );
+  CPPUNIT_ASSERT ( child->getParent() != obj );
+  CPPUNIT_ASSERT ( obj2->hasChildren() );
+  CPPUNIT_ASSERT ( obj2->numOfChildren() == 1 );
+  CPPUNIT_ASSERT ( obj2->isChild(child) );
+  CPPUNIT_ASSERT ( child->getParent() == obj2 );
+
   delete obj;  // also deletes the child object
 }
 

From a69d38fb1eb03f3e187780450ebf003befd44ff8 Mon Sep 17 00:00:00 2001
From: Markus Gans 
Date: Wed, 23 Sep 2020 23:18:48 +0200
Subject: [PATCH 05/30] Bugfix: empty FString() + wchar_t

---
 ChangeLog             |  3 ++
 doc/faq.md            |  1 +
 doc/first-steps.md    | 20 ++++++------
 doc/user-theme.md     |  2 +-
 src/fmenu.cpp         | 13 +++-----
 src/fmenubar.cpp      |  4 +--
 src/fscrollbar.cpp    |  2 +-
 src/fstring.cpp       | 11 ++++---
 src/fvterm.cpp        |  5 +--
 test/fstring-test.cpp | 74 ++++++++++++++++++++++++++++++++++---------
 10 files changed, 92 insertions(+), 43 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 287dd6bd..fc72c7cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2020-09-23  Markus Gans  
+	* Bugfix: empty FString() + wchar_t
+
 2020-09-22  Markus Gans  
 	* Bugfix in FDialog::setSize(): Automatic size adjustment and 
 	  simultaneous widget movement are now possible.
diff --git a/doc/faq.md b/doc/faq.md
index 47164336..d8304638 100644
--- a/doc/faq.md
+++ b/doc/faq.md
@@ -85,6 +85,7 @@ You need three things:
     * autoconf
     * autoconf-archive
     * libtool
+    * pkg-config
 
 3. Development packages for following libraries:
 
diff --git a/doc/first-steps.md b/doc/first-steps.md
index 473cd941..1e1e376f 100644
--- a/doc/first-steps.md
+++ b/doc/first-steps.md
@@ -93,7 +93,7 @@ int main (int argc, char* argv[])
 After entering the source code in *dialog.cpp* you can compile
 the above program with gcc:
 ```cpp
-g++ -O2 -lfinal dialog.cpp -o dialog
+g++ dialog.cpp -o dialog -O2 -lfinal
 ```
 
 
@@ -240,7 +240,7 @@ int main (int argc, char* argv[])
 After entering the source code in *memory.cpp* you can compile
 the above program with gcc:
 ```cpp
-g++ -O2 -lfinal memory.cpp -o memory
+g++ memory.cpp -o memory -O2 -lfinal
 ```
 
 
@@ -380,7 +380,7 @@ int main (int argc, char* argv[])
 After entering the source code in *timer.cpp* you can compile
 the above program with gcc:
 ```cpp
-g++ -O2 -lfinal -std=c++11 timer.cpp -o timer
+g++ timer.cpp -o timer -O2 -lfinal -std=c++11
 ```
 
 
@@ -493,7 +493,7 @@ int main (int argc, char* argv[])
 After entering the source code in *user-event.cpp* you can compile
 the above program with gcc:
 ```cpp
-g++ -O2 -lfinal -std=c++11 user-event.cpp -o user-event
+g++ user-event.cpp -o user-event -O2 -lfinal -std=c++11
 ```
 
 
@@ -764,7 +764,7 @@ int main (int argc, char* argv[])
 After entering the source code in *callback-function.cpp* you can compile
 the above program with gcc:
 ```cpp
-g++ -O2 -lfinal callback-function.cpp -o callback-function
+g++ callback-function.cpp -o callback-function -O2 -lfinal
 ```
  
 
@@ -827,7 +827,7 @@ int main (int argc, char* argv[])
 After entering the source code in *callback-lambda.cpp* you can compile
 the above program with gcc:
 ```cpp
-g++ -O2 -lfinal -std=c++11 callback-lambda.cpp -o callback-lambda
+g++ callback-lambda.cpp -o callback-lambda -O2 -lfinal -std=c++11
 ```
  
 
@@ -886,7 +886,7 @@ int main (int argc, char* argv[])
 After entering the source code in *callback-method.cpp* you can compile
 the above program with gcc:
 ```cpp
-g++ -O2 -lfinal -std=c++11 callback-method.cpp -o callback-method
+g++ callback-method.cpp -o callback-method -O2 -lfinal -std=c++11
 ```
  
 
@@ -1007,7 +1007,7 @@ int main (int argc, char* argv[])
 After entering the source code in *emit-signal.cpp* you can compile
 the above program with gcc:
 ```cpp
-g++ -O2 -lfinal -std=c++11 emit-signal.cpp -o emit-signal
+g++ emit-signal.cpp -o emit-signal -O2 -lfinal -std=c++11
 ```
 
 
@@ -1278,7 +1278,7 @@ int main (int argc, char* argv[])
 After entering the source code in *size-adjustment.cpp* you can compile
 the above program with gcc:
 ```cpp
-g++ -O2 -lfinal -std=c++11 size-adjustment.cpp -o size-adjustment
+g++ size-adjustment.cpp -o size-adjustment -O2 -lfinal -std=c++11
 ```
 
 
@@ -1406,5 +1406,5 @@ int main (int argc, char* argv[])
 After entering the source code in *scrollview.cpp* you can compile
 the above program with gcc:
 ```cpp
-g++ -O2 -lfinal -std=c++11 scrollview.cpp -o scrollview
+g++ scrollview.cpp -o scrollview -O2 -lfinal -std=c++11
 ```
diff --git a/doc/user-theme.md b/doc/user-theme.md
index fc59dd45..bd05ed97 100644
--- a/doc/user-theme.md
+++ b/doc/user-theme.md
@@ -438,6 +438,6 @@ int main (int argc, char* argv[])
 After entering the source code in *theme.cpp* you can compile
 the above program with gcc:
 ```cpp
-g++ -O2 -lfinal -std=c++11 theme.cpp -o theme
+g++ theme.cpp -o theme -O2 -lfinal -std=c++11
 ```
 
diff --git a/src/fmenu.cpp b/src/fmenu.cpp
index 83f823b5..bc05b82f 100644
--- a/src/fmenu.cpp
+++ b/src/fmenu.cpp
@@ -138,9 +138,7 @@ void FMenu::onKeyPress (FKeyEvent* ev)
 
   if ( menu_bar )
   {
-    auto mbar = static_cast(menu_bar);
-
-    if ( mbar->hotkeyMenu(ev) )
+    if ( menu_bar->hotkeyMenu(ev) )
       return;
   }
 
@@ -989,9 +987,8 @@ void FMenu::passEventToMenuBar (FMouseEvent* const& ev) const
     const auto& _ev = \
         std::make_shared(fc::MouseMove_Event, p, t, b);
     setClickedWidget(menu_bar);
-    auto& mbar = *(static_cast(menu_bar));
-    mbar.mouse_down = true;
-    mbar.onMouseMove(_ev.get());
+    menu_bar->mouse_down = true;
+    menu_bar->onMouseMove(_ev.get());
   }
   catch (const std::bad_alloc&)
   {
@@ -1060,7 +1057,7 @@ bool FMenu::selectNextItem()
         ++next_element;
         if ( next_element == list.end() )
           next_element = list.begin();
-        next = static_cast(*next_element);
+        next = *next_element;
       }
       while ( ! next->isEnabled()
            || ! next->acceptFocus()
@@ -1110,7 +1107,7 @@ bool FMenu::selectPrevItem()
         if ( prev_element == list.begin() )
           prev_element = list.end();
         --prev_element;
-        prev = static_cast(*prev_element);
+        prev = *prev_element;
       }
       while ( ! prev->isEnabled()
            || ! prev->acceptFocus()
diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp
index 756dc48e..47f145db 100644
--- a/src/fmenubar.cpp
+++ b/src/fmenubar.cpp
@@ -302,7 +302,7 @@ bool FMenuBar::selectNextItem()
         if ( next_element == list.end() )
           next_element = list.begin();
 
-        next = static_cast(*next_element);
+        next = *next_element;
       } while ( ! next->isEnabled()
              || ! next->acceptFocus()
              || ! next->isShown()
@@ -365,7 +365,7 @@ bool FMenuBar::selectPrevItem()
           prev_element = list.end();
 
         --prev_element;
-        prev = static_cast(*prev_element);
+        prev = *prev_element;
       }
       while ( ! prev->isEnabled()
            || ! prev->acceptFocus()
diff --git a/src/fscrollbar.cpp b/src/fscrollbar.cpp
index e5895cad..a593745c 100644
--- a/src/fscrollbar.cpp
+++ b/src/fscrollbar.cpp
@@ -40,7 +40,7 @@ FScrollbar::FScrollbar(FWidget* parent)
   : FWidget{parent}
 {
   // The default scrollbar orientation is vertical
-  setGeometry(FPoint{1, 1}, FSize{1, length}, false);
+  FScrollbar::setGeometry(FPoint{1, 1}, FSize{1, length}, false);
   init();
 }
 
diff --git a/src/fstring.cpp b/src/fstring.cpp
index b5be91ad..5524ea9d 100644
--- a/src/fstring.cpp
+++ b/src/fstring.cpp
@@ -1537,9 +1537,12 @@ const FString operator + (const FString& s1, const FString& s2)
 //----------------------------------------------------------------------
 const FString operator + (const FString& s, const wchar_t c)
 {
-  FString tmp{s};
-  tmp._insert (tmp.length, 1, &c);
-  return tmp;
+  FString tmp1{s};
+  wchar_t tmp2[2];
+  tmp2[0] = c;
+  tmp2[1] = L'\0';
+  tmp1._insert (tmp1.length, 1, tmp2);
+  return tmp1;
 }
 
 //----------------------------------------------------------------------
@@ -1597,7 +1600,7 @@ const FString operator + (const FString& s, const char c)
   wchar_t tmp2[2];
   tmp2[0] = wchar_t(c & 0xff);
   tmp2[1] = L'\0';
-  tmp1._insert (s.length, 1, tmp2);
+  tmp1._insert (tmp1.length, 1, tmp2);
   return tmp1;
 }
 
diff --git a/src/fvterm.cpp b/src/fvterm.cpp
index a9611754..b935f6a7 100644
--- a/src/fvterm.cpp
+++ b/src/fvterm.cpp
@@ -1706,9 +1706,10 @@ void FVTerm::updateVTerm() const
     vdesktop->has_changes = false;
   }
 
-  const FWidget* widget = static_cast(vterm->widget);
+  const FWidget* widget = vterm->widget;
 
-  if ( ! widget->getWindowList() || widget->getWindowList()->empty() )
+  if ( ! widget || ! widget->getWindowList()
+    || widget->getWindowList()->empty() )
     return;
 
   for (auto&& window : *(widget->getWindowList()))
diff --git a/test/fstring-test.cpp b/test/fstring-test.cpp
index a79aa300..38c63c51 100644
--- a/test/fstring-test.cpp
+++ b/test/fstring-test.cpp
@@ -163,8 +163,8 @@ void FStringTest::noArgumentTest()
   CPPUNIT_ASSERT ( empty.getLength() == 0 );
   CPPUNIT_ASSERT ( empty.capacity() == 0 );
   CPPUNIT_ASSERT ( empty.getUTF8length() == 0 );
-  CPPUNIT_ASSERT ( empty.wc_str() == 0 );
-  CPPUNIT_ASSERT ( empty.c_str() == 0 );
+  CPPUNIT_ASSERT ( empty.wc_str() == nullptr );
+  CPPUNIT_ASSERT ( empty.c_str() == nullptr );
   CPPUNIT_ASSERT_EQUAL ( empty.toString(), std::string() );
   CPPUNIT_ASSERT ( strlen(finalcut::FString(99).c_str()) == 0 );
   CPPUNIT_ASSERT ( wcslen(finalcut::FString(99).wc_str()) == 0 );
@@ -172,9 +172,9 @@ void FStringTest::noArgumentTest()
   CPPUNIT_ASSERT ( wcslen(finalcut::FString("").wc_str()) == 0 );
 
   char* cstr = empty.c_str();
-  CPPUNIT_ASSERT ( cstr == 0 );
+  CPPUNIT_ASSERT ( cstr == nullptr );
   wchar_t* wcstr = empty.wc_str();
-  CPPUNIT_ASSERT ( wcstr == 0 );
+  CPPUNIT_ASSERT ( wcstr == nullptr );
   std::string str = empty.toString();
   CPPUNIT_ASSERT ( str.length() == 0 );
   CPPUNIT_ASSERT ( str.size() == 0 );
@@ -516,7 +516,7 @@ void FStringTest::additionAssignmentTest()
 //----------------------------------------------------------------------
 void FStringTest::additionTest()
 {
-  // finalcut::FString member operator
+  // const finalcut::FString + ...
   const finalcut::FString s1("abc");
   CPPUNIT_ASSERT ( s1.getLength() == 3 );
   CPPUNIT_ASSERT ( *(s1.c_str() + s1.getLength()) == '\0' );
@@ -529,8 +529,7 @@ void FStringTest::additionTest()
   CPPUNIT_ASSERT ( s1 + wchar_t(L'd') == L"abcd" );
   CPPUNIT_ASSERT ( s1 + char('d') == L"abcd" );
 
-
-  // finalcut::FString non-member operator
+  // finalcut::FString + ...
   finalcut::FString s2("abc");
   CPPUNIT_ASSERT ( s2.getLength() == 3 );
   CPPUNIT_ASSERT ( *(s2.c_str() + s2.getLength()) == '\0' );
@@ -543,25 +542,70 @@ void FStringTest::additionTest()
   CPPUNIT_ASSERT ( s2 + wchar_t(L'd') == L"abcd" );
   CPPUNIT_ASSERT ( s2 + char('d') == L"abcd" );
 
-  const std::wstring& s3 = L"abc";
-  CPPUNIT_ASSERT ( s3 + finalcut::FString("def") == L"abcdef" );
+  // Empty const finalcut::FString + ...
+  const finalcut::FString s3;
+  CPPUNIT_ASSERT ( s3.getLength() == 0 );
+  CPPUNIT_ASSERT ( s3.c_str() == nullptr );
+  CPPUNIT_ASSERT ( s3.wc_str() == nullptr );
+  CPPUNIT_ASSERT ( s3 + finalcut::FString("def") == L"def" );
+  CPPUNIT_ASSERT ( s3 + std::wstring(L"def") == L"def" );
+  CPPUNIT_ASSERT ( s3 + const_cast(L"def") == L"def" );
+  CPPUNIT_ASSERT ( s3 + std::string("def") == L"def" );
+  CPPUNIT_ASSERT ( s3 + const_cast("def") == L"def" );
+  CPPUNIT_ASSERT ( s3 + wchar_t(L'd') == L"d" );
+  CPPUNIT_ASSERT ( s3 + char('d') == L"d" );
 
-  constexpr wchar_t s4[] = L"abc";
-  CPPUNIT_ASSERT ( s4 + finalcut::FString("def") == L"abcdef" );
+  // Empty finalcut::FString + ...
+  finalcut::FString s4;
+  CPPUNIT_ASSERT ( s4.getLength() == 0 );
+  CPPUNIT_ASSERT ( s4.c_str() == nullptr );
+  CPPUNIT_ASSERT ( s4.wc_str() == nullptr );
+  CPPUNIT_ASSERT ( s4 + finalcut::FString("def") == L"def" );
+  CPPUNIT_ASSERT ( s4 + std::wstring(L"def") == L"def" );
+  CPPUNIT_ASSERT ( s4 + const_cast(L"def") == L"def" );
+  CPPUNIT_ASSERT ( s4 + std::string("def") == L"def" );
+  CPPUNIT_ASSERT ( s4 + const_cast("def") == L"def" );
+  CPPUNIT_ASSERT ( s4 + wchar_t(L'd') == L"d" );
+  CPPUNIT_ASSERT ( s4 + char('d') == L"d" );
 
-  const std::string& s5 = "abc";
+  // Other string types + finalcut::FString
+  const std::wstring& s5 = L"abc";
   CPPUNIT_ASSERT ( s5 + finalcut::FString("def") == L"abcdef" );
 
-  constexpr char s6[] = "abc";
+  constexpr wchar_t s6[] = L"abc";
   CPPUNIT_ASSERT ( s6 + finalcut::FString("def") == L"abcdef" );
 
+  const std::string& s7 = "abc";
+  CPPUNIT_ASSERT ( s7 + finalcut::FString("def") == L"abcdef" );
+
+  constexpr char s8[] = "abc";
+  CPPUNIT_ASSERT ( s8 + finalcut::FString("def") == L"abcdef" );
+
   constexpr wchar_t c1 = L'a';
-  CPPUNIT_ASSERT ( c1 + s3 == L"aabc" );
+  CPPUNIT_ASSERT ( c1 + s5 == L"aabc" );
   CPPUNIT_ASSERT ( c1 + finalcut::FString("def") == L"adef" );
 
   constexpr char c2 = 'a';
-  CPPUNIT_ASSERT ( c2 + s5 == "aabc" );
+  CPPUNIT_ASSERT ( c2 + s7 == "aabc" );
   CPPUNIT_ASSERT ( c2 + finalcut::FString("def") == L"adef" );
+
+  // Other string types + empty const finalcut::FString
+  CPPUNIT_ASSERT ( s5 + s3 == L"abc" );
+  CPPUNIT_ASSERT ( s6 + s3 == L"abc" );
+  CPPUNIT_ASSERT ( s7 + s3 == L"abc" );
+  CPPUNIT_ASSERT ( s8 + s3 == L"abc" );
+  CPPUNIT_ASSERT ( c1 + s3 == L"a" );
+  CPPUNIT_ASSERT ( c1 + s3 == L"a" );
+  CPPUNIT_ASSERT ( c2 + s3 == "a" );
+
+  // Other string types + empty finalcut::FString
+  CPPUNIT_ASSERT ( s5 + s4 == L"abc" );
+  CPPUNIT_ASSERT ( s6 + s4 == L"abc" );
+  CPPUNIT_ASSERT ( s7 + s4 == L"abc" );
+  CPPUNIT_ASSERT ( s8 + s4 == L"abc" );
+  CPPUNIT_ASSERT ( c1 + s4 == L"a" );
+  CPPUNIT_ASSERT ( c1 + s4 == L"a" );
+  CPPUNIT_ASSERT ( c2 + s4 == "a" );
 }
 
 //----------------------------------------------------------------------

From 3d9f621258c0cc305fb5ece97bf64e8934cd1b24 Mon Sep 17 00:00:00 2001
From: Markus Gans 
Date: Fri, 25 Sep 2020 00:48:58 +0200
Subject: [PATCH 06/30] std::clog now streams everything to the FLogger object

---
 ChangeLog                        |  3 ++
 examples/7segment.cpp            | 24 +++++------
 examples/busy.cpp                | 10 ++---
 examples/calculator.cpp          | 24 +++++------
 examples/checklist.cpp           | 24 +++++------
 examples/event-log.cpp           | 18 ++++----
 examples/input-dialog.cpp        | 16 +++----
 examples/listbox.cpp             |  8 ++--
 examples/listview.cpp            | 48 ++++++++++-----------
 examples/string-operations.cpp   |  4 +-
 examples/termcap.cpp             | 10 ++---
 examples/transparent.cpp         | 10 ++---
 examples/treeview.cpp            | 72 +++++++++++++++----------------
 examples/ui.cpp                  | 42 +++++++++---------
 examples/windows.cpp             |  2 +-
 src/Makefile.am                  |  1 +
 src/Makefile.clang               |  2 +
 src/Makefile.gcc                 |  2 +
 src/fapplication.cpp             | 37 +++++++++++++---
 src/fcharmap.cpp                 | 12 +++---
 src/fcombobox.cpp                |  1 -
 src/fdata.cpp                    | 42 ++++++++++++++++++
 src/flineedit.cpp                | 22 +++++-----
 src/fmenu.cpp                    |  7 +--
 src/foptimove.cpp                | 74 ++++++++++++++++----------------
 src/fterm.cpp                    | 12 +++---
 src/fterm_functions.cpp          | 20 ++++-----
 src/ftermcap.cpp                 | 18 ++++----
 src/ftermfreebsd.cpp             | 12 +++---
 src/ftermlinux.cpp               |  4 +-
 src/ftermopenbsd.cpp             | 10 ++---
 src/ftermxterminal.cpp           | 10 ++---
 src/include/final/emptyfstring.h |  3 +-
 src/include/final/fapplication.h |  1 +
 src/include/final/fcharmap.h     | 10 ++---
 src/include/final/fdata.h        | 30 ++++++++++++-
 src/include/final/flog.h         |  3 ++
 src/include/final/ftypes.h       | 14 +++---
 src/include/final/fvterm.h       |  4 +-
 test/fdata-test.cpp              | 11 ++---
 test/flogger-test.cpp            | 31 ++++++++++++-
 test/ftermfreebsd-test.cpp       |  2 +-
 42 files changed, 420 insertions(+), 290 deletions(-)
 create mode 100644 src/fdata.cpp

diff --git a/ChangeLog b/ChangeLog
index fc72c7cb..02f97c46 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2020-09-25  Markus Gans  
+	* std::clog now streams everything to the FLogger object
+
 2020-09-23  Markus Gans  
 	* Bugfix: empty FString() + wchar_t
 
diff --git a/examples/7segment.cpp b/examples/7segment.cpp
index 89991113..2a6876fd 100644
--- a/examples/7segment.cpp
+++ b/examples/7segment.cpp
@@ -68,8 +68,8 @@ class SegmentView final : public finalcut::FDialog
     // Data members
     std::map code{};
     finalcut::FString line[3]{};
-    finalcut::FLineEdit Input{"0123", this};
-    finalcut::FButton Exit{"E&xit", this};
+    finalcut::FLineEdit input{"0123", this};
+    finalcut::FButton exit{"E&xit", this};
 };
 
 //----------------------------------------------------------------------
@@ -86,18 +86,18 @@ SegmentView::SegmentView (finalcut::FWidget* parent)
   hexEncoding();
 
   // Input field
-  Input.setGeometry (FPoint(2, 2), FSize{12, 1});
-  Input.setLabelText (L"&Hex value");
-  Input.setLabelText (L"&Hex-digits or (.) (:) (H) (L) (P) (U)");
-  Input.setLabelOrientation(finalcut::FLineEdit::label_above);
-  Input.setMaxLength(9);
-  Input.setInputFilter("[:.hHlLpPuU[:xdigit:]]");
+  input.setGeometry (FPoint(2, 2), FSize{12, 1});
+  input.setLabelText (L"&Hex value");
+  input.setLabelText (L"&Hex-digits or (.) (:) (H) (L) (P) (U)");
+  input.setLabelOrientation(finalcut::FLineEdit::label_above);
+  input.setMaxLength(9);
+  input.setInputFilter("[:.hHlLpPuU[:xdigit:]]");
 
   // Exit button
-  Exit.setGeometry(FPoint{28, 11}, FSize{10, 1});
+  exit.setGeometry(FPoint{28, 11}, FSize{10, 1});
 
   // Add some function callbacks
-  Input.addCallback
+  input.addCallback
   (
     "changed",
     [] (SegmentView& dialog)
@@ -107,7 +107,7 @@ SegmentView::SegmentView (finalcut::FWidget* parent)
     std::ref(*this)
   );
 
-  Exit.addCallback
+  exit.addCallback
   (
     "clicked",
     finalcut::getFApplication(),
@@ -206,7 +206,7 @@ void SegmentView::draw()
   setColor(fc::LightGray, fc::Black);
   finalcut::drawBorder(this, FRect(FPoint{3, 6}, FPoint{40, 11}));
 
-  for (auto&& ch : Input.getText().toUpper())
+  for (auto&& ch : input.getText().toUpper())
   {
     const FColorPair color{fc::LightRed, fc::Black};
     get7Segment(ch);
diff --git a/examples/busy.cpp b/examples/busy.cpp
index 24e3bf22..281da6e7 100644
--- a/examples/busy.cpp
+++ b/examples/busy.cpp
@@ -89,13 +89,13 @@ Dialog::Dialog (FWidget* parent)
 void Dialog::adjustSize()
 {
   finalcut::FDialog::adjustSize();
-  int X = int((getDesktopWidth() - getWidth()) / 2);
-  const int Y = 5;
+  int x = int((getDesktopWidth() - getWidth()) / 2);
+  const int y = 5;
 
-  if ( X < 1 )
-    X = 1;
+  if ( x < 1 )
+    x = 1;
 
-  setPos (FPoint{X, Y}, false);
+  setPos (FPoint{x, y}, false);
 }
 
 //----------------------------------------------------------------------
diff --git a/examples/calculator.cpp b/examples/calculator.cpp
index ae3f2b9f..156a5c96 100644
--- a/examples/calculator.cpp
+++ b/examples/calculator.cpp
@@ -36,7 +36,7 @@ using finalcut::FRect;
 using finalcut::FSize;
 using finalcut::FColorPair;
 
-constexpr lDouble PI{3.141592653589793238L};
+constexpr lDouble pi_value{3.141592653589793238L};
 
 
 //----------------------------------------------------------------------
@@ -233,13 +233,13 @@ class Calc final : public finalcut::FDialog
     finalcut::FString input{""};
     button            button_no[Calc::NUM_OF_BUTTONS]{};
 
-    struct stack_data
+    struct StackData
     {
       lDouble term;
       char infix_operator;
     };
 
-    std::stack bracket_stack{};
+    std::stack bracket_stack{};
     std::map > calculator_buttons{};
     std::map key_map{};
 };
@@ -703,14 +703,14 @@ void Calc::percent (lDouble& x)
 //----------------------------------------------------------------------
 void Calc::pi (lDouble& x)
 {
-  x = PI;
+  x = pi_value;
   setDisplay(x);
 }
 
 //----------------------------------------------------------------------
 void Calc::open_bracket (const lDouble&)
 {
-  const stack_data d{ a, infix_operator };
+  const StackData d{ a, infix_operator };
   bracket_stack.push(d);
   clearInfixOperator();
   input = "";
@@ -726,7 +726,7 @@ void Calc::close_bracket (const lDouble&)
 
   calcInfixOperator();
   setDisplay(a);
-  const stack_data d = bracket_stack.top();
+  const StackData d = bracket_stack.top();
   bracket_stack.pop();
   b = d.term;
   infix_operator = d.infix_operator;
@@ -835,11 +835,11 @@ void Calc::sine (lDouble& x)
   else
   {
     if ( arcus_mode )
-      x = std::asin(x) * 180.0L / PI;
+      x = std::asin(x) * 180.0L / pi_value;
     else if ( std::fabs(std::fmod(x, 180.0L)) < LDBL_EPSILON )  // x / 180 = 0
       x = 0.0L;
     else
-      x = std::sin(x * PI / 180.0L);
+      x = std::sin(x * pi_value / 180.0L);
   }
 
   if ( errno == EDOM )
@@ -873,11 +873,11 @@ void Calc::cosine (lDouble& x)
   else
   {
     if ( arcus_mode )
-      x = std::acos(x) * 180.0L / PI;
+      x = std::acos(x) * 180.0L / pi_value;
     else if ( std::fabs(std::fmod(x - 90.0L, 180.0L)) < LDBL_EPSILON )  // (x - 90) / 180 == 0
       x = 0.0L;
     else
-      x = std::cos(x * PI / 180.0L);
+      x = std::cos(x * pi_value / 180.0L);
   }
 
   if ( errno == EDOM )
@@ -911,7 +911,7 @@ void Calc::tangent (lDouble& x)
   else
   {
     if ( arcus_mode )
-      x = std::atan(x) * 180.0L / PI;
+      x = std::atan(x) * 180.0L / pi_value;
     else
     {
       // Test if (x / 180) != 0 and x / 90 == 0
@@ -921,7 +921,7 @@ void Calc::tangent (lDouble& x)
       else if ( std::fabs(std::fmod(x, 180.0L)) < LDBL_EPSILON )  // x / 180 == 0
         x = 0.0L;
       else
-        x = std::tan(x * PI / 180.0L);
+        x = std::tan(x * pi_value / 180.0L);
     }
   }
 
diff --git a/examples/checklist.cpp b/examples/checklist.cpp
index 6304866a..07248adf 100644
--- a/examples/checklist.cpp
+++ b/examples/checklist.cpp
@@ -67,7 +67,7 @@ class CheckList final : public finalcut::FDialog
     void cb_showList();
 
     // Data members
-    finalcut::FListView  listView{this};
+    finalcut::FListView  listview{this};
     finalcut::FStatusBar status_bar{this};
 };
 
@@ -83,22 +83,22 @@ CheckList::CheckList (finalcut::FWidget* parent)
   FDialog::setGeometry ( FPoint{int(1 + (parent->getWidth() - 28) / 2), 5}
                        , FSize{28 + nf_offset, 13} );
   setShadow();
-  listView.ignorePadding();
-  listView.setGeometry ( FPoint{1 + int(nf_offset), 2}
+  listview.ignorePadding();
+  listview.setGeometry ( FPoint{1 + int(nf_offset), 2}
                        , FSize{getWidth() - nf_offset, getHeight() - 1} );
 
   // Add columns to the view
-  listView.addColumn ("Item");
-  listView.addColumn ("Priority", 9);
+  listview.addColumn ("Item");
+  listview.addColumn ("Priority", 9);
 
   // Set the type of sorting
-  listView.setColumnSortType (1, fc::by_name);
-  listView.setColumnSortType (2, fc::by_name);
+  listview.setColumnSortType (1, fc::by_name);
+  listview.setColumnSortType (2, fc::by_name);
 
   // Statusbar at the bottom
   finalcut::FString separator{};
   separator << ' ' << fc::BoxDrawingsVertical << ' ';
-  listView.setStatusbarMessage ( finalcut::FString{}
+  listview.setStatusbarMessage ( finalcut::FString{}
                                  << " exit" << separator
                                  << " select an item" << separator
                                  << " see your pick list");
@@ -107,7 +107,7 @@ CheckList::CheckList (finalcut::FWidget* parent)
   populate();
 
   // Add callback method
-  listView.addCallback
+  listview.addCallback
   (
     "clicked",
     this, &CheckList::cb_showList
@@ -138,7 +138,7 @@ void CheckList::populate()
   for (const auto& line : list)
   {
     const finalcut::FStringList string_line (&line[0], &line[0] + 2);
-    auto iter = listView.insert (string_line);
+    auto iter = listview.insert (string_line);
     auto item = static_cast(*iter);
     item->setCheckable(true);
   }
@@ -170,10 +170,10 @@ void CheckList::onClose (finalcut::FCloseEvent* ev)
 //----------------------------------------------------------------------
 void CheckList::cb_showList()
 {
-  auto iter = listView.beginOfList();
+  auto iter = listview.beginOfList();
   finalcut::FString shopping_list{};
 
-  while ( iter != listView.endOfList() )
+  while ( iter != listview.endOfList() )
   {
     const auto item = static_cast(*iter);
 
diff --git a/examples/event-log.cpp b/examples/event-log.cpp
index ee9284c8..a82db7fa 100644
--- a/examples/event-log.cpp
+++ b/examples/event-log.cpp
@@ -162,8 +162,10 @@ void EventDialog::onKeyPress (finalcut::FKeyEvent* ev)
   if ( key_name.isEmpty() )
     key_name = wchar_t(key_id);
 
-  log << finalcut::FLog::Info
-      << "Key " << key_name << " (id " << key_id << ")" << std::flush;
+  // std::clog redirects all stream data to FLogger
+  std::clog << finalcut::FLog::Info
+            << "Key " << key_name
+            << " (id " << key_id << ")" << std::flush;
 
   finalcut::FDialog::onKeyPress(ev);
 }
@@ -257,7 +259,7 @@ class EventLog final : public finalcut::FDialog, public std::ostringstream
     void adjustSize() override;
 
     // Data members
-    finalcut::FTextView scrollText{this};
+    finalcut::FTextView scrolltext{this};
     EventDialog* event_dialog{new EventDialog(this)};
 };
 
@@ -273,8 +275,8 @@ EventLog::EventLog (finalcut::FWidget* parent)
   FDialog::setResizeable();
   setMinimumSize (FSize{75, 5});
   setShadow();
-  scrollText.ignorePadding();
-  scrollText.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
+  scrolltext.ignorePadding();
+  scrolltext.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
   event_dialog->setFocus();
   addTimer(250);  // Starts the timer every 250 milliseconds
 }
@@ -288,9 +290,9 @@ void EventLog::onTimer (finalcut::FTimerEvent*)
 {
   if ( ! str().empty() )
   {
-    scrollText.append(str());
+    scrolltext.append(str());
     str("");
-    scrollText.scrollToEnd();
+    scrolltext.scrollToEnd();
     redraw();
     updateTerminal();
   }
@@ -306,7 +308,7 @@ void EventLog::onClose (finalcut::FCloseEvent* ev)
 void EventLog::adjustSize()
 {
   finalcut::FDialog::adjustSize();
-  scrollText.setGeometry (FPoint{1, 2}, FSize(getWidth(), getHeight() - 1));
+  scrolltext.setGeometry (FPoint{1, 2}, FSize(getWidth(), getHeight() - 1));
 }
 
 
diff --git a/examples/input-dialog.cpp b/examples/input-dialog.cpp
index e977d60d..c0912dc2 100644
--- a/examples/input-dialog.cpp
+++ b/examples/input-dialog.cpp
@@ -93,22 +93,22 @@ int main (int argc, char* argv[])
   c_field.setGeometry (FPoint{11, 11}, FSize{4, 1});
 
   // Create the button group
-  finalcut::FButtonGroup radioButtonGroup {"Sex", &dgl};
-  radioButtonGroup.setGeometry(FPoint{2, 13}, FSize{13, 4});
+  finalcut::FButtonGroup radiobutton_group {"Sex", &dgl};
+  radiobutton_group.setGeometry(FPoint{2, 13}, FSize{13, 4});
 
   // Create radio buttons
-  finalcut::FRadioButton male {"&Male", &radioButtonGroup};
-  finalcut::FRadioButton female {"&Female", &radioButtonGroup};
+  finalcut::FRadioButton male {"&Male", &radiobutton_group};
+  finalcut::FRadioButton female {"&Female", &radiobutton_group};
   male.setGeometry (FPoint{1, 1}, FSize{8, 1});
   female.setGeometry (FPoint{1, 2}, FSize{10, 1});
 
   // Create another button group
-  finalcut::FButtonGroup checkButtonGroup {"&Data options", &dgl};
-  checkButtonGroup.setGeometry(FPoint{16, 13}, FSize{19, 4});
+  finalcut::FButtonGroup checkbutton_group {"&Data options", &dgl};
+  checkbutton_group.setGeometry(FPoint{16, 13}, FSize{19, 4});
 
   // Create checkbox buttons
-  finalcut::FCheckBox check1 {"Save data", &checkButtonGroup};
-  finalcut::FCheckBox check2 {"Encrypt data", &checkButtonGroup};
+  finalcut::FCheckBox check1 {"Save data", &checkbutton_group};
+  finalcut::FCheckBox check2 {"Encrypt data", &checkbutton_group};
   check1.setGeometry (FPoint{1, 1}, FSize{13, 1});
   check2.setGeometry (FPoint{1, 2}, FSize{16, 1});
   check2.setDisable();
diff --git a/examples/listbox.cpp b/examples/listbox.cpp
index 017b4f5a..3c5cef26 100644
--- a/examples/listbox.cpp
+++ b/examples/listbox.cpp
@@ -101,7 +101,7 @@ class Listbox final : public FDialog
     FListBox list1{this};
     FListBox list2{this};
     FListBox list3{this};
-    FButton  Quit{this};
+    FButton  quit{this};
 };
 
 //----------------------------------------------------------------------
@@ -151,11 +151,11 @@ Listbox::Listbox (FWidget* parent)
   list3.setText ("key: value");
 
   // Quit button
-  Quit.setGeometry(FPoint{42, 12}, FSize{10, 1});
-  Quit.setText (L"&Quit");
+  quit.setGeometry(FPoint{42, 12}, FSize{10, 1});
+  quit.setText (L"&Quit");
 
   // Add quit button function callback
-  Quit.addCallback
+  quit.addCallback
   (
     "clicked",
     finalcut::getFApplication(),
diff --git a/examples/listview.cpp b/examples/listview.cpp
index 6f7c905a..c2587da4 100644
--- a/examples/listview.cpp
+++ b/examples/listview.cpp
@@ -62,8 +62,8 @@ class Listview final : public finalcut::FDialog
     void cb_showInMessagebox();
 
     // Data members
-    finalcut::FListView listView{this};
-    finalcut::FButton   Quit{this};
+    finalcut::FListView listview{this};
+    finalcut::FButton   quit{this};
 };
 
 //----------------------------------------------------------------------
@@ -71,44 +71,44 @@ Listview::Listview (finalcut::FWidget* parent)
   : finalcut::FDialog{parent}
 {
   // Set FListView geometry
-  listView.setGeometry(FPoint{2, 1}, FSize{33, 14});
+  listview.setGeometry(FPoint{2, 1}, FSize{33, 14});
 
   // Add columns to the view
-  listView.addColumn ("City");
-  listView.addColumn ("Condition");
-  listView.addColumn ("Temp.");
-  listView.addColumn ("Humidity");
-  listView.addColumn ("Pressure", 10);
+  listview.addColumn ("City");
+  listview.addColumn ("Condition");
+  listview.addColumn ("Temp.");
+  listview.addColumn ("Humidity");
+  listview.addColumn ("Pressure", 10);
 
   // Set right alignment for the third, fourth, and fifth column
-  listView.setColumnAlignment (3, fc::alignRight);
-  listView.setColumnAlignment (4, fc::alignRight);
-  listView.setColumnAlignment (5, fc::alignRight);
+  listview.setColumnAlignment (3, fc::alignRight);
+  listview.setColumnAlignment (4, fc::alignRight);
+  listview.setColumnAlignment (5, fc::alignRight);
 
   // Set the type of sorting
-  listView.setColumnSortType (1, fc::by_name);
-  listView.setColumnSortType (2, fc::by_name);
-  listView.setColumnSortType (3, fc::by_number);
-  listView.setColumnSortType (4, fc::by_number);
-  listView.setColumnSortType (5, fc::by_number);
+  listview.setColumnSortType (1, fc::by_name);
+  listview.setColumnSortType (2, fc::by_name);
+  listview.setColumnSortType (3, fc::by_number);
+  listview.setColumnSortType (4, fc::by_number);
+  listview.setColumnSortType (5, fc::by_number);
 
   // Sort in ascending order by the 1st column
-  listView.setColumnSort (1, fc::ascending);
+  listview.setColumnSort (1, fc::ascending);
   // Sorting follows later automatically on insert().
   // Otherwise you could start the sorting directly with sort()
 
   // Allways show the sort indicator (▼/▲)
-  listView.hideSortIndicator(false);
+  listview.hideSortIndicator(false);
 
   // Populate FListView with a list of items
   populate();
 
   // Quit button
-  Quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
-  Quit.setText (L"&Quit");
+  quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
+  quit.setText (L"&Quit");
 
   // Add some function callbacks
-  Quit.addCallback
+  quit.addCallback
   (
     "clicked",
     finalcut::getFApplication(),
@@ -116,7 +116,7 @@ Listview::Listview (finalcut::FWidget* parent)
     this
   );
 
-  listView.addCallback
+  listview.addCallback
   (
     "clicked",
     this, &Listview::cb_showInMessagebox
@@ -178,7 +178,7 @@ void Listview::populate()
   for (const auto& place : weather)
   {
     const finalcut::FStringList line (&place[0], &place[0] + 5);
-    listView.insert (line);
+    listview.insert (line);
   }
 }
 
@@ -191,7 +191,7 @@ void Listview::onClose (finalcut::FCloseEvent* ev)
 //----------------------------------------------------------------------
 void Listview::cb_showInMessagebox()
 {
-  const auto& item = listView.getCurrentItem();
+  const auto& item = listview.getCurrentItem();
   finalcut::FMessageBox info ( "Weather in " + item->getText(1)
                              , "  Condition: " + item->getText(2) + "\n"
                                "Temperature: " + item->getText(3) + "\n"
diff --git a/examples/string-operations.cpp b/examples/string-operations.cpp
index a9ef2794..faacd892 100644
--- a/examples/string-operations.cpp
+++ b/examples/string-operations.cpp
@@ -481,9 +481,9 @@ void stringSplittingExample()
 void fromatStringExample()
 {
   // Test: format a string with sprintf
-  finalcut::FString formatStr{""};
+  finalcut::FString format_str{""};
   std::cout << " formatted: "
-            << formatStr.sprintf("sqrt(%d) = %d", 16, 4)
+            << format_str.sprintf("sqrt(%d) = %d", 16, 4)
             << std::endl;
 }
 
diff --git a/examples/termcap.cpp b/examples/termcap.cpp
index bbe7f067..1c36835c 100644
--- a/examples/termcap.cpp
+++ b/examples/termcap.cpp
@@ -42,21 +42,21 @@ void string();
 // struct data
 //----------------------------------------------------------------------
 
-struct data
+struct Data
 {
-  struct alignas(alignof(std::string)) termcap_string
+  struct alignas(alignof(std::string)) TermcapString
   {
     const std::string name;
     const fc::termcaps cap;
   };
 
-  static termcap_string strings[];
+  static TermcapString strings[];
 };
 
 //----------------------------------------------------------------------
 // struct data - string data array
 //----------------------------------------------------------------------
-data::termcap_string data::strings[] =
+Data::TermcapString Data::strings[] =
 {
   { "t_bell", fc::t_bell },
   { "t_erase_chars", fc::t_erase_chars },
@@ -285,7 +285,7 @@ void string()
   const finalcut::FTermcap::tcap_map (&tcap_strings)[] \
       = finalcut::FTermcap::strings;
 
-  for (const auto& entry : data::strings)
+  for (const auto& entry : Data::strings)
   {
     const std::string name = entry.name;
     const fc::termcaps cap = entry.cap;
diff --git a/examples/transparent.cpp b/examples/transparent.cpp
index ac8d5644..38a9e988 100644
--- a/examples/transparent.cpp
+++ b/examples/transparent.cpp
@@ -256,12 +256,12 @@ void MainWindow::onShow (finalcut::FShowEvent*)
 //----------------------------------------------------------------------
 void MainWindow::onTimer (finalcut::FTimerEvent*)
 {
-  wchar_t first_Char[2];
+  wchar_t first_char[2];
   std::size_t length = line1.getLength();
-  first_Char[0] = line1[0];
-  first_Char[1] = line2[0];
-  line1 = line1.right(length - 1) + first_Char[0];
-  line2 = line2.right(length - 1) + first_Char[1];
+  first_char[0] = line1[0];
+  first_char[1] = line2[0];
+  line1 = line1.right(length - 1) + first_char[0];
+  line2 = line2.right(length - 1) + first_char[1];
   redraw();
   flush();
 }
diff --git a/examples/treeview.cpp b/examples/treeview.cpp
index 438ab0f3..a0393b4a 100644
--- a/examples/treeview.cpp
+++ b/examples/treeview.cpp
@@ -33,7 +33,7 @@ using finalcut::FSize;
 
 
 // Function prototypes
-sInt64 StringToNumber (const finalcut::FString&);
+sInt64 stringToNumber (const finalcut::FString&);
 bool sortAscending (const finalcut::FObject*, const finalcut::FObject*);
 bool sortDescending (const finalcut::FObject*, const finalcut::FObject*);
 bool isLessThanInteger (const finalcut::FString&, const finalcut::FString&);
@@ -44,13 +44,13 @@ bool isGreaterThanDouble (const finalcut::FString&, const finalcut::FString&);
 
 // non-member functions
 //----------------------------------------------------------------------
-sInt64 StringToNumber (const finalcut::FString& str)
+sInt64 stringToNumber (const finalcut::FString& str)
 {
   // Cut off one character (because LONG_MAX = 2147483647)
-  auto NumString = str.left(str.getLength() - 1);
-  NumString = NumString.replace(",", "");
-  NumString = NumString.replace('.', "");
-  sInt64 number = sInt64(NumString.toLong());
+  auto num_string = str.left(str.getLength() - 1);
+  num_string = num_string.replace(",", "");
+  num_string = num_string.replace('.', "");
+  sInt64 number = sInt64(num_string.toLong());
   return number;
 }
 
@@ -58,8 +58,8 @@ sInt64 StringToNumber (const finalcut::FString& str)
 inline bool isLessThanInteger ( const finalcut::FString& lhs
                               , const finalcut::FString& rhs )
 {
-  const sInt64 l_number = StringToNumber(lhs);
-  const sInt64 r_number = StringToNumber(rhs);
+  const sInt64 l_number = stringToNumber(lhs);
+  const sInt64 r_number = stringToNumber(rhs);
   return bool( l_number < r_number );  // lhs < rhs
 }
 
@@ -77,8 +77,8 @@ inline bool isLessThanDouble ( const finalcut::FString& lhs
 inline bool isGreaterThanInteger ( const finalcut::FString& lhs
                                  , const finalcut::FString& rhs )
 {
-  const sInt64 l_number = StringToNumber(lhs);
-  const sInt64 r_number = StringToNumber(rhs);
+  const sInt64 l_number = stringToNumber(lhs);
+  const sInt64 r_number = stringToNumber(rhs);
   return bool( l_number > r_number );  // lhs > rhs
 }
 
@@ -168,8 +168,8 @@ class Treeview final : public finalcut::FDialog
 
     // Data members
     bool                initialized{false};
-    finalcut::FListView listView{this};
-    finalcut::FButton   Quit{this};
+    finalcut::FListView listview{this};
+    finalcut::FButton   quit{this};
     static TreeItem     africa[];
     static TreeItem     asia[];
     static TreeItem     europe[];
@@ -329,26 +329,26 @@ Treeview::Treeview (finalcut::FWidget* parent)
   : finalcut::FDialog{parent}
 {
   // Set FListView geometry
-  listView.setGeometry(FPoint{2, 1}, FSize{53, 14});
+  listview.setGeometry(FPoint{2, 1}, FSize{53, 14});
 
   // Add columns to the view
-  listView.addColumn ("Name", 23);
-  listView.addColumn ("Population");
-  listView.addColumn ("Density/km²");
+  listview.addColumn ("Name", 23);
+  listview.addColumn ("Population");
+  listview.addColumn ("Density/km²");
 
   // Set right alignment for the second and third column
-  listView.setColumnAlignment (2, fc::alignRight);
-  listView.setColumnAlignment (3, fc::alignRight);
+  listview.setColumnAlignment (2, fc::alignRight);
+  listview.setColumnAlignment (3, fc::alignRight);
 
   // Set the type of sorting
-  listView.setColumnSortType (1, fc::by_name);
-  listView.setColumnSortType (2, fc::user_defined);
-  listView.setColumnSortType (3, fc::user_defined);
-  listView.setUserAscendingCompare(sortAscending);
-  listView.setUserDescendingCompare(sortDescending);
+  listview.setColumnSortType (1, fc::by_name);
+  listview.setColumnSortType (2, fc::user_defined);
+  listview.setColumnSortType (3, fc::user_defined);
+  listview.setUserAscendingCompare(sortAscending);
+  listview.setUserDescendingCompare(sortDescending);
 
   // Activate tree view
-  listView.setTreeView();
+  listview.setTreeView();
 
   // Populate FListView with a list of items
   static TreeItem continent_list[] =
@@ -367,23 +367,23 @@ Treeview::Treeview (finalcut::FWidget* parent)
     const TreeItem* country_list = continent.child_element;
     finalcut::FStringList continent_line ( continent.begin()
                                          , continent.end() );
-    auto iter = listView.insert (continent_line);
+    auto iter = listview.insert (continent_line);
 
     while ( country_list && country_list->name )
     {
       finalcut::FStringList country_line ( country_list->begin()
                                          , country_list->end() );
-      listView.insert (country_line, iter);
+      listview.insert (country_line, iter);
       country_list++;
     }
   }
 
-  // Quit button
-  Quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
-  Quit.setText (L"&Quit");
+  // quit button
+  quit.setGeometry(FPoint{24, 16}, FSize{10, 1});
+  quit.setText (L"&Quit");
 
   // Callback function
-  Quit.addCallback
+  quit.addCallback
   (
     "clicked",
     finalcut::getFApplication(),
@@ -403,17 +403,17 @@ void Treeview::adjustSize()
 {
   std::size_t h = getDesktopHeight() - 4;
   setHeight (h, false);
-  int X = int((getDesktopWidth() - getWidth()) / 2);
+  int x = int((getDesktopWidth() - getWidth()) / 2);
 
-  if ( X < 1 )
-    X = 1;
+  if ( x < 1 )
+    x = 1;
 
-  setX (X, false);
+  setX (x, false);
 
   if ( initialized )
   {
-    listView.setHeight (getHeight() - 6, false);
-    Quit.setY(int(getHeight()) - 4);
+    listview.setHeight (getHeight() - 6, false);
+    quit.setY(int(getHeight()) - 4);
   }
 
   finalcut::FDialog::adjustSize();
diff --git a/examples/ui.cpp b/examples/ui.cpp
index a6638197..8f0b8a99 100644
--- a/examples/ui.cpp
+++ b/examples/ui.cpp
@@ -68,7 +68,7 @@ class ProgressDialog final : public finalcut::FDialog
     void cb_exit_bar();
 
     // Data members
-    finalcut::FProgressbar progressBar{this};
+    finalcut::FProgressbar progressbar{this};
     finalcut::FButton      reset{this};
     finalcut::FButton      more{this};
     finalcut::FButton      quit{this};
@@ -100,8 +100,8 @@ ProgressDialog::ProgressDialog (finalcut::FWidget* parent)
   quit.setGeometry(FPoint{28, 6}, FSize{8, 1}, false);
   quit.setDisable();
 
-  progressBar.setGeometry(FPoint{2, 3}, FSize{34, 1}, false);
-  //progressBar.setPercentage(78);
+  progressbar.setGeometry(FPoint{2, 3}, FSize{34, 1}, false);
+  //progressbar.setPercentage(78);
 
   reset.addCallback
   (
@@ -140,9 +140,9 @@ void ProgressDialog::onShow (finalcut::FShowEvent*)
 //----------------------------------------------------------------------
 void ProgressDialog::onTimer (finalcut::FTimerEvent*)
 {
-  auto p = progressBar.getPercentage();
+  auto p = progressbar.getPercentage();
   p++;
-  progressBar.setPercentage(p);
+  progressbar.setPercentage(p);
   flush();
 
   if ( p != 100 )
@@ -167,15 +167,15 @@ void ProgressDialog::onTimer (finalcut::FTimerEvent*)
 //----------------------------------------------------------------------
 void ProgressDialog::cb_reset_bar()
 {
-  progressBar.reset();
+  progressbar.reset();
 }
 
 //----------------------------------------------------------------------
 void ProgressDialog::cb_more_bar()
 {
-  auto p = progressBar.getPercentage();
+  auto p = progressbar.getPercentage();
   p++;
-  progressBar.setPercentage(p);
+  progressbar.setPercentage(p);
 }
 
 //----------------------------------------------------------------------
@@ -212,25 +212,25 @@ class TextWindow final : public finalcut::FDialog
     void adjustSize() override;
 
     // Data members
-    finalcut::FTextView scrollText{this};
+    finalcut::FTextView scrolltext{this};
 };
 
 //----------------------------------------------------------------------
 TextWindow::TextWindow (finalcut::FWidget* parent)
   : finalcut::FDialog{parent}
 {
-  scrollText.ignorePadding();
-  scrollText.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
+  scrolltext.ignorePadding();
+  scrolltext.setGeometry (FPoint{1, 2}, FSize{getWidth(), getHeight() - 1});
   setMinimumSize (FSize{51, 6});
-  scrollText.setFocus();
-  scrollText.insert(" -----------------------------------------------\n"
+  scrolltext.setFocus();
+  scrolltext.insert(" -----------------------------------------------\n"
                     " line 1\n"
                     " -----------------------------------------------\n"
                     " line 3\n"
                     " line 4"
                     , -1);
-  scrollText.replaceRange("                   File viewer", 1, 1);
-  scrollText.deleteRange(3, 4);
+  scrolltext.replaceRange("                   File viewer", 1, 1);
+  scrolltext.deleteRange(3, 4);
 }
 
 //----------------------------------------------------------------------
@@ -240,14 +240,14 @@ TextWindow::~TextWindow()  // destructor
 //----------------------------------------------------------------------
 void TextWindow::append (const finalcut::FString& str)
 {
-  scrollText.append(str);
+  scrolltext.append(str);
 }
 
 //----------------------------------------------------------------------
 void TextWindow::adjustSize()
 {
   finalcut::FDialog::adjustSize();
-  scrollText.setGeometry (FPoint{1, 2}, FSize(getWidth(), getHeight() - 1));
+  scrolltext.setGeometry (FPoint{1, 2}, FSize(getWidth(), getHeight() - 1));
 }
 
 
@@ -784,12 +784,12 @@ void MyDialog::adjustSize()
 {
   const auto h = getParentWidget()->getHeight() - 4;
   setHeight (h, false);
-  int X = int((getDesktopWidth() - getWidth()) / 2);
+  int x = int((getDesktopWidth() - getWidth()) / 2);
 
-  if ( X < 1 )
-    X = 1;
+  if ( x < 1 )
+    x = 1;
 
-  setX (X, false);
+  setX (x, false);
 
   if ( initialized )
     myList.setHeight (getHeight() - 3, false);
diff --git a/examples/windows.cpp b/examples/windows.cpp
index 1283e6f2..526a28f1 100644
--- a/examples/windows.cpp
+++ b/examples/windows.cpp
@@ -122,7 +122,7 @@ void SmallWindow::adjustSize()
   else
   {
     top_right_label = "zoom";
-    bottom_label.setVisible();
+    bottom_label.show();
   }
 
   finalcut::FDialog::adjustSize();
diff --git a/src/Makefile.am b/src/Makefile.am
index 6eb26cfc..b85607e3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -20,6 +20,7 @@ libfinal_la_SOURCES = \
 	fbutton.cpp \
 	fbuttongroup.cpp \
 	fcallback.cpp \
+	fdata.cpp \
 	ftogglebutton.cpp \
 	fradiobutton.cpp \
 	fcheckbox.cpp \
diff --git a/src/Makefile.clang b/src/Makefile.clang
index 00547773..fef6c695 100644
--- a/src/Makefile.clang
+++ b/src/Makefile.clang
@@ -13,6 +13,7 @@ INCLUDE_HEADERS = \
 	fbuttongroup.h \
 	fbutton.h \
 	fcallback.h \
+	fdata.h \
 	fcolorpair.h \
 	fstyle.h \
 	ftogglebutton.h \
@@ -93,6 +94,7 @@ OBJS = \
 	fsize.o \
 	frect.o \
 	fcallback.o \
+	fdata.o \
 	fscrollbar.o \
 	fprogressbar.o \
 	flineedit.o \
diff --git a/src/Makefile.gcc b/src/Makefile.gcc
index 6ab87c5b..885996af 100644
--- a/src/Makefile.gcc
+++ b/src/Makefile.gcc
@@ -13,6 +13,7 @@ INCLUDE_HEADERS = \
 	fbuttongroup.h \
 	fbutton.h \
 	fcallback.h \
+	fdata.h \
 	fcolorpair.h \
 	fstyle.h \
 	ftogglebutton.h \
@@ -93,6 +94,7 @@ OBJS = \
 	fsize.o \
 	frect.o \
 	fcallback.o \
+	fdata.o \
 	fscrollbar.o \
 	fprogressbar.o \
 	flineedit.o \
diff --git a/src/fapplication.cpp b/src/fapplication.cpp
index ec644f0c..3d1bfd75 100644
--- a/src/fapplication.cpp
+++ b/src/fapplication.cpp
@@ -22,7 +22,9 @@
 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 
@@ -131,18 +133,28 @@ FWidget* FApplication::getKeyboardWidget()
 FApplication::FLogPtr& FApplication::getLog()
 {
   // Global logger object
-  static FLogPtr* logger = new FLogPtr();
+  static FLogPtr* logger_ptr = new FLogPtr();
 
-  if ( logger && logger->get() == nullptr )
-    *logger = std::make_shared();
+  if ( logger_ptr && logger_ptr->get() == nullptr )
+  {
+    *logger_ptr = std::make_shared();
 
-  return *logger;
+    // Set the logger as rdbuf of clog
+    std::clog.rdbuf(logger_ptr->get());
+  }
+
+  return *logger_ptr;
 }
 
 //----------------------------------------------------------------------
-void FApplication::setLog (const FLogPtr& logger)
+void FApplication::setLog (const FLogPtr& log)
 {
-  getLog() = logger;
+  FLogPtr& logger = getLog();
+  logger.reset();
+  logger = log;
+
+  // Set the logger as rdbuf of clog
+  std::clog.rdbuf(logger.get());
 }
 
 //----------------------------------------------------------------------
@@ -586,6 +598,10 @@ void FApplication::showParameterUsage()
 //----------------------------------------------------------------------
 inline void FApplication::destroyLog()
 {
+  // Reset the rdbuf of clog
+  std::clog.rdbuf(default_clog_rdbuf);
+
+  // Delete the logger
   const FLogPtr* logger = &(getLog());
   delete logger;
 }
@@ -1354,4 +1370,13 @@ bool FApplication::isNextEventTimeout()
   return FObject::isTimeout (&time_last_event, next_event_wait);
 }
 
+
+// FLog non-member operators
+//----------------------------------------------------------------------
+std::ostream& operator << (std::ostream& outstr, FLog::LogLevel l)
+{
+  *FApplication::getLog() << l;
+  return outstr;
+}
+
 }  // namespace finalcut
diff --git a/src/fcharmap.cpp b/src/fcharmap.cpp
index ad782f45..06597bb1 100644
--- a/src/fcharmap.cpp
+++ b/src/fcharmap.cpp
@@ -159,7 +159,7 @@ uInt character[][fc::NUM_OF_ENCODINGS] =
  * (2) Only supported in use with newfont
  */
 
-const std::size_t lastCharItem = \
+constexpr std::size_t last_char_item = \
     std::size_t((sizeof(character) / sizeof(character[0])) - 1);
 
 
@@ -206,7 +206,7 @@ constexpr int vt100_key_to_utf8[][2] =
   {fc::vt100_key_diamond  , fc::Bullet}                         // ◆
 };
 
-const std::size_t lastKeyItem = \
+constexpr std::size_t last_key_item = \
     std::size_t((sizeof(vt100_key_to_utf8) / sizeof(vt100_key_to_utf8[0])) - 1);
 
 
@@ -470,11 +470,11 @@ constexpr wchar_t cp437_ucs[][2] =
   {0xff, 0x00a0}   // no-break space
 };
 
-const std::size_t lastCP437Item = \
+constexpr std::size_t last_cp437_item = \
     std::size_t((sizeof(cp437_ucs) / sizeof(cp437_ucs[0])) - 1);
 
 // Based on http://www.unicode.org/charts/PDF/UFF00.pdf
-constexpr wchar_t halfWidth_fullWidth[][2] =
+constexpr wchar_t halfwidth_fullwidth[][2] =
 {
   // Fullwidth ASCII variants
   {0x0020, 0x3000},  // ' ' -> ' '
@@ -712,8 +712,8 @@ constexpr wchar_t halfWidth_fullWidth[][2] =
   {0xffee, 0x25cb}   // ○ -> ○
 };
 
-const std::size_t lastHalfWidthItem = \
-    std::size_t((sizeof(halfWidth_fullWidth) / sizeof(halfWidth_fullWidth[0])) - 1);
+constexpr std::size_t last_halfwidth_item = \
+    std::size_t((sizeof(halfwidth_fullwidth) / sizeof(halfwidth_fullwidth[0])) - 1);
 
 }  // namespace fc
 
diff --git a/src/fcombobox.cpp b/src/fcombobox.cpp
index 3d16be66..8ee8ca44 100644
--- a/src/fcombobox.cpp
+++ b/src/fcombobox.cpp
@@ -29,7 +29,6 @@
 #include "final/flabel.h"
 #include "final/flineedit.h"
 #include "final/flistbox.h"
-#include "final/flog.h"
 #include "final/fmouse.h"
 #include "final/fpoint.h"
 #include "final/fsize.h"
diff --git a/src/fdata.cpp b/src/fdata.cpp
new file mode 100644
index 00000000..f39345d9
--- /dev/null
+++ b/src/fdata.cpp
@@ -0,0 +1,42 @@
+/***********************************************************************
+* fdata.cpp - A general-purpose data wrapper                           *
+*                                                                      *
+* This file is part of the FINAL CUT widget toolkit                    *
+*                                                                      *
+* Copyright 2020 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       *
+* published by the Free Software Foundation; either version 3 of       *
+* the License, or (at your option) any later version.                  *
+*                                                                      *
+* FINAL CUT is distributed in the hope that it will be useful, but     *
+* WITHOUT ANY WARRANTY; without even the implied warranty of           *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
+* GNU Lesser General Public License for more details.                  *
+*                                                                      *
+* You should have received a copy of the GNU Lesser General Public     *
+* License along with this program.  If not, see                        *
+* .                                      *
+***********************************************************************/
+
+#include "final/fdata.h"
+
+namespace finalcut
+{
+
+//----------------------------------------------------------------------
+// class FDataAccess
+//----------------------------------------------------------------------
+
+// constructors and destructor
+//----------------------------------------------------------------------
+FDataAccess::FDataAccess()
+{ }
+
+//----------------------------------------------------------------------
+FDataAccess::~FDataAccess()  // destructor
+{ }
+
+}  // namespace finalcut
+
diff --git a/src/flineedit.cpp b/src/flineedit.cpp
index 317b784e..e5556ebd 100644
--- a/src/flineedit.cpp
+++ b/src/flineedit.cpp
@@ -25,8 +25,8 @@
 #include "final/fapplication.h"
 #include "final/fevent.h"
 #include "final/flabel.h"
-#include "final/flog.h"
 #include "final/flineedit.h"
+#include "final/flog.h"
 #include "final/fpoint.h"
 #include "final/fsize.h"
 #include "final/fstatusbar.h"
@@ -833,8 +833,8 @@ inline FLineEdit::offsetPair FLineEdit::endPosToOffset (std::size_t pos)
     }
     catch (const std::out_of_range& ex)
     {
-      *FApplication::getLog() << FLog::Error
-          << "Out of Range error: " << ex.what() << std::endl;
+      std::clog << FLog::Error
+                << "Out of Range error: " << ex.what() << std::endl;
     }
 
     if ( input_width >= char_width )
@@ -857,8 +857,8 @@ inline FLineEdit::offsetPair FLineEdit::endPosToOffset (std::size_t pos)
         }
         catch (const std::out_of_range& ex)
         {
-          *FApplication::getLog() << FLog::Error
-              << "Out of Range error: " << ex.what() << std::endl;
+          std::clog << FLog::Error
+                    << "Out of Range error: " << ex.what() << std::endl;
         }
       }
 
@@ -893,8 +893,8 @@ std::size_t FLineEdit::clickPosToCursorPos (std::size_t pos)
     }
     catch (const std::out_of_range& ex)
     {
-      *FApplication::getLog() << FLog::Error
-          << "Out of Range error: " << ex.what() << std::endl;
+      std::clog << FLog::Error
+                << "Out of Range error: " << ex.what() << std::endl;
     }
 
     idx++;
@@ -927,8 +927,8 @@ void FLineEdit::adjustTextOffset()
     }
     catch (const std::out_of_range& ex)
     {
-      *FApplication::getLog() << FLog::Error
-          << "Out of Range error: " << ex.what() << std::endl;
+      std::clog << FLog::Error
+                << "Out of Range error: " << ex.what() << std::endl;
     }
   }
 
@@ -940,8 +940,8 @@ void FLineEdit::adjustTextOffset()
     }
     catch (const std::out_of_range& ex)
     {
-      *FApplication::getLog() << FLog::Error
-          << "Out of Range error: " << ex.what() << std::endl;
+      std::clog << FLog::Error
+                << "Out of Range error: " << ex.what() << std::endl;
     }
   }
 
diff --git a/src/fmenu.cpp b/src/fmenu.cpp
index bc05b82f..3464a8b7 100644
--- a/src/fmenu.cpp
+++ b/src/fmenu.cpp
@@ -136,11 +136,8 @@ void FMenu::onKeyPress (FKeyEvent* ev)
   // looking for menu bar hotkey
   auto menu_bar = getMenuBar();
 
-  if ( menu_bar )
-  {
-    if ( menu_bar->hotkeyMenu(ev) )
-      return;
-  }
+  if ( menu_bar && menu_bar->hotkeyMenu(ev) )
+    return;
 
   switch ( ev->key() )
   {
diff --git a/src/foptimove.cpp b/src/foptimove.cpp
index 6f815346..5d87b8fb 100644
--- a/src/foptimove.cpp
+++ b/src/foptimove.cpp
@@ -24,7 +24,6 @@
 
 #include "final/fapplication.h"
 #include "final/fc.h"
-#include "final/flog.h"
 #include "final/foptimove.h"
 #include "final/ftermcap.h"
 
@@ -1107,43 +1106,42 @@ void FOptiMove::moveByMethod ( int method
 //----------------------------------------------------------------------
 void printDurations (const FOptiMove& om)
 {
-  finalcut::FLog& log = *FApplication::getLog();
-  log << "            speed: "
-      << om.baudrate << " baud" << std::flush;
-  log << "    char_duration: "
-      << om.char_duration << " ms" << std::flush;
-  log << "      cursor_home: "
-      << om.F_cursor_home.duration << " ms" << std::flush;
-  log << "     cursor_to_ll: "
-      << om.F_cursor_to_ll.duration << " ms" << std::flush;
-  log << "  carriage_return: "
-      << om.F_carriage_return.duration << " ms" << std::flush;
-  log << "              tab: "
-      << om.F_tab.duration << " ms" << std::flush;
-  log << "         back_tab: "
-      << om.F_back_tab.duration << " ms" << std::flush;
-  log << "        cursor_up: "
-      << om.F_cursor_up.duration << " ms" << std::flush;
-  log << "      cursor_down: "
-      << om.F_cursor_down.duration << " ms" << std::flush;
-  log << "      cursor_left: "
-      << om.F_cursor_left.duration << " ms" << std::flush;
-  log << "     cursor_right: "
-      << om.F_cursor_right.duration << " ms" << std::flush;
-  log << "   cursor_address: "
-      << om.F_cursor_address.duration << " ms" << std::flush;
-  log << "   column_address: "
-      << om.F_column_address.duration << " ms" << std::flush;
-  log << "      row_address: "
-      << om.F_row_address.duration << " ms" << std::flush;
-  log << "   parm_up_cursor: "
-      << om.F_parm_up_cursor.duration << " ms" << std::flush;
-  log << " parm_down_cursor: "
-      << om.F_parm_down_cursor.duration << " ms" << std::flush;
-  log << " parm_left_cursor: "
-      << om.F_parm_left_cursor.duration << " ms" << std::flush;
-  log << "parm_right_cursor: "
-      << om.F_parm_right_cursor.duration << " ms" << std::flush;
+  std::clog << "            speed: "
+            << om.baudrate << " baud" << std::flush;
+  std::clog << "    char_duration: "
+            << om.char_duration << " ms" << std::flush;
+  std::clog << "      cursor_home: "
+            << om.F_cursor_home.duration << " ms" << std::flush;
+  std::clog << "     cursor_to_ll: "
+            << om.F_cursor_to_ll.duration << " ms" << std::flush;
+  std::clog << "  carriage_return: "
+            << om.F_carriage_return.duration << " ms" << std::flush;
+  std::clog << "              tab: "
+            << om.F_tab.duration << " ms" << std::flush;
+  std::clog << "         back_tab: "
+            << om.F_back_tab.duration << " ms" << std::flush;
+  std::clog << "        cursor_up: "
+            << om.F_cursor_up.duration << " ms" << std::flush;
+  std::clog << "      cursor_down: "
+            << om.F_cursor_down.duration << " ms" << std::flush;
+  std::clog << "      cursor_left: "
+            << om.F_cursor_left.duration << " ms" << std::flush;
+  std::clog << "     cursor_right: "
+            << om.F_cursor_right.duration << " ms" << std::flush;
+  std::clog << "   cursor_address: "
+            << om.F_cursor_address.duration << " ms" << std::flush;
+  std::clog << "   column_address: "
+            << om.F_column_address.duration << " ms" << std::flush;
+  std::clog << "      row_address: "
+            << om.F_row_address.duration << " ms" << std::flush;
+  std::clog << "   parm_up_cursor: "
+            << om.F_parm_up_cursor.duration << " ms" << std::flush;
+  std::clog << " parm_down_cursor: "
+            << om.F_parm_down_cursor.duration << " ms" << std::flush;
+  std::clog << " parm_left_cursor: "
+            << om.F_parm_left_cursor.duration << " ms" << std::flush;
+  std::clog << "parm_right_cursor: "
+            << om.F_parm_right_cursor.duration << " ms" << std::flush;
 }
 
 }  // namespace finalcut
diff --git a/src/fterm.cpp b/src/fterm.cpp
index f896f6f3..430f66bf 100644
--- a/src/fterm.cpp
+++ b/src/fterm.cpp
@@ -1191,7 +1191,7 @@ wchar_t FTerm::charEncode (wchar_t c, fc::encoding enc)
 {
   wchar_t ch_enc = c;
 
-  for (std::size_t i{0}; i <= fc::lastCharItem; i++)
+  for (std::size_t i{0}; i <= fc::last_char_item; i++)
   {
     if ( fc::character[i][fc::UTF8] == uInt(c) )
     {
@@ -1421,7 +1421,7 @@ void FTerm::init_alt_charset()
   };
 
   // Update array 'character' with discovered VT100 pairs
-  for (std::size_t n{0}; n <= fc::lastKeyItem; n++ )
+  for (std::size_t n{0}; n <= fc::last_key_item; n++ )
   {
     const uChar keyChar = uChar(fc::vt100_key_to_utf8[n][vt100_key]);
     const uChar altChar = uChar(vt100_alt_char[keyChar]);
@@ -1429,9 +1429,9 @@ void FTerm::init_alt_charset()
     const fc::encoding num{fc::NUM_OF_ENCODINGS};
 
     uInt* p = std::find ( fc::character[0]
-                        , fc::character[fc::lastCharItem] + num
+                        , fc::character[fc::last_char_item] + num
                         , utf8char );
-    if ( p != fc::character[fc::lastCharItem] + num )  // found in character
+    if ( p != fc::character[fc::last_char_item] + num )  // found in character
     {
       const int item = int(std::distance(fc::character[0], p) / num);
 
@@ -1506,7 +1506,7 @@ void FTerm::init_cygwin_charmap()
     return;
 
   // PC encoding changes
-  for (std::size_t i{0}; i <= fc::lastCharItem; i++ )
+  for (std::size_t i{0}; i <= fc::last_char_item; i++ )
   {
     if ( fc::character[i][fc::UTF8] == fc::BlackUpPointingTriangle )  // ▲
       fc::character[i][fc::PC] = 0x18;
@@ -1560,7 +1560,7 @@ void FTerm::init_teraterm_charmap()
   if ( ! isTeraTerm() )
     return;
 
-  for (std::size_t i{0}; i <= fc::lastCharItem; i++ )
+  for (std::size_t i{0}; i <= fc::last_char_item; i++ )
     if ( fc::character[i][fc::PC] < 0x20 )
       fc::character[i][fc::PC] = fc::character[i][fc::ASCII];
 }
diff --git a/src/fterm_functions.cpp b/src/fterm_functions.cpp
index 6f838725..19699705 100644
--- a/src/fterm_functions.cpp
+++ b/src/fterm_functions.cpp
@@ -274,7 +274,7 @@ wchar_t cp437_to_unicode (uChar c)
   constexpr std::size_t UNICODE = 1;
   wchar_t ucs = c;
 
-  for (std::size_t i{0}; i <= fc::lastCP437Item; i++)
+  for (std::size_t i{0}; i <= fc::last_cp437_item; i++)
   {
     if ( fc::cp437_ucs[i][CP437] == c )  // found
     {
@@ -293,7 +293,7 @@ uChar unicode_to_cp437 (wchar_t ucs)
   constexpr std::size_t UNICODE = 1;
   uChar c{'?'};
 
-  for (std::size_t i{0}; i <= fc::lastCP437Item; i++)
+  for (std::size_t i{0}; i <= fc::last_cp437_item; i++)
   {
     if ( fc::cp437_ucs[i][UNICODE] == ucs )  // found
     {
@@ -322,10 +322,10 @@ const FString getFullWidth (const FString& str)
     }
     else
     {
-      for (std::size_t i{0}; i <= fc::lastHalfWidthItem; i++)
+      for (std::size_t i{0}; i <= fc::last_halfwidth_item; i++)
       {
-        if ( fc::halfWidth_fullWidth[i][HALF] == c )  // found
-          c = fc::halfWidth_fullWidth[i][FULL];
+        if ( fc::halfwidth_fullwidth[i][HALF] == c )  // found
+          c = fc::halfwidth_fullwidth[i][FULL];
       }
     }
   }
@@ -350,10 +350,10 @@ const FString getHalfWidth (const FString& str)
     }
     else
     {
-      for (std::size_t i{0}; i <= fc::lastHalfWidthItem; i++)
+      for (std::size_t i{0}; i <= fc::last_halfwidth_item; i++)
       {
-        if ( fc::halfWidth_fullWidth[i][FULL] == c )  // found
-          c = fc::halfWidth_fullWidth[i][HALF];
+        if ( fc::halfwidth_fullwidth[i][FULL] == c )  // found
+          c = fc::halfwidth_fullwidth[i][HALF];
       }
     }
   }
@@ -457,8 +457,8 @@ std::size_t getColumnWidth (const FString& s, std::size_t pos)
     }
     catch (const std::out_of_range& ex)
     {
-      *FApplication::getLog() << FLog::Error
-          << "Out of Range error: " << ex.what() << std::endl;
+      std::clog << FLog::Error
+                << "Out of Range error: " << ex.what() << std::endl;
     }
   }
 
diff --git a/src/ftermcap.cpp b/src/ftermcap.cpp
index 8c695bc1..37e014f0 100644
--- a/src/ftermcap.cpp
+++ b/src/ftermcap.cpp
@@ -27,6 +27,7 @@
 #include "final/emptyfstring.h"
 #include "final/fc.h"
 #include "final/fkey_map.h"
+#include "final/flog.h"
 #include "final/fsystem.h"
 #include "final/fterm.h"
 #include "final/ftermdata.h"
@@ -127,23 +128,22 @@ void FTermcap::termcapError (int status)
   static constexpr int no_entry = 0;
   static constexpr int db_not_found = -1;
   static constexpr int uninitialized = -2;
-  finalcut::FLog& log = *FApplication::getLog();
 
   if ( status == no_entry || status == uninitialized )
   {
     const char* termtype = fterm_data->getTermType();
-    log << FLog::Error
-        << "Unknown terminal: \""  << termtype << "\". "
-        << "Check the TERM environment variable. "
-        << "Also make sure that the terminal "
-        << "is defined in the termcap/terminfo database."
-        << std::endl;
+    std::clog << FLog::Error
+              << "Unknown terminal: \""  << termtype << "\". "
+              << "Check the TERM environment variable. "
+              << "Also make sure that the terminal "
+              << "is defined in the termcap/terminfo database."
+              << std::endl;
     std::abort();
   }
   else if ( status == db_not_found )
   {
-    log << "The termcap/terminfo database could not be found."
-        << std::endl;
+    std::clog << "The termcap/terminfo database could not be found."
+              << std::endl;
     std::abort();
   }
 }
diff --git a/src/ftermfreebsd.cpp b/src/ftermfreebsd.cpp
index 69edb8a9..6c4eb50e 100644
--- a/src/ftermfreebsd.cpp
+++ b/src/ftermfreebsd.cpp
@@ -171,7 +171,7 @@ void FTermFreeBSD::initCharMap()
   if ( ! isFreeBSDConsole() )
     return;
 
-  for (std::size_t i{0}; i <= fc::lastCharItem; i++)
+  for (std::size_t i{0}; i <= fc::last_char_item; i++)
     if ( fc::character[i][fc::PC] < 0x1c )
       fc::character[i][fc::PC] = fc::character[i][fc::ASCII];
 }
@@ -195,11 +195,11 @@ void FTermFreeBSD::finish()
 //----------------------------------------------------------------------
 void FTermFreeBSD::warnNotInitialized()
 {
-  *FApplication::getLog() << FLog::Warn
-                          << "The FTermFreeBSD object has "
-                          << "not yet been initialized! "
-                          << "Please call the init() method first."
-                          << std::endl;
+  std::clog << FLog::Warn
+            << "The FTermFreeBSD object has "
+            << "not yet been initialized! "
+            << "Please call the init() method first."
+            << std::endl;
 }
 
 //----------------------------------------------------------------------
diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp
index 046de52b..5a775168 100644
--- a/src/ftermlinux.cpp
+++ b/src/ftermlinux.cpp
@@ -202,7 +202,7 @@ void FTermLinux::init()
   }
   else
   {
-    FApplication::getLog()->error("Can not open the console.");
+    std::clog << FLog::Error << "Can not open the console." << std::endl;
     std::abort();
   }
 }
@@ -217,7 +217,7 @@ void FTermLinux::initCharMap()
 
   if ( screen_unicode_map.entry_ct > 0 && screen_unicode_map.entries )
   {
-    for (std::size_t i{0}; i <= fc::lastCharItem; i++ )
+    for (std::size_t i{0}; i <= fc::last_char_item; i++ )
     {
       const auto ucs = wchar_t(fc::character[i][fc::UTF8]);
       const sInt16 fontpos = getFontPos(ucs);
diff --git a/src/ftermopenbsd.cpp b/src/ftermopenbsd.cpp
index 8d12b856..6b789543 100644
--- a/src/ftermopenbsd.cpp
+++ b/src/ftermopenbsd.cpp
@@ -162,11 +162,11 @@ bool FTermOpenBSD::resetBeep()
 //----------------------------------------------------------------------
 void FTermOpenBSD::warnNotInitialized()
 {
-  *FApplication::getLog() << FLog::Warn
-                          << "The FTermOpenBSD object has "
-                          << "not yet been initialized! "
-                          << "Please call the init() method first."
-                          << std::endl;
+  std::clog << FLog::Warn
+            << "The FTermOpenBSD object has "
+            << "not yet been initialized! "
+            << "Please call the init() method first."
+            << std::endl;
 }
 
 //----------------------------------------------------------------------
diff --git a/src/ftermxterminal.cpp b/src/ftermxterminal.cpp
index 9c19ee5d..fe41dc2e 100644
--- a/src/ftermxterminal.cpp
+++ b/src/ftermxterminal.cpp
@@ -311,11 +311,11 @@ void FTermXTerminal::captureFontAndTitle()
 //----------------------------------------------------------------------
 void FTermXTerminal::warnNotInitialized() const
 {
-  *FApplication::getLog() << FLog::Warn
-                          << "The FTermXTerminal object has "
-                          << "not yet been initialized! "
-                          << "Please call the init() method first."
-                          << std::endl;
+  std::clog << FLog::Warn
+            << "The FTermXTerminal object has "
+            << "not yet been initialized! "
+            << "Please call the init() method first."
+            << std::endl;
 }
 
 //----------------------------------------------------------------------
diff --git a/src/include/final/emptyfstring.h b/src/include/final/emptyfstring.h
index b11cf9f8..27123bf6 100644
--- a/src/include/final/emptyfstring.h
+++ b/src/include/final/emptyfstring.h
@@ -35,7 +35,8 @@
   #error "Only  can be included directly."
 #endif
 
-#include "final/fapplication.h"
+#include 
+
 #include "final/flog.h"
 #include "final/fstring.h"
 
diff --git a/src/include/final/fapplication.h b/src/include/final/fapplication.h
index db7efbdb..5f3117c2 100644
--- a/src/include/final/fapplication.h
+++ b/src/include/final/fapplication.h
@@ -207,6 +207,7 @@ class FApplication : public FWidget
     char**                app_argv{};
     uInt64                key_timeout{100000};        // 100 ms
     uInt64                dblclick_interval{500000};  // 500 ms
+    std::streambuf*       default_clog_rdbuf{std::clog.rdbuf()};
     FEventQueue           event_queue{};
     static uInt64         next_event_wait;
     static timeval        time_last_event;
diff --git a/src/include/final/fcharmap.h b/src/include/final/fcharmap.h
index 02caf1c2..79571fcd 100644
--- a/src/include/final/fcharmap.h
+++ b/src/include/final/fcharmap.h
@@ -37,16 +37,16 @@ namespace fc
 {
 
 extern uInt character[][fc::NUM_OF_ENCODINGS];
-extern const std::size_t lastCharItem;
+extern const std::size_t last_char_item;
 
 extern const int vt100_key_to_utf8[][2];
-extern const std::size_t lastKeyItem;
+extern const std::size_t last_key_item;
 
 extern const wchar_t cp437_ucs[][2];
-extern const std::size_t lastCP437Item;
+extern const std::size_t last_cp437_item;
 
-extern const wchar_t halfWidth_fullWidth[][2];
-extern const std::size_t lastHalfWidthItem;
+extern const wchar_t halfwidth_fullwidth[][2];
+extern const std::size_t last_halfwidth_item;
 
 }  // namespace fc
 
diff --git a/src/include/final/fdata.h b/src/include/final/fdata.h
index 91ed9984..64b3cd7f 100644
--- a/src/include/final/fdata.h
+++ b/src/include/final/fdata.h
@@ -57,9 +57,11 @@ class FData;  // Class forward declaration
 class FDataAccess
 {
   public:
+    // Constructor
+    FDataAccess();
+
     // Destructor
-    virtual ~FDataAccess()
-    { }
+    virtual ~FDataAccess();
 
     // Accessors
     virtual const FString getClassName() const
@@ -101,7 +103,31 @@ class FData : public FDataAccess
       , value_ref{value}
     { }
 
+    FData (const FData& d)  // Copy constructor
+      : value{d.value}
+      , value_ref{value}
+    { }
+
+    FData (FData&& d) noexcept  // Move constructor
+      : value{std::move(d.value)}
+      , value_ref{value}
+    { }
+
     // Overloaded operators
+    FData& operator = (const FData& d)  // Copy assignment operator (=)
+    {
+      value = d.value;
+      value_ref = value;
+      return *this;
+    }
+
+    FData& operator = (FData&& d) noexcept  // Move assignment operator (=)
+    {
+      value = std::move(d.value);
+      value_ref = value;
+      return *this;
+    }
+
     T operator () () const
     {
       return value_ref;
diff --git a/src/include/final/flog.h b/src/include/final/flog.h
index 20da08b3..5fafbc83 100644
--- a/src/include/final/flog.h
+++ b/src/include/final/flog.h
@@ -108,6 +108,9 @@ class FLog : public std::stringbuf
     LineEnding   end_of_line{CRLF};
     FLogPrint    current_log{std::bind(&FLog::info, this, std::placeholders::_1)};
     std::ostream stream{this};
+
+    // Friend Non-member operator functions
+    friend std::ostream& operator << (std::ostream&, LogLevel);
 };
 
 // FLog inline functions
diff --git a/src/include/final/ftypes.h b/src/include/final/ftypes.h
index 6aa4028a..bf2947ab 100644
--- a/src/include/final/ftypes.h
+++ b/src/include/final/ftypes.h
@@ -38,13 +38,13 @@
 
 #define null nullptr
 
-#define badAllocOutput(object_name)                            \
-    *FApplication::getLog() << FLog::Error                     \
-                            << __FILE__  << ":" << __LINE__    \
-                            << ": Not enough memory to alloc " \
-                            << (object_name)                   \
-                            << " in "                          \
-                            << __func__ << std::endl;
+#define badAllocOutput(object_name)              \
+    std::clog << FLog::Error                     \
+              << __FILE__  << ":" << __LINE__    \
+              << ": Not enough memory to alloc " \
+              << (object_name)                   \
+              << " in "                          \
+              << __func__ << std::endl;
 
 typedef unsigned char         uChar;
 typedef unsigned short        uShort;
diff --git a/src/include/final/fvterm.h b/src/include/final/fvterm.h
index c62004af..546463bb 100644
--- a/src/include/final/fvterm.h
+++ b/src/include/final/fvterm.h
@@ -579,9 +579,9 @@ inline FVTerm& FVTerm::operator << (const std::string& string)
 
 //----------------------------------------------------------------------
 inline FVTerm& FVTerm::operator << \
-    (const std::vector& termString)
+    (const std::vector& term_string)
 {
-  print (termString);
+  print (term_string);
   return *this;
 }
 
diff --git a/test/fdata-test.cpp b/test/fdata-test.cpp
index 206cdc14..555b2ab5 100644
--- a/test/fdata-test.cpp
+++ b/test/fdata-test.cpp
@@ -35,16 +35,17 @@
 //----------------------------------------------------------------------
 // functions
 //----------------------------------------------------------------------
-/*void cb_function_ptr (int* value)
+float my_function()
 {
-  (*value)++;
+  return 13.45F;
 }
 
 //----------------------------------------------------------------------
-void cb_function_ref (int& value)
+long int my_function2 (long int i)
 {
-  value += 2;
-}*/
+  return 2 * i;
+}
+
 
 //----------------------------------------------------------------------
 // class FDataTest
diff --git a/test/flogger-test.cpp b/test/flogger-test.cpp
index 21d91247..c3aee10c 100644
--- a/test/flogger-test.cpp
+++ b/test/flogger-test.cpp
@@ -316,6 +316,9 @@ void FLoggerTest::fileTest()
 //----------------------------------------------------------------------
 void FLoggerTest::applicationObjectTest()
 {
+  // Save the rdbuf of clog
+  std::streambuf* default_clog_rdbuf = std::clog.rdbuf();
+
   // Generation of a logger in a shared_ptr via a pointer
   finalcut::FApplication::setLog (std::make_shared());
   // Get the shared_ptr with the base class
@@ -348,6 +351,15 @@ void FLoggerTest::applicationObjectTest()
   CPPUNIT_ASSERT ( buf.str() == "[ERROR] test6\r\n" );
   buf.str("");  // Clear buffer
 
+  // Logging to std::clog
+  std::clog << finalcut::FLog::Info << "test7" << std::flush;
+  CPPUNIT_ASSERT ( buf.str() == "[INFO] test7\r\n" );
+  buf.str("");  // Clear buffer
+
+  std::clog << finalcut::FLog::Warn << "test8" << std::endl;
+  CPPUNIT_ASSERT ( buf.str() == "[WARNING] test8\n\r\n" );
+  buf.str("");  // Clear buffer
+
   // Replace the logger with another one
   finalcut::FApplication::setLog(std::make_shared());
   log = finalcut::FApplication::getLog();
@@ -369,8 +381,23 @@ void FLoggerTest::applicationObjectTest()
   CPPUNIT_ASSERT ( buf.str() == "Debug: myLogger 4\n" );
   buf.str("");  // Clear buffer
 
-  std::shared_ptr* logger = &(finalcut::FApplication::getLog());
-  delete logger;
+  // Logging to std::clog with the replaced logger
+  std::clog << finalcut::FLog::Info << "myLogger 5" << std::flush;
+  CPPUNIT_ASSERT ( buf.str() == " Info: myLogger 5\n" );
+  buf.str("");  // Clear buffer
+
+  std::clog << finalcut::FLog::Error << "myLogger 6" << std::endl;
+  CPPUNIT_ASSERT ( buf.str() == "Error: myLogger 6\n\n" );
+  buf.str("");  // Clear buffer
+
+  // Reset to the default rdbuf of clog
+  std::clog.rdbuf(default_clog_rdbuf);
+
+  // Delete the global FApplication logger object
+  auto logger = &(finalcut::FApplication::getLog());
+
+  if ( logger )
+    delete logger;
 }
 
 
diff --git a/test/ftermfreebsd-test.cpp b/test/ftermfreebsd-test.cpp
index a14a4f00..c5b51406 100644
--- a/test/ftermfreebsd-test.cpp
+++ b/test/ftermfreebsd-test.cpp
@@ -819,7 +819,7 @@ wchar_t ftermfreebsdTest::charEncode (wchar_t c)
 {
   wchar_t ch_enc{L'\0'};
 
-  for (std::size_t i{0}; i <= finalcut::fc::lastCharItem; i++)
+  for (std::size_t i{0}; i <= finalcut::fc::last_char_item; i++)
   {
     if ( finalcut::fc::character[i][finalcut::fc::UTF8] == uInt(c) )
     {

From b15a665729988acee3ed1f5a193096e26598f14d Mon Sep 17 00:00:00 2001
From: Markus Gans 
Date: Fri, 25 Sep 2020 06:16:32 +0200
Subject: [PATCH 07/30] unit test for the FData

---
 ChangeLog                 |   1 +
 examples/Makefile.clang   |   2 +-
 examples/Makefile.gcc     |   2 +-
 examples/event-log.cpp    |   5 +-
 src/Makefile.clang        |   2 +-
 src/Makefile.gcc          |   2 +-
 src/include/final/fdata.h |  10 ++-
 test/Makefile.am          |   3 +
 test/Makefile.clang       |   2 +-
 test/Makefile.gcc         |   2 +-
 test/fdata-test.cpp       | 148 ++++++++++++++++++++++++++++++++++++--
 11 files changed, 165 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 02f97c46..e45ce897 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 2020-09-25  Markus Gans  
 	* std::clog now streams everything to the FLogger object
+	* Added a unit test for the FData class
 
 2020-09-23  Markus Gans  
 	* Bugfix: empty FString() + wchar_t
diff --git a/examples/Makefile.clang b/examples/Makefile.clang
index 8f0825f7..7f1a5005 100644
--- a/examples/Makefile.clang
+++ b/examples/Makefile.clang
@@ -24,7 +24,7 @@ endif
 # $@ = name of the targets
 # $^ = all dependency (without double entries)
 .cpp:
-	$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o $@ $^
+	$(CXX) $^ -o $@ $(CCXFLAGS) $(INCLUDES) $(LDFLAGS)
 
 all: $(OBJS)
 
diff --git a/examples/Makefile.gcc b/examples/Makefile.gcc
index 072db0da..724b4c2d 100644
--- a/examples/Makefile.gcc
+++ b/examples/Makefile.gcc
@@ -24,7 +24,7 @@ endif
 # $@ = name of the targets
 # $^ = all dependency (without double entries)
 .cpp:
-	$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o $@ $^
+	$(CXX) $^ -o $@ $(CCXFLAGS) $(INCLUDES) $(LDFLAGS)
 
 all: $(OBJS)
 
diff --git a/examples/event-log.cpp b/examples/event-log.cpp
index a82db7fa..e3b2afa2 100644
--- a/examples/event-log.cpp
+++ b/examples/event-log.cpp
@@ -283,7 +283,10 @@ EventLog::EventLog (finalcut::FWidget* parent)
 
 //----------------------------------------------------------------------
 EventLog::~EventLog()  // destructor
-{ }
+{
+  if ( event_dialog )
+    delete event_dialog;
+}
 
 //----------------------------------------------------------------------
 void EventLog::onTimer (finalcut::FTimerEvent*)
diff --git a/src/Makefile.clang b/src/Makefile.clang
index fef6c695..b81d7c26 100644
--- a/src/Makefile.clang
+++ b/src/Makefile.clang
@@ -174,7 +174,7 @@ endif
 	$(CXX) -c $(CCXFLAGS) $(INCLUDES) -fpic -o $@ $<
 
 all: dep $(OBJS)
-	$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -shared -Wl,-soname,$(LIB).$(MAJOR) -o $(LIB).$(VERSION) $(OBJS)
+	$(CXX) $(OBJS) -o $(LIB).$(VERSION) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -shared -Wl,-soname,$(LIB).$(MAJOR)
 	ln -s -f $(LIB).$(VERSION) libfinal.so.$(MAJOR)
 	ln -s -f $(LIB).$(MAJOR) libfinal.so
 
diff --git a/src/Makefile.gcc b/src/Makefile.gcc
index 885996af..ebe8df58 100644
--- a/src/Makefile.gcc
+++ b/src/Makefile.gcc
@@ -174,7 +174,7 @@ endif
 	$(CXX) -c $(CCXFLAGS) $(INCLUDES) -fpic -o $@ $<
 
 all: dep $(OBJS)
-	$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -shared -Wl,-soname,$(LIB).$(MAJOR) -o $(LIB).$(VERSION) $(OBJS)
+	$(CXX) $(OBJS) -o $(LIB).$(VERSION) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -shared -Wl,-soname,$(LIB).$(MAJOR)
 	ln -s -f $(LIB).$(VERSION) libfinal.so.$(MAJOR)
 	ln -s -f $(LIB).$(MAJOR) libfinal.so
 
diff --git a/src/include/final/fdata.h b/src/include/final/fdata.h
index 64b3cd7f..e108dcfd 100644
--- a/src/include/final/fdata.h
+++ b/src/include/final/fdata.h
@@ -48,7 +48,7 @@ namespace finalcut
 {
 
 //----------------------------------------------------------------------
-// struct FDataAccess
+// class FDataAccess
 //----------------------------------------------------------------------
 
 template 
@@ -86,7 +86,7 @@ class FDataAccess
 
 
 //----------------------------------------------------------------------
-// struct FData
+// class FData
 //----------------------------------------------------------------------
 
 template 
@@ -103,6 +103,10 @@ class FData : public FDataAccess
       , value_ref{value}
     { }
 
+    // Destructor
+    ~FData() override
+    { }
+
     FData (const FData& d)  // Copy constructor
       : value{d.value}
       , value_ref{value}
@@ -170,7 +174,7 @@ class FData : public FDataAccess
     // Inquiries
     bool isInitializedCopy()
     {
-      return bool(value);
+      return bool( &value == &value_ref );
     }
 
     bool isInitializedReference()
diff --git a/test/Makefile.am b/test/Makefile.am
index 27420c4d..35396361 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -9,6 +9,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/include -Wall -Werror -std=c++11
 noinst_PROGRAMS = \
 	fobject_test \
 	fcallback_test \
+	fdata_test \
 	fmouse_test \
 	fkeyboard_test \
 	ftermdata_test \
@@ -30,6 +31,7 @@ noinst_PROGRAMS = \
 
 fobject_test_SOURCES = fobject-test.cpp
 fcallback_test_SOURCES = fcallback-test.cpp
+fdata_test_SOURCES = fdata-test.cpp
 fmouse_test_SOURCES = fmouse-test.cpp
 fkeyboard_test_SOURCES = fkeyboard-test.cpp
 ftermdata_test_SOURCES = ftermdata-test.cpp
@@ -51,6 +53,7 @@ frect_test_SOURCES = frect-test.cpp
 
 TESTS = fobject_test \
 	fcallback_test \
+	fdata_test \
 	fmouse_test \
 	fkeyboard_test \
 	ftermdata_test \
diff --git a/test/Makefile.clang b/test/Makefile.clang
index f4ae2e58..9d1817f7 100644
--- a/test/Makefile.clang
+++ b/test/Makefile.clang
@@ -26,7 +26,7 @@ endif
 # $@ = name of the targets
 # $^ = all dependency (without double entries)
 .cpp:
-	$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o $@ $^
+	$(CXX) $^ -o $@ $(CCXFLAGS) $(INCLUDES) $(LDFLAGS)
 
 all: $(OBJS)
 
diff --git a/test/Makefile.gcc b/test/Makefile.gcc
index a3cd0ed1..3df1bbd2 100644
--- a/test/Makefile.gcc
+++ b/test/Makefile.gcc
@@ -26,7 +26,7 @@ endif
 # $@ = name of the targets
 # $^ = all dependency (without double entries)
 .cpp:
-	$(CXX) $(CCXFLAGS) $(INCLUDES) $(LDFLAGS) -o $@ $^
+	$(CXX) $^ -o $@ $(CCXFLAGS) $(INCLUDES) $(LDFLAGS)
 
 all: $(OBJS)
 
diff --git a/test/fdata-test.cpp b/test/fdata-test.cpp
index 555b2ab5..858bc664 100644
--- a/test/fdata-test.cpp
+++ b/test/fdata-test.cpp
@@ -59,7 +59,8 @@ class FDataTest : public CPPUNIT_NS::TestFixture
 
   protected:
     void classNameTest();
-    void dataTest();
+    void fdataTest();
+    void makeFDataTest();
 
   private:
     // Adds code needed to register the test suite
@@ -67,7 +68,8 @@ class FDataTest : public CPPUNIT_NS::TestFixture
 
     // Add a methods to the test suite
     CPPUNIT_TEST (classNameTest);
-    CPPUNIT_TEST (dataTest);
+    CPPUNIT_TEST (fdataTest);
+    CPPUNIT_TEST (makeFDataTest);
 
     // End of test suite definition
     CPPUNIT_TEST_SUITE_END();
@@ -82,16 +84,154 @@ finalcut::FWidget FDataTest::root_widget{nullptr};
 //----------------------------------------------------------------------
 void FDataTest::classNameTest()
 {
-  const finalcut::FCallback d;
+  auto da = finalcut::FDataAccess();
+  const finalcut::FString& classname2 = da.getClassName();
+  CPPUNIT_ASSERT ( classname2 == "FDataAccess" );
+
+  auto d = finalcut::FData(nullptr);
   const finalcut::FString& classname = d.getClassName();
   CPPUNIT_ASSERT ( classname == "FData" );
 }
 
 //----------------------------------------------------------------------
-void FDataTest::dataTest()
+void FDataTest::fdataTest()
 {
+  // nummber
+  auto data1 = finalcut::FData(5);
+  CPPUNIT_ASSERT ( data1.isInitializedCopy() );
+  CPPUNIT_ASSERT ( ! data1.isInitializedReference() );
+  std::stringstream stream{};
+  stream << data1;
+  CPPUNIT_ASSERT ( stream.str() == "5" );
+  int i1{data1};
+  CPPUNIT_ASSERT ( i1 == 5 );
+  CPPUNIT_ASSERT ( data1() == 5 );
+  CPPUNIT_ASSERT ( data1.get() == 5 );
+  data1.get()++;
+  CPPUNIT_ASSERT ( data1.get() == 6 );
+  data1.set(3);
+  CPPUNIT_ASSERT ( data1.get() == 3 );
+  data1 << 8;
+  CPPUNIT_ASSERT ( data1.get() == 8 );
 
+  // int value
+  int integer_value = 10;
+  auto data2 = finalcut::FData(integer_value);
+  CPPUNIT_ASSERT ( ! data2.isInitializedCopy() );
+  CPPUNIT_ASSERT ( data2.isInitializedReference() );
+  stream.clear();
+  stream.str("");
+  stream << data2;
+  CPPUNIT_ASSERT ( stream.str() == "10" );
+  int i2{data2};
+  CPPUNIT_ASSERT ( i2 == 10 );
+  CPPUNIT_ASSERT ( data2() == 10 );
+  CPPUNIT_ASSERT ( data2.get() == 10 );
+  data2.get()--;
+  CPPUNIT_ASSERT ( data2.get() == 9 );
+  CPPUNIT_ASSERT ( integer_value == 9 );
+  data2.set(7);
+  CPPUNIT_ASSERT ( data2.get() == 7 );
+  CPPUNIT_ASSERT ( integer_value == 7 );
+  data2 << 15;
+  CPPUNIT_ASSERT ( integer_value == 15 );
+
+  // const int value
+  const int const_integer_value = 12;
+  auto data3 = finalcut::FData(const_integer_value);
+  CPPUNIT_ASSERT ( ! data3.isInitializedCopy() );
+  CPPUNIT_ASSERT ( data3.isInitializedReference() );
+  stream.clear();
+  stream.str("");
+  stream << data3;
+  CPPUNIT_ASSERT ( stream.str() == "12" );
+  int i3{data3};
+  CPPUNIT_ASSERT ( i3 == 12 );
+  CPPUNIT_ASSERT ( data3() == 12 );
+  CPPUNIT_ASSERT ( data3.get() == 12 );
+
+  // Function via pointer
+  auto data4 = finalcut::FData>(&my_function);
+  CPPUNIT_ASSERT ( data4.isInitializedCopy() );
+  CPPUNIT_ASSERT ( ! data4.isInitializedReference() );
+  stream.clear();
+  stream.str("");
+  stream << data4()();
+  CPPUNIT_ASSERT ( stream.str() == "13.45" );
+  CPPUNIT_ASSERT ( data4()() == 13.45F );
+  CPPUNIT_ASSERT ( data4.get()() == 13.45F );
+
+  // Function via reference -> remove reference + add pointer
+  auto data5 = finalcut::FData>(my_function);
+  CPPUNIT_ASSERT ( data5.isInitializedCopy() );
+  CPPUNIT_ASSERT ( ! data5.isInitializedReference() );
+  stream.clear();
+  stream.str("");
+  stream << data5()();
+  CPPUNIT_ASSERT ( stream.str() == "13.45" );
+  CPPUNIT_ASSERT ( data5()() == 13.45F );
+  CPPUNIT_ASSERT ( data5.get()() == 13.45F );
+
+  // Function with parameter via pointer
+  auto data6 = finalcut::FData>(&my_function2);
+  CPPUNIT_ASSERT ( data6.isInitializedCopy() );
+  CPPUNIT_ASSERT ( ! data6.isInitializedReference() );
+  stream.clear();
+  stream.str("");
+  stream << data6()(4L);
+  CPPUNIT_ASSERT ( stream.str() == "8" );
+  CPPUNIT_ASSERT ( data6()(4) == 8L );
+  CPPUNIT_ASSERT ( data6.get()(4) == 8L );
+
+  // std::string
+  auto data7 = finalcut::FData("123");
+  CPPUNIT_ASSERT ( data7.isInitializedCopy() );
+  CPPUNIT_ASSERT ( ! data7.isInitializedReference() );
+  stream.clear();
+  stream.str("");
+  stream << data7;
+  CPPUNIT_ASSERT ( stream.str() == "123" );
+  std::string str{data7};
+  CPPUNIT_ASSERT ( str == "123" );
+  CPPUNIT_ASSERT ( data7() == "123" );
+  CPPUNIT_ASSERT ( data7.get() == "123" );
+  data7.get() += "4";
+  CPPUNIT_ASSERT ( data7.get() == "1234" );
+  data7.set("abc");
+  CPPUNIT_ASSERT ( data7.get() == "abc" );
+  data7 << "xyz";
+  CPPUNIT_ASSERT ( data7.get() == "xyz" );
 }
+
+//----------------------------------------------------------------------
+void FDataTest::makeFDataTest()
+{
+  finalcut::FDataAccess* data_pointer{nullptr};
+
+  using ThreeInts = int[3];
+  ThreeInts int_array{2, 1, 4};
+  data_pointer = finalcut::makeFData(std::move(int_array));
+  const auto& ints = static_cast>&>(*data_pointer).get();
+  CPPUNIT_ASSERT ( ints[0] == 2 );
+  CPPUNIT_ASSERT ( ints[1] == 1 );
+  CPPUNIT_ASSERT ( ints[2] == 4 );
+
+  int n = 9;
+  data_pointer = finalcut::makeFData(std::move(n));
+  auto data = static_cast&&>(*data_pointer);
+  CPPUNIT_ASSERT ( data.isInitializedCopy() );
+  CPPUNIT_ASSERT ( ! data.isInitializedReference() );
+  auto& n2 = data.get();
+  CPPUNIT_ASSERT ( n2 == 9 );
+  n2++;
+  CPPUNIT_ASSERT ( n2 == 10 );
+  CPPUNIT_ASSERT ( data() == 10 );
+
+  data_pointer = finalcut::makeFData(std::move(my_function2));
+  const auto& func = static_cast>&>(*data_pointer).get();
+  CPPUNIT_ASSERT ( func(128) == 256 );
+}
+
 // Put the test suite in the registry
 CPPUNIT_TEST_SUITE_REGISTRATION (FDataTest);
 

From 4478948bc780f348dcbc0b7554f71c414c2f5f94 Mon Sep 17 00:00:00 2001
From: Markus Gans 
Date: Sat, 26 Sep 2020 01:59:58 +0200
Subject: [PATCH 08/30] FData improvements

---
 ChangeLog                 |   3 +
 src/include/final/fdata.h | 301 ++++++++++++++++++++------------------
 test/fdata-test.cpp       | 136 ++++++++++++++++-
 3 files changed, 292 insertions(+), 148 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e45ce897..dcc221d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2020-09-26  Markus Gans  
+	* FData improvements
+
 2020-09-25  Markus Gans  
 	* std::clog now streams everything to the FLogger object
 	* Added a unit test for the FData class
diff --git a/src/include/final/fdata.h b/src/include/final/fdata.h
index e108dcfd..f6b57f1a 100644
--- a/src/include/final/fdata.h
+++ b/src/include/final/fdata.h
@@ -47,154 +47,9 @@
 namespace finalcut
 {
 
-//----------------------------------------------------------------------
-// class FDataAccess
-//----------------------------------------------------------------------
-
 template 
 class FData;  // Class forward declaration
 
-class FDataAccess
-{
-  public:
-    // Constructor
-    FDataAccess();
-
-    // Destructor
-    virtual ~FDataAccess();
-
-    // Accessors
-    virtual const FString getClassName() const
-    {
-      return "FDataAccess";
-    }
-
-    template 
-    const T& get() const
-    {
-      return static_cast&>(*this).get();
-    }
-
-    // Mutator
-    template 
-    void set (const V& v)
-    {
-      static_cast&>(*this).set(v);
-    }
-};
-
-
-//----------------------------------------------------------------------
-// class FData
-//----------------------------------------------------------------------
-
-template 
-class FData : public FDataAccess
-{
-  public:
-    // Constructors
-    explicit FData (T& v)  // constructor
-      : value_ref{v}
-    { }
-
-    explicit FData (T&& v)  // constructor
-      : value{std::move(v)}
-      , value_ref{value}
-    { }
-
-    // Destructor
-    ~FData() override
-    { }
-
-    FData (const FData& d)  // Copy constructor
-      : value{d.value}
-      , value_ref{value}
-    { }
-
-    FData (FData&& d) noexcept  // Move constructor
-      : value{std::move(d.value)}
-      , value_ref{value}
-    { }
-
-    // Overloaded operators
-    FData& operator = (const FData& d)  // Copy assignment operator (=)
-    {
-      value = d.value;
-      value_ref = value;
-      return *this;
-    }
-
-    FData& operator = (FData&& d) noexcept  // Move assignment operator (=)
-    {
-      value = std::move(d.value);
-      value_ref = value;
-      return *this;
-    }
-
-    T operator () () const
-    {
-      return value_ref;
-    }
-
-    template 
-    T operator () (Args... args) const
-    {
-      return value_ref(args...);
-    }
-
-    explicit operator T () const
-    {
-      return value_ref;
-    }
-
-    FData& operator << (const T& v)
-    {
-      value_ref = v;
-      return *this;
-    }
-
-    // Accessors
-    const FString getClassName() const override
-    {
-      return "FData";
-    }
-
-    T& get()
-    {
-      return value_ref;
-    }
-
-    // Mutator
-    void set (const T& v)
-    {
-      value_ref = v;
-    }
-
-    // Inquiries
-    bool isInitializedCopy()
-    {
-      return bool( &value == &value_ref );
-    }
-
-    bool isInitializedReference()
-    {
-      return ! isInitializedCopy();
-    }
-
-    // Friend Non-member operator functions
-    friend std::ostream& operator << (std::ostream &os, const FData& data)
-    {
-      os << data.value_ref;
-      return os;
-    }
-
-  private:
-    // Data members
-    T value{};
-    T& value_ref;
-};
-
 // non-member functions
 //----------------------------------------------------------------------
 namespace internal
@@ -254,6 +109,162 @@ constexpr FData>* makeFData (T&& data)
   return new FData>(std::forward(data));
 }
 
+
+//----------------------------------------------------------------------
+// class FDataAccess
+//----------------------------------------------------------------------
+
+class FDataAccess
+{
+  public:
+    // Constructor
+    FDataAccess();
+
+    // Destructor
+    virtual ~FDataAccess();
+
+    // Accessors
+    virtual const FString getClassName() const
+    {
+      return "FDataAccess";
+    }
+
+    template
+    clean_fdata_t& get()
+    {
+      return static_cast>&>(*this).get();
+    }
+
+    // Mutator
+    template 
+    void set (V& data)
+    {
+      static_cast&>(*this).set(std::forward(data));
+    }
+};
+
+
+//----------------------------------------------------------------------
+// class FData
+//----------------------------------------------------------------------
+
+template 
+class FData : public FDataAccess
+{
+  public:
+    // Constructors
+    explicit FData (T& v)  // constructor
+      : value_ref{v}
+    { }
+
+    explicit FData (T&& v)  // constructor
+      : value{std::move(v)}
+      , value_ref{value}
+    { }
+
+    // Destructor
+    ~FData() override
+    { }
+
+    FData (const FData& d)  // Copy constructor
+      : value{d.value}
+      , value_ref{d.isInitializedCopy() ? std::ref(value) : d.value_ref}
+    { }
+
+    FData (FData&& d) noexcept  // Move constructor
+      : value{std::move(d.value)}
+      , value_ref{d.isInitializedCopy() ? std::ref(value) : std::move(d.value_ref)}
+    { }
+
+    // Overloaded operators
+    FData& operator = (const FData& d)  // Copy assignment operator (=)
+    {
+      if ( &d != this )
+      {
+        value = d.value;
+
+        if ( d.isInitializedCopy() )
+          value_ref = value;
+        else
+          value_ref = d.value_ref;
+      }
+
+      return *this;
+    }
+
+    FData& operator = (FData&& d) noexcept  // Move assignment operator (=)
+    {
+      if ( &d != this )
+      {
+        value = std::move(d.value);
+
+        if ( d.isInitializedCopy() )
+          value_ref = value;
+        else
+          value_ref = std::move(d.value_ref);
+      }
+
+      return *this;
+    }
+
+    T operator () () const
+    {
+      return value_ref;
+    }
+
+    explicit operator T () const
+    {
+      return value_ref;
+    }
+
+    FData& operator << (const T& v)
+    {
+      value_ref.get() = v;
+      return *this;
+    }
+
+    // Accessors
+    const FString getClassName() const override
+    {
+      return "FData";
+    }
+
+    T& get() const
+    {
+      return value_ref;
+    }
+
+    // Mutator
+    void set (const T& v)
+    {
+      value_ref.get() = v;
+    }
+
+    // Inquiries
+    bool isInitializedCopy() const
+    {
+      return bool( (void*)&value == (void*)&value_ref.get() );
+    }
+
+    bool isInitializedReference() const
+    {
+      return ! isInitializedCopy();
+    }
+
+    // Friend Non-member operator functions
+    friend std::ostream& operator << (std::ostream &os, const FData& data)
+    {
+      os << data.value_ref.get();
+      return os;
+    }
+
+  private:
+    // Data members
+    T value{};
+    std::reference_wrapper value_ref;
+};
+
 }  // namespace finalcut
 
 #endif  // FDATA_H
diff --git a/test/fdata-test.cpp b/test/fdata-test.cpp
index 858bc664..98e98ba0 100644
--- a/test/fdata-test.cpp
+++ b/test/fdata-test.cpp
@@ -46,6 +46,12 @@ long int my_function2 (long int i)
   return 2 * i;
 }
 
+//----------------------------------------------------------------------
+long int my_function3 (long int i)
+{
+  return 3 * i;
+}
+
 
 //----------------------------------------------------------------------
 // class FDataTest
@@ -60,6 +66,10 @@ class FDataTest : public CPPUNIT_NS::TestFixture
   protected:
     void classNameTest();
     void fdataTest();
+    void copyConstructorTest();
+    void moveConstructorTest();
+    void copyAssignmentTest();
+    void moveAssignmentTest();
     void makeFDataTest();
 
   private:
@@ -69,6 +79,10 @@ class FDataTest : public CPPUNIT_NS::TestFixture
     // Add a methods to the test suite
     CPPUNIT_TEST (classNameTest);
     CPPUNIT_TEST (fdataTest);
+    CPPUNIT_TEST (copyConstructorTest);
+    CPPUNIT_TEST (moveConstructorTest);
+    CPPUNIT_TEST (copyAssignmentTest);
+    CPPUNIT_TEST (moveAssignmentTest);
     CPPUNIT_TEST (makeFDataTest);
 
     // End of test suite definition
@@ -116,7 +130,7 @@ void FDataTest::fdataTest()
 
   // int value
   int integer_value = 10;
-  auto data2 = finalcut::FData(integer_value);
+  auto data2 = finalcut::FData(std::ref(integer_value));
   CPPUNIT_ASSERT ( ! data2.isInitializedCopy() );
   CPPUNIT_ASSERT ( data2.isInitializedReference() );
   stream.clear();
@@ -203,11 +217,117 @@ void FDataTest::fdataTest()
   CPPUNIT_ASSERT ( data7.get() == "xyz" );
 }
 
+//----------------------------------------------------------------------
+void FDataTest::copyConstructorTest()
+{
+  // value copy
+  auto data1 = finalcut::FData(2);
+  CPPUNIT_ASSERT ( data1.isInitializedCopy() );
+  CPPUNIT_ASSERT ( data1.get() == 2 );
+  auto data2 = finalcut::FData(data1);
+  CPPUNIT_ASSERT ( data2.isInitializedCopy() );
+  data1.get()++;
+  CPPUNIT_ASSERT ( data1.get() == 3 );
+  CPPUNIT_ASSERT ( data2.get() == 2 );
+
+  // reference copy
+  uInt n = 100;
+  auto data3 = finalcut::FData(n);
+  CPPUNIT_ASSERT ( data3.isInitializedReference() );
+  CPPUNIT_ASSERT ( data3.get() == 100 );
+  auto data4 = finalcut::FData(data3);
+  CPPUNIT_ASSERT ( data4.isInitializedReference() );
+  data3.get()--;
+  CPPUNIT_ASSERT ( data3.get() == 99 );
+  CPPUNIT_ASSERT ( data4.get() == 99 );
+}
+
+//----------------------------------------------------------------------
+void FDataTest::moveConstructorTest()
+{
+  // value copy
+  auto data1 = finalcut::FData(-5);
+  CPPUNIT_ASSERT ( data1.isInitializedCopy() );
+  CPPUNIT_ASSERT ( data1.get() == -5 );
+  auto data2 = finalcut::FData(std::move(data1));
+  CPPUNIT_ASSERT ( data2.isInitializedCopy() );
+  data1.get() += 10;
+  CPPUNIT_ASSERT ( data1.get() == 5 );
+  CPPUNIT_ASSERT ( data2.get() == -5 );
+
+  // reference copy
+  long int n = 0xfffffff;
+  auto data3 = finalcut::FData(n);
+  CPPUNIT_ASSERT ( data3.isInitializedReference() );
+  CPPUNIT_ASSERT ( data3.get() == 0xfffffff );
+  auto data4 = finalcut::FData(std::move(data3));
+  CPPUNIT_ASSERT ( data4.isInitializedReference() );
+  data3.get()++;
+  CPPUNIT_ASSERT ( data3.get() == 0x10000000 );
+  CPPUNIT_ASSERT ( data4.get() == 0x10000000 );
+}
+
+//----------------------------------------------------------------------
+void FDataTest::copyAssignmentTest()
+{
+  // value copy
+  auto data1 = finalcut::FData(123);
+  CPPUNIT_ASSERT ( data1.isInitializedCopy() );
+  CPPUNIT_ASSERT ( data1.get() == 123 );
+  finalcut::FData data2{0};
+  data2 = data1;
+  CPPUNIT_ASSERT ( data2.isInitializedCopy() );
+  data1.get() -= 100;
+  CPPUNIT_ASSERT ( data1.get() == 23 );
+  CPPUNIT_ASSERT ( data2.get() == 123 );
+
+  // reference copy
+  double c = 299792458.0;  // Speed of light
+  auto data3 = finalcut::FData(c);
+  CPPUNIT_ASSERT ( data3.isInitializedReference() );
+  CPPUNIT_ASSERT ( data3.get() == 299792458 );
+  finalcut::FData data4{0.0};
+  data4 = data3;
+  CPPUNIT_ASSERT ( data4.isInitializedReference() );
+  data4.get() -= 343.2;  // Speed of sound
+
+  CPPUNIT_ASSERT ( data3.get() == 299792114.8 );
+  CPPUNIT_ASSERT ( data4.get() == 299792114.8 );
+}
+
+//----------------------------------------------------------------------
+void FDataTest::moveAssignmentTest()
+{
+  // value copy
+  auto data1 = finalcut::FData(9.81F);
+  CPPUNIT_ASSERT ( data1.isInitializedCopy() );
+  CPPUNIT_ASSERT ( data1.get() == 9.81F );
+  finalcut::FData data2{0};
+  data2 = std::move(data1);
+  CPPUNIT_ASSERT ( data2.isInitializedCopy() );
+  data1.get() -= 0.81;
+  CPPUNIT_ASSERT ( data1.get() == 9.0F );
+  CPPUNIT_ASSERT ( data2.get() == 9.81F );
+
+  // reference copy
+  auto au = 149597870700LL;  // Astronomical unit
+  auto data3 = finalcut::FData(au);
+  CPPUNIT_ASSERT ( data3.isInitializedReference() );
+  CPPUNIT_ASSERT ( data3.get() == 149597870700LL );
+  finalcut::FData data4{0};
+  data4 = std::move(data3);
+  CPPUNIT_ASSERT ( data4.isInitializedReference() );
+  data4.get() /= 2LL;
+  CPPUNIT_ASSERT ( data3.get() == 74798935350LL );
+  CPPUNIT_ASSERT ( data4.get() == 74798935350LL );
+}
+
 //----------------------------------------------------------------------
 void FDataTest::makeFDataTest()
 {
   finalcut::FDataAccess* data_pointer{nullptr};
 
+  // Array
   using ThreeInts = int[3];
   ThreeInts int_array{2, 1, 4};
   data_pointer = finalcut::makeFData(std::move(int_array));
@@ -215,10 +335,12 @@ void FDataTest::makeFDataTest()
   CPPUNIT_ASSERT ( ints[0] == 2 );
   CPPUNIT_ASSERT ( ints[1] == 1 );
   CPPUNIT_ASSERT ( ints[2] == 4 );
+  delete data_pointer;
 
+  // Integer
   int n = 9;
   data_pointer = finalcut::makeFData(std::move(n));
-  auto data = static_cast&&>(*data_pointer);
+  auto& data = static_cast&>(*data_pointer);
   CPPUNIT_ASSERT ( data.isInitializedCopy() );
   CPPUNIT_ASSERT ( ! data.isInitializedReference() );
   auto& n2 = data.get();
@@ -226,10 +348,18 @@ void FDataTest::makeFDataTest()
   n2++;
   CPPUNIT_ASSERT ( n2 == 10 );
   CPPUNIT_ASSERT ( data() == 10 );
+  CPPUNIT_ASSERT ( data_pointer->get() == 10 );
+  //data_pointer->set(33);
+  //CPPUNIT_ASSERT ( data_pointer->get() == 33 );
+  delete data_pointer;
 
-  data_pointer = finalcut::makeFData(std::move(my_function2));
+  // Function
+  data_pointer = finalcut::makeFData(my_function2);
   const auto& func = static_cast>&>(*data_pointer).get();
   CPPUNIT_ASSERT ( func(128) == 256 );
+  //data_pointer->set(&my_function3);
+  //PUNIT_ASSERT ( func(128) == 384 );
+  delete data_pointer;
 }
 
 // Put the test suite in the registry

From c1a2ef59e40db583744dfca782a0f4dd4aae3456 Mon Sep 17 00:00:00 2001
From: Markus Gans 
Date: Sat, 26 Sep 2020 02:09:34 +0200
Subject: [PATCH 09/30] FData improvements

---
 src/include/final/fdata.h | 2 +-
 test/fdata-test.cpp       | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/include/final/fdata.h b/src/include/final/fdata.h
index f6b57f1a..a5aa27e5 100644
--- a/src/include/final/fdata.h
+++ b/src/include/final/fdata.h
@@ -138,7 +138,7 @@ class FDataAccess
     // Mutator
     template 
-    void set (V& data)
+    void set (V&& data)
     {
       static_cast&>(*this).set(std::forward(data));
     }
diff --git a/test/fdata-test.cpp b/test/fdata-test.cpp
index 98e98ba0..00691ba3 100644
--- a/test/fdata-test.cpp
+++ b/test/fdata-test.cpp
@@ -349,16 +349,16 @@ void FDataTest::makeFDataTest()
   CPPUNIT_ASSERT ( n2 == 10 );
   CPPUNIT_ASSERT ( data() == 10 );
   CPPUNIT_ASSERT ( data_pointer->get() == 10 );
-  //data_pointer->set(33);
-  //CPPUNIT_ASSERT ( data_pointer->get() == 33 );
+  data_pointer->set(33);
+  CPPUNIT_ASSERT ( data_pointer->get() == 33 );
   delete data_pointer;
 
   // Function
   data_pointer = finalcut::makeFData(my_function2);
   const auto& func = static_cast>&>(*data_pointer).get();
   CPPUNIT_ASSERT ( func(128) == 256 );
-  //data_pointer->set(&my_function3);
-  //PUNIT_ASSERT ( func(128) == 384 );
+  data_pointer->set(&my_function3);
+  CPPUNIT_ASSERT ( func(128) == 384 );
   delete data_pointer;
 }
 

From 72bcce87b79061b76f59e9fa61b09ec171a5d02c Mon Sep 17 00:00:00 2001
From: Markus Gans 
Date: Sat, 26 Sep 2020 19:06:49 +0200
Subject: [PATCH 10/30] Limit for the number of FObject child objects

---
 ChangeLog                   |  3 +++
 src/fapplication.cpp        |  3 +++
 src/fobject.cpp             |  6 +++--
 src/ftermlinux.cpp          |  2 +-
 src/include/final/fobject.h | 22 +++++++++++++---
 test/fobject-test.cpp       | 51 +++++++++++++++++++++++++------------
 6 files changed, 65 insertions(+), 22 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index dcc221d9..e0fd1576 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2020-09-26  Markus Gans  
 	* FData improvements
+	* The number of FObject children can now be limited with 
+	  setMaxChildren()
+	* FApplication can now have no more than one child widget
 
 2020-09-25  Markus Gans  
 	* std::clog now streams everything to the FLogger object
diff --git a/src/fapplication.cpp b/src/fapplication.cpp
index 3d1bfd75..cc0a2c7c 100644
--- a/src/fapplication.cpp
+++ b/src/fapplication.cpp
@@ -388,6 +388,9 @@ void FApplication::processExternalUserEvent()
 //----------------------------------------------------------------------
 void FApplication::init()
 {
+  // FApplication cannot have a second child widget
+  setMaxChildren(1);
+
   // Initialize the last event time
   time_last_event.tv_sec = 0;
   time_last_event.tv_usec = 0;
diff --git a/src/fobject.cpp b/src/fobject.cpp
index f10a8adc..fffaac9f 100644
--- a/src/fobject.cpp
+++ b/src/fobject.cpp
@@ -48,7 +48,6 @@ FObject::FObject (FObject* parent)
   if ( parent )                // add object to parent
   {
     parent->addChild(this);
-    has_parent = true;
   }
   else
   {
@@ -107,7 +106,7 @@ FObject* FObject::getChild (int index) const
   if ( ! hasChildren() )
     return nullptr;
 
-  if ( index <= 0 || index > numOfChildren() )
+  if ( index <= 0 || index > int(numOfChildren()) )
     return nullptr;
 
   auto iter = begin();
@@ -148,6 +147,9 @@ void FObject::addChild (FObject* obj)
   if ( ! obj )
     return;
 
+  if ( max_children != UNLIMITED && max_children <= numOfChildren() )
+    throw std::length_error ("max. child objects reached");
+
   if ( obj->parent_obj )
     obj->parent_obj->delChild(obj);
 
diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp
index 5a775168..58478eee 100644
--- a/src/ftermlinux.cpp
+++ b/src/ftermlinux.cpp
@@ -698,7 +698,7 @@ int FTermLinux::setScreenFont ( const uChar fontdata[], uInt count
     }
 
     for (std::size_t i{0}; i < count; i++)
-      std::memcpy ( const_cast(font.data + bytes_per_line * 32 * i)
+      std::memcpy ( font.data + bytes_per_line * 32 * i
                   , &fontdata[i * font.height]
                   , font.height);
   }
diff --git a/src/include/final/fobject.h b/src/include/final/fobject.h
index e4456bb8..0a7217ae 100644
--- a/src/include/final/fobject.h
+++ b/src/include/final/fobject.h
@@ -78,6 +78,9 @@ class FObject
     typedef FObjectList::iterator       iterator;
     typedef FObjectList::const_iterator const_iterator;
 
+    // Constants
+    static constexpr std::size_t UNLIMITED = static_cast(-1);
+
     // Constructor
     explicit FObject (FObject* = nullptr);
 
@@ -96,12 +99,16 @@ class FObject
     FObject*              getChild (int) const;
     FObjectList&          getChildren();
     const FObjectList&    getChildren() const;
-    int                   numOfChildren() const;
+    std::size_t           getMaxChildren() const;
+    std::size_t           numOfChildren() const;
     iterator              begin();
     iterator              end();
     const_iterator        begin() const;
     const_iterator        end() const;
 
+    // Mutator
+    void                  setMaxChildren (std::size_t);
+
     // Inquiries
     bool                  hasParent() const;
     bool                  hasChildren() const;
@@ -160,6 +167,7 @@ class FObject
     // Data members
     FObject*              parent_obj{nullptr};
     FObjectList           children_list{};  // no children yet
+    std::size_t           max_children{UNLIMITED};
     bool                  has_parent{false};
     bool                  widget_object{false};
     static bool           timer_modify_lock;
@@ -184,8 +192,12 @@ inline const FObject::FObjectList& FObject::getChildren() const
 { return children_list; }
 
 //----------------------------------------------------------------------
-inline int FObject::numOfChildren() const
-{ return int(children_list.size()); }
+inline std::size_t FObject::getMaxChildren() const
+{ return max_children; }
+
+//----------------------------------------------------------------------
+inline std::size_t FObject::numOfChildren() const
+{ return children_list.size(); }
 
 //----------------------------------------------------------------------
 inline FObject::iterator FObject::begin()
@@ -203,6 +215,10 @@ inline FObject::const_iterator FObject::begin() const
 inline FObject::const_iterator FObject::end() const
 { return children_list.end(); }
 
+//----------------------------------------------------------------------
+inline void FObject::setMaxChildren (std::size_t max)
+{ max_children = max; }
+
 //----------------------------------------------------------------------
 inline bool FObject::hasParent() const
 { return has_parent; }
diff --git a/test/fobject-test.cpp b/test/fobject-test.cpp
index 60d48637..da3da803 100644
--- a/test/fobject-test.cpp
+++ b/test/fobject-test.cpp
@@ -376,38 +376,57 @@ void FObjectTest::addTest()
 {
   // obj -> child
 
-  auto obj =  new finalcut::FObject();
+  auto obj1 =  new finalcut::FObject();
   auto child = new finalcut::FObject();
 
-  CPPUNIT_ASSERT ( ! obj->hasChildren() );
-  CPPUNIT_ASSERT ( obj->numOfChildren() == 0 );
-  CPPUNIT_ASSERT ( ! obj->isChild(child) );
+  CPPUNIT_ASSERT ( ! obj1->hasChildren() );
+  CPPUNIT_ASSERT ( obj1->numOfChildren() == 0 );
+  CPPUNIT_ASSERT ( ! obj1->isChild(child) );
 
   CPPUNIT_ASSERT ( ! child->hasParent() );
-  CPPUNIT_ASSERT ( child->getParent() != obj );
+  CPPUNIT_ASSERT ( child->getParent() != obj1 );
 
-  obj->addChild(child);
-  CPPUNIT_ASSERT ( obj->hasChildren() );
-  CPPUNIT_ASSERT ( obj->numOfChildren() == 1 );
-  CPPUNIT_ASSERT ( obj->isChild(child) );
+  obj1->addChild(child);
+  CPPUNIT_ASSERT ( obj1->hasChildren() );
+  CPPUNIT_ASSERT ( obj1->numOfChildren() == 1 );
+  CPPUNIT_ASSERT ( obj1->isChild(child) );
 
   CPPUNIT_ASSERT ( child->hasParent() );
-  CPPUNIT_ASSERT ( child->getParent() == obj );
+  CPPUNIT_ASSERT ( child->getParent() == obj1 );
 
   // Switch of the parent by a second addChild
   auto obj2 = new finalcut::FObject();
   obj2->addChild(child);
   CPPUNIT_ASSERT ( child->hasParent() );
-  CPPUNIT_ASSERT ( ! obj->hasChildren() );
-  CPPUNIT_ASSERT ( obj->numOfChildren() == 0 );
-  CPPUNIT_ASSERT ( ! obj->isChild(child) );
-  CPPUNIT_ASSERT ( child->getParent() != obj );
+  CPPUNIT_ASSERT ( ! obj1->hasChildren() );
+  CPPUNIT_ASSERT ( obj1->numOfChildren() == 0 );
+  CPPUNIT_ASSERT ( ! obj1->isChild(child) );
+  CPPUNIT_ASSERT ( child->getParent() != obj1 );
   CPPUNIT_ASSERT ( obj2->hasChildren() );
   CPPUNIT_ASSERT ( obj2->numOfChildren() == 1 );
   CPPUNIT_ASSERT ( obj2->isChild(child) );
   CPPUNIT_ASSERT ( child->getParent() == obj2 );
 
-  delete obj;  // also deletes the child object
+  // Are the maximum number of child objects reached?
+  CPPUNIT_ASSERT ( obj2->getMaxChildren() == finalcut::FObject::UNLIMITED );
+  obj2->setMaxChildren(1);
+  CPPUNIT_ASSERT ( obj2->hasChildren() );
+  CPPUNIT_ASSERT ( obj2->getMaxChildren() == 1 );
+  CPPUNIT_ASSERT ( obj2->numOfChildren() == 1 );
+  auto child2 = new finalcut::FObject();
+  CPPUNIT_ASSERT ( ! child2->hasParent() );
+  CPPUNIT_ASSERT_THROW ( obj2->addChild(child2), std::length_error );
+  CPPUNIT_ASSERT ( obj2->numOfChildren() == 1 );
+  obj2->setMaxChildren(2);
+  CPPUNIT_ASSERT ( ! child2->hasParent() );
+  CPPUNIT_ASSERT ( obj2->getMaxChildren() == 2 );
+  obj2->addChild(child2);
+  CPPUNIT_ASSERT ( child2->hasParent() );
+  CPPUNIT_ASSERT ( obj2->hasChildren() );
+  CPPUNIT_ASSERT ( obj2->numOfChildren() == 2 );
+
+  delete obj1;
+  delete obj2;  // also deletes the child object
 }
 
 //----------------------------------------------------------------------
@@ -456,7 +475,7 @@ void FObjectTest::iteratorTest()
   finalcut::FObject::const_iterator c_iter, c_last;
   c_iter = obj->begin();
   c_last = obj->end();
-  int i = 0;
+  std::size_t i = 0;
 
   while ( c_iter != c_last )
   {

From 722be333df709de86182968a831eb79d13bef8ad Mon Sep 17 00:00:00 2001
From: Markus Gans 
Date: Sun, 27 Sep 2020 20:43:53 +0200
Subject: [PATCH 11/30] Additions to the documentation

---
 ChangeLog                     |   4 +
 doc/final-cut-widget tree.svg | 361 ++++++++++++++++++++++++++++++++++
 doc/first-steps.md            |  70 +++++--
 3 files changed, 422 insertions(+), 13 deletions(-)
 create mode 100644 doc/final-cut-widget tree.svg

diff --git a/ChangeLog b/ChangeLog
index e0fd1576..e9c1575f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2020-09-27  Markus Gans  
+	* An explanation of the widget tree was added to the document 
+	  of the first steps
+
 2020-09-26  Markus Gans  
 	* FData improvements
 	* The number of FObject children can now be limited with 
diff --git a/doc/final-cut-widget tree.svg b/doc/final-cut-widget tree.svg
new file mode 100644
index 00000000..e96d08d4
--- /dev/null
+++ b/doc/final-cut-widget tree.svg	
@@ -0,0 +1,361 @@
+
+
+  
+    
+      
+        image/svg+xml
+        
+        
+      
+    
+  
+  
+    
+      
+    
+    
+      
+    
+    
+      
+    
+    
+      
+    
+    
+      
+    
+    
+      
+    
+    
+      
+    
+  
+  
+    
+    
+  
+  
+    
+    
+      FApplication
+    
+  
+  
+    
+    
+      FDialog
+    
+  
+  
+    
+    
+      FDialog
+    
+  
+  
+    
+    
+      FLabel
+    
+  
+  
+    
+    
+      FButton
+    
+  
+  
+    etc.
+  
+  
+  
+  
+  
+  
+  
+    
+      Parent:
+    
+    
+      Child:
+    
+    
+      Subchild:
+    
+    
+      Sub-subchild:
+    
+  
+  
+    
+      Application widget (= 1)
+    
+    
+      Main widget (= 1)
+    
+    
+      Widget(s) of the main widget (≥ 0)
+    
+    
+      Widget(s) from the parent widget (≥ 0)
+    
+  
+
diff --git a/doc/first-steps.md b/doc/first-steps.md
index 1e1e376f..b7d5bf52 100644
--- a/doc/first-steps.md
+++ b/doc/first-steps.md
@@ -7,6 +7,8 @@ Table of Contents
 
 
 - [Basic functions](#basic-functions)
+- [Widgets](#widgets)
+- [Widget tree](#widget-tree)
 - [How to use the library](#how-to-use-the-library)
 - [Memory Management](#memory-management)
 - [Event Processing](#event-processing)
@@ -55,6 +57,48 @@ emulator. It uses various optimization methods to improve the drawing speed.
 
 
 
+Widgets
+-------
+
+FINAL CUT has many widgets. It offers buttons, input fields, menus, and 
+dialog boxes that cover the most common use cases. Widgets are visual 
+elements that are combined to create user interfaces. Own widgets can be 
+easily created by creating a derived class of `FWidget` or other existing 
+widgets. All widgets are instances of 
+[FWidget](https://codedocs.xyz/gansm/finalcut/classfinalcut_1_1FWidget.html) 
+or its subclasses.
+
+A widget can contain any number of child widgets. Child widgets are displayed 
+in the display area of the parent widget. Window widgets based on `FWindow` 
+have their own virtual display area and are independent of the parent widget.
+
+When a parent widget is disabled, hidden, or deleted, the same operation is 
+used recursively to all its child widgets. The base class `FObject` implements 
+the self-organized object tree behavior. For example, `addChild()` removes 
+the child ownership from an existing parent object before assigning it to 
+the new target. When a child becomes deleted, the parent-child relationship 
+causes its reference in the parent object to be removed. An explicit 
+`delChild()` is no longer required here.
+
+
+Widget tree
+-----------
+
+An `FApplication` widget is the top-level widget of an application. It is 
+unique and can not have a parent widget. The class `FApplication` manages 
+all settings and assigns keyboard and mouse input to the different widgets.
+
+
+ application structure +
Figure 2. Widget tree of a FINAL CUT application
+
+ +The main widget of a FINAL CUT application is the only object that +`FApplication` can have as a child. This main widget is usually a window +object that contains all sub-widgets of the application. A sub-widget can +also be another window. + + How to use the library ---------------------- @@ -82,7 +126,7 @@ int main (int argc, char* argv[]) ```
dialog.cpp -
Figure 2. A blank dialog
+
Figure 3. A blank dialog


@@ -229,7 +273,7 @@ int main (int argc, char* argv[]) ```
memory.cpp -
Figure 3. FObject manages its child objects
+
Figure 4. FObject manages its child objects


@@ -369,7 +413,7 @@ int main (int argc, char* argv[]) ```
timer.cpp -
Figure 4. FObject::onTimer event handler
+
Figure 5. FObject::onTimer event handler


@@ -482,7 +526,7 @@ int main (int argc, char* argv[]) ```
user-event.cpp -
Figure 5. User event generation
+
Figure 6. User event generation


@@ -753,7 +797,7 @@ int main (int argc, char* argv[]) ```
callback-function.cpp -
Figure 6. Button with a callback function
+
Figure 7. Button with a callback function


@@ -816,7 +860,7 @@ int main (int argc, char* argv[]) ```
callback-lambda.cpp -
Figure 7. Button with lambda expression callback.
+
Figure 8. Button with lambda expression callback.


@@ -875,7 +919,7 @@ int main (int argc, char* argv[]) ```
callback-method.cpp -
Figure 8. Button with a callback method
+
Figure 9. Button with a callback method


@@ -996,7 +1040,7 @@ int main (int argc, char* argv[]) ```
emit-signal.cpp -
Figure 9. Callbacks with custom signals
+
Figure 10. Callbacks with custom signals


@@ -1037,7 +1081,7 @@ If you want to ignore padding spaces, you must force this with the
widget coordinates -
Figure 10. Widget coordinates
+
Figure 11. Widget coordinates


@@ -1087,7 +1131,7 @@ methods.
widget lengths -
Figure 11. Width and height of a widget
+
Figure 12. Width and height of a widget


@@ -1140,7 +1184,7 @@ absolute geometry values as a `FRect` object, you can call the method
widget geometry -
Figure 12. Geometry of widgets
+
Figure 13. Geometry of widgets


@@ -1267,7 +1311,7 @@ int main (int argc, char* argv[]) ```
size-adjustment.cpp -
Figure 13. Dynamic layout
+
Figure 14. Dynamic layout


@@ -1395,7 +1439,7 @@ int main (int argc, char* argv[]) ```
scrollview.cpp -
Figure 14. Dialog with a scrolling viewport
+
Figure 15. Dialog with a scrolling viewport


From 61d88eb413e56c09e43d59ff8fd3e3887c97908c Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Tue, 29 Sep 2020 04:14:14 +0200 Subject: [PATCH 12/30] Move FChar comparison operators to ftypes.h --- doc/final-cut-widget tree.svg | 219 +++++++++++++++++++++------------- doc/first-steps.md | 3 +- src/include/final/foptiattr.h | 20 ---- src/include/final/ftypes.h | 19 +++ 4 files changed, 157 insertions(+), 104 deletions(-) diff --git a/doc/final-cut-widget tree.svg b/doc/final-cut-widget tree.svg index e96d08d4..2b911b0b 100644 --- a/doc/final-cut-widget tree.svg +++ b/doc/final-cut-widget tree.svg @@ -5,11 +5,39 @@ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" id="svg61" version="1.1" - width="189.15524mm" - viewBox="0 0 189.15524 79.081643" - height="79.081642mm"> + width="149.86537mm" + viewBox="0 0 149.86537 65.484895" + height="65.484894mm" + sodipodi:docname="final-cut-widget tree.svg" + inkscape:version="0.92.1 r15371"> + @@ -34,7 +62,8 @@ transform="matrix(-0.4,0,0,-0.4,-4,0)" style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1.00000003pt;stroke-opacity:1" d="M 0,0 5,-5 -12.5,0 5,5 Z" - id="path4659" /> + id="path4659" + inkscape:connector-curvature="0" /> + id="path4671" + inkscape:connector-curvature="0" /> + id="path4650" + inkscape:connector-curvature="0" /> + id="path4659-6" + inkscape:connector-curvature="0" /> + id="path4659-6-0" + inkscape:connector-curvature="0" /> + id="path4659-6-0-3" + inkscape:connector-curvature="0" /> + id="path4659-6-0-3-2" + inkscape:connector-curvature="0" /> + transform="matrix(0.82806766,0,0,0.82760652,18.811674,-210.24741)" + style="stroke-width:1.20796716"> + style="opacity:1;fill:#f9f9f9;fill-opacity:1;stroke:#000000;stroke-width:0.5110532;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" /> + style="font-weight:bold;font-size:4.93888903px;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0;word-spacing:0;writing-mode:lr-tb;text-anchor:middle;fill:#1a1a1a;stroke-width:0.51097012;stroke-opacity:0"> FApplication + id="tspan4512" + style="stroke-width:0.51097012">FApplication + transform="matrix(0.82806766,0,0,0.82760652,25.151866,-0.20330766)" + id="g4560" + style="stroke-width:1.20796716"> + style="opacity:1;fill:#f9f9f9;fill-opacity:1;stroke:#000000;stroke-width:0.51105309;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" /> + style="font-weight:bold;font-size:4.93888903px;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0;word-spacing:0;writing-mode:lr-tb;text-anchor:middle;fill:#1a1a1a;stroke-width:0.51097012;stroke-opacity:0"> FDialog + y="26.275915" + style="stroke-width:0.51097012">FDialog + transform="matrix(0.82806766,0,0,0.82760652,38.120716,15.124655)" + style="stroke-width:1.20796716"> + style="opacity:1;fill:#f9f9f9;fill-opacity:1;stroke:#000000;stroke-width:0.51105309;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" /> + style="font-weight:bold;font-size:4.93888903px;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0;word-spacing:0;writing-mode:lr-tb;text-anchor:middle;fill:#1a1a1a;stroke-width:0.51097012;stroke-opacity:0"> FDialog + y="26.275915" + style="stroke-width:0.51097012">FDialog + transform="matrix(0.82806766,0,0,0.82760652,12.006292,15.124655)" + style="stroke-width:1.20796716"> + style="opacity:1;fill:#f9f9f9;fill-opacity:1;stroke:#000000;stroke-width:0.51105309;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" /> + style="font-weight:bold;font-size:4.93888903px;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0;word-spacing:0;writing-mode:lr-tb;text-anchor:middle;fill:#1a1a1a;stroke-width:0.51097012;stroke-opacity:0"> FLabel + id="tspan4610" + style="stroke-width:0.51097012">FLabel + transform="matrix(0.82806766,0,0,0.82760652,25.151866,-0.20330766)" + id="g6273" + style="stroke-width:1.20796716"> + style="opacity:1;fill:#f9f9f9;fill-opacity:1;stroke:#000000;stroke-width:0.51105309;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" /> + style="font-weight:bold;font-size:4.93888903px;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0;word-spacing:0;writing-mode:lr-tb;text-anchor:middle;fill:#1a1a1a;stroke-width:0.51097012;stroke-opacity:0"> FButton + y="63.317585" + style="stroke-width:0.51097012">FButton + style="font-style:italic;font-weight:bold;font-size:4.08859491px;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0;word-spacing:0;writing-mode:lr-tb;text-anchor:middle;fill:#1a1a1a;stroke-width:0.42300001;stroke-opacity:0" + x="62.287796" + y="65.409096" + id="text47-6-3-6-5" + transform="scale(1.0002786,0.99972148)"> etc. + d="M 49.251306,9.2100164 V 14.9971" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.42306879;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#Arrow1Mend)" + inkscape:connector-curvature="0" /> + d="m 42.679299,24.537976 v 5.779196" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.42306873;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#Arrow1Mend-9)" + inkscape:connector-curvature="0" /> + d="m 55.736511,24.537898 v 5.779196" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.42306867;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#Arrow1Mend-9-7)" + inkscape:connector-curvature="0" /> + d="m 62.369882,39.865938 v 5.548839" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.42306867;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#Arrow1Mend-9-7-1)" + inkscape:connector-curvature="0" /> + d="m 62.369882,55.193909 v 5.548839" + style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.42306867;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#Arrow1Mend-9-7-1-7)" + inkscape:connector-curvature="0" /> + transform="matrix(0.82806766,0,0,0.82760652,25.151866,-0.20330766)" + id="level" + style="stroke-width:1.20796716"> Parent: Child: Subchild: Sub-subchild: + transform="matrix(0.82806766,0,0,0.82760652,107.7173,-0.20330766)" + style="stroke-width:1.20796716"> Application widget (= 1) Main widget (= 1) Widget(s) of the main widget (≥ 0) Widget(s) from the parent widget (≥ 0) diff --git a/doc/first-steps.md b/doc/first-steps.md index b7d5bf52..172a4e64 100644 --- a/doc/first-steps.md +++ b/doc/first-steps.md @@ -89,9 +89,10 @@ unique and can not have a parent widget. The class `FApplication` manages all settings and assigns keyboard and mouse input to the different widgets.
- application structure + widget tree
Figure 2. Widget tree of a FINAL CUT application
+

The main widget of a FINAL CUT application is the only object that `FApplication` can have as a child. This main widget is usually a window diff --git a/src/include/final/foptiattr.h b/src/include/final/foptiattr.h index d0aa7abf..76c4d37b 100644 --- a/src/include/final/foptiattr.h +++ b/src/include/final/foptiattr.h @@ -337,26 +337,6 @@ inline void FOptiAttr::setDefaultColorSupport() inline void FOptiAttr::unsetDefaultColorSupport() { ansi_default_color = false; } - -// FChar operator functions -//---------------------------------------------------------------------- -inline bool operator == ( const FChar& lhs, - const FChar& rhs ) -{ - return lhs.ch == rhs.ch - && lhs.fg_color == rhs.fg_color - && lhs.bg_color == rhs.bg_color - && lhs.attr.byte[0] == rhs.attr.byte[0] - && lhs.attr.byte[1] == rhs.attr.byte[1] - && lhs.attr.bit.fullwidth_padding \ - == rhs.attr.bit.fullwidth_padding; -} - -//---------------------------------------------------------------------- -inline bool operator != ( const FChar& lhs, - const FChar& rhs ) -{ return ! ( lhs == rhs ); } - } // namespace finalcut #endif // FOPTIATTR_H diff --git a/src/include/final/ftypes.h b/src/include/final/ftypes.h index bf2947ab..f4c65fc2 100644 --- a/src/include/final/ftypes.h +++ b/src/include/final/ftypes.h @@ -187,6 +187,25 @@ FKeyName; } // namespace fc +// FChar operator functions +//---------------------------------------------------------------------- +inline constexpr bool operator == (const FChar& lhs, const FChar& rhs) +{ + return lhs.ch == rhs.ch + && lhs.fg_color == rhs.fg_color + && lhs.bg_color == rhs.bg_color + && lhs.attr.byte[0] == rhs.attr.byte[0] + && lhs.attr.byte[1] == rhs.attr.byte[1] + && lhs.attr.bit.fullwidth_padding \ + == rhs.attr.bit.fullwidth_padding; +} + +//---------------------------------------------------------------------- +inline constexpr bool operator != (const FChar& lhs, const FChar& rhs) +{ + return ! ( lhs == rhs ); +} + } // namespace finalcut #endif // FTYPES_H From 9c1f6fb05a52dcab33554552a9302c7157bc68e1 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Fri, 2 Oct 2020 01:23:26 +0200 Subject: [PATCH 13/30] Create codeql-analysis.yml --- .github/workflows/codeql-analysis.yml | 71 +++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000..4c79fbdd --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,71 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +name: "CodeQL" + +on: + push: + branches: [master] + pull_request: + # The branches below must be a subset of the branches above + branches: [master] + schedule: + - cron: '0 7 * * 2' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + # Override automatic language detection by changing the below list + # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] + language: ['cpp'] + # Learn more... + # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + # We must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head. + fetch-depth: 2 + + # If this run was triggered by a pull request event, then checkout + # the head of the pull request instead of the merge commit. + - run: git checkout HEAD^2 + if: ${{ github.event_name == 'pull_request' }} + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 From b428db3d9c438ba8e62739cab3bee9bf9537d2c6 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Fri, 2 Oct 2020 01:31:49 +0200 Subject: [PATCH 14/30] Update codeql-analysis.yml --- .github/workflows/codeql-analysis.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 4c79fbdd..81f76659 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -51,11 +51,6 @@ jobs: # Prefix the list here with "+" to use these queries and those in the config file. # queries: ./path/to/local/query, your-org/your-repo/queries@main - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -63,9 +58,10 @@ jobs: # and modify them (or add more) to build your code if your project # uses a compiled language - #- run: | - # make bootstrap - # make release + - run: | + autoreconf -v --install --force + ./configure --prefix=/usr CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -pedantic" + make V=1 -j10 - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 From 31eb81d61250783d7dd3416012ca4846a526b22d Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Fri, 2 Oct 2020 01:51:52 +0200 Subject: [PATCH 15/30] Update codeql-analysis.yml --- .github/workflows/codeql-analysis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 81f76659..ad83a4f9 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -59,6 +59,8 @@ jobs: # uses a compiled language - run: | + apt-get update + apt-get install autoconf-archive autoreconf -v --install --force ./configure --prefix=/usr CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -pedantic" make V=1 -j10 From 021cd12d583211c79101c39a54a3ff9aade1ad39 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Fri, 2 Oct 2020 02:04:20 +0200 Subject: [PATCH 16/30] Update codeql-analysis.yml --- .github/workflows/codeql-analysis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index ad83a4f9..496581e5 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -59,7 +59,6 @@ jobs: # uses a compiled language - run: | - apt-get update apt-get install autoconf-archive autoreconf -v --install --force ./configure --prefix=/usr CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -pedantic" From dcc66b14dbd1c1667b106e9c5169bcd2b670074e Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Fri, 2 Oct 2020 02:23:00 +0200 Subject: [PATCH 17/30] Update codeql-analysis.yml --- .github/workflows/codeql-analysis.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 496581e5..72fd0efd 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -58,11 +58,17 @@ jobs: # and modify them (or add more) to build your code if your project # uses a compiled language - - run: | - apt-get install autoconf-archive - autoreconf -v --install --force - ./configure --prefix=/usr CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -pedantic" - make V=1 -j10 + - name: Build dependencies + run: apt-get install autoconf-archive + + - name: Create configure file + run: autoreconf -v --install --force + + - name: Create makefiles + run: ./configure --prefix=/usr CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -pedantic" + + - name: Build + run: make V=1 -j10 - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v1 From 61434b4d16b73feae5f84ff2892b97c657fe2b6d Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Fri, 2 Oct 2020 02:26:42 +0200 Subject: [PATCH 18/30] Update codeql-analysis.yml --- .github/workflows/codeql-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 72fd0efd..4b08a42d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -59,7 +59,7 @@ jobs: # uses a compiled language - name: Build dependencies - run: apt-get install autoconf-archive + run: sudo apt-get install autoconf-archive - name: Create configure file run: autoreconf -v --install --force From a821030333a6b5bf90987b81e666fc2d16eac8de Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 4 Oct 2020 00:59:21 +0200 Subject: [PATCH 19/30] Replaces some C-style arrays with std::array --- ChangeLog | 5 + doc/final-cut-widget tree.svg | 552 +++++------ doc/user-theme.md | 8 +- examples/7segment.cpp | 13 +- examples/background-color.cpp | 3 - examples/calculator.cpp | 29 +- examples/checklist.cpp | 39 +- examples/event-log.cpp | 4 +- examples/listview.cpp | 95 +- examples/mandelbrot.cpp | 4 +- examples/menu.cpp | 7 +- examples/mouse.cpp | 5 +- examples/opti-move.cpp | 15 +- examples/rotozoomer.cpp | 11 +- examples/term-attributes.cpp | 5 +- examples/termcap.cpp | 17 +- examples/transparent.cpp | 9 +- examples/treeview.cpp | 11 +- examples/ui.cpp | 30 +- examples/watch.cpp | 6 +- examples/windows.cpp | 8 +- fonts/unicodemap.h | 14 +- src/fbusyindicator.cpp | 3 +- src/fcharmap.cpp | 1314 +++++++++++++-------------- src/fdialog.cpp | 55 +- src/fevent.cpp | 5 +- src/ffiledialog.cpp | 24 +- src/fkey_map.cpp | 29 +- src/fkeyboard.cpp | 37 +- src/flogger.cpp | 4 +- src/fmenubar.cpp | 12 +- src/fmenuitem.cpp | 2 +- src/fmessagebox.cpp | 55 +- src/fmouse.cpp | 10 +- src/fobject.cpp | 10 +- src/foptiattr.cpp | 6 +- src/frect.cpp | 16 +- src/fstring.cpp | 64 +- src/fterm.cpp | 86 +- src/fterm_functions.cpp | 34 +- src/ftermbuffer.cpp | 4 +- src/ftermcap.cpp | 20 +- src/ftermfreebsd.cpp | 6 +- src/ftermlinux.cpp | 14 +- src/ftermxterminal.cpp | 4 +- src/ftextview.cpp | 12 +- src/fvterm.cpp | 38 +- src/fwidget.cpp | 93 +- src/fwidget_functions.cpp | 2 +- src/fwindow.cpp | 20 +- src/include/final/emptyfstring.h | 4 +- src/include/final/fapplication.h | 4 +- src/include/final/fbusyindicator.h | 4 +- src/include/final/fbutton.h | 6 +- src/include/final/fbuttongroup.h | 6 +- src/include/final/fcallback.h | 4 +- src/include/final/fcharmap.h | 15 +- src/include/final/fcheckbox.h | 4 +- src/include/final/fcheckmenuitem.h | 4 +- src/include/final/fcolorpair.h | 2 +- src/include/final/fcolorpalette.h | 16 +- src/include/final/fcombobox.h | 8 +- src/include/final/fdata.h | 4 +- src/include/final/fdialog.h | 10 +- src/include/final/fdialoglistmenu.h | 4 +- src/include/final/fevent.h | 22 +- src/include/final/ffiledialog.h | 36 +- src/include/final/fkey_map.h | 6 +- src/include/final/fkeyboard.h | 23 +- src/include/final/flabel.h | 6 +- src/include/final/flineedit.h | 6 +- src/include/final/flistbox.h | 17 +- src/include/final/flistview.h | 21 +- src/include/final/flog.h | 4 +- src/include/final/flogger.h | 8 +- src/include/final/fmenu.h | 6 +- src/include/final/fmenubar.h | 6 +- src/include/final/fmenuitem.h | 4 +- src/include/final/fmenulist.h | 4 +- src/include/final/fmessagebox.h | 46 +- src/include/final/fmouse.h | 14 +- src/include/final/fobject.h | 6 +- src/include/final/foptiattr.h | 4 +- src/include/final/foptimove.h | 4 +- src/include/final/fpoint.h | 16 +- src/include/final/fprogressbar.h | 6 +- src/include/final/fradiobutton.h | 4 +- src/include/final/fradiomenuitem.h | 4 +- src/include/final/frect.h | 20 +- src/include/final/fscrollbar.h | 4 +- src/include/final/fscrollview.h | 16 +- src/include/final/fsize.h | 12 +- src/include/final/fspinbox.h | 4 +- src/include/final/fstartoptions.h | 4 +- src/include/final/fstatusbar.h | 8 +- src/include/final/fstring.h | 46 +- src/include/final/fstringstream.h | 4 +- src/include/final/fstyle.h | 2 +- src/include/final/fswitch.h | 4 +- src/include/final/fterm.h | 14 +- src/include/final/ftermbuffer.h | 6 +- src/include/final/ftermcap.h | 13 +- src/include/final/ftermcapquirks.h | 6 +- src/include/final/ftermdata.h | 4 +- src/include/final/ftermdetection.h | 4 +- src/include/final/ftermfreebsd.h | 4 +- src/include/final/ftermios.h | 6 +- src/include/final/ftermlinux.h | 4 +- src/include/final/ftermopenbsd.h | 4 +- src/include/final/ftermxterminal.h | 40 +- src/include/final/ftextview.h | 6 +- src/include/final/ftogglebutton.h | 6 +- src/include/final/ftooltip.h | 10 +- src/include/final/ftypes.h | 4 +- src/include/final/fvterm.h | 14 +- src/include/final/fwidget.h | 10 +- src/include/final/fwidgetcolors.h | 20 +- src/include/final/fwindow.h | 4 +- src/include/final/sgr_optimizer.h | 2 +- test/fkeyboard-test.cpp | 17 +- test/ftermcapquirks-test.cpp | 24 +- test/ftermfreebsd-test.cpp | 6 +- test/ftermlinux-test.cpp | 2 +- 123 files changed, 1830 insertions(+), 1761 deletions(-) diff --git a/ChangeLog b/ChangeLog index e9c1575f..de56b965 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2020-10-04 Markus Gans + * Replaces some C-style arrays with std::array + * Now you can use the arrow keys to move a window into the visible area + * Removes FData memory leak in FListBoxItem and FListViewItem + 2020-09-27 Markus Gans * An explanation of the widget tree was added to the document of the first steps diff --git a/doc/final-cut-widget tree.svg b/doc/final-cut-widget tree.svg index 2b911b0b..eeb7eeae 100644 --- a/doc/final-cut-widget tree.svg +++ b/doc/final-cut-widget tree.svg @@ -5,41 +5,13 @@ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - id="svg61" - version="1.1" - width="149.86537mm" - viewBox="0 0 149.86537 65.484895" height="65.484894mm" - sodipodi:docname="final-cut-widget tree.svg" - inkscape:version="0.92.1 r15371"> - + viewBox="0 0 149.86537 65.484895" + width="149.86537mm" + version="1.1" + id="svg109"> + id="metadata115"> @@ -51,364 +23,302 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + id="defs113" /> + + + + + + + + + + + + + + + - - - + + + FApplication - - - - - - + FApplication + + + + + FDialog - - - - - - + FDialog + + + + + FDialog - - - - - - + FDialog + + + + + FLabel - - - - - - + FLabel + + + + + FButton - + id="text53"> + FListBox + + + id="text61"> etc. + y="65.409096" + id="tspan59">etc. + d="m49.251306 9.2100164v5.7870836" + fill="none" + marker-end="url(#a)" + stroke="#000" + stroke-width=".423069" + id="path63" /> + d="m42.679299 24.537976v5.779196" + fill="none" + marker-end="url(#b)" + stroke="#000" + stroke-width=".423069" + id="path65" /> + d="m55.736511 24.537898v5.779196" + fill="none" + marker-end="url(#c)" + stroke="#000" + stroke-width=".423069" + id="path67" /> + d="m62.369882 39.865938v5.548839" + fill="none" + marker-end="url(#d)" + stroke="#000" + stroke-width=".423069" + id="path69" /> + d="m62.369882 55.193909v5.548839" + fill="none" + marker-end="url(#e)" + stroke="#000" + stroke-width=".423069" + id="path71" /> + style="font-size:4.93888903px;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;letter-spacing:0;word-spacing:0;text-anchor:middle;fill:#1a1a1a;stroke-width:0.51097;stroke-opacity:0" + transform="matrix(0.82806766,0,0,0.82760652,25.151866,-0.203308)" + id="g89"> + id="text75"> Parent: + y="8.7182531" + id="tspan73">Parent: + id="text79"> Child: + y="27.239086" + id="tspan77">Child: + id="text83"> Subchild: + y="44.796837" + id="tspan81">Subchild: + id="text87"> Sub-subchild: + y="63.317669" + id="tspan85">Sub-subchild: + style="font-size:4.93888903px;font-family:FreeSans, Arial, 'Bitstream Vera Sans', 'DejaVu Sans', 'Open Sans', sans-serif;letter-spacing:0;word-spacing:0;text-anchor:middle;fill:#1a1a1a;stroke-width:0.51097;stroke-opacity:0" + transform="matrix(0.82806766,0,0,0.82760652,107.7173,-0.203308)" + id="g107"> + id="text93"> Application widget (= 1) + y="8.7182531" + id="tspan91">Application widget (= 1) + id="text97"> Main widget (= 1) + y="27.239086" + id="tspan95">Main widget (= 1) + id="text101"> Widget(s) of the main widget (≥ 0) + y="44.796837" + id="tspan99">Widget(s) of the main widget (≥ 0) + id="text105"> Widget(s) from the parent widget (≥ 0) + y="63.317669" + id="tspan103">Widget(s) from the parent widget (≥ 0) diff --git a/doc/user-theme.md b/doc/user-theme.md index bd05ed97..611a2c23 100644 --- a/doc/user-theme.md +++ b/doc/user-theme.md @@ -27,7 +27,7 @@ class myWidgetColors final : public finalcut::FWidgetColors ~myWidgetColors() override { } - const finalcut::FString getClassName() const override + finalcut::FString getClassName() const override { return "myWidgetColors"; } @@ -68,7 +68,7 @@ class BeeColorTheme final : public finalcut::FWidgetColors ~BeeColorTheme() override { } - const finalcut::FString getClassName() const override + finalcut::FString getClassName() const override { return "BeeColorTheme"; } @@ -216,7 +216,7 @@ class myColorPalette final : public finalcut::FColorPalette ~myColorPalette() { } - const finalcut::FString getClassName() const override + finalcut::FString getClassName() const override { return "myColorPalette"; } @@ -299,7 +299,7 @@ class BeeColorPalette final : public finalcut::FColorPalette ~BeeColorPalette() { } - const finalcut::FString getClassName() const override + finalcut::FString getClassName() const override { return "BeeColorPalette"; } diff --git a/examples/7segment.cpp b/examples/7segment.cpp index 2a6876fd..6a16fd6c 100644 --- a/examples/7segment.cpp +++ b/examples/7segment.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include #include #include @@ -39,9 +40,6 @@ using finalcut::FSize; class SegmentView final : public finalcut::FDialog { public: - // Using-declaration - using FDialog::setGeometry; - // Constructor explicit SegmentView (finalcut::FWidget* = nullptr); @@ -64,10 +62,9 @@ class SegmentView final : public finalcut::FDialog void get7Segment (const wchar_t); void draw() override; - // Data members std::map code{}; - finalcut::FString line[3]{}; + std::array line{}; finalcut::FLineEdit input{"0123", this}; finalcut::FButton exit{"E&xit", this}; }; @@ -140,7 +137,7 @@ void SegmentView::hexEncoding() //---------------------------------------------------------------------- void SegmentView::get7Segment (const wchar_t c) { - for (int i{0}; i < 3; i++) + for (std::size_t i{0}; i < 3; i++) line[i].clear(); switch ( c ) @@ -186,8 +183,8 @@ void SegmentView::get7Segment (const wchar_t c) if ( code.find(c) != code.end() ) { const sevenSegment& s = code[c]; - constexpr char h[2]{' ', '_'}; - constexpr char v[2]{' ', '|'}; + constexpr std::array h{{' ', '_'}}; + constexpr std::array v{{' ', '|'}}; line[0] << ' ' << h[s.a] << ' '; line[1] << v[s.f] << h[s.g] << v[s.b]; diff --git a/examples/background-color.cpp b/examples/background-color.cpp index 186bdd20..e215f7d7 100644 --- a/examples/background-color.cpp +++ b/examples/background-color.cpp @@ -38,9 +38,6 @@ using finalcut::FSize; class Background final : public finalcut::FDialog { public: - // Using-declaration - using FDialog::setGeometry; - // Typedef typedef std::tuple RGB; diff --git a/examples/calculator.cpp b/examples/calculator.cpp index 156a5c96..77e1479b 100644 --- a/examples/calculator.cpp +++ b/examples/calculator.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -231,7 +232,7 @@ class Calc final : public finalcut::FDialog char infix_operator{'\0'}; char last_infix_operator{'\0'}; finalcut::FString input{""}; - button button_no[Calc::NUM_OF_BUTTONS]{}; + std::array button_no{}; struct StackData { @@ -950,8 +951,8 @@ void Calc::draw() bool Calc::isDataEntryKey (int key) const { // Test if key is in {'.', '0'..'9'} - const int data_entry_keys[] = - { + constexpr std::array key_list = + {{ Decimal_point, Zero, One, @@ -963,11 +964,11 @@ bool Calc::isDataEntryKey (int key) const Seven, Eight, Nine - }; + }}; - const int* iter = std::find (data_entry_keys, data_entry_keys + 11, key); + const auto& iter = std::find (key_list.begin(), key_list.end(), key); - if ( iter != data_entry_keys + 11 ) + if ( iter != key_list.end() ) return true; else return false; @@ -977,19 +978,19 @@ bool Calc::isDataEntryKey (int key) const bool Calc::isOperatorKey(int key) const { // Test if key is in {'*', '/', '+', '-', '^', '='} - const int operators[] = - { + constexpr std::array operators = + {{ Multiply, Divide, Add, Subtract, Power, Equals - }; + }}; - const int* iter = std::find (operators, operators + 6, key); + const auto& iter = std::find (operators.begin(), operators.end(), key); - if ( iter != operators + 6 ) + if ( iter != operators.end() ) return true; else return false; @@ -1099,8 +1100,8 @@ void Calc::adjustSize() //---------------------------------------------------------------------- const wchar_t* Calc::getButtonText (const std::size_t key) const { - static const wchar_t* const button_text[Calc::NUM_OF_BUTTONS] = - { + constexpr std::array button_text = + {{ L"&Sin", L"&Cos", L"&Tan", @@ -1135,7 +1136,7 @@ const wchar_t* Calc::getButtonText (const std::size_t key) const L"&.", L"&±", L"&=" - }; + }}; return button_text[key]; } diff --git a/examples/checklist.cpp b/examples/checklist.cpp index 07248adf..46c19675 100644 --- a/examples/checklist.cpp +++ b/examples/checklist.cpp @@ -58,6 +58,7 @@ class CheckList final : public finalcut::FDialog private: // Method void populate(); + void adjustSize() override; // Event handlers void onKeyPress (finalcut::FKeyEvent*) override; @@ -80,8 +81,7 @@ CheckList::CheckList (finalcut::FWidget* parent) // (CERT, OOP50-CPP) FDialog::setText (L"Shopping list"); const std::size_t nf_offset = ( finalcut::FTerm::isNewFont() ) ? 1 : 0; - FDialog::setGeometry ( FPoint{int(1 + (parent->getWidth() - 28) / 2), 5} - , FSize{28 + nf_offset, 13} ); + FDialog::setSize (FSize{28 + nf_offset, 13} ); setShadow(); listview.ignorePadding(); listview.setGeometry ( FPoint{1 + int(nf_offset), 2} @@ -121,29 +121,36 @@ CheckList::~CheckList() // destructor //---------------------------------------------------------------------- void CheckList::populate() { - const std::string list[][2] = - { - { "Milk", "Highest" }, - { "Cheese", "High" }, - { "Yoghurt", "Medium" }, - { "Bread", "Low" }, - { "Eggs", "High" }, - { "Toothpaste", "Medium" }, - { "Apples", "Lowest" }, - { "Bananas", "Medium" }, - { "Fish", "Medium" }, - { "Lemons", "Low" } - }; + constexpr std::array, 10> list = + {{ + {{ "Milk", "Highest" }}, + {{ "Cheese", "High" }}, + {{ "Yoghurt", "Medium" }}, + {{ "Bread", "Low" }}, + {{ "Eggs", "High" }}, + {{ "Toothpaste", "Medium" }}, + {{ "Apples", "Lowest" }}, + {{ "Bananas", "Medium" }}, + {{ "Fish", "Medium" }}, + {{ "Lemons", "Low" }} + }}; for (const auto& line : list) { - const finalcut::FStringList string_line (&line[0], &line[0] + 2); + const finalcut::FStringList string_line (line.begin(), line.end()); auto iter = listview.insert (string_line); auto item = static_cast(*iter); item->setCheckable(true); } } +//---------------------------------------------------------------------- +void CheckList::adjustSize() +{ + finalcut::FDialog::adjustSize(); + setPos(FPoint{int(1 + (getDesktopWidth() - getWidth()) / 2), 5}); +} + //---------------------------------------------------------------------- void CheckList::onKeyPress (finalcut::FKeyEvent* ev) { diff --git a/examples/event-log.cpp b/examples/event-log.cpp index e3b2afa2..a3bd7095 100644 --- a/examples/event-log.cpp +++ b/examples/event-log.cpp @@ -51,7 +51,7 @@ class EventDialog final : public finalcut::FDialog EventDialog (const EventDialog&) = delete; // Destructor - ~EventDialog(); + ~EventDialog() override; // Disable copy assignment operator (=) EventDialog& operator = (const EventDialog&) = delete; @@ -245,7 +245,7 @@ class EventLog final : public finalcut::FDialog, public std::ostringstream EventLog (const EventLog&) = delete; // Destructor - ~EventLog(); + ~EventLog() override; // Disable copy assignment operator (=) EventLog& operator = (const EventLog&) = delete; diff --git a/examples/listview.cpp b/examples/listview.cpp index c2587da4..bdc9eec3 100644 --- a/examples/listview.cpp +++ b/examples/listview.cpp @@ -130,54 +130,54 @@ Listview::~Listview() // destructor //---------------------------------------------------------------------- void Listview::populate() { - const std::string weather[][5] = - { - { "Alexandria", "Sunny", "31°C", "61%", "1006.4 mb" }, - { "Amsterdam", "Cloudy", "21°C", "82%", "1021.3 mb" }, - { "Baghdad", "Fair", "47°C", "9%", "1001.0 mb" }, - { "Bangkok", "Partly Cloudy", "30°C", "69%", "1002.0 mb" }, - { "Beijing", "Fair", "31°C", "68%", "1007.1 mb" }, - { "Berlin", "Cloudy", "22°C", "53%", "1022.0 mb" }, - { "Bogotá", "Fair", "9°C", "95%", "1028.5 mb" }, - { "Budapest", "Partly Cloudy", "23°C", "37%", "1020.7 mb" }, - { "Buenos Aires", "Cloudy", "7°C", "73%", "1019.0 mb" }, - { "Cairo", "Fair", "39°C", "22%", "1006.1 mb" }, - { "Cape Town", "Partly Cloudy", "12°C", "45%", "1030.1 mb" }, - { "Chicago", "Mostly Cloudy", "21°C", "81%", "1014.9 mb" }, - { "Delhi", "Haze", "33°C", "68%", "998.0 mb" }, - { "Dhaka", "Haze", "32°C", "64%", "996.3 mb" }, - { "Houston", "Cloudy", "23°C", "100%", "1014.2 mb" }, - { "Istanbul", "Mostly Cloudy", "27°C", "61%", "1011.2 mb" }, - { "Jakarta", "Fair", "28°C", "71%", "1009.1 mb" }, - { "Jerusalem", "Sunny", "35°C", "17%", "1005.8 mb" }, - { "Johannesburg", "Fair", "18°C", "16%", "1020.0 mb" }, - { "Karachi", "Mostly Cloudy", "29°C", "76%", "998.0 mb" }, - { "Lagos", "Mostly Cloudy", "27°C", "86%", "1014.6 mb" }, - { "Lima", "Cloudy", "17°C", "83%", "1017.3 mb" }, - { "London", "Cloudy", "23°C", "71%", "1023.0 mb" }, - { "Los Angeles", "Fair", "21°C", "78%", "1011.9 mb" }, - { "Madrid", "Fair", "32°C", "35%", "1020.0 mb" }, - { "Mexico City", "Partly Cloudy", "14°C", "79%", "1028.5 mb" }, - { "Moscow", "Partly Cloudy", "24°C", "54%", "1014.2 mb" }, - { "Mumbai", "Haze", "28°C", "77%", "1003.0 mb" }, - { "New York City", "Sunny", "21°C", "80%", "1014.2 mb" }, - { "Paris", "Partly Cloudy", "27°C", "57%", "1024.4 mb" }, - { "Reykjavík", "Mostly Cloudy", "11°C", "76%", "998.6 mb" }, - { "Rio de Janeiro", "Fair", "24°C", "64%", "1022.0 mb" }, - { "Rome", "Fair", "32°C", "18%", "1014.2 mb" }, - { "Saint Petersburg", "Mostly Cloudy", "18°C", "55%", "1014.6 mb" }, - { "São Paulo", "Fair", "19°C", "53%", "1024.0 mb" }, - { "Seoul", "Cloudy", "26°C", "87%", "1012.2 mb" }, - { "Shanghai", "Fair", "32°C", "69%", "1009.1 mb" }, - { "Singapore", "Mostly Cloudy", "29°C", "73%", "1009.1 mb" }, - { "Tehran", "Fair", "36°C", "14%", "1013.2 mb" }, - { "Tokyo", "Mostly Cloudy", "28°C", "67%", "1009.1 mb" }, - { "Zurich", "Mostly Cloudy", "23°C", "44%", "1023.7 mb" } - }; + constexpr std::array, 41> weather = + {{ + {{ "Alexandria", "Sunny", "31°C", "61%", "1006.4 mb" }}, + {{ "Amsterdam", "Cloudy", "21°C", "82%", "1021.3 mb" }}, + {{ "Baghdad", "Fair", "47°C", "9%", "1001.0 mb" }}, + {{ "Bangkok", "Partly Cloudy", "30°C", "69%", "1002.0 mb" }}, + {{ "Beijing", "Fair", "31°C", "68%", "1007.1 mb" }}, + {{ "Berlin", "Cloudy", "22°C", "53%", "1022.0 mb" }}, + {{ "Bogotá", "Fair", "9°C", "95%", "1028.5 mb" }}, + {{ "Budapest", "Partly Cloudy", "23°C", "37%", "1020.7 mb" }}, + {{ "Buenos Aires", "Cloudy", "7°C", "73%", "1019.0 mb" }}, + {{ "Cairo", "Fair", "39°C", "22%", "1006.1 mb" }}, + {{ "Cape Town", "Partly Cloudy", "12°C", "45%", "1030.1 mb" }}, + {{ "Chicago", "Mostly Cloudy", "21°C", "81%", "1014.9 mb" }}, + {{ "Delhi", "Haze", "33°C", "68%", "998.0 mb" }}, + {{ "Dhaka", "Haze", "32°C", "64%", "996.3 mb" }}, + {{ "Houston", "Cloudy", "23°C", "100%", "1014.2 mb" }}, + {{ "Istanbul", "Mostly Cloudy", "27°C", "61%", "1011.2 mb" }}, + {{ "Jakarta", "Fair", "28°C", "71%", "1009.1 mb" }}, + {{ "Jerusalem", "Sunny", "35°C", "17%", "1005.8 mb" }}, + {{ "Johannesburg", "Fair", "18°C", "16%", "1020.0 mb" }}, + {{ "Karachi", "Mostly Cloudy", "29°C", "76%", "998.0 mb" }}, + {{ "Lagos", "Mostly Cloudy", "27°C", "86%", "1014.6 mb" }}, + {{ "Lima", "Cloudy", "17°C", "83%", "1017.3 mb" }}, + {{ "London", "Cloudy", "23°C", "71%", "1023.0 mb" }}, + {{ "Los Angeles", "Fair", "21°C", "78%", "1011.9 mb" }}, + {{ "Madrid", "Fair", "32°C", "35%", "1020.0 mb" }}, + {{ "Mexico City", "Partly Cloudy", "14°C", "79%", "1028.5 mb" }}, + {{ "Moscow", "Partly Cloudy", "24°C", "54%", "1014.2 mb" }}, + {{ "Mumbai", "Haze", "28°C", "77%", "1003.0 mb" }}, + {{ "New York City", "Sunny", "21°C", "80%", "1014.2 mb" }}, + {{ "Paris", "Partly Cloudy", "27°C", "57%", "1024.4 mb" }}, + {{ "Reykjavík", "Mostly Cloudy", "11°C", "76%", "998.6 mb" }}, + {{ "Rio de Janeiro", "Fair", "24°C", "64%", "1022.0 mb" }}, + {{ "Rome", "Fair", "32°C", "18%", "1014.2 mb" }}, + {{ "Saint Petersburg", "Mostly Cloudy", "18°C", "55%", "1014.6 mb" }}, + {{ "São Paulo", "Fair", "19°C", "53%", "1024.0 mb" }}, + {{ "Seoul", "Cloudy", "26°C", "87%", "1012.2 mb" }}, + {{ "Shanghai", "Fair", "32°C", "69%", "1009.1 mb" }}, + {{ "Singapore", "Mostly Cloudy", "29°C", "73%", "1009.1 mb" }}, + {{ "Tehran", "Fair", "36°C", "14%", "1013.2 mb" }}, + {{ "Tokyo", "Mostly Cloudy", "28°C", "67%", "1009.1 mb" }}, + {{ "Zurich", "Mostly Cloudy", "23°C", "44%", "1023.7 mb" }} + }}; for (const auto& place : weather) { - const finalcut::FStringList line (&place[0], &place[0] + 5); + const finalcut::FStringList line (place.begin(), place.end()); listview.insert (line); } } @@ -197,7 +197,10 @@ void Listview::cb_showInMessagebox() "Temperature: " + item->getText(3) + "\n" " Humidity: " + item->getText(4) + "\n" " Pressure: " + item->getText(5) - , finalcut::FMessageBox::Ok, 0, 0, this ); + , finalcut::FMessageBox::Ok + , finalcut::FMessageBox::Reject + , finalcut::FMessageBox::Reject + , this ); info.show(); } diff --git a/examples/mandelbrot.cpp b/examples/mandelbrot.cpp index fe9d1c44..f8c52b96 100644 --- a/examples/mandelbrot.cpp +++ b/examples/mandelbrot.cpp @@ -75,8 +75,8 @@ void Mandelbrot::draw() const int xoffset{2}; const int yoffset{2}; - const int Cols = int(getClientWidth()); - const int Lines = int(getClientHeight()); + const auto Cols = int(getClientWidth()); + const auto Lines = int(getClientHeight()); int current_line{0}; if ( Cols < 2 || Lines < 2 ) diff --git a/examples/menu.cpp b/examples/menu.cpp index 216c630f..66099bf8 100644 --- a/examples/menu.cpp +++ b/examples/menu.cpp @@ -291,8 +291,8 @@ void Menu::defaultCallback (const finalcut::FMenuList* mb) //---------------------------------------------------------------------- void Menu::adjustSize() { - const int pw = int(getDesktopWidth()); - const int ph = int(getDesktopHeight()); + const auto pw = int(getDesktopWidth()); + const auto ph = int(getDesktopHeight()); setX (1 + (pw - int(getWidth())) / 2, false); setY (1 + (ph - int(getHeight())) / 4, false); finalcut::FDialog::adjustSize(); @@ -327,8 +327,7 @@ int main (int argc, char* argv[]) // Create main dialog object Menu main_dlg {&app}; main_dlg.setText ("Menu example"); - main_dlg.setGeometry ( FPoint{int(1 + (app.getWidth() - 40) / 2), 2} - , FSize{40, 6} ); + main_dlg.setSize ({40, 6}); main_dlg.setShadow(); // Set dialog main_dlg as main widget diff --git a/examples/mouse.cpp b/examples/mouse.cpp index e986e937..c59524af 100644 --- a/examples/mouse.cpp +++ b/examples/mouse.cpp @@ -537,8 +537,8 @@ void MouseDraw::adjustSize() { const std::size_t w{60}; const std::size_t h{18}; - const int x = 1 + int((getParentWidget()->getWidth() - w) / 2); - const int y = 1 + int((getParentWidget()->getHeight() - h) / 2); + const int x = 1 + int((getDesktopWidth() - w) / 2); + const int y = 1 + int((getDesktopHeight() - h) / 2); setGeometry (FPoint{x, y}, FSize{w, h}, false); finalcut::FDialog::adjustSize(); } @@ -590,7 +590,6 @@ int main (int argc, char* argv[]) // Create a simple dialog box MouseDraw mouse_draw{&app}; - mouse_draw.setGeometry (FPoint{12, 4}, FSize{60, 18}); // Set dialog object mouse_draw as main widget finalcut::FWidget::setMainWidget(&mouse_draw); diff --git a/examples/opti-move.cpp b/examples/opti-move.cpp index ddb33701..b89bf694 100644 --- a/examples/opti-move.cpp +++ b/examples/opti-move.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include #include #include #include @@ -93,14 +94,15 @@ void move (int xold, int yold, int xnew, int ynew) finalcut::FString from{}; finalcut::FString to{}; finalcut::FString byte{}; - const std::string ctrl_character[] = - { + + constexpr std::array ctrl_character = + {{ "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "Tab", "LF", "VT", "FF", "CR", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "Esc", "FS", "GS", "RS", "US", "Space" - }; + }}; term_boundaries(xold, yold); term_boundaries(xnew, ynew); @@ -209,8 +211,11 @@ DirectLogger::~DirectLogger() // destructor //---------------------------------------------------------------------- int main (int argc, char* argv[]) { - // Disable mouse - finalcut::FStartOptions::getFStartOptions().mouse_support = false; + // Disable mouse, color palette changes and terminal data requests + auto& start_options = finalcut::FStartOptions::getFStartOptions(); + start_options.mouse_support = false; + start_options.color_change = false; + start_options.terminal_data_request = false; // Create the application object finalcut::FApplication term_app{argc, argv}; diff --git a/examples/rotozoomer.cpp b/examples/rotozoomer.cpp index 270c3346..12dfec23 100644 --- a/examples/rotozoomer.cpp +++ b/examples/rotozoomer.cpp @@ -226,7 +226,7 @@ void RotoZoomer::onShow (finalcut::FShowEvent*) end = system_clock::now(); generateReport(); flush(); - quit(); + close(); } } @@ -261,7 +261,9 @@ void RotoZoomer::onKeyPress (finalcut::FKeyEvent* ev) //---------------------------------------------------------------------- void RotoZoomer::onClose (finalcut::FCloseEvent* ev) { - if ( ! benchmark ) + if ( benchmark ) + ev->accept(); + else finalcut::FApplication::closeConfirmationDialog (this, ev); } @@ -305,6 +307,9 @@ int main (int argc, char* argv[]) || strcmp(argv[1], "-b") == 0 ) ) { benchmark = true; + // Disable terminal data requests + auto& start_options = finalcut::FStartOptions::getFStartOptions(); + start_options.terminal_data_request = false; } { // Create the application object in this scope @@ -317,8 +322,6 @@ int main (int argc, char* argv[]) if ( benchmark ) roto.setGeometry (FPoint{1, 1}, FSize{80, 24}); - else - roto.setGeometry (FPoint{5, 1}, FSize{72, 23}); roto.setShadow(); diff --git a/examples/term-attributes.cpp b/examples/term-attributes.cpp index 65ec75dd..9eacc4e1 100644 --- a/examples/term-attributes.cpp +++ b/examples/term-attributes.cpp @@ -63,7 +63,7 @@ class AttribDlg final : public finalcut::FDialog private: // Constants - static constexpr FColor UNDEFINED = static_cast(-2); + static constexpr auto UNDEFINED = static_cast(-2); // Method void adjustSize() override; @@ -498,8 +498,7 @@ int main (int argc, char* argv[]) // This object will be automatically deleted by // the parent object "app" (FObject destructor). AttribDlg dialog{&app}; - - dialog.setGeometry (FPoint{6, 2}, FSize{69, 21}); + dialog.setSize (FSize{69, 21}); dialog.setShadow(); // Create the attribute demo widget as a child object from the dialog diff --git a/examples/termcap.cpp b/examples/termcap.cpp index 1c36835c..f93935f7 100644 --- a/examples/termcap.cpp +++ b/examples/termcap.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include #include #include #include @@ -50,14 +51,14 @@ struct Data const fc::termcaps cap; }; - static TermcapString strings[]; + static std::array strings; }; //---------------------------------------------------------------------- // struct data - string data array //---------------------------------------------------------------------- -Data::TermcapString Data::strings[] = -{ +std::array Data::strings = +{{ { "t_bell", fc::t_bell }, { "t_erase_chars", fc::t_erase_chars }, { "t_clear_screen", fc::t_clear_screen }, @@ -99,6 +100,7 @@ Data::TermcapString Data::strings[] = { "t_parm_right_cursor", fc::t_parm_right_cursor }, { "t_save_cursor", fc::t_save_cursor }, { "t_restore_cursor", fc::t_restore_cursor }, + { "t_cursor_style", fc::t_cursor_style }, { "t_scroll_forward", fc::t_scroll_forward }, { "t_scroll_reverse", fc::t_scroll_reverse }, { "t_enter_ca_mode", fc::t_enter_ca_mode }, @@ -140,7 +142,7 @@ Data::TermcapString Data::strings[] = { "t_keypad_xmit", fc::t_keypad_xmit }, { "t_keypad_local", fc::t_keypad_local }, { "t_key_mouse", fc::t_key_mouse } -}; +}}; //---------------------------------------------------------------------- @@ -174,11 +176,11 @@ void tcapString (const std::string& name, const char cap_str[]) return; } - const uInt len = uInt(std::strlen(cap_str)); + const auto len = uInt(std::strlen(cap_str)); for (uInt i{0}; i < len; i++) { - const uChar c = uChar(cap_str[i]); + const auto c = uChar(cap_str[i]); if ( c > 127 ) { @@ -282,8 +284,7 @@ void numeric() void string() { std::cout << "\r\n[String]\r\n"; - const finalcut::FTermcap::tcap_map (&tcap_strings)[] \ - = finalcut::FTermcap::strings; + const auto& tcap_strings = finalcut::FTermcap::strings; for (const auto& entry : Data::strings) { diff --git a/examples/transparent.cpp b/examples/transparent.cpp index 38a9e988..cebba7d9 100644 --- a/examples/transparent.cpp +++ b/examples/transparent.cpp @@ -256,12 +256,11 @@ void MainWindow::onShow (finalcut::FShowEvent*) //---------------------------------------------------------------------- void MainWindow::onTimer (finalcut::FTimerEvent*) { - wchar_t first_char[2]; std::size_t length = line1.getLength(); - first_char[0] = line1[0]; - first_char[1] = line2[0]; - line1 = line1.right(length - 1) + first_char[0]; - line2 = line2.right(length - 1) + first_char[1]; + const wchar_t first_char1 = line1[0]; + const wchar_t first_char2 = line2[0]; + line1 = line1.right(length - 1) + first_char1; + line2 = line2.right(length - 1) + first_char2; redraw(); flush(); } diff --git a/examples/treeview.cpp b/examples/treeview.cpp index a0393b4a..98f53c8a 100644 --- a/examples/treeview.cpp +++ b/examples/treeview.cpp @@ -401,6 +401,8 @@ Treeview::~Treeview() // destructor //---------------------------------------------------------------------- void Treeview::adjustSize() { + finalcut::FDialog::adjustSize(); + std::size_t h = getDesktopHeight() - 4; setHeight (h, false); int x = int((getDesktopWidth() - getWidth()) / 2); @@ -408,15 +410,13 @@ void Treeview::adjustSize() if ( x < 1 ) x = 1; - setX (x, false); + setPos (FPoint{x, 3}, false); if ( initialized ) { - listview.setHeight (getHeight() - 6, false); + listview.setHeight (getHeight() - 6, true); quit.setY(int(getHeight()) - 4); } - - finalcut::FDialog::adjustSize(); } //---------------------------------------------------------------------- @@ -438,8 +438,7 @@ int main (int argc, char* argv[]) // Create main dialog object Treeview d{&app}; d.setText (L"Continents"); - d.setGeometry ( FPoint{int(1 + (app.getWidth() - 57) / 2), 3} - , FSize{57, 20} ); + d.setSize (FSize{57, 20}); d.setShadow(); // Set dialog d as main widget diff --git a/examples/ui.cpp b/examples/ui.cpp index 8f0b8a99..562113ab 100644 --- a/examples/ui.cpp +++ b/examples/ui.cpp @@ -782,19 +782,19 @@ void MyDialog::initWidgetsCallbacks() //---------------------------------------------------------------------- void MyDialog::adjustSize() { - const auto h = getParentWidget()->getHeight() - 4; + finalcut::FDialog::adjustSize(); + + const auto h = getDesktopHeight() - 4; setHeight (h, false); - int x = int((getDesktopWidth() - getWidth()) / 2); + auto x = int((getDesktopWidth() - getWidth()) / 2); if ( x < 1 ) x = 1; - setX (x, false); + setPos (FPoint{x, 2}, false); if ( initialized ) - myList.setHeight (getHeight() - 3, false); - - finalcut::FDialog::adjustSize(); + myList.setHeight (getHeight() - 3, true); } //---------------------------------------------------------------------- @@ -823,7 +823,10 @@ void MyDialog::cb_about() , line + L" FINAL CUT " + line + L"\n\n" L"Version " + libver + L"\n\n" L"(c) 2020 by Markus Gans" - , finalcut::FMessageBox::Ok, 0, 0, this ); + , finalcut::FMessageBox::Ok + , finalcut::FMessageBox::Reject + , finalcut::FMessageBox::Reject + , this ); info.setCenterText(); info.show(); } @@ -843,7 +846,10 @@ void MyDialog::cb_terminfo() << " Size: " << x << fc::Times << y << "\n" << "Colors: " << finalcut::FTerm::getMaxColor() - , finalcut::FMessageBox::Ok, 0, 0, this + , finalcut::FMessageBox::Ok + , finalcut::FMessageBox::Reject + , finalcut::FMessageBox::Reject + , this ); info1.setHeadline("Terminal:"); info1.exec(); @@ -858,7 +864,10 @@ void MyDialog::cb_drives() , "Generic: \n\n" "Network: \n\n" " CD:" - , finalcut::FMessageBox::Ok, 0, 0, this + , finalcut::FMessageBox::Ok + , finalcut::FMessageBox::Reject + , finalcut::FMessageBox::Reject + , this ); if ( finalcut::FTerm::isNewFont() ) @@ -1057,8 +1066,7 @@ int main (int argc, char* argv[]) // Create main dialog object d MyDialog d{&app}; d.setText (title); - d.setGeometry ( FPoint{int((app.getWidth() - 56) / 2), 2} - , FSize{56, app.getHeight() - 4} ); + d.setSize (FSize{56, app.getHeight() - 4}); d.setShadow(); // Set the dialog object d as the main widget of the application. diff --git a/examples/watch.cpp b/examples/watch.cpp index 92359dc6..c607fd61 100644 --- a/examples/watch.cpp +++ b/examples/watch.cpp @@ -79,8 +79,7 @@ Watch::Watch (FWidget* parent) // Avoids calling a virtual function from the constructor // (CERT, OOP50-CPP) FDialog::setText ("Watch"); - const int pw = int(getParentWidget()->getWidth()); - FDialog::setGeometry (FPoint{1 + (pw - 22) / 2, 3}, FSize{22, 13}); + FDialog::setSize ({22, 13}); // Labels time_label.setGeometry(FPoint{5, 2}, FSize{5, 1}); @@ -193,8 +192,9 @@ void Watch::cb_seconds() //---------------------------------------------------------------------- void Watch::adjustSize() { - const int pw = int(getParentWidget()->getWidth()); + const int pw = int(getDesktopWidth()); setX (1 + (pw - 22) / 2, false); + setY (3, false); finalcut::FDialog::adjustSize(); } diff --git a/examples/windows.cpp b/examples/windows.cpp index 526a28f1..d19ec369 100644 --- a/examples/windows.cpp +++ b/examples/windows.cpp @@ -243,6 +243,8 @@ class Window final : public finalcut::FDialog Window::Window (finalcut::FWidget* parent) : finalcut::FDialog{parent} { + setSize ({40, 6}); + // Menu bar item File.setStatusbarMessage ("File management commands"); @@ -349,6 +351,8 @@ void Window::activateWindow (finalcut::FDialog* win) const //---------------------------------------------------------------------- void Window::adjustSize() { + finalcut::FDialog::adjustSize(); + const std::size_t w = getDesktopWidth(); const std::size_t h = getDesktopHeight(); const int X = int(1 + (w - 40) / 2); @@ -375,8 +379,6 @@ void Window::adjustSize() ++iter; } - - finalcut::FDialog::adjustSize(); } //---------------------------------------------------------------------- @@ -574,8 +576,6 @@ int main (int argc, char* argv[]) // Create main dialog object Window main_dlg {&app}; main_dlg.setText ("Main window"); - main_dlg.setGeometry ( FPoint{int(1 + (app.getWidth() - 40) / 2), 2} - , FSize{40, 6} ); // Set dialog main_dlg as main widget finalcut::FWidget::setMainWidget (&main_dlg); diff --git a/fonts/unicodemap.h b/fonts/unicodemap.h index 09f9703d..24d80d69 100644 --- a/fonts/unicodemap.h +++ b/fonts/unicodemap.h @@ -11,14 +11,16 @@ #include #endif +#include + namespace finalcut { namespace fc { -constexpr struct unipair unicode_cp437_pairs[] = -{ +constexpr std::array unicode_cp437_pairs = +{{ // .----------- unicode // | .---- fontpos // | | @@ -304,10 +306,10 @@ constexpr struct unipair unicode_cp437_pairs[] = {0x266a, 0x0d}, {0x266b, 0x0e}, {0x266c, 0x0e} -}; +}}; -constexpr struct unipair unicode_newfont_pairs[] = -{ +constexpr std::array unicode_newfont_pairs = +{{ // .----------- unicode // | .---- fontpos // | | @@ -610,7 +612,7 @@ constexpr struct unipair unicode_newfont_pairs[] = {0xe1f9, 0xf9}, {0xe1fb, 0xfb}, {0xe1fc, 0xfc} -}; +}}; } // namespace fc diff --git a/src/fbusyindicator.cpp b/src/fbusyindicator.cpp index 63f24e66..3aa435ff 100644 --- a/src/fbusyindicator.cpp +++ b/src/fbusyindicator.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include #include "final/fbusyindicator.h" namespace finalcut @@ -75,7 +76,7 @@ void FBusyIndicator::init() //---------------------------------------------------------------------- void FBusyIndicator::createIndicatorText() { - FString line[4]{}; + std::array line{}; if ( FTerm::getEncoding() == fc::UTF8 ) { diff --git a/src/fcharmap.cpp b/src/fcharmap.cpp index 06597bb1..7c6c2097 100644 --- a/src/fcharmap.cpp +++ b/src/fcharmap.cpp @@ -20,6 +20,8 @@ * . * ***********************************************************************/ +#include + #include "final/fc.h" #include "final/ftypes.h" #include "final/fcharmap.h" @@ -30,690 +32,676 @@ namespace finalcut namespace fc { -uInt character[][fc::NUM_OF_ENCODINGS] = -{ +std::array, 115> character = +{{ // .--------------------- Unicode (UTF-8) // | .--------------- VT100 // | | .--------- PC (IBM-437) // | | | .---- ASCII (7-Bit) // | | | | - {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 - {0x203a, '>', 0xaf, '>'}, // › - SingleRightAngleQuotationMark - {0x2039, '<', 0xae, '<'}, // ‹ - SingleLeftAngleQuotationMark - {0x2026, '.', '.', '.'}, // … - HorizontalEllipsis - {0x03c0, '{', 0xe3, 'n'}, // π - Pi - {0x207F, 'I', 0xfc, ' '}, // ⁿ - SuperscriptLatinSmallLetterN - {0x2265, 'z', 0xf2, '>'}, // ≥ - GreaterThanOrEqualTo - {0x2264, 'y', 0xf3, '<'}, // ≤ - LessThanOrEqualTo - {0x2260, 0, 0xd8, '#'}, // ≠ - NotEqualTo - {0x00b1, 'g', 0xf1, '#'}, // ± - PlusMinus - {0x00f7, '/', 0xf6, '/'}, // ÷ - Division sign - {0x00d7, 0, 'x', 'x'}, // × - Multiplication sign - {0x02e3, '~', 0xfc, '`'}, // ˣ - Modifier letter small x - {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) - {0x2409, 'b', ' ', ' '}, // ␉ - SymbolForHorizontalTab (1) - {0x240c, 'c', ' ', ' '}, // ␌ - SymbolForFormFeed (1) - {0x240d, 'd', ' ', ' '}, // ␍ - SymbolForCarriageReturn (1) - {0x240a, 'e', ' ', ' '}, // ␊ - SymbolForLineFeed (1) - {0x2592, 'a', 0xb0, '#'}, // ▒ - MediumShade - {0x2588, '0', 0xdb, '#'}, // █ - FullBlock - {0x25ae, '_', 0xfe, '#'}, // ▮ - BlackVerticalRectangle (1) - {0x258c, 0, 0xdd, ' '}, // ▌ - LeftHalfBlock - {0x2590, 0, 0xde, ' '}, // ▐ - RightHalfBlock - {0x2584, 0, 0xdc, ' '}, // ▄ - LowerHalfBlock - {0x2580, 0, 0xdf, ' '}, // ▀ - UpperHalfBlock - {0x2500, 'q', 0xc4, '-'}, // ─ - BoxDrawingsHorizontal - {0x2502, 'x', 0xb3, '|'}, // │ - BoxDrawingsVertical - {0x250c, 'l', 0xda, '.'}, // ┌ - BoxDrawingsDownAndRight - {0x2510, 'k', 0xbf, '.'}, // ┐ - BoxDrawingsDownAndLeft - {0x2514, 'm', 0xc0, '`'}, // └ - BoxDrawingsUpAndRight - {0x2518, 'j', 0xd9, '\''}, // ┘ - BoxDrawingsUpAndLeft - {0x253c, 'n', 0xc5, '+'}, // ┼ - BoxDrawingsCross - {0x252c, 'w', 0xc2, '+'}, // ┬ - BoxDrawingsDownAndHorizontal - {0x2524, 'u', 0xb4, '+'}, // ┤ - BoxDrawingsVerticalAndLeft - {0x251c, 't', 0xc3, '+'}, // ├ - BoxDrawingsVerticalAndRight - {0x2534, 'v', 0xc1, '+'}, // ┴ - BoxDrawingsUpAndHorizontal - {0x23ba, 'o', '~', '~'}, // ⎺ - HorizontalScanLine1 (1) - {0x23bb, 'p', 0xc4, '-'}, // ⎻ - HorizontalScanLine3 (1) - {0x23bc, 'r', 0xc4, '-'}, // ⎼ - HorizontalScanLine7 (1) - {0x23bd, 's', '_', '_'}, // ⎽ - HorizontalScanLine9 (1) - {0x25b2, '-', 0x1e, '^'}, // ▲ - BlackUpPointingTriangle - {0x25bc, '.', 0x1f, 'v'}, // ▼ - BlackDownPointingTriangle - {0x25b6, '+', 0x10, '>'}, // ▶ - BlackRightPointingTriangle - {0x25c0, ',', 0x11, '<'}, // ◀ - BlackLeftPointingTriangle (1) - {0x25ba, '+', 0x10, '>'}, // ► - BlackRightPointingPointer (1) - {0x25c4, ',', 0x11, '<'}, // ◄ - BlackLeftPointingPointer - {0xe1b3, 'x', 0xb3, '|'}, // │ - NF_border_line_vertical (2) - {0xe1b4, 0, 0xb4, 0}, // ⊐ - NF_rev_left_arrow2 (2) - {0xe1b5, 0, 0xb5, 0}, // ► - NF_rev_right_arrow2 (2) - {0xe1b6, 0, 0xb6, 0}, // ╵ - NF_border_line_left_up (2) - {0xe1b7, 0, 0xb7, 0}, // ) - NF_radio_button3 (2) - {0xe1b8, 0, 0xb8, 0}, // ⎤ - NF_rev_border_corner_upper_right (2) - {0xe1b9, 0, 0xb9, 0}, // ⎹ - NF_rev_border_line_right (2) - {0xe1ba, 0, 0xba, 0}, // ┤ - NF_rev_border_line_vertical_left (2) - {0xe1bb, 0, 0xbb, 0}, // ⎦ - NF_rev_border_corner_lower_right (2) - {0xe1bc, 0, 0xbc, 0}, // ⎸ - NF_border_line_left (2) - {0xe1bd, 0, 0xbd, 0}, //⎹◣ - NF_rev_up_arrow2 (2) - {0xe1be, 0, 0xbe, 0}, //⎹◤ - NF_rev_down_arrow2 (2) - {0xe1bf, 0, 0xbf, 0}, // ╷ - NF_border_line_left_down (2) - {0xe1c0, 0, 0xc0, 0}, // └ - NF_border_corner_middle_lower_left (2) - {0xe1c1, 0, 0xc1, 0}, // ◢⎸ - NF_rev_up_arrow1 (2) - {0xe1c2, 0, 0xc2, 0}, // ◥⎸ - NF_rev_down_arrow1 (2) - {0xe1c3, 0, 0xc3, 0}, // ├ - NF_border_line_vertical_right (2) - {0xe1c4, 'q', 0xc4, '-'}, // ─ - NF_border_line_horizontal (2) - {0xe1c5, 0, 0xc5, 0}, // = - NF_border_line_up_and_down (2) - {0xe1c6, 0, 0xc6, 0}, // = - NF_shadow_box_middle (2) - {0xe1c7, 0, 0xc7, 0}, // = - NF_shadow_box_hdd (2) - {0xe1c8, 0, 0xc8, 0}, // ◄ - NF_rev_left_arrow1 (2) - {0xe1c9, 0, 0xc9, 0}, // ⊏ - NF_rev_right_arrow1 (2) - {0xe1ca, 0, 0xca, 0}, // [ - NF_rev_menu_button1 (2) - {0xe1cb, 0, 0xcb, 0}, // - - NF_rev_menu_button2 (2) - {0xe1cc, 0, 0xcc, 0}, // ┌ - NF_border_corner_middle_upper_left (2) - {0xe1cd, 0, 0xcd, 0}, // = - NF_shadow_box_cd (2) - {0xe1ce, 0, 0xce, 0}, // [ - NF_shadow_box_left (2) - {0xe1cf, 0, 0xcf, 0}, // ┌ - NF_border_line_middle_left_down (2) - {0xe1d0, 0, 0xd0, 0}, // └ - NF_border_line_middle_right_up (2) - {0xe1d1, 0, 0xd1, 0}, // = - NF_shadow_box_net (2) - {0xe1d2, 0, 0xd2, 0}, // ◢ - NF_rev_up_pointing_triangle1 (2) - {0xe1d3, 0, 0xd3, 0}, // ⎣ - NF_border_corner_lower_left (2) - {0xe1d4, 0, 0xd4, 0}, // _ - NF_border_line_bottom (2) - {0xe1d5, 0, 0xd5, 0}, // O - NF_radio_button2 (2) - {0xe1d6, 0, 0xd6, 0}, // ● - NF_radio_button2_checked (2) - {0xe1d7, 0, 0xd7, 0}, // ◥ - NF_rev_down_pointing_triangle1 (2) - {0xe1d8, 0, 0xd8, 0}, // ¯ - NF_border_line_upper (2) - {0xe1d9, 0, 0xd9, 0}, // ( - NF_radio_button1 (2) - {0xe1da, 0, 0xda, 0}, // ⎡ - NF_border_corner_upper_left (2) - {0xe1dc, 0, 0xdc, 0}, // ✓ - NF_shadow_box_checked (2) - {0xe1e7, 0, 0xe7, 0}, // ║ - NF_rev_border_line_right_and_left (2) - {0xe1e8, 0, 0xe8, 0}, // ◣ - NF_rev_up_pointing_triangle2 (2) - {0xe1e9, 0, 0xe9, 0}, // ◤ - NF_rev_down_pointing_triangle2 (2) - {0xe1ea, 0, 0xea, 0}, // ┘ - NF_border_corner_middle_lower_right (2) - {0xe1eb, 0, 0xeb, 0}, // ┐ - NF_border_corner_middle_upper_right (2) - {0xe1f4, 0, 0xf4, 0}, // ] - NF_rev_menu_button3 (2) - {0xe1f5, 0, 0xf5, 0}, // ] - NF_shadow_box_right (2) - {0xe1fb, 0, 0xfb, 0}, // ✓ - NF_check_mark (2) - {0xe1fc, '~', 0xfc, '`'}, // ˣ - NF_xsuperior (2) - {0x221a, 0, 0xfb, 'x'} // √ - square root -}; + {{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 + {{0x203a, '>', 0xaf, '>'}}, // › - SingleRightAngleQuotationMark + {{0x2039, '<', 0xae, '<'}}, // ‹ - SingleLeftAngleQuotationMark + {{0x2026, '.', '.', '.'}}, // … - HorizontalEllipsis + {{0x03c0, '{', 0xe3, 'n'}}, // π - Pi + {{0x207F, 'I', 0xfc, ' '}}, // ⁿ - SuperscriptLatinSmallLetterN + {{0x2265, 'z', 0xf2, '>'}}, // ≥ - GreaterThanOrEqualTo + {{0x2264, 'y', 0xf3, '<'}}, // ≤ - LessThanOrEqualTo + {{0x2260, 0, 0xd8, '#'}}, // ≠ - NotEqualTo + {{0x00b1, 'g', 0xf1, '#'}}, // ± - PlusMinus + {{0x00f7, '/', 0xf6, '/'}}, // ÷ - Division sign + {{0x00d7, 0, 'x', 'x'}}, // × - Multiplication sign + {{0x02e3, '~', 0xfc, '`'}}, // ˣ - Modifier letter small x + {{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) + {{0x2409, 'b', ' ', ' '}}, // ␉ - SymbolForHorizontalTab (1) + {{0x240c, 'c', ' ', ' '}}, // ␌ - SymbolForFormFeed (1) + {{0x240d, 'd', ' ', ' '}}, // ␍ - SymbolForCarriageReturn (1) + {{0x240a, 'e', ' ', ' '}}, // ␊ - SymbolForLineFeed (1) + {{0x2592, 'a', 0xb0, '#'}}, // ▒ - MediumShade + {{0x2588, '0', 0xdb, '#'}}, // █ - FullBlock + {{0x25ae, '_', 0xfe, '#'}}, // ▮ - BlackVerticalRectangle (1) + {{0x258c, 0, 0xdd, ' '}}, // ▌ - LeftHalfBlock + {{0x2590, 0, 0xde, ' '}}, // ▐ - RightHalfBlock + {{0x2584, 0, 0xdc, ' '}}, // ▄ - LowerHalfBlock + {{0x2580, 0, 0xdf, ' '}}, // ▀ - UpperHalfBlock + {{0x2500, 'q', 0xc4, '-'}}, // ─ - BoxDrawingsHorizontal + {{0x2502, 'x', 0xb3, '|'}}, // │ - BoxDrawingsVertical + {{0x250c, 'l', 0xda, '.'}}, // ┌ - BoxDrawingsDownAndRight + {{0x2510, 'k', 0xbf, '.'}}, // ┐ - BoxDrawingsDownAndLeft + {{0x2514, 'm', 0xc0, '`'}}, // └ - BoxDrawingsUpAndRight + {{0x2518, 'j', 0xd9, '\''}}, // ┘ - BoxDrawingsUpAndLeft + {{0x253c, 'n', 0xc5, '+'}}, // ┼ - BoxDrawingsCross + {{0x252c, 'w', 0xc2, '+'}}, // ┬ - BoxDrawingsDownAndHorizontal + {{0x2524, 'u', 0xb4, '+'}}, // ┤ - BoxDrawingsVerticalAndLeft + {{0x251c, 't', 0xc3, '+'}}, // ├ - BoxDrawingsVerticalAndRight + {{0x2534, 'v', 0xc1, '+'}}, // ┴ - BoxDrawingsUpAndHorizontal + {{0x23ba, 'o', '~', '~'}}, // ⎺ - HorizontalScanLine1 (1) + {{0x23bb, 'p', 0xc4, '-'}}, // ⎻ - HorizontalScanLine3 (1) + {{0x23bc, 'r', 0xc4, '-'}}, // ⎼ - HorizontalScanLine7 (1) + {{0x23bd, 's', '_', '_'}}, // ⎽ - HorizontalScanLine9 (1) + {{0x25b2, '-', 0x1e, '^'}}, // ▲ - BlackUpPointingTriangle + {{0x25bc, '.', 0x1f, 'v'}}, // ▼ - BlackDownPointingTriangle + {{0x25b6, '+', 0x10, '>'}}, // ▶ - BlackRightPointingTriangle + {{0x25c0, ',', 0x11, '<'}}, // ◀ - BlackLeftPointingTriangle (1) + {{0x25ba, '+', 0x10, '>'}}, // ► - BlackRightPointingPointer (1) + {{0x25c4, ',', 0x11, '<'}}, // ◄ - BlackLeftPointingPointer + {{0xe1b3, 'x', 0xb3, '|'}}, // │ - NF_border_line_vertical (2) + {{0xe1b4, 0, 0xb4, 0}}, // ⊐ - NF_rev_left_arrow2 (2) + {{0xe1b5, 0, 0xb5, 0}}, // ► - NF_rev_right_arrow2 (2) + {{0xe1b6, 0, 0xb6, 0}}, // ╵ - NF_border_line_left_up (2) + {{0xe1b7, 0, 0xb7, 0}}, // ) - NF_radio_button3 (2) + {{0xe1b8, 0, 0xb8, 0}}, // ⎤ - NF_rev_border_corner_upper_right (2) + {{0xe1b9, 0, 0xb9, 0}}, // ⎹ - NF_rev_border_line_right (2) + {{0xe1ba, 0, 0xba, 0}}, // ┤ - NF_rev_border_line_vertical_left (2) + {{0xe1bb, 0, 0xbb, 0}}, // ⎦ - NF_rev_border_corner_lower_right (2) + {{0xe1bc, 0, 0xbc, 0}}, // ⎸ - NF_border_line_left (2) + {{0xe1bd, 0, 0xbd, 0}}, //⎹◣ - NF_rev_up_arrow2 (2) + {{0xe1be, 0, 0xbe, 0}}, //⎹◤ - NF_rev_down_arrow2 (2) + {{0xe1bf, 0, 0xbf, 0}}, // ╷ - NF_border_line_left_down (2) + {{0xe1c0, 0, 0xc0, 0}}, // └ - NF_border_corner_middle_lower_left (2) + {{0xe1c1, 0, 0xc1, 0}}, // ◢⎸ - NF_rev_up_arrow1 (2) + {{0xe1c2, 0, 0xc2, 0}}, // ◥⎸ - NF_rev_down_arrow1 (2) + {{0xe1c3, 0, 0xc3, 0}}, // ├ - NF_border_line_vertical_right (2) + {{0xe1c4, 'q', 0xc4, '-'}}, // ─ - NF_border_line_horizontal (2) + {{0xe1c5, 0, 0xc5, 0}}, // = - NF_border_line_up_and_down (2) + {{0xe1c6, 0, 0xc6, 0}}, // = - NF_shadow_box_middle (2) + {{0xe1c7, 0, 0xc7, 0}}, // = - NF_shadow_box_hdd (2) + {{0xe1c8, 0, 0xc8, 0}}, // ◄ - NF_rev_left_arrow1 (2) + {{0xe1c9, 0, 0xc9, 0}}, // ⊏ - NF_rev_right_arrow1 (2) + {{0xe1ca, 0, 0xca, 0}}, // [ - NF_rev_menu_button1 (2) + {{0xe1cb, 0, 0xcb, 0}}, // - - NF_rev_menu_button2 (2) + {{0xe1cc, 0, 0xcc, 0}}, // ┌ - NF_border_corner_middle_upper_left (2) + {{0xe1cd, 0, 0xcd, 0}}, // = - NF_shadow_box_cd (2) + {{0xe1ce, 0, 0xce, 0}}, // [ - NF_shadow_box_left (2) + {{0xe1cf, 0, 0xcf, 0}}, // ┌ - NF_border_line_middle_left_down (2) + {{0xe1d0, 0, 0xd0, 0}}, // └ - NF_border_line_middle_right_up (2) + {{0xe1d1, 0, 0xd1, 0}}, // = - NF_shadow_box_net (2) + {{0xe1d2, 0, 0xd2, 0}}, // ◢ - NF_rev_up_pointing_triangle1 (2) + {{0xe1d3, 0, 0xd3, 0}}, // ⎣ - NF_border_corner_lower_left (2) + {{0xe1d4, 0, 0xd4, 0}}, // _ - NF_border_line_bottom (2) + {{0xe1d5, 0, 0xd5, 0}}, // O - NF_radio_button2 (2) + {{0xe1d6, 0, 0xd6, 0}}, // ● - NF_radio_button2_checked (2) + {{0xe1d7, 0, 0xd7, 0}}, // ◥ - NF_rev_down_pointing_triangle1 (2) + {{0xe1d8, 0, 0xd8, 0}}, // ¯ - NF_border_line_upper (2) + {{0xe1d9, 0, 0xd9, 0}}, // ( - NF_radio_button1 (2) + {{0xe1da, 0, 0xda, 0}}, // ⎡ - NF_border_corner_upper_left (2) + {{0xe1dc, 0, 0xdc, 0}}, // ✓ - NF_shadow_box_checked (2) + {{0xe1e7, 0, 0xe7, 0}}, // ║ - NF_rev_border_line_right_and_left (2) + {{0xe1e8, 0, 0xe8, 0}}, // ◣ - NF_rev_up_pointing_triangle2 (2) + {{0xe1e9, 0, 0xe9, 0}}, // ◤ - NF_rev_down_pointing_triangle2 (2) + {{0xe1ea, 0, 0xea, 0}}, // ┘ - NF_border_corner_middle_lower_right (2) + {{0xe1eb, 0, 0xeb, 0}}, // ┐ - NF_border_corner_middle_upper_right (2) + {{0xe1f4, 0, 0xf4, 0}}, // ] - NF_rev_menu_button3 (2) + {{0xe1f5, 0, 0xf5, 0}}, // ] - NF_shadow_box_right (2) + {{0xe1fb, 0, 0xfb, 0}}, // ✓ - NF_check_mark (2) + {{0xe1fc, '~', 0xfc, '`'}}, // ˣ - NF_xsuperior (2) + {{0x221a, 0, 0xfb, 'x'}} // √ - square root +}}; /* * (1) Not defined in Windows Glyph List 4 (WGL4) * (2) Only supported in use with newfont */ -constexpr std::size_t last_char_item = \ - std::size_t((sizeof(character) / sizeof(character[0])) - 1); +constexpr std::array, 39> vt100_key_to_utf8 = +{{ + {{fc::vt100_key_rarrow , fc::BlackRightPointingPointer}}, // ► + {{fc::vt100_key_larrow , fc::BlackLeftPointingPointer}}, // ◄ + {{fc::vt100_key_uarrow , fc::BlackUpPointingTriangle}}, // ▲ + {{fc::vt100_key_darrow , fc::BlackDownPointingTriangle}}, // ▼ + {{fc::vt100_key_block , fc::FullBlock}}, // █ + {{fc::vt100_key_nsup , fc::SuperscriptLatinSmallLetterN}}, // ⁿ + {{fc::vt100_key_blackrect, fc::BlackVerticalRectangle}}, // ▮ + {{fc::vt100_key_diamond , fc::BlackDiamondSuit}}, // ◆ + {{fc::vt100_key_ckboard , fc::MediumShade}}, // ▒ + {{fc::vt100_key_htab , fc::SymbolForHorizontalTab}}, // ␉ + {{fc::vt100_key_ff , fc::SymbolForFormFeed}}, // ␌ + {{fc::vt100_key_cr , fc::SymbolForCarriageReturn}}, // ␍ + {{fc::vt100_key_lf , fc::SymbolForLineFeed}}, // ␊ + {{fc::vt100_key_degree , fc::Degree}}, // ° + {{fc::vt100_key_plminus , fc::PlusMinus}}, // ± + {{fc::vt100_key_board , fc::SymbolForNewline}}, // ␤ + {{fc::vt100_key_lantern , fc::SymbolForVerticalTab}}, // ␋ + {{fc::vt100_key_lrcorner , fc::BoxDrawingsUpAndLeft}}, // ┘ + {{fc::vt100_key_urcorner , fc::BoxDrawingsDownAndLeft}}, // ┐ + {{fc::vt100_key_ulcorner , fc::BoxDrawingsDownAndRight}}, // ┌ + {{fc::vt100_key_llcorner , fc::BoxDrawingsUpAndRight}}, // └ + {{fc::vt100_key_plus , fc::BoxDrawingsCross}}, // ┼ + {{fc::vt100_key_s1 , fc::HorizontalScanLine1}}, // ⎺ + {{fc::vt100_key_s3 , fc::HorizontalScanLine3}}, // ⎻ + {{fc::vt100_key_hline , fc::BoxDrawingsHorizontal}}, // ─ + {{fc::vt100_key_s7 , fc::HorizontalScanLine7}}, // ⎼ + {{fc::vt100_key_s9 , fc::HorizontalScanLine9}}, // ⎽ + {{fc::vt100_key_ltee , fc::BoxDrawingsVerticalAndRight}}, // ├ + {{fc::vt100_key_rtee , fc::BoxDrawingsVerticalAndLeft}}, // ┤ + {{fc::vt100_key_btee , fc::BoxDrawingsUpAndHorizontal}}, // ┴ + {{fc::vt100_key_ttee , fc::BoxDrawingsDownAndHorizontal}}, // ┬ + {{fc::vt100_key_vline , fc::BoxDrawingsVertical}}, // │ + {{fc::vt100_key_lequal , fc::LessThanOrEqualTo}}, // ≤ + {{fc::vt100_key_gequal , fc::GreaterThanOrEqualTo}}, // ≥ + {{fc::vt100_key_pi , fc::Pi}}, // π + {{fc::vt100_key_nequal , fc::NotEqualTo}}, // ≠ + {{fc::vt100_key_sterling , fc::Pound}}, // £ + {{fc::vt100_key_bullet , fc::SmallBullet}}, // · + {{fc::vt100_key_diamond , fc::Bullet}} // ◆ +}}; - -constexpr int vt100_key_to_utf8[][2] = -{ - {fc::vt100_key_rarrow , fc::BlackRightPointingPointer}, // ► - {fc::vt100_key_larrow , fc::BlackLeftPointingPointer}, // ◄ - {fc::vt100_key_uarrow , fc::BlackUpPointingTriangle}, // ▲ - {fc::vt100_key_darrow , fc::BlackDownPointingTriangle}, // ▼ - {fc::vt100_key_block , fc::FullBlock}, // █ - {fc::vt100_key_nsup , fc::SuperscriptLatinSmallLetterN}, // ⁿ - {fc::vt100_key_blackrect, fc::BlackVerticalRectangle}, // ▮ - {fc::vt100_key_diamond , fc::BlackDiamondSuit}, // ◆ - {fc::vt100_key_ckboard , fc::MediumShade}, // ▒ - {fc::vt100_key_htab , fc::SymbolForHorizontalTab}, // ␉ - {fc::vt100_key_ff , fc::SymbolForFormFeed}, // ␌ - {fc::vt100_key_cr , fc::SymbolForCarriageReturn}, // ␍ - {fc::vt100_key_lf , fc::SymbolForLineFeed}, // ␊ - {fc::vt100_key_degree , fc::Degree}, // ° - {fc::vt100_key_plminus , fc::PlusMinus}, // ± - {fc::vt100_key_board , fc::SymbolForNewline}, // ␤ - {fc::vt100_key_lantern , fc::SymbolForVerticalTab}, // ␋ - {fc::vt100_key_lrcorner , fc::BoxDrawingsUpAndLeft}, // ┘ - {fc::vt100_key_urcorner , fc::BoxDrawingsDownAndLeft}, // ┐ - {fc::vt100_key_ulcorner , fc::BoxDrawingsDownAndRight}, // ┌ - {fc::vt100_key_llcorner , fc::BoxDrawingsUpAndRight}, // └ - {fc::vt100_key_plus , fc::BoxDrawingsCross}, // ┼ - {fc::vt100_key_s1 , fc::HorizontalScanLine1}, // ⎺ - {fc::vt100_key_s3 , fc::HorizontalScanLine3}, // ⎻ - {fc::vt100_key_hline , fc::BoxDrawingsHorizontal}, // ─ - {fc::vt100_key_s7 , fc::HorizontalScanLine7}, // ⎼ - {fc::vt100_key_s9 , fc::HorizontalScanLine9}, // ⎽ - {fc::vt100_key_ltee , fc::BoxDrawingsVerticalAndRight}, // ├ - {fc::vt100_key_rtee , fc::BoxDrawingsVerticalAndLeft}, // ┤ - {fc::vt100_key_btee , fc::BoxDrawingsUpAndHorizontal}, // ┴ - {fc::vt100_key_ttee , fc::BoxDrawingsDownAndHorizontal}, // ┬ - {fc::vt100_key_vline , fc::BoxDrawingsVertical}, // │ - {fc::vt100_key_lequal , fc::LessThanOrEqualTo}, // ≤ - {fc::vt100_key_gequal , fc::GreaterThanOrEqualTo}, // ≥ - {fc::vt100_key_pi , fc::Pi}, // π - {fc::vt100_key_nequal , fc::NotEqualTo}, // ≠ - {fc::vt100_key_sterling , fc::Pound}, // £ - {fc::vt100_key_bullet , fc::SmallBullet}, // · - {fc::vt100_key_diamond , fc::Bullet} // ◆ -}; - -constexpr std::size_t last_key_item = \ - std::size_t((sizeof(vt100_key_to_utf8) / sizeof(vt100_key_to_utf8[0])) - 1); - - -constexpr wchar_t cp437_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 - {0x83, 0x00e2}, // latin small letter a with circumflex - {0x84, 0x00e4}, // latin small letter a with diaeresis - {0x85, 0x00e0}, // latin small letter a with grave - {0x86, 0x00e5}, // latin small letter a with ring above - {0x87, 0x00e7}, // latin small letter c with cedilla - {0x88, 0x00ea}, // latin small letter e with circumflex - {0x89, 0x00eb}, // latin small letter e with diaeresis - {0x8a, 0x00e8}, // latin small letter e with grave - {0x8b, 0x00ef}, // latin small letter i with diaeresis - {0x8c, 0x00ee}, // latin small letter i with circumflex - {0x8d, 0x00ec}, // latin small letter i with grave - {0x8e, 0x00c4}, // latin capital letter a with diaeresis - {0x8f, 0x00c5}, // latin capital letter a with ring above - {0x90, 0x00c9}, // latin capital letter e with acute - {0x91, 0x00e6}, // latin small ligature ae - {0x92, 0x00c6}, // latin capital ligature ae - {0x93, 0x00f4}, // latin small letter o with circumflex - {0x94, 0x00f6}, // latin small letter o with diaeresis - {0x95, 0x00f2}, // latin small letter o with grave - {0x96, 0x00fb}, // latin small letter u with circumflex - {0x97, 0x00f9}, // latin small letter u with grave - {0x98, 0x00ff}, // latin small letter y with diaeresis - {0x99, 0x00d6}, // latin capital letter o with diaeresis - {0x9a, 0x00dc}, // latin capital letter u with diaeresis - {0x9b, 0x00a2}, // cent sign - {0x9c, 0x00a3}, // pound sign - {0x9d, 0x00a5}, // yen sign - {0x9e, 0x20a7}, // peseta sign - {0x9f, 0x0192}, // latin small letter f with hook - {0xa0, 0x00e1}, // latin small letter a with acute - {0xa1, 0x00ed}, // latin small letter i with acute - {0xa2, 0x00f3}, // latin small letter o with acute - {0xa3, 0x00fa}, // latin small letter u with acute - {0xa4, 0x00f1}, // latin small letter n with tilde - {0xa5, 0x00d1}, // latin capital letter n with tilde - {0xa6, 0x00aa}, // feminine ordinal indicator - {0xa7, 0x00ba}, // masculine ordinal indicator - {0xa8, 0x00bf}, // inverted question mark - {0xa9, 0x2310}, // reversed not sign - {0xaa, 0x00ac}, // not sign - {0xab, 0x00bd}, // vulgar fraction one half - {0xac, 0x00bc}, // vulgar fraction one quarter - {0xad, 0x00a1}, // inverted exclamation mark - {0xae, 0x00ab}, // left-pointing double angle quotation mark - {0xaf, 0x00bb}, // right-pointing double angle quotation mark - {0xb0, 0x2591}, // light shade - {0xb1, 0x2592}, // medium shade - {0xb2, 0x2593}, // dark shade - {0xb3, 0x2502}, // box drawings light vertical - {0xb4, 0x2524}, // box drawings light vertical and left - {0xb5, 0x2561}, // box drawings vertical single and left double - {0xb6, 0x2562}, // box drawings vertical double and left single - {0xb7, 0x2556}, // box drawings down double and left single - {0xb8, 0x2555}, // box drawings down single and left double - {0xb9, 0x2563}, // box drawings double vertical and left - {0xba, 0x2551}, // box drawings double vertical - {0xbb, 0x2557}, // box drawings double down and left - {0xbc, 0x255d}, // box drawings double up and left - {0xbd, 0x255c}, // box drawings up double and left single - {0xbe, 0x255b}, // box drawings up single and left double - {0xbf, 0x2510}, // box drawings light down and left - {0xc0, 0x2514}, // box drawings light up and right - {0xc1, 0x2534}, // box drawings light up and horizontal - {0xc2, 0x252c}, // box drawings light down and horizontal - {0xc3, 0x251c}, // box drawings light vertical and right - {0xc4, 0x2500}, // box drawings light horizontal - {0xc5, 0x253c}, // box drawings light vertical and horizontal - {0xc6, 0x255e}, // box drawings vertical single and right double - {0xc7, 0x255f}, // box drawings vertical double and right single - {0xc8, 0x255a}, // box drawings double up and right - {0xc9, 0x2554}, // box drawings double down and right - {0xca, 0x2569}, // box drawings double up and horizontal - {0xcb, 0x2566}, // box drawings double down and horizontal - {0xcc, 0x2560}, // box drawings double vertical and right - {0xcd, 0x2550}, // box drawings double horizontal - {0xce, 0x256c}, // box drawings double vertical and horizontal - {0xcf, 0x2567}, // box drawings up single and horizontal double - {0xd0, 0x2568}, // box drawings up double and horizontal single - {0xd1, 0x2564}, // box drawings down single and horizontal double - {0xd2, 0x2565}, // box drawings down double and horizontal single - {0xd3, 0x2559}, // box drawings up double and right single - {0xd4, 0x2558}, // box drawings up single and right double - {0xd5, 0x2552}, // box drawings down single and right double - {0xd6, 0x2553}, // box drawings down double and right single - {0xd7, 0x256b}, // box drawings vertical double and horizontal single - {0xd8, 0x256a}, // box drawings vertical single and horizontal double - {0xd9, 0x2518}, // box drawings light up and left - {0xda, 0x250c}, // box drawings light down and right - {0xdb, 0x2588}, // full block - {0xdc, 0x2584}, // lower half block - {0xdd, 0x258c}, // left half block - {0xde, 0x2590}, // right half block - {0xdf, 0x2580}, // upper half block - {0xe0, 0x03b1}, // greek small letter alpha - {0xe1, 0x00df}, // latin small letter sharp s - {0xe2, 0x0393}, // greek capital letter gamma - {0xe3, 0x03c0}, // greek small letter pi - {0xe4, 0x03a3}, // greek capital letter sigma - {0xe5, 0x03c3}, // greek small letter sigma - {0xe6, 0x00b5}, // micro sign - {0xe7, 0x03c4}, // greek small letter tau - {0xe8, 0x03a6}, // greek capital letter phi - {0xe9, 0x0398}, // greek capital letter theta - {0xea, 0x03a9}, // greek capital letter omega - {0xeb, 0x03b4}, // greek small letter delta - {0xec, 0x221e}, // infinity - {0xed, 0x03c6}, // greek small letter phi - {0xee, 0x03b5}, // greek small letter epsilon - {0xef, 0x2229}, // intersection - {0xf0, 0x2261}, // identical to - {0xf1, 0x00b1}, // plus-minus sign - {0xf2, 0x2265}, // greater-than or equal to - {0xf3, 0x2264}, // less-than or equal to - {0xf4, 0x2320}, // top half integral - {0xf5, 0x2321}, // bottom half integral - {0xf6, 0x00f7}, // division sign - {0xf7, 0x2248}, // almost equal to - {0xf8, 0x00b0}, // degree sign - {0xf9, 0x2219}, // bullet operator - {0xfa, 0x00b7}, // middle dot - {0xfb, 0x221a}, // square root - {0xfc, 0x207f}, // superscript latin small letter n - {0xfd, 0x00b2}, // superscript two - {0xfe, 0x25a0}, // black square - {0xff, 0x00a0} // no-break space -}; - -constexpr std::size_t last_cp437_item = \ - std::size_t((sizeof(cp437_ucs) / sizeof(cp437_ucs[0])) - 1); +constexpr std::array, 256> cp437_ucs = +{{ + {{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 + {{0x83, 0x00e2}}, // latin small letter a with circumflex + {{0x84, 0x00e4}}, // latin small letter a with diaeresis + {{0x85, 0x00e0}}, // latin small letter a with grave + {{0x86, 0x00e5}}, // latin small letter a with ring above + {{0x87, 0x00e7}}, // latin small letter c with cedilla + {{0x88, 0x00ea}}, // latin small letter e with circumflex + {{0x89, 0x00eb}}, // latin small letter e with diaeresis + {{0x8a, 0x00e8}}, // latin small letter e with grave + {{0x8b, 0x00ef}}, // latin small letter i with diaeresis + {{0x8c, 0x00ee}}, // latin small letter i with circumflex + {{0x8d, 0x00ec}}, // latin small letter i with grave + {{0x8e, 0x00c4}}, // latin capital letter a with diaeresis + {{0x8f, 0x00c5}}, // latin capital letter a with ring above + {{0x90, 0x00c9}}, // latin capital letter e with acute + {{0x91, 0x00e6}}, // latin small ligature ae + {{0x92, 0x00c6}}, // latin capital ligature ae + {{0x93, 0x00f4}}, // latin small letter o with circumflex + {{0x94, 0x00f6}}, // latin small letter o with diaeresis + {{0x95, 0x00f2}}, // latin small letter o with grave + {{0x96, 0x00fb}}, // latin small letter u with circumflex + {{0x97, 0x00f9}}, // latin small letter u with grave + {{0x98, 0x00ff}}, // latin small letter y with diaeresis + {{0x99, 0x00d6}}, // latin capital letter o with diaeresis + {{0x9a, 0x00dc}}, // latin capital letter u with diaeresis + {{0x9b, 0x00a2}}, // cent sign + {{0x9c, 0x00a3}}, // pound sign + {{0x9d, 0x00a5}}, // yen sign + {{0x9e, 0x20a7}}, // peseta sign + {{0x9f, 0x0192}}, // latin small letter f with hook + {{0xa0, 0x00e1}}, // latin small letter a with acute + {{0xa1, 0x00ed}}, // latin small letter i with acute + {{0xa2, 0x00f3}}, // latin small letter o with acute + {{0xa3, 0x00fa}}, // latin small letter u with acute + {{0xa4, 0x00f1}}, // latin small letter n with tilde + {{0xa5, 0x00d1}}, // latin capital letter n with tilde + {{0xa6, 0x00aa}}, // feminine ordinal indicator + {{0xa7, 0x00ba}}, // masculine ordinal indicator + {{0xa8, 0x00bf}}, // inverted question mark + {{0xa9, 0x2310}}, // reversed not sign + {{0xaa, 0x00ac}}, // not sign + {{0xab, 0x00bd}}, // vulgar fraction one half + {{0xac, 0x00bc}}, // vulgar fraction one quarter + {{0xad, 0x00a1}}, // inverted exclamation mark + {{0xae, 0x00ab}}, // left-pointing double angle quotation mark + {{0xaf, 0x00bb}}, // right-pointing double angle quotation mark + {{0xb0, 0x2591}}, // light shade + {{0xb1, 0x2592}}, // medium shade + {{0xb2, 0x2593}}, // dark shade + {{0xb3, 0x2502}}, // box drawings light vertical + {{0xb4, 0x2524}}, // box drawings light vertical and left + {{0xb5, 0x2561}}, // box drawings vertical single and left double + {{0xb6, 0x2562}}, // box drawings vertical double and left single + {{0xb7, 0x2556}}, // box drawings down double and left single + {{0xb8, 0x2555}}, // box drawings down single and left double + {{0xb9, 0x2563}}, // box drawings double vertical and left + {{0xba, 0x2551}}, // box drawings double vertical + {{0xbb, 0x2557}}, // box drawings double down and left + {{0xbc, 0x255d}}, // box drawings double up and left + {{0xbd, 0x255c}}, // box drawings up double and left single + {{0xbe, 0x255b}}, // box drawings up single and left double + {{0xbf, 0x2510}}, // box drawings light down and left + {{0xc0, 0x2514}}, // box drawings light up and right + {{0xc1, 0x2534}}, // box drawings light up and horizontal + {{0xc2, 0x252c}}, // box drawings light down and horizontal + {{0xc3, 0x251c}}, // box drawings light vertical and right + {{0xc4, 0x2500}}, // box drawings light horizontal + {{0xc5, 0x253c}}, // box drawings light vertical and horizontal + {{0xc6, 0x255e}}, // box drawings vertical single and right double + {{0xc7, 0x255f}}, // box drawings vertical double and right single + {{0xc8, 0x255a}}, // box drawings double up and right + {{0xc9, 0x2554}}, // box drawings double down and right + {{0xca, 0x2569}}, // box drawings double up and horizontal + {{0xcb, 0x2566}}, // box drawings double down and horizontal + {{0xcc, 0x2560}}, // box drawings double vertical and right + {{0xcd, 0x2550}}, // box drawings double horizontal + {{0xce, 0x256c}}, // box drawings double vertical and horizontal + {{0xcf, 0x2567}}, // box drawings up single and horizontal double + {{0xd0, 0x2568}}, // box drawings up double and horizontal single + {{0xd1, 0x2564}}, // box drawings down single and horizontal double + {{0xd2, 0x2565}}, // box drawings down double and horizontal single + {{0xd3, 0x2559}}, // box drawings up double and right single + {{0xd4, 0x2558}}, // box drawings up single and right double + {{0xd5, 0x2552}}, // box drawings down single and right double + {{0xd6, 0x2553}}, // box drawings down double and right single + {{0xd7, 0x256b}}, // box drawings vertical double and horizontal single + {{0xd8, 0x256a}}, // box drawings vertical single and horizontal double + {{0xd9, 0x2518}}, // box drawings light up and left + {{0xda, 0x250c}}, // box drawings light down and right + {{0xdb, 0x2588}}, // full block + {{0xdc, 0x2584}}, // lower half block + {{0xdd, 0x258c}}, // left half block + {{0xde, 0x2590}}, // right half block + {{0xdf, 0x2580}}, // upper half block + {{0xe0, 0x03b1}}, // greek small letter alpha + {{0xe1, 0x00df}}, // latin small letter sharp s + {{0xe2, 0x0393}}, // greek capital letter gamma + {{0xe3, 0x03c0}}, // greek small letter pi + {{0xe4, 0x03a3}}, // greek capital letter sigma + {{0xe5, 0x03c3}}, // greek small letter sigma + {{0xe6, 0x00b5}}, // micro sign + {{0xe7, 0x03c4}}, // greek small letter tau + {{0xe8, 0x03a6}}, // greek capital letter phi + {{0xe9, 0x0398}}, // greek capital letter theta + {{0xea, 0x03a9}}, // greek capital letter omega + {{0xeb, 0x03b4}}, // greek small letter delta + {{0xec, 0x221e}}, // infinity + {{0xed, 0x03c6}}, // greek small letter phi + {{0xee, 0x03b5}}, // greek small letter epsilon + {{0xef, 0x2229}}, // intersection + {{0xf0, 0x2261}}, // identical to + {{0xf1, 0x00b1}}, // plus-minus sign + {{0xf2, 0x2265}}, // greater-than or equal to + {{0xf3, 0x2264}}, // less-than or equal to + {{0xf4, 0x2320}}, // top half integral + {{0xf5, 0x2321}}, // bottom half integral + {{0xf6, 0x00f7}}, // division sign + {{0xf7, 0x2248}}, // almost equal to + {{0xf8, 0x00b0}}, // degree sign + {{0xf9, 0x2219}}, // bullet operator + {{0xfa, 0x00b7}}, // middle dot + {{0xfb, 0x221a}}, // square root + {{0xfc, 0x207f}}, // superscript latin small letter n + {{0xfd, 0x00b2}}, // superscript two + {{0xfe, 0x25a0}}, // black square + {{0xff, 0x00a0}} // no-break space +}}; // Based on http://www.unicode.org/charts/PDF/UFF00.pdf -constexpr wchar_t halfwidth_fullwidth[][2] = -{ +constexpr std::array, 227> halfwidth_fullwidth = +{{ // Fullwidth ASCII variants - {0x0020, 0x3000}, // ' ' -> ' ' - {0x0021, 0xff01}, // ! -> ! - {0x0022, 0xff02}, // " -> " - {0x0023, 0xff03}, // # -> # - {0x0024, 0xff04}, // $ -> $ - {0x0025, 0xff05}, // % -> % - {0x0026, 0xff06}, // & -> & - {0x0027, 0xff07}, // ' -> ' - {0x0028, 0xff08}, // ( -> ( - {0x0029, 0xff09}, // ) -> ) - {0x002a, 0xff0a}, // * -> * - {0x002b, 0xff0b}, // + -> + - {0x002c, 0xff0c}, // , -> , - {0x002d, 0xff0d}, // - -> - - {0x002e, 0xff0e}, // . -> . - {0x002f, 0xff0f}, // / -> / - {0x0030, 0xff10}, // 0 -> 0 - {0x0031, 0xff11}, // 1 -> 1 - {0x0032, 0xff12}, // 2 -> 2 - {0x0033, 0xff13}, // 3 -> 3 - {0x0034, 0xff14}, // 4 -> 4 - {0x0035, 0xff15}, // 5 -> 5 - {0x0036, 0xff16}, // 6 -> 6 - {0x0037, 0xff17}, // 7 -> 7 - {0x0038, 0xff18}, // 8 -> 8 - {0x0039, 0xff19}, // 9 -> 9 - {0x003a, 0xff1a}, // : -> : - {0x003b, 0xff1b}, // ; -> ; - {0x003c, 0xff1c}, // < -> < - {0x003d, 0xff1d}, // = -> = - {0x003e, 0xff1e}, // > -> > - {0x003f, 0xff1f}, // ? -> ? - {0x0040, 0xff20}, // @ -> @ - {0x0041, 0xff21}, // A -> A - {0x0042, 0xff22}, // B -> B - {0x0043, 0xff23}, // C -> C - {0x0044, 0xff24}, // D -> D - {0x0045, 0xff25}, // E -> E - {0x0046, 0xff26}, // F -> F - {0x0047, 0xff27}, // G -> G - {0x0048, 0xff28}, // H -> H - {0x0049, 0xff29}, // I -> I - {0x004a, 0xff2a}, // J -> J - {0x004b, 0xff2b}, // K -> K - {0x004c, 0xff2c}, // L -> L - {0x004d, 0xff2d}, // M -> M - {0x004e, 0xff2e}, // N -> N - {0x004f, 0xff2f}, // O -> O - {0x0050, 0xff30}, // P -> P - {0x0051, 0xff31}, // Q -> Q - {0x0052, 0xff32}, // R -> R - {0x0053, 0xff33}, // S -> S - {0x0054, 0xff34}, // T -> T - {0x0055, 0xff35}, // U -> U - {0x0056, 0xff36}, // V -> V - {0x0057, 0xff37}, // W -> W - {0x0058, 0xff38}, // X -> X - {0x0059, 0xff39}, // Y -> Y - {0x005a, 0xff3a}, // Z -> Z - {0x005b, 0xff3b}, // [ -> [ - {0x005c, 0xff3c}, // \ -> \ - {0x005d, 0xff3c}, // ] -> ] - {0x005e, 0xff3e}, // ^ -> ^ - {0x005f, 0xff3f}, // _ -> _ - {0x0060, 0xff40}, // ` -> ` - {0x0061, 0xff41}, // a -> a - {0x0062, 0xff42}, // b -> b - {0x0063, 0xff43}, // c -> c - {0x0064, 0xff44}, // d -> d - {0x0065, 0xff45}, // e -> e - {0x0066, 0xff46}, // f -> f - {0x0067, 0xff47}, // g -> g - {0x0068, 0xff48}, // h -> h - {0x0069, 0xff49}, // i -> i - {0x006a, 0xff4a}, // j -> j - {0x006b, 0xff4b}, // k -> k - {0x006c, 0xff4c}, // l -> l - {0x006d, 0xff4d}, // m -> m - {0x006e, 0xff4e}, // n -> n - {0x006f, 0xff4f}, // o -> o - {0x0070, 0xff50}, // p -> p - {0x0071, 0xff51}, // q -> q - {0x0072, 0xff52}, // r -> r - {0x0073, 0xff53}, // s -> s - {0x0074, 0xff54}, // t -> t - {0x0075, 0xff55}, // u -> u - {0x0076, 0xff56}, // v -> v - {0x0077, 0xff57}, // w -> w - {0x0078, 0xff58}, // x -> x - {0x0079, 0xff59}, // y -> y - {0x007a, 0xff5a}, // z -> z - {0x007b, 0xff5b}, // { -> { - {0x007c, 0xff5c}, // | -> | - {0x007d, 0xff5d}, // } -> } - {0x007e, 0xff5e}, // ~ -> ~ - {0x007e, 0x0301}, // ~ -> 〜 + {{0x0020, 0x3000}}, // ' ' -> ' ' + {{0x0021, 0xff01}}, // ! -> ! + {{0x0022, 0xff02}}, // " -> " + {{0x0023, 0xff03}}, // # -> # + {{0x0024, 0xff04}}, // $ -> $ + {{0x0025, 0xff05}}, // % -> % + {{0x0026, 0xff06}}, // & -> & + {{0x0027, 0xff07}}, // ' -> ' + {{0x0028, 0xff08}}, // ( -> ( + {{0x0029, 0xff09}}, // ) -> ) + {{0x002a, 0xff0a}}, // * -> * + {{0x002b, 0xff0b}}, // + -> + + {{0x002c, 0xff0c}}, // , -> , + {{0x002d, 0xff0d}}, // - -> - + {{0x002e, 0xff0e}}, // . -> . + {{0x002f, 0xff0f}}, // / -> / + {{0x0030, 0xff10}}, // 0 -> 0 + {{0x0031, 0xff11}}, // 1 -> 1 + {{0x0032, 0xff12}}, // 2 -> 2 + {{0x0033, 0xff13}}, // 3 -> 3 + {{0x0034, 0xff14}}, // 4 -> 4 + {{0x0035, 0xff15}}, // 5 -> 5 + {{0x0036, 0xff16}}, // 6 -> 6 + {{0x0037, 0xff17}}, // 7 -> 7 + {{0x0038, 0xff18}}, // 8 -> 8 + {{0x0039, 0xff19}}, // 9 -> 9 + {{0x003a, 0xff1a}}, // : -> : + {{0x003b, 0xff1b}}, // ; -> ; + {{0x003c, 0xff1c}}, // < -> < + {{0x003d, 0xff1d}}, // = -> = + {{0x003e, 0xff1e}}, // > -> > + {{0x003f, 0xff1f}}, // ? -> ? + {{0x0040, 0xff20}}, // @ -> @ + {{0x0041, 0xff21}}, // A -> A + {{0x0042, 0xff22}}, // B -> B + {{0x0043, 0xff23}}, // C -> C + {{0x0044, 0xff24}}, // D -> D + {{0x0045, 0xff25}}, // E -> E + {{0x0046, 0xff26}}, // F -> F + {{0x0047, 0xff27}}, // G -> G + {{0x0048, 0xff28}}, // H -> H + {{0x0049, 0xff29}}, // I -> I + {{0x004a, 0xff2a}}, // J -> J + {{0x004b, 0xff2b}}, // K -> K + {{0x004c, 0xff2c}}, // L -> L + {{0x004d, 0xff2d}}, // M -> M + {{0x004e, 0xff2e}}, // N -> N + {{0x004f, 0xff2f}}, // O -> O + {{0x0050, 0xff30}}, // P -> P + {{0x0051, 0xff31}}, // Q -> Q + {{0x0052, 0xff32}}, // R -> R + {{0x0053, 0xff33}}, // S -> S + {{0x0054, 0xff34}}, // T -> T + {{0x0055, 0xff35}}, // U -> U + {{0x0056, 0xff36}}, // V -> V + {{0x0057, 0xff37}}, // W -> W + {{0x0058, 0xff38}}, // X -> X + {{0x0059, 0xff39}}, // Y -> Y + {{0x005a, 0xff3a}}, // Z -> Z + {{0x005b, 0xff3b}}, // [ -> [ + {{0x005c, 0xff3c}}, // \ -> \ + {{0x005d, 0xff3c}}, // ] -> ] + {{0x005e, 0xff3e}}, // ^ -> ^ + {{0x005f, 0xff3f}}, // _ -> _ + {{0x0060, 0xff40}}, // ` -> ` + {{0x0061, 0xff41}}, // a -> a + {{0x0062, 0xff42}}, // b -> b + {{0x0063, 0xff43}}, // c -> c + {{0x0064, 0xff44}}, // d -> d + {{0x0065, 0xff45}}, // e -> e + {{0x0066, 0xff46}}, // f -> f + {{0x0067, 0xff47}}, // g -> g + {{0x0068, 0xff48}}, // h -> h + {{0x0069, 0xff49}}, // i -> i + {{0x006a, 0xff4a}}, // j -> j + {{0x006b, 0xff4b}}, // k -> k + {{0x006c, 0xff4c}}, // l -> l + {{0x006d, 0xff4d}}, // m -> m + {{0x006e, 0xff4e}}, // n -> n + {{0x006f, 0xff4f}}, // o -> o + {{0x0070, 0xff50}}, // p -> p + {{0x0071, 0xff51}}, // q -> q + {{0x0072, 0xff52}}, // r -> r + {{0x0073, 0xff53}}, // s -> s + {{0x0074, 0xff54}}, // t -> t + {{0x0075, 0xff55}}, // u -> u + {{0x0076, 0xff56}}, // v -> v + {{0x0077, 0xff57}}, // w -> w + {{0x0078, 0xff58}}, // x -> x + {{0x0079, 0xff59}}, // y -> y + {{0x007a, 0xff5a}}, // z -> z + {{0x007b, 0xff5b}}, // { -> { + {{0x007c, 0xff5c}}, // | -> | + {{0x007d, 0xff5d}}, // } -> } + {{0x007e, 0xff5e}}, // ~ -> ~ + {{0x007e, 0x0301}}, // ~ -> 〜 // Fullwidth brackets - {0xff5f, 0x2e28}, // ⦅ -> ⸨ - {0xff60, 0x2e29}, // ⦆ -> ⸩ + {{0xff5f, 0x2e28}}, // ⦅ -> ⸨ + {{0xff60, 0x2e29}}, // ⦆ -> ⸩ // Halfwidth CJK punctuation - {0xff61, 0x3002}, // 。 -> 。 - {0xff62, 0x300c}, // 「 -> 「 - {0xff63, 0x300d}, // 」 -> 」 - {0xff64, 0x3001}, // 、 -> 、 + {{0xff61, 0x3002}}, // 。 -> 。 + {{0xff62, 0x300c}}, // 「 -> 「 + {{0xff63, 0x300d}}, // 」 -> 」 + {{0xff64, 0x3001}}, // 、 -> 、 // Halfwidth Katakana variants - {0xff65, 0x30fb}, // ・ -> ・ - {0xff66, 0x30f2}, // ヲ -> ヲ - {0xff67, 0x30a1}, // ァ -> ァ - {0xff68, 0x30a3}, // ィ -> ィ - {0xff69, 0x30a5}, // ゥ -> ゥ - {0xff6a, 0x30a7}, // ェ -> ェ - {0xff6b, 0x30a9}, // ォ -> ォ - {0xff6c, 0x30e3}, // ャ -> ャ - {0xff6d, 0x30e5}, // ュ -> ュ - {0xff6e, 0x30e7}, // ョ -> ョ - {0xff6f, 0x30c3}, // ッ -> ッ - {0xff70, 0x30fc}, // ー -> ー - {0xff71, 0x30a2}, // ア -> ア - {0xff72, 0x30a4}, // イ -> イ - {0xff73, 0x30a6}, // ウ -> ウ - {0xff74, 0x30a8}, // エ -> エ - {0xff75, 0x30aa}, // オ -> オ - {0xff76, 0x30ab}, // カ -> カ - {0xff77, 0x30ad}, // キ -> キ - {0xff78, 0x30af}, // ク -> ク - {0xff79, 0x30b1}, // ケ -> ケ - {0xff7a, 0x30b3}, // コ -> コ - {0xff7b, 0x30b5}, // サ -> サ - {0xff7c, 0x30b7}, // シ -> シ - {0xff7d, 0x30b9}, // ス -> ス - {0xff7e, 0x30bb}, // セ -> セ - {0xff7f, 0x30bd}, // ソ -> ソ - {0xff80, 0x30bf}, // タ -> タ - {0xff81, 0x30c1}, // チ -> チ - {0xff82, 0x30c4}, // ツ -> ツ - {0xff83, 0x30c6}, // テ -> テ - {0xff84, 0x30c8}, // ト -> ト - {0xff85, 0x30ca}, // ナ -> ナ - {0xff86, 0x30cb}, // ニ -> ニ - {0xff87, 0x30cc}, // ヌ -> ヌ - {0xff88, 0x30cd}, // ネ -> ネ - {0xff89, 0x30ce}, // ノ -> ノ - {0xff8a, 0x30cf}, // ハ -> ハ - {0xff8b, 0x30d2}, // ヒ -> ヒ - {0xff8c, 0x30d5}, // フ -> フ - {0xff8d, 0x30d8}, // ヘ -> ヘ - {0xff8e, 0x30db}, // ホ -> ホ - {0xff8f, 0x30de}, // マ -> マ - {0xff90, 0x30df}, // ミ -> ミ - {0xff91, 0x30e0}, // ム -> ム - {0xff92, 0x30e1}, // メ -> メ - {0xff93, 0x30e2}, // モ -> モ - {0xff94, 0x30e4}, // ヤ -> ヤ - {0xff95, 0x30e6}, // ユ -> ユ - {0xff96, 0x30e8}, // ヨ -> ヨ - {0xff97, 0x30e9}, // ラ -> ラ - {0xff98, 0x30ea}, // リ -> リ - {0xff99, 0x30eb}, // ル -> ル - {0xff9a, 0x30ec}, // レ -> レ - {0xff9b, 0x30ed}, // ロ -> ロ - {0xff9c, 0x30ef}, // ワ -> ワ - {0xff9d, 0x30f3}, // ン -> ン - {0xff9e, 0x3099}, // ゙ -> ゙ - {0xff9f, 0x309a}, // ゚ -> ゚ + {{0xff65, 0x30fb}}, // ・ -> ・ + {{0xff66, 0x30f2}}, // ヲ -> ヲ + {{0xff67, 0x30a1}}, // ァ -> ァ + {{0xff68, 0x30a3}}, // ィ -> ィ + {{0xff69, 0x30a5}}, // ゥ -> ゥ + {{0xff6a, 0x30a7}}, // ェ -> ェ + {{0xff6b, 0x30a9}}, // ォ -> ォ + {{0xff6c, 0x30e3}}, // ャ -> ャ + {{0xff6d, 0x30e5}}, // ュ -> ュ + {{0xff6e, 0x30e7}}, // ョ -> ョ + {{0xff6f, 0x30c3}}, // ッ -> ッ + {{0xff70, 0x30fc}}, // ー -> ー + {{0xff71, 0x30a2}}, // ア -> ア + {{0xff72, 0x30a4}}, // イ -> イ + {{0xff73, 0x30a6}}, // ウ -> ウ + {{0xff74, 0x30a8}}, // エ -> エ + {{0xff75, 0x30aa}}, // オ -> オ + {{0xff76, 0x30ab}}, // カ -> カ + {{0xff77, 0x30ad}}, // キ -> キ + {{0xff78, 0x30af}}, // ク -> ク + {{0xff79, 0x30b1}}, // ケ -> ケ + {{0xff7a, 0x30b3}}, // コ -> コ + {{0xff7b, 0x30b5}}, // サ -> サ + {{0xff7c, 0x30b7}}, // シ -> シ + {{0xff7d, 0x30b9}}, // ス -> ス + {{0xff7e, 0x30bb}}, // セ -> セ + {{0xff7f, 0x30bd}}, // ソ -> ソ + {{0xff80, 0x30bf}}, // タ -> タ + {{0xff81, 0x30c1}}, // チ -> チ + {{0xff82, 0x30c4}}, // ツ -> ツ + {{0xff83, 0x30c6}}, // テ -> テ + {{0xff84, 0x30c8}}, // ト -> ト + {{0xff85, 0x30ca}}, // ナ -> ナ + {{0xff86, 0x30cb}}, // ニ -> ニ + {{0xff87, 0x30cc}}, // ヌ -> ヌ + {{0xff88, 0x30cd}}, // ネ -> ネ + {{0xff89, 0x30ce}}, // ノ -> ノ + {{0xff8a, 0x30cf}}, // ハ -> ハ + {{0xff8b, 0x30d2}}, // ヒ -> ヒ + {{0xff8c, 0x30d5}}, // フ -> フ + {{0xff8d, 0x30d8}}, // ヘ -> ヘ + {{0xff8e, 0x30db}}, // ホ -> ホ + {{0xff8f, 0x30de}}, // マ -> マ + {{0xff90, 0x30df}}, // ミ -> ミ + {{0xff91, 0x30e0}}, // ム -> ム + {{0xff92, 0x30e1}}, // メ -> メ + {{0xff93, 0x30e2}}, // モ -> モ + {{0xff94, 0x30e4}}, // ヤ -> ヤ + {{0xff95, 0x30e6}}, // ユ -> ユ + {{0xff96, 0x30e8}}, // ヨ -> ヨ + {{0xff97, 0x30e9}}, // ラ -> ラ + {{0xff98, 0x30ea}}, // リ -> リ + {{0xff99, 0x30eb}}, // ル -> ル + {{0xff9a, 0x30ec}}, // レ -> レ + {{0xff9b, 0x30ed}}, // ロ -> ロ + {{0xff9c, 0x30ef}}, // ワ -> ワ + {{0xff9d, 0x30f3}}, // ン -> ン + {{0xff9e, 0x3099}}, // ゙ -> ゙ + {{0xff9f, 0x309a}}, // ゚ -> ゚ // Halfwidth Hangul variants - {0xffa0, 0x3164}, // ᅠ-> ᅠ - {0xffa1, 0x3131}, // ᄀ -> ㄱ - {0xffa2, 0x3132}, // ᄁ -> ㄲ - {0xffa3, 0x3133}, // ᆪ -> ㄳ - {0xffa4, 0x3134}, // ᄂ -> ㄴ - {0xffa5, 0x3135}, // ᆬ -> ㄵ - {0xffa6, 0x3136}, // ᆭ -> ㄶ - {0xffa7, 0x3137}, // ᄃ -> ㄷ - {0xffa8, 0x3138}, // ᄄ -> ㄸ - {0xffa9, 0x3139}, // ᄅ -> ㄹ - {0xffaa, 0x313a}, // ᆰ -> ㄺ - {0xffab, 0x313b}, // ᆱ -> ㄻ - {0xffac, 0x313c}, // ᆲ -> ㄼ - {0xffad, 0x313d}, // ᆳ -> ㄽ - {0xffae, 0x313e}, // ᆴ -> ㄾ - {0xffaf, 0x313f}, // ᆵ -> ㄿ - {0xffb0, 0x3140}, // ᄚ -> ㅀ - {0xffb1, 0x3141}, // ᄆ -> ㅁ - {0xffb2, 0x3142}, // ᄇ -> ㅂ - {0xffb3, 0x3143}, // ᄈ -> ㅃ - {0xffb4, 0x3144}, // ᄡ -> ㅄ - {0xffb5, 0x3145}, // ᄉ -> ㅅ - {0xffb6, 0x3146}, // ᄊ -> ㅆ - {0xffb7, 0x3147}, // ᄋ -> ㅇ - {0xffb8, 0x3148}, // ᄌ -> ㅈ - {0xffb9, 0x3149}, // ᄍ -> ㅉ - {0xffba, 0x314a}, // ᄎ -> ㅊ - {0xffbb, 0x314b}, // ᄏ -> ㅋ - {0xffbc, 0x314c}, // ᄐ -> ㅌ - {0xffbd, 0x314d}, // ᄑ -> ㅍ - {0xffbe, 0x314e}, // ᄒ -> ㅎ - {0xffc2, 0x314f}, // ᅡ -> ㅏ - {0xffc3, 0x3150}, // ᅢ -> ㅐ - {0xffc4, 0x3151}, // ᅣ -> ㅑ - {0xffc5, 0x3152}, // ᅤ -> ㅒ - {0xffc6, 0x3153}, // ᅥ -> ㅓ - {0xffc7, 0x3154}, // ᅦ -> ㅔ - {0xffca, 0x3155}, // ᅧ -> ㅕ - {0xffcb, 0x3156}, // ᅨ -> ㅖ - {0xffcc, 0x3157}, // ᅩ -> ㅗ - {0xffcd, 0x3158}, // ᅪ -> ㅘ - {0xffce, 0x3159}, // ᅫ -> ㅙ - {0xffcf, 0x315a}, // ᅬ -> ㅚ - {0xffd2, 0x315b}, // ᅭ -> ㅛ - {0xffd3, 0x315c}, // ᅮ -> ㅜ - {0xffd4, 0x315d}, // ᅯ -> ㅝ - {0xffd5, 0x315e}, // ᅰ -> ㅞ - {0xffd6, 0x315f}, // ᅱ -> ㅟ - {0xffd7, 0x3160}, // ᅲ -> ㅠ - {0xffda, 0x3161}, // ᅳ -> ㅡ - {0xffdb, 0x3162}, // ᅴ -> ㅢ - {0xffdc, 0x3163}, // ᅵ -> ㅣ + {{0xffa0, 0x3164}}, // ᅠ-> ᅠ + {{0xffa1, 0x3131}}, // ᄀ -> ㄱ + {{0xffa2, 0x3132}}, // ᄁ -> ㄲ + {{0xffa3, 0x3133}}, // ᆪ -> ㄳ + {{0xffa4, 0x3134}}, // ᄂ -> ㄴ + {{0xffa5, 0x3135}}, // ᆬ -> ㄵ + {{0xffa6, 0x3136}}, // ᆭ -> ㄶ + {{0xffa7, 0x3137}}, // ᄃ -> ㄷ + {{0xffa8, 0x3138}}, // ᄄ -> ㄸ + {{0xffa9, 0x3139}}, // ᄅ -> ㄹ + {{0xffaa, 0x313a}}, // ᆰ -> ㄺ + {{0xffab, 0x313b}}, // ᆱ -> ㄻ + {{0xffac, 0x313c}}, // ᆲ -> ㄼ + {{0xffad, 0x313d}}, // ᆳ -> ㄽ + {{0xffae, 0x313e}}, // ᆴ -> ㄾ + {{0xffaf, 0x313f}}, // ᆵ -> ㄿ + {{0xffb0, 0x3140}}, // ᄚ -> ㅀ + {{0xffb1, 0x3141}}, // ᄆ -> ㅁ + {{0xffb2, 0x3142}}, // ᄇ -> ㅂ + {{0xffb3, 0x3143}}, // ᄈ -> ㅃ + {{0xffb4, 0x3144}}, // ᄡ -> ㅄ + {{0xffb5, 0x3145}}, // ᄉ -> ㅅ + {{0xffb6, 0x3146}}, // ᄊ -> ㅆ + {{0xffb7, 0x3147}}, // ᄋ -> ㅇ + {{0xffb8, 0x3148}}, // ᄌ -> ㅈ + {{0xffb9, 0x3149}}, // ᄍ -> ㅉ + {{0xffba, 0x314a}}, // ᄎ -> ㅊ + {{0xffbb, 0x314b}}, // ᄏ -> ㅋ + {{0xffbc, 0x314c}}, // ᄐ -> ㅌ + {{0xffbd, 0x314d}}, // ᄑ -> ㅍ + {{0xffbe, 0x314e}}, // ᄒ -> ㅎ + {{0xffc2, 0x314f}}, // ᅡ -> ㅏ + {{0xffc3, 0x3150}}, // ᅢ -> ㅐ + {{0xffc4, 0x3151}}, // ᅣ -> ㅑ + {{0xffc5, 0x3152}}, // ᅤ -> ㅒ + {{0xffc6, 0x3153}}, // ᅥ -> ㅓ + {{0xffc7, 0x3154}}, // ᅦ -> ㅔ + {{0xffca, 0x3155}}, // ᅧ -> ㅕ + {{0xffcb, 0x3156}}, // ᅨ -> ㅖ + {{0xffcc, 0x3157}}, // ᅩ -> ㅗ + {{0xffcd, 0x3158}}, // ᅪ -> ㅘ + {{0xffce, 0x3159}}, // ᅫ -> ㅙ + {{0xffcf, 0x315a}}, // ᅬ -> ㅚ + {{0xffd2, 0x315b}}, // ᅭ -> ㅛ + {{0xffd3, 0x315c}}, // ᅮ -> ㅜ + {{0xffd4, 0x315d}}, // ᅯ -> ㅝ + {{0xffd5, 0x315e}}, // ᅰ -> ㅞ + {{0xffd6, 0x315f}}, // ᅱ -> ㅟ + {{0xffd7, 0x3160}}, // ᅲ -> ㅠ + {{0xffda, 0x3161}}, // ᅳ -> ㅡ + {{0xffdb, 0x3162}}, // ᅴ -> ㅢ + {{0xffdc, 0x3163}}, // ᅵ -> ㅣ // Fullwidth symbol variants - {0x00a2, 0xffe0}, // ¢ -> ¢ - {0x00a3, 0xffe1}, // £ -> £ - {0x00ac, 0xffe2}, // ¬ -> ¬ - {0x00af, 0xffe3}, // ¯ ->  ̄ - {0x00a6, 0xffe4}, // ¦ -> ¦ - {0x00a5, 0xffe5}, // ¥ -> ¥ - {0x20a9, 0xffe6}, // ₩ -> ₩ + {{0x00a2, 0xffe0}}, // ¢ -> ¢ + {{0x00a3, 0xffe1}}, // £ -> £ + {{0x00ac, 0xffe2}}, // ¬ -> ¬ + {{0x00af, 0xffe3}}, // ¯ ->  ̄ + {{0x00a6, 0xffe4}}, // ¦ -> ¦ + {{0x00a5, 0xffe5}}, // ¥ -> ¥ + {{0x20a9, 0xffe6}}, // ₩ -> ₩ // Halfwidth symbol variants - {0xffe8, 0x2502}, // │ -> │ - {0xffe9, 0x2190}, // ← -> ← - {0xffea, 0x2191}, // ↑ -> ↑ - {0xffeb, 0x2192}, // → -> → - {0xffec, 0x2193}, // ↓ -> ↓ - {0xffed, 0x25a0}, // ■ -> ■ - {0xffee, 0x25cb} // ○ -> ○ -}; - -constexpr std::size_t last_halfwidth_item = \ - std::size_t((sizeof(halfwidth_fullwidth) / sizeof(halfwidth_fullwidth[0])) - 1); + {{0xffe8, 0x2502}}, // │ -> │ + {{0xffe9, 0x2190}}, // ← -> ← + {{0xffea, 0x2191}}, // ↑ -> ↑ + {{0xffeb, 0x2192}}, // → -> → + {{0xffec, 0x2193}}, // ↓ -> ↓ + {{0xffed, 0x25a0}}, // ■ -> ■ + {{0xffee, 0x25cb}} // ○ -> ○ +}}; } // namespace fc diff --git a/src/fdialog.cpp b/src/fdialog.cpp index 1a300d1c..5ec74e93 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -282,7 +282,16 @@ void FDialog::move (const FPoint& d_pos) //---------------------------------------------------------------------- inline bool FDialog::moveUp (int n) { - move ({0, -n}); + if ( isBottomOutside() ) + { + const auto y_max = int(getMaxHeight()); + FWindow::setY(y_max, false); + putArea (getTermPos(), getVWin()); + restoreOverlaidWindows(); + } + else + move ({0, -n}); + return ! setPos_error; } @@ -296,7 +305,16 @@ inline bool FDialog::moveDown (int n) //---------------------------------------------------------------------- inline bool FDialog::moveLeft (int n) { - move ({-n, 0}); + if ( isLeftOutside() ) + { + const auto x_max = int(getMaxWidth()); + FWindow::setX(x_max, false); + putArea (getTermPos(), getVWin()); + restoreOverlaidWindows(); + } + else + move ({-n, 0}); + return ! setPos_error; } @@ -458,8 +476,9 @@ void FDialog::onKeyPress (FKeyEvent* ev) if ( this == getMainWidget() ) return; - if ( ev->key() == fc::Fkey_escape - || ev->key() == fc::Fkey_escape_mintty ) + if ( ! ev->isAccepted() + && ( ev->key() == fc::Fkey_escape + || ev->key() == fc::Fkey_escape_mintty) ) { ev->accept(); @@ -1385,48 +1404,58 @@ inline void FDialog::moveSizeKey (FKeyEvent* ev) { case fc::Fkey_up: moveUp(1); + ev->accept(); break; case fc::Fkey_down: moveDown(1); + ev->accept(); break; case fc::Fkey_left: moveLeft(1); + ev->accept(); break; case fc::Fkey_right: moveRight(1); + ev->accept(); break; case fc::Fmkey_up: case fc::Fkey_sr: reduceHeight(1); + ev->accept(); break; case fc::Fmkey_down: case fc::Fkey_sf: expandHeight(1); + ev->accept(); break; case fc::Fmkey_left: case fc::Fkey_sleft: reduceWidth(1); + ev->accept(); break; case fc::Fmkey_right: case fc::Fkey_sright: expandWidth(1); + ev->accept(); break; case fc::Fkey_return: case fc::Fkey_enter: acceptMoveSize(); + ev->accept(); break; case fc::Fkey_escape: case fc::Fkey_escape_mintty: cancelMoveSize(); + ev->accept(); return; default: @@ -1470,6 +1499,24 @@ bool FDialog::isOutsideTerminal (const FPoint& pos) const return false; } +//---------------------------------------------------------------------- +bool FDialog::isLeftOutside() +{ + if ( getX() > int(getMaxWidth()) ) + return true; + + return false; +} + +//---------------------------------------------------------------------- +bool FDialog::isBottomOutside() +{ + if ( getY() > int(getMaxHeight()) ) + return true; + + return false; +} + //---------------------------------------------------------------------- bool FDialog::isLowerRightResizeCorner (const mouseStates& ms) const { diff --git a/src/fevent.cpp b/src/fevent.cpp index 588a9e83..7f213231 100644 --- a/src/fevent.cpp +++ b/src/fevent.cpp @@ -366,10 +366,7 @@ FUserEvent::FUserEvent (fc::events ev_type, int user_event_id) // constructor //---------------------------------------------------------------------- FUserEvent::~FUserEvent() // destructor -{ - if ( ! external_data_pointer && data_pointer ) - delete data_pointer; -} +{ } //---------------------------------------------------------------------- int FUserEvent::getUserId() const diff --git a/src/ffiledialog.cpp b/src/ffiledialog.cpp index 66a4c70f..20412da6 100644 --- a/src/ffiledialog.cpp +++ b/src/ffiledialog.cpp @@ -55,10 +55,10 @@ bool sortDirFirst ( const FFileDialog::FDirEntry& lhs } //---------------------------------------------------------------------- -const FString fileChooser ( FWidget* parent - , const FString& dirname - , const FString& filter - , FFileDialog::DialogType type ) +FString fileChooser ( FWidget* parent + , const FString& dirname + , const FString& filter + , FFileDialog::DialogType type ) { FString ret{}; FString path{dirname}; @@ -165,7 +165,7 @@ FFileDialog& FFileDialog::operator = (const FFileDialog& fdlg) } //---------------------------------------------------------------------- -const FString FFileDialog::getSelectedFile() const +FString FFileDialog::getSelectedFile() const { const uLong n = uLong(filebrowser.currentItem() - 1); @@ -257,17 +257,17 @@ void FFileDialog::onKeyPress (FKeyEvent* ev) } //---------------------------------------------------------------------- -const FString FFileDialog::fileOpenChooser ( FWidget* parent - , const FString& dirname - , const FString& filter ) +FString FFileDialog::fileOpenChooser ( FWidget* parent + , const FString& dirname + , const FString& filter ) { return fileChooser (parent, dirname, filter, FFileDialog::Open); } //---------------------------------------------------------------------- -const FString FFileDialog::fileSaveChooser ( FWidget* parent - , const FString& dirname - , const FString& filter ) +FString FFileDialog::fileSaveChooser ( FWidget* parent + , const FString& dirname + , const FString& filter ) { return fileChooser (parent, dirname, filter, FFileDialog::Save); } @@ -736,7 +736,7 @@ void FFileDialog::printPath (const FString& txt) } //---------------------------------------------------------------------- -const FString FFileDialog::getHomeDir() +FString FFileDialog::getHomeDir() { struct passwd pwd{}; struct passwd* pwd_ptr{}; diff --git a/src/fkey_map.cpp b/src/fkey_map.cpp index ea1e0089..06d49bff 100644 --- a/src/fkey_map.cpp +++ b/src/fkey_map.cpp @@ -20,6 +20,8 @@ * . * ***********************************************************************/ +#include + #include "final/fc.h" #include "final/fkey_map.h" #include "final/ftypes.h" @@ -30,8 +32,8 @@ namespace finalcut namespace fc { -FKeyMap fkey[] = -{ +std::array fkey +{{ { fc::Fkey_backspace , nullptr, "kb" }, // backspace key { fc::Fkey_catab , nullptr, "ka" }, // clear-all-tabs key { fc::Fkey_clear , nullptr, "kC" }, // clear-screen or erase key @@ -210,12 +212,11 @@ FKeyMap fkey[] = { fc::Fkey_slash , ESC "Oo", "KP1"}, // keypad slash { fc::Fkey_asterisk , ESC "Oj", "KP2"}, // keypad asterisk { fc::Fkey_minus_sign, ESC "Om", "KP3"}, // keypad minus sign - { fc::Fkey_plus_sign , ESC "Ok", "KP4"}, // keypad plus sign - { 0 , nullptr, "\0" } -}; + { fc::Fkey_plus_sign , ESC "Ok", "KP4"} // keypad plus sign +}}; -constexpr FMetakeyMap fmetakey[] = -{ +constexpr std::array fmetakey = +{{ { fc::Fmkey_ic , "\033[2;3~" }, // M-insert { fc::Fmkey_ic , "\033\033[2~" }, // M-insert { fc::Fmkey_dc , "\033[3;3~" }, // M-delete @@ -443,12 +444,11 @@ constexpr FMetakeyMap fmetakey[] = { fc::Fmkey_left_curly_bracket , "\033{" }, // M-{ { fc::Fmkey_vertical_bar , "\033|" }, // M-| { fc::Fmkey_right_curly_bracket , "\033}" }, // M-} - { fc::Fmkey_tilde , "\033~" }, // M-~ - { 0 , "\0" } -}; + { fc::Fmkey_tilde , "\033~" } // M-~ +}}; -constexpr FKeyName fkeyname[] = -{ +constexpr std::array fkeyname = +{{ { fc::Fckey_a , "Ctrl+A" }, { fc::Fckey_b , "Ctrl+B" }, { fc::Fckey_c , "Ctrl+C" }, @@ -836,9 +836,8 @@ constexpr FKeyName fkeyname[] = { fc::Fkey_mouse , "xterm mouse" }, { fc::Fkey_extended_mouse , "SGR extended mouse" }, { fc::Fkey_urxvt_mouse , "urxvt mouse extension" }, - { fc::Fkey_incomplete , "incomplete key string" }, - { 0 , "\0" } -}; + { fc::Fkey_incomplete , "incomplete key string" } +}}; } // namespace fc diff --git a/src/fkeyboard.cpp b/src/fkeyboard.cpp index d7ea5801..c3776343 100644 --- a/src/fkeyboard.cpp +++ b/src/fkeyboard.cpp @@ -86,11 +86,20 @@ void FKeyboard::fetchKeyCode() } //---------------------------------------------------------------------- -const FString FKeyboard::getKeyName (const FKey keynum) const +FString FKeyboard::getKeyName (const FKey keynum) const { - for (std::size_t i{0}; fc::fkeyname[i].string[0] != 0; i++) - if ( fc::fkeyname[i].num && fc::fkeyname[i].num == keynum ) - return FString{fc::fkeyname[i].string}; + const auto& key = std::find_if + ( + fc::fkeyname.begin(), + fc::fkeyname.end(), + [&keynum] (fc::FKeyName kn) + { + return (kn.num > 0 && kn.num == keynum); + } + ); + + if ( key != fc::fkeyname.end() ) + return FString{key->string}; if ( keynum > 32 && keynum < 127 ) return FString{char(keynum)}; @@ -98,12 +107,6 @@ const FString FKeyboard::getKeyName (const FKey keynum) const return FString{""}; } -//---------------------------------------------------------------------- -void FKeyboard::setTermcapMap (fc::FKeyMap* keymap) -{ - key_map = keymap; -} - //---------------------------------------------------------------------- void FKeyboard::init() { @@ -221,12 +224,12 @@ inline FKey FKeyboard::getTermcapKey() assert ( FIFO_BUF_SIZE > 0 ); - if ( ! key_map ) + if ( key_map.use_count() == 0 ) return NOT_SET; - for (std::size_t i{0}; key_map[i].tname[0] != 0; i++) + for (auto&& entry : *key_map) { - const char* k = key_map[i].string; + const char* k = entry.string; const std::size_t len = ( k ) ? std::strlen(k) : 0; if ( k && std::strncmp(k, fifo_buf, len) == 0 ) // found @@ -240,7 +243,7 @@ inline FKey FKeyboard::getTermcapKey() fifo_buf[n] = '\0'; input_data_pending = bool(fifo_buf[0] != '\0'); - return fc::fkey[i].num; + return entry.num; } } @@ -254,9 +257,9 @@ inline FKey FKeyboard::getMetaKey() assert ( FIFO_BUF_SIZE > 0 ); - for (std::size_t i{0}; fc::fmetakey[i].string[0] != 0; i++) + for (auto&& entry : fc::fmetakey) { - const char* kmeta = fc::fmetakey[i].string; // The string is never null + const char* kmeta = entry.string; // The string is never null const std::size_t len = std::strlen(kmeta); if ( std::strncmp(kmeta, fifo_buf, len) == 0 ) // found @@ -279,7 +282,7 @@ inline FKey FKeyboard::getMetaKey() fifo_buf[n] = '\0'; input_data_pending = bool(fifo_buf[0] != '\0'); - return fc::fmetakey[i].num; + return entry.num; } } diff --git a/src/flogger.cpp b/src/flogger.cpp index daec3cea..11992e73 100644 --- a/src/flogger.cpp +++ b/src/flogger.cpp @@ -58,7 +58,7 @@ void FLogger::newlineReplace ( std::string& str } //---------------------------------------------------------------------- -const std::string FLogger::getTimeString() const +std::string FLogger::getTimeString() const { char str[100]; const auto& now = std::chrono::system_clock::now(); @@ -71,7 +71,7 @@ const std::string FLogger::getTimeString() const } //---------------------------------------------------------------------- -const std::string FLogger::getEOL() const +std::string FLogger::getEOL() const { if ( getEnding() == FLog::LF ) return "\n"; diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index 47f145db..cb57dc8a 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -268,17 +268,17 @@ void FMenuBar::calculateDimensions() const // find the maximum item width for (auto&& item : getItemList()) { - int len = int(item->getTextWidth()); - int item_width = len + 2; + auto len = item->getTextWidth(); + auto item_width = len + 2; // set item geometry - item->setGeometry (item_pos, FSize{std::size_t(item_width), 1}, false); + item->setGeometry (item_pos, FSize{item_width, 1}, false); // set menu position if ( item->hasMenu() ) item->getMenu()->setPos (item_pos, false); - item_pos.x_ref() += item_width; + item_pos.x_ref() += int(item_width); } } @@ -681,7 +681,7 @@ void FMenuBar::adjustItems() const for (auto&& item : getItemList()) { // get item width - int item_width = int(item->getWidth()); + auto item_width = item->getWidth(); if ( item->hasMenu() ) { @@ -694,7 +694,7 @@ void FMenuBar::adjustItems() const menu->adjustItems(); } - item_X += item_width; + item_X += int(item_width); } } diff --git a/src/fmenuitem.cpp b/src/fmenuitem.cpp index 2dee3015..5da65bb1 100644 --- a/src/fmenuitem.cpp +++ b/src/fmenuitem.cpp @@ -606,7 +606,7 @@ void FMenuItem::createDialogList (FMenu* winmenu) const { auto win = static_cast(*iter); FMenuItem* win_item{}; - const uInt32 n = uInt32(std::distance(first, iter)); + const auto n = uInt32(std::distance(first, iter)); // get the dialog title const auto& name = win->getText(); diff --git a/src/fmessagebox.cpp b/src/fmessagebox.cpp index 1e720423..c8599240 100644 --- a/src/fmessagebox.cpp +++ b/src/fmessagebox.cpp @@ -21,6 +21,7 @@ ***********************************************************************/ #include +#include #include "final/fapplication.h" #include "final/fbutton.h" @@ -30,8 +31,8 @@ namespace finalcut { -static const char* const button_text[] = -{ +constexpr std::array button_text = +{{ nullptr, "&OK", "&Cancel", @@ -39,9 +40,8 @@ static const char* const button_text[] = "&No", "&Abort", "&Retry", - "&Ignore", - nullptr -}; + "&Ignore" +}}; //---------------------------------------------------------------------- // class FMessageBox @@ -51,7 +51,7 @@ static const char* const button_text[] = //---------------------------------------------------------------------- FMessageBox::FMessageBox (FWidget* parent) : FDialog{parent} - , button_digit{FMessageBox::Ok, 0, 0} + , button_digit{FMessageBox::Ok, FMessageBox::Reject, FMessageBox::Reject} { setTitlebarText("Message for you"); init(); @@ -79,9 +79,9 @@ FMessageBox::FMessageBox (const FMessageBox& mbox) //---------------------------------------------------------------------- FMessageBox::FMessageBox ( const FString& caption , const FString& message - , int button0 - , int button1 - , int button2 + , ButtonType button0 + , ButtonType button1 + , ButtonType button2 , FWidget* parent ) : FDialog{parent} , text{message} @@ -158,10 +158,10 @@ void FMessageBox::setText (const FString& txt) if ( button[0] ) button[0]->setY (int(getHeight()) - 4, false); - if ( button[1] && button_digit[1] != 0 ) + if ( button[1] && button_digit[1] != FMessageBox::Reject ) button[1]->setY (int(getHeight()) - 4, false); - if ( button[2] && button_digit[2] != 0 ) + if ( button[2] && button_digit[2] != FMessageBox::Reject ) button[2]->setY (int(getHeight()) - 4, false); adjustButtons(); @@ -195,9 +195,9 @@ void FMessageBox::adjustSize() } //---------------------------------------------------------------------- -void FMessageBox::cb_processClick (int reply) +void FMessageBox::cb_processClick (ButtonType reply) { - done(reply); + done(int(reply)); } @@ -210,15 +210,18 @@ void FMessageBox::init() if ( (button_digit[2] && ! button_digit[1]) || (button_digit[1] && ! button_digit[0]) ) { - button_digit[0] = button_digit[1] = button_digit[2] = 0; + button_digit[0] = button_digit[1] \ + = button_digit[2] \ + = FMessageBox::Reject; } - if ( button_digit[0] == 0 ) + if ( button_digit[0] == FMessageBox::Reject ) button_digit[0] = FMessageBox::Ok; - if ( button_digit[1] == 0 && button_digit[2] == 0 ) + if ( button_digit[1] == FMessageBox::Reject + && button_digit[2] == FMessageBox::Reject ) num_buttons = 1; - else if ( button_digit[2] == 0 ) + else if ( button_digit[2] == FMessageBox::Reject ) num_buttons = 2; else num_buttons = 3; @@ -242,7 +245,7 @@ inline void FMessageBox::allocation() button[0]->setHeight(1, false); button[0]->setFocus(); - if ( button_digit[1] > 0 ) + if ( button_digit[1] > FMessageBox::Reject ) { button[1] = new FButton(this); button[1]->setText(button_text[button_digit[1]]); @@ -251,7 +254,7 @@ inline void FMessageBox::allocation() button[1]->setHeight(1, false); } - if ( button_digit[2] > 0 ) + if ( button_digit[2] > FMessageBox::Reject ) { button[2] = new FButton(this); button[2]->setText(button_text[button_digit[2]]); @@ -278,7 +281,7 @@ inline void FMessageBox::deallocation() //---------------------------------------------------------------------- inline void FMessageBox::initCallbacks() { - if ( button[0] && button_digit[0] != 0 ) + if ( button[0] && button_digit[0] != FMessageBox::Reject ) { button[0]->addCallback ( @@ -288,7 +291,7 @@ inline void FMessageBox::initCallbacks() ); } - if ( button[1] && button_digit[1] != 0 ) + if ( button[1] && button_digit[1] != FMessageBox::Reject ) { button[1]->addCallback ( @@ -298,7 +301,7 @@ inline void FMessageBox::initCallbacks() ); } - if ( button[2] && button_digit[2] != 0 ) + if ( button[2] && button_digit[2] != FMessageBox::Reject ) { button[2]->addCallback ( @@ -350,7 +353,7 @@ void FMessageBox::draw() int head_offset{0}; int center_x{0}; // center the whole block - const int msg_x = int((getWidth() - max_line_width) / 2); + const auto msg_x = int((getWidth() - max_line_width) / 2); if ( FTerm::isMonochron() ) setReverse(true); @@ -388,7 +391,7 @@ void FMessageBox::draw() //---------------------------------------------------------------------- void FMessageBox::resizeButtons() const { - std::size_t len[3]{}; + std::array len{}; std::size_t max_size{}; for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++) @@ -447,7 +450,7 @@ void FMessageBox::adjustButtons() setX (int((max_width - getWidth()) / 2)); } - const int btn_x = int((getWidth() - btn_width) / 2); + const auto btn_x = int((getWidth() - btn_width) / 2); for (std::size_t n{0}; n < num_buttons && n < MAX_BUTTONS; n++) { @@ -458,7 +461,7 @@ void FMessageBox::adjustButtons() button[n]->setX(btn_x); else { - const int btn_size = int(button[n]->getWidth()); + const auto btn_size = int(button[n]->getWidth()); button[n]->setX(btn_x + int(n) * (btn_size + int(gap))); } } diff --git a/src/fmouse.cpp b/src/fmouse.cpp index f6a01da3..471d13de 100644 --- a/src/fmouse.cpp +++ b/src/fmouse.cpp @@ -54,7 +54,7 @@ FMouse::FMouse() // public methods of FMouse //---------------------------------------------------------------------- -const FString FMouse::getClassName() const +FString FMouse::getClassName() const { return "FMouse"; } @@ -287,7 +287,7 @@ FMouseGPM::~FMouseGPM() // destructor // public methods of FMouseX11 //---------------------------------------------------------------------- -const FString FMouseGPM::getClassName() const +FString FMouseGPM::getClassName() const { return "FMouseGPM"; } @@ -520,7 +520,7 @@ int FMouseGPM::gpmEvent (bool clear) const // public methods of FMouseX11 //---------------------------------------------------------------------- -const FString FMouseX11::getClassName() const +FString FMouseX11::getClassName() const { return "FMouseX11"; } @@ -698,7 +698,7 @@ void FMouseX11::setButtonState (const int btn, const struct timeval* time) // public methods of FMouseSGR //---------------------------------------------------------------------- -const FString FMouseSGR::getClassName() const +FString FMouseSGR::getClassName() const { return "FMouseSGR"; } @@ -928,7 +928,7 @@ void FMouseSGR::setReleasedButtonState (const int btn) // public methods of FMouseUrxvt //---------------------------------------------------------------------- -const FString FMouseUrxvt::getClassName() const +FString FMouseUrxvt::getClassName() const { return "FMouseUrxvt"; } diff --git a/src/fobject.cpp b/src/fobject.cpp index fffaac9f..d474c249 100644 --- a/src/fobject.cpp +++ b/src/fobject.cpp @@ -382,11 +382,17 @@ bool FObject::delAllTimers() const // protected methods of FObject //---------------------------------------------------------------------- void FObject::onTimer (FTimerEvent*) -{ } +{ + // This event handler can be reimplemented in a subclass + // to receive timer events for this object +} //---------------------------------------------------------------------- void FObject::onUserEvent (FUserEvent*) -{ } +{ + // This event handler can be reimplemented in a subclass + // to receive user events for this object +} //---------------------------------------------------------------------- uInt FObject::processTimerEvent() diff --git a/src/foptiattr.cpp b/src/foptiattr.cpp index 9f6680dd..3de29ae4 100644 --- a/src/foptiattr.cpp +++ b/src/foptiattr.cpp @@ -531,11 +531,11 @@ FColor FOptiAttr::vga2ansi (FColor color) color = 0; else if ( color < 16 ) { - static const FColor lookup_table[] = - { + constexpr std::array lookup_table = + {{ 0, 4, 2, 6, 1, 5, 3, 7, 8, 12, 10, 14, 9, 13, 11, 15 - }; + }}; color = lookup_table[color]; } diff --git a/src/frect.cpp b/src/frect.cpp index d861f836..e62c8c40 100644 --- a/src/frect.cpp +++ b/src/frect.cpp @@ -84,37 +84,37 @@ bool FRect::isEmpty() const } //---------------------------------------------------------------------- -const FPoint FRect::getPos() const +FPoint FRect::getPos() const { return { X1, Y1 }; } //---------------------------------------------------------------------- -const FPoint FRect::getUpperLeftPos() const +FPoint FRect::getUpperLeftPos() const { return { X1, Y1 }; } //---------------------------------------------------------------------- -const FPoint FRect::getUpperRightPos() const +FPoint FRect::getUpperRightPos() const { return { X2, Y1 }; } //---------------------------------------------------------------------- -const FPoint FRect::getLowerLeftPos() const +FPoint FRect::getLowerLeftPos() const { return { X1, Y2 }; } //---------------------------------------------------------------------- -const FPoint FRect::getLowerRightPos() const +FPoint FRect::getLowerRightPos() const { return { X2, Y2 }; } //---------------------------------------------------------------------- -const FSize FRect::getSize() const +FSize FRect::getSize() const { return { getWidth(), getHeight() }; } @@ -338,7 +338,7 @@ FRect FRect::combined (const FRect& r) const // FRect non-member operators //---------------------------------------------------------------------- -const FRect operator + (const FRect& r, const FSize& s) +FRect operator + (const FRect& r, const FSize& s) { return { r.X1 , r.Y1 @@ -347,7 +347,7 @@ const FRect operator + (const FRect& r, const FSize& s) } //---------------------------------------------------------------------- -const FRect operator - (const FRect& r, const FSize& s) +FRect operator - (const FRect& r, const FSize& s) { return { r.X1 , r.Y1 diff --git a/src/fstring.cpp b/src/fstring.cpp index 5524ea9d..a28918eb 100644 --- a/src/fstring.cpp +++ b/src/fstring.cpp @@ -409,13 +409,13 @@ char* FString::c_str() } //---------------------------------------------------------------------- -const std::string FString::toString() const +std::string FString::toString() const { return std::string(c_str(), length); } //---------------------------------------------------------------------- -const FString FString::toLower() const +FString FString::toLower() const { FString s{*this}; auto to_lower = [] (wchar_t& c) @@ -427,7 +427,7 @@ const FString FString::toLower() const } //---------------------------------------------------------------------- -const FString FString::toUpper() const +FString FString::toUpper() const { FString s{*this}; auto to_upper = [] (wchar_t& c) @@ -455,7 +455,7 @@ sInt16 FString::toShort() const //---------------------------------------------------------------------- uInt16 FString::toUShort() const { - const uLong num = uLong(toULong()); + const uLong num = toULong(); if ( num > USHRT_MAX ) throw std::overflow_error ("overflow"); @@ -466,7 +466,7 @@ uInt16 FString::toUShort() const //---------------------------------------------------------------------- int FString::toInt() const { - long num = toLong(); + const long num = toLong(); if ( num > INT_MAX ) throw std::overflow_error ("overflow"); @@ -480,7 +480,7 @@ int FString::toInt() const //---------------------------------------------------------------------- uInt FString::toUInt() const { - const uLong num = uLong(toULong()); + const uLong num = toULong(); if ( num > UINT_MAX ) throw std::overflow_error ("overflow"); @@ -518,7 +518,7 @@ long FString::toLong() const while ( std::iswdigit(std::wint_t(*p)) ) { - uChar d = uChar(*p - L'0'); + auto d = uChar(*p - L'0'); if ( num > tenth_limit || (num == tenth_limit && d > tenth_limit_digit) ) @@ -568,7 +568,7 @@ uLong FString::toULong() const while ( std::iswdigit(std::wint_t(*p)) ) { - const uChar d = uChar(*p - L'0'); + const auto d = uChar(*p - L'0'); if ( num > tenth_limit || (num == tenth_limit && d > tenth_limit_digit) ) @@ -628,7 +628,7 @@ double FString::toDouble() const } //---------------------------------------------------------------------- -const FString FString::ltrim() const +FString FString::ltrim() const { const FString s{*this}; @@ -645,7 +645,7 @@ const FString FString::ltrim() const } //---------------------------------------------------------------------- -const FString FString::rtrim() const +FString FString::rtrim() const { FString s{*this}; @@ -668,7 +668,7 @@ const FString FString::rtrim() const } //---------------------------------------------------------------------- -const FString FString::trim() const +FString FString::trim() const { // handle NULL and empty string if ( ! (string && *string) ) @@ -679,7 +679,7 @@ const FString FString::trim() const } //---------------------------------------------------------------------- -const FString FString::left (std::size_t len) const +FString FString::left (std::size_t len) const { FString s{*this}; @@ -697,7 +697,7 @@ const FString FString::left (std::size_t len) const } //---------------------------------------------------------------------- -const FString FString::right (std::size_t len) const +FString FString::right (std::size_t len) const { const FString s{*this}; @@ -714,7 +714,7 @@ const FString FString::right (std::size_t len) const } //---------------------------------------------------------------------- -const FString FString::mid (std::size_t pos, std::size_t len) const +FString FString::mid (std::size_t pos, std::size_t len) const { const FString s{*this}; @@ -771,7 +771,7 @@ FString& FString::setNumber (sInt64 num) { wchar_t buf[30]{}; wchar_t* s = &buf[29]; // Pointer to the last character - uInt64 abs_num = static_cast(num); + auto abs_num = static_cast(num); if ( num < 0 ) abs_num = static_cast(-num); @@ -847,7 +847,7 @@ FString& FString::setFormatedNumber (sInt64 num, char separator) int n{0}; wchar_t buf[30]{}; wchar_t* s = &buf[29]; // Pointer to the last character - uInt64 abs_num = static_cast(num); + auto abs_num = static_cast(num); if ( separator == 0 ) separator = ' '; @@ -1001,7 +1001,7 @@ const FString& FString::insert (const FString& s, std::size_t pos) } //---------------------------------------------------------------------- -FString const FString::replace (const FString& from, const FString& to) const +FString FString::replace (const FString& from, const FString& to) const { FString s{*this}; @@ -1040,7 +1040,7 @@ FString const FString::replace (const FString& from, const FString& to) const } //---------------------------------------------------------------------- -const FString FString::replaceControlCodes() const +FString FString::replaceControlCodes() const { FString s{*this}; @@ -1066,7 +1066,7 @@ const FString FString::replaceControlCodes() const } //---------------------------------------------------------------------- -const FString FString::expandTabs (int tabstop) const +FString FString::expandTabs (int tabstop) const { FString instr{string}; FString outstr{}; @@ -1079,8 +1079,8 @@ const FString FString::expandTabs (int tabstop) const for (std::size_t i{0}; i < last; i++) { - const std::size_t len = tab_split[i].getLength(); - const std::size_t tab_len = std::size_t(tabstop); + const auto len = tab_split[i].getLength(); + const auto tab_len = std::size_t(tabstop); if ( i == last - 1 ) outstr += tab_split[i]; @@ -1527,7 +1527,7 @@ inline const wchar_t* FString::_extractToken ( wchar_t* rest[] // FString non-member operators //---------------------------------------------------------------------- -const FString operator + (const FString& s1, const FString& s2) +FString operator + (const FString& s1, const FString& s2) { FString tmp{s1}; tmp._insert (tmp.length, s2.length, s2.wc_str()); @@ -1535,7 +1535,7 @@ const FString operator + (const FString& s1, const FString& s2) } //---------------------------------------------------------------------- -const FString operator + (const FString& s, const wchar_t c) +FString operator + (const FString& s, const wchar_t c) { FString tmp1{s}; wchar_t tmp2[2]; @@ -1546,7 +1546,7 @@ const FString operator + (const FString& s, const wchar_t c) } //---------------------------------------------------------------------- -const FString operator + (const std::wstring& s1, const FString& s2) +FString operator + (const std::wstring& s1, const FString& s2) { FString tmp{s1}; tmp._insert (tmp.length, s2.length, s2.wc_str()); @@ -1554,7 +1554,7 @@ const FString operator + (const std::wstring& s1, const FString& s2) } //---------------------------------------------------------------------- -const FString operator + (const wchar_t s1[], const FString& s2) +FString operator + (const wchar_t s1[], const FString& s2) { FString tmp{s1}; tmp._insert (tmp.length, s2.length, s2.wc_str()); @@ -1562,7 +1562,7 @@ const FString operator + (const wchar_t s1[], const FString& s2) } //---------------------------------------------------------------------- -const FString operator + (const std::string& s1, const FString& s2) +FString operator + (const std::string& s1, const FString& s2) { FString tmp{s1}; tmp._insert (tmp.length, s2.length, s2.wc_str()); @@ -1570,7 +1570,7 @@ const FString operator + (const std::string& s1, const FString& s2) } //---------------------------------------------------------------------- -const FString operator + (const char s1[], const FString& s2) +FString operator + (const char s1[], const FString& s2) { FString tmp{s1}; tmp._insert (tmp.length, s2.length, s2.wc_str()); @@ -1578,7 +1578,7 @@ const FString operator + (const char s1[], const FString& s2) } //---------------------------------------------------------------------- -const FString operator + (const wchar_t c, const FString& s) +FString operator + (const wchar_t c, const FString& s) { FString tmp{c}; tmp._insert (1, s.length, s.wc_str()); @@ -1586,7 +1586,7 @@ const FString operator + (const wchar_t c, const FString& s) } //---------------------------------------------------------------------- -const FString operator + (const char c, const FString& s) +FString operator + (const char c, const FString& s) { FString tmp{c}; tmp._insert (1, s.length, s.wc_str()); @@ -1594,7 +1594,7 @@ const FString operator + (const char c, const FString& s) } //---------------------------------------------------------------------- -const FString operator + (const FString& s, const char c) +FString operator + (const FString& s, const char c) { FString tmp1{s}; wchar_t tmp2[2]; @@ -1607,7 +1607,7 @@ const FString operator + (const FString& s, const char c) //---------------------------------------------------------------------- std::ostream& operator << (std::ostream& outstr, const FString& s) { - const std::size_t width = std::size_t(outstr.width()); + const auto width = std::size_t(outstr.width()); if ( s.length > 0 ) { @@ -1641,7 +1641,7 @@ std::istream& operator >> (std::istream& instr, FString& s) //---------------------------------------------------------------------- std::wostream& operator << (std::wostream& outstr, const FString& s) { - const std::size_t width = std::size_t(outstr.width()); + const auto width = std::size_t(outstr.width()); if ( s.length > 0 ) { diff --git a/src/fterm.cpp b/src/fterm.cpp index 430f66bf..a819f1a3 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -158,7 +158,7 @@ std::size_t FTerm::getColumnNumber() } //---------------------------------------------------------------------- -const FString FTerm::getKeyName (FKey keynum) +FString FTerm::getKeyName (FKey keynum) { return keyboard->getKeyName (keynum); } @@ -202,7 +202,7 @@ int FTerm::getMaxColor() //---------------------------------------------------------------------- FTerm::FColorPalettePtr& FTerm::getColorPaletteTheme() { - static FColorPalettePtr* color_theme = new FColorPalettePtr(); + static auto color_theme = new FColorPalettePtr(); return *color_theme; } @@ -820,16 +820,15 @@ int FTerm::openConsole() int fd = data->getTTYFileDescriptor(); const char* termfilename = data->getTermFileName(); - static const char* terminal_devices[] = - { + constexpr std::array terminal_devices = + {{ "/proc/self/fd/0", "/dev/tty", "/dev/tty0", "/dev/vc/0", "/dev/systty", - "/dev/console", - nullptr - }; + "/dev/console" + }}; if ( fd >= 0 ) // console is already opened return 0; @@ -837,9 +836,9 @@ int FTerm::openConsole() if ( ! *termfilename || ! fsys ) return 0; - for (std::size_t i{0}; terminal_devices[i] != nullptr; i++) + for (auto&& entry : terminal_devices) { - fd = fsys->open(terminal_devices[i], O_RDWR, 0); + fd = fsys->open(entry, O_RDWR, 0); data->setTTYFileDescriptor(fd); if ( fd >= 0 ) @@ -1191,11 +1190,11 @@ wchar_t FTerm::charEncode (wchar_t c, fc::encoding enc) { wchar_t ch_enc = c; - for (std::size_t i{0}; i <= fc::last_char_item; i++) + for (auto&& entry : fc::character) { - if ( fc::character[i][fc::UTF8] == uInt(c) ) + if ( entry[fc::UTF8] == uInt(c) ) { - ch_enc = wchar_t(fc::character[i][enc]); + ch_enc = wchar_t(entry[enc]); break; } } @@ -1235,7 +1234,7 @@ bool FTerm::scrollTermReverse() //---------------------------------------------------------------------- FTerm::defaultPutChar& FTerm::putchar() { - static defaultPutChar* fputchar = new defaultPutChar(); + static auto fputchar = new defaultPutChar(); return *fputchar; } @@ -1408,8 +1407,8 @@ void FTerm::init_alt_charset() for (std::size_t n{0}; TCAP(fc::t_acs_chars)[n]; n += 2) { // insert the VT100 key/value pairs into a map - const uChar p1 = uChar(TCAP(fc::t_acs_chars)[n]); - const uChar p2 = uChar(TCAP(fc::t_acs_chars)[n + 1]); + const auto p1 = uChar(TCAP(fc::t_acs_chars)[n]); + const auto p2 = uChar(TCAP(fc::t_acs_chars)[n + 1]); vt100_alt_char[p1] = p2; } } @@ -1421,19 +1420,18 @@ void FTerm::init_alt_charset() }; // Update array 'character' with discovered VT100 pairs - for (std::size_t n{0}; n <= fc::last_key_item; n++ ) + for (auto&& pair : fc::vt100_key_to_utf8) { - const uChar keyChar = uChar(fc::vt100_key_to_utf8[n][vt100_key]); - const uChar altChar = uChar(vt100_alt_char[keyChar]); - const uInt utf8char = uInt(fc::vt100_key_to_utf8[n][utf8_char]); - const fc::encoding num{fc::NUM_OF_ENCODINGS}; - - uInt* p = std::find ( fc::character[0] - , fc::character[fc::last_char_item] + num - , utf8char ); - if ( p != fc::character[fc::last_char_item] + num ) // found in character + const auto keyChar = uChar(pair[vt100_key]); + const auto altChar = uChar(vt100_alt_char[keyChar]); + const auto utf8char = uInt(pair[utf8_char]); + const auto p = std::find_if ( fc::character.begin() + , fc::character.end() + , [&utf8char] (std::array entry) + { return entry[0] == utf8char; } ); + if ( p != fc::character.end() ) // found in character { - const int item = int(std::distance(fc::character[0], p) / num); + const auto item = std::size_t(std::distance(fc::character.begin(), p)); if ( altChar ) // update alternate character set fc::character[item][fc::VT100] = altChar; @@ -1506,24 +1504,24 @@ void FTerm::init_cygwin_charmap() return; // PC encoding changes - for (std::size_t i{0}; i <= fc::last_char_item; i++ ) + for (auto&& entry : fc::character) { - if ( fc::character[i][fc::UTF8] == fc::BlackUpPointingTriangle ) // ▲ - fc::character[i][fc::PC] = 0x18; + if ( entry[fc::UTF8] == fc::BlackUpPointingTriangle ) // ▲ + entry[fc::PC] = 0x18; - if ( fc::character[i][fc::UTF8] == fc::BlackDownPointingTriangle ) // ▼ - fc::character[i][fc::PC] = 0x19; + if ( entry[fc::UTF8] == fc::BlackDownPointingTriangle ) // ▼ + entry[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]; + if ( entry[fc::UTF8] == fc::InverseBullet // ◘ + || entry[fc::UTF8] == fc::InverseWhiteCircle // ◙ + || entry[fc::UTF8] == fc::UpDownArrow // ↕ + || entry[fc::UTF8] == fc::LeftRightArrow // ↔ + || entry[fc::UTF8] == fc::DoubleExclamationMark // ‼ + || entry[fc::UTF8] == fc::BlackRectangle // ▬ + || entry[fc::UTF8] == fc::RightwardsArrow // → + || entry[fc::UTF8] == fc::Section // § + || entry[fc::UTF8] == fc::SquareRoot ) // SquareRoot √ + entry[fc::PC] = entry[fc::ASCII]; } // General encoding changes @@ -1560,9 +1558,9 @@ void FTerm::init_teraterm_charmap() if ( ! isTeraTerm() ) return; - for (std::size_t i{0}; i <= fc::last_char_item; i++ ) - if ( fc::character[i][fc::PC] < 0x20 ) - fc::character[i][fc::PC] = fc::character[i][fc::ASCII]; + for (auto&& entry : fc::character) + if ( entry[fc::PC] < 0x20 ) + entry[fc::PC] = entry[fc::ASCII]; } //---------------------------------------------------------------------- diff --git a/src/fterm_functions.cpp b/src/fterm_functions.cpp index 19699705..e7afe543 100644 --- a/src/fterm_functions.cpp +++ b/src/fterm_functions.cpp @@ -274,11 +274,11 @@ wchar_t cp437_to_unicode (uChar c) constexpr std::size_t UNICODE = 1; wchar_t ucs = c; - for (std::size_t i{0}; i <= fc::last_cp437_item; i++) + for (auto&& entry : fc::cp437_ucs) { - if ( fc::cp437_ucs[i][CP437] == c ) // found + if ( entry[CP437] == c ) // found { - ucs = fc::cp437_ucs[i][UNICODE]; + ucs = entry[UNICODE]; break; } } @@ -293,11 +293,11 @@ uChar unicode_to_cp437 (wchar_t ucs) constexpr std::size_t UNICODE = 1; uChar c{'?'}; - for (std::size_t i{0}; i <= fc::last_cp437_item; i++) + for (auto&& entry : fc::cp437_ucs) { - if ( fc::cp437_ucs[i][UNICODE] == ucs ) // found + if ( entry[UNICODE] == ucs ) // found { - c = uChar(fc::cp437_ucs[i][CP437]); + c = uChar(entry[CP437]); break; } } @@ -306,7 +306,7 @@ uChar unicode_to_cp437 (wchar_t ucs) } //---------------------------------------------------------------------- -const FString getFullWidth (const FString& str) +FString getFullWidth (const FString& str) { // Converts half-width to full-width characters @@ -322,10 +322,10 @@ const FString getFullWidth (const FString& str) } else { - for (std::size_t i{0}; i <= fc::last_halfwidth_item; i++) + for (auto&& entry : fc::halfwidth_fullwidth) { - if ( fc::halfwidth_fullwidth[i][HALF] == c ) // found - c = fc::halfwidth_fullwidth[i][FULL]; + if ( entry[HALF] == c ) // found + c = entry[FULL]; } } } @@ -334,7 +334,7 @@ const FString getFullWidth (const FString& str) } //---------------------------------------------------------------------- -const FString getHalfWidth (const FString& str) +FString getHalfWidth (const FString& str) { // Converts full-width to half-width characters @@ -350,10 +350,10 @@ const FString getHalfWidth (const FString& str) } else { - for (std::size_t i{0}; i <= fc::last_halfwidth_item; i++) + for (auto&& entry : fc::halfwidth_fullwidth) { - if ( fc::halfwidth_fullwidth[i][FULL] == c ) // found - c = fc::halfwidth_fullwidth[i][HALF]; + if ( entry[FULL] == c ) // found + c = entry[HALF]; } } } @@ -362,9 +362,9 @@ const FString getHalfWidth (const FString& str) } //---------------------------------------------------------------------- -const FString getColumnSubString ( const FString& str - , std::size_t col_pos - , std::size_t col_len ) +FString getColumnSubString ( const FString& str + , std::size_t col_pos + , std::size_t col_len ) { FString s{str}; std::size_t col_first{1}; diff --git a/src/ftermbuffer.cpp b/src/ftermbuffer.cpp index 81c3ec88..f5b61a9c 100644 --- a/src/ftermbuffer.cpp +++ b/src/ftermbuffer.cpp @@ -43,7 +43,7 @@ FTermBuffer::~FTermBuffer() // destructor // public methods of FTermBuffer //---------------------------------------------------------------------- -const FString FTermBuffer::toString() const +FString FTermBuffer::toString() const { std::wstring wide_string{}; wide_string.reserve(data.size()); @@ -62,7 +62,7 @@ const FString FTermBuffer::toString() const int FTermBuffer::write (const FString& string) { assert ( ! string.isNull() ); - const int len = int(string.getLength()); + const auto len = int(string.getLength()); for (auto&& c : string) { diff --git a/src/ftermcap.cpp b/src/ftermcap.cpp index 37e014f0..a819436a 100644 --- a/src/ftermcap.cpp +++ b/src/ftermcap.cpp @@ -224,8 +224,9 @@ void FTermcap::termcapStrings() // Get termcap strings // Read termcap output strings - for (std::size_t i{0}; strings[i].tname[0] != 0; i++) - strings[i].string = getString(strings[i].tname); + + for (auto&& entry : strings) + entry.string = getString(entry.tname); const auto& ho = TCAP(fc::t_cursor_home); @@ -239,10 +240,8 @@ void FTermcap::termcapKeys() // Get termcap keys // Read termcap key sequences up to the self-defined values - for ( std::size_t i{0}; - fc::fkey[i].string == nullptr && fc::fkey[i].tname[0] != 0; - i++ ) - fc::fkey[i].string = getString(fc::fkey[i].tname); + for (auto&& entry : fc::fkey) + entry.string = getString(entry.tname); } //---------------------------------------------------------------------- @@ -257,8 +256,8 @@ int FTermcap::_tputs (const char* str, int affcnt, fn_putc putc) // private Data Member of FTermcap - termcap capabilities //---------------------------------------------------------------------- -FTermcap::tcap_map FTermcap::strings[] = -{ +FTermcap::TCapMapType FTermcap::strings = +{{ // .------------- term string // | .-------- Tcap-code // | | // variable name -> description @@ -347,9 +346,8 @@ FTermcap::tcap_map FTermcap::strings[] = { nullptr, "ac" }, // acs_chars -> graphics charset pairs (vt100) { nullptr, "ks" }, // keypad_xmit -> enter 'key-board_transmit' mode { nullptr, "ke" }, // keypad_local -> leave 'key-board_transmit' mode - { nullptr, "Km" }, // key_mouse -> Mouse event has occurred - { nullptr, "\0" } -}; + { nullptr, "Km" } // key_mouse -> Mouse event has occurred +}}; /* * (P) indicates that padding may be specified diff --git a/src/ftermfreebsd.cpp b/src/ftermfreebsd.cpp index 6c4eb50e..ee6a08cc 100644 --- a/src/ftermfreebsd.cpp +++ b/src/ftermfreebsd.cpp @@ -171,9 +171,9 @@ void FTermFreeBSD::initCharMap() if ( ! isFreeBSDConsole() ) return; - for (std::size_t i{0}; i <= fc::last_char_item; i++) - if ( fc::character[i][fc::PC] < 0x1c ) - fc::character[i][fc::PC] = fc::character[i][fc::ASCII]; + for (auto&& entry : fc::character) + if ( entry[fc::PC] < 0x1c ) + entry[fc::PC] = entry[fc::ASCII]; } //---------------------------------------------------------------------- diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index 58478eee..8be13144 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -217,14 +217,14 @@ void FTermLinux::initCharMap() if ( screen_unicode_map.entry_ct > 0 && screen_unicode_map.entries ) { - for (std::size_t i{0}; i <= fc::last_char_item; i++ ) + for (auto&& entry : fc::character) { - const auto ucs = wchar_t(fc::character[i][fc::UTF8]); + const auto ucs = wchar_t(entry[fc::UTF8]); const sInt16 fontpos = getFontPos(ucs); // Fix for a non-cp437 Linux console with PC charset encoding if ( fontpos > 255 || fontpos == NOT_FOUND ) - fc::character[i][fc::PC] = fc::character[i][fc::ASCII]; + entry[fc::PC] = entry[fc::ASCII]; // Character substitutions for missing characters if ( fontpos == NOT_FOUND ) @@ -700,7 +700,7 @@ int FTermLinux::setScreenFont ( const uChar fontdata[], uInt count for (std::size_t i{0}; i < count; i++) std::memcpy ( font.data + bytes_per_line * 32 * i , &fontdata[i * font.height] - , font.height); + , font.height ); } // Font operation @@ -932,8 +932,8 @@ void FTermLinux::getVGAPalette() //---------------------------------------------------------------------- void FTermLinux::setVGADefaultPalette() { - constexpr rgb defaultColor[16] = - { + constexpr std::array defaultColor = + {{ {0x00, 0x00, 0x00}, {0xaa, 0x00, 0x00}, {0x00, 0xaa, 0x00}, {0xaa, 0x55, 0x00}, {0x00, 0x00, 0xaa}, {0xaa, 0x00, 0xaa}, @@ -942,7 +942,7 @@ void FTermLinux::setVGADefaultPalette() {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++) { diff --git a/src/ftermxterminal.cpp b/src/ftermxterminal.cpp index fe41dc2e..d314045e 100644 --- a/src/ftermxterminal.cpp +++ b/src/ftermxterminal.cpp @@ -743,7 +743,7 @@ void FTermXTerminal::oscPostfix() const } //---------------------------------------------------------------------- -const FString FTermXTerminal::captureXTermFont() const +FString FTermXTerminal::captureXTermFont() const { initCheck(FString{}); @@ -787,7 +787,7 @@ const FString FTermXTerminal::captureXTermFont() const } //---------------------------------------------------------------------- -const FString FTermXTerminal::captureXTermTitle() const +FString FTermXTerminal::captureXTermTitle() const { initCheck(FString{}); diff --git a/src/ftextview.cpp b/src/ftextview.cpp index 7671fa09..c08a03b5 100644 --- a/src/ftextview.cpp +++ b/src/ftextview.cpp @@ -54,7 +54,7 @@ FTextView::~FTextView() // destructor // public methods of FTextView //---------------------------------------------------------------------- -const FString FTextView::getText() const +FString FTextView::getText() const { if ( data.empty() ) return FString{""}; @@ -149,7 +149,7 @@ void FTextView::scrollTo (int x, int y) if ( changeX && isHorizontallyScrollable() ) { - const int xoffset_end = int(max_line_width - getTextWidth()); + const auto xoffset_end = int(max_line_width - getTextWidth()); xoffset = x; if ( xoffset < 0 ) @@ -167,7 +167,7 @@ void FTextView::scrollTo (int x, int y) if ( changeY && isVerticallyScrollable() ) { - const int yoffset_end = int(getRows() - getTextHeight()); + const auto yoffset_end = int(getRows() - getTextHeight()); yoffset = y; if ( yoffset < 0 ) @@ -335,7 +335,7 @@ void FTextView::clear() //---------------------------------------------------------------------- void FTextView::onKeyPress (FKeyEvent* ev) { - const int idx = int(ev->key()); + const auto idx = int(ev->key()); if ( key_map.find(idx) != key_map.end() ) { @@ -504,8 +504,8 @@ void FTextView::adjustSize() FWidget::adjustSize(); const std::size_t width = getWidth(); const std::size_t height = getHeight(); - const int last_line = int(getRows()); - const int max_width = int(max_line_width); + const auto last_line = int(getRows()); + const auto max_width = int(max_line_width); if ( xoffset >= max_width - int(width) - nf_offset ) xoffset = max_width - int(width) - nf_offset - 1; diff --git a/src/fvterm.cpp b/src/fvterm.cpp index b935f6a7..4992c157 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -111,7 +111,7 @@ FVTerm& FVTerm::operator << (const FTermBuffer& term_buffer) // public methods of FVTerm //---------------------------------------------------------------------- -const FPoint FVTerm::getPrintCursor() +FPoint FVTerm::getPrintCursor() { const auto& win = getPrintArea(); @@ -130,8 +130,8 @@ void FVTerm::setTermXY (int x, int y) const if ( term_pos->getX() == x && term_pos->getY() == y ) return; - const int term_width = int(FTerm::getColumnNumber()); - const int term_height = int(FTerm::getLineNumber()); + const auto term_width = int(FTerm::getColumnNumber()); + const auto term_height = int(FTerm::getLineNumber()); if ( x >= term_width && term_width > 0 ) { @@ -434,7 +434,7 @@ int FVTerm::print (const std::vector& term_string) int FVTerm::print (FTermArea* area, const std::vector& term_string) { int len{0}; - const uInt tabstop = uInt(FTerm::getTabstop()); + const auto tabstop = uInt(FTerm::getTabstop()); if ( ! area ) return -1; @@ -734,10 +734,10 @@ void FVTerm::resizeArea ( const FRect& box const int offset_left = box.getX(); const int offset_top = box.getY(); - const int width = int(box.getWidth()); - const int height = int(box.getHeight()); - const int rsw = int(shadow.getWidth()); - const int bsh = int(shadow.getHeight()); + const auto width = int(box.getWidth()); + const auto height = int(box.getHeight()); + const auto rsw = int(shadow.getWidth()); + const auto bsh = int(shadow.getHeight()); assert ( offset_top >= 0 ); assert ( width > 0 && width + rsw > 0 ); @@ -827,8 +827,8 @@ void FVTerm::restoreVTerm (const FRect& box) int x = box.getX() - 1; int y = box.getY() - 1; - int w = int(box.getWidth()); - int h = int(box.getHeight()); + auto w = int(box.getWidth()); + auto h = int(box.getHeight()); if ( x < 0 ) x = 0; @@ -970,8 +970,8 @@ void FVTerm::getArea (const FRect& box, const FTermArea* area) const int x = box.getX(); const int y = box.getY(); - const int w = int(box.getWidth()); - const int h = int(box.getHeight()); + const auto w = int(box.getWidth()); + const auto h = int(box.getHeight()); const int dx = x - area->offset_left + 1; const int dy = y - area->offset_top + 1; int y_end{}; @@ -1040,8 +1040,8 @@ void FVTerm::putArea (const FTermArea* area) const for (int y{0}; y < y_end; y++) // Line loop { bool modified{false}; - int line_xmin = int(area->changes[y].xmin); - int line_xmax = int(area->changes[y].xmax); + auto line_xmin = int(area->changes[y].xmin); + auto line_xmax = int(area->changes[y].xmax); if ( line_xmin > line_xmax ) continue; @@ -1289,7 +1289,7 @@ void FVTerm::clearArea (FTermArea* area, int fillchar) const return; } - const uInt w = uInt(area->width + area->right_shadow); + const auto w = uInt(area->width + area->right_shadow); if ( area->right_shadow == 0 ) { @@ -1795,7 +1795,7 @@ bool FVTerm::isInsideArea (const FPoint& pos, const FTermArea* area) } //---------------------------------------------------------------------- -const FChar FVTerm::generateCharacter (const FPoint& pos) +FChar FVTerm::generateCharacter (const FPoint& pos) { // Generates characters for a given position considering all areas @@ -1865,7 +1865,7 @@ const FChar FVTerm::generateCharacter (const FPoint& pos) } //---------------------------------------------------------------------- -const FChar FVTerm::getCharacter ( character_type char_type +FChar FVTerm::getCharacter ( character_type char_type , const FPoint& pos , FVTerm* obj ) { @@ -1925,14 +1925,14 @@ const FChar FVTerm::getCharacter ( character_type char_type } //---------------------------------------------------------------------- -const FChar FVTerm::getCoveredCharacter (const FPoint& pos, FVTerm* obj) +FChar FVTerm::getCoveredCharacter (const FPoint& pos, FVTerm* obj) { // Gets the covered character for a given position return getCharacter (covered_character, pos, obj); } //---------------------------------------------------------------------- -const FChar FVTerm::getOverlappedCharacter (const FPoint& pos, FVTerm* obj) +FChar FVTerm::getOverlappedCharacter (const FPoint& pos, FVTerm* obj) { // Gets the overlapped character for a given position return getCharacter (overlapped_character, pos, obj); diff --git a/src/fwidget.cpp b/src/fwidget.cpp index a1843529..4d843aef 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -242,7 +242,7 @@ std::vector& FWidget::doubleFlatLine_ref (fc::sides side) } //---------------------------------------------------------------------- -const FPoint FWidget::getPrintPos() +FPoint FWidget::getPrintPos() { const auto& cur = getPrintCursor(); return { cur.getX() - woffset.getX1() - getX() + 1 @@ -721,7 +721,7 @@ void FWidget::setDoubleFlatLine (fc::sides side, int pos, bool bit) assert ( pos >= 1 ); uLong length{}; - const uLong index = uLong(pos - 1); + const auto index = uLong(pos - 1); switch ( side ) { @@ -957,7 +957,8 @@ void FWidget::show() show_root_widget = this; } - draw(); // Draw the widget + adjustSize(); // Alignment before drawing + draw(); // Draw the widget flags.hidden = false; flags.shown = true; @@ -1209,8 +1210,8 @@ void FWidget::setParentOffset() void FWidget::setTermOffset() { const auto& r = getRootWidget(); - const int w = int(r->getWidth()); - const int h = int(r->getHeight()); + const auto w = int(r->getWidth()); + const auto h = int(r->getHeight()); woffset.setCoordinates (0, 0, w - 1, h - 1); } @@ -1585,55 +1586,94 @@ bool FWidget::event (FEvent* ev) //---------------------------------------------------------------------- void FWidget::onKeyPress (FKeyEvent*) -{ } +{ + // This event handler can be reimplemented in a subclass + // to receive key press events for the widget +} //---------------------------------------------------------------------- void FWidget::onKeyUp (FKeyEvent*) -{ } +{ + // This event handler can be reimplemented in a subclass + // to receive key up events for the widget +} //---------------------------------------------------------------------- void FWidget::onKeyDown (FKeyEvent*) -{ } +{ + // This event handler can be reimplemented in a subclass + // to receive key down events for the widget +} //---------------------------------------------------------------------- void FWidget::onMouseDown (FMouseEvent*) -{ } +{ + // This event handler can be reimplemented in a subclass + // to receive mouse down events for the widget +} //---------------------------------------------------------------------- void FWidget::onMouseUp (FMouseEvent*) -{ } +{ + // This event handler can be reimplemented in a subclass + // to receive mouse up events for the widget +} //---------------------------------------------------------------------- void FWidget::onMouseDoubleClick (FMouseEvent*) -{ } +{ + // This event handler can be reimplemented in a subclass + // to receive mouse double clicks events for the widget +} //---------------------------------------------------------------------- void FWidget::onWheel (FWheelEvent*) -{ } +{ + // This event handler can be reimplemented in a subclass + // to receive mouse wheel events for the widget +} //---------------------------------------------------------------------- void FWidget::onMouseMove (FMouseEvent*) -{ } +{ + // This event handler can be reimplemented in a subclass + // to receive mouse move events for the widget +} //---------------------------------------------------------------------- void FWidget::onFocusIn (FFocusEvent*) -{ } +{ + // This event handler can be reimplemented in a subclass + // to receive a widget focus event (get focus) +} //---------------------------------------------------------------------- void FWidget::onFocusOut (FFocusEvent*) -{ } +{ + // This event handler can be reimplemented in a subclass + // to receive a widget focus event (lost focus) +} //---------------------------------------------------------------------- void FWidget::onChildFocusIn (FFocusEvent*) -{ } +{ + // This event handler can be reimplemented in a subclass + // to receive a child widget focus event (get focus) +} //---------------------------------------------------------------------- void FWidget::onChildFocusOut (FFocusEvent*) -{ } +{ + // This event handler can be reimplemented in a subclass + // to receive a child widget focus event (lost focus) +} //---------------------------------------------------------------------- void FWidget::onAccel (FAccelEvent*) -{ } +{ + // This event handler can be reimplemented in a subclass to receive + // an event when an acceleration key is pressed for this widget +} //---------------------------------------------------------------------- void FWidget::onResize (FResizeEvent* ev) @@ -1646,15 +1686,23 @@ void FWidget::onResize (FResizeEvent* ev) //---------------------------------------------------------------------- void FWidget::onShow (FShowEvent*) -{ } +{ + // This event handler can be reimplemented in a subclass + // to receive a widget show event +} //---------------------------------------------------------------------- void FWidget::onHide (FHideEvent*) -{ } +{ + // This event handler can be reimplemented in a subclass + // to receive a widget hide event +} //---------------------------------------------------------------------- void FWidget::onClose (FCloseEvent* ev) { + // This event handler can be reimplemented in a subclass + // to receive a widget close event ev->accept(); } @@ -1914,7 +1962,10 @@ bool FWidget::changeFocus ( FWidget* follower, FWidget* parent //---------------------------------------------------------------------- void FWidget::draw() -{ } +{ + // This method must be reimplemented in a subclass + // for drawing the widget +} //---------------------------------------------------------------------- void FWidget::drawWindows() const diff --git a/src/fwidget_functions.cpp b/src/fwidget_functions.cpp index b8072edb..b3d60d80 100644 --- a/src/fwidget_functions.cpp +++ b/src/fwidget_functions.cpp @@ -97,7 +97,7 @@ std::size_t getHotkeyPos (const FString& src, FString& dest) // Find hotkey position in string // + generate a new string without the '&'-sign - constexpr std::size_t NOT_SET = static_cast(-1); + constexpr auto NOT_SET = static_cast(-1); std::size_t hotkeypos{NOT_SET}; std::size_t i{0}; diff --git a/src/fwindow.cpp b/src/fwindow.cpp index d8d6c8cf..bb66c627 100644 --- a/src/fwindow.cpp +++ b/src/fwindow.cpp @@ -815,19 +815,31 @@ bool FWindow::event (FEvent* ev) //---------------------------------------------------------------------- void FWindow::onWindowActive (FEvent*) -{ } +{ + // This event handler can be reimplemented in a subclass + // to receive activation events for this window +} //---------------------------------------------------------------------- void FWindow::onWindowInactive (FEvent*) -{ } +{ + // This event handler can be reimplemented in a subclass + // to receive deactivation events for this window +} //---------------------------------------------------------------------- void FWindow::onWindowRaised (FEvent*) -{ } +{ + // This event handler can be reimplemented in a subclass + // to receive window raising events for this window +} //---------------------------------------------------------------------- void FWindow::onWindowLowered (FEvent*) -{ } +{ + // This event handler can be reimplemented in a subclass + // to receive window lowering events for this window +} // private methods of FWindow diff --git a/src/include/final/emptyfstring.h b/src/include/final/emptyfstring.h index 27123bf6..c6ab6f97 100644 --- a/src/include/final/emptyfstring.h +++ b/src/include/final/emptyfstring.h @@ -62,7 +62,7 @@ public: // Disable copy assignment operator (=) emptyFString& operator = (const emptyFString&) = delete; - static const FString getClassName(); + static FString getClassName(); static bool isNull(); static const FString& get(); static void clear(); @@ -74,7 +74,7 @@ private: // emptyFString inline functions //---------------------------------------------------------------------- -inline const FString emptyFString::getClassName() +inline FString emptyFString::getClassName() { return "emptyFString"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fapplication.h b/src/include/final/fapplication.h index 5f3117c2..4a0b0d07 100644 --- a/src/include/final/fapplication.h +++ b/src/include/final/fapplication.h @@ -110,7 +110,7 @@ class FApplication : public FWidget FApplication& operator = (const FApplication&) = delete; // Accessors - const FString getClassName() const override; + FString getClassName() const override; int getArgc() const; char** getArgv() const; static FApplication* getApplicationObject(); @@ -229,7 +229,7 @@ FApplication* getFApplication(); // FApplication inline functions //---------------------------------------------------------------------- -inline const FString FApplication::getClassName() const +inline FString FApplication::getClassName() const { return "FApplication"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fbusyindicator.h b/src/include/final/fbusyindicator.h index a73618b1..82b7540e 100644 --- a/src/include/final/fbusyindicator.h +++ b/src/include/final/fbusyindicator.h @@ -82,7 +82,7 @@ class FBusyIndicator : public FToolTip FBusyIndicator& operator = (const FBusyIndicator&) = delete; // Accessors - const FString getClassName() const override; + FString getClassName() const override; // Inquiries bool isRunning() const; @@ -113,7 +113,7 @@ class FBusyIndicator : public FToolTip // FBusyIndicator inline functions //---------------------------------------------------------------------- -inline const FString FBusyIndicator::getClassName() const +inline FString FBusyIndicator::getClassName() const { return "FBusyIndicator"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fbutton.h b/src/include/final/fbutton.h index 36ba2ae1..2e1b4aea 100644 --- a/src/include/final/fbutton.h +++ b/src/include/final/fbutton.h @@ -77,7 +77,7 @@ class FButton : public FWidget FButton& operator = (const FString&); // Accessors - const FString getClassName() const override; + FString getClassName() const override; FString getText() const; // Mutators @@ -134,7 +134,7 @@ class FButton : public FWidget private: // Constants - static constexpr std::size_t NOT_SET = static_cast(-1); + static constexpr auto NOT_SET = static_cast(-1); // Methods void init(); @@ -174,7 +174,7 @@ class FButton : public FWidget // FButton inline functions //---------------------------------------------------------------------- -inline const FString FButton::getClassName() const +inline FString FButton::getClassName() const { return "FButton"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fbuttongroup.h b/src/include/final/fbuttongroup.h index f59e05fd..410f186a 100644 --- a/src/include/final/fbuttongroup.h +++ b/src/include/final/fbuttongroup.h @@ -78,7 +78,7 @@ class FButtonGroup : public FScrollView FButtonGroup& operator = (const FButtonGroup&) = delete; // Accessor - const FString getClassName() const override; + FString getClassName() const override; FToggleButton* getFirstButton(); FToggleButton* getLastButton(); FToggleButton* getButton (int) const; @@ -119,7 +119,7 @@ class FButtonGroup : public FScrollView private: // Constants - static constexpr std::size_t NOT_SET = static_cast(-1); + static constexpr auto NOT_SET = static_cast(-1); // Inquiries bool isRadioButton (const FToggleButton*) const; @@ -139,7 +139,7 @@ class FButtonGroup : public FScrollView // FButtonGroup inline functions //---------------------------------------------------------------------- -inline const FString FButtonGroup::getClassName() const +inline FString FButtonGroup::getClassName() const { return "FButtonGroup"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fcallback.h b/src/include/final/fcallback.h index 12829d09..32de081b 100644 --- a/src/include/final/fcallback.h +++ b/src/include/final/fcallback.h @@ -147,7 +147,7 @@ class FCallback FCallback& operator = (const FCallback&) = delete; // Accessors - const FString getClassName() const; + FString getClassName() const; std::size_t getCallbackCount() const; // Methods @@ -220,7 +220,7 @@ class FCallback // FCallback inline functions //---------------------------------------------------------------------- -inline const FString FCallback::getClassName() const +inline FString FCallback::getClassName() const { return "FCallback"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fcharmap.h b/src/include/final/fcharmap.h index 79571fcd..9d20d745 100644 --- a/src/include/final/fcharmap.h +++ b/src/include/final/fcharmap.h @@ -36,17 +36,10 @@ namespace finalcut namespace fc { -extern uInt character[][fc::NUM_OF_ENCODINGS]; -extern const std::size_t last_char_item; - -extern const int vt100_key_to_utf8[][2]; -extern const std::size_t last_key_item; - -extern const wchar_t cp437_ucs[][2]; -extern const std::size_t last_cp437_item; - -extern const wchar_t halfwidth_fullwidth[][2]; -extern const std::size_t last_halfwidth_item; +extern std::array, 115> character; +extern const std::array, 39> vt100_key_to_utf8; +extern const std::array, 256> cp437_ucs; +extern const std::array, 227> halfwidth_fullwidth; } // namespace fc diff --git a/src/include/final/fcheckbox.h b/src/include/final/fcheckbox.h index 07c5626d..40e74bb7 100644 --- a/src/include/final/fcheckbox.h +++ b/src/include/final/fcheckbox.h @@ -78,7 +78,7 @@ class FCheckBox : public FToggleButton FCheckBox& operator = (const FCheckBox&) = delete; // Accessor - const FString getClassName() const override; + FString getClassName() const override; private: // Methods @@ -91,7 +91,7 @@ class FCheckBox : public FToggleButton // FCheckBox inline functions //---------------------------------------------------------------------- -inline const FString FCheckBox::getClassName() const +inline FString FCheckBox::getClassName() const { return "FCheckBox"; } } // namespace finalcut diff --git a/src/include/final/fcheckmenuitem.h b/src/include/final/fcheckmenuitem.h index 82cb04ec..c5ea112b 100644 --- a/src/include/final/fcheckmenuitem.h +++ b/src/include/final/fcheckmenuitem.h @@ -78,7 +78,7 @@ class FCheckMenuItem : public FMenuItem FCheckMenuItem& operator = (const FCheckMenuItem&) = delete; // Accessor - const FString getClassName() const override; + FString getClassName() const override; private: // Methods @@ -89,7 +89,7 @@ class FCheckMenuItem : public FMenuItem // FCheckMenuItem inline functions //---------------------------------------------------------------------- -inline const FString FCheckMenuItem::getClassName() const +inline FString FCheckMenuItem::getClassName() const { return "FCheckMenuItem"; } } // namespace finalcut diff --git a/src/include/final/fcolorpair.h b/src/include/final/fcolorpair.h index badcf497..7309fc54 100644 --- a/src/include/final/fcolorpair.h +++ b/src/include/final/fcolorpair.h @@ -65,7 +65,7 @@ class FColorPair FColorPair& operator = (const FColorPair& pair) = default; // Accessor - const FString getClassName() const + FString getClassName() const { return "FColorPair"; } FColor getForegroundColor() const diff --git a/src/include/final/fcolorpalette.h b/src/include/final/fcolorpalette.h index 606ab79c..d5e781cb 100644 --- a/src/include/final/fcolorpalette.h +++ b/src/include/final/fcolorpalette.h @@ -59,7 +59,7 @@ class FColorPalette virtual ~FColorPalette(); // Accessor - virtual const FString getClassName() const; + virtual FString getClassName() const; // Methods virtual void setColorPalette() = 0; @@ -76,7 +76,7 @@ class FColorPalette // FColorPalette inline functions //---------------------------------------------------------------------- -inline const FString FColorPalette::getClassName() const +inline FString FColorPalette::getClassName() const { return "FColorPalette"; } @@ -107,7 +107,7 @@ class default8ColorPalette final : public FColorPalette ~default8ColorPalette(); // Accessor - const FString getClassName() const override; + FString getClassName() const override; // Methods void setColorPalette() override; @@ -116,7 +116,7 @@ class default8ColorPalette final : public FColorPalette // default8ColorPalette inline functions //---------------------------------------------------------------------- -inline const FString default8ColorPalette::getClassName() const +inline FString default8ColorPalette::getClassName() const { return "default8ColorPalette"; } @@ -147,7 +147,7 @@ class default16ColorPalette final : public FColorPalette ~default16ColorPalette(); // Accessor - const FString getClassName() const override; + FString getClassName() const override; // Methods void setColorPalette() override; @@ -156,7 +156,7 @@ class default16ColorPalette final : public FColorPalette // default16ColorPalette inline functions //---------------------------------------------------------------------- -inline const FString default16ColorPalette::getClassName() const +inline FString default16ColorPalette::getClassName() const { return "default16ColorPalette"; } /* Inheritance diagram @@ -186,7 +186,7 @@ class default16DarkColorPalette final : public FColorPalette ~default16DarkColorPalette(); // Accessor - const FString getClassName() const override; + FString getClassName() const override; // Methods void setColorPalette() override; @@ -195,7 +195,7 @@ class default16DarkColorPalette final : public FColorPalette // default16ColorPalette inline functions //---------------------------------------------------------------------- -inline const FString default16DarkColorPalette::getClassName() const +inline FString default16DarkColorPalette::getClassName() const { return "default16DarkColorPalette"; } } // namespace finalcut diff --git a/src/include/final/fcombobox.h b/src/include/final/fcombobox.h index b6758717..5949deb8 100644 --- a/src/include/final/fcombobox.h +++ b/src/include/final/fcombobox.h @@ -84,7 +84,7 @@ class FDropDownListBox : public FWindow FDropDownListBox& operator = (const FDropDownListBox&) = delete; // Accessors - const FString getClassName() const override; + FString getClassName() const override; // Mutators void setGeometry ( const FPoint&, const FSize& @@ -115,7 +115,7 @@ class FDropDownListBox : public FWindow // FDropDownListBox inline functions //---------------------------------------------------------------------- -inline const FString FDropDownListBox::getClassName() const +inline FString FDropDownListBox::getClassName() const { return "FDropDownListBox"; } //---------------------------------------------------------------------- @@ -148,7 +148,7 @@ class FComboBox : public FWidget // Overloaded operators // Accessors - const FString getClassName() const override; + FString getClassName() const override; std::size_t getCount() const; FString getText() const; template @@ -239,7 +239,7 @@ bool closeComboBox (FDropDownListBox*, const FPoint&); // FComboBox inline functions //---------------------------------------------------------------------- -inline const FString FComboBox::getClassName() const +inline FString FComboBox::getClassName() const { return "FComboBox"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fdata.h b/src/include/final/fdata.h index a5aa27e5..70e5bcab 100644 --- a/src/include/final/fdata.h +++ b/src/include/final/fdata.h @@ -124,7 +124,7 @@ class FDataAccess virtual ~FDataAccess(); // Accessors - virtual const FString getClassName() const + virtual FString getClassName() const { return "FDataAccess"; } @@ -225,7 +225,7 @@ class FData : public FDataAccess } // Accessors - const FString getClassName() const override + FString getClassName() const override { return "FData"; } diff --git a/src/include/final/fdialog.h b/src/include/final/fdialog.h index 64e903d4..4288332f 100644 --- a/src/include/final/fdialog.h +++ b/src/include/final/fdialog.h @@ -91,8 +91,8 @@ class FDialog : public FWindow FDialog& operator = (const FDialog&) = delete; // Accessors - const FString getClassName() const override; - virtual const FString getText() const; + FString getClassName() const override; + virtual FString getText() const; // Mutators bool setDialogWidget (bool); @@ -200,6 +200,8 @@ class FDialog : public FWindow void raiseActivateDialog(); void lowerActivateDialog(); bool isOutsideTerminal (const FPoint&) const; + bool isLeftOutside(); + bool isBottomOutside(); bool isLowerRightResizeCorner (const mouseStates&) const; void resizeMouseDown (const mouseStates&); void resizeMouseUpMove (const mouseStates&, bool = false); @@ -237,11 +239,11 @@ class FDialog : public FWindow // FDialog inline functions //---------------------------------------------------------------------- -inline const FString FDialog::getClassName() const +inline FString FDialog::getClassName() const { return "FDialog"; } //---------------------------------------------------------------------- -inline const FString FDialog::getText() const +inline FString FDialog::getText() const { return tb_text; } //---------------------------------------------------------------------- diff --git a/src/include/final/fdialoglistmenu.h b/src/include/final/fdialoglistmenu.h index e80f8953..f753242e 100644 --- a/src/include/final/fdialoglistmenu.h +++ b/src/include/final/fdialoglistmenu.h @@ -84,7 +84,7 @@ class FDialogListMenu : public FMenu FDialogListMenu& operator = (const FDialogListMenu&) = delete; // Accessors - const FString getClassName() const override; + FString getClassName() const override; private: // Method @@ -94,7 +94,7 @@ class FDialogListMenu : public FMenu // FDialogListMenu inline functions //---------------------------------------------------------------------- -inline const FString FDialogListMenu::getClassName() const +inline FString FDialogListMenu::getClassName() const { return "FDialogListMenu"; } } // namespace finalcut diff --git a/src/include/final/fevent.h b/src/include/final/fevent.h index da0313cf..74a27d04 100644 --- a/src/include/final/fevent.h +++ b/src/include/final/fevent.h @@ -80,6 +80,8 @@ #error "Only can be included directly." #endif +#include + #include "final/fc.h" #include "final/fdata.h" #include "final/fpoint.h" @@ -185,9 +187,9 @@ class FWheelEvent : public FEvent // wheel event int getWheel() const; private: - FPoint p; - FPoint tp; - int w; + FPoint p{}; + FPoint tp{}; + int w{}; }; @@ -354,9 +356,12 @@ class FUserEvent : public FEvent // user event void setData (T&&); private: + // Using-declaration + using FDataAccessPtr = std::shared_ptr; + + // Data members int uid{0}; - FDataAccess* data_pointer{nullptr}; - bool external_data_pointer{false}; + FDataAccessPtr data_pointer{nullptr}; }; //---------------------------------------------------------------------- @@ -377,15 +382,14 @@ inline clean_fdata_t& FUserEvent::getData() const template inline void FUserEvent::setFDataObject (T&& fdata) { - external_data_pointer = true; - data_pointer = &(std::forward(fdata)); + data_pointer.reset(&(std::forward(fdata))); } + //---------------------------------------------------------------------- template inline void FUserEvent::setData (T&& data) { - external_data_pointer = false; - data_pointer = makeFData(std::forward(data)); + data_pointer.reset(makeFData(std::forward(data))); } } // namespace finalcut diff --git a/src/include/final/ffiledialog.h b/src/include/final/ffiledialog.h index eb4ab939..b18f1ba0 100644 --- a/src/include/final/ffiledialog.h +++ b/src/include/final/ffiledialog.h @@ -112,10 +112,10 @@ class FFileDialog : public FDialog FFileDialog& operator = (const FFileDialog&); // Accessors - const FString getClassName() const override; - const FString getPath() const; - const FString getFilter() const; - const FString getSelectedFile() const; + FString getClassName() const override; + FString getPath() const; + FString getFilter() const; + FString getSelectedFile() const; bool getShowHiddenFiles() const; // Mutators @@ -129,12 +129,12 @@ class FFileDialog : public FDialog void onKeyPress (FKeyEvent*) override; // Methods - static const FString fileOpenChooser ( FWidget* - , const FString& = FString() - , const FString& = FString() ); - static const FString fileSaveChooser ( FWidget* - , const FString& = FString() - , const FString& = FString() ); + static FString fileOpenChooser ( FWidget* + , const FString& = FString() + , const FString& = FString() ); + static FString fileSaveChooser ( FWidget* + , const FString& = FString() + , const FString& = FString() ); protected: // Method @@ -203,7 +203,7 @@ class FFileDialog : public FDialog void selectDirectoryEntry (const char* const); int changeDir (const FString&); void printPath (const FString&); - static const FString getHomeDir(); + static FString getHomeDir(); // Callback methods void cb_processActivate(); @@ -232,23 +232,23 @@ class FFileDialog : public FDialog , const FFileDialog::FDirEntry& ); friend bool sortDirFirst ( const FFileDialog::FDirEntry& , const FFileDialog::FDirEntry& ); - friend const FString fileChooser ( FWidget* - , const FString& - , const FString& - , FFileDialog::DialogType); + friend FString fileChooser ( FWidget* + , const FString& + , const FString& + , FFileDialog::DialogType); }; // FMessageBox inline functions //---------------------------------------------------------------------- -inline const FString FFileDialog::getClassName() const +inline FString FFileDialog::getClassName() const { return "FFileDialog"; } //---------------------------------------------------------------------- -inline const FString FFileDialog::getPath() const +inline FString FFileDialog::getPath() const { return directory; } //---------------------------------------------------------------------- -inline const FString FFileDialog::getFilter() const +inline FString FFileDialog::getFilter() const { return filter_pattern; } //---------------------------------------------------------------------- diff --git a/src/include/final/fkey_map.h b/src/include/final/fkey_map.h index 12dfaa57..b3465059 100644 --- a/src/include/final/fkey_map.h +++ b/src/include/final/fkey_map.h @@ -33,9 +33,9 @@ namespace finalcut namespace fc { -extern FKeyMap fkey[]; -extern const FMetakeyMap fmetakey[]; -extern const FKeyName fkeyname[]; +extern std::array fkey; +extern const std::array fmetakey; +extern const std::array fkeyname; } // namespace fc diff --git a/src/include/final/fkeyboard.h b/src/include/final/fkeyboard.h index 6f090aa7..70f6a483 100644 --- a/src/include/final/fkeyboard.h +++ b/src/include/final/fkeyboard.h @@ -36,7 +36,11 @@ #endif #include + +#include #include +#include + #include "final/fstring.h" #include "final/ftypes.h" @@ -99,16 +103,17 @@ class FKeyboard final FKeyboard& operator = (const FKeyboard&) = delete; // Accessors - const FString getClassName() const; + FString getClassName() const; FKey getKey() const; - const FString getKeyName (const FKey) const; + FString getKeyName (const FKey) const; keybuffer& getKeyBuffer(); timeval* getKeyPressedTime(); static uInt64 getKeypressTimeout(); static uInt64 getReadBlockingTime(); // Mutators - void setTermcapMap (fc::FKeyMap*); + template + void setTermcapMap (const T&); static void setKeypressTimeout (const uInt64); static void setReadBlockingTime (const uInt64); void enableUTF8(); @@ -132,6 +137,9 @@ class FKeyboard final void escapeKeyHandling(); private: + // Using-declaration + using FKeyMapPtr = std::shared_ptr>; + // Constants static constexpr FKey NOT_SET = static_cast(-1); @@ -176,7 +184,7 @@ class FKeyboard final static uInt64 read_blocking_time; static uInt64 key_timeout; static uInt64 interval_timeout; - fc::FKeyMap* key_map{nullptr}; + FKeyMapPtr key_map{}; FKey key{0}; uChar read_character{}; char fifo_buf[FIFO_BUF_SIZE]{'\0'}; @@ -191,7 +199,7 @@ class FKeyboard final // FKeyboard inline functions //---------------------------------------------------------------------- -inline const FString FKeyboard::getClassName() const +inline FString FKeyboard::getClassName() const { return "FKeyboard"; } //---------------------------------------------------------------------- @@ -214,6 +222,11 @@ inline uInt64 FKeyboard::getKeypressTimeout() inline uInt64 FKeyboard::getReadBlockingTime() { return read_blocking_time; } +//---------------------------------------------------------------------- +template +inline void FKeyboard::setTermcapMap (const T& keymap) +{ key_map = std::make_shared(keymap); } + //---------------------------------------------------------------------- inline void FKeyboard::setKeypressTimeout (const uInt64 timeout) { key_timeout = timeout; } diff --git a/src/include/final/flabel.h b/src/include/final/flabel.h index d9c82cef..b6e7a637 100644 --- a/src/include/final/flabel.h +++ b/src/include/final/flabel.h @@ -87,7 +87,7 @@ class FLabel : public FWidget const FLabel& operator >> (FString&) const; // Accessors - const FString getClassName() const override; + FString getClassName() const override; FWidget* getAccelWidget(); fc::text_alignment getAlignment() const; FString& getText(); @@ -127,7 +127,7 @@ class FLabel : public FWidget private: // Constants - static constexpr std::size_t NOT_SET = static_cast(-1); + static constexpr auto NOT_SET = static_cast(-1); // Methods void init(); @@ -165,7 +165,7 @@ inline FLabel& FLabel::operator << (const typeT& s) } //---------------------------------------------------------------------- -inline const FString FLabel::getClassName() const +inline FString FLabel::getClassName() const { return "FLabel"; } //---------------------------------------------------------------------- diff --git a/src/include/final/flineedit.h b/src/include/final/flineedit.h index 25c36aa9..cedeadfc 100644 --- a/src/include/final/flineedit.h +++ b/src/include/final/flineedit.h @@ -103,7 +103,7 @@ class FLineEdit : public FWidget const FLineEdit& operator >> (FString&) const; // Accessors - const FString getClassName() const override; + FString getClassName() const override; FString getText() const; std::size_t getMaxLength() const; std::size_t getCursorPosition() const; @@ -175,7 +175,7 @@ class FLineEdit : public FWidget }; // Constants - static constexpr std::size_t NOT_SET = static_cast(-1); + static constexpr auto NOT_SET = static_cast(-1); // Methods void init(); @@ -237,7 +237,7 @@ inline FLineEdit& FLineEdit::operator << (const typeT& s) } //---------------------------------------------------------------------- -inline const FString FLineEdit::getClassName() const +inline FString FLineEdit::getClassName() const { return "FLineEdit"; } //---------------------------------------------------------------------- diff --git a/src/include/final/flistbox.h b/src/include/final/flistbox.h index 7c923e0a..e2a99540 100644 --- a/src/include/final/flistbox.h +++ b/src/include/final/flistbox.h @@ -48,6 +48,7 @@ #error "Only can be included directly." #endif +#include #include #include @@ -83,7 +84,7 @@ class FListBoxItem FListBoxItem& operator = (const FListBoxItem&); // Accessors - virtual const FString getClassName() const; + virtual FString getClassName() const; virtual FString getText() const; template clean_fdata_t
& getData() const; @@ -97,9 +98,12 @@ class FListBoxItem void clear(); private: + // Using-declaration + using FDataAccessPtr = std::shared_ptr; + // Data members FString text{}; - FDataAccess* data_pointer{nullptr}; + FDataAccessPtr data_pointer{}; fc::brackets_type brackets{fc::NoBrackets}; bool selected{false}; @@ -117,7 +121,7 @@ inline FListBoxItem::FListBoxItem (const FString& txt, DT&& data) { } //---------------------------------------------------------------------- -inline const FString FListBoxItem::getClassName() const +inline FString FListBoxItem::getClassName() const { return "FListBoxItem"; } //---------------------------------------------------------------------- @@ -139,7 +143,8 @@ inline void FListBoxItem::setText (const FString& txt) template inline void FListBoxItem::setData (DT&& data) { - data_pointer = makeFData(std::forward
(data)); + const auto data_obj = makeFData(std::forward
(data)); + data_pointer.reset(data_obj); } //---------------------------------------------------------------------- @@ -179,7 +184,7 @@ class FListBox : public FWidget FListBox& operator = (const FListBox&) = delete; // Accessors - const FString getClassName() const override; + FString getClassName() const override; std::size_t getCount() const; FListBoxItem& getItem (std::size_t); const FListBoxItem& getItem (std::size_t) const; @@ -415,7 +420,7 @@ inline FListBox::FListBox ( Container container } //---------------------------------------------------------------------- -inline const FString FListBox::getClassName() const +inline FString FListBox::getClassName() const { return "FListBox"; } //---------------------------------------------------------------------- diff --git a/src/include/final/flistview.h b/src/include/final/flistview.h index 5052fbea..0c44ab21 100644 --- a/src/include/final/flistview.h +++ b/src/include/final/flistview.h @@ -48,6 +48,7 @@ #endif #include +#include #include #include #include @@ -86,7 +87,7 @@ class FListViewItem : public FObject FListViewItem& operator = (const FListViewItem&); // Accessors - const FString getClassName() const override; + FString getClassName() const override; uInt getColumnCount() const; int getSortColumn() const; FString getText (int) const; @@ -113,6 +114,9 @@ class FListViewItem : public FObject void collapse(); private: + // Using-declaration + using FDataAccessPtr = std::shared_ptr; + // Inquiry bool isExpandable() const; bool isCheckable() const; @@ -127,7 +131,7 @@ class FListViewItem : public FObject // Data members FStringList column_list{}; - FDataAccess* data_pointer{nullptr}; + FDataAccessPtr data_pointer{}; iterator root{}; std::size_t visible_lines{1}; bool expandable{false}; @@ -159,7 +163,7 @@ inline FListViewItem::FListViewItem ( const FStringList& cols } //---------------------------------------------------------------------- -inline const FString FListViewItem::getClassName() const +inline FString FListViewItem::getClassName() const { return "FListViewItem"; } //---------------------------------------------------------------------- @@ -177,7 +181,8 @@ inline clean_fdata_t
& FListViewItem::getData() const template inline void FListViewItem::setData (DT&& data) { - data_pointer = makeFData(std::forward
(data)); + const auto data_obj = makeFData(std::forward
(data)); + data_pointer = data_obj; } //---------------------------------------------------------------------- @@ -237,7 +242,7 @@ class FListViewIterator bool operator != (const FListViewIterator&) const; // Accessor - const FString getClassName() const; + FString getClassName() const; int& getPosition(); // Methods @@ -273,7 +278,7 @@ inline bool FListViewIterator::operator != (const FListViewIterator& rhs) const { return node != rhs.node; } //---------------------------------------------------------------------- -inline const FString FListViewIterator::getClassName() const +inline FString FListViewIterator::getClassName() const { return "FListViewIterator"; } //---------------------------------------------------------------------- @@ -304,7 +309,7 @@ class FListView : public FWidget FListView& operator = (const FListView&) = delete; // Accessors - const FString getClassName() const override; + FString getClassName() const override; std::size_t getCount() const; fc::text_alignment getColumnAlignment (int) const; FString getColumnText (int) const; @@ -545,7 +550,7 @@ struct FListView::Header // FListView inline functions //---------------------------------------------------------------------- -inline const FString FListView::getClassName() const +inline FString FListView::getClassName() const { return "FListView"; } //---------------------------------------------------------------------- diff --git a/src/include/final/flog.h b/src/include/final/flog.h index 5fafbc83..92f0e6f9 100644 --- a/src/include/final/flog.h +++ b/src/include/final/flog.h @@ -84,7 +84,7 @@ class FLog : public std::stringbuf FLog& operator << (IOManip); FLog& operator << (LogLevel); - virtual const FString getClassName() const; + virtual FString getClassName() const; virtual void info (const std::string&) = 0; virtual void warn (const std::string&) = 0; virtual void error (const std::string&) = 0; @@ -130,7 +130,7 @@ inline FLog& FLog::operator << (IOManip pf) } //---------------------------------------------------------------------- -inline const FString FLog::getClassName() const +inline FString FLog::getClassName() const { return "FLog"; } //---------------------------------------------------------------------- diff --git a/src/include/final/flogger.h b/src/include/final/flogger.h index 2811bc67..5f0d64ea 100644 --- a/src/include/final/flogger.h +++ b/src/include/final/flogger.h @@ -72,7 +72,7 @@ class FLogger : public FLog ~FLogger() override; // Methods - const FString getClassName() const override; + FString getClassName() const override; void info (const std::string&) override; void warn (const std::string&) override; void error (const std::string&) override; @@ -86,8 +86,8 @@ class FLogger : public FLog private: // Methods void newlineReplace (std::string&, const std::string&) const; - const std::string getTimeString() const; - const std::string getEOL() const; + std::string getTimeString() const; + std::string getEOL() const; void printLogLine (const std::string&); // Data member @@ -97,7 +97,7 @@ class FLogger : public FLog // FLogger inline functions //---------------------------------------------------------------------- -inline const FString FLogger::getClassName() const +inline FString FLogger::getClassName() const { return "FLogger"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fmenu.h b/src/include/final/fmenu.h index 30727eca..cda08e57 100644 --- a/src/include/final/fmenu.h +++ b/src/include/final/fmenu.h @@ -91,7 +91,7 @@ class FMenu : public FWindow, public FMenuList FMenu& operator = (const FMenu&) = delete; // Accessors - const FString getClassName() const override; + FString getClassName() const override; FString getText() const; FMenuItem* getItem(); @@ -133,7 +133,7 @@ class FMenu : public FWindow, public FMenuList private: // Constants - static constexpr std::size_t NOT_SET = static_cast(-1); + static constexpr auto NOT_SET = static_cast(-1); static constexpr bool SELECT_ITEM = true; // Typedef @@ -248,7 +248,7 @@ std::tuple closeOpenMenus (FMenu*, const FPoint&); // FMenu inline functions //---------------------------------------------------------------------- -inline const FString FMenu::getClassName() const +inline FString FMenu::getClassName() const { return "FMenu"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fmenubar.h b/src/include/final/fmenubar.h index 40961246..ec51b27f 100644 --- a/src/include/final/fmenubar.h +++ b/src/include/final/fmenubar.h @@ -83,7 +83,7 @@ class FMenuBar : public FWindow, public FMenuList FMenuBar& operator = (const FMenuBar&) = delete; // Accessors - const FString getClassName() const override; + FString getClassName() const override; // Methods void resetColors() override; @@ -103,7 +103,7 @@ class FMenuBar : public FWindow, public FMenuList private: // Constants - static constexpr std::size_t NOT_SET = static_cast(-1); + static constexpr auto NOT_SET = static_cast(-1); // Typedef typedef struct @@ -157,7 +157,7 @@ class FMenuBar : public FWindow, public FMenuList // FMenuBar inline functions //---------------------------------------------------------------------- -inline const FString FMenuBar::getClassName() const +inline FString FMenuBar::getClassName() const { return "FMenuBar"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fmenuitem.h b/src/include/final/fmenuitem.h index c535e1ca..c48b8962 100644 --- a/src/include/final/fmenuitem.h +++ b/src/include/final/fmenuitem.h @@ -88,7 +88,7 @@ class FMenuItem : public FWidget FMenuItem& operator = (const FMenuItem&) = delete; // Accessors - const FString getClassName() const override; + FString getClassName() const override; FKey getHotkey() const; FMenu* getMenu() const; std::size_t getTextLength() const; @@ -196,7 +196,7 @@ class FMenuItem : public FWidget // FMenuItem inline functions //---------------------------------------------------------------------- -inline const FString FMenuItem::getClassName() const +inline FString FMenuItem::getClassName() const { return "FMenuItem"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fmenulist.h b/src/include/final/fmenulist.h index ec77e07a..6f34a8e1 100644 --- a/src/include/final/fmenulist.h +++ b/src/include/final/fmenulist.h @@ -71,7 +71,7 @@ class FMenuList FMenuList& operator = (const FMenuList&) = delete; // Accessors - virtual const FString getClassName() const; + virtual FString getClassName() const; std::size_t getCount() const; FMenuItem* getItem (int) const; FMenuItem* getSelectedItem() const; @@ -104,7 +104,7 @@ class FMenuList // FMenuList inline functions //---------------------------------------------------------------------- -inline const FString FMenuList::getClassName() const +inline FString FMenuList::getClassName() const { return "FMenuList"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fmessagebox.h b/src/include/final/fmessagebox.h index 22a63bfa..4b79c0c5 100644 --- a/src/include/final/fmessagebox.h +++ b/src/include/final/fmessagebox.h @@ -92,7 +92,7 @@ class FMessageBox : public FDialog explicit FMessageBox (FWidget* = nullptr); FMessageBox (const FMessageBox&); // copy constructor FMessageBox ( const FString&, const FString& - , int, int, int + , ButtonType, ButtonType, ButtonType , FWidget* = nullptr ); // Destructor ~FMessageBox() override; @@ -101,10 +101,10 @@ class FMessageBox : public FDialog FMessageBox& operator = (const FMessageBox&); // Accessor - const FString getClassName() const override; - const FString getTitlebarText() const; - const FString getHeadline() const; - const FString getText() const override; + FString getClassName() const override; + FString getTitlebarText() const; + FString getHeadline() const; + FString getText() const override; // Mutator void setTitlebarText (const FString&); @@ -119,22 +119,22 @@ class FMessageBox : public FDialog static int info ( FWidget* , const FString& , const messageType& - , int = FMessageBox::Ok - , int = 0 - , int = 0 ); + , ButtonType = FMessageBox::Ok + , ButtonType = FMessageBox::Reject + , ButtonType = FMessageBox::Reject ); template static int error ( FWidget* , const messageType& - , int = FMessageBox::Ok - , int = 0 - , int = 0 ); + , ButtonType = FMessageBox::Ok + , ButtonType = FMessageBox::Reject + , ButtonType = FMessageBox::Reject ); protected: // Method void adjustSize() override; // Callback method - void cb_processClick (int); + void cb_processClick (ButtonType); private: // Constants @@ -157,7 +157,7 @@ class FMessageBox : public FDialog FButton* button[MAX_BUTTONS]{nullptr}; std::size_t max_line_width{0}; FColor emphasis_color{getColorTheme()->dialog_emphasis_fg}; - int button_digit[MAX_BUTTONS]{0}; + ButtonType button_digit[MAX_BUTTONS]{FMessageBox::Reject}; std::size_t num_buttons{0}; std::size_t text_num_lines{0}; bool center_text{false}; @@ -166,22 +166,22 @@ class FMessageBox : public FDialog // FMessageBox inline functions //---------------------------------------------------------------------- -inline const FString FMessageBox::getClassName() const +inline FString FMessageBox::getClassName() const { return "FMessageBox"; } //---------------------------------------------------------------------- -inline const FString FMessageBox::getTitlebarText() const +inline FString FMessageBox::getTitlebarText() const { const FString& title = FDialog::getText(); // initialize text return title; } //---------------------------------------------------------------------- -inline const FString FMessageBox::getHeadline() const +inline FString FMessageBox::getHeadline() const { return headline_text; } //---------------------------------------------------------------------- -inline const FString FMessageBox::getText() const +inline FString FMessageBox::getText() const { return text; } //---------------------------------------------------------------------- @@ -205,9 +205,9 @@ template int FMessageBox::info ( FWidget* parent , const FString& caption , const messageType& message - , int button0 - , int button1 - , int button2 ) + , ButtonType button0 + , ButtonType button1 + , ButtonType button2 ) { FMessageBox mbox ( caption , FString() << message @@ -221,9 +221,9 @@ int FMessageBox::info ( FWidget* parent template int FMessageBox::error ( FWidget* parent , const messageType& message - , int button0 - , int button1 - , int button2 ) + , ButtonType button0 + , ButtonType button1 + , ButtonType button2 ) { const FString caption{"Error message"}; diff --git a/src/include/final/fmouse.h b/src/include/final/fmouse.h index 7d912232..a0a22e02 100644 --- a/src/include/final/fmouse.h +++ b/src/include/final/fmouse.h @@ -102,7 +102,7 @@ class FMouse { } // Accessors - virtual const FString getClassName() const; + virtual FString getClassName() const; const FPoint& getPos() const; void clearEvent(); @@ -215,7 +215,7 @@ class FMouseGPM final : public FMouse ~FMouseGPM() override; // Accessors - const FString getClassName() const override; + FString getClassName() const override; // Mutators void setStdinNo(int); @@ -283,7 +283,7 @@ class FMouseX11 final : public FMouse ~FMouseX11() override = default; // Accessors - const FString getClassName() const override; + FString getClassName() const override; // Inquiry bool hasData() override; @@ -342,7 +342,7 @@ class FMouseSGR final : public FMouse ~FMouseSGR() override = default; // Accessors - const FString getClassName() const override; + FString getClassName() const override; // Inquiry bool hasData() override; @@ -401,7 +401,7 @@ class FMouseUrxvt final : public FMouse ~FMouseUrxvt() override = default; // Accessors - const FString getClassName() const override; + FString getClassName() const override; // Inquiry bool hasData() override; @@ -466,7 +466,7 @@ class FMouseControl FMouseControl& operator = (const FMouseControl&) = delete; // Accessors - virtual const FString getClassName() const; + virtual FString getClassName() const; const FPoint& getPos(); void clearEvent(); @@ -526,7 +526,7 @@ class FMouseControl // FMouseControl inline functions //---------------------------------------------------------------------- -inline const FString FMouseControl::getClassName() const +inline FString FMouseControl::getClassName() const { return "FMouseControl"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fobject.h b/src/include/final/fobject.h index 0a7217ae..836b8fbe 100644 --- a/src/include/final/fobject.h +++ b/src/include/final/fobject.h @@ -79,7 +79,7 @@ class FObject typedef FObjectList::const_iterator const_iterator; // Constants - static constexpr std::size_t UNLIMITED = static_cast(-1); + static constexpr auto UNLIMITED = static_cast(-1); // Constructor explicit FObject (FObject* = nullptr); @@ -94,7 +94,7 @@ class FObject FObject& operator = (const FObject&) = delete; // Accessors - virtual const FString getClassName() const; + virtual FString getClassName() const; FObject* getParent() const; FObject* getChild (int) const; FObjectList& getChildren(); @@ -176,7 +176,7 @@ class FObject //---------------------------------------------------------------------- -inline const FString FObject::getClassName() const +inline FString FObject::getClassName() const { return "FObject"; } //---------------------------------------------------------------------- diff --git a/src/include/final/foptiattr.h b/src/include/final/foptiattr.h index 76c4d37b..ddd28571 100644 --- a/src/include/final/foptiattr.h +++ b/src/include/final/foptiattr.h @@ -107,7 +107,7 @@ class FOptiAttr final FOptiAttr& operator = (const FOptiAttr&) = delete; // Accessors - const FString getClassName() const; + FString getClassName() const; // Mutators void setTermEnvironment (const termEnv&); @@ -318,7 +318,7 @@ class FOptiAttr final // FOptiAttr inline functions //---------------------------------------------------------------------- -inline const FString FOptiAttr::getClassName() const +inline FString FOptiAttr::getClassName() const { return "FOptiAttr"; } //---------------------------------------------------------------------- diff --git a/src/include/final/foptimove.h b/src/include/final/foptimove.h index dc02ca5a..f30a5d87 100644 --- a/src/include/final/foptimove.h +++ b/src/include/final/foptimove.h @@ -92,7 +92,7 @@ class FOptiMove final ~FOptiMove(); // Accessors - const FString getClassName() const; + FString getClassName() const; uInt getCursorHomeLength() const; uInt getCarriageReturnLength() const; uInt getCursorToLLLength() const; @@ -224,7 +224,7 @@ class FOptiMove final // FOptiMove inline functions //---------------------------------------------------------------------- -inline const FString FOptiMove::getClassName() const +inline FString FOptiMove::getClassName() const { return "FOptiMove"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fpoint.h b/src/include/final/fpoint.h index 981d43cd..17ba5628 100644 --- a/src/include/final/fpoint.h +++ b/src/include/final/fpoint.h @@ -66,7 +66,7 @@ class FPoint FPoint& operator -= (const FPoint&); // Accessors - virtual const FString getClassName(); + virtual FString getClassName(); int getX() const; int getY() const; void setX (int); @@ -93,9 +93,9 @@ class FPoint // Friend operator functions friend bool operator == (const FPoint&, const FPoint&); friend bool operator != (const FPoint&, const FPoint&); - friend const FPoint operator + (const FPoint&, const FPoint&); - friend const FPoint operator - (const FPoint&, const FPoint&); - friend const FPoint operator - (const FPoint&); + friend FPoint operator + (const FPoint&, const FPoint&); + friend FPoint operator - (const FPoint&, const FPoint&); + friend FPoint operator - (const FPoint&); friend std::ostream& operator << (std::ostream&, const FPoint&); friend std::istream& operator >> (std::istream&, FPoint&); }; @@ -121,7 +121,7 @@ inline FPoint::FPoint (int x, int y) { } //---------------------------------------------------------------------- -inline const FString FPoint::getClassName() +inline FString FPoint::getClassName() { return "FPoint"; } //---------------------------------------------------------------------- @@ -155,15 +155,15 @@ inline bool operator != (const FPoint& p1, const FPoint& p2) { return p1.xpos != p2.xpos || p1.ypos != p2.ypos; } //---------------------------------------------------------------------- -inline const FPoint operator + (const FPoint& p1, const FPoint& p2) +inline FPoint operator + (const FPoint& p1, const FPoint& p2) { return {p1.xpos + p2.xpos, p1.ypos + p2.ypos}; } //---------------------------------------------------------------------- -inline const FPoint operator - (const FPoint& p1, const FPoint& p2) +inline FPoint operator - (const FPoint& p1, const FPoint& p2) { return {p1.xpos - p2.xpos, p1.ypos - p2.ypos}; } //---------------------------------------------------------------------- -inline const FPoint operator - (const FPoint& p) +inline FPoint operator - (const FPoint& p) { return {-p.xpos, -p.ypos}; } } // namespace finalcut diff --git a/src/include/final/fprogressbar.h b/src/include/final/fprogressbar.h index 8f6bd4e8..05d2005b 100644 --- a/src/include/final/fprogressbar.h +++ b/src/include/final/fprogressbar.h @@ -69,7 +69,7 @@ class FProgressbar : public FWidget ~FProgressbar() override; // Accessors - const FString getClassName() const override; + FString getClassName() const override; std::size_t getPercentage() const; // Mutators @@ -90,7 +90,7 @@ class FProgressbar : public FWidget private: // Constants - static constexpr std::size_t NOT_SET = static_cast(-1); + static constexpr auto NOT_SET = static_cast(-1); // Methods void init(); @@ -108,7 +108,7 @@ class FProgressbar : public FWidget // FProgressbar inline functions //---------------------------------------------------------------------- -inline const FString FProgressbar::getClassName() const +inline FString FProgressbar::getClassName() const { return "FProgressbar"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fradiobutton.h b/src/include/final/fradiobutton.h index d00410b8..5187017f 100644 --- a/src/include/final/fradiobutton.h +++ b/src/include/final/fradiobutton.h @@ -78,7 +78,7 @@ class FRadioButton : public FToggleButton FRadioButton& operator = (const FRadioButton&) = delete; // Accessor - const FString getClassName() const override; + FString getClassName() const override; private: // Methods @@ -92,7 +92,7 @@ class FRadioButton : public FToggleButton // FRadioButton inline functions //---------------------------------------------------------------------- -inline const FString FRadioButton::getClassName() const +inline FString FRadioButton::getClassName() const { return "FRadioButton"; } } // namespace finalcut diff --git a/src/include/final/fradiomenuitem.h b/src/include/final/fradiomenuitem.h index f96672aa..4ba3b0c3 100644 --- a/src/include/final/fradiomenuitem.h +++ b/src/include/final/fradiomenuitem.h @@ -78,7 +78,7 @@ class FRadioMenuItem : public FMenuItem FRadioMenuItem& operator = (const FRadioMenuItem&) = delete; // Accessor - const FString getClassName() const override; + FString getClassName() const override; private: // Methods @@ -89,7 +89,7 @@ class FRadioMenuItem : public FMenuItem // FRadioMenuItem inline functions //---------------------------------------------------------------------- -inline const FString FRadioMenuItem::getClassName() const +inline FString FRadioMenuItem::getClassName() const { return "FRadioMenuItem"; } } // namespace finalcut diff --git a/src/include/final/frect.h b/src/include/final/frect.h index 2f0463de..0768f1ae 100644 --- a/src/include/final/frect.h +++ b/src/include/final/frect.h @@ -74,21 +74,21 @@ class FRect FRect& operator = (FRect&&) noexcept; // Accessors - virtual const FString getClassName(); + virtual FString getClassName(); int getX1() const; int getY1() const; int getX2() const; int getY2() const; int getX() const; int getY() const; - const FPoint getPos() const; - const FPoint getUpperLeftPos() const; - const FPoint getUpperRightPos() const; - const FPoint getLowerLeftPos() const; - const FPoint getLowerRightPos() const; + FPoint getPos() const; + FPoint getUpperLeftPos() const; + FPoint getUpperRightPos() const; + FPoint getLowerLeftPos() const; + FPoint getLowerRightPos() const; std::size_t getWidth() const; std::size_t getHeight() const; - const FSize getSize() const; + FSize getSize() const; // Mutators void setX1 (int); @@ -138,8 +138,8 @@ class FRect int Y2{-1}; // Friend operator functions - friend const FRect operator + (const FRect&, const FSize&); - friend const FRect operator - (const FRect&, const FSize&); + friend FRect operator + (const FRect&, const FSize&); + friend FRect operator - (const FRect&, const FSize&); friend bool operator == (const FRect&, const FRect&); friend bool operator != (const FRect&, const FRect&); friend std::ostream& operator << (std::ostream&, const FRect&); @@ -172,7 +172,7 @@ inline FRect::FRect (int x, int y, std::size_t width, std::size_t height) { } //---------------------------------------------------------------------- -inline const FString FRect::getClassName() +inline FString FRect::getClassName() { return "FRect"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fscrollbar.h b/src/include/final/fscrollbar.h index 856cc7c5..f4b7fe95 100644 --- a/src/include/final/fscrollbar.h +++ b/src/include/final/fscrollbar.h @@ -100,7 +100,7 @@ class FScrollbar : public FWidget FScrollbar& operator = (const FScrollbar&) = delete; // Accessors - const FString getClassName() const override; + FString getClassName() const override; int getValue() const; sType getScrollType() const; @@ -203,7 +203,7 @@ void initScrollbar ( FScrollbarPtr& bar // FScrollbar inline functions //---------------------------------------------------------------------- -inline const FString FScrollbar::getClassName() const +inline FString FScrollbar::getClassName() const { return "FScrollbar"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fscrollview.h b/src/include/final/fscrollview.h index fa3195b8..a3189cd4 100644 --- a/src/include/final/fscrollview.h +++ b/src/include/final/fscrollview.h @@ -80,14 +80,14 @@ class FScrollView : public FWidget FScrollView& operator = (const FScrollView&) = delete; // Accessors - const FString getClassName() const override; + FString getClassName() const override; std::size_t getViewportWidth() const; std::size_t getViewportHeight() const; - const FSize getViewportSize() const; + FSize getViewportSize() const; std::size_t getScrollWidth() const; std::size_t getScrollHeight() const; - const FSize getScrollSize() const; - const FPoint getScrollPos() const; + FSize getScrollSize() const; + FPoint getScrollPos() const; int getScrollX() const; int getScrollY() const; @@ -191,7 +191,7 @@ class FScrollView : public FWidget // FScrollView inline functions //---------------------------------------------------------------------- -inline const FString FScrollView::getClassName() const +inline FString FScrollView::getClassName() const { return "FScrollView"; } //---------------------------------------------------------------------- @@ -203,7 +203,7 @@ inline std::size_t FScrollView::getViewportHeight() const { return getHeight() - horizontal_border_spacing; } //---------------------------------------------------------------------- -inline const FSize FScrollView::getViewportSize() const +inline FSize FScrollView::getViewportSize() const { return FSize(getViewportWidth(), getViewportHeight()); } //---------------------------------------------------------------------- @@ -215,11 +215,11 @@ inline std::size_t FScrollView::getScrollHeight() const { return scroll_geometry.getHeight(); } //---------------------------------------------------------------------- -inline const FSize FScrollView::getScrollSize() const +inline FSize FScrollView::getScrollSize() const { return scroll_geometry.getSize(); } //---------------------------------------------------------------------- -inline const FPoint FScrollView::getScrollPos() const +inline FPoint FScrollView::getScrollPos() const { return viewport_geometry.getPos(); } //---------------------------------------------------------------------- diff --git a/src/include/final/fsize.h b/src/include/final/fsize.h index 6186a06e..9de799ef 100644 --- a/src/include/final/fsize.h +++ b/src/include/final/fsize.h @@ -71,7 +71,7 @@ class FSize FSize& operator -= (const FSize&); // Accessors - virtual const FString getClassName(); + virtual FString getClassName(); std::size_t getWidth() const; std::size_t getHeight() const; std::size_t getArea() const; @@ -103,8 +103,8 @@ class FSize friend bool operator != (const FSize&, const FSize&); friend bool operator >= (const FSize&, const FSize&); friend bool operator > (const FSize&, const FSize&); - friend const FSize operator + (const FSize&, const FSize&); - friend const FSize operator - (const FSize&, const FSize&); + friend FSize operator + (const FSize&, const FSize&); + friend FSize operator - (const FSize&, const FSize&); friend std::ostream& operator << (std::ostream&, const FSize&); friend std::istream& operator >> (std::istream&, FSize&); @@ -130,7 +130,7 @@ inline FSize::FSize (std::size_t w, std::size_t h) { } //---------------------------------------------------------------------- -inline const FString FSize::getClassName() +inline FString FSize::getClassName() { return "FSize"; } //---------------------------------------------------------------------- @@ -180,7 +180,7 @@ inline bool operator > (const FSize& s1, const FSize& s2) { return s1.width > s2.width && s1.height > s2.height; } //---------------------------------------------------------------------- -inline const FSize operator + (const FSize& s1, const FSize& s2) +inline FSize operator + (const FSize& s1, const FSize& s2) { constexpr std::size_t max = std::numeric_limits::max(); const std::size_t w = ( s1.width < max - s2.width) ? s1.width + s2.width : max; @@ -189,7 +189,7 @@ inline const FSize operator + (const FSize& s1, const FSize& s2) } //---------------------------------------------------------------------- -inline const FSize operator - (const FSize& s1, const FSize& s2) +inline FSize operator - (const FSize& s1, const FSize& s2) { const std::size_t w = ( s1.width >= s2.width ) ? s1.width - s2.width : 0; const std::size_t h = ( s1.height >= s2.height ) ? s1.height - s2.height : 0; diff --git a/src/include/final/fspinbox.h b/src/include/final/fspinbox.h index ba419621..b13c306f 100644 --- a/src/include/final/fspinbox.h +++ b/src/include/final/fspinbox.h @@ -80,7 +80,7 @@ class FSpinBox : public FWidget FSpinBox& operator = (const FSpinBox&) = delete; // Accessors - const FString getClassName() const override; + FString getClassName() const override; sInt64 getValue() const; FString getPrefix() const; FString getSuffix() const; @@ -161,7 +161,7 @@ class FSpinBox : public FWidget // FSpinBox inline functions //---------------------------------------------------------------------- -inline const FString FSpinBox::getClassName() const +inline FString FSpinBox::getClassName() const { return "FSpinBox"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fstartoptions.h b/src/include/final/fstartoptions.h index ab5cffae..a5430228 100644 --- a/src/include/final/fstartoptions.h +++ b/src/include/final/fstartoptions.h @@ -65,7 +65,7 @@ class FStartOptions final FStartOptions& operator = (const FStartOptions&) = delete; // Accessors - static const FString getClassName(); + static FString getClassName(); static FStartOptions& getFStartOptions(); // Mutator @@ -102,7 +102,7 @@ class FStartOptions final }; //---------------------------------------------------------------------- -inline const FString FStartOptions::getClassName() +inline FString FStartOptions::getClassName() { return "FStartOptions"; } } // namespace finalcut diff --git a/src/include/final/fstatusbar.h b/src/include/final/fstatusbar.h index 751543e4..9f253a01 100644 --- a/src/include/final/fstatusbar.h +++ b/src/include/final/fstatusbar.h @@ -87,7 +87,7 @@ class FStatusKey : public FWidget FStatusKey& operator = (const FStatusKey&) = delete; // Accessors - const FString getClassName() const override; + FString getClassName() const override; virtual FKey getKey() const; virtual FString getText() const; @@ -128,7 +128,7 @@ class FStatusKey : public FWidget // FStatusKey inline functions //---------------------------------------------------------------------- -inline const FString FStatusKey::getClassName() const +inline FString FStatusKey::getClassName() const { return "FStatusKey"; } //---------------------------------------------------------------------- @@ -196,7 +196,7 @@ class FStatusBar : public FWindow FStatusBar& operator = (const FStatusBar&) = delete; // Accessors - const FString getClassName() const override; + FString getClassName() const override; FStatusKey* getStatusKey (int) const; FString getMessage() const; std::size_t getCount() const; @@ -255,7 +255,7 @@ class FStatusBar : public FWindow // FStatusBar inline functions //---------------------------------------------------------------------- -inline const FString FStatusBar::getClassName() const +inline FString FStatusBar::getClassName() const { return "FStatusBar"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fstring.h b/src/include/final/fstring.h index 78379176..a8bd97a5 100644 --- a/src/include/final/fstring.h +++ b/src/include/final/fstring.h @@ -159,7 +159,7 @@ class FString operator const char* () const { return c_str(); } // Accessor - virtual const FString getClassName() const; + virtual FString getClassName() const; // inquiries bool isNull() const; @@ -185,10 +185,10 @@ class FString wchar_t* wc_str(); const char* c_str() const; char* c_str(); - const std::string toString() const; + std::string toString() const; - const FString toLower() const; - const FString toUpper() const; + FString toLower() const; + FString toUpper() const; sInt16 toShort() const; uInt16 toUShort() const; @@ -199,13 +199,13 @@ class FString float toFloat() const; double toDouble() const; - const FString ltrim() const; - const FString rtrim() const; - const FString trim() const; + FString ltrim() const; + FString rtrim() const; + FString trim() const; - const FString left (std::size_t) const; - const FString right (std::size_t) const; - const FString mid (std::size_t, std::size_t) const; + FString left (std::size_t) const; + FString right (std::size_t) const; + FString mid (std::size_t, std::size_t) const; FStringList split (const FString&) const; FString& setString (const FString&); @@ -224,10 +224,10 @@ class FString const FString& insert (const FString&, int); const FString& insert (const FString&, std::size_t); - const FString replace (const FString&, const FString&) const; + FString replace (const FString&, const FString&) const; - const FString replaceControlCodes() const; - const FString expandTabs (int = 8) const; + FString replaceControlCodes() const; + FString expandTabs (int = 8) const; FString removeDel() const; FString removeBackspaces() const; @@ -261,15 +261,15 @@ class FString static const wchar_t const_null_char; // Friend Non-member operator functions - friend const FString operator + (const FString&, const FString&); - friend const FString operator + (const FString&, const wchar_t); - friend const FString operator + (const std::wstring&, const FString&); - friend const FString operator + (const wchar_t[], const FString&); - friend const FString operator + (const std::string&, const FString&); - friend const FString operator + (const char[], const FString&); - friend const FString operator + (const wchar_t, const FString&); - friend const FString operator + (const char, const FString&); - friend const FString operator + (const FString&, const char); + friend FString operator + (const FString&, const FString&); + friend FString operator + (const FString&, const wchar_t); + friend FString operator + (const std::wstring&, const FString&); + friend FString operator + (const wchar_t[], const FString&); + friend FString operator + (const std::string&, const FString&); + friend FString operator + (const char[], const FString&); + friend FString operator + (const wchar_t, const FString&); + friend FString operator + (const char, const FString&); + friend FString operator + (const FString&, const char); friend std::ostream& operator << (std::ostream&, const FString&); friend std::istream& operator >> (std::istream&, FString& s); @@ -366,7 +366,7 @@ inline bool FString::operator > (const CharT& s) const } //---------------------------------------------------------------------- -inline const FString FString::getClassName() const +inline FString FString::getClassName() const { return "FString"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fstringstream.h b/src/include/final/fstringstream.h index 15ec22a6..ce10acfb 100644 --- a/src/include/final/fstringstream.h +++ b/src/include/final/fstringstream.h @@ -80,7 +80,7 @@ class FStringStream : public std::wiostream // Move assignment operator (=) FStringStream& operator = (FStringStream&& sstream) noexcept; - virtual const FString getClassName() const; + virtual FString getClassName() const; void swap (FStringStream&) noexcept; void clear(); std::wstringbuf* rdbuf() const; @@ -93,7 +93,7 @@ class FStringStream : public std::wiostream // FStringStream inline functions //---------------------------------------------------------------------- -inline const FString FStringStream::getClassName() const +inline FString FStringStream::getClassName() const { return "FStringStream"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fstyle.h b/src/include/final/fstyle.h index bef360fe..dbb93162 100644 --- a/src/include/final/fstyle.h +++ b/src/include/final/fstyle.h @@ -70,7 +70,7 @@ class FStyle } // Accessor - const FString getClassName() const + FString getClassName() const { return "FStyle"; } FColor getStyle() const diff --git a/src/include/final/fswitch.h b/src/include/final/fswitch.h index cd94a57d..3978a4db 100644 --- a/src/include/final/fswitch.h +++ b/src/include/final/fswitch.h @@ -78,7 +78,7 @@ class FSwitch : public FToggleButton FSwitch& operator = (const FSwitch&) = delete; // Accessor - const FString getClassName() const override; + FString getClassName() const override; // Mutator void setText (const FString&) override; @@ -102,7 +102,7 @@ class FSwitch : public FToggleButton // FSwitch inline functions //---------------------------------------------------------------------- -inline const FString FSwitch::getClassName() const +inline FString FSwitch::getClassName() const { return "FSwitch"; } } // namespace finalcut diff --git a/src/include/final/fterm.h b/src/include/final/fterm.h index d11fa5bd..be325578 100644 --- a/src/include/final/fterm.h +++ b/src/include/final/fterm.h @@ -178,10 +178,10 @@ class FTerm final FTerm& operator = (const FTerm&) = delete; // Accessors - static const FString getClassName(); + static FString getClassName(); static std::size_t getLineNumber(); static std::size_t getColumnNumber(); - static const FString getKeyName (FKey); + static FString getKeyName (FKey); static int getTTYFileDescriptor(); static const char* getTermType(); static const char* getTermFileName(); @@ -406,9 +406,9 @@ bool isReverseNewFontchar (wchar_t); bool hasFullWidthSupports(); wchar_t cp437_to_unicode (uChar); uChar unicode_to_cp437 (wchar_t); -const FString getFullWidth (const FString&); -const FString getHalfWidth (const FString&); -const FString getColumnSubString (const FString&, std::size_t, std::size_t); +FString getFullWidth (const FString&); +FString getHalfWidth (const FString&); +FString getColumnSubString (const FString&, std::size_t, std::size_t); std::size_t getLengthFromColumnWidth (const FString&, std::size_t); std::size_t getColumnWidth (const FString&, std::size_t); std::size_t getColumnWidth (const FString&); @@ -419,7 +419,7 @@ std::size_t getColumnWidth (const FTermBuffer&); // FTerm inline functions //---------------------------------------------------------------------- -inline const FString FTerm::getClassName() +inline FString FTerm::getClassName() { return "FTerm"; } //---------------------------------------------------------------------- @@ -462,7 +462,7 @@ inline void FTerm::putstringf (const char format[], Args&&... args) if ( ! fsys ) getFSystem(); // Trying to set fsys - const std::size_t count = std::size_t(size); + const auto count = std::size_t(size); std::vector buf(count); std::snprintf (&buf[0], count, format, std::forward(args)...); diff --git a/src/include/final/ftermbuffer.h b/src/include/final/ftermbuffer.h index f3976b9e..ab2593ae 100644 --- a/src/include/final/ftermbuffer.h +++ b/src/include/final/ftermbuffer.h @@ -79,7 +79,7 @@ class FTermBuffer FTermBuffer& operator << (const FColorPair&); // Accessors - virtual const FString getClassName() const; + virtual FString getClassName() const; std::size_t getLength() const; const FCharVector& getBuffer() const; @@ -93,7 +93,7 @@ class FTermBuffer const_iterator end() const; FChar front() const; FChar back() const; - const FString toString() const; + FString toString() const; void clear(); template int writef (const FString&, Args&&...); @@ -169,7 +169,7 @@ inline FTermBuffer& FTermBuffer::operator << (const FColorPair& pair) } //---------------------------------------------------------------------- -inline const FString FTermBuffer::getClassName() const +inline FString FTermBuffer::getClassName() const { return "FTermBuffer"; } //---------------------------------------------------------------------- diff --git a/src/include/final/ftermcap.h b/src/include/final/ftermcap.h index 852ad862..447ea433 100644 --- a/src/include/final/ftermcap.h +++ b/src/include/final/ftermcap.h @@ -77,9 +77,6 @@ class FTermDetection; class FTermcap final { public: - // Using-declaration - using fn_putc = int (*)(int); - // Typedef typedef struct { @@ -88,6 +85,10 @@ class FTermcap final } tcap_map; + // Using-declaration + using fn_putc = int (*)(int); + using TCapMapType = std::array; + // Constructors FTermcap() = default; @@ -95,7 +96,7 @@ class FTermcap final ~FTermcap() = default; // Accessors - const FString getClassName() const; + FString getClassName() const; template static bool getFlag (const CharT&); template @@ -129,7 +130,7 @@ class FTermcap final static int max_color; static int tabstop; static int attr_without_color; - static tcap_map strings[]; + static TCapMapType strings; private: // Constant @@ -156,7 +157,7 @@ class FTermcap final // FTermcap inline functions //---------------------------------------------------------------------- -inline const FString FTermcap::getClassName() const +inline FString FTermcap::getClassName() const { return "FTermcap"; } //---------------------------------------------------------------------- diff --git a/src/include/final/ftermcapquirks.h b/src/include/final/ftermcapquirks.h index 60148df9..c73df24b 100644 --- a/src/include/final/ftermcapquirks.h +++ b/src/include/final/ftermcapquirks.h @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2018-2019 Markus Gans * +* Copyright 2018-2020 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 * @@ -56,7 +56,7 @@ class FTermcapQuirks final ~FTermcapQuirks(); // Accessor - const FString getClassName() const; + FString getClassName() const; // Methods static void terminalFixup(); @@ -85,7 +85,7 @@ class FTermcapQuirks final // FTermcapQuirks inline functions //---------------------------------------------------------------------- -inline const FString FTermcapQuirks::getClassName() const +inline FString FTermcapQuirks::getClassName() const { return "FTermcapQuirks"; } } // namespace finalcut diff --git a/src/include/final/ftermdata.h b/src/include/final/ftermdata.h index 1ba99f3e..e4c65fcd 100644 --- a/src/include/final/ftermdata.h +++ b/src/include/final/ftermdata.h @@ -71,7 +71,7 @@ class FTermData final FTermData& operator = (const FTermData&) = delete; // Accessors - const FString getClassName() const; + FString getClassName() const; encodingMap& getEncodingList(); charSubstitution& getCharSubstitutionMap(); fc::encoding getTermEncoding() const; @@ -166,7 +166,7 @@ class FTermData final // FTermData inline functions //---------------------------------------------------------------------- -inline const FString FTermData::getClassName() const +inline FString FTermData::getClassName() const { return "FTermData"; } //---------------------------------------------------------------------- diff --git a/src/include/final/ftermdetection.h b/src/include/final/ftermdetection.h index e7d1fe64..1308c73d 100644 --- a/src/include/final/ftermdetection.h +++ b/src/include/final/ftermdetection.h @@ -92,7 +92,7 @@ class FTermDetection final FTermDetection& operator = (const FTermDetection&) = delete; // Accessor - static const FString getClassName(); + static FString getClassName(); static const char* getTermType(); static int getGnomeTerminalID(); FTerminalType& getTermTypeStruct(); @@ -243,7 +243,7 @@ struct FTermDetection::secondaryDA // FTermDetection inline functions //---------------------------------------------------------------------- -inline const FString FTermDetection::getClassName() +inline FString FTermDetection::getClassName() { return "FTermDetection"; } //---------------------------------------------------------------------- diff --git a/src/include/final/ftermfreebsd.h b/src/include/final/ftermfreebsd.h index 55f0a8a3..93ac5405 100644 --- a/src/include/final/ftermfreebsd.h +++ b/src/include/final/ftermfreebsd.h @@ -95,7 +95,7 @@ class FTermFreeBSD final FTermFreeBSD& operator = (const FTermFreeBSD&) = delete; // Accessors - const FString getClassName() const; + FString getClassName() const; static CursorStyle getCursorStyle(); // Inquiry @@ -137,7 +137,7 @@ class FTermFreeBSD final // FTermFreeBSD inline functions //---------------------------------------------------------------------- -inline const FString FTermFreeBSD::getClassName() const +inline FString FTermFreeBSD::getClassName() const { return "FTermFreeBSD"; } //---------------------------------------------------------------------- diff --git a/src/include/final/ftermios.h b/src/include/final/ftermios.h index e80813f7..e1a31e35 100644 --- a/src/include/final/ftermios.h +++ b/src/include/final/ftermios.h @@ -3,7 +3,7 @@ * * * This file is part of the FINAL CUT widget toolkit * * * -* Copyright 2018-2019 Markus Gans * +* Copyright 2018-2020 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 * @@ -58,7 +58,7 @@ class FTermios final ~FTermios(); // Accessors - const FString getClassName() const; + FString getClassName() const; static termios getTTY(); static int getStdIn(); static int getStdOut(); @@ -94,7 +94,7 @@ class FTermios final // FTermios inline functions //---------------------------------------------------------------------- -inline const FString FTermios::getClassName() const +inline FString FTermios::getClassName() const { return "FTermios"; } //---------------------------------------------------------------------- diff --git a/src/include/final/ftermlinux.h b/src/include/final/ftermlinux.h index 4cfc6219..cbcfd5cf 100644 --- a/src/include/final/ftermlinux.h +++ b/src/include/final/ftermlinux.h @@ -93,7 +93,7 @@ class FTermLinux final FTermLinux& operator = (const FTermLinux&) = delete; // Accessors - const FString getClassName() const; + FString getClassName() const; fc::linuxConsoleCursorStyle getCursorStyle() const; char* getCursorStyleString(); int getFramebufferBpp() const; @@ -204,7 +204,7 @@ class FTermLinux final // FTermLinux inline functions //---------------------------------------------------------------------- -inline const FString FTermLinux::getClassName() const +inline FString FTermLinux::getClassName() const { return "FTermLinux"; } //---------------------------------------------------------------------- diff --git a/src/include/final/ftermopenbsd.h b/src/include/final/ftermopenbsd.h index b5e470ce..97799dbb 100644 --- a/src/include/final/ftermopenbsd.h +++ b/src/include/final/ftermopenbsd.h @@ -87,7 +87,7 @@ class FTermOpenBSD final FTermOpenBSD& operator = (const FTermOpenBSD&) = delete; // Accessor - const FString getClassName() const; + FString getClassName() const; // Inquiries static bool isBSDConsole(); @@ -122,7 +122,7 @@ class FTermOpenBSD final // FTermOpenBSD inline functions //---------------------------------------------------------------------- -inline const FString FTermOpenBSD::getClassName() const +inline FString FTermOpenBSD::getClassName() const { return "FTermOpenBSD"; } //---------------------------------------------------------------------- diff --git a/src/include/final/ftermxterminal.h b/src/include/final/ftermxterminal.h index 628ed9ae..39f9cb1d 100644 --- a/src/include/final/ftermxterminal.h +++ b/src/include/final/ftermxterminal.h @@ -80,16 +80,16 @@ class FTermXTerminal final void metaSendsESC (bool); // Accessors - const FString getClassName() const; + FString getClassName() const; fc::xtermCursorStyle getCursorStyle() const; - const FString getFont() const; - const FString getTitle() const; - const FString getForeground() const; - const FString getBackground() const; - const FString getCursorColor() const; - const FString getMouseForeground() const; - const FString getMouseBackground() const; - const FString getHighlightBackground() const; + FString getFont() const; + FString getTitle() const; + FString getForeground() const; + FString getBackground() const; + FString getCursorColor() const; + FString getMouseForeground() const; + FString getMouseBackground() const; + FString getHighlightBackground() const; // Inquiries bool hasFont() const; @@ -136,8 +136,8 @@ class FTermXTerminal final bool canResetColor() const; void oscPrefix() const; void oscPostfix() const; - const FString captureXTermFont() const; - const FString captureXTermTitle() const; + FString captureXTermFont() const; + FString captureXTermTitle() const; static void enableXTermMouse(); static void disableXTermMouse(); void enableXTermMetaSendsESC(); @@ -165,7 +165,7 @@ class FTermXTerminal final // FTermXTerminal inline functions //---------------------------------------------------------------------- -inline const FString FTermXTerminal::getClassName() const +inline FString FTermXTerminal::getClassName() const { return "FTermXTerminal"; } //---------------------------------------------------------------------- @@ -177,35 +177,35 @@ inline fc::xtermCursorStyle FTermXTerminal::getCursorStyle() const { return cursor_style; } //---------------------------------------------------------------------- -inline const FString FTermXTerminal::getFont() const +inline FString FTermXTerminal::getFont() const { return xterm_font; } //---------------------------------------------------------------------- -inline const FString FTermXTerminal::getTitle() const +inline FString FTermXTerminal::getTitle() const { return xterm_title; } //---------------------------------------------------------------------- -inline const FString FTermXTerminal::getForeground() const +inline FString FTermXTerminal::getForeground() const { return foreground_color; } //---------------------------------------------------------------------- -inline const FString FTermXTerminal::getBackground() const +inline FString FTermXTerminal::getBackground() const { return background_color; } //---------------------------------------------------------------------- -inline const FString FTermXTerminal::getCursorColor() const +inline FString FTermXTerminal::getCursorColor() const { return cursor_color; } //---------------------------------------------------------------------- -inline const FString FTermXTerminal::getMouseForeground() const +inline FString FTermXTerminal::getMouseForeground() const { return mouse_foreground_color; } //---------------------------------------------------------------------- -inline const FString FTermXTerminal::getMouseBackground() const +inline FString FTermXTerminal::getMouseBackground() const { return mouse_background_color; } //---------------------------------------------------------------------- -inline const FString FTermXTerminal::getHighlightBackground() const +inline FString FTermXTerminal::getHighlightBackground() const { return highlight_background_color; } //---------------------------------------------------------------------- diff --git a/src/include/final/ftextview.h b/src/include/final/ftextview.h index 090280a7..1e93758e 100644 --- a/src/include/final/ftextview.h +++ b/src/include/final/ftextview.h @@ -90,10 +90,10 @@ class FTextView : public FWidget FTextView& operator << (const std::string&); // Accessors - const FString getClassName() const override; + FString getClassName() const override; std::size_t getColumns() const; std::size_t getRows() const; - const FString getText() const; + FString getText() const; const FStringList& getLines() const; // Mutators @@ -212,7 +212,7 @@ inline FTextView& FTextView::operator << (const std::string& string) } //---------------------------------------------------------------------- -inline const FString FTextView::getClassName() const +inline FString FTextView::getClassName() const { return "FTextView"; } //---------------------------------------------------------------------- diff --git a/src/include/final/ftogglebutton.h b/src/include/final/ftogglebutton.h index c1b49d63..35e35565 100644 --- a/src/include/final/ftogglebutton.h +++ b/src/include/final/ftogglebutton.h @@ -79,7 +79,7 @@ class FToggleButton : public FWidget FToggleButton& operator = (const FToggleButton&) = delete; // Accessors - const FString getClassName() const override; + FString getClassName() const override; FString& getText(); // Mutators @@ -141,7 +141,7 @@ class FToggleButton : public FWidget private: // Constants - static constexpr std::size_t NOT_SET = static_cast(-1); + static constexpr auto NOT_SET = static_cast(-1); // Mutator void setGroup (FButtonGroup*); @@ -165,7 +165,7 @@ class FToggleButton : public FWidget // FRadioButton inline functions //---------------------------------------------------------------------- -inline const FString FToggleButton::getClassName() const +inline FString FToggleButton::getClassName() const { return "FToggleButton"; } //---------------------------------------------------------------------- diff --git a/src/include/final/ftooltip.h b/src/include/final/ftooltip.h index 4fdc0839..46caa009 100644 --- a/src/include/final/ftooltip.h +++ b/src/include/final/ftooltip.h @@ -80,8 +80,8 @@ class FToolTip : public FWindow FToolTip& operator = (const FToolTip&) = delete; // Accessors - const FString getClassName() const override; - const FString getText() const; + FString getClassName() const override; + FString getText() const; // Mutators void setText (const FString&); @@ -116,9 +116,13 @@ class FToolTip : public FWindow // FToolTip inline functions //---------------------------------------------------------------------- -inline const FString FToolTip::getClassName() const +inline FString FToolTip::getClassName() const { return "FToolTip"; } +//---------------------------------------------------------------------- +inline FString FToolTip::getText() const +{ return text; } + //---------------------------------------------------------------------- inline bool FToolTip::setBorder() { return setBorder(true); } diff --git a/src/include/final/ftypes.h b/src/include/final/ftypes.h index f4c65fc2..7936d795 100644 --- a/src/include/final/ftypes.h +++ b/src/include/final/ftypes.h @@ -189,7 +189,7 @@ FKeyName; // FChar operator functions //---------------------------------------------------------------------- -inline constexpr bool operator == (const FChar& lhs, const FChar& rhs) +constexpr bool operator == (const FChar& lhs, const FChar& rhs) { return lhs.ch == rhs.ch && lhs.fg_color == rhs.fg_color @@ -201,7 +201,7 @@ inline constexpr bool operator == (const FChar& lhs, const FChar& rhs) } //---------------------------------------------------------------------- -inline constexpr bool operator != (const FChar& lhs, const FChar& rhs) +constexpr bool operator != (const FChar& lhs, const FChar& rhs) { return ! ( lhs == rhs ); } diff --git a/src/include/final/fvterm.h b/src/include/final/fvterm.h index 546463bb..ec6923fe 100644 --- a/src/include/final/fvterm.h +++ b/src/include/final/fvterm.h @@ -143,12 +143,12 @@ class FVTerm FVTerm& operator << (const FColorPair&); // Accessors - virtual const FString getClassName() const; + virtual FString getClassName() const; static FColor getTermForegroundColor(); static FColor getTermBackgroundColor(); FTermArea*& getVWin(); const FTermArea* getVWin() const; - const FPoint getPrintCursor(); + FPoint getPrintCursor(); static const FChar getAttribute(); FTerm& getFTerm() const; @@ -371,12 +371,12 @@ class FVTerm bool hasChildAreaChanges (FTermArea*) const; void clearChildAreaChanges (const FTermArea*) const; static bool isInsideArea (const FPoint&, const FTermArea*); - static const FChar generateCharacter (const FPoint&); - static const FChar getCharacter ( character_type + static FChar generateCharacter (const FPoint&); + static FChar getCharacter ( character_type , const FPoint& , FVTerm* ); - static const FChar getCoveredCharacter (const FPoint&, FVTerm*); - static const FChar getOverlappedCharacter (const FPoint&, FVTerm*); + static FChar getCoveredCharacter (const FPoint&, FVTerm*); + static FChar getOverlappedCharacter (const FPoint&, FVTerm*); void init(); static void init_characterLengths (const FOptiMove*); void finish(); @@ -607,7 +607,7 @@ inline FVTerm& FVTerm::operator << (const FColorPair& pair) } //---------------------------------------------------------------------- -inline const FString FVTerm::getClassName() const +inline FString FVTerm::getClassName() const { return "FVTerm"; } //---------------------------------------------------------------------- diff --git a/src/include/final/fwidget.h b/src/include/final/fwidget.h index 1a54c839..f4dbea63 100644 --- a/src/include/final/fwidget.h +++ b/src/include/final/fwidget.h @@ -183,7 +183,7 @@ class FWidget : public FVTerm, public FObject FWidget& operator = (const FWidget&) = delete; // Accessors - const FString getClassName() const override; + FString getClassName() const override; FWidget* getRootWidget() const; FWidget* getParentWidget() const; static FWidget*& getMainWidget(); @@ -230,8 +230,8 @@ class FWidget : public FVTerm, public FObject std::size_t getDesktopWidth() const; std::size_t getDesktopHeight() const; const FWidgetFlags& getFlags() const; - const FPoint getCursorPos() const; - const FPoint getPrintPos(); + FPoint getCursorPos() const; + FPoint getPrintPos(); // Mutators static void setMainWidget (FWidget*); @@ -541,7 +541,7 @@ void drawNewFontListBox (FWidget*, const FRect&); // FWidget inline functions //---------------------------------------------------------------------- -inline const FString FWidget::getClassName() const +inline FString FWidget::getClassName() const { return "FWidget"; } //---------------------------------------------------------------------- @@ -751,7 +751,7 @@ inline const FWidget::FWidgetFlags& FWidget::getFlags() const { return flags; } //---------------------------------------------------------------------- -inline const FPoint FWidget::getCursorPos() const +inline FPoint FWidget::getCursorPos() const { return widget_cursor_position; } //---------------------------------------------------------------------- diff --git a/src/include/final/fwidgetcolors.h b/src/include/final/fwidgetcolors.h index 3b00cbf2..38fbed1a 100644 --- a/src/include/final/fwidgetcolors.h +++ b/src/include/final/fwidgetcolors.h @@ -54,7 +54,7 @@ class FWidgetColors virtual ~FWidgetColors(); // Method - virtual const FString getClassName() const; + virtual FString getClassName() const; virtual void setColorTheme() = 0; // Data members @@ -148,7 +148,7 @@ class FWidgetColors // FWidgetColors inline functions //---------------------------------------------------------------------- -inline const FString FWidgetColors::getClassName() const +inline FString FWidgetColors::getClassName() const { return "FWidgetColors"; } @@ -179,13 +179,13 @@ class default8ColorTheme final : public FWidgetColors ~default8ColorTheme() override; // Method - const FString getClassName() const override; + FString getClassName() const override; void setColorTheme() override; }; // default8ColorTheme inline functions //---------------------------------------------------------------------- -inline const FString default8ColorTheme::getClassName() const +inline FString default8ColorTheme::getClassName() const { return "default8ColorTheme"; } @@ -216,13 +216,13 @@ class default16ColorTheme final : public FWidgetColors ~default16ColorTheme() override; // Method - const FString getClassName() const override; + FString getClassName() const override; void setColorTheme() override; }; // default16ColorTheme inline functions //---------------------------------------------------------------------- -inline const FString default16ColorTheme::getClassName() const +inline FString default16ColorTheme::getClassName() const { return "default16ColorTheme"; } @@ -253,13 +253,13 @@ class default8ColorDarkTheme final : public FWidgetColors ~default8ColorDarkTheme() override; // Method - const FString getClassName() const override; + FString getClassName() const override; void setColorTheme() override; }; // default8ColorDarkTheme inline functions //---------------------------------------------------------------------- -inline const FString default8ColorDarkTheme::getClassName() const +inline FString default8ColorDarkTheme::getClassName() const { return "default8ColorDarkTheme"; } @@ -290,13 +290,13 @@ class default16ColorDarkTheme final : public FWidgetColors ~default16ColorDarkTheme() override; // Method - const FString getClassName() const override; + FString getClassName() const override; void setColorTheme() override; }; // default16ColorDarkTheme inline functions //---------------------------------------------------------------------- -inline const FString default16ColorDarkTheme::getClassName() const +inline FString default16ColorDarkTheme::getClassName() const { return "default16ColorDarkTheme"; } } // namespace finalcut diff --git a/src/include/final/fwindow.h b/src/include/final/fwindow.h index 274b5c5d..f2e61c8c 100644 --- a/src/include/final/fwindow.h +++ b/src/include/final/fwindow.h @@ -83,7 +83,7 @@ class FWindow : public FWidget FWindow& operator = (const FWindow&) = delete; // Accessors - const FString getClassName() const override; + FString getClassName() const override; static FWindow* getWindowWidget (const FWidget*); static int getWindowLayer (const FWidget*); FWidget* getWindowFocusWidget() const; @@ -181,7 +181,7 @@ void closeDropDown (const FWidget*, const FPoint&); // FWindow inline functions //---------------------------------------------------------------------- -inline const FString FWindow::getClassName() const +inline FString FWindow::getClassName() const { return "FWindow"; } //---------------------------------------------------------------------- diff --git a/src/include/final/sgr_optimizer.h b/src/include/final/sgr_optimizer.h index ca974cbe..9aac2929 100644 --- a/src/include/final/sgr_optimizer.h +++ b/src/include/final/sgr_optimizer.h @@ -70,7 +70,7 @@ class SGRoptimizer final private: // Constants - static constexpr std::size_t NOT_SET = static_cast(-1); + static constexpr auto NOT_SET = static_cast(-1); // Methods void findParameter(); diff --git a/test/fkeyboard-test.cpp b/test/fkeyboard-test.cpp index 660631b5..50497acc 100644 --- a/test/fkeyboard-test.cpp +++ b/test/fkeyboard-test.cpp @@ -43,8 +43,11 @@ typedef struct } FKeyMap; -FKeyMap fkey[] = -{ +using original_type = std::array; +using test_type = std::array; + +test_type fkey = +{{ { finalcut::fc::Fkey_backspace , "\177" , "kb" }, // backspace key { finalcut::fc::Fkey_catab , 0 , "ka" }, // clear-all-tabs key { finalcut::fc::Fkey_clear , 0 , "kC" }, // clear-screen or erase key @@ -222,9 +225,8 @@ FKeyMap fkey[] = { finalcut::fc::Fkey_slash , ESC "Oo" , "KP1"}, // keypad slash { finalcut::fc::Fkey_asterisk , ESC "Oj" , "KP2"}, // keypad asterisk { finalcut::fc::Fkey_minus_sign, ESC "Om" , "KP3"}, // keypad minus sign - { finalcut::fc::Fkey_plus_sign , ESC "Ok" , "KP4"}, // keypad plus sign - { 0 , 0 , "\0" } -}; + { finalcut::fc::Fkey_plus_sign , ESC "Ok" , "KP4"} // keypad plus sign +}}; } // namespace test @@ -2826,7 +2828,10 @@ void FKeyboardTest::init() CPPUNIT_ASSERT ( key_pressed == 0 ); keyboard->enableUTF8(); keyboard->enableMouseSequences(); - keyboard->setTermcapMap (reinterpret_cast(test::fkey)); + + auto ptr = &test::fkey; + const auto& ref = *reinterpret_cast(ptr); + keyboard->setTermcapMap (ref); } //---------------------------------------------------------------------- diff --git a/test/ftermcapquirks-test.cpp b/test/ftermcapquirks-test.cpp index bc82fe26..bdd25f47 100644 --- a/test/ftermcapquirks-test.cpp +++ b/test/ftermcapquirks-test.cpp @@ -56,7 +56,7 @@ namespace test typedef struct { const char* string; - char tname[3]; + char tname[alignof(char*)]; } tcap_map; @@ -222,7 +222,7 @@ void FTermcapQuirksTest::classNameTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::generalTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; + auto& caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) @@ -285,7 +285,7 @@ void FTermcapQuirksTest::generalTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::xtermTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; + auto& caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) @@ -316,7 +316,7 @@ void FTermcapQuirksTest::xtermTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::freebsdTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; + auto& caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) @@ -355,7 +355,7 @@ void FTermcapQuirksTest::freebsdTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::cygwinTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; + auto& caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) @@ -380,7 +380,7 @@ void FTermcapQuirksTest::cygwinTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::linuxTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; + auto& caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) @@ -452,7 +452,7 @@ void FTermcapQuirksTest::linuxTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::rxvtTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; + auto& caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) @@ -493,7 +493,7 @@ void FTermcapQuirksTest::rxvtTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::vteTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; + auto& caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) @@ -517,7 +517,7 @@ void FTermcapQuirksTest::vteTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::puttyTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; + auto& caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) @@ -607,7 +607,7 @@ void FTermcapQuirksTest::puttyTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::teratermTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; + auto& caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) @@ -637,7 +637,7 @@ void FTermcapQuirksTest::teratermTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::sunTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; + auto& caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) @@ -755,7 +755,7 @@ void FTermcapQuirksTest::sunTest() //---------------------------------------------------------------------- void FTermcapQuirksTest::screenTest() { - finalcut::FTermcap::tcap_map* caps = finalcut::FTermcap::strings; + auto& caps = finalcut::FTermcap::strings; constexpr int last_item = int(sizeof(test::tcap) / sizeof(test::tcap[0])) - 1; for (std::size_t i = 0; i < last_item; i++) diff --git a/test/ftermfreebsd-test.cpp b/test/ftermfreebsd-test.cpp index c5b51406..08f37d34 100644 --- a/test/ftermfreebsd-test.cpp +++ b/test/ftermfreebsd-test.cpp @@ -819,11 +819,11 @@ wchar_t ftermfreebsdTest::charEncode (wchar_t c) { wchar_t ch_enc{L'\0'}; - for (std::size_t i{0}; i <= finalcut::fc::last_char_item; i++) + for (auto&& entry : finalcut::fc::character) { - if ( finalcut::fc::character[i][finalcut::fc::UTF8] == uInt(c) ) + if ( entry[finalcut::fc::UTF8] == uInt(c) ) { - ch_enc = wchar_t(finalcut::fc::character[i][finalcut::fc::PC]); + ch_enc = wchar_t(entry[finalcut::fc::PC]); break; } } diff --git a/test/ftermlinux-test.cpp b/test/ftermlinux-test.cpp index 6304adb8..97e50104 100644 --- a/test/ftermlinux-test.cpp +++ b/test/ftermlinux-test.cpp @@ -1446,7 +1446,7 @@ void FSystemTest::initVScreenInfo() void FSystemTest::initFScreenInfo() { char id[16] { "VESA VGA" }; - std::strncpy (fb_terminal_fix_info.id, id, sizeof(id)); + std::strncpy (fb_terminal_fix_info.id, id, sizeof(fb_terminal_fix_info.id)); fb_terminal_fix_info.smem_start = 0xf9000000; fb_terminal_fix_info.smem_len = 0x00500000; fb_terminal_fix_info.type = 0; From fb8baf8c5c19bfb3bbc625d97947ebaeade91d99 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 4 Oct 2020 02:55:15 +0200 Subject: [PATCH 20/30] Fixed a few minor bugs --- .github/workflows/codeql-analysis.yml | 2 +- examples/busy.cpp | 2 +- examples/mouse.cpp | 6 ++--- examples/opti-move.cpp | 8 +++--- examples/rotozoomer.cpp | 20 +++++++------- examples/scrollview.cpp | 4 +-- examples/term-attributes.cpp | 4 +-- examples/transparent.cpp | 2 +- examples/treeview.cpp | 4 +-- examples/watch.cpp | 2 +- examples/windows.cpp | 10 +++---- src/fapplication.cpp | 2 +- src/fdialog.cpp | 14 +++++----- src/ffiledialog.cpp | 4 +-- src/fkeyboard.cpp | 14 +++++----- src/flineedit.cpp | 8 +++--- src/flistbox.cpp | 12 ++++----- src/flistview.cpp | 38 +++++++++++++-------------- src/fmouse.cpp | 4 +-- src/fobject.cpp | 2 +- src/fscrollbar.cpp | 2 +- src/fscrollview.cpp | 22 ++++++++-------- src/fstatusbar.cpp | 2 +- src/ftermdetection.cpp | 6 ++--- src/include/final/fdialog.h | 4 +-- src/include/final/flineedit.h | 2 +- src/include/final/fscrollview.h | 2 +- src/include/final/ftermcap.h | 1 + src/include/final/ftermdetection.h | 6 ++--- src/include/final/fvterm.h | 4 +-- src/include/final/fwidget.h | 22 ++++++++-------- 31 files changed, 118 insertions(+), 117 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 4b08a42d..2f58b012 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -63,7 +63,7 @@ jobs: - name: Create configure file run: autoreconf -v --install --force - + - name: Create makefiles run: ./configure --prefix=/usr CPPFLAGS="-DDEBUG" CXXFLAGS="-g -O0 -DDEBUG -W -Wall -pedantic" diff --git a/examples/busy.cpp b/examples/busy.cpp index 281da6e7..4e06d2ae 100644 --- a/examples/busy.cpp +++ b/examples/busy.cpp @@ -89,7 +89,7 @@ Dialog::Dialog (FWidget* parent) void Dialog::adjustSize() { finalcut::FDialog::adjustSize(); - int x = int((getDesktopWidth() - getWidth()) / 2); + auto x = int((getDesktopWidth() - getWidth()) / 2); const int y = 5; if ( x < 1 ) diff --git a/examples/mouse.cpp b/examples/mouse.cpp index c59524af..5d76c3d3 100644 --- a/examples/mouse.cpp +++ b/examples/mouse.cpp @@ -428,7 +428,7 @@ void MouseDraw::onClose (finalcut::FCloseEvent* ev) //---------------------------------------------------------------------- void MouseDraw::draw() { - const int y_max = int(getHeight()); + const auto y_max = int(getHeight()); finalcut::FDialog::draw(); setColor(); @@ -463,8 +463,8 @@ void MouseDraw::draw() //---------------------------------------------------------------------- void MouseDraw::drawBrush (int x, int y, bool swap_color) { - const int Cols = int(getWidth()); - const int Lines = int(getHeight()); + const auto Cols = int(getWidth()); + const auto Lines = int(getHeight()); if ( x > 10 && x < Cols && y > 2 && y < Lines ) { diff --git a/examples/opti-move.cpp b/examples/opti-move.cpp index b89bf694..79f9c359 100644 --- a/examples/opti-move.cpp +++ b/examples/opti-move.cpp @@ -66,8 +66,8 @@ bool keyPressed() void term_boundaries (int& x, int& y) { // checks and corrects the terminal boundaries - const int term_width = int(app->getDesktopWidth()); - const int term_height = int(app->getDesktopHeight()); + const auto term_width = int(app->getDesktopWidth()); + const auto term_height = int(app->getDesktopHeight()); if ( x < 0 ) x = 0; @@ -230,8 +230,8 @@ int main (int argc, char* argv[]) app = &term_app; // Get screen dimension - int xmax = int(term_app.getDesktopWidth() - 1); - int ymax = int(term_app.getDesktopHeight() - 1); + auto xmax = int(term_app.getDesktopWidth() - 1); + auto ymax = int(term_app.getDesktopHeight() - 1); finalcut::FString line{std::size_t(xmax) + 1, '-'}; // Place the cursor in the upper left corner diff --git a/examples/rotozoomer.cpp b/examples/rotozoomer.cpp index 12dfec23..448ff8af 100644 --- a/examples/rotozoomer.cpp +++ b/examples/rotozoomer.cpp @@ -129,10 +129,10 @@ void RotoZoomer::draw() start = system_clock::now(); finalcut::FDialog::draw(); - double cx = double(80.0 / 2.0 + (80.0 / 2.0 * std::sin(double(path) / 50.0))); - double cy = double(23.0 + (23.0 * std::cos(double(path) / 50.0))); - double r = double(128.0 + 96.0 * std::cos(double(path) / 10.0)); - double a = double(path) / 50.0; + auto cx = double(80.0 / 2.0 + (80.0 / 2.0 * std::sin(double(path) / 50.0))); + auto cy = double(23.0 + (23.0 * std::cos(double(path) / 50.0))); + auto r = double(128.0 + 96.0 * std::cos(double(path) / 10.0)); + auto a = double(path) / 50.0; rotozoomer (cx, cy, r, a); } @@ -141,12 +141,12 @@ void RotoZoomer::rotozoomer (double cx, double cy, double r, double a) { const int Cols = int(getClientWidth()); const int Lines = int(getClientHeight()); - int Ax = int(4096.0 * (cx + r * std::cos(a))); - int Ay = int(4096.0 * (cy + r * std::sin(a))); - int Bx = int(4096.0 * (cx + r * std::cos(a + 2.02358))); - int By = int(4096.0 * (cy + r * std::sin(a + 2.02358))); - int Cx = int(4096.0 * (cx + r * std::cos(a - 1.11701))); - int Cy = int(4096.0 * (cy + r * std::sin(a - 1.11701))); + auto Ax = int(4096.0 * (cx + r * std::cos(a))); + auto Ay = int(4096.0 * (cy + r * std::sin(a))); + auto Bx = int(4096.0 * (cx + r * std::cos(a + 2.02358))); + auto By = int(4096.0 * (cy + r * std::sin(a + 2.02358))); + auto Cx = int(4096.0 * (cx + r * std::cos(a - 1.11701))); + auto Cy = int(4096.0 * (cy + r * std::sin(a - 1.11701))); int dxdx = (Bx - Ax) / 80; int dydx = (By - Ay) / 80; int dxdy = (Cx - Ax) / 23; diff --git a/examples/scrollview.cpp b/examples/scrollview.cpp index 22bbac87..6ef8b54f 100644 --- a/examples/scrollview.cpp +++ b/examples/scrollview.cpp @@ -118,8 +118,8 @@ Scrollview::~Scrollview() void Scrollview::setScrollSize (const FSize& size) { FScrollView::setScrollSize (size); - const int width = int(size.getWidth()); - const int height = int(size.getHeight()); + const auto width = int(size.getWidth()); + const auto height = int(size.getHeight()); go_south.setPos (FPoint{width - 5, 1}); go_west.setPos (FPoint{width - 5, height - 1}); go_north.setPos (FPoint{1, height - 1}); diff --git a/examples/term-attributes.cpp b/examples/term-attributes.cpp index 9eacc4e1..37ac4cf5 100644 --- a/examples/term-attributes.cpp +++ b/examples/term-attributes.cpp @@ -177,8 +177,8 @@ void AttribDlg::cb_back() //---------------------------------------------------------------------- void AttribDlg::adjustSize() { - int x = int((getDesktopWidth() - getWidth()) / 2); - int y = int((getDesktopHeight() - getHeight()) / 2) + 1; + auto x = int((getDesktopWidth() - getWidth()) / 2); + auto y = int((getDesktopHeight() - getHeight()) / 2) + 1; if ( x < 1 ) x = 1; diff --git a/examples/transparent.cpp b/examples/transparent.cpp index cebba7d9..80e91e7b 100644 --- a/examples/transparent.cpp +++ b/examples/transparent.cpp @@ -213,7 +213,7 @@ MainWindow::MainWindow (finalcut::FWidget* parent) ibg->unsetTransparentShadow(); // Set statusbar text for this window - setStatusbarMessage("Press Q to quit"); + FDialog::setStatusbarMessage("Press Q to quit"); unsetTransparentShadow(); activateDialog(); diff --git a/examples/treeview.cpp b/examples/treeview.cpp index 98f53c8a..3f3d8123 100644 --- a/examples/treeview.cpp +++ b/examples/treeview.cpp @@ -50,7 +50,7 @@ sInt64 stringToNumber (const finalcut::FString& str) auto num_string = str.left(str.getLength() - 1); num_string = num_string.replace(",", ""); num_string = num_string.replace('.', ""); - sInt64 number = sInt64(num_string.toLong()); + auto number = sInt64(num_string.toLong()); return number; } @@ -405,7 +405,7 @@ void Treeview::adjustSize() std::size_t h = getDesktopHeight() - 4; setHeight (h, false); - int x = int((getDesktopWidth() - getWidth()) / 2); + auto x = int((getDesktopWidth() - getWidth()) / 2); if ( x < 1 ) x = 1; diff --git a/examples/watch.cpp b/examples/watch.cpp index c607fd61..89adc220 100644 --- a/examples/watch.cpp +++ b/examples/watch.cpp @@ -192,7 +192,7 @@ void Watch::cb_seconds() //---------------------------------------------------------------------- void Watch::adjustSize() { - const int pw = int(getDesktopWidth()); + const auto pw = int(getDesktopWidth()); setX (1 + (pw - 22) / 2, false); setY (3, false); finalcut::FDialog::adjustSize(); diff --git a/examples/windows.cpp b/examples/windows.cpp index d19ec369..5d750c66 100644 --- a/examples/windows.cpp +++ b/examples/windows.cpp @@ -243,7 +243,7 @@ class Window final : public finalcut::FDialog Window::Window (finalcut::FWidget* parent) : finalcut::FDialog{parent} { - setSize ({40, 6}); + FDialog::setSize ({40, 6}); // Menu bar item File.setStatusbarMessage ("File management commands"); @@ -355,8 +355,8 @@ void Window::adjustSize() const std::size_t w = getDesktopWidth(); const std::size_t h = getDesktopHeight(); - const int X = int(1 + (w - 40) / 2); - int Y = int(1 + (h - 22) / 2); + const auto X = int(1 + (w - 40) / 2); + auto Y = int(1 + (h - 22) / 2); const int dx = ( w > 80 ) ? int(w - 80) / 2 : 0; const int dy = ( h > 24 ) ? int(h - 24) / 2 : 0; @@ -371,7 +371,7 @@ void Window::adjustSize() { if ( (*iter)->is_open ) { - const int n = int(std::distance(first, iter)); + const auto n = int(std::distance(first, iter)); const int x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3; const int y = dy + 11 + int(n / 3) * 3; (*iter)->dgl->setPos (FPoint{x, y}); @@ -469,7 +469,7 @@ void Window::cb_createWindows() win_dat->dgl = win; win_dat->is_open = true; win->setText(win_dat->title); - const int n = int(std::distance(first, iter)); + const auto n = int(std::distance(first, iter)); const int x = dx + 5 + (n % 3) * 25 + int(n / 3) * 3; const int y = dy + 11 + int(n / 3) * 3; win->setGeometry (FPoint{x, y}, FSize{20, 8}); diff --git a/src/fapplication.cpp b/src/fapplication.cpp index cc0a2c7c..7173906f 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -133,7 +133,7 @@ FWidget* FApplication::getKeyboardWidget() FApplication::FLogPtr& FApplication::getLog() { // Global logger object - static FLogPtr* logger_ptr = new FLogPtr(); + static auto logger_ptr = new FLogPtr(); if ( logger_ptr && logger_ptr->get() == nullptr ) { diff --git a/src/fdialog.cpp b/src/fdialog.cpp index 5ec74e93..0b91c3dc 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -226,8 +226,8 @@ void FDialog::setPos (const FPoint& pos, bool) if ( getTermGeometry().overlap(old_geometry) ) { FRect restore{}; - const std::size_t d_width = std::size_t(std::abs(dx)); - const std::size_t d_height = std::size_t(std::abs(dy)); + const auto d_width = std::size_t(std::abs(dx)); + const auto d_height = std::size_t(std::abs(dy)); // dx > 0 : move left // dx = 0 : move vertical @@ -354,8 +354,8 @@ void FDialog::setSize (const FSize& size, bool adjust) // dh = 0 : scale only width // dh < 0 : scale up height - const std::size_t d_width = std::size_t(dw); - const std::size_t d_height = std::size_t(dh); + const auto d_width = std::size_t(dw); + const auto d_height = std::size_t(dh); // restoring the non-covered terminal areas if ( dw > 0 ) @@ -492,7 +492,7 @@ void FDialog::onKeyPress (FKeyEvent* ev) //---------------------------------------------------------------------- void FDialog::onMouseDown (FMouseEvent* ev) { - const int width = int(getWidth()); + const auto width = int(getWidth()); const mouseStates ms = { @@ -1500,7 +1500,7 @@ bool FDialog::isOutsideTerminal (const FPoint& pos) const } //---------------------------------------------------------------------- -bool FDialog::isLeftOutside() +bool FDialog::isLeftOutside() const { if ( getX() > int(getMaxWidth()) ) return true; @@ -1509,7 +1509,7 @@ bool FDialog::isLeftOutside() } //---------------------------------------------------------------------- -bool FDialog::isBottomOutside() +bool FDialog::isBottomOutside() const { if ( getY() > int(getMaxHeight()) ) return true; diff --git a/src/ffiledialog.cpp b/src/ffiledialog.cpp index 20412da6..70d9213b 100644 --- a/src/ffiledialog.cpp +++ b/src/ffiledialog.cpp @@ -167,7 +167,7 @@ FFileDialog& FFileDialog::operator = (const FFileDialog& fdlg) //---------------------------------------------------------------------- FString FFileDialog::getSelectedFile() const { - const uLong n = uLong(filebrowser.currentItem() - 1); + const auto n = uLong(filebrowser.currentItem() - 1); if ( dir_entries[n].directory ) return FString{""}; @@ -823,7 +823,7 @@ void FFileDialog::cb_processRowChanged() //---------------------------------------------------------------------- void FFileDialog::cb_processClicked() { - const uLong n = uLong(filebrowser.currentItem() - 1); + const auto n = uLong(filebrowser.currentItem() - 1); if ( dir_entries[n].directory ) changeDir(dir_entries[n].name); diff --git a/src/fkeyboard.cpp b/src/fkeyboard.cpp index c3776343..27d48ab3 100644 --- a/src/fkeyboard.cpp +++ b/src/fkeyboard.cpp @@ -88,18 +88,18 @@ void FKeyboard::fetchKeyCode() //---------------------------------------------------------------------- FString FKeyboard::getKeyName (const FKey keynum) const { - const auto& key = std::find_if + const auto& found_key = std::find_if ( fc::fkeyname.begin(), fc::fkeyname.end(), - [&keynum] (fc::FKeyName kn) + [&keynum] (const fc::FKeyName& kn) { return (kn.num > 0 && kn.num == keynum); } ); - if ( key != fc::fkeyname.end() ) - return FString{key->string}; + if ( found_key != fc::fkeyname.end() ) + return FString{found_key->string}; if ( keynum > 32 && keynum < 127 ) return FString{char(keynum)}; @@ -296,7 +296,7 @@ inline FKey FKeyboard::getSingleKey() std::size_t n{}; std::size_t len{1}; - const uChar firstchar = uChar(fifo_buf[0]); + const auto firstchar = uChar(fifo_buf[0]); FKey keycode{}; // Look for a utf-8 character @@ -385,7 +385,7 @@ FKey FKeyboard::UTF8decode (const char utf8[]) const for (std::size_t i{0}; i < len; ++i) { - const uChar ch = uChar(utf8[i]); + const auto ch = uChar(utf8[i]); if ( (ch & 0xc0) == 0x80 ) { @@ -478,7 +478,7 @@ void FKeyboard::parseKeyBuffer() //---------------------------------------------------------------------- FKey FKeyboard::parseKeyString() { - const uChar firstchar = uChar(fifo_buf[0]); + const auto firstchar = uChar(fifo_buf[0]); if ( firstchar == ESC[0] ) { diff --git a/src/flineedit.cpp b/src/flineedit.cpp index e5556ebd..8ef8f38e 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -752,9 +752,9 @@ void FLineEdit::drawInputField() // set the cursor to the insert pos. const auto cursor_pos_column = getCursorColumnPos(); - const int xpos = int(2 + cursor_pos_column - - text_offset_column - + char_width_offset); + const auto xpos = int(2 + cursor_pos_column + - text_offset_column + + char_width_offset); setCursorPos ({xpos, 1}); } @@ -802,7 +802,7 @@ inline std::size_t FLineEdit::getCursorColumnPos() const } //---------------------------------------------------------------------- -inline const FString FLineEdit::getPasswordText() const +inline FString FLineEdit::getPasswordText() const { return FString{text.getLength(), fc::Bullet}; // • } diff --git a/src/flistbox.cpp b/src/flistbox.cpp index 8709dcb0..cb43608d 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -692,7 +692,7 @@ inline void FListBox::mapKeyFunctions() //---------------------------------------------------------------------- void FListBox::processKeyAction (FKeyEvent* ev) { - const int idx = int(ev->key()); + const auto idx = int(ev->key()); if ( key_map.find(idx) != key_map.end() ) { @@ -933,7 +933,7 @@ inline void FListBox::drawListBracketsLine ( int y printLeftBracket (iter->brackets); } - const std::size_t first = std::size_t(xoffset); + const auto first = std::size_t(xoffset); const std::size_t max_width = getWidth() - nf_offset - 4 - b; const FString element(getColumnSubString (getString(iter), first, max_width)); std::size_t column_width = getColumnWidth(element); @@ -1233,7 +1233,7 @@ void FListBox::wheelUp (int pagesize) void FListBox::wheelDown (int pagesize) { const std::size_t element_count = getCount(); - int yoffset_end = int(element_count - getClientHeight()); + auto yoffset_end = int(element_count - getClientHeight()); if ( yoffset_end < 0 ) yoffset_end = 0; @@ -1366,7 +1366,7 @@ void FListBox::prevListItem (int distance) void FListBox::nextListItem (int distance) { const std::size_t element_count = getCount(); - const int yoffset_end = int(element_count - getClientHeight()); + const auto yoffset_end = int(element_count - getClientHeight()); if ( current == element_count ) return; @@ -1407,7 +1407,7 @@ void FListBox::scrollToX (int val) void FListBox::scrollToY (int val) { const std::size_t element_count = getCount(); - const int yoffset_end = int(element_count - getClientHeight()); + const auto yoffset_end = int(element_count - getClientHeight()); if ( yoffset == val ) return; @@ -1516,7 +1516,7 @@ inline void FListBox::firstPos() inline void FListBox::lastPos() { const std::size_t element_count = getCount(); - const int yoffset_end = int(element_count - getClientHeight()); + const auto yoffset_end = int(element_count - getClientHeight()); current = element_count; if ( current > getClientHeight() ) diff --git a/src/flistview.cpp b/src/flistview.cpp index 7bcb30e2..a8f37cd2 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -239,7 +239,7 @@ FString FListViewItem::getText (int column) const return fc::emptyFString::get(); // Convert column position to address offset (index) - const std::size_t index = std::size_t(column - 1); + const auto index = std::size_t(column - 1); return column_list[index]; } @@ -275,7 +275,7 @@ void FListViewItem::setText (int column, const FString& text) if ( ! listview->header[index].fixed_width ) { - const int column_width = int(getColumnWidth(text)); + const auto column_width = int(getColumnWidth(text)); if ( column_width > listview->header[index].width ) listview->header[index].width = column_width; @@ -705,7 +705,7 @@ fc::text_alignment FListView::getColumnAlignment (int column) const return fc::alignLeft; // Convert column position to address offset (index) - const std::size_t index = std::size_t(column - 1); + const auto index = std::size_t(column - 1); return header[index].alignment; } @@ -718,7 +718,7 @@ FString FListView::getColumnText (int column) const return fc::emptyFString::get(); // Convert column position to address offset (index) - const std::size_t index = std::size_t(column - 1); + const auto index = std::size_t(column - 1); return header[index].name; } @@ -726,7 +726,7 @@ FString FListView::getColumnText (int column) const fc::sorting_type FListView::getColumnSortType (int column) const { fc::sorting_type type; - const std::size_t col = std::size_t(column); + const auto col = std::size_t(column); try { @@ -764,7 +764,7 @@ void FListView::setColumnAlignment (int column, fc::text_alignment align) return; // Convert column position to address offset (index) - const std::size_t index = std::size_t(column - 1); + const auto index = std::size_t(column - 1); header[index].alignment = align; } @@ -777,11 +777,11 @@ void FListView::setColumnText (int column, const FString& label) return; // Convert column position to address offset (index) - std::size_t index = std::size_t(column - 1); + auto index = std::size_t(column - 1); if ( ! header[index].fixed_width ) { - const int column_width = int(getColumnWidth(label)); + const auto column_width = int(getColumnWidth(label)); if ( column_width > header[index].width ) header[index].width = column_width; @@ -1375,7 +1375,7 @@ void FListView::onFocusOut (FFocusEvent*) //---------------------------------------------------------------------- void FListView::adjustViewport (const int element_count) { - const int height = int(getClientHeight()); + const auto height = int(getClientHeight()); if ( height <= 0 || element_count == 0 ) return; @@ -1511,7 +1511,7 @@ inline void FListView::mapKeyFunctions() //---------------------------------------------------------------------- void FListView::processKeyAction (FKeyEvent* ev) { - const int idx = int(ev->key()); + const auto idx = int(ev->key()); if ( key_map.find(idx) != key_map.end() ) { @@ -1760,7 +1760,7 @@ void FListView::drawListLine ( const FListViewItem* item { static constexpr std::size_t ellipsis_length = 2; const auto& text = item->column_list[col]; - std::size_t width = std::size_t(header[col].width); + auto width = std::size_t(header[col].width); const std::size_t column_width = getColumnWidth(text); // Increment the value of col for the column position // and the next iteration @@ -1989,7 +1989,7 @@ void FListView::drawHeadlineLabel (const headerItems::const_iterator& iter) static constexpr std::size_t leading_space = 1; const auto& text = iter->name; FString txt{" " + text}; - const std::size_t width = std::size_t(iter->width); + const auto width = std::size_t(iter->width); std::size_t column_width = getColumnWidth(txt); const std::size_t column_max = leading_space + width; const headerItems::const_iterator first = header.begin(); @@ -2169,7 +2169,7 @@ std::size_t FListView::determineLineWidth (FListViewItem* item) for (auto&& header_item : header) { - const std::size_t width = std::size_t(header_item.width); + const auto width = std::size_t(header_item.width); const bool fixed_width = header_item.fixed_width; if ( ! fixed_width ) @@ -2276,7 +2276,7 @@ void FListView::mouseHeaderClicked() { static constexpr int leading_space = 1; const bool has_sort_indicator( column == sort_column ); - int click_width = int(getColumnWidth(item.name)); + auto click_width = int(getColumnWidth(item.name)); if ( has_sort_indicator ) click_width += 2; @@ -2335,7 +2335,7 @@ void FListView::wheelDown (int pagesize) if ( itemlist.empty() ) return; - const int element_count = int(getCount()); + const auto element_count = int(getCount()); if ( current_iter.getPosition() + 1 == element_count ) return; @@ -2374,7 +2374,7 @@ bool FListView::dragScrollUp (int position_before) //---------------------------------------------------------------------- bool FListView::dragScrollDown (int position_before) { - const int element_count = int(getCount()); + const auto element_count = int(getCount()); if ( position_before + 1 == element_count ) { @@ -2593,7 +2593,7 @@ inline void FListView::lastPos() if ( itemlist.empty() ) return; - const int element_count = int(getCount()); + const auto element_count = int(getCount()); current_iter += element_count - current_iter.getPosition() - 1; const int difference = element_count - last_visible_line.getPosition() - 1; first_visible_line += difference; @@ -2688,7 +2688,7 @@ void FListView::stepForward (int distance) if ( itemlist.empty() ) return; - const int element_count = int(getCount()); + const auto element_count = int(getCount()); if ( current_iter.getPosition() + 1 == element_count ) return; @@ -2769,7 +2769,7 @@ void FListView::scrollToX (int x) void FListView::scrollToY (int y) { const int pagesize = int(getClientHeight()) - 1; - const int element_count = int(getCount()); + const auto element_count = int(getCount()); if ( first_visible_line.getPosition() == y ) return; diff --git a/src/fmouse.cpp b/src/fmouse.cpp index 471d13de..510fb482 100644 --- a/src/fmouse.cpp +++ b/src/fmouse.cpp @@ -563,8 +563,8 @@ void FMouseX11::processEvent (struct timeval* time) // Parse and interpret the X11 xterm mouse string const auto& mouse_position = getPos(); - const uChar x = uChar(x11_mouse[1] - 0x20); - const uChar y = uChar(x11_mouse[2] - 0x20); + const auto x = uChar(x11_mouse[1] - 0x20); + const auto y = uChar(x11_mouse[2] - 0x20); const int btn = x11_mouse[0]; setNewPos (x, y); clearButtonState(); diff --git a/src/fobject.cpp b/src/fobject.cpp index d474c249..20f7e420 100644 --- a/src/fobject.cpp +++ b/src/fobject.cpp @@ -254,7 +254,7 @@ bool FObject::isTimeout (const timeval* time, uInt64 timeout) diff.tv_usec += 1000000; } - const uInt64 diff_usec = uInt64((diff.tv_sec * 1000000) + diff.tv_usec); + const auto diff_usec = uInt64((diff.tv_sec * 1000000) + diff.tv_usec); return ( diff_usec > timeout ); } diff --git a/src/fscrollbar.cpp b/src/fscrollbar.cpp index a593745c..fef5ace8 100644 --- a/src/fscrollbar.cpp +++ b/src/fscrollbar.cpp @@ -411,7 +411,7 @@ void FScrollbar::onTimer (FTimerEvent*) || ( scroll_type == FScrollbar::scrollPageForward && slider_pos == slider_click_stop_pos ) ) { - const int max_slider_pos = int(bar_length - slider_length); + const auto max_slider_pos = int(bar_length - slider_length); if ( scroll_type == FScrollbar::scrollPageBackward && slider_pos == 0 ) diff --git a/src/fscrollview.cpp b/src/fscrollview.cpp index 235cad83..d0483e76 100644 --- a/src/fscrollview.cpp +++ b/src/fscrollview.cpp @@ -139,8 +139,8 @@ void FScrollView::setScrollSize (const FSize& size) setChildPrintArea (viewport); } - const int xoffset_end = int(getScrollWidth() - getViewportWidth()); - const int yoffset_end = int(getScrollHeight() - getViewportHeight()); + const auto xoffset_end = int(getScrollWidth() - getViewportWidth()); + const auto yoffset_end = int(getScrollHeight() - getViewportHeight()); setTopPadding (1 - getScrollY()); setLeftPadding (1 - getScrollX()); setBottomPadding (1 - (yoffset_end - getScrollY())); @@ -352,8 +352,8 @@ void FScrollView::scrollTo (int x, int y) int& yoffset = viewport_geometry.y1_ref(); const int xoffset_before = xoffset; const int yoffset_before = yoffset; - const int xoffset_end = int(getScrollWidth() - getViewportWidth()); - const int yoffset_end = int(getScrollHeight() - getViewportHeight()); + const auto xoffset_end = int(getScrollWidth() - getViewportWidth()); + const auto yoffset_end = int(getScrollHeight() - getViewportHeight()); const std::size_t save_width = viewport_geometry.getWidth(); const std::size_t save_height = viewport_geometry.getHeight(); x--; @@ -462,7 +462,7 @@ void FScrollView::drawBorder() //---------------------------------------------------------------------- void FScrollView::onKeyPress (FKeyEvent* ev) { - const int idx = int(ev->key()); + const auto idx = int(ev->key()); if ( key_map.find(idx) != key_map.end() ) { @@ -658,8 +658,8 @@ void FScrollView::copy2area() const int ay = getTermY() - printarea->offset_top; const int dx = viewport_geometry.getX(); const int dy = viewport_geometry.getY(); - int y_end = int(getViewportHeight()); - int x_end = int(getViewportWidth()); + auto y_end = int(getViewportHeight()); + auto x_end = int(getViewportWidth()); // viewport width does not fit into the printarea if ( printarea->width <= ax + x_end ) @@ -694,7 +694,7 @@ void FScrollView::copy2area() // private methods of FScrollView //---------------------------------------------------------------------- -inline const FPoint FScrollView::getViewportCursorPos() const +inline FPoint FScrollView::getViewportCursorPos() const { const auto& window = FWindow::getWindowWidget(this); @@ -726,8 +726,8 @@ void FScrollView::init() resetColors(); setGeometry (FPoint{1, 1}, FSize{4, 4}); setMinimumSize (FSize{4, 4}); - const int xoffset_end = int(getScrollWidth() - getViewportWidth()); - const int yoffset_end = int(getScrollHeight() - getViewportHeight()); + const auto xoffset_end = int(getScrollWidth() - getViewportWidth()); + const auto yoffset_end = int(getScrollHeight() - getViewportHeight()); nf_offset = FTerm::isNewFont() ? 1 : 0; setTopPadding (1 - getScrollY()); setLeftPadding (1 - getScrollX()); @@ -767,7 +767,7 @@ inline void FScrollView::mapKeyFunctions() key_map[fc::Fkey_end] = \ [this] () { - int yoffset_end = int(getScrollHeight() - getViewportHeight()); + auto yoffset_end = int(getScrollHeight() - getViewportHeight()); scrollToY (1 + yoffset_end); }; } diff --git a/src/fstatusbar.cpp b/src/fstatusbar.cpp index 56b7951c..8581fba5 100644 --- a/src/fstatusbar.cpp +++ b/src/fstatusbar.cpp @@ -516,7 +516,7 @@ void FStatusBar::init() { const auto& r = getRootWidget(); const std::size_t w = r->getWidth(); - const int h = int(r->getHeight()); + const auto h = int(r->getHeight()); // initialize geometry values setGeometry (FPoint{1, h}, FSize{w, 1}, false); setAlwaysOnTop(); diff --git a/src/ftermdetection.cpp b/src/ftermdetection.cpp index 5f552054..b1738424 100644 --- a/src/ftermdetection.cpp +++ b/src/ftermdetection.cpp @@ -548,7 +548,7 @@ const char* FTermDetection::determineMaxColor (const char current_termtype[]) } //---------------------------------------------------------------------- -const FString FTermDetection::getXTermColorName (FColor color) +FString FTermDetection::getXTermColorName (FColor color) { FString color_str{""}; fd_set ifds{}; @@ -629,7 +629,7 @@ const char* FTermDetection::parseAnswerbackMsg (const char current_termtype[]) } //---------------------------------------------------------------------- -const FString FTermDetection::getAnswerbackMsg() +FString FTermDetection::getAnswerbackMsg() { FString answerback{""}; fd_set ifds{}; @@ -746,7 +746,7 @@ int FTermDetection::str2int (const FString& s) } //---------------------------------------------------------------------- -const FString FTermDetection::getSecDA() +FString FTermDetection::getSecDA() { FString sec_da_str{""}; diff --git a/src/include/final/fdialog.h b/src/include/final/fdialog.h index 4288332f..82ca069a 100644 --- a/src/include/final/fdialog.h +++ b/src/include/final/fdialog.h @@ -200,8 +200,8 @@ class FDialog : public FWindow void raiseActivateDialog(); void lowerActivateDialog(); bool isOutsideTerminal (const FPoint&) const; - bool isLeftOutside(); - bool isBottomOutside(); + bool isLeftOutside() const; + bool isBottomOutside() const; bool isLowerRightResizeCorner (const mouseStates&) const; void resizeMouseDown (const mouseStates&); void resizeMouseUpMove (const mouseStates&, bool = false); diff --git a/src/include/final/flineedit.h b/src/include/final/flineedit.h index cedeadfc..7c28aebe 100644 --- a/src/include/final/flineedit.h +++ b/src/include/final/flineedit.h @@ -185,7 +185,7 @@ class FLineEdit : public FWidget std::size_t printTextField(); std::size_t printPassword(); std::size_t getCursorColumnPos() const; - const FString getPasswordText() const; + FString getPasswordText() const; bool isPasswordField() const; offsetPair endPosToOffset (std::size_t); std::size_t clickPosToCursorPos (std::size_t); diff --git a/src/include/final/fscrollview.h b/src/include/final/fscrollview.h index a3189cd4..bb205471 100644 --- a/src/include/final/fscrollview.h +++ b/src/include/final/fscrollview.h @@ -157,7 +157,7 @@ class FScrollView : public FWidget static constexpr int horizontal_border_spacing = 2; // Accessors - const FPoint getViewportCursorPos() const; + FPoint getViewportCursorPos() const; // Methods void init(); diff --git a/src/include/final/ftermcap.h b/src/include/final/ftermcap.h index 447ea433..23cb3aa2 100644 --- a/src/include/final/ftermcap.h +++ b/src/include/final/ftermcap.h @@ -55,6 +55,7 @@ #undef buttons // from term.h #endif +#include #include #include #include diff --git a/src/include/final/ftermdetection.h b/src/include/final/ftermdetection.h index 1308c73d..b4ebf48d 100644 --- a/src/include/final/ftermdetection.h +++ b/src/include/final/ftermdetection.h @@ -174,12 +174,12 @@ class FTermDetection final static bool get256colorEnvString(); static const char* termtype_256color_quirks(); static const char* determineMaxColor (const char[]); - static const FString getXTermColorName (FColor); + static FString getXTermColorName (FColor); static const char* parseAnswerbackMsg (const char[]); - static const FString getAnswerbackMsg(); + static FString getAnswerbackMsg(); static const char* parseSecDA (const char[]); static int str2int (const FString&); - static const FString getSecDA(); + static FString getSecDA(); static const char* secDA_Analysis (const char[]); static const char* secDA_Analysis_0 (const char[]); static const char* secDA_Analysis_1 (const char[]); diff --git a/src/include/final/fvterm.h b/src/include/final/fvterm.h index ec6923fe..a61acf75 100644 --- a/src/include/final/fvterm.h +++ b/src/include/final/fvterm.h @@ -149,7 +149,7 @@ class FVTerm FTermArea*& getVWin(); const FTermArea* getVWin() const; FPoint getPrintCursor(); - static const FChar getAttribute(); + static FChar getAttribute(); FTerm& getFTerm() const; // Mutators @@ -627,7 +627,7 @@ inline const FVTerm::FTermArea* FVTerm::getVWin() const { return vwin; } //---------------------------------------------------------------------- -inline const FChar FVTerm::getAttribute() +inline FChar FVTerm::getAttribute() { return next_attribute; } //---------------------------------------------------------------------- diff --git a/src/include/final/fwidget.h b/src/include/final/fwidget.h index f4dbea63..dcaf9451 100644 --- a/src/include/final/fwidget.h +++ b/src/include/final/fwidget.h @@ -206,20 +206,20 @@ class FWidget : public FVTerm, public FObject // Positioning and sizes accessors... int getX() const; int getY() const; - const FPoint getPos() const; + FPoint getPos() const; int getTermX() const; int getTermY() const; - const FPoint getTermPos() const; + FPoint getTermPos() const; std::size_t getWidth() const; std::size_t getHeight() const; - const FSize getSize() const; + FSize getSize() const; int getTopPadding() const; int getLeftPadding() const; int getBottomPadding() const; int getRightPadding() const; std::size_t getClientWidth() const; std::size_t getClientHeight() const; - const FSize getClientSize() const; + FSize getClientSize() const; std::size_t getMaxWidth() const; std::size_t getMaxHeight() const; const FSize& getShadow() const; @@ -332,7 +332,7 @@ class FWidget : public FVTerm, public FObject virtual void hide(); virtual bool focusFirstChild(); // widget focusing virtual bool focusLastChild(); - const FPoint termToWidgetPos (const FPoint&) const; + FPoint termToWidgetPos (const FPoint&) const; void print (const FPoint&) override; virtual void move (const FPoint&); virtual void drawBorder(); @@ -583,7 +583,7 @@ inline FStatusBar* FWidget::getStatusBar() //---------------------------------------------------------------------- inline FWidget::FWidgetColorsPtr& FWidget::getColorTheme() { - static FWidgetColorsPtr* color_theme = new FWidgetColorsPtr(); + static auto color_theme = new FWidgetColorsPtr(); return *color_theme; } @@ -616,7 +616,7 @@ inline int FWidget::getY() const // y-position relative to the widget { return adjust_wsize.getY(); } //---------------------------------------------------------------------- -inline const FPoint FWidget::getPos() const // position relative to the widget +inline FPoint FWidget::getPos() const // position relative to the widget { const FPoint& pos = adjust_wsize.getPos(); // initialize pos return pos; @@ -631,7 +631,7 @@ inline int FWidget::getTermY() const // y-position on terminal { return woffset.getY1() + adjust_wsize.getY(); } //---------------------------------------------------------------------- -inline const FPoint FWidget::getTermPos() const // position on terminal +inline FPoint FWidget::getTermPos() const // position on terminal { return {getTermX(), getTermY()}; } //---------------------------------------------------------------------- @@ -643,7 +643,7 @@ inline std::size_t FWidget::getHeight() const { return adjust_wsize.getHeight(); } //---------------------------------------------------------------------- -inline const FSize FWidget::getSize() const +inline FSize FWidget::getSize() const { const FSize& size = adjust_wsize.getSize(); // initialize size return size; @@ -674,7 +674,7 @@ inline std::size_t FWidget::getClientHeight() const { return wclient_offset.getHeight(); } //---------------------------------------------------------------------- -inline const FSize FWidget::getClientSize() const +inline FSize FWidget::getClientSize() const { const FSize& size = wclient_offset.getSize(); // initialize size return size; @@ -1013,7 +1013,7 @@ inline void FWidget::delAccelerator() { delAccelerator(this); } //---------------------------------------------------------------------- -inline const FPoint FWidget::termToWidgetPos (const FPoint& tPos) const +inline FPoint FWidget::termToWidgetPos (const FPoint& tPos) const { return { tPos.getX() + 1 - woffset.getX1() - adjust_wsize.getX() , tPos.getY() + 1 - woffset.getY1() - adjust_wsize.getY() }; From 37f238eef7a2f9de1698c068974bc914e58a013e Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 4 Oct 2020 05:56:13 +0200 Subject: [PATCH 21/30] Add some includes --- src/fevent.cpp | 1 - src/fkeyboard.cpp | 1 + src/fterm_functions.cpp | 1 + src/include/final/fcombobox.h | 2 ++ src/include/final/fevent.h | 1 + src/include/final/flistbox.h | 3 ++- 6 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/fevent.cpp b/src/fevent.cpp index 7f213231..e3885c76 100644 --- a/src/fevent.cpp +++ b/src/fevent.cpp @@ -21,7 +21,6 @@ ***********************************************************************/ #include - #include "final/fevent.h" namespace finalcut diff --git a/src/fkeyboard.cpp b/src/fkeyboard.cpp index 27d48ab3..91b12a68 100644 --- a/src/fkeyboard.cpp +++ b/src/fkeyboard.cpp @@ -26,6 +26,7 @@ #include // need for FD_ZERO, FD_SET, FD_CLR, ... #endif +#include #include #include "final/fkeyboard.h" diff --git a/src/fterm_functions.cpp b/src/fterm_functions.cpp index e7afe543..7a6d71c9 100644 --- a/src/fterm_functions.cpp +++ b/src/fterm_functions.cpp @@ -25,6 +25,7 @@ #endif #include +#include #include #include #include diff --git a/src/include/final/fcombobox.h b/src/include/final/fcombobox.h index 5949deb8..ec23e70f 100644 --- a/src/include/final/fcombobox.h +++ b/src/include/final/fcombobox.h @@ -47,6 +47,8 @@ #error "Only can be included directly." #endif +#include + #include "final/fdata.h" #include "final/flineedit.h" #include "final/flistbox.h" diff --git a/src/include/final/fevent.h b/src/include/final/fevent.h index 74a27d04..d59610ac 100644 --- a/src/include/final/fevent.h +++ b/src/include/final/fevent.h @@ -81,6 +81,7 @@ #endif #include +#include #include "final/fc.h" #include "final/fdata.h" diff --git a/src/include/final/flistbox.h b/src/include/final/flistbox.h index e2a99540..4680048a 100644 --- a/src/include/final/flistbox.h +++ b/src/include/final/flistbox.h @@ -50,6 +50,7 @@ #include #include +#include #include #include "final/fdata.h" @@ -386,7 +387,7 @@ constexpr clean_fdata_t& getContainer(FDataAccess* container) return static_cast>&>(*container).get(); } -} // namespace FListBoxHelper +} // namespace flistboxhelper // FListBox inline functions //---------------------------------------------------------------------- From adccd6ae3b048fb976fcd81338e2fb72bcdada7d Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Mon, 5 Oct 2020 04:24:14 +0200 Subject: [PATCH 22/30] Now hides the input cursor when a widget gets hidden --- ChangeLog | 3 +++ examples/checklist.cpp | 2 +- examples/input-dialog.cpp | 2 +- examples/mandelbrot.cpp | 2 +- examples/rotozoomer.cpp | 6 +++--- examples/term-attributes.cpp | 2 +- examples/ui.cpp | 2 +- src/fvterm.cpp | 32 ++++++++++++++++---------------- src/fwidget.cpp | 7 ++++++- src/fwindow.cpp | 12 ++++++++++-- src/include/final/fsystemimpl.h | 2 +- src/include/final/fvterm.h | 9 +++++++++ 12 files changed, 53 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index de56b965..ac8bb9e5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2020-10-05 Markus Gans + * Now hides the input cursor when a widget gets hidden + 2020-10-04 Markus Gans * Replaces some C-style arrays with std::array * Now you can use the arrow keys to move a window into the visible area diff --git a/examples/checklist.cpp b/examples/checklist.cpp index 46c19675..a0f7f2c7 100644 --- a/examples/checklist.cpp +++ b/examples/checklist.cpp @@ -82,7 +82,7 @@ CheckList::CheckList (finalcut::FWidget* parent) FDialog::setText (L"Shopping list"); const std::size_t nf_offset = ( finalcut::FTerm::isNewFont() ) ? 1 : 0; FDialog::setSize (FSize{28 + nf_offset, 13} ); - setShadow(); + setShadow(); // Instead of the transparent window shadow listview.ignorePadding(); listview.setGeometry ( FPoint{1 + int(nf_offset), 2} , FSize{getWidth() - nf_offset, getHeight() - 1} ); diff --git a/examples/input-dialog.cpp b/examples/input-dialog.cpp index c0912dc2..c4bb2245 100644 --- a/examples/input-dialog.cpp +++ b/examples/input-dialog.cpp @@ -65,7 +65,7 @@ int main (int argc, char* argv[]) finalcut::FDialog dgl{&app}; dgl.setText ("Data input"); dgl.setGeometry (FPoint{4, 2}, FSize{37, 22}); - dgl.setShadow(); + dgl.setShadow(); // Instead of the transparent window shadow // Create input fields finalcut::FLineEdit name_field {&dgl}; diff --git a/examples/mandelbrot.cpp b/examples/mandelbrot.cpp index f8c52b96..e087776a 100644 --- a/examples/mandelbrot.cpp +++ b/examples/mandelbrot.cpp @@ -167,7 +167,7 @@ int main (int argc, char* argv[]) // Create a simple dialog box Mandelbrot mb{&app}; mb.setGeometry (FPoint{6, 1}, FSize{70, 23}); - mb.setShadow(); + mb.setShadow(); // Instead of the transparent window shadow // Set the mandelbrot object as main widget finalcut::FWidget::setMainWidget(&mb); diff --git a/examples/rotozoomer.cpp b/examples/rotozoomer.cpp index 448ff8af..fa00a994 100644 --- a/examples/rotozoomer.cpp +++ b/examples/rotozoomer.cpp @@ -139,8 +139,8 @@ void RotoZoomer::draw() //---------------------------------------------------------------------- void RotoZoomer::rotozoomer (double cx, double cy, double r, double a) { - const int Cols = int(getClientWidth()); - const int Lines = int(getClientHeight()); + const auto Cols = int(getClientWidth()); + const auto Lines = int(getClientHeight()); auto Ax = int(4096.0 * (cx + r * std::cos(a))); auto Ay = int(4096.0 * (cy + r * std::sin(a))); auto Bx = int(4096.0 * (cx + r * std::cos(a + 2.02358))); @@ -323,7 +323,7 @@ int main (int argc, char* argv[]) if ( benchmark ) roto.setGeometry (FPoint{1, 1}, FSize{80, 24}); - roto.setShadow(); + roto.setShadow(); // Instead of the transparent window shadow // Set the RotoZoomer object as main widget finalcut::FWidget::setMainWidget(&roto); diff --git a/examples/term-attributes.cpp b/examples/term-attributes.cpp index 37ac4cf5..f7da8ef3 100644 --- a/examples/term-attributes.cpp +++ b/examples/term-attributes.cpp @@ -499,7 +499,7 @@ int main (int argc, char* argv[]) // the parent object "app" (FObject destructor). AttribDlg dialog{&app}; dialog.setSize (FSize{69, 21}); - dialog.setShadow(); + dialog.setShadow(); // Instead of the transparent window shadow // Create the attribute demo widget as a child object from the dialog AttribDemo demo(&dialog); diff --git a/examples/ui.cpp b/examples/ui.cpp index 562113ab..e080d9a7 100644 --- a/examples/ui.cpp +++ b/examples/ui.cpp @@ -1067,7 +1067,7 @@ int main (int argc, char* argv[]) MyDialog d{&app}; d.setText (title); d.setSize (FSize{56, app.getHeight() - 4}); - d.setShadow(); + d.setShadow(); // Instead of the transparent window shadow // Set the dialog object d as the main widget of the application. // When you close the main widget, the application will be closed. diff --git a/src/fvterm.cpp b/src/fvterm.cpp index 4992c157..77d02a23 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -800,23 +800,23 @@ void FVTerm::removeArea (FTermArea*& area) { // remove the virtual window - if ( area != nullptr ) + if ( area == nullptr ) + return; + + if ( area->changes != nullptr ) { - if ( area->changes != nullptr ) - { - delete[] area->changes; - area->changes = nullptr; - } - - if ( area->data != nullptr ) - { - delete[] area->data; - area->data = nullptr; - } - - delete area; - area = nullptr; + delete[] area->changes; + area->changes = nullptr; } + + if ( area->data != nullptr ) + { + delete[] area->data; + area->data = nullptr; + } + + delete area; + area = nullptr; } //---------------------------------------------------------------------- @@ -876,7 +876,7 @@ bool FVTerm::updateVTermCursor (const FTermArea* area) const if ( ! area ) return false; - if ( area != active_area ) + if ( ! isActive(area) ) return false; if ( ! area->visible ) diff --git a/src/fwidget.cpp b/src/fwidget.cpp index 4d843aef..d44b85c7 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -638,7 +638,7 @@ bool FWidget::setCursorPos (const FPoint& pos) widget_cursor_position.setPoint(pos); - if ( ! flags.focus || isWindowWidget() ) + if ( ! flags.focus || flags.hidden || isWindowWidget() ) return false; if ( ! FWindow::getWindowWidget(this) ) @@ -999,6 +999,11 @@ void FWidget::hide() { flags.shown = false; + if ( flags.visible_cursor && FWidget::getFocusWidget() == this ) + { + getPrintArea()->input_cursor_visible = false; + } + if ( ! isDialogWidget() && FWidget::getFocusWidget() == this && ! focusPrevChild() ) diff --git a/src/fwindow.cpp b/src/fwindow.cpp index bb66c627..5d005844 100644 --- a/src/fwindow.cpp +++ b/src/fwindow.cpp @@ -278,8 +278,17 @@ void FWindow::show() //---------------------------------------------------------------------- void FWindow::hide() { + const auto& virtual_win = getVWin(); + + if ( isActive(virtual_win) + && virtual_win->visible + && virtual_win->input_cursor_visible ) + { + hideVTermCursor(); + } + if ( isVirtualWindow() ) - getVWin()->visible = false; + virtual_win->visible = false; FWidget::hide(); const auto& t_geometry = getTermGeometryWithShadow(); @@ -681,7 +690,6 @@ void FWindow::switchToPrevWindow (const FWidget* widget) const bool is_activated = activatePrevWindow(); auto active_win = static_cast(getActiveWindow()); - if ( ! is_activated && getWindowList() && getWindowList()->size() > 1 ) { diff --git a/src/include/final/fsystemimpl.h b/src/include/final/fsystemimpl.h index 25bbf3c4..17d56a4b 100644 --- a/src/include/final/fsystemimpl.h +++ b/src/include/final/fsystemimpl.h @@ -145,7 +145,7 @@ class FSystemImpl : public FSystem { va_list args{}; va_start (args, flags); - mode_t mode = static_cast(va_arg (args, int)); + auto mode = static_cast(va_arg (args, int)); int ret = ::open (pathname, flags, mode); va_end (args); return ret; diff --git a/src/include/final/fvterm.h b/src/include/final/fvterm.h index a61acf75..1107aa86 100644 --- a/src/include/final/fvterm.h +++ b/src/include/final/fvterm.h @@ -292,6 +292,7 @@ class FVTerm void setActiveArea (FTermArea*) const; // Inquiries + bool isActive (const FTermArea*) const; bool hasPrintArea() const; bool hasChildPrintArea() const; bool isVirtualWindow() const; @@ -307,6 +308,7 @@ class FVTerm static void removeArea (FTermArea*&); static void restoreVTerm (const FRect&); bool updateVTermCursor (const FTermArea*) const; + void hideVTermCursor() const; static void setAreaCursor ( const FPoint& , bool, FTermArea* ); static void getArea (const FPoint&, const FTermArea*); @@ -966,6 +968,10 @@ inline void FVTerm::setChildPrintArea (FTermArea* area) inline void FVTerm::setActiveArea (FTermArea* area) const { active_area = area; } +//---------------------------------------------------------------------- +inline bool FVTerm::isActive (const FTermArea* area) const +{ return bool( area == active_area ); } + //---------------------------------------------------------------------- inline bool FVTerm::hasPrintArea() const { return print_area; } @@ -982,6 +988,9 @@ inline bool FVTerm::isVirtualWindow() const inline bool FVTerm::isCursorHideable() const { return cursor_hideable; } +//---------------------------------------------------------------------- +inline void FVTerm::hideVTermCursor() const +{ vterm->input_cursor_visible = false; } } // namespace finalcut From e74dccf481f364002f8e2cbe60300474f0489a26 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Thu, 8 Oct 2020 05:55:32 +0200 Subject: [PATCH 23/30] Screen reports (like Secondary DA) are now read directly --- ChangeLog | 7 + examples/checklist.cpp | 10 +- examples/rotozoomer.cpp | 23 +- examples/ui.cpp | 20 +- src/fapplication.cpp | 5 +- src/fbusyindicator.cpp | 4 +- src/fdialog.cpp | 22 +- src/ffiledialog.cpp | 38 ++-- src/fkey_map.cpp | 49 +++-- src/fkeyboard.cpp | 52 ++--- src/flineedit.cpp | 4 +- src/flistbox.cpp | 10 +- src/flistview.cpp | 8 +- src/flogger.cpp | 6 +- src/fmenu.cpp | 14 +- src/fmouse.cpp | 4 +- src/fobject.cpp | 5 +- src/foptiattr.cpp | 19 +- src/foptimove.cpp | 40 ++-- src/fstatusbar.cpp | 4 +- src/fterm.cpp | 14 +- src/fterm_functions.cpp | 51 +++++ src/ftermcap.cpp | 5 + src/ftermdetection.cpp | 129 ++++++++--- src/ftermios.cpp | 2 +- src/ftermlinux.cpp | 6 +- src/ftermxterminal.cpp | 87 ++++++-- src/include/final/fbusyindicator.h | 2 +- src/include/final/fc.h | 17 +- src/include/final/fcolorpalette.h | 6 +- src/include/final/fdata.h | 3 +- src/include/final/fdialog.h | 16 +- src/include/final/ffiledialog.h | 4 +- src/include/final/fkey_map.h | 6 +- src/include/final/fkeyboard.h | 34 +-- src/include/final/flistbox.h | 295 +++++++++++++------------ src/include/final/flistview.h | 342 +++++++++++++++-------------- src/include/final/fmenu.h | 14 +- src/include/final/foptiattr.h | 101 +++++---- src/include/final/foptimove.h | 48 ++-- src/include/final/fscrollview.h | 4 +- src/include/final/fstatusbar.h | 8 +- src/include/final/fstring.h | 7 +- src/include/final/fterm.h | 5 +- src/include/final/ftermcap.h | 4 +- src/include/final/ftermdata.h | 8 +- src/include/final/ftermdetection.h | 1 + src/include/final/ftermlinux.h | 10 +- src/include/final/ftermxterminal.h | 4 + src/include/final/ftextview.h | 4 +- src/include/final/fwidget.h | 28 +-- src/include/final/sgr_optimizer.h | 6 +- src/sgr_optimizer.cpp | 4 +- test/fkeyboard-test.cpp | 150 +++++++++++-- test/foptiattr-test.cpp | 74 +++---- test/foptimove-test.cpp | 2 +- test/ftermlinux-test.cpp | 60 ++--- 57 files changed, 1126 insertions(+), 779 deletions(-) diff --git a/ChangeLog b/ChangeLog index ac8bb9e5..a65440a9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2020-10-08 Markus Gans + * Better keyboard support for urxvt terminals + * Screen reports (like Secondary DA) are now read directly + * Report Cursor Position (DECXCPR) support + * FListView and FListBox now have direct access to the list of client + elements via data() + 2020-10-05 Markus Gans * Now hides the input cursor when a widget gets hidden diff --git a/examples/checklist.cpp b/examples/checklist.cpp index a0f7f2c7..6d748651 100644 --- a/examples/checklist.cpp +++ b/examples/checklist.cpp @@ -177,18 +177,12 @@ void CheckList::onClose (finalcut::FCloseEvent* ev) //---------------------------------------------------------------------- void CheckList::cb_showList() { - auto iter = listview.beginOfList(); finalcut::FString shopping_list{}; - while ( iter != listview.endOfList() ) + for (auto item : listview.getData()) { - const auto item = static_cast(*iter); - if ( item->isChecked() ) - shopping_list << fc::Bullet << ' ' - << item->getText(1) << '\n'; - - ++iter; + shopping_list << fc::Bullet << ' ' << item->getText(1) << '\n'; } if ( shopping_list.isEmpty() ) diff --git a/examples/rotozoomer.cpp b/examples/rotozoomer.cpp index fa00a994..3284abac 100644 --- a/examples/rotozoomer.cpp +++ b/examples/rotozoomer.cpp @@ -20,10 +20,11 @@ * . * ***********************************************************************/ +#include + #include #include - -#include +#include #include @@ -74,7 +75,7 @@ class RotoZoomer final : public finalcut::FDialog bool benchmark{false}; int loops{0}; int path{0}; - wchar_t data[256]{}; + std::wstring data{std::wstring(256, L'\0')}; finalcut::FString report{}; time_point start{}; time_point end{}; @@ -89,29 +90,29 @@ RotoZoomer::RotoZoomer (finalcut::FWidget* parent, bool b, int l) { FDialog::setText ("Rotozoomer effect"); - int h{0}; + std::size_t h{0}; - for (int j{0}; j < 8; j++) + for (std::size_t j{0}; j < 8; j++) { - for (int i{0}; i < 8; i++) + for (std::size_t i{0}; i < 8; i++) { data[h++] = L' '; } - for (int i{0}; i < 8; i++) + for (std::size_t i{0}; i < 8; i++) { data[h++] = L'+'; } } - for (int j{0}; j < 8; j++) + for (std::size_t j{0}; j < 8; j++) { - for (int i{0}; i < 8; i++) + for (std::size_t i{0}; i < 8; i++) { data[h++] = L'x'; } - for (int i{0}; i < 8; i++) + for (std::size_t i{0}; i < 8; i++) { data[h++] = L' '; } @@ -160,7 +161,7 @@ void RotoZoomer::rotozoomer (double cx, double cy, double r, double a) for (int x = 0; x < Cols; x++) { - wchar_t ch = data[((Cy >> 14) & 0xf) + ((Cx >> 10) & 0xf0)]; + auto ch = data[((Cy >> 14) & 0xf) + ((Cx >> 10) & 0xf0)]; if ( ch == '+' ) print() << finalcut::FColorPair{fc::Black, fc::Red}; diff --git a/examples/ui.cpp b/examples/ui.cpp index e080d9a7..1b16c5f1 100644 --- a/examples/ui.cpp +++ b/examples/ui.cpp @@ -305,8 +305,7 @@ class MyDialog final : public finalcut::FDialog , const finalcut::FLineEdit& ) const; void cb_setTitlebar (const finalcut::FLineEdit&); void cb_showProgressBar(); - void cb_updateNumber ( const finalcut::FListBox& - , finalcut::FLabel& ) const; + void cb_updateNumber(); void cb_activateButton ( const finalcut::FRadioButton& , finalcut::FButton& ) const; void cb_view (const finalcut::FMenuItem*); @@ -774,8 +773,7 @@ void MyDialog::initWidgetsCallbacks() myList.addCallback ( "row-selected", - this, &MyDialog::cb_updateNumber, - std::ref(myList), std::ref(tagged_count) + this, &MyDialog::cb_updateNumber ); } @@ -977,19 +975,17 @@ void MyDialog::cb_showProgressBar() } //---------------------------------------------------------------------- -void MyDialog::cb_updateNumber ( const finalcut::FListBox& list - , finalcut::FLabel& num) const +void MyDialog::cb_updateNumber() { - const auto count = list.getCount(); int select_num = 0; - for (std::size_t n{1}; n <= count; n++) - if ( list.isSelected(n) ) + for (auto&& item : myList.getData() ) + if ( item.isSelected() ) select_num++; - num.clear(); - num << select_num; - num.redraw(); + tagged_count.clear(); + tagged_count << select_num; + tagged_count.redraw(); } //---------------------------------------------------------------------- diff --git a/src/fapplication.cpp b/src/fapplication.cpp index 7173906f..b4b77029 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -96,9 +96,10 @@ FApplication::FApplication (const int& _argc, char* _argv[]) if ( ! (_argc && _argv) ) { - static char empty_str[1] = ""; + typedef char* CString; + static CString empty[1]{CString("")}; app_argc = 0; - app_argv = reinterpret_cast(&empty_str); + app_argv = empty; } init(); diff --git a/src/fbusyindicator.cpp b/src/fbusyindicator.cpp index 3aa435ff..59bc3bdd 100644 --- a/src/fbusyindicator.cpp +++ b/src/fbusyindicator.cpp @@ -80,7 +80,7 @@ void FBusyIndicator::createIndicatorText() if ( FTerm::getEncoding() == fc::UTF8 ) { - const wchar_t (&p)[8] = uni_pattern; + const auto& p = uni_pattern; line[0] << " " << p[7] << " " << p[0] << " \n"; line[1] << " " << p[6] << " " << p[1] << " \n"; line[2] << " " << p[5] << " " << p[2] << " \n"; @@ -88,7 +88,7 @@ void FBusyIndicator::createIndicatorText() } else { - const char (&p)[8] = pattern; + const auto& p = pattern; line[0] << " " << p[7] << " " << p[0] << " \n"; line[1] << " " << p[6] << " " << p[1] << " \n"; line[2] << " " << p[5] << " " << p[2] << " \n"; diff --git a/src/fdialog.cpp b/src/fdialog.cpp index 0b91c3dc..d726452c 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -494,7 +494,7 @@ void FDialog::onMouseDown (FMouseEvent* ev) { const auto width = int(getWidth()); - const mouseStates ms = + const MouseStates ms = { ev->getX(), ev->getY(), @@ -553,7 +553,7 @@ void FDialog::onMouseDown (FMouseEvent* ev) //---------------------------------------------------------------------- void FDialog::onMouseUp (FMouseEvent* ev) { - const mouseStates ms = + const MouseStates ms = { ev->getX(), ev->getY(), @@ -602,7 +602,7 @@ void FDialog::onMouseUp (FMouseEvent* ev) //---------------------------------------------------------------------- void FDialog::onMouseMove (FMouseEvent* ev) { - const mouseStates ms = + const MouseStates ms = { ev->getX(), ev->getY(), @@ -632,7 +632,7 @@ void FDialog::onMouseMove (FMouseEvent* ev) //---------------------------------------------------------------------- void FDialog::onMouseDoubleClick (FMouseEvent* ev) { - const mouseStates ms = + const MouseStates ms = { ev->getX(), ev->getY(), @@ -1317,7 +1317,7 @@ inline void FDialog::deactivateZoomButton() } //---------------------------------------------------------------------- -inline void FDialog::activateZoomButton (const mouseStates& ms) +inline void FDialog::activateZoomButton (const MouseStates& ms) { if ( ms.mouse_x <= int(getWidth() - ms.zoom_btn) || ms.mouse_y != 1 ) @@ -1329,7 +1329,7 @@ inline void FDialog::activateZoomButton (const mouseStates& ms) } //---------------------------------------------------------------------- -inline void FDialog::leaveZoomButton (const mouseStates& ms) +inline void FDialog::leaveZoomButton (const MouseStates& ms) { bool zoom_button_pressed_before = zoom_button_pressed; @@ -1346,7 +1346,7 @@ inline void FDialog::leaveZoomButton (const mouseStates& ms) } //---------------------------------------------------------------------- -void FDialog::pressZoomButton (const mouseStates& ms) +void FDialog::pressZoomButton (const MouseStates& ms) { if ( ms.mouse_x <= int(getWidth() - ms.zoom_btn) || ms.mouse_y != 1 @@ -1370,7 +1370,7 @@ inline bool FDialog::isMouseOverMenu (const FPoint& termpos) const } //---------------------------------------------------------------------- -inline void FDialog::passEventToSubMenu ( const mouseStates& ms +inline void FDialog::passEventToSubMenu ( const MouseStates& ms , const FMouseEvent* ev ) { // Mouse event handover to the dialog menu @@ -1518,7 +1518,7 @@ bool FDialog::isBottomOutside() const } //---------------------------------------------------------------------- -bool FDialog::isLowerRightResizeCorner (const mouseStates& ms) const +bool FDialog::isLowerRightResizeCorner (const MouseStates& ms) const { // 3 characters in the lower right corner | // x @@ -1537,7 +1537,7 @@ bool FDialog::isLowerRightResizeCorner (const mouseStates& ms) const } //---------------------------------------------------------------------- -void FDialog::resizeMouseDown (const mouseStates& ms) +void FDialog::resizeMouseDown (const MouseStates& ms) { // Click on the lower right resize corner @@ -1562,7 +1562,7 @@ void FDialog::resizeMouseDown (const mouseStates& ms) } //---------------------------------------------------------------------- -void FDialog::resizeMouseUpMove (const mouseStates& ms, bool mouse_up) +void FDialog::resizeMouseUpMove (const MouseStates& ms, bool mouse_up) { // Resize the dialog if ( isResizeable() && ! resize_click_pos.isOrigin() ) diff --git a/src/ffiledialog.cpp b/src/ffiledialog.cpp index 70d9213b..d36e80d0 100644 --- a/src/ffiledialog.cpp +++ b/src/ffiledialog.cpp @@ -179,7 +179,7 @@ FString FFileDialog::getSelectedFile() const void FFileDialog::setPath (const FString& dir) { const char* const dirname = dir.c_str(); - char resolved_path[MAXPATHLEN]{}; + std::array resolved_path{}; FString r_dir{}; struct stat sb{}; @@ -201,8 +201,8 @@ void FFileDialog::setPath (const FString& dir) return; } - if ( fsystem && fsystem->realpath(dir.c_str(), resolved_path) != nullptr ) - r_dir.setString(resolved_path); + if ( fsystem && fsystem->realpath(dir.c_str(), resolved_path.data()) != nullptr ) + r_dir.setString(resolved_path.data()); else r_dir.setString(dir); @@ -418,20 +418,20 @@ void FFileDialog::initCallbacks() inline bool FFileDialog::patternMatch ( const char* const pattern , const char fname[] ) const { - char search[128]{}; + std::array search{}; if ( show_hidden && fname[0] == '.' && fname[1] != '\0' ) // hidden files { search[0] = '.'; search[1] = '\0'; - std::strncat(search, pattern, sizeof(search) - std::strlen(search) - 1); + std::strncat(search.data(), pattern, search.size() - std::strlen(search.data()) - 1); } else - std::strncpy(search, pattern, sizeof(search)); + std::strncpy(search.data(), pattern, search.size()); - search[sizeof(search) - 1] = '\0'; + search[search.size() - 1] = '\0'; - if ( fnmatch (search, fname, FNM_PERIOD) == 0 ) + if ( fnmatch (search.data(), fname, FNM_PERIOD) == 0 ) return true; else return false; @@ -595,24 +595,24 @@ void FFileDialog::followSymLink (const char* const dir, FDirEntry& entry) const if ( ! entry.symbolic_link ) return; // No symbolic link - char resolved_path[MAXPATHLEN]{}; - char symLink[MAXPATHLEN]{}; + std::array resolved_path{}; + std::array symLink{}; struct stat sb{}; if ( ! fsystem ) fsystem = FTerm::getFSystem(); - std::strncpy (symLink, dir, sizeof(symLink)); - symLink[sizeof(symLink) - 1] = '\0'; - std::strncat ( symLink + std::strncpy (symLink.data(), dir, symLink.size()); + symLink[symLink.size() - 1] = '\0'; + std::strncat ( symLink.data() , entry.name.c_str() - , sizeof(symLink) - std::strlen(symLink) - 1); - symLink[sizeof(symLink) - 1] = '\0'; + , symLink.size() - std::strlen(symLink.data()) - 1); + symLink[symLink.size() - 1] = '\0'; - if ( fsystem->realpath(symLink, resolved_path) == nullptr ) + if ( fsystem->realpath(symLink.data(), resolved_path.data()) == nullptr ) return; // Cannot follow the symlink - if ( lstat(resolved_path, &sb) == -1 ) + if ( lstat(resolved_path.data(), &sb) == -1 ) return; // Cannot get file status if ( S_ISDIR(sb.st_mode) ) @@ -740,14 +740,14 @@ FString FFileDialog::getHomeDir() { struct passwd pwd{}; struct passwd* pwd_ptr{}; - char buf[1024]{}; + std::array buf{}; if ( ! fsystem ) fsystem = FTerm::getFSystem(); const uid_t euid = fsystem->geteuid(); - if ( fsystem->getpwuid_r(euid, &pwd, buf, sizeof(buf), &pwd_ptr) ) + if ( fsystem->getpwuid_r(euid, &pwd, buf.data(), buf.size(), &pwd_ptr) ) return FString{""}; else return FString{pwd.pw_dir}; diff --git a/src/fkey_map.cpp b/src/fkey_map.cpp index 06d49bff..14e06150 100644 --- a/src/fkey_map.cpp +++ b/src/fkey_map.cpp @@ -24,7 +24,6 @@ #include "final/fc.h" #include "final/fkey_map.h" -#include "final/ftypes.h" namespace finalcut { @@ -32,14 +31,13 @@ namespace finalcut namespace fc { -std::array fkey +std::array fkey {{ { fc::Fkey_backspace , nullptr, "kb" }, // backspace key { fc::Fkey_catab , nullptr, "ka" }, // clear-all-tabs key { fc::Fkey_clear , nullptr, "kC" }, // clear-screen or erase key { fc::Fkey_ctab , nullptr, "kt" }, // clear-tab key { fc::Fkey_dc , nullptr, "kD" }, // delete-character key - { fc::Fkey_dc , nullptr, "kDx"}, // keypad delete { fc::Fkey_dl , nullptr, "kL" }, // delete-line key { fc::Fkey_down , nullptr, "kd" }, // down-arrow key { fc::Fkey_eic , nullptr, "kM" }, // sent by rmir or smir in insert mode @@ -186,36 +184,51 @@ std::array fkey { fc::Fkey_f63 , nullptr, "Fr" }, // F63 function key // Some terminals (e.g. PuTTY) send vt100 key codes // when the arrow and function keys are pressed - { fc::Fkey_down , CSI "B", "kdx"}, // down-arrow key (standard mode) - { fc::Fkey_down , ESC "OB", "kdX"}, // down-arrow key (application mode) - { fc::Fkey_f1 , ESC "OP", "k1X"}, // PF1 (application mode) - { fc::Fkey_f2 , ESC "OQ", "k2X"}, // PF2 (application mode) - { fc::Fkey_f3 , ESC "OR", "k3X"}, // PF3 (application mode) - { fc::Fkey_f4 , ESC "OS", "k4X"}, // PF4 (application mode) + { fc::Fkey_f1 , ESC "OP", "k1x"}, // PF1 (application mode) + { fc::Fkey_f2 , ESC "OQ", "k2x"}, // PF2 (application mode) + { fc::Fkey_f3 , ESC "OR", "k3x"}, // PF3 (application mode) + { fc::Fkey_f4 , ESC "OS", "k4x"}, // PF4 (application mode) { fc::Fkey_left , CSI "D", "klx"}, // left-arrow key (standard mode) { fc::Fkey_left , ESC "OD", "klX"}, // left-arrow key (application mode) { fc::Fkey_right , CSI "C", "krx"}, // right-arrow key (standard mode) { fc::Fkey_right , ESC "OC", "krX"}, // right-arrow key (application mode) { fc::Fkey_up , CSI "A", "kux"}, // up-arrow key (standard mode) { fc::Fkey_up , ESC "OA", "kuX"}, // up-arrow key (application mode) + { fc::Fkey_down , CSI "B", "kdx"}, // down-arrow key (standard mode) + { fc::Fkey_down , ESC "OB", "kdX"}, // down-arrow key (application mode) + { fc::Fkey_sf , CSI "a", "kFx"}, // scroll-forward key (shift-up) + { fc::Fkey_sr , CSI "b", "kRx"}, // scroll-backward key (shift-down) // Fallback for rxvt with TERM=xterm { fc::Fkey_home , CSI "7~", "khx"}, // home key { fc::Fkey_end , CSI "8~", "@7x"}, // end key - { fc::Fkey_f1 , CSI "11~", "k1x"}, // F1 function key - { fc::Fkey_f2 , CSI "12~", "k2x"}, // F2 function key - { fc::Fkey_f3 , CSI "13~", "k3x"}, // F3 function key - { fc::Fkey_f4 , CSI "14~", "k4x"}, // F4 function key + { fc::Fkey_f1 , CSI "11~", "k1X"}, // F1 function key + { fc::Fkey_f2 , CSI "12~", "k2X"}, // F2 function key + { fc::Fkey_f3 , CSI "13~", "k3X"}, // F3 function key + { fc::Fkey_f4 , CSI "14~", "k4X"}, // F4 function key // Fallback for TERM=ansi - { fc::Fkey_end , CSI "K", "@7X"}, // end key + { fc::Fkey_home , CSI "H", "khX"}, // home key + { fc::Fkey_end , CSI "F", "@7X"}, // end key + { fc::Fkey_end , CSI "K", "@7y"}, // end key (Microsoft HyperTerminal) // Keypad keys { fc::Fkey_enter , ESC "OM", "@8x"}, // enter key { fc::Fkey_slash , ESC "Oo", "KP1"}, // keypad slash { fc::Fkey_asterisk , ESC "Oj", "KP2"}, // keypad asterisk { fc::Fkey_minus_sign, ESC "Om", "KP3"}, // keypad minus sign - { fc::Fkey_plus_sign , ESC "Ok", "KP4"} // keypad plus sign + { fc::Fkey_plus_sign , ESC "Ok", "KP4"}, // keypad plus sign + { fc::Fkey_ic , ESC "Op", "kIx"}, // keypad insert + { fc::Fkey_dc , ESC "On", "kDx"}, // keypad delete + { fc::Fkey_left , ESC "Ot", "kly"}, // keypad left-arrow + { fc::Fkey_right , ESC "Ov", "kry"}, // keypad right-arrow + { fc::Fkey_up , ESC "Ox", "kuy"}, // keypad up-arrow + { fc::Fkey_down , ESC "Or", "kdy"}, // keypad down-arrow + { fc::Fkey_a1 , ESC "Ow", "K1x"}, // keypad upper left + { fc::Fkey_a3 , ESC "Oy", "K3x"}, // keypad upper right + { fc::Fkey_b2 , ESC "Ou", "K2x"}, // keypad center + { fc::Fkey_c1 , ESC "Oq", "K4x"}, // keypad lower left + { fc::Fkey_c3 , ESC "Os", "K5x"} // keypad lower right }}; -constexpr std::array fmetakey = +constexpr std::array fmetakey = {{ { fc::Fmkey_ic , "\033[2;3~" }, // M-insert { fc::Fmkey_ic , "\033\033[2~" }, // M-insert @@ -290,9 +303,13 @@ constexpr std::array fmetakey = { fc::Fckey_ppage , "\033[5;5~" }, // ctrl-prev-page { fc::Fckey_npage , "\033[6;5~" }, // ctrl-next-page { fc::Fckey_up , "\033[1;5A" }, // ctrl-up + { fc::Fckey_up , "\033Oa" }, // ctrl-up { fc::Fckey_down , "\033[1;5B" }, // ctrl-down + { fc::Fckey_down , "\033Ob" }, // ctrl-down { fc::Fckey_right , "\033[1;5C" }, // ctrl-right + { fc::Fckey_right , "\033Oc" }, // ctrl-right { fc::Fckey_left , "\033[1;5D" }, // ctrl-left + { fc::Fckey_left , "\033Od" }, // ctrl-left { fc::Fckey_sic , "\033[2;6~" }, // shift-ctrl-M-insert { fc::Fckey_sdc , "\033[3;6~" }, // shift-ctrl-M-delete { fc::Fckey_shome , "\033[1;6H" }, // shift-ctrl-M-home diff --git a/src/fkeyboard.cpp b/src/fkeyboard.cpp index 91b12a68..79ea18ff 100644 --- a/src/fkeyboard.cpp +++ b/src/fkeyboard.cpp @@ -108,6 +108,30 @@ FString FKeyboard::getKeyName (const FKey keynum) const return FString{""}; } +//---------------------------------------------------------------------- +bool FKeyboard::setNonBlockingInput (bool enable) +{ + if ( enable == non_blocking_stdin ) + return non_blocking_stdin; + + if ( enable ) // make stdin non-blocking + { + stdin_status_flags |= O_NONBLOCK; + + if ( fcntl (FTermios::getStdIn(), F_SETFL, stdin_status_flags) != -1 ) + non_blocking_stdin = true; + } + else + { + stdin_status_flags &= ~O_NONBLOCK; + + if ( fcntl (FTermios::getStdIn(), F_SETFL, stdin_status_flags) != -1 ) + non_blocking_stdin = false; + } + + return non_blocking_stdin; +} + //---------------------------------------------------------------------- void FKeyboard::init() { @@ -303,7 +327,7 @@ inline FKey FKeyboard::getSingleKey() // Look for a utf-8 character if ( utf8_input && (firstchar & 0xc0) == 0xc0 ) { - char utf8char[5]{}; // Init array with '\0' + std::array utf8char{}; // Init array with '\0' const std::size_t buf_len = std::strlen(fifo_buf); if ( (firstchar & 0xe0) == 0xc0 ) @@ -319,7 +343,7 @@ inline FKey FKeyboard::getSingleKey() for (std::size_t i{0}; i < len ; i++) utf8char[i] = char(fifo_buf[i] & 0xff); - keycode = UTF8decode(utf8char); + keycode = UTF8decode(utf8char.data()); } else keycode = uChar(fifo_buf[0] & 0xff); @@ -338,30 +362,6 @@ inline FKey FKeyboard::getSingleKey() return FKey(keycode == 127 ? fc::Fkey_backspace : keycode); } -//---------------------------------------------------------------------- -bool FKeyboard::setNonBlockingInput (bool enable) -{ - if ( enable == non_blocking_stdin ) - return non_blocking_stdin; - - if ( enable ) // make stdin non-blocking - { - stdin_status_flags |= O_NONBLOCK; - - if ( fcntl (FTermios::getStdIn(), F_SETFL, stdin_status_flags) != -1 ) - non_blocking_stdin = true; - } - else - { - stdin_status_flags &= ~O_NONBLOCK; - - if ( fcntl (FTermios::getStdIn(), F_SETFL, stdin_status_flags) != -1 ) - non_blocking_stdin = false; - } - - return non_blocking_stdin; -} - //---------------------------------------------------------------------- inline bool FKeyboard::isKeypressTimeout() { diff --git a/src/flineedit.cpp b/src/flineedit.cpp index 8ef8f38e..b130c935 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -1109,9 +1109,9 @@ inline wchar_t FLineEdit::characterFilter (const wchar_t c) const if ( input_filter.empty() ) return c; - const wchar_t character[2]{c, L'\0'}; + std::array character{{c, L'\0'}}; - if ( regex_match(character, std::wregex(input_filter)) ) + if ( regex_match(character.data(), std::wregex(input_filter)) ) return c; else return L'\0'; diff --git a/src/flistbox.cpp b/src/flistbox.cpp index cb43608d..e840233e 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -120,7 +120,7 @@ void FListBox::setCurrentItem (std::size_t index) } //---------------------------------------------------------------------- -void FListBox::setCurrentItem (listBoxItems::iterator iter) +void FListBox::setCurrentItem (FListBoxItems::iterator iter) { const auto index = std::size_t(std::distance(itemlist.begin(), iter)) + 1; setCurrentItem(index); @@ -641,7 +641,7 @@ void FListBox::adjustSize() // private methods of FListBox //---------------------------------------------------------------------- -inline FString FListBox::getString (listBoxItems::iterator iter) +inline FString FListBox::getString (FListBoxItems::iterator iter) { return iter->getText(); } @@ -860,7 +860,7 @@ void FListBox::drawList() //---------------------------------------------------------------------- inline void FListBox::drawListLine ( int y - , listBoxItems::iterator iter + , FListBoxItems::iterator iter , bool serach_mark ) { const std::size_t inc_len = inc_search.getLength(); @@ -915,7 +915,7 @@ inline void FListBox::printRightBracket (fc::brackets_type bracket_type) //---------------------------------------------------------------------- inline void FListBox::drawListBracketsLine ( int y - , listBoxItems::iterator iter + , FListBoxItems::iterator iter , bool serach_mark ) { std::size_t b{0}; @@ -1726,7 +1726,7 @@ void FListBox::changeOnResize() const } //---------------------------------------------------------------------- -void FListBox::lazyConvert(listBoxItems::iterator iter, std::size_t y) +void FListBox::lazyConvert(FListBoxItems::iterator iter, std::size_t y) { if ( conv_type != lazy_convert || ! iter->getText().isNull() ) return; diff --git a/src/flistview.cpp b/src/flistview.cpp index a8f37cd2..3b55d8fb 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -1662,7 +1662,7 @@ void FListView::drawHeadlines() || max_line_width < 1 ) return; - headerItems::const_iterator iter = header.begin(); + HeaderItems::const_iterator iter = header.begin(); headerline.clear(); if ( hasCheckableItems() ) @@ -1983,7 +1983,7 @@ inline void FListView::drawHeaderBorder (std::size_t length) //---------------------------------------------------------------------- -void FListView::drawHeadlineLabel (const headerItems::const_iterator& iter) +void FListView::drawHeadlineLabel (const HeaderItems::const_iterator& iter) { // Print label text static constexpr std::size_t leading_space = 1; @@ -1992,7 +1992,7 @@ void FListView::drawHeadlineLabel (const headerItems::const_iterator& iter) const auto width = std::size_t(iter->width); std::size_t column_width = getColumnWidth(txt); const std::size_t column_max = leading_space + width; - const headerItems::const_iterator first = header.begin(); + const HeaderItems::const_iterator first = header.begin(); const int column = int(std::distance(first, iter)) + 1; const bool has_sort_indicator( sort_column == column && ! hide_sort_indicator ); const auto& wc = getColorTheme(); @@ -2119,7 +2119,7 @@ void FListView::drawBufferedHeadline() } //---------------------------------------------------------------------- -void FListView::drawColumnEllipsis ( const headerItems::const_iterator& iter +void FListView::drawColumnEllipsis ( const HeaderItems::const_iterator& iter , const FString& text ) { // Print label ellipsis diff --git a/src/flogger.cpp b/src/flogger.cpp index 11992e73..4daaa0c8 100644 --- a/src/flogger.cpp +++ b/src/flogger.cpp @@ -60,14 +60,14 @@ void FLogger::newlineReplace ( std::string& str //---------------------------------------------------------------------- std::string FLogger::getTimeString() const { - char str[100]; + std::array str; const auto& now = std::chrono::system_clock::now(); const auto& t = std::chrono::system_clock::to_time_t(now); // Print RFC 2822 date struct tm time{}; localtime_r (&t, &time); - std::strftime (str, sizeof(str), "%a, %d %b %Y %T %z", &time); - return std::string(str); + std::strftime (str.data(), str.size(), "%a, %d %b %Y %T %z", &time); + return std::string(str.data()); } //---------------------------------------------------------------------- diff --git a/src/fmenu.cpp b/src/fmenu.cpp index 3464a8b7..0c8d5401 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -267,7 +267,7 @@ void FMenu::onMouseMove (FMouseEvent* ev) if ( ! mouse_down || getItemList().empty() ) return; - mouseStates ms = + MouseStates ms = { false, // focus_changed false, // hide_sub_menu @@ -819,7 +819,7 @@ bool FMenu::mouseUpOverList (const FPoint& mouse_pos) } //---------------------------------------------------------------------- -void FMenu::mouseMoveOverList (const FPoint& mouse_pos, mouseStates& ms) +void FMenu::mouseMoveOverList (const FPoint& mouse_pos, MouseStates& ms) { FPoint pos{mouse_pos}; pos -= FPoint{getRightPadding(), getTopPadding()}; @@ -840,7 +840,7 @@ void FMenu::mouseMoveOverList (const FPoint& mouse_pos, mouseStates& ms) } //---------------------------------------------------------------------- -void FMenu::mouseMoveSelection (FMenuItem* m_item, mouseStates& ms) +void FMenu::mouseMoveSelection (FMenuItem* m_item, MouseStates& ms) { if ( ! m_item->isEnabled() || m_item->isSelected() @@ -873,7 +873,7 @@ void FMenu::mouseMoveSelection (FMenuItem* m_item, mouseStates& ms) } //---------------------------------------------------------------------- -void FMenu::mouseMoveDeselection (FMenuItem* m_item, mouseStates& ms) +void FMenu::mouseMoveDeselection (FMenuItem* m_item, MouseStates& ms) { if ( ! ms.mouse_over_menu || ! m_item->isEnabled() @@ -902,7 +902,7 @@ void FMenu::mouseUpOverBorder() } //---------------------------------------------------------------------- -void FMenu::mouseMoveOverBorder (mouseStates& ms) const +void FMenu::mouseMoveOverBorder (MouseStates& ms) const { // Mouse is moved over border or separator line @@ -1271,7 +1271,7 @@ inline void FMenu::drawSeparator (int y) inline void FMenu::drawMenuLine (FMenuItem* m_item, int y) { FString txt{m_item->getText()}; - menuText txtdata{}; + MenuText txtdata{}; std::size_t column_width = getColumnWidth(txt); const FKey accel_key = m_item->accel_key; const bool is_enabled = m_item->isEnabled(); @@ -1361,7 +1361,7 @@ inline void FMenu::drawCheckMarkPrefix (const FMenuItem* m_item) } //---------------------------------------------------------------------- -inline void FMenu::drawMenuText (menuText& data) +inline void FMenu::drawMenuText (MenuText& data) { // Print menu text diff --git a/src/fmouse.cpp b/src/fmouse.cpp index 510fb482..843c668a 100644 --- a/src/fmouse.cpp +++ b/src/fmouse.cpp @@ -306,7 +306,9 @@ bool FMouseGPM::hasData() //---------------------------------------------------------------------- void FMouseGPM::setRawData (FKeyboard::keybuffer&) -{ } +{ + // This method need not be implemented for FMouseGPM +} //---------------------------------------------------------------------- void FMouseGPM::processEvent (struct timeval*) diff --git a/src/fobject.cpp b/src/fobject.cpp index 20f7e420..c29ab4e9 100644 --- a/src/fobject.cpp +++ b/src/fobject.cpp @@ -435,6 +435,9 @@ uInt FObject::processTimerEvent() //---------------------------------------------------------------------- void FObject::performTimerAction (FObject*, FEvent*) -{ } +{ + // This method must be reimplemented in a subclass + // to process the passed object and timer event +} } // namespace finalcut diff --git a/src/foptiattr.cpp b/src/foptiattr.cpp index 3de29ae4..ea103bd4 100644 --- a/src/foptiattr.cpp +++ b/src/foptiattr.cpp @@ -53,7 +53,7 @@ FOptiAttr::~FOptiAttr() // destructor // public methods of FOptiAttr //---------------------------------------------------------------------- -void FOptiAttr::setTermEnvironment (const termEnv& term_env) +void FOptiAttr::setTermEnvironment (const TermEnv& term_env) { // Set all required termcap values at once // and initialize the FOptiAttr environment @@ -551,7 +551,7 @@ const char* FOptiAttr::changeAttribute (FChar*& term, FChar*& next) attr_buf[0] = '\0'; if ( ! (term && next) ) - return attr_buf; + return attr_buf.data(); prevent_no_color_video_attributes (term, next_has_color); prevent_no_color_video_attributes (next); @@ -583,7 +583,7 @@ const char* FOptiAttr::changeAttribute (FChar*& term, FChar*& next) if ( FStartOptions::getFStartOptions().sgr_optimizer ) sgr_optimizer.optimize(); - return attr_buf; + return attr_buf.data(); } @@ -1086,8 +1086,8 @@ bool FOptiAttr::setTermDefaultColor (FChar*& term) return true; else if ( ansi_default_color ) { - char sgr_39_49[] = CSI "39;49m"; - append_sequence (sgr_39_49); + std::string sgr_39_49{CSI "39;49m"}; + append_sequence (sgr_39_49.c_str()); return true; } else @@ -1453,8 +1453,8 @@ inline void FOptiAttr::change_to_default_color ( FChar*& term } else if ( fg == fc::Default && term->fg_color != fc::Default ) { - char sgr_39[]{ CSI "39m" }; - append_sequence (sgr_39); + std::string sgr_39{CSI "39m"}; + append_sequence (sgr_39.c_str()); term->fg_color = fc::Default; } else if ( bg == fc::Default && term->bg_color != fc::Default ) @@ -1667,8 +1667,9 @@ inline bool FOptiAttr::append_sequence (const char seq[]) if ( ! seq ) return false; - std::strncat (attr_ptr, seq, sizeof(attr_buf) - std::strlen(attr_ptr)); - attr_buf[sizeof(attr_buf) - 1] = '\0'; + char* attr_ptr{attr_buf.data()}; + std::strncat (attr_ptr, seq, attr_buf.size() - std::strlen(attr_ptr)); + attr_buf[attr_buf.size() - 1] = '\0'; return true; } diff --git a/src/foptimove.cpp b/src/foptimove.cpp index 5d87b8fb..6ce2918e 100644 --- a/src/foptimove.cpp +++ b/src/foptimove.cpp @@ -82,7 +82,7 @@ void FOptiMove::setTermSize (std::size_t w, std::size_t h) } //---------------------------------------------------------------------- -void FOptiMove::setTermEnvironment (const termEnv& term_env) +void FOptiMove::setTermEnvironment (const TermEnv& term_env) { // Set all required termcap values at once @@ -606,7 +606,7 @@ int FOptiMove::capDurationToLength (int duration) const } //---------------------------------------------------------------------- -int FOptiMove::repeatedAppend ( const capability& o +int FOptiMove::repeatedAppend ( const Capability& o , volatile int count , char* dst ) const { @@ -800,7 +800,7 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime if ( F_cursor_right.cap ) { - char str[BUF_SIZE]{}; + std::array str{}; int htime_r{0}; str[0] = '\0'; @@ -816,7 +816,7 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime if ( tab_pos > to_x ) break; - htime_r += repeatedAppend (F_tab, 1, str); + htime_r += repeatedAppend (F_tab, 1, str.data()); if ( htime_r >= LONG_DURATION ) break; @@ -827,11 +827,11 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime num = to_x - pos; } - htime_r += repeatedAppend (F_cursor_right, num, str); + htime_r += repeatedAppend (F_cursor_right, num, str.data()); if ( htime_r < htime ) { - std::strncpy (hmove, str, BUF_SIZE); + std::strncpy (hmove, str.data(), BUF_SIZE); hmove[BUF_SIZE - 1] = '\0'; htime = htime_r; } @@ -855,7 +855,7 @@ inline void FOptiMove::leftMove ( char hmove[], int& htime if ( F_cursor_left.cap ) { - char str[BUF_SIZE]{}; + std::array str{}; int htime_l{0}; str[0] = '\0'; @@ -871,7 +871,7 @@ inline void FOptiMove::leftMove ( char hmove[], int& htime if ( tab_pos < to_x ) break; - htime_l += repeatedAppend (F_back_tab, 1, str); + htime_l += repeatedAppend (F_back_tab, 1, str.data()); if ( htime_l >= LONG_DURATION ) break; @@ -882,11 +882,11 @@ inline void FOptiMove::leftMove ( char hmove[], int& htime num = pos - to_x; } - htime_l += repeatedAppend (F_cursor_left, num, str); + htime_l += repeatedAppend (F_cursor_left, num, str.data()); if ( htime_l < htime ) { - std::strncpy (hmove, str, BUF_SIZE); + std::strncpy (hmove, str.data(), BUF_SIZE); hmove[BUF_SIZE - 1] = '\0'; htime = htime_l; } @@ -932,8 +932,8 @@ inline bool FOptiMove::isMethod1Faster ( int& move_time if ( xold >= 0 && yold >= 0 ) { - char null_result[BUF_SIZE]; - const int new_time = relativeMove (null_result, xold, yold, xnew, ynew); + std::array null_result{}; + const int new_time = relativeMove (null_result.data(), xold, yold, xnew, ynew); if ( new_time < LONG_DURATION && new_time < move_time ) { @@ -954,8 +954,8 @@ inline bool FOptiMove::isMethod2Faster ( int& move_time if ( yold >= 0 && F_carriage_return.cap ) { - char null_result[BUF_SIZE]; - const int new_time = relativeMove (null_result, 0, yold, xnew, ynew); + std::array null_result{}; + const int new_time = relativeMove (null_result.data(), 0, yold, xnew, ynew); if ( new_time < LONG_DURATION && F_carriage_return.duration + new_time < move_time ) @@ -976,8 +976,8 @@ inline bool FOptiMove::isMethod3Faster ( int& move_time if ( F_cursor_home.cap ) { - char null_result[BUF_SIZE]; - const int new_time = relativeMove (null_result, 0, 0, xnew, ynew); + std::array null_result{}; + const int new_time = relativeMove (null_result.data(), 0, 0, xnew, ynew); if ( new_time < LONG_DURATION && F_cursor_home.duration + new_time < move_time ) @@ -997,8 +997,8 @@ inline bool FOptiMove::isMethod4Faster ( int& move_time // Test method 4: home-down + local movement if ( F_cursor_to_ll.cap ) { - char null_result[BUF_SIZE]; - const int new_time = relativeMove ( null_result + std::array null_result{}; + const int new_time = relativeMove ( null_result.data() , 0, int(screen_height) - 1 , xnew, ynew ); @@ -1024,8 +1024,8 @@ inline bool FOptiMove::isMethod5Faster ( int& move_time && yold > 0 && F_cursor_left.cap ) { - char null_result[BUF_SIZE]; - const int new_time = relativeMove ( null_result + std::array null_result{}; + const int new_time = relativeMove ( null_result.data() , int(screen_width) - 1, yold - 1 , xnew, ynew ); diff --git a/src/fstatusbar.cpp b/src/fstatusbar.cpp index 8581fba5..ab53e32b 100644 --- a/src/fstatusbar.cpp +++ b/src/fstatusbar.cpp @@ -602,7 +602,7 @@ void FStatusBar::drawKeys() } //---------------------------------------------------------------------- -void FStatusBar::drawKey (keyList::const_iterator iter) +void FStatusBar::drawKey (FKeyList::const_iterator iter) { // Draw not active key @@ -660,7 +660,7 @@ void FStatusBar::drawKey (keyList::const_iterator iter) } //---------------------------------------------------------------------- -void FStatusBar::drawActiveKey (keyList::const_iterator iter) +void FStatusBar::drawActiveKey (FKeyList::const_iterator iter) { // Draw active key diff --git a/src/fterm.cpp b/src/fterm.cpp index a819f1a3..0eeaf7ca 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -767,7 +767,7 @@ bool FTerm::setNewFont() } //---------------------------------------------------------------------- -bool FTerm::setOldFont() +bool FTerm::resetFont() { bool retval{false}; @@ -1590,7 +1590,7 @@ void FTerm::init_optiMove() { // Duration precalculation of the cursor movement strings - FOptiMove::termEnv optimove_env = + FOptiMove::TermEnv optimove_env = { TCAP(fc::t_cursor_home), TCAP(fc::t_carriage_return), @@ -1625,7 +1625,7 @@ void FTerm::init_optiAttr() { // Setting video attribute optimization - FOptiAttr::termEnv optiattr_env = + FOptiAttr::TermEnv optiattr_env = { TCAP(fc::t_enter_bold_mode), TCAP(fc::t_exit_bold_mode), @@ -2469,12 +2469,10 @@ void FTerm::initBaudRate() const void FTerm::finish() const { // Set default signal handler - - const auto& title = data->getXtermTitle(); resetSignalHandler(); - if ( title && isXTerminal() && ! isRxvtTerminal() ) - setTermTitle (title); + if ( isXTerminal() && ! isRxvtTerminal() ) + getFTermXTerminal()->resetTitle(); // Restore the saved termios settings FTermios::restoreTTYsettings(); @@ -2529,7 +2527,7 @@ void FTerm::finish() const finish_encoding(); if ( data->isNewFont() || data->isVGAFont() ) - setOldFont(); + resetFont(); } //---------------------------------------------------------------------- diff --git a/src/fterm_functions.cpp b/src/fterm_functions.cpp index 7a6d71c9..3dabd87b 100644 --- a/src/fterm_functions.cpp +++ b/src/fterm_functions.cpp @@ -33,8 +33,10 @@ #include "final/fapplication.h" #include "final/fcharmap.h" #include "final/flog.h" +#include "final/fpoint.h" #include "final/fterm.h" #include "final/ftermbuffer.h" +#include "final/ftermios.h" namespace finalcut @@ -531,4 +533,53 @@ std::size_t getColumnWidth (const FTermBuffer& tb) ); } +//---------------------------------------------------------------------- +FPoint readCursorPos() +{ + int x{-1}; + int y{-1}; + const int stdin_no{FTermios::getStdIn()}; + const int stdout_no{FTermios::getStdOut()}; + fd_set ifds{}; + struct timeval tv{}; + constexpr auto& DECXCPR{ESC "[6n"}; + + // Report Cursor Position (DECXCPR) + const ssize_t ret = write(stdout_no, DECXCPR, std::strlen(DECXCPR)); + + if ( ret > 0 ) + { + std::fflush(stdout); + FD_ZERO(&ifds); + FD_SET(stdin_no, &ifds); + tv.tv_sec = 0; + tv.tv_usec = 100000; // 100 ms + + // Read the answer + if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) == 1 ) + { + constexpr auto parse = "\033[%4d;%4dR"; + std::array temp{}; + std::size_t pos{0}; + + do + { + std::size_t bytes_free = temp.size() - pos - 1; + const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free); + + if ( bytes <= 0 ) + break; + + pos += std::size_t(bytes); + } + while ( pos < temp.size() && std::strchr(temp.data(), 'R') == nullptr ); + + if ( pos > 4 ) + std::sscanf(temp.data(), parse, &x, &y); + } + } + + return FPoint{x, y}; +} + } // namespace finalcut diff --git a/src/ftermcap.cpp b/src/ftermcap.cpp index a819436a..372173ca 100644 --- a/src/ftermcap.cpp +++ b/src/ftermcap.cpp @@ -241,7 +241,12 @@ void FTermcap::termcapKeys() // Read termcap key sequences up to the self-defined values for (auto&& entry : fc::fkey) + { + if ( entry.string != nullptr ) + break; + entry.string = getString(entry.tname); + } } //---------------------------------------------------------------------- diff --git a/src/ftermdetection.cpp b/src/ftermdetection.cpp index b1738424..63fc2ac7 100644 --- a/src/ftermdetection.cpp +++ b/src/ftermdetection.cpp @@ -28,6 +28,7 @@ #include "final/fapplication.h" #include "final/fc.h" #include "final/flog.h" +#include "final/fkeyboard.h" #include "final/fsystem.h" #include "final/fterm.h" #include "final/ftermcap.h" @@ -53,6 +54,7 @@ FTermDetection::colorEnv FTermDetection::color_env{}; FTermDetection::secondaryDA FTermDetection::secondary_da{}; FTermData* FTermDetection::fterm_data{nullptr}; FSystem* FTermDetection::fsystem{nullptr}; +FKeyboard* FTermDetection::keyboard{nullptr}; char FTermDetection::termtype[256]{}; char FTermDetection::ttytypename[256]{}; bool FTermDetection::decscusr_support{}; @@ -130,6 +132,7 @@ void FTermDetection::detect() { fterm_data = FTerm::getFTermData(); fsystem = FTerm::getFSystem(); + keyboard = FTerm::getFKeyboard(); deallocation(); // Set the variable 'termtype' to the predefined type of the terminal @@ -320,6 +323,14 @@ void FTermDetection::termtypeAnalysis() if ( std::strncmp(termtype, "mlterm", 6) == 0 ) terminal_type.mlterm = true; + // rxvt + if ( std::strncmp(termtype, "rxvt", 4) == 0 ) + terminal_type.rxvt = true; + + // urxvt + if ( std::strncmp(termtype, "rxvt-unicode", 12) == 0 ) + terminal_type.urxvt = true; + // screen/tmux if ( std::strncmp(termtype, "screen", 6) == 0 ) { @@ -350,6 +361,7 @@ void FTermDetection::detectTerminal() if ( terminal_detection ) { FTermios::setCaptureSendCharacters(); + keyboard->setNonBlockingInput(); // Initialize 256 colors terminals new_termtype = init_256colorTerminal(); @@ -363,6 +375,7 @@ void FTermDetection::detectTerminal() // Determines the maximum number of colors new_termtype = determineMaxColor(new_termtype); + keyboard->unsetNonBlockingInput(); FTermios::unsetCaptureSendCharacters(); } @@ -517,6 +530,7 @@ const char* FTermDetection::determineMaxColor (const char current_termtype[]) // Determine xterm maximum number of colors via OSC 4 const char* new_termtype = current_termtype; + keyboard->setNonBlockingInput(); if ( ! color256 && ! isCygwinTerminal() @@ -544,6 +558,7 @@ const char* FTermDetection::determineMaxColor (const char current_termtype[]) } } + keyboard->unsetNonBlockingInput(); return new_termtype; } @@ -551,6 +566,7 @@ const char* FTermDetection::determineMaxColor (const char current_termtype[]) FString FTermDetection::getXTermColorName (FColor color) { FString color_str{""}; + std::array buf{}; fd_set ifds{}; struct timeval tv{}; const int stdin_no = FTermios::getStdIn(); @@ -558,28 +574,45 @@ FString FTermDetection::getXTermColorName (FColor color) // get color std::fprintf (stdout, OSC "4;%hu;?" BEL, color); std::fflush (stdout); - - char temp[512]{}; FD_ZERO(&ifds); FD_SET(stdin_no, &ifds); tv.tv_sec = 0; tv.tv_usec = 150000; // 150 ms // read the terminal answer - if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) > 0 - && std::scanf("\033]4;%10hu;%509[^\n]s", &color, temp) == 2 ) + if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) > 0 ) { - std::size_t n = std::strlen(temp); + constexpr auto parse = "\033]4;%10hu;%509[^\n]s"; + std::array temp{}; + std::size_t pos{0}; - // BEL + '\0' = string terminator - if ( n >= 6 && temp[n - 1] == BEL[0] && temp[n] == '\0' ) - temp[n - 1] = '\0'; + do + { + std::size_t bytes_free = temp.size() - pos - 1; + const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free); - // Esc + \ = OSC string terminator (mintty) - if ( n >= 6 && temp[n - 2] == ESC[0] && temp[n - 1] == '\\' ) - temp[n - 2] = '\0'; + if ( bytes <= 0 ) + break; - color_str = temp; + pos += std::size_t(bytes); + } + while ( pos < temp.size() ); + + if ( pos > 4 + && std::sscanf(temp.data(), parse, &color, buf.data()) == 2 ) + { + std::size_t n = std::strlen(buf.data()); + + // BEL + '\0' = string terminator + if ( n >= 6 && buf[n - 1] == BEL[0] && buf[n] == '\0' ) + buf[n - 1] = '\0'; + + // Esc + \ = OSC string terminator (mintty) + if ( n >= 6 && buf[n - 2] == ESC[0] && buf[n - 1] == '\\' ) + buf[n - 2] = '\0'; + + color_str = buf.data(); + } } return color_str; @@ -589,11 +622,14 @@ FString FTermDetection::getXTermColorName (FColor color) const char* FTermDetection::parseAnswerbackMsg (const char current_termtype[]) { const char* new_termtype = current_termtype; - + keyboard->setNonBlockingInput(); // send ENQ and read the answerback message + const auto& ans = getAnswerbackMsg(); + keyboard->unsetNonBlockingInput(); + try { - answer_back = new FString(getAnswerbackMsg()); + answer_back = new FString(ans); } catch (const std::bad_alloc&) { @@ -611,9 +647,10 @@ const char* FTermDetection::parseAnswerbackMsg (const char current_termtype[]) new_termtype = "putty"; } - // cygwin needs a backspace to delete the '♣' char - if ( isCygwinTerminal() || isWindowsTerminal() ) - FTerm::putstring (BS " " BS); + // Some terminal like cygwin or the windows terminal + // needs to delete the '♣' char + std::fprintf (stdout, "\r " BS); + std::fflush (stdout); #if DEBUG if ( new_termtype ) @@ -634,21 +671,36 @@ FString FTermDetection::getAnswerbackMsg() FString answerback{""}; fd_set ifds{}; struct timeval tv{}; - char temp[10]{}; const int stdin_no = FTermios::getStdIn(); - - std::putchar (ENQ[0]); // Send enquiry character + // Send enquiry character + std::putchar (ENQ[0]); std::fflush(stdout); - FD_ZERO(&ifds); FD_SET(stdin_no, &ifds); tv.tv_sec = 0; tv.tv_usec = 150000; // 150 ms // Read the answerback message - if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) > 0 - && std::fgets (temp, sizeof(temp) - 1, stdin) != nullptr ) - answerback = temp; + if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) > 0 ) + { + std::array temp{}; + std::size_t pos{0}; + + do + { + std::size_t bytes_free = temp.size() - pos - 1; + const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free); + + if ( bytes <= 0 ) + break; + + pos += std::size_t(bytes); + } + while ( pos < temp.size() ); + + if ( pos > 0 ) + answerback = temp.data(); + } return answerback; } @@ -660,10 +712,13 @@ const char* FTermDetection::parseSecDA (const char current_termtype[]) if ( isLinuxTerm() || isCygwinTerminal() ) return current_termtype; + // Secondary device attributes (SEC_DA) <- decTerminalID string + const auto& ans = getSecDA(); + try { // Secondary device attributes (SEC_DA) <- decTerminalID string - sec_da = new FString(getSecDA()); + sec_da = new FString(ans); } catch (const std::bad_alloc&) { @@ -757,6 +812,7 @@ FString FTermDetection::getSecDA() const int stdout_no{FTermios::getStdOut()}; fd_set ifds{}; struct timeval tv{}; + constexpr auto& SECDA{ESC "[>c"}; // Get the secondary device attributes const ssize_t ret = write(stdout_no, SECDA, std::strlen(SECDA)); @@ -771,9 +827,28 @@ FString FTermDetection::getSecDA() tv.tv_usec = 600000; // 600 ms // Read the answer - if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) == 1 - && std::scanf("\033[>%10d;%10d;%10dc", &a, &b, &c) == 3 ) + if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) == 1 ) + { + constexpr auto parse = "\033[>%10d;%10d;%10dc"; + std::array temp{}; + std::size_t pos{0}; + + do + { + std::size_t bytes_free = temp.size() - pos - 1; + const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free); + + if ( bytes <= 0 ) + break; + + pos += std::size_t(bytes); + } + while ( pos < temp.size() && std::strchr(temp.data(), 'c') == nullptr ); + + if ( pos > 3 + && std::sscanf(temp.data(), parse, &a, &b, &c) == 3 ) sec_da_str.sprintf("\033[>%d;%d;%dc", a, b, c); + } return sec_da_str; } diff --git a/src/ftermios.cpp b/src/ftermios.cpp index c3c17765..6abb3249 100644 --- a/src/ftermios.cpp +++ b/src/ftermios.cpp @@ -153,7 +153,7 @@ void FTermios::setCaptureSendCharacters() struct termios t{}; tcgetattr (stdin_no, &t); t.c_lflag &= uInt(~(ICANON | ECHO)); - t.c_cc[VTIME] = 1; // Timeout in deciseconds + t.c_cc[VTIME] = 10; // Timeout in deciseconds t.c_cc[VMIN] = 0; // Minimum number of characters tcsetattr (stdin_no, TCSANOW, &t); } diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index 8be13144..45d47f49 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -460,7 +460,7 @@ FKey FTermLinux::modifierKeyCorrection (const FKey& key_id) if ( ! fsystem ) fsystem = FTerm::getFSystem(); - const modifier_key& m = getModifierKey(); + const ModifierKey& m = getModifierKey(); if ( ! (m.shift || m.ctrl || m.alt) ) { @@ -631,7 +631,7 @@ bool FTermLinux::getUnicodeMap() } //---------------------------------------------------------------------- -FTermLinux::modifier_key& FTermLinux::getModifierKey() +FTermLinux::ModifierKey& FTermLinux::getModifierKey() { // Get Linux console shift state @@ -932,7 +932,7 @@ void FTermLinux::getVGAPalette() //---------------------------------------------------------------------- void FTermLinux::setVGADefaultPalette() { - constexpr std::array defaultColor = + constexpr std::array defaultColor = {{ {0x00, 0x00, 0x00}, {0xaa, 0x00, 0x00}, {0x00, 0xaa, 0x00}, {0xaa, 0x55, 0x00}, diff --git a/src/ftermxterminal.cpp b/src/ftermxterminal.cpp index d314045e..fdf0e6ba 100644 --- a/src/ftermxterminal.cpp +++ b/src/ftermxterminal.cpp @@ -27,6 +27,7 @@ #include "final/fapplication.h" #include "final/fc.h" #include "final/flog.h" +#include "final/fkeyboard.h" #include "final/fstring.h" #include "final/fterm.h" #include "final/ftermcap.h" @@ -49,8 +50,9 @@ namespace finalcut { // static class attributes -bool FTermXTerminal::mouse_support{false}; -FSystem* FTermXTerminal::fsystem{nullptr}; +bool FTermXTerminal::mouse_support{false}; +FSystem* FTermXTerminal::fsystem{nullptr}; +FKeyboard* FTermXTerminal::keyboard{nullptr}; //---------------------------------------------------------------------- @@ -63,6 +65,7 @@ FTermXTerminal::FTermXTerminal() { // Get FSystem object fsystem = FTerm::getFSystem(); + keyboard = FTerm::getFKeyboard(); } //---------------------------------------------------------------------- @@ -290,6 +293,13 @@ void FTermXTerminal::resetDefaults() } } +//---------------------------------------------------------------------- +void FTermXTerminal::resetTitle() +{ + if ( title_was_changed ) + setTitle(xterm_title); +} + //---------------------------------------------------------------------- void FTermXTerminal::captureFontAndTitle() { @@ -300,8 +310,10 @@ void FTermXTerminal::captureFontAndTitle() && ! term_detection->isRxvtTerminal() ) { FTermios::setCaptureSendCharacters(); + keyboard->setNonBlockingInput(); xterm_font = captureXTermFont(); xterm_title = captureXTermTitle(); + keyboard->unsetNonBlockingInput(); FTermios::unsetCaptureSendCharacters(); } } @@ -356,15 +368,21 @@ void FTermXTerminal::setXTermTitle() if ( term_detection->isXTerminal() || term_detection->isScreenTerm() + || term_detection->isUrxvtTerminal() || term_detection->isCygwinTerminal() || term_detection->isMinttyTerm() || term_detection->isPuttyTerminal() || FTermcap::osc_support ) { oscPrefix(); + + if ( xterm_title.isNull() ) + xterm_title = ""; + FTerm::putstringf (OSC "0;%s" BEL, xterm_title.c_str()); oscPostfix(); std::fflush(stdout); + title_was_changed = true; } } @@ -755,11 +773,11 @@ FString FTermXTerminal::captureXTermFont() const struct timeval tv{}; const int stdin_no = FTermios::getStdIn(); + // Querying the terminal font oscPrefix(); - FTerm::putstring (OSC "50;?" BEL); // get font + FTerm::putstring (OSC "50;?" BEL); oscPostfix(); std::fflush(stdout); - FD_ZERO(&ifds); FD_SET(stdin_no, &ifds); tv.tv_sec = 0; @@ -768,17 +786,33 @@ FString FTermXTerminal::captureXTermFont() const // Read the terminal answer if ( select(stdin_no + 1, &ifds, nullptr, nullptr, &tv) > 0 ) { - char temp[150]{}; + std::array temp{}; + std::size_t pos{0}; - if ( std::scanf("\033]50;%148[^\n]s", temp) == 1 ) + do { - const std::size_t n = std::strlen(temp); + std::size_t bytes_free = temp.size() - pos - 1; + const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free); + + if ( bytes <= 0 ) + break; + + pos += std::size_t(bytes); + } + while ( pos < temp.size() && std::strchr(temp.data(), '\a') == nullptr ); + + if ( pos > 5 && temp[0] == ESC[0] && temp[1] == ']' + && temp[2] == '5' && temp[3] == '0' && temp[4] == ';' ) + { + // Skip leading Esc ] 5 0 ; + char* str = &temp[5]; + const std::size_t n = std::strlen(str); // BEL + '\0' = string terminator - if ( n >= 5 && temp[n - 1] == BEL[0] && temp[n] == '\0' ) - temp[n - 1] = '\0'; + if ( n >= 5 && str[n - 1] == BEL[0] && str[n] == '\0' ) + str[n - 1] = '\0'; - return FString{temp}; + return FString{str}; } } } @@ -796,11 +830,11 @@ FString FTermXTerminal::captureXTermTitle() const fd_set ifds{}; struct timeval tv{}; - const int stdin_no = FTermios::getStdIn(); + const int stdin_no{FTermios::getStdIn()}; - FTerm::putstring (CSI "21t"); // get title + // Report window title + FTerm::putstring (CSI "21t"); std::fflush(stdout); - FD_ZERO(&ifds); FD_SET(stdin_no, &ifds); tv.tv_sec = 0; @@ -809,20 +843,35 @@ FString FTermXTerminal::captureXTermTitle() const // read the terminal answer if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) > 0 ) { - char temp[512]{}; + std::array temp{}; + std::size_t pos{0}; - if ( std::scanf("\033]l%509[^\n]s", temp) == 1 ) + do { - const std::size_t n = std::strlen(temp); + std::size_t bytes_free = temp.size() - pos - 1; + const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free); + + if ( bytes <= 0 ) + break; + + pos += std::size_t(bytes); + } + while ( pos < temp.size() && std::strstr(temp.data(), ESC "\\") == nullptr ); + + if ( pos > 6 && temp[0] == ESC[0] && temp[1] == ']' && temp[2] == 'l' ) + { + // Skip leading Esc + ] + l = OSC l + char* str = &temp[3]; + const std::size_t n = std::strlen(str); // Esc + \ = OSC string terminator - if ( n >= 2 && temp[n - 2] == ESC[0] && temp[n - 1] == '\\' ) + if ( n >= 2 && str[n - 2] == ESC[0] && str[n - 1] == '\\' ) { if ( n < 4 ) return FString{}; - temp[n - 2] = '\0'; - return FString{temp}; + str[n - 2] = '\0'; + return FString{str}; } } } diff --git a/src/include/final/fbusyindicator.h b/src/include/final/fbusyindicator.h index 82b7540e..00babea3 100644 --- a/src/include/final/fbusyindicator.h +++ b/src/include/final/fbusyindicator.h @@ -76,7 +76,7 @@ class FBusyIndicator : public FToolTip FBusyIndicator (const FBusyIndicator&) = delete; // Destructor - ~FBusyIndicator(); + ~FBusyIndicator() override; // Disable copy assignment operator (=) FBusyIndicator& operator = (const FBusyIndicator&) = delete; diff --git a/src/include/final/fc.h b/src/include/final/fc.h index aa1585c4..735b89a0 100644 --- a/src/include/final/fc.h +++ b/src/include/final/fc.h @@ -33,15 +33,14 @@ #define C_STR const_cast // ASCII sequences -#define ESC "\033" // Escape -#define CSI ESC "[" // Control sequence introducer (7-bit) -#define ENQ "\005" // Enquiry -#define BEL "\007" // Bell (ctrl‐g) -#define BS "\010" // Backspace -#define SO "\016" // Shift out (alternative character set) -#define SI "\017" // Shift in (regular character set) -#define OSC ESC "]" // Operating system command (7-bit) -#define SECDA ESC "[>c" // Secondary Device Attributes +#define ESC "\033" // Escape +#define CSI ESC "[" // Control sequence introducer (7-bit) +#define ENQ "\005" // Enquiry +#define BEL "\007" // Bell (ctrl‐g) +#define BS "\010" // Backspace +#define SO "\016" // Shift out (alternative character set) +#define SI "\017" // Shift in (regular character set) +#define OSC ESC "]" // Operating system command (7-bit) namespace finalcut { diff --git a/src/include/final/fcolorpalette.h b/src/include/final/fcolorpalette.h index d5e781cb..ed22b4f1 100644 --- a/src/include/final/fcolorpalette.h +++ b/src/include/final/fcolorpalette.h @@ -104,7 +104,7 @@ class default8ColorPalette final : public FColorPalette explicit default8ColorPalette (const FSetPalette&); // Destructor - ~default8ColorPalette(); + ~default8ColorPalette() override; // Accessor FString getClassName() const override; @@ -144,7 +144,7 @@ class default16ColorPalette final : public FColorPalette explicit default16ColorPalette (const FSetPalette&); // Destructor - ~default16ColorPalette(); + ~default16ColorPalette() override; // Accessor FString getClassName() const override; @@ -183,7 +183,7 @@ class default16DarkColorPalette final : public FColorPalette explicit default16DarkColorPalette (const FSetPalette&); // Destructor - ~default16DarkColorPalette(); + ~default16DarkColorPalette() override; // Accessor FString getClassName() const override; diff --git a/src/include/final/fdata.h b/src/include/final/fdata.h index 70e5bcab..c691e6b5 100644 --- a/src/include/final/fdata.h +++ b/src/include/final/fdata.h @@ -244,7 +244,8 @@ class FData : public FDataAccess // Inquiries bool isInitializedCopy() const { - return bool( (void*)&value == (void*)&value_ref.get() ); + return bool( reinterpret_cast(&value) + == reinterpret_cast(&value_ref.get()) ); } bool isInitializedReference() const diff --git a/src/include/final/fdialog.h b/src/include/final/fdialog.h index 82ca069a..16ac4f30 100644 --- a/src/include/final/fdialog.h +++ b/src/include/final/fdialog.h @@ -163,7 +163,7 @@ class FDialog : public FWindow FPoint termPos; std::size_t zoom_btn; bool mouse_over_menu; - } mouseStates; + } MouseStates; // Constant static constexpr std::size_t MENU_BTN = 3; @@ -189,12 +189,12 @@ class FDialog : public FWindow void selectFirstMenuItem(); void setZoomItem(); std::size_t getZoomButtonWidth() const; - void activateZoomButton (const mouseStates&); + void activateZoomButton (const MouseStates&); void deactivateZoomButton(); - void leaveZoomButton (const mouseStates&); - void pressZoomButton (const mouseStates&); + void leaveZoomButton (const MouseStates&); + void pressZoomButton (const MouseStates&); bool isMouseOverMenu (const FPoint&) const; - void passEventToSubMenu ( const mouseStates& + void passEventToSubMenu ( const MouseStates& , const FMouseEvent* ); void moveSizeKey (FKeyEvent*); void raiseActivateDialog(); @@ -202,9 +202,9 @@ class FDialog : public FWindow bool isOutsideTerminal (const FPoint&) const; bool isLeftOutside() const; bool isBottomOutside() const; - bool isLowerRightResizeCorner (const mouseStates&) const; - void resizeMouseDown (const mouseStates&); - void resizeMouseUpMove (const mouseStates&, bool = false); + bool isLowerRightResizeCorner (const MouseStates&) const; + void resizeMouseDown (const MouseStates&); + void resizeMouseUpMove (const MouseStates&, bool = false); void cancelMouseResize(); void acceptMoveSize(); void cancelMoveSize(); diff --git a/src/include/final/ffiledialog.h b/src/include/final/ffiledialog.h index b18f1ba0..04e366e6 100644 --- a/src/include/final/ffiledialog.h +++ b/src/include/final/ffiledialog.h @@ -186,7 +186,7 @@ class FFileDialog : public FDialog uChar : 1; // padding bits }; - typedef std::vector dirEntries; + typedef std::vector DirEntries; // Methods void init(); @@ -216,7 +216,7 @@ class FFileDialog : public FDialog // Data members static FSystem* fsystem; DIR* directory_stream{nullptr}; - dirEntries dir_entries{}; + DirEntries dir_entries{}; FString directory{}; FString filter_pattern{}; FLineEdit filename{this}; diff --git a/src/include/final/fkey_map.h b/src/include/final/fkey_map.h index b3465059..f2c74aae 100644 --- a/src/include/final/fkey_map.h +++ b/src/include/final/fkey_map.h @@ -27,14 +27,16 @@ #error "Only can be included directly." #endif +#include "final/ftypes.h" + namespace finalcut { namespace fc { -extern std::array fkey; -extern const std::array fmetakey; +extern std::array fkey; +extern const std::array fmetakey; extern const std::array fkeyname; } // namespace fc diff --git a/src/include/final/fkeyboard.h b/src/include/final/fkeyboard.h index 70f6a483..77bd0969 100644 --- a/src/include/final/fkeyboard.h +++ b/src/include/final/fkeyboard.h @@ -41,6 +41,7 @@ #include #include +#include "final/fkey_map.h" #include "final/fstring.h" #include "final/ftypes.h" @@ -116,6 +117,9 @@ class FKeyboard final void setTermcapMap (const T&); static void setKeypressTimeout (const uInt64); static void setReadBlockingTime (const uInt64); + bool setNonBlockingInput (bool); + bool setNonBlockingInput(); + bool unsetNonBlockingInput(); void enableUTF8(); void disableUTF8(); void enableMouseSequences(); @@ -138,7 +142,7 @@ class FKeyboard final private: // Using-declaration - using FKeyMapPtr = std::shared_ptr>; + using FKeyMapPtr = std::shared_ptr; // Constants static constexpr FKey NOT_SET = static_cast(-1); @@ -149,11 +153,6 @@ class FKeyboard final FKey getMetaKey(); FKey getSingleKey(); - // Mutators - bool setNonBlockingInput (bool); - bool setNonBlockingInput(); - bool unsetNonBlockingInput(); - // Inquiry static bool isKeypressTimeout(); static bool isIntervalTimeout(); @@ -235,6 +234,18 @@ inline void FKeyboard::setKeypressTimeout (const uInt64 timeout) inline void FKeyboard::setReadBlockingTime (const uInt64 blocking_time) { read_blocking_time = blocking_time; } +//---------------------------------------------------------------------- +inline bool FKeyboard::setNonBlockingInput() +{ return setNonBlockingInput(true); } + +//---------------------------------------------------------------------- +inline bool FKeyboard::unsetNonBlockingInput() +{ return setNonBlockingInput(false); } + +//---------------------------------------------------------------------- +inline bool FKeyboard::isInputDataPending() const +{ return input_data_pending; } + //---------------------------------------------------------------------- inline void FKeyboard::enableUTF8() { utf8_input = true; } @@ -263,17 +274,6 @@ inline void FKeyboard::setReleaseCommand (const FKeyboardCommand& cmd) inline void FKeyboard::setEscPressedCommand (const FKeyboardCommand& cmd) { escape_key_cmd = cmd; } -//---------------------------------------------------------------------- -inline bool FKeyboard::isInputDataPending() const -{ return input_data_pending; } -//---------------------------------------------------------------------- -inline bool FKeyboard::setNonBlockingInput() -{ return setNonBlockingInput(true); } - -//---------------------------------------------------------------------- -inline bool FKeyboard::unsetNonBlockingInput() -{ return setNonBlockingInput(false); } - } // namespace finalcut #endif // FKEYBOARD_H diff --git a/src/include/final/flistbox.h b/src/include/final/flistbox.h index 4680048a..d763a5eb 100644 --- a/src/include/final/flistbox.h +++ b/src/include/final/flistbox.h @@ -95,6 +95,9 @@ class FListBoxItem template void setData (DT&&); + // Inquiries + bool isSelected() const; + // Methods void clear(); @@ -148,6 +151,10 @@ inline void FListBoxItem::setData (DT&& data) data_pointer.reset(data_obj); } +//---------------------------------------------------------------------- +inline bool FListBoxItem::isSelected() const +{ return selected; } + //---------------------------------------------------------------------- inline void FListBoxItem::clear() { text.clear(); } @@ -164,7 +171,7 @@ class FListBox : public FWidget using FWidget::setGeometry; // Typedef - typedef std::vector listBoxItems; + typedef std::vector FListBoxItems; // Constructor explicit FListBox (FWidget* = nullptr); @@ -185,92 +192,94 @@ class FListBox : public FWidget FListBox& operator = (const FListBox&) = delete; // Accessors - FString getClassName() const override; - std::size_t getCount() const; - FListBoxItem& getItem (std::size_t); - const FListBoxItem& getItem (std::size_t) const; - FListBoxItem& getItem (listBoxItems::iterator); - const FListBoxItem& getItem (listBoxItems::const_iterator) const; - std::size_t currentItem() const; - FString& getText(); + FString getClassName() const override; + std::size_t getCount() const; + FListBoxItem& getItem (std::size_t); + const FListBoxItem& getItem (std::size_t) const; + FListBoxItem& getItem (FListBoxItems::iterator); + const FListBoxItem& getItem (FListBoxItems::const_iterator) const; + std::size_t currentItem() const; + FListBoxItems& getData(); + const FListBoxItems& getData() const; + FString& getText(); // Mutators - void setCurrentItem (std::size_t); - void setCurrentItem (listBoxItems::iterator); - void selectItem (std::size_t); - void selectItem (listBoxItems::iterator) const; - void unselectItem (std::size_t); - void unselectItem (listBoxItems::iterator) const; - void showInsideBrackets (const std::size_t, fc::brackets_type); - void showNoBrackets (std::size_t); - void showNoBrackets (listBoxItems::iterator) const; - void setSize (const FSize&, bool = true) override; - void setGeometry ( const FPoint&, const FSize& - , bool = true ) override; - void setMultiSelection (bool); - void setMultiSelection (); - void unsetMultiSelection (); - bool setDisable() override; - void setText (const FString&); + void setCurrentItem (std::size_t); + void setCurrentItem (FListBoxItems::iterator); + void selectItem (std::size_t); + void selectItem (FListBoxItems::iterator) const; + void unselectItem (std::size_t); + void unselectItem (FListBoxItems::iterator) const; + void showInsideBrackets (const std::size_t, fc::brackets_type); + void showNoBrackets (std::size_t); + void showNoBrackets (FListBoxItems::iterator) const; + void setSize (const FSize&, bool = true) override; + void setGeometry ( const FPoint&, const FSize& + , bool = true ) override; + void setMultiSelection (bool); + void setMultiSelection (); + void unsetMultiSelection (); + bool setDisable() override; + void setText (const FString&); // Inquiries - bool isSelected (std::size_t) const; - bool isSelected (listBoxItems::iterator) const; - bool isMultiSelection() const; - bool hasBrackets (std::size_t) const; - bool hasBrackets (listBoxItems::iterator) const; + bool isSelected (std::size_t) const; + bool isSelected (FListBoxItems::iterator) const; + bool isMultiSelection() const; + bool hasBrackets (std::size_t) const; + bool hasBrackets (FListBoxItems::iterator) const; // Methods - void hide() override; + void hide() override; template - void insert ( Iterator, Iterator - , const InsertConverter& ); + void insert ( Iterator, Iterator + , const InsertConverter& ); template - void insert ( const Container& - , const LazyConverter& ); + void insert ( const Container& + , const LazyConverter& ); template - void insert (Container*, const LazyConverter&); - void insert (const FListBoxItem&); + void insert (Container*, const LazyConverter&); + void insert (const FListBoxItem&); template - void insert ( const std::initializer_list& list - , fc::brackets_type = fc::NoBrackets - , bool = false - , DT&& = DT() ); + void insert ( const std::initializer_list& list + , fc::brackets_type = fc::NoBrackets + , bool = false + , DT&& = DT() ); template - void insert ( const ItemT& - , fc::brackets_type = fc::NoBrackets - , bool = false - , DT&& = DT() ); - void remove (std::size_t); - void reserve (std::size_t); - void clear(); + void insert ( const ItemT& + , fc::brackets_type = fc::NoBrackets + , bool = false + , DT&& = DT() ); + void remove (std::size_t); + void reserve (std::size_t); + void clear(); // Event handlers - void onKeyPress (FKeyEvent*) override; - void onMouseDown (FMouseEvent*) override; - void onMouseUp (FMouseEvent*) override; - void onMouseMove (FMouseEvent*) override; - void onMouseDoubleClick (FMouseEvent*) override; - void onWheel (FWheelEvent*) override; - void onTimer (FTimerEvent*) override; - void onFocusIn (FFocusEvent*) override; - void onFocusOut (FFocusEvent*) override; + void onKeyPress (FKeyEvent*) override; + void onMouseDown (FMouseEvent*) override; + void onMouseUp (FMouseEvent*) override; + void onMouseMove (FMouseEvent*) override; + void onMouseDoubleClick (FMouseEvent*) override; + void onWheel (FWheelEvent*) override; + void onTimer (FTimerEvent*) override; + void onFocusIn (FFocusEvent*) override; + void onFocusOut (FFocusEvent*) override; protected: // Methods - void adjustYOffset (std::size_t); - void adjustSize() override; + void adjustYOffset (std::size_t); + void adjustSize() override; private: // Typedefs - typedef std::unordered_map> keyMap; - typedef std::unordered_map> keyMapResult; - typedef std::function lazyInsert; + typedef std::unordered_map> KeyMap; + typedef std::unordered_map> KeyMapResult; + typedef std::function LazyInsert; // Enumeration enum convert_type @@ -281,83 +290,83 @@ class FListBox : public FWidget }; // Accessors - static FString getString (listBoxItems::iterator); + static FString getString (FListBoxItems::iterator); // Inquiry - bool isHorizontallyScrollable() const; - bool isVerticallyScrollable() const; + bool isHorizontallyScrollable() const; + bool isVerticallyScrollable() const; // Methods - void init(); - void mapKeyFunctions(); - void processKeyAction (FKeyEvent*); - void draw() override; - void drawBorder() override; - void drawScrollbars() const; - void drawHeadline(); - void drawList(); - void drawListLine (int, listBoxItems::iterator, bool); - void printLeftBracket (fc::brackets_type); - void printRightBracket (fc::brackets_type); - void drawListBracketsLine (int, listBoxItems::iterator, bool); - void setLineAttributes (int, bool, bool, bool&); - void unsetAttributes() const; - void updateDrawing (bool, bool); - void recalculateHorizontalBar (std::size_t, bool); - void recalculateVerticalBar (std::size_t) const; - void getWidgetFocus(); - void multiSelection (std::size_t); - void multiSelectionUpTo (std::size_t); - void wheelUp (int); - void wheelDown (int); - bool dragScrollUp(); - bool dragScrollDown(); - void dragUp (int); - void dragDown (int); - void stopDragScroll(); - void prevListItem (int); - void nextListItem (int); - void scrollToX (int); - void scrollToY (int); - void scrollLeft (int); - void scrollRight (int); - void scrollLeft(); - void scrollRight(); - void onePosUp(); - void onePosDown(); - void onePageUp(); - void onePageDown(); - void firstPos(); - void lastPos(); - bool skipIncrementalSearch(); - void acceptSelection(); - bool spacebarProcessing(); - bool changeSelectionAndPosition(); - bool deletePreviousCharacter(); - bool keyIncSearchInput (FKey); - void processClick() const; - void processSelect() const; - void processChanged() const; - void changeOnResize() const; - void lazyConvert (listBoxItems::iterator, std::size_t); - listBoxItems::iterator index2iterator (std::size_t); - listBoxItems::const_iterator index2iterator (std::size_t index) const; + void init(); + void mapKeyFunctions(); + void processKeyAction (FKeyEvent*); + void draw() override; + void drawBorder() override; + void drawScrollbars() const; + void drawHeadline(); + void drawList(); + void drawListLine (int, FListBoxItems::iterator, bool); + void printLeftBracket (fc::brackets_type); + void printRightBracket (fc::brackets_type); + void drawListBracketsLine (int, FListBoxItems::iterator, bool); + void setLineAttributes (int, bool, bool, bool&); + void unsetAttributes() const; + void updateDrawing (bool, bool); + void recalculateHorizontalBar (std::size_t, bool); + void recalculateVerticalBar (std::size_t) const; + void getWidgetFocus(); + void multiSelection (std::size_t); + void multiSelectionUpTo (std::size_t); + void wheelUp (int); + void wheelDown (int); + bool dragScrollUp(); + bool dragScrollDown(); + void dragUp (int); + void dragDown (int); + void stopDragScroll(); + void prevListItem (int); + void nextListItem (int); + void scrollToX (int); + void scrollToY (int); + void scrollLeft (int); + void scrollRight (int); + void scrollLeft(); + void scrollRight(); + void onePosUp(); + void onePosDown(); + void onePageUp(); + void onePageDown(); + void firstPos(); + void lastPos(); + bool skipIncrementalSearch(); + void acceptSelection(); + bool spacebarProcessing(); + bool changeSelectionAndPosition(); + bool deletePreviousCharacter(); + bool keyIncSearchInput (FKey); + void processClick() const; + void processSelect() const; + void processChanged() const; + void changeOnResize() const; + void lazyConvert (FListBoxItems::iterator, std::size_t); + FListBoxItems::iterator index2iterator (std::size_t); + FListBoxItems::const_iterator index2iterator (std::size_t index) const; // Callback methods - void cb_vbarChange (const FWidget*); - void cb_hbarChange (const FWidget*); + void cb_vbarChange (const FWidget*); + void cb_hbarChange (const FWidget*); // Function Pointer - lazyInsert lazy_inserter{}; + LazyInsert lazy_inserter{}; // Data members - listBoxItems itemlist{}; + FListBoxItems itemlist{}; FDataAccess* source_container{nullptr}; FScrollbarPtr vbar{nullptr}; FScrollbarPtr hbar{nullptr}; FString text{}; FString inc_search{}; - keyMap key_map{}; - keyMapResult key_map_result{}; + KeyMap key_map{}; + KeyMapResult key_map_result{}; convert_type conv_type{FListBox::no_convert}; fc::dragScroll drag_scroll{fc::noScroll}; int scroll_repeat{100}; @@ -431,29 +440,37 @@ inline std::size_t FListBox::getCount() const //---------------------------------------------------------------------- inline FListBoxItem& FListBox::getItem (std::size_t index) { - listBoxItems::iterator iter = index2iterator(index - 1); + FListBoxItems::iterator iter = index2iterator(index - 1); return *iter; } //---------------------------------------------------------------------- inline const FListBoxItem& FListBox::getItem (std::size_t index) const { - listBoxItems::const_iterator iter = index2iterator(index - 1); + FListBoxItems::const_iterator iter = index2iterator(index - 1); return *iter; } //---------------------------------------------------------------------- -inline FListBoxItem& FListBox::getItem (listBoxItems::iterator iter) +inline FListBoxItem& FListBox::getItem (FListBoxItems::iterator iter) { return *iter; } //---------------------------------------------------------------------- -inline const FListBoxItem& FListBox::getItem (listBoxItems::const_iterator iter) const +inline const FListBoxItem& FListBox::getItem (FListBoxItems::const_iterator iter) const { return *iter; } //---------------------------------------------------------------------- inline std::size_t FListBox::currentItem() const { return current; } +//---------------------------------------------------------------------- +inline FListBox::FListBoxItems& FListBox::getData() +{ return itemlist; } + +//---------------------------------------------------------------------- +inline const FListBox::FListBoxItems& FListBox::getData() const +{ return itemlist; } + //---------------------------------------------------------------------- inline FString& FListBox::getText() { return text; } @@ -463,7 +480,7 @@ inline void FListBox::selectItem (std::size_t index) { index2iterator(index - 1)->selected = true; } //---------------------------------------------------------------------- -inline void FListBox::selectItem (listBoxItems::iterator iter) const +inline void FListBox::selectItem (FListBoxItems::iterator iter) const { iter->selected = true; } //---------------------------------------------------------------------- @@ -471,7 +488,7 @@ inline void FListBox::unselectItem (std::size_t index) { index2iterator(index - 1)->selected = false; } //---------------------------------------------------------------------- -inline void FListBox::unselectItem (listBoxItems::iterator iter) const +inline void FListBox::unselectItem (FListBoxItems::iterator iter) const { iter->selected = false; } //---------------------------------------------------------------------- @@ -479,7 +496,7 @@ inline void FListBox::showNoBrackets (std::size_t index) { index2iterator(index - 1)->brackets = fc::NoBrackets; } //---------------------------------------------------------------------- -inline void FListBox::showNoBrackets (listBoxItems::iterator iter) const +inline void FListBox::showNoBrackets (FListBoxItems::iterator iter) const { iter->brackets = fc::NoBrackets; } //---------------------------------------------------------------------- @@ -503,7 +520,7 @@ inline bool FListBox::isSelected (std::size_t index) const { return index2iterator(index - 1)->selected; } //---------------------------------------------------------------------- -inline bool FListBox::isSelected (listBoxItems::iterator iter) const +inline bool FListBox::isSelected (FListBoxItems::iterator iter) const { return iter->selected; } //---------------------------------------------------------------------- @@ -515,7 +532,7 @@ inline bool FListBox::hasBrackets(std::size_t index) const { return bool(index2iterator(index - 1)->brackets > 0); } //---------------------------------------------------------------------- -inline bool FListBox::hasBrackets(listBoxItems::iterator iter) const +inline bool FListBox::hasBrackets(FListBoxItems::iterator iter) const { return bool(iter->brackets > 0); } //---------------------------------------------------------------------- @@ -602,19 +619,19 @@ inline bool FListBox::isVerticallyScrollable() const { return bool( getCount() > getClientHeight() ); } //---------------------------------------------------------------------- -inline FListBox::listBoxItems::iterator \ +inline FListBox::FListBoxItems::iterator \ FListBox::index2iterator (std::size_t index) { - listBoxItems::iterator iter = itemlist.begin(); + FListBoxItems::iterator iter = itemlist.begin(); std::advance (iter, index); return iter; } //---------------------------------------------------------------------- -inline FListBox::listBoxItems::const_iterator \ +inline FListBox::FListBoxItems::const_iterator \ FListBox::index2iterator (std::size_t index) const { - listBoxItems::const_iterator iter = itemlist.begin(); + FListBoxItems::const_iterator iter = itemlist.begin(); std::advance (iter, index); return iter; } diff --git a/src/include/final/flistview.h b/src/include/final/flistview.h index 0c44ab21..388b83c8 100644 --- a/src/include/final/flistview.h +++ b/src/include/final/flistview.h @@ -92,7 +92,7 @@ class FListViewItem : public FObject int getSortColumn() const; FString getText (int) const; template - clean_fdata_t
& getData() const; + clean_fdata_t
& getData() const; uInt getDepth() const; // Mutators @@ -296,6 +296,9 @@ class FListView : public FWidget // Using-declaration using FWidget::setGeometry; + // Typedef + typedef std::list FListViewItems; + // Constructor explicit FListView (FWidget* = nullptr); @@ -309,218 +312,219 @@ class FListView : public FWidget FListView& operator = (const FListView&) = delete; // Accessors - FString getClassName() const override; - std::size_t getCount() const; - fc::text_alignment getColumnAlignment (int) const; - FString getColumnText (int) const; - fc::sorting_type getColumnSortType (int) const; - fc::sorting_order getSortOrder() const; - int getSortColumn() const; - FListViewItem* getCurrentItem(); + FString getClassName() const override; + std::size_t getCount() const; + fc::text_alignment getColumnAlignment (int) const; + FString getColumnText (int) const; + fc::sorting_type getColumnSortType (int) const; + fc::sorting_order getSortOrder() const; + int getSortColumn() const; + FListViewItem* getCurrentItem(); // Mutators - void setSize (const FSize&, bool = true) override; - void setGeometry ( const FPoint&, const FSize& - , bool = true ) override; - void setColumnAlignment (int, fc::text_alignment); - void setColumnText (int, const FString&); - void setColumnSortType (int, fc::sorting_type \ - = fc::by_name); - void setColumnSort (int, fc::sorting_order \ - = fc::ascending); + void setSize (const FSize&, bool = true) override; + void setGeometry ( const FPoint&, const FSize& + , bool = true ) override; + void setColumnAlignment (int, fc::text_alignment); + void setColumnText (int, const FString&); + void setColumnSortType (int, fc::sorting_type \ + = fc::by_name); + void setColumnSort (int, fc::sorting_order \ + = fc::ascending); template - void setUserAscendingCompare (Compare); + void setUserAscendingCompare (Compare); template - void setUserDescendingCompare (Compare); - void hideSortIndicator (bool); - bool setTreeView (bool); - bool setTreeView(); - bool unsetTreeView(); + void setUserDescendingCompare (Compare); + void hideSortIndicator (bool); + bool setTreeView (bool); + bool setTreeView(); + bool unsetTreeView(); // Methods - virtual int addColumn (const FString&, int = USE_MAX_SIZE); - void hide() override; - iterator insert (FListViewItem*); - iterator insert (FListViewItem*, iterator); + virtual int addColumn (const FString&, int = USE_MAX_SIZE); + void hide() override; + iterator insert (FListViewItem*); + iterator insert (FListViewItem*, iterator); template - iterator insert ( const FStringList& - , DT&& = DT() ); - iterator insert ( const FStringList& - , iterator ); + iterator insert ( const FStringList& + , DT&& = DT() ); + iterator insert ( const FStringList& + , iterator ); template - iterator insert ( const FStringList& - , DT&& - , iterator ); + iterator insert ( const FStringList& + , DT&& + , iterator ); template - iterator insert ( const std::initializer_list& - , DT&& = DT() ); + iterator insert ( const std::initializer_list& + , DT&& = DT() ); template - iterator insert ( const std::initializer_list& - , iterator ); + iterator insert ( const std::initializer_list& + , iterator ); template - iterator insert ( const std::initializer_list& - , DT&& - , iterator ); + iterator insert ( const std::initializer_list& + , DT&& + , iterator ); template - iterator insert ( const std::vector& - , DT&& = DT() ); + iterator insert ( const std::vector& + , DT&& = DT() ); template - iterator insert ( const std::vector& - , iterator ); + iterator insert ( const std::vector& + , iterator ); template - iterator insert ( const std::vector& - , DT&& - , iterator ); - void remove (FListViewItem*); - void clear(); - iterator beginOfList(); - iterator endOfList(); - virtual void sort(); + iterator insert ( const std::vector& + , DT&& + , iterator ); + void remove (FListViewItem*); + void clear(); + FListViewItems& getData(); + const FListViewItems& getData() const; + + virtual void sort(); // Event handlers - void onKeyPress (FKeyEvent*) override; - void onMouseDown (FMouseEvent*) override; - void onMouseUp (FMouseEvent*) override; - void onMouseMove (FMouseEvent*) override; - void onMouseDoubleClick (FMouseEvent*) override; - void onWheel (FWheelEvent*) override; - void onTimer (FTimerEvent*) override; - void onFocusIn (FFocusEvent*) override; - void onFocusOut (FFocusEvent*) override; + void onKeyPress (FKeyEvent*) override; + void onMouseDown (FMouseEvent*) override; + void onMouseUp (FMouseEvent*) override; + void onMouseMove (FMouseEvent*) override; + void onMouseDoubleClick (FMouseEvent*) override; + void onWheel (FWheelEvent*) override; + void onTimer (FTimerEvent*) override; + void onFocusIn (FFocusEvent*) override; + void onFocusOut (FFocusEvent*) override; protected: // Methods - void adjustViewport (const int); - void adjustScrollbars (const std::size_t) const; - void adjustSize() override; + void adjustViewport (const int); + void adjustScrollbars (const std::size_t) const; + void adjustSize() override; private: // Typedefs - typedef std::unordered_map> keyMap; - typedef std::unordered_map> keyMapResult; + typedef std::unordered_map> KeyMap; + typedef std::unordered_map> KeyMapResult; // Constants static constexpr std::size_t checkbox_space = 4; // Typedef struct Header; // forward declaration - typedef std::vector
headerItems; - typedef std::vector sortTypes; + typedef std::vector
HeaderItems; + typedef std::vector SortTypes; // Constants static constexpr int USE_MAX_SIZE = -1; // Accessors - static iterator& getNullIterator(); + static iterator& getNullIterator(); // Mutators - static void setNullIterator (const iterator&); + static void setNullIterator (const iterator&); // Inquiry - bool isHorizontallyScrollable() const; - bool isVerticallyScrollable() const; + bool isHorizontallyScrollable() const; + bool isVerticallyScrollable() const; // Methods - void init(); - void mapKeyFunctions(); - void processKeyAction (FKeyEvent*); + void init(); + void mapKeyFunctions(); + void processKeyAction (FKeyEvent*); template - void sort (Compare); - std::size_t getAlignOffset ( const fc::text_alignment - , const std::size_t - , const std::size_t ) const; - iterator getListEnd (const FListViewItem*); - void draw() override; - void drawBorder() override; - void drawScrollbars() const; - void drawHeadlines(); - void drawList(); - void drawListLine (const FListViewItem*, bool, bool); - void clearList(); - void setLineAttributes (bool, bool) const; - FString getCheckBox (const FListViewItem* item) const; - FString getLinePrefix (const FListViewItem*, std::size_t) const; - void drawSortIndicator (std::size_t&, std::size_t); - void drawHeadlineLabel (const headerItems::const_iterator&); - void drawHeaderBorder (std::size_t); - void drawBufferedHeadline(); - void drawColumnEllipsis ( const headerItems::const_iterator& - , const FString& ); - void updateDrawing (bool, bool); - std::size_t determineLineWidth (FListViewItem*); - void beforeInsertion (FListViewItem*); - void afterInsertion(); - void recalculateHorizontalBar (std::size_t); - void recalculateVerticalBar (std::size_t) const; - void mouseHeaderClicked(); - void wheelUp (int); - void wheelDown (int); - bool dragScrollUp (int); - bool dragScrollDown (int); - void dragUp (int); - void dragDown (int); - void stopDragScroll(); - iterator appendItem (FListViewItem*); - void processClick() const; - void processChanged() const; - void changeOnResize() const; - void toggleCheckbox(); - void collapseAndScrollLeft(); - void expandAndScrollRight(); - void firstPos(); - void lastPos(); - bool expandSubtree(); - bool collapseSubtree(); - void setRelativePosition (int); - void stepForward(); - void stepBackward(); - void stepForward (int); - void stepBackward (int); - void scrollToX (int); - void scrollToY (int); - void scrollTo (const FPoint &); - void scrollTo (int, int); - void scrollBy (int, int); - bool hasCheckableItems() const; + void sort (Compare); + std::size_t getAlignOffset ( const fc::text_alignment + , const std::size_t + , const std::size_t ) const; + iterator getListEnd (const FListViewItem*); + void draw() override; + void drawBorder() override; + void drawScrollbars() const; + void drawHeadlines(); + void drawList(); + void drawListLine (const FListViewItem*, bool, bool); + void clearList(); + void setLineAttributes (bool, bool) const; + FString getCheckBox (const FListViewItem* item) const; + FString getLinePrefix (const FListViewItem*, std::size_t) const; + void drawSortIndicator (std::size_t&, std::size_t); + void drawHeadlineLabel (const HeaderItems::const_iterator&); + void drawHeaderBorder (std::size_t); + void drawBufferedHeadline(); + void drawColumnEllipsis ( const HeaderItems::const_iterator& + , const FString& ); + void updateDrawing (bool, bool); + std::size_t determineLineWidth (FListViewItem*); + void beforeInsertion (FListViewItem*); + void afterInsertion(); + void recalculateHorizontalBar (std::size_t); + void recalculateVerticalBar (std::size_t) const; + void mouseHeaderClicked(); + void wheelUp (int); + void wheelDown (int); + bool dragScrollUp (int); + bool dragScrollDown (int); + void dragUp (int); + void dragDown (int); + void stopDragScroll(); + iterator appendItem (FListViewItem*); + void processClick() const; + void processChanged() const; + void changeOnResize() const; + void toggleCheckbox(); + void collapseAndScrollLeft(); + void expandAndScrollRight(); + void firstPos(); + void lastPos(); + bool expandSubtree(); + bool collapseSubtree(); + void setRelativePosition (int); + void stepForward(); + void stepBackward(); + void stepForward (int); + void stepBackward (int); + void scrollToX (int); + void scrollToY (int); + void scrollTo (const FPoint &); + void scrollTo (int, int); + void scrollBy (int, int); + bool hasCheckableItems() const; // Callback methods - void cb_vbarChange (const FWidget*); - void cb_hbarChange (const FWidget*); + void cb_vbarChange (const FWidget*); + void cb_hbarChange (const FWidget*); // Data members - iterator root{}; - FObjectList selflist{}; - FObjectList itemlist{}; - FListViewIterator current_iter{}; - FListViewIterator first_visible_line{}; - FListViewIterator last_visible_line{}; - headerItems header{}; - FTermBuffer headerline{}; - FScrollbarPtr vbar{nullptr}; - FScrollbarPtr hbar{nullptr}; - sortTypes sort_type{}; - FPoint clicked_expander_pos{-1, -1}; - FPoint clicked_header_pos{-1, -1}; - keyMap key_map{}; - keyMapResult key_map_result{}; - const FListViewItem* clicked_checkbox_item{nullptr}; - std::size_t nf_offset{0}; - std::size_t max_line_width{1}; - fc::dragScroll drag_scroll{fc::noScroll}; - int first_line_position_before{-1}; - int scroll_repeat{100}; - int scroll_distance{1}; - int xoffset{0}; - int sort_column{-1}; - fc::sorting_order sort_order{fc::unsorted}; - bool scroll_timer{false}; - bool tree_view{false}; - bool hide_sort_indicator{false}; - bool has_checkable_items{false}; + iterator root{}; + FObjectList selflist{}; + FObjectList itemlist{}; + FListViewIterator current_iter{}; + FListViewIterator first_visible_line{}; + FListViewIterator last_visible_line{}; + HeaderItems header{}; + FTermBuffer headerline{}; + FScrollbarPtr vbar{nullptr}; + FScrollbarPtr hbar{nullptr}; + SortTypes sort_type{}; + FPoint clicked_expander_pos{-1, -1}; + FPoint clicked_header_pos{-1, -1}; + KeyMap key_map{}; + KeyMapResult key_map_result{}; + const FListViewItem* clicked_checkbox_item{nullptr}; + std::size_t nf_offset{0}; + std::size_t max_line_width{1}; + fc::dragScroll drag_scroll{fc::noScroll}; + int first_line_position_before{-1}; + int scroll_repeat{100}; + int scroll_distance{1}; + int xoffset{0}; + int sort_column{-1}; + fc::sorting_order sort_order{fc::unsorted}; + bool scroll_timer{false}; + bool tree_view{false}; + bool hide_sort_indicator{false}; + bool has_checkable_items{false}; // Function Pointer bool (*user_defined_ascending) (const FObject*, const FObject*){nullptr}; @@ -712,12 +716,12 @@ FObject::iterator } //---------------------------------------------------------------------- -inline FObject::iterator FListView::beginOfList() -{ return itemlist.begin(); } +inline FListView::FListViewItems& FListView::getData() +{ return reinterpret_cast(itemlist); } //---------------------------------------------------------------------- -inline FObject::iterator FListView::endOfList() -{ return itemlist.end(); } +inline const FListView::FListViewItems& FListView::getData() const +{ return reinterpret_cast(itemlist); } //---------------------------------------------------------------------- inline bool FListView::isHorizontallyScrollable() const diff --git a/src/include/final/fmenu.h b/src/include/final/fmenu.h index cda08e57..a20e0544 100644 --- a/src/include/final/fmenu.h +++ b/src/include/final/fmenu.h @@ -146,14 +146,14 @@ class FMenu : public FWindow, public FMenuList uChar mouse_over_supermenu : 1; uChar mouse_over_menubar : 1; uChar : 2; // padding bits - } mouseStates; + } MouseStates; typedef struct { FString text; std::size_t hotkeypos; bool no_underline; - } menuText; + } MenuText; // Accessors FWidget* getSuperMenu() const; @@ -187,11 +187,11 @@ class FMenu : public FWindow, public FMenuList void mouseDownSubmenu (const FMenuItem*); void mouseDownSelection (FMenuItem*, bool&); bool mouseUpOverList (const FPoint&); - void mouseMoveOverList (const FPoint&, mouseStates&); - void mouseMoveSelection (FMenuItem*, mouseStates&); - void mouseMoveDeselection (FMenuItem*, mouseStates&); + void mouseMoveOverList (const FPoint&, MouseStates&); + void mouseMoveSelection (FMenuItem*, MouseStates&); + void mouseMoveDeselection (FMenuItem*, MouseStates&); void mouseUpOverBorder(); - void mouseMoveOverBorder (mouseStates&) const; + void mouseMoveOverBorder (MouseStates&) const; void passEventToSubMenu (FMouseEvent* const&); void passEventToSuperMenu (FMouseEvent* const&); void passEventToMenuBar (FMouseEvent* const&) const; @@ -208,7 +208,7 @@ class FMenu : public FWindow, public FMenuList void drawSeparator (int); void drawMenuLine (FMenuItem*, int); void drawCheckMarkPrefix (const FMenuItem*); - void drawMenuText (menuText&); + void drawMenuText (MenuText&); void drawSubMenuIndicator (std::size_t&); void drawAcceleratorKey (std::size_t&, FKey); void drawTrailingSpaces (std::size_t); diff --git a/src/include/final/foptiattr.h b/src/include/final/foptiattr.h index ddd28571..c38e1ede 100644 --- a/src/include/final/foptiattr.h +++ b/src/include/final/foptiattr.h @@ -92,7 +92,7 @@ class FOptiAttr final int max_color; int attr_without_color; bool ansi_default_color; - } termEnv; + } TermEnv; // Constructor FOptiAttr(); @@ -110,7 +110,7 @@ class FOptiAttr final FString getClassName() const; // Mutators - void setTermEnvironment (const termEnv&); + void setTermEnvironment (const TermEnv&); void setMaxColor (const int&); void setNoColorVideo (int); void setDefaultColorSupport(); @@ -161,13 +161,13 @@ class FOptiAttr final private: // Typedefs and Enumerations - typedef char attributebuffer[SGRoptimizer::ATTR_BUF_SIZE]; + typedef SGRoptimizer::AttributeBuffer AttributeBuffer; typedef struct { const char* cap; bool caused_reset; - } capability; + } Capability; enum init_reset_tests { @@ -263,56 +263,55 @@ class FOptiAttr final bool append_sequence (const char[]); // Data members - capability F_enter_bold_mode{}; - capability F_exit_bold_mode{}; - capability F_enter_dim_mode{}; - capability F_exit_dim_mode{}; - capability F_enter_italics_mode{}; - capability F_exit_italics_mode{}; - capability F_enter_underline_mode{}; - capability F_exit_underline_mode{}; - capability F_enter_blink_mode{}; - capability F_exit_blink_mode{}; - capability F_enter_reverse_mode{}; - capability F_exit_reverse_mode{}; - capability F_enter_standout_mode{}; - capability F_exit_standout_mode{}; - capability F_enter_secure_mode{}; - capability F_exit_secure_mode{}; - capability F_enter_protected_mode{}; - capability F_exit_protected_mode{}; - capability F_enter_crossed_out_mode{}; - capability F_exit_crossed_out_mode{}; - capability F_enter_dbl_underline_mode{}; - capability F_exit_dbl_underline_mode{}; - capability F_set_attributes{}; - capability F_exit_attribute_mode{}; - capability F_enter_alt_charset_mode{}; - capability F_exit_alt_charset_mode{}; - capability F_enter_pc_charset_mode{}; - capability F_exit_pc_charset_mode{}; - capability F_set_a_foreground{}; - capability F_set_a_background{}; - capability F_set_foreground{}; - capability F_set_background{}; - capability F_set_color_pair{}; - capability F_orig_pair{}; - capability F_orig_colors{}; + Capability F_enter_bold_mode{}; + Capability F_exit_bold_mode{}; + Capability F_enter_dim_mode{}; + Capability F_exit_dim_mode{}; + Capability F_enter_italics_mode{}; + Capability F_exit_italics_mode{}; + Capability F_enter_underline_mode{}; + Capability F_exit_underline_mode{}; + Capability F_enter_blink_mode{}; + Capability F_exit_blink_mode{}; + Capability F_enter_reverse_mode{}; + Capability F_exit_reverse_mode{}; + Capability F_enter_standout_mode{}; + Capability F_exit_standout_mode{}; + Capability F_enter_secure_mode{}; + Capability F_exit_secure_mode{}; + Capability F_enter_protected_mode{}; + Capability F_exit_protected_mode{}; + Capability F_enter_crossed_out_mode{}; + Capability F_exit_crossed_out_mode{}; + Capability F_enter_dbl_underline_mode{}; + Capability F_exit_dbl_underline_mode{}; + Capability F_set_attributes{}; + Capability F_exit_attribute_mode{}; + Capability F_enter_alt_charset_mode{}; + Capability F_exit_alt_charset_mode{}; + Capability F_enter_pc_charset_mode{}; + Capability F_exit_pc_charset_mode{}; + Capability F_set_a_foreground{}; + Capability F_set_a_background{}; + Capability F_set_foreground{}; + Capability F_set_background{}; + Capability F_set_color_pair{}; + Capability F_orig_pair{}; + Capability F_orig_colors{}; - FChar on{}; - FChar off{}; - FChar reset_byte_mask{}; + FChar on{}; + FChar off{}; + FChar reset_byte_mask{}; - SGRoptimizer sgr_optimizer{attr_buf}; + SGRoptimizer sgr_optimizer{attr_buf}; + AttributeBuffer attr_buf{}; - int max_color{1}; - int attr_without_color{0}; - char* attr_ptr{attr_buf}; - char attr_buf[SGRoptimizer::ATTR_BUF_SIZE]{'\0'}; - bool ansi_default_color{false}; - bool alt_equal_pc_charset{false}; - bool monochron{true}; - bool fake_reverse{false}; + int max_color{1}; + int attr_without_color{0}; + bool ansi_default_color{false}; + bool alt_equal_pc_charset{false}; + bool monochron{true}; + bool fake_reverse{false}; }; diff --git a/src/include/final/foptimove.h b/src/include/final/foptimove.h index f30a5d87..1fcea1fb 100644 --- a/src/include/final/foptimove.h +++ b/src/include/final/foptimove.h @@ -83,7 +83,7 @@ class FOptiMove final int tabstop; bool automatic_left_margin; bool eat_nl_glitch; - } termEnv; + } TermEnv; // Constructor explicit FOptiMove (int = 0); @@ -118,7 +118,7 @@ class FOptiMove final void setBaudRate (int); void setTabStop (int); void setTermSize (std::size_t, std::size_t); - void setTermEnvironment (const termEnv&); + void setTermEnvironment (const TermEnv&); void set_cursor_home (const char[]); void set_cursor_to_ll (const char[]); void set_carriage_return (const char[]); @@ -156,7 +156,7 @@ class FOptiMove final const char* cap; int duration; int length; - } capability; + } Capability; // Constants static constexpr int LONG_DURATION{INT_MAX}; @@ -168,7 +168,7 @@ class FOptiMove final void calculateCharDuration(); int capDuration (const char[], int) const; int capDurationToLength (int) const; - int repeatedAppend (const capability&, volatile int, char*) const; + int repeatedAppend (const Capability&, volatile int, char*) const; int relativeMove (char[], int, int, int, int) const; int verticalMove (char[], int, int) const; void downMove (char[], int&, int, int) const; @@ -187,26 +187,26 @@ class FOptiMove final void moveByMethod (int, int, int, int, int); // Data members - capability F_cursor_home{}; - capability F_carriage_return{}; - capability F_cursor_to_ll{}; - capability F_tab{}; - capability F_back_tab{}; - capability F_cursor_up{}; - capability F_cursor_down{}; - capability F_cursor_left{}; - capability F_cursor_right{}; - capability F_cursor_address{}; - capability F_column_address{}; - capability F_row_address{}; - capability F_parm_up_cursor{}; - capability F_parm_down_cursor{}; - capability F_parm_left_cursor{}; - capability F_parm_right_cursor{}; - capability F_erase_chars{}; - capability F_repeat_char{}; - capability F_clr_bol{}; - capability F_clr_eol{}; + Capability F_cursor_home{}; + Capability F_carriage_return{}; + Capability F_cursor_to_ll{}; + Capability F_tab{}; + Capability F_back_tab{}; + Capability F_cursor_up{}; + Capability F_cursor_down{}; + Capability F_cursor_left{}; + Capability F_cursor_right{}; + Capability F_cursor_address{}; + Capability F_column_address{}; + Capability F_row_address{}; + Capability F_parm_up_cursor{}; + Capability F_parm_down_cursor{}; + Capability F_parm_left_cursor{}; + Capability F_parm_right_cursor{}; + Capability F_erase_chars{}; + Capability F_repeat_char{}; + Capability F_clr_bol{}; + Capability F_clr_eol{}; std::size_t screen_width{80}; std::size_t screen_height{24}; diff --git a/src/include/final/fscrollview.h b/src/include/final/fscrollview.h index bb205471..c0f6eccb 100644 --- a/src/include/final/fscrollview.h +++ b/src/include/final/fscrollview.h @@ -150,7 +150,7 @@ class FScrollView : public FWidget private: // Typedefs - typedef std::unordered_map> keyMap; + typedef std::unordered_map> KeyMap; // Constants static constexpr int vertical_border_spacing = 2; @@ -181,7 +181,7 @@ class FScrollView : public FWidget FTermArea* viewport{nullptr}; // virtual scroll content FScrollbarPtr vbar{nullptr}; FScrollbarPtr hbar{nullptr}; - keyMap key_map{}; + KeyMap key_map{}; uInt8 nf_offset{0}; bool use_own_print_area{false}; bool update_scrollbar{true}; diff --git a/src/include/final/fstatusbar.h b/src/include/final/fstatusbar.h index 9f253a01..7b7cc1c3 100644 --- a/src/include/final/fstatusbar.h +++ b/src/include/final/fstatusbar.h @@ -231,7 +231,7 @@ class FStatusBar : public FWindow private: // Typedef - typedef std::vector keyList; + typedef std::vector FKeyList; // Methods void init(); @@ -239,11 +239,11 @@ class FStatusBar : public FWindow int getKeyTextWidth (const FStatusKey*) const; void draw() override; void drawKeys(); - void drawKey (keyList::const_iterator); - void drawActiveKey (keyList::const_iterator); + void drawKey (FKeyList::const_iterator); + void drawActiveKey (FKeyList::const_iterator); // Data members - keyList key_list{}; + FKeyList key_list{}; FString text{""}; std::size_t screenWidth{80}; int keyname_len{0}; diff --git a/src/include/final/fstring.h b/src/include/final/fstring.h index a8bd97a5..7beec6aa 100644 --- a/src/include/final/fstring.h +++ b/src/include/final/fstring.h @@ -419,8 +419,7 @@ inline wchar_t FString::back() const template inline FString& FString::sprintf (const FString& format, Args&&... args) { - static constexpr int BUFSIZE = 4096; - wchar_t buf[BUFSIZE]{}; + std::array buf{}; if ( format.isEmpty() ) { @@ -428,9 +427,9 @@ inline FString& FString::sprintf (const FString& format, Args&&... args) return *this; } - std::swprintf ( buf, BUFSIZE, format.wc_str() + std::swprintf ( buf.data(), buf.size(), format.wc_str() , std::forward(args)... ); - _assign(buf); + _assign(buf.data()); return *this; } diff --git a/src/include/final/fterm.h b/src/include/final/fterm.h index be325578..55badcc9 100644 --- a/src/include/final/fterm.h +++ b/src/include/final/fterm.h @@ -132,6 +132,7 @@ class FKeyboard; class FMouseControl; class FOptiAttr; class FOptiMove; +class FPoint; class FStartOptions; class FSize; class FString; @@ -266,7 +267,7 @@ class FTerm final // Methods static bool setVGAFont(); static bool setNewFont(); - static bool setOldFont(); + static bool resetFont(); static int openConsole(); static int closeConsole(); static const char* moveCursorString (int, int, int, int); @@ -415,7 +416,7 @@ std::size_t getColumnWidth (const FString&); std::size_t getColumnWidth (const wchar_t); std::size_t getColumnWidth (FChar&); std::size_t getColumnWidth (const FTermBuffer&); - +FPoint readCursorPos(); // FTerm inline functions //---------------------------------------------------------------------- diff --git a/src/include/final/ftermcap.h b/src/include/final/ftermcap.h index 23cb3aa2..c356b1bd 100644 --- a/src/include/final/ftermcap.h +++ b/src/include/final/ftermcap.h @@ -84,11 +84,11 @@ class FTermcap final const char* string; char tname[alignof(char*)]; } - tcap_map; + TCapMap; // Using-declaration using fn_putc = int (*)(int); - using TCapMapType = std::array; + using TCapMapType = std::array; // Constructors FTermcap() = default; diff --git a/src/include/final/ftermdata.h b/src/include/final/ftermdata.h index e4c65fcd..5ba213c6 100644 --- a/src/include/final/ftermdata.h +++ b/src/include/final/ftermdata.h @@ -54,7 +54,7 @@ class FTermData final { public: // Typedefs - typedef std::unordered_map encodingMap; + typedef std::unordered_map EncodingMap; // Constructors FTermData() @@ -72,7 +72,7 @@ class FTermData final // Accessors FString getClassName() const; - encodingMap& getEncodingList(); + EncodingMap& getEncodingList(); charSubstitution& getCharSubstitutionMap(); fc::encoding getTermEncoding() const; FRect& getTermGeometry(); @@ -132,7 +132,7 @@ class FTermData final private: // Data members - encodingMap encoding_list{}; + EncodingMap encoding_list{}; charSubstitution char_substitution_map{}; FRect term_geometry{}; // current terminal geometry FString xterm_font{}; @@ -170,7 +170,7 @@ inline FString FTermData::getClassName() const { return "FTermData"; } //---------------------------------------------------------------------- -inline FTermData::encodingMap& FTermData::getEncodingList() +inline FTermData::EncodingMap& FTermData::getEncodingList() { return encoding_list; } //---------------------------------------------------------------------- diff --git a/src/include/final/ftermdetection.h b/src/include/final/ftermdetection.h index b4ebf48d..89798b87 100644 --- a/src/include/final/ftermdetection.h +++ b/src/include/final/ftermdetection.h @@ -210,6 +210,7 @@ class FTermDetection final static const FString* sec_da; static FTermData* fterm_data; static FSystem* fsystem; + static FKeyboard* keyboard; static FTerminalType terminal_type; static colorEnv color_env; static secondaryDA secondary_da; diff --git a/src/include/final/ftermlinux.h b/src/include/final/ftermlinux.h index cbcfd5cf..84b8b0a0 100644 --- a/src/include/final/ftermlinux.h +++ b/src/include/final/ftermlinux.h @@ -124,7 +124,7 @@ class FTermLinux final private: // Typedef - struct modifier_key // bit field + struct ModifierKey // bit field { uChar shift : 1; // 0..1 uChar alt_gr : 1; // 0..1 @@ -138,18 +138,18 @@ class FTermLinux final uChar red; uChar green; uChar blue; - } rgb; + } RGB; typedef struct { - rgb color[16]; + RGB color[16]; } ColorMap; // Accessors int getFramebuffer_bpp(); bool getScreenFont(); bool getUnicodeMap (); - modifier_key& getModifierKey(); + ModifierKey& getModifierKey(); // Mutators int setScreenFont ( const uChar[], uInt, uInt, uInt @@ -197,7 +197,7 @@ class FTermLinux final ColorMap saved_color_map{}; ColorMap cmap{}; int framebuffer_bpp{-1}; - modifier_key mod_key{}; + ModifierKey mod_key{}; #endif // defined(__linux__) }; diff --git a/src/include/final/ftermxterminal.h b/src/include/final/ftermxterminal.h index 39f9cb1d..805f58a3 100644 --- a/src/include/final/ftermxterminal.h +++ b/src/include/final/ftermxterminal.h @@ -41,6 +41,7 @@ namespace finalcut // class forward declaration class FString; class FSystem; +class FKeyboard; class FTermDetection; //---------------------------------------------------------------------- @@ -106,6 +107,7 @@ class FTermXTerminal final void resetMouseBackground(); void resetHighlightBackground(); void resetDefaults(); + void resetTitle(); void captureFontAndTitle(); private: @@ -147,6 +149,7 @@ class FTermXTerminal final static bool mouse_support; bool meta_sends_esc{false}; bool xterm_default_colors{false}; + bool title_was_changed{false}; std::size_t term_width{80}; std::size_t term_height{24}; FString xterm_font{}; @@ -158,6 +161,7 @@ class FTermXTerminal final FString mouse_background_color{}; FString highlight_background_color{}; static FSystem* fsystem; + static FKeyboard* keyboard; FTermDetection* term_detection{nullptr}; fc::xtermCursorStyle cursor_style{fc::unknown_cursor_style}; }; diff --git a/src/include/final/ftextview.h b/src/include/final/ftextview.h index 1e93758e..8fb66e65 100644 --- a/src/include/final/ftextview.h +++ b/src/include/final/ftextview.h @@ -138,7 +138,7 @@ class FTextView : public FWidget private: // Typedefs - typedef std::unordered_map> keyMap; + typedef std::unordered_map> KeyMap; // Accessors std::size_t getTextHeight() const; @@ -168,7 +168,7 @@ class FTextView : public FWidget FStringList data{}; FScrollbarPtr vbar{nullptr}; FScrollbarPtr hbar{nullptr}; - keyMap key_map{}; + KeyMap key_map{}; bool update_scrollbar{true}; int xoffset{0}; int yoffset{0}; diff --git a/src/include/final/fwidget.h b/src/include/final/fwidget.h index dcaf9451..20e8c62e 100644 --- a/src/include/final/fwidget.h +++ b/src/include/final/fwidget.h @@ -1058,7 +1058,7 @@ inline void FWidget::processDestroy() const // Non-member elements for NewFont //---------------------------------------------------------------------- -const wchar_t NF_menu_button[4] = +constexpr wchar_t NF_menu_button[] { fc::NF_rev_menu_button1, fc::NF_rev_menu_button2, @@ -1066,49 +1066,49 @@ const wchar_t NF_menu_button[4] = '\0' }; -const wchar_t NF_button_up[3] = +constexpr wchar_t NF_button_up[] { fc::NF_rev_up_pointing_triangle1, fc::NF_rev_up_pointing_triangle2, '\0' }; -const wchar_t NF_button_down[3] = +constexpr wchar_t NF_button_down[] { fc::NF_rev_down_pointing_triangle1, fc::NF_rev_down_pointing_triangle2, '\0' }; -const wchar_t NF_button_arrow_up[3] = +constexpr wchar_t NF_button_arrow_up[] { fc::NF_rev_up_arrow1, fc::NF_rev_up_arrow2, '\0' }; -const wchar_t NF_button_arrow_down[3] = +constexpr wchar_t NF_button_arrow_down[] { fc::NF_rev_down_arrow1, fc::NF_rev_down_arrow2, '\0' }; -const wchar_t NF_button_arrow_left[3] = +constexpr wchar_t NF_button_arrow_left[] { fc::NF_rev_left_arrow1, fc::NF_rev_left_arrow2, '\0' }; -const wchar_t NF_button_arrow_right[3] = +constexpr wchar_t NF_button_arrow_right[] { fc::NF_rev_right_arrow1, fc::NF_rev_right_arrow2, '\0' }; -const wchar_t NF_Drive[5] = +constexpr wchar_t NF_Drive[] { fc::NF_shadow_box_left, fc::NF_shadow_box_middle, @@ -1117,7 +1117,7 @@ const wchar_t NF_Drive[5] = '\0' }; -const wchar_t NF_CD_ROM[5] = +constexpr wchar_t NF_CD_ROM[] { fc::NF_shadow_box_left, fc::NF_shadow_box_middle, @@ -1126,7 +1126,7 @@ const wchar_t NF_CD_ROM[5] = '\0' }; -const wchar_t NF_Net_Drive[5] = +constexpr wchar_t NF_Net_Drive[] { fc::NF_shadow_box_left, fc::NF_shadow_box_middle, @@ -1135,7 +1135,7 @@ const wchar_t NF_Net_Drive[5] = '\0' }; -const wchar_t CHECKBOX[4] = +constexpr wchar_t CHECKBOX[] { fc::NF_shadow_box_left, fc::NF_shadow_box_middle, @@ -1143,7 +1143,7 @@ const wchar_t CHECKBOX[4] = '\0' }; -const wchar_t CHECKBOX_ON[4] = +constexpr wchar_t CHECKBOX_ON[] { fc::NF_shadow_box_left, fc::NF_shadow_box_checked, @@ -1151,7 +1151,7 @@ const wchar_t CHECKBOX_ON[4] = '\0' }; -const wchar_t RADIO_BUTTON[4] = +constexpr wchar_t RADIO_BUTTON[] { fc::NF_radio_button1, fc::NF_radio_button2, @@ -1159,7 +1159,7 @@ const wchar_t RADIO_BUTTON[4] = '\0' }; -const wchar_t CHECKED_RADIO_BUTTON[4] = +constexpr wchar_t CHECKED_RADIO_BUTTON[] { fc::NF_radio_button1, fc::NF_radio_button2_checked, diff --git a/src/include/final/sgr_optimizer.h b/src/include/final/sgr_optimizer.h index 9aac2929..011ff67c 100644 --- a/src/include/final/sgr_optimizer.h +++ b/src/include/final/sgr_optimizer.h @@ -51,10 +51,10 @@ class SGRoptimizer final static constexpr std::size_t ATTR_BUF_SIZE{8192}; // Typedefs - typedef char attributebuffer[ATTR_BUF_SIZE]; + typedef std::array AttributeBuffer; // Constructors - explicit SGRoptimizer (attributebuffer&); + explicit SGRoptimizer (AttributeBuffer&); // Disable copy constructor SGRoptimizer (const SGRoptimizer&) = delete; @@ -77,7 +77,7 @@ class SGRoptimizer final void combineParameter(); // Data member - attributebuffer& seq; + AttributeBuffer& seq; struct parameter { diff --git a/src/sgr_optimizer.cpp b/src/sgr_optimizer.cpp index e2d846a6..b38ecbf4 100644 --- a/src/sgr_optimizer.cpp +++ b/src/sgr_optimizer.cpp @@ -35,7 +35,7 @@ namespace finalcut // constructors and destructor //---------------------------------------------------------------------- -SGRoptimizer::SGRoptimizer (attributebuffer& sequence) +SGRoptimizer::SGRoptimizer (AttributeBuffer& sequence) : seq{sequence} { } @@ -59,7 +59,7 @@ void SGRoptimizer::findParameter() { // Find ANSI X3.64 terminal SGR (Select Graphic Rendition) strings - const std::size_t len = std::strlen(seq); + const std::size_t len = std::strlen(seq.data()); csi_parameter.clear(); if ( len < 6 ) diff --git a/test/fkeyboard-test.cpp b/test/fkeyboard-test.cpp index 50497acc..a70ff8d0 100644 --- a/test/fkeyboard-test.cpp +++ b/test/fkeyboard-test.cpp @@ -43,8 +43,8 @@ typedef struct } FKeyMap; -using original_type = std::array; -using test_type = std::array; +using original_type = std::array; +using test_type = std::array; test_type fkey = {{ @@ -53,7 +53,6 @@ test_type fkey = { finalcut::fc::Fkey_clear , 0 , "kC" }, // clear-screen or erase key { finalcut::fc::Fkey_ctab , CSI "3~" , "kt" }, // clear-tab key { finalcut::fc::Fkey_dc , 0 , "kD" }, // delete-character key - { finalcut::fc::Fkey_dc , 0 , "kDx" }, // delete-character key { finalcut::fc::Fkey_dl , 0 , "kL" }, // delete-line key { finalcut::fc::Fkey_down , ESC "OB" , "kd" }, // down-arrow key { finalcut::fc::Fkey_eic , 0 , "kM" }, // sent by rmir or smir in insert mode @@ -199,33 +198,48 @@ test_type fkey = { finalcut::fc::Fkey_f62 , ESC "O1;4Q", "Fq" }, // F62 function key { finalcut::fc::Fkey_f63 , ESC "O1;4R", "Fr" }, // F63 function key // vt100 key codes for arrow and function keys - { finalcut::fc::Fkey_down , CSI "B" , "kdx"}, // down-arrow key (standard mode) - { finalcut::fc::Fkey_down , ESC "OB" , "kdX"}, // down-arrow key (application mode) - { finalcut::fc::Fkey_f1 , ESC "OP" , "k1X"}, // PF1 (application mode) - { finalcut::fc::Fkey_f2 , CSI "OQ" , "k2X"}, // PF2 (application mode) - { finalcut::fc::Fkey_f3 , ESC "OR" , "k3X"}, // PF3 (application mode) - { finalcut::fc::Fkey_f4 , ESC "OS" , "k4X"}, // PF4 (application mode) + { finalcut::fc::Fkey_f1 , ESC "OP" , "k1x"}, // PF1 (application mode) + { finalcut::fc::Fkey_f2 , ESC "OQ" , "k2x"}, // PF2 (application mode) + { finalcut::fc::Fkey_f3 , ESC "OR" , "k3x"}, // PF3 (application mode) + { finalcut::fc::Fkey_f4 , ESC "OS" , "k4x"}, // PF4 (application mode) { finalcut::fc::Fkey_left , CSI "D" , "klx"}, // left-arrow key (standard mode) { finalcut::fc::Fkey_left , ESC "OD" , "klX"}, // left-arrow key (application mode) { finalcut::fc::Fkey_right , CSI "C" , "krx"}, // right-arrow key (standard mode) { finalcut::fc::Fkey_right , ESC "OC" , "krX"}, // right-arrow key (application mode) { finalcut::fc::Fkey_up , CSI "A" , "kux"}, // up-arrow key (standard mode) { finalcut::fc::Fkey_up , ESC "OA" , "kuX"}, // up-arrow key (application mode) + { finalcut::fc::Fkey_down , CSI "B" , "kdx"}, // down-arrow key (standard mode) + { finalcut::fc::Fkey_down , ESC "OB" , "kdX"}, // down-arrow key (application mode) + { finalcut::fc::Fkey_sf , CSI "a" , "kFx"}, // scroll-forward key (shift-up) + { finalcut::fc::Fkey_sr , CSI "b" , "kRx"}, // scroll-backward key (shift-down) // Fallback for rxvt with TERM=xterm { finalcut::fc::Fkey_home , CSI "7~" , "khx"}, // home key { finalcut::fc::Fkey_end , CSI "8~" , "@7x"}, // end key - { finalcut::fc::Fkey_f1 , CSI "11~" , "k1x"}, // F1 function key - { finalcut::fc::Fkey_f2 , CSI "12~" , "k2x"}, // F2 function key - { finalcut::fc::Fkey_f3 , CSI "13~" , "k3x"}, // F3 function key - { finalcut::fc::Fkey_f4 , CSI "14~" , "k4x"}, // F4 function key + { finalcut::fc::Fkey_f1 , CSI "11~" , "k1X"}, // F1 function key + { finalcut::fc::Fkey_f2 , CSI "12~" , "k2X"}, // F2 function key + { finalcut::fc::Fkey_f3 , CSI "13~" , "k3X"}, // F3 function key + { finalcut::fc::Fkey_f4 , CSI "14~" , "k4X"}, // F4 function key // Fallback for TERM=ansi - { finalcut::fc::Fkey_end , CSI "K" , "@7X"}, // end key + { finalcut::fc::Fkey_home , CSI "H" , "khX"}, // home key + { finalcut::fc::Fkey_end , CSI "F" , "@7X"}, // end key + { finalcut::fc::Fkey_end , CSI "K" , "@7y"}, // end key (Microsoft HyperTerminal) // Keypad keys { finalcut::fc::Fkey_enter , ESC "OM" , "@8x"}, // enter key { finalcut::fc::Fkey_slash , ESC "Oo" , "KP1"}, // keypad slash { finalcut::fc::Fkey_asterisk , ESC "Oj" , "KP2"}, // keypad asterisk { finalcut::fc::Fkey_minus_sign, ESC "Om" , "KP3"}, // keypad minus sign - { finalcut::fc::Fkey_plus_sign , ESC "Ok" , "KP4"} // keypad plus sign + { finalcut::fc::Fkey_plus_sign , ESC "Ok" , "KP4"}, // keypad plus sign + { finalcut::fc::Fkey_ic , ESC "Op" , "kIx"}, // keypad insert + { finalcut::fc::Fkey_dc , ESC "On" , "kDx"}, // keypad delete + { finalcut::fc::Fkey_left , ESC "Ot" , "kly"}, // keypad left-arrow + { finalcut::fc::Fkey_right , ESC "Ov" , "kry"}, // keypad right-arrow + { finalcut::fc::Fkey_up , ESC "Ox" , "kuy"}, // keypad up-arrow + { finalcut::fc::Fkey_down , ESC "Or" , "kdy"}, // keypad down-arrow + { finalcut::fc::Fkey_a1 , ESC "Ow" , "K1x"}, // keypad upper left + { finalcut::fc::Fkey_a3 , ESC "Oy" , "K3x"}, // keypad upper right + { finalcut::fc::Fkey_b2 , ESC "Ou" , "K2x"}, // keypad center + { finalcut::fc::Fkey_c1 , ESC "Oq" , "K4x"}, // keypad lower left + { finalcut::fc::Fkey_c3 , ESC "Os" , "K5x"} // keypad lower right }}; } // namespace test @@ -2539,6 +2553,13 @@ void FKeyboardTest::sequencesTest() CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fkey_home ); clear(); + // Home key (ANSI terminal) + input("\033[H"); + processInput(); + std::cout << " - Key: " << keyboard->getKeyName(key_pressed) << std::endl; + CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fkey_home ); + clear(); + // End key in positioning mode input("\033[8~"); processInput(); @@ -2554,6 +2575,13 @@ void FKeyboardTest::sequencesTest() clear(); // End key (ANSI terminal) + input("\033[F"); + processInput(); + std::cout << " - Key: " << keyboard->getKeyName(key_pressed) << std::endl; + CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fkey_end ); + clear(); + + // End key (Microsoft HyperTerminal) input("\033[K"); processInput(); std::cout << " - Key: " << keyboard->getKeyName(key_pressed) << std::endl; @@ -2588,6 +2616,13 @@ void FKeyboardTest::sequencesTest() CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fkey_sf ); clear(); + // Scroll-forward key (shift + up-arrow) in applications mode + input("\033[a"); + processInput(); + std::cout << " - Key: " << keyboard->getKeyName(key_pressed) << std::endl; + CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fkey_sf ); + clear(); + // Scroll-backward key (shift + down-arrow) input("\033[1;2A"); processInput(); @@ -2595,6 +2630,13 @@ void FKeyboardTest::sequencesTest() CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fkey_sr ); clear(); + // Scroll-backward key (shift + down-arrow) in applications mode + input("\033[b"); + processInput(); + std::cout << " - Key: " << keyboard->getKeyName(key_pressed) << std::endl; + CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fkey_sr ); + clear(); + // Center of keypad input("\033[E"); processInput(); @@ -2706,6 +2748,84 @@ void FKeyboardTest::sequencesTest() std::cout << " - Key: " << keyboard->getKeyName(key_pressed) << std::endl; CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fkey_plus_sign ); clear(); + + // Keypad insert (numlock off) + input("\033Op"); + processInput(); + std::cout << " - Key: " << keyboard->getKeyName(key_pressed) << std::endl; + CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fkey_ic ); + clear(); + + // Keypad delete (numlock off) + input("\033On"); + processInput(); + std::cout << " - Key: " << keyboard->getKeyName(key_pressed) << std::endl; + CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fkey_dc ); + clear(); + + // Keypad left-arrow (numlock off) + input("\033Ot"); + processInput(); + std::cout << " - Key: " << keyboard->getKeyName(key_pressed) << std::endl; + CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fkey_left ); + clear(); + + // Keypad right-arrow (numlock off) + input("\033Ov"); + processInput(); + std::cout << " - Key: " << keyboard->getKeyName(key_pressed) << std::endl; + CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fkey_right ); + clear(); + + // Keypad up-arrow (numlock off) + input("\033Ox"); + processInput(); + std::cout << " - Key: " << keyboard->getKeyName(key_pressed) << std::endl; + CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fkey_up ); + clear(); + + // Keypad down-arrow (numlock off) + input("\033Or"); + processInput(); + std::cout << " - Key: " << keyboard->getKeyName(key_pressed) << std::endl; + CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fkey_down ); + clear(); + + // Keypad upper left (numlock off) + input("\033Ow"); + processInput(); + std::cout << " - Key: " << keyboard->getKeyName(key_pressed) << std::endl; + CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fkey_a1 ); + clear(); + + // Keypad upper right (numlock off) + input("\033Oy"); + processInput(); + std::cout << " - Key: " << keyboard->getKeyName(key_pressed) << std::endl; + CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fkey_a3 ); + clear(); + + // Keypad center (numlock off) + input("\033Ou"); + processInput(); + std::cout << " - Key: " << keyboard->getKeyName(key_pressed) << std::endl; + CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fkey_b2 ); + clear(); + + // Keypad lower left (numlock off) + input("\033Oq"); + processInput(); + std::cout << " - Key: " << keyboard->getKeyName(key_pressed) << std::endl; + CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fkey_c1 ); + clear(); + + // Keypad lower right (numlock off) + input("\033Os"); + processInput(); + std::cout << " - Key: " << keyboard->getKeyName(key_pressed) << std::endl; + CPPUNIT_ASSERT ( key_pressed == finalcut::fc::Fkey_c3 ); + clear(); + } //---------------------------------------------------------------------- diff --git a/test/foptiattr-test.cpp b/test/foptiattr-test.cpp index a6eb3748..81c6fcbe 100644 --- a/test/foptiattr-test.cpp +++ b/test/foptiattr-test.cpp @@ -224,80 +224,80 @@ void FOptiAttrTest::sgrOptimizerTest() // Test only the optimizer // ----------------------- - char buffer[8192] = { CSI "0;10m" CSI "11m" CSI "36m" CSI "44m" }; + finalcut::SGRoptimizer::AttributeBuffer buffer = { CSI "0;10m" CSI "11m" CSI "36m" CSI "44m" }; finalcut::SGRoptimizer sgr_optimizer(buffer); sgr_optimizer.optimize(); - CPPUNIT_ASSERT_CSTRING ( buffer, CSI "0;10;11;36;44m" ); + CPPUNIT_ASSERT_CSTRING ( buffer.data(), CSI "0;10;11;36;44m" ); - std::strcpy(buffer, CSI "0;1m" CSI "34m"); + std::strcpy(buffer.data(), CSI "0;1m" CSI "34m"); sgr_optimizer.optimize(); - CPPUNIT_ASSERT_CSTRING ( buffer, CSI "0;1;34m" ); + CPPUNIT_ASSERT_CSTRING ( buffer.data(), CSI "0;1;34m" ); - std::strcpy(buffer, CSI "m" CSI "34m"); + std::strcpy(buffer.data(), CSI "m" CSI "34m"); sgr_optimizer.optimize(); - CPPUNIT_ASSERT_CSTRING ( buffer, CSI "0;34m" ); + CPPUNIT_ASSERT_CSTRING ( buffer.data(), CSI "0;34m" ); - std::strcpy(buffer, CSI "1m" CSI "m" CSI "45m"); + std::strcpy(buffer.data(), CSI "1m" CSI "m" CSI "45m"); sgr_optimizer.optimize(); - CPPUNIT_ASSERT_CSTRING ( buffer, CSI "1;0;45m" ); + CPPUNIT_ASSERT_CSTRING ( buffer.data(), CSI "1;0;45m" ); - std::strcpy(buffer, CSI "47m"); + std::strcpy(buffer.data(), CSI "47m"); sgr_optimizer.optimize(); - CPPUNIT_ASSERT_CSTRING ( buffer, CSI "47m" ); + CPPUNIT_ASSERT_CSTRING ( buffer.data(), CSI "47m" ); - std::strcpy(buffer, CSI "47m" CSI "m" CSI "1m"); + std::strcpy(buffer.data(), CSI "47m" CSI "m" CSI "1m"); sgr_optimizer.optimize(); - CPPUNIT_ASSERT_CSTRING ( buffer, CSI "47;0;1m" ); + CPPUNIT_ASSERT_CSTRING ( buffer.data(), CSI "47;0;1m" ); - std::strcpy(buffer, CSI "49m" CSI "m" CSI "0m"); + std::strcpy(buffer.data(), CSI "49m" CSI "m" CSI "0m"); sgr_optimizer.optimize(); - CPPUNIT_ASSERT_CSTRING ( buffer, CSI "49;0;0m" ); + CPPUNIT_ASSERT_CSTRING ( buffer.data(), CSI "49;0;0m" ); - std::strcpy(buffer, CSI "m" CSI "m" CSI "m"); + std::strcpy(buffer.data(), CSI "m" CSI "m" CSI "m"); sgr_optimizer.optimize(); - CPPUNIT_ASSERT_CSTRING ( buffer, CSI "0;0;0m" ); + CPPUNIT_ASSERT_CSTRING ( buffer.data(), CSI "0;0;0m" ); - std::strcpy(buffer, CSI "m"); + std::strcpy(buffer.data(), CSI "m"); sgr_optimizer.optimize(); - CPPUNIT_ASSERT_CSTRING ( buffer, CSI "m" ); + CPPUNIT_ASSERT_CSTRING ( buffer.data(), CSI "m" ); - std::strcpy(buffer, CSI "0;10;1;7m" CSI "3m" CSI "39m" CSI "49m"); + std::strcpy(buffer.data(), CSI "0;10;1;7m" CSI "3m" CSI "39m" CSI "49m"); sgr_optimizer.optimize(); - CPPUNIT_ASSERT_CSTRING ( buffer, CSI "0;10;1;7;3;39;49m" ); + CPPUNIT_ASSERT_CSTRING ( buffer.data(), CSI "0;10;1;7;3;39;49m" ); - std::strcpy(buffer, CSI "m" CSI "38;5;20m" CSI "48;5;229m"); + std::strcpy(buffer.data(), CSI "m" CSI "38;5;20m" CSI "48;5;229m"); sgr_optimizer.optimize(); - CPPUNIT_ASSERT_CSTRING ( buffer, CSI "0;38;5;20;48;5;229m" ); + CPPUNIT_ASSERT_CSTRING ( buffer.data(), CSI "0;38;5;20;48;5;229m" ); - std::strcpy(buffer, CSI "m" CSI "38;5;20m" CSI "11;16H"); + std::strcpy(buffer.data(), CSI "m" CSI "38;5;20m" CSI "11;16H"); sgr_optimizer.optimize(); - CPPUNIT_ASSERT_CSTRING ( buffer, CSI "0;38;5;20m" CSI "11;16H" ); + CPPUNIT_ASSERT_CSTRING ( buffer.data(), CSI "0;38;5;20m" CSI "11;16H" ); - std::strcpy(buffer, CSI "1;1H" CSI "m" CSI "38;5;35m"); + std::strcpy(buffer.data(), CSI "1;1H" CSI "m" CSI "38;5;35m"); sgr_optimizer.optimize(); - CPPUNIT_ASSERT_CSTRING ( buffer, CSI "1;1H" CSI "0;38;5;35m" ); + CPPUNIT_ASSERT_CSTRING ( buffer.data(), CSI "1;1H" CSI "0;38;5;35m" ); - std::strcpy(buffer, CSI "m" CSI "38;5;20m" CSI "11;16H" CSI "48;5;229m"); + std::strcpy(buffer.data(), CSI "m" CSI "38;5;20m" CSI "11;16H" CSI "48;5;229m"); sgr_optimizer.optimize(); - CPPUNIT_ASSERT_CSTRING ( buffer, CSI "0;38;5;20m" CSI "11;16H" CSI "48;5;229m" ); + CPPUNIT_ASSERT_CSTRING ( buffer.data(), CSI "0;38;5;20m" CSI "11;16H" CSI "48;5;229m" ); - std::strcpy(buffer, CSI "m" CSI "38;5;20m" "ABC" CSI "48;5;229m"); + std::strcpy(buffer.data(), CSI "m" CSI "38;5;20m" "ABC" CSI "48;5;229m"); sgr_optimizer.optimize(); - CPPUNIT_ASSERT_CSTRING ( buffer, CSI "0;38;5;20mABC" CSI "48;5;229m" ); + CPPUNIT_ASSERT_CSTRING ( buffer.data(), CSI "0;38;5;20mABC" CSI "48;5;229m" ); - std::strcpy(buffer, CSI "m" CSI "1m" CSI "2m" CSI "3m" CSI "4m" + std::strcpy(buffer.data(), CSI "m" CSI "1m" CSI "2m" CSI "3m" CSI "4m" CSI "5m" CSI "7m" CSI "8m" CSI "9m"); sgr_optimizer.optimize(); - CPPUNIT_ASSERT_CSTRING ( buffer, CSI "0;1;2;3;4;5;7;8;9m" ); + CPPUNIT_ASSERT_CSTRING ( buffer.data(), CSI "0;1;2;3;4;5;7;8;9m" ); - std::strcpy(buffer, CSI "0m" CSI "46;36;1m"); + std::strcpy(buffer.data(), CSI "0m" CSI "46;36;1m"); sgr_optimizer.optimize(); - CPPUNIT_ASSERT_CSTRING ( buffer, CSI "0;46;36;1m" ); + CPPUNIT_ASSERT_CSTRING ( buffer.data(), CSI "0;46;36;1m" ); - std::strcpy(buffer, CSI "m" CSI "38;2;0;139;139m" CSI "48;2;240;255;240m"); + std::strcpy(buffer.data(), CSI "m" CSI "38;2;0;139;139m" CSI "48;2;240;255;240m"); sgr_optimizer.optimize(); - CPPUNIT_ASSERT_CSTRING ( buffer, CSI "0;38;2;0;139;139;48;2;240;255;240m" ); + CPPUNIT_ASSERT_CSTRING ( buffer.data(), CSI "0;38;2;0;139;139;48;2;240;255;240m" ); delete to; delete from; @@ -4163,7 +4163,7 @@ void FOptiAttrTest::wyse50Test() finalcut::FStartOptions::getFStartOptions().sgr_optimizer = false; finalcut::FOptiAttr oa; - finalcut::FOptiAttr::termEnv optiattr_env = + finalcut::FOptiAttr::TermEnv optiattr_env = { 0, // Enter bold ESC "(" ESC "H\003" diff --git a/test/foptimove-test.cpp b/test/foptimove-test.cpp index d98f0509..eaa610d1 100644 --- a/test/foptimove-test.cpp +++ b/test/foptimove-test.cpp @@ -612,7 +612,7 @@ void FOptiMoveTest::teratermTest() om.setTermSize (80, 25); om.setBaudRate (38400); - finalcut::FOptiMove::termEnv optimove_env = + finalcut::FOptiMove::TermEnv optimove_env = { CSI "H", // Cursor home "\r", // Carriage return diff --git a/test/ftermlinux-test.cpp b/test/ftermlinux-test.cpp index 97e50104..017acccd 100644 --- a/test/ftermlinux-test.cpp +++ b/test/ftermlinux-test.cpp @@ -75,18 +75,18 @@ class FSystemTest : public finalcut::FSystem uChar ctrl : 1; uChar alt : 1; uChar : 4; // padding bits - } shiftstate; + } ShiftState; typedef struct { uChar red; uChar green; uChar blue; - } rgb; + } RGB; typedef struct { - rgb color[16]; + RGB color[16]; } ColorMap; enum ac_mode @@ -117,9 +117,9 @@ class FSystemTest : public finalcut::FSystem int getpwuid_r (uid_t, struct passwd*, char* , size_t, struct passwd** ) override; char* realpath (const char*, char*) override; - rgb& getRGB (std::size_t); + RGB& getRGB (std::size_t); console_font_op& getConsoleFont(); - shiftstate& getShiftState(); + ShiftState& getShiftState(); std::string& getCharacters(); private: @@ -129,9 +129,9 @@ class FSystemTest : public finalcut::FSystem // Data members std::string characters; - static shiftstate shift_state; - static rgb terminal_color[16]; - static rgb defaultColor[16]; + static ShiftState shift_state; + static RGB terminal_color[16]; + static RGB defaultColor[16]; static struct console_font_op terminal_font; static unimapdesc terminal_unicode_map; static struct fb_var_screeninfo fb_terminal_info; @@ -948,9 +948,9 @@ struct unipair FSystemTest::unicode_cp437_pairs[] = {0x266c, 0x0e} }; -FSystemTest::rgb FSystemTest::terminal_color[16] { }; +FSystemTest::RGB FSystemTest::terminal_color[16] { }; -FSystemTest::rgb FSystemTest::defaultColor[16] +FSystemTest::RGB FSystemTest::defaultColor[16] { {0x00, 0x00, 0x00}, {0xaa, 0x00, 0x00}, {0x00, 0xaa, 0x00}, {0xaa, 0x55, 0x00}, @@ -965,7 +965,7 @@ FSystemTest::rgb FSystemTest::defaultColor[16] // static class attributes //---------------------------------------------------------------------- -FSystemTest::shiftstate FSystemTest::shift_state{}; +FSystemTest::ShiftState FSystemTest::shift_state{}; struct console_font_op FSystemTest::terminal_font{}; unimapdesc FSystemTest::terminal_unicode_map{}; struct fb_var_screeninfo FSystemTest::fb_terminal_info{}; @@ -1368,7 +1368,7 @@ char* FSystemTest::realpath (const char*, char*) } //---------------------------------------------------------------------- -FSystemTest::rgb& FSystemTest::getRGB (std::size_t i) +FSystemTest::RGB& FSystemTest::getRGB (std::size_t i) { if ( i < 16 ) return terminal_color[i]; @@ -1383,7 +1383,7 @@ console_font_op& FSystemTest::getConsoleFont() } //---------------------------------------------------------------------- -FSystemTest::shiftstate& FSystemTest::getShiftState() +FSystemTest::ShiftState& FSystemTest::getShiftState() { return shift_state; } @@ -1894,7 +1894,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( linux.resetColorMap() == true ); CPPUNIT_ASSERT ( linux.saveColorMap() == true ); FColor index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::Black); - test::FSystemTest::rgb& RGB0 = fsystest->getRGB(index); + test::FSystemTest::RGB& RGB0 = fsystest->getRGB(index); CPPUNIT_ASSERT ( RGB0.red == 0x00 ); CPPUNIT_ASSERT ( RGB0.green == 0x00 ); CPPUNIT_ASSERT ( RGB0.blue == 0x00 ); @@ -1904,7 +1904,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB0.blue == 0x03 ); index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::Blue); - test::FSystemTest::rgb& RGB1 = fsystest->getRGB(index); + test::FSystemTest::RGB& RGB1 = fsystest->getRGB(index); CPPUNIT_ASSERT ( RGB1.red == 0x00 ); CPPUNIT_ASSERT ( RGB1.green == 0x00 ); CPPUNIT_ASSERT ( RGB1.blue == 0xaa ); @@ -1914,7 +1914,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB1.blue == 0x06 ); index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::Green); - test::FSystemTest::rgb& RGB2 = fsystest->getRGB(index); + test::FSystemTest::RGB& RGB2 = fsystest->getRGB(index); CPPUNIT_ASSERT ( RGB2.red == 0x00 ); CPPUNIT_ASSERT ( RGB2.green == 0xaa ); CPPUNIT_ASSERT ( RGB2.blue == 0x00 ); @@ -1924,7 +1924,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB2.blue == 0x09 ); index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::Cyan); - test::FSystemTest::rgb& RGB3 = fsystest->getRGB(index); + test::FSystemTest::RGB& RGB3 = fsystest->getRGB(index); CPPUNIT_ASSERT ( RGB3.red == 0x00 ); CPPUNIT_ASSERT ( RGB3.green == 0xaa ); CPPUNIT_ASSERT ( RGB3.blue == 0xaa ); @@ -1934,7 +1934,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB3.blue == 0x0c ); index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::Red); - test::FSystemTest::rgb& RGB4 = fsystest->getRGB(index); + test::FSystemTest::RGB& RGB4 = fsystest->getRGB(index); CPPUNIT_ASSERT ( RGB4.red == 0xaa ); CPPUNIT_ASSERT ( RGB4.green == 0x00 ); CPPUNIT_ASSERT ( RGB4.blue == 0x00 ); @@ -1944,7 +1944,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB4.blue == 0x0f ); index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::Magenta); - test::FSystemTest::rgb& RGB5 = fsystest->getRGB(index); + test::FSystemTest::RGB& RGB5 = fsystest->getRGB(index); CPPUNIT_ASSERT ( RGB5.red == 0xaa ); CPPUNIT_ASSERT ( RGB5.green == 0x00 ); CPPUNIT_ASSERT ( RGB5.blue == 0xaa ); @@ -1954,7 +1954,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB5.blue == 0x12 ); index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::Brown); - test::FSystemTest::rgb& RGB6 = fsystest->getRGB(index); + test::FSystemTest::RGB& RGB6 = fsystest->getRGB(index); CPPUNIT_ASSERT ( RGB6.red == 0xaa ); CPPUNIT_ASSERT ( RGB6.green == 0x55 ); CPPUNIT_ASSERT ( RGB6.blue == 0x00 ); @@ -1964,7 +1964,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB6.blue == 0x15 ); index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::LightGray); - test::FSystemTest::rgb& RGB7 = fsystest->getRGB(index); + test::FSystemTest::RGB& RGB7 = fsystest->getRGB(index); CPPUNIT_ASSERT ( RGB7.red == 0xaa ); CPPUNIT_ASSERT ( RGB7.green == 0xaa ); CPPUNIT_ASSERT ( RGB7.blue == 0xaa ); @@ -1974,7 +1974,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB7.blue == 0x18 ); index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::DarkGray); - test::FSystemTest::rgb& RGB8 = fsystest->getRGB(index); + test::FSystemTest::RGB& RGB8 = fsystest->getRGB(index); CPPUNIT_ASSERT ( RGB8.red == 0x55 ); CPPUNIT_ASSERT ( RGB8.green == 0x55 ); CPPUNIT_ASSERT ( RGB8.blue == 0x55 ); @@ -1984,7 +1984,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB8.blue == 0x21 ); index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::LightBlue); - test::FSystemTest::rgb& RGB9 = fsystest->getRGB(index); + test::FSystemTest::RGB& RGB9 = fsystest->getRGB(index); CPPUNIT_ASSERT ( RGB9.red == 0x55 ); CPPUNIT_ASSERT ( RGB9.green == 0x55 ); CPPUNIT_ASSERT ( RGB9.blue == 0xff ); @@ -1994,7 +1994,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB9.blue == 0x24 ); index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::LightGreen); - test::FSystemTest::rgb& RGB10 = fsystest->getRGB(index); + test::FSystemTest::RGB& RGB10 = fsystest->getRGB(index); CPPUNIT_ASSERT ( RGB10.red == 0x55 ); CPPUNIT_ASSERT ( RGB10.green == 0xff ); CPPUNIT_ASSERT ( RGB10.blue == 0x55 ); @@ -2004,7 +2004,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB10.blue == 0x27 ); index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::LightCyan); - test::FSystemTest::rgb& RGB11 = fsystest->getRGB(index); + test::FSystemTest::RGB& RGB11 = fsystest->getRGB(index); CPPUNIT_ASSERT ( RGB11.red == 0x55 ); CPPUNIT_ASSERT ( RGB11.green == 0xff ); CPPUNIT_ASSERT ( RGB11.blue == 0xff ); @@ -2014,7 +2014,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB11.blue == 0x30 ); index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::LightRed); - test::FSystemTest::rgb& RGB12 = fsystest->getRGB(index); + test::FSystemTest::RGB& RGB12 = fsystest->getRGB(index); CPPUNIT_ASSERT ( RGB12.red == 0xff ); CPPUNIT_ASSERT ( RGB12.green == 0x55 ); CPPUNIT_ASSERT ( RGB12.blue == 0x55 ); @@ -2024,7 +2024,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB12.blue == 0x33 ); index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::LightMagenta); - test::FSystemTest::rgb& RGB13 = fsystest->getRGB(index); + test::FSystemTest::RGB& RGB13 = fsystest->getRGB(index); CPPUNIT_ASSERT ( RGB13.red == 0xff ); CPPUNIT_ASSERT ( RGB13.green == 0x55 ); CPPUNIT_ASSERT ( RGB13.blue == 0xff ); @@ -2034,7 +2034,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB13.blue == 0x36 ); index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::Yellow); - test::FSystemTest::rgb& RGB14 = fsystest->getRGB(index); + test::FSystemTest::RGB& RGB14 = fsystest->getRGB(index); CPPUNIT_ASSERT ( RGB14.red == 0xff ); CPPUNIT_ASSERT ( RGB14.green == 0xff ); CPPUNIT_ASSERT ( RGB14.blue == 0x55 ); @@ -2044,7 +2044,7 @@ void FTermLinuxTest::linuxColorPaletteTest() CPPUNIT_ASSERT ( RGB14.blue == 0x39 ); index = finalcut::FOptiAttr::vga2ansi(finalcut::fc::White); - test::FSystemTest::rgb& RGB15 = fsystest->getRGB(index); + test::FSystemTest::RGB& RGB15 = fsystest->getRGB(index); CPPUNIT_ASSERT ( RGB15.red == 0xff ); CPPUNIT_ASSERT ( RGB15.green == 0xff ); CPPUNIT_ASSERT ( RGB15.blue == 0xff ); @@ -2253,7 +2253,7 @@ void FTermLinuxTest::modifierKeyTest() finalcut::FTermLinux linux{}; finalcut::FSystem* fsys(new test::FSystemTest()); test::FSystemTest* fsystest = static_cast(fsys); - test::FSystemTest::shiftstate& mod_key = fsystest->getShiftState(); + test::FSystemTest::ShiftState& mod_key = fsystest->getShiftState(); // Up key keycode = finalcut::fc::Fkey_up; From 9f1bd871518ac991e57f18e0c06464d5bd7e3096 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Thu, 8 Oct 2020 12:09:48 +0200 Subject: [PATCH 24/30] Minor changes --- examples/rotozoomer.cpp | 12 ++-- src/fapplication.cpp | 4 +- src/ffiledialog.cpp | 5 +- src/fterm_functions.cpp | 54 +++++++-------- src/ftermdetection.cpp | 126 +++++++++++++++++----------------- src/ftermxterminal.cpp | 140 +++++++++++++++++++------------------- src/include/final/fdata.h | 7 +- 7 files changed, 176 insertions(+), 172 deletions(-) diff --git a/examples/rotozoomer.cpp b/examples/rotozoomer.cpp index 3284abac..31d6d9c5 100644 --- a/examples/rotozoomer.cpp +++ b/examples/rotozoomer.cpp @@ -96,12 +96,14 @@ RotoZoomer::RotoZoomer (finalcut::FWidget* parent, bool b, int l) { for (std::size_t i{0}; i < 8; i++) { - data[h++] = L' '; + data[h] = L' '; + h++; } for (std::size_t i{0}; i < 8; i++) { - data[h++] = L'+'; + data[h] = L'+'; + h++; } } @@ -109,12 +111,14 @@ RotoZoomer::RotoZoomer (finalcut::FWidget* parent, bool b, int l) { for (std::size_t i{0}; i < 8; i++) { - data[h++] = L'x'; + data[h] = L'x'; + h++; } for (std::size_t i{0}; i < 8; i++) { - data[h++] = L' '; + data[h] = L' '; + h++; } } } diff --git a/src/fapplication.cpp b/src/fapplication.cpp index b4b77029..1c68fd9d 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -97,9 +97,9 @@ FApplication::FApplication (const int& _argc, char* _argv[]) if ( ! (_argc && _argv) ) { typedef char* CString; - static CString empty[1]{CString("")}; + static std::array empty{CString("")}; app_argc = 0; - app_argv = empty; + app_argv = empty.data(); } init(); diff --git a/src/ffiledialog.cpp b/src/ffiledialog.cpp index d36e80d0..5b456fae 100644 --- a/src/ffiledialog.cpp +++ b/src/ffiledialog.cpp @@ -25,6 +25,7 @@ #include // need for strcasecmp #endif +#include #include #include "final/fevent.h" @@ -427,7 +428,7 @@ inline bool FFileDialog::patternMatch ( const char* const pattern std::strncat(search.data(), pattern, search.size() - std::strlen(search.data()) - 1); } else - std::strncpy(search.data(), pattern, search.size()); + std::strncpy(search.data(), pattern, search.size() - 1); search[search.size() - 1] = '\0'; @@ -602,7 +603,7 @@ void FFileDialog::followSymLink (const char* const dir, FDirEntry& entry) const if ( ! fsystem ) fsystem = FTerm::getFSystem(); - std::strncpy (symLink.data(), dir, symLink.size()); + std::strncpy (symLink.data(), dir, symLink.size() - 1); symLink[symLink.size() - 1] = '\0'; std::strncat ( symLink.data() , entry.name.c_str() diff --git a/src/fterm_functions.cpp b/src/fterm_functions.cpp index 3dabd87b..e1e42515 100644 --- a/src/fterm_functions.cpp +++ b/src/fterm_functions.cpp @@ -545,39 +545,37 @@ FPoint readCursorPos() constexpr auto& DECXCPR{ESC "[6n"}; // Report Cursor Position (DECXCPR) - const ssize_t ret = write(stdout_no, DECXCPR, std::strlen(DECXCPR)); + if ( write(stdout_no, DECXCPR, std::strlen(DECXCPR)) < 1 ) + return FPoint{x, y}; - if ( ret > 0 ) + std::fflush(stdout); + FD_ZERO(&ifds); + FD_SET(stdin_no, &ifds); + tv.tv_sec = 0; + tv.tv_usec = 100000; // 100 ms + + // Read the answer + if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) != 1 ) + return FPoint{x, y}; + + constexpr auto parse = "\033[%4d;%4dR"; + std::array temp{}; + std::size_t pos{0}; + + do { - std::fflush(stdout); - FD_ZERO(&ifds); - FD_SET(stdin_no, &ifds); - tv.tv_sec = 0; - tv.tv_usec = 100000; // 100 ms + std::size_t bytes_free = temp.size() - pos - 1; + const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free); - // Read the answer - if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) == 1 ) - { - constexpr auto parse = "\033[%4d;%4dR"; - std::array temp{}; - std::size_t pos{0}; + if ( bytes <= 0 ) + break; - do - { - std::size_t bytes_free = temp.size() - pos - 1; - const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free); - - if ( bytes <= 0 ) - break; - - pos += std::size_t(bytes); - } - while ( pos < temp.size() && std::strchr(temp.data(), 'R') == nullptr ); - - if ( pos > 4 ) - std::sscanf(temp.data(), parse, &x, &y); - } + pos += std::size_t(bytes); } + while ( pos < temp.size() && std::strchr(temp.data(), 'R') == nullptr ); + + if ( pos > 4 ) + std::sscanf(temp.data(), parse, &x, &y); return FPoint{x, y}; } diff --git a/src/ftermdetection.cpp b/src/ftermdetection.cpp index 63fc2ac7..083d95c9 100644 --- a/src/ftermdetection.cpp +++ b/src/ftermdetection.cpp @@ -580,39 +580,38 @@ FString FTermDetection::getXTermColorName (FColor color) tv.tv_usec = 150000; // 150 ms // read the terminal answer - if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) > 0 ) + if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) < 1 ) + return color_str; + + constexpr auto parse = "\033]4;%10hu;%509[^\n]s"; + std::array temp{}; + std::size_t pos{0}; + + do { - constexpr auto parse = "\033]4;%10hu;%509[^\n]s"; - std::array temp{}; - std::size_t pos{0}; + std::size_t bytes_free = temp.size() - pos - 1; + const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free); - do - { - std::size_t bytes_free = temp.size() - pos - 1; - const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free); + if ( bytes <= 0 ) + break; - if ( bytes <= 0 ) - break; + pos += std::size_t(bytes); + } + while ( pos < temp.size() ); - pos += std::size_t(bytes); - } - while ( pos < temp.size() ); + if ( pos > 4 && std::sscanf(temp.data(), parse, &color, buf.data()) == 2 ) + { + std::size_t n = std::strlen(buf.data()); - if ( pos > 4 - && std::sscanf(temp.data(), parse, &color, buf.data()) == 2 ) - { - std::size_t n = std::strlen(buf.data()); + // BEL + '\0' = string terminator + if ( n >= 6 && buf[n - 1] == BEL[0] && buf[n] == '\0' ) + buf[n - 1] = '\0'; - // BEL + '\0' = string terminator - if ( n >= 6 && buf[n - 1] == BEL[0] && buf[n] == '\0' ) - buf[n - 1] = '\0'; + // Esc + \ = OSC string terminator (mintty) + if ( n >= 6 && buf[n - 2] == ESC[0] && buf[n - 1] == '\\' ) + buf[n - 2] = '\0'; - // Esc + \ = OSC string terminator (mintty) - if ( n >= 6 && buf[n - 2] == ESC[0] && buf[n - 1] == '\\' ) - buf[n - 2] = '\0'; - - color_str = buf.data(); - } + color_str = buf.data(); } return color_str; @@ -647,8 +646,8 @@ const char* FTermDetection::parseAnswerbackMsg (const char current_termtype[]) new_termtype = "putty"; } - // Some terminal like cygwin or the windows terminal - // needs to delete the '♣' char + // Some terminals like cygwin or the Windows terminal + // have to delete the printed character '♣' std::fprintf (stdout, "\r " BS); std::fflush (stdout); @@ -681,26 +680,26 @@ FString FTermDetection::getAnswerbackMsg() tv.tv_usec = 150000; // 150 ms // Read the answerback message - if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) > 0 ) + if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) < 1 ) + return answerback; + + std::array temp{}; + std::size_t pos{0}; + + do { - std::array temp{}; - std::size_t pos{0}; + std::size_t bytes_free = temp.size() - pos - 1; + const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free); - do - { - std::size_t bytes_free = temp.size() - pos - 1; - const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free); + if ( bytes <= 0 ) + break; - if ( bytes <= 0 ) - break; - - pos += std::size_t(bytes); - } - while ( pos < temp.size() ); - - if ( pos > 0 ) - answerback = temp.data(); + pos += std::size_t(bytes); } + while ( pos < temp.size() ); + + if ( pos > 0 ) + answerback = temp.data(); return answerback; } @@ -815,9 +814,7 @@ FString FTermDetection::getSecDA() constexpr auto& SECDA{ESC "[>c"}; // Get the secondary device attributes - const ssize_t ret = write(stdout_no, SECDA, std::strlen(SECDA)); - - if ( ret == -1 ) + if ( write(stdout_no, SECDA, std::strlen(SECDA)) == -1 ) return sec_da_str; std::fflush(stdout); @@ -827,28 +824,27 @@ FString FTermDetection::getSecDA() tv.tv_usec = 600000; // 600 ms // Read the answer - if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) == 1 ) + if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) < 1 ) + return sec_da_str; + + constexpr auto parse = "\033[>%10d;%10d;%10dc"; + std::array temp{}; + std::size_t pos{0}; + + do { - constexpr auto parse = "\033[>%10d;%10d;%10dc"; - std::array temp{}; - std::size_t pos{0}; + std::size_t bytes_free = temp.size() - pos - 1; + const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free); - do - { - std::size_t bytes_free = temp.size() - pos - 1; - const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free); + if ( bytes <= 0 ) + break; - if ( bytes <= 0 ) - break; - - pos += std::size_t(bytes); - } - while ( pos < temp.size() && std::strchr(temp.data(), 'c') == nullptr ); - - if ( pos > 3 - && std::sscanf(temp.data(), parse, &a, &b, &c) == 3 ) - sec_da_str.sprintf("\033[>%d;%d;%dc", a, b, c); + pos += std::size_t(bytes); } + while ( pos < temp.size() && std::strchr(temp.data(), 'c') == nullptr ); + + if ( pos > 3 && std::sscanf(temp.data(), parse, &a, &b, &c) == 3 ) + sec_da_str.sprintf("\033[>%d;%d;%dc", a, b, c); return sec_da_str; } diff --git a/src/ftermxterminal.cpp b/src/ftermxterminal.cpp index fdf0e6ba..ce079766 100644 --- a/src/ftermxterminal.cpp +++ b/src/ftermxterminal.cpp @@ -765,56 +765,58 @@ FString FTermXTerminal::captureXTermFont() const { initCheck(FString{}); - if ( term_detection->isXTerminal() - || term_detection->isScreenTerm() - || FTermcap::osc_support ) + if ( ! term_detection->isXTerminal() + && ! term_detection->isScreenTerm() + && ! FTermcap::osc_support ) { - fd_set ifds{}; - struct timeval tv{}; - const int stdin_no = FTermios::getStdIn(); + return FString{}; + } - // Querying the terminal font - oscPrefix(); - FTerm::putstring (OSC "50;?" BEL); - oscPostfix(); - std::fflush(stdout); - FD_ZERO(&ifds); - FD_SET(stdin_no, &ifds); - tv.tv_sec = 0; - tv.tv_usec = 150000; // 150 ms + fd_set ifds{}; + struct timeval tv{}; + const int stdin_no = FTermios::getStdIn(); - // Read the terminal answer - if ( select(stdin_no + 1, &ifds, nullptr, nullptr, &tv) > 0 ) - { - std::array temp{}; - std::size_t pos{0}; + // Querying the terminal font + oscPrefix(); + FTerm::putstring (OSC "50;?" BEL); + oscPostfix(); + std::fflush(stdout); + FD_ZERO(&ifds); + FD_SET(stdin_no, &ifds); + tv.tv_sec = 0; + tv.tv_usec = 150000; // 150 ms - do - { - std::size_t bytes_free = temp.size() - pos - 1; - const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free); + // Read the terminal answer + if ( select(stdin_no + 1, &ifds, nullptr, nullptr, &tv) < 1 ) + return FString{}; - if ( bytes <= 0 ) - break; + std::array temp{}; + std::size_t pos{0}; - pos += std::size_t(bytes); - } - while ( pos < temp.size() && std::strchr(temp.data(), '\a') == nullptr ); + do + { + std::size_t bytes_free = temp.size() - pos - 1; + const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free); - if ( pos > 5 && temp[0] == ESC[0] && temp[1] == ']' - && temp[2] == '5' && temp[3] == '0' && temp[4] == ';' ) - { - // Skip leading Esc ] 5 0 ; - char* str = &temp[5]; - const std::size_t n = std::strlen(str); + if ( bytes <= 0 ) + break; - // BEL + '\0' = string terminator - if ( n >= 5 && str[n - 1] == BEL[0] && str[n] == '\0' ) - str[n - 1] = '\0'; + pos += std::size_t(bytes); + } + while ( pos < temp.size() && std::strchr(temp.data(), '\a') == nullptr ); - return FString{str}; - } - } + if ( pos > 5 && temp[0] == ESC[0] && temp[1] == ']' && temp[2] == '5' + && temp[3] == '0' && temp[4] == ';' ) + { + // Skip leading Esc ] 5 0 ; + char* str = &temp[5]; + const std::size_t n = std::strlen(str); + + // BEL + '\0' = string terminator + if ( n >= 5 && str[n - 1] == BEL[0] && str[n] == '\0' ) + str[n - 1] = '\0'; + + return FString{str}; } return FString{}; @@ -841,38 +843,38 @@ FString FTermXTerminal::captureXTermTitle() const tv.tv_usec = 150000; // 150 ms // read the terminal answer - if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) > 0 ) + if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) < 1 ) + return FString{}; + + std::array temp{}; + std::size_t pos{0}; + + do { - std::array temp{}; - std::size_t pos{0}; + std::size_t bytes_free = temp.size() - pos - 1; + const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free); - do + if ( bytes <= 0 ) + break; + + pos += std::size_t(bytes); + } + while ( pos < temp.size() && std::strstr(temp.data(), ESC "\\") == nullptr ); + + if ( pos > 6 && temp[0] == ESC[0] && temp[1] == ']' && temp[2] == 'l' ) + { + // Skip leading Esc + ] + l = OSC l + char* str = &temp[3]; + const std::size_t n = std::strlen(str); + + // Esc + \ = OSC string terminator + if ( n >= 2 && str[n - 2] == ESC[0] && str[n - 1] == '\\' ) { - std::size_t bytes_free = temp.size() - pos - 1; - const ssize_t bytes = read(stdin_no, &temp[pos], bytes_free); + if ( n < 4 ) + return FString{}; - if ( bytes <= 0 ) - break; - - pos += std::size_t(bytes); - } - while ( pos < temp.size() && std::strstr(temp.data(), ESC "\\") == nullptr ); - - if ( pos > 6 && temp[0] == ESC[0] && temp[1] == ']' && temp[2] == 'l' ) - { - // Skip leading Esc + ] + l = OSC l - char* str = &temp[3]; - const std::size_t n = std::strlen(str); - - // Esc + \ = OSC string terminator - if ( n >= 2 && str[n - 2] == ESC[0] && str[n - 1] == '\\' ) - { - if ( n < 4 ) - return FString{}; - - str[n - 2] = '\0'; - return FString{str}; - } + str[n - 2] = '\0'; + return FString{str}; } } diff --git a/src/include/final/fdata.h b/src/include/final/fdata.h index c691e6b5..9b47169d 100644 --- a/src/include/final/fdata.h +++ b/src/include/final/fdata.h @@ -153,6 +153,8 @@ template class FData : public FDataAccess { public: + typedef typename std::remove_cv::type T_nocv; + // Constructors explicit FData (T& v) // constructor : value_ref{v} @@ -244,8 +246,9 @@ class FData : public FDataAccess // Inquiries bool isInitializedCopy() const { - return bool( reinterpret_cast(&value) - == reinterpret_cast(&value_ref.get()) ); + const auto& v = reinterpret_cast(const_cast(&value)); + const auto& r = reinterpret_cast(const_cast(&value_ref.get())); + return bool( v == r ); } bool isInitializedReference() const From 97f1dea7b8f60a7847be04020b7b7bb04f78d47b Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Thu, 8 Oct 2020 16:28:29 +0200 Subject: [PATCH 25/30] Add some includes --- examples/windows.cpp | 4 ++-- src/fapplication.cpp | 2 +- src/fkeyboard.cpp | 1 + src/flineedit.cpp | 1 + src/flogger.cpp | 1 + src/fmessagebox.cpp | 4 ++-- src/foptiattr.cpp | 1 + src/foptimove.cpp | 1 + src/ftermdetection.cpp | 2 ++ src/ftermlinux.cpp | 1 + src/ftermxterminal.cpp | 2 ++ src/ftextview.cpp | 2 +- src/fwidget.cpp | 18 ++++++++++-------- src/include/final/frect.h | 4 ++-- src/include/final/fstring.h | 1 + test/fkeyboard-test.cpp | 22 ++++++++++++++++++++++ 16 files changed, 51 insertions(+), 16 deletions(-) diff --git a/examples/windows.cpp b/examples/windows.cpp index 5d750c66..b3ee3827 100644 --- a/examples/windows.cpp +++ b/examples/windows.cpp @@ -261,10 +261,10 @@ Window::Window (finalcut::FWidget* parent) Statusbar.setMessage("Status bar message"); // Generate data vector for the windows - for (int n{1}; n <= 6; n++) + for (uInt n{1}; n < 7; n++) { auto win_dat = new win_data; - win_dat->title.sprintf("Window %1d", n); + win_dat->title.sprintf("Window %1u", n); windows.push_back(win_dat); } } diff --git a/src/fapplication.cpp b/src/fapplication.cpp index 1c68fd9d..b490a189 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -97,7 +97,7 @@ FApplication::FApplication (const int& _argc, char* _argv[]) if ( ! (_argc && _argv) ) { typedef char* CString; - static std::array empty{CString("")}; + static std::array empty{{CString("")}}; app_argc = 0; app_argv = empty.data(); } diff --git a/src/fkeyboard.cpp b/src/fkeyboard.cpp index 79ea18ff..f0d9d2db 100644 --- a/src/fkeyboard.cpp +++ b/src/fkeyboard.cpp @@ -27,6 +27,7 @@ #endif #include +#include #include #include "final/fkeyboard.h" diff --git a/src/flineedit.cpp b/src/flineedit.cpp index b130c935..47ac36cf 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include #include #include "final/fapplication.h" diff --git a/src/flogger.cpp b/src/flogger.cpp index 4daaa0c8..d75341b3 100644 --- a/src/flogger.cpp +++ b/src/flogger.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include #include #include "final/flogger.h" diff --git a/src/fmessagebox.cpp b/src/fmessagebox.cpp index c8599240..d707e89f 100644 --- a/src/fmessagebox.cpp +++ b/src/fmessagebox.cpp @@ -207,8 +207,8 @@ void FMessageBox::init() { calculateDimensions(); - if ( (button_digit[2] && ! button_digit[1]) - || (button_digit[1] && ! button_digit[0]) ) + if ( (button_digit[2] != Reject && button_digit[1] == Reject) + || (button_digit[1] != Reject && button_digit[0] == Reject) ) { button_digit[0] = button_digit[1] \ = button_digit[2] \ diff --git a/src/foptiattr.cpp b/src/foptiattr.cpp index ea103bd4..4c03b929 100644 --- a/src/foptiattr.cpp +++ b/src/foptiattr.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include #include #include "final/fc.h" diff --git a/src/foptimove.cpp b/src/foptimove.cpp index 6ce2918e..38e05c20 100644 --- a/src/foptimove.cpp +++ b/src/foptimove.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include #include #include "final/fapplication.h" diff --git a/src/ftermdetection.cpp b/src/ftermdetection.cpp index 083d95c9..8eed2bd6 100644 --- a/src/ftermdetection.cpp +++ b/src/ftermdetection.cpp @@ -24,6 +24,8 @@ #include "final/fconfig.h" // includes _GNU_SOURCE for fd_set #endif +#include + #include "final/emptyfstring.h" #include "final/fapplication.h" #include "final/fc.h" diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index 45d47f49..fd8fade7 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include #include #include "final/fapplication.h" diff --git a/src/ftermxterminal.cpp b/src/ftermxterminal.cpp index ce079766..a73717dd 100644 --- a/src/ftermxterminal.cpp +++ b/src/ftermxterminal.cpp @@ -24,6 +24,8 @@ #include "final/fconfig.h" // includes _GNU_SOURCE for fd_set #endif +#include + #include "final/fapplication.h" #include "final/fc.h" #include "final/flog.h" diff --git a/src/ftextview.cpp b/src/ftextview.cpp index c08a03b5..961ce175 100644 --- a/src/ftextview.cpp +++ b/src/ftextview.cpp @@ -535,7 +535,7 @@ void FTextView::adjustSize() if ( width < 3 ) return; - const int hmax = ( max_width > int(width) - nf_offset - 2 ) + const int hmax = ( max_width >= int(width) - nf_offset - 1 ) ? max_width - int(width) + nf_offset + 2 : 0; hbar->setMaximum (hmax); diff --git a/src/fwidget.cpp b/src/fwidget.cpp index d44b85c7..5dfb4856 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -1798,21 +1798,23 @@ inline void FWidget::insufficientSpaceAdjust() // move left if not enough space while ( getTermX() + int(getWidth()) - padding.right > woffset.getX2() + 2 ) { - adjust_wsize.x1_ref()--; - adjust_wsize.x2_ref()--; - - if ( adjust_wsize.x1_ref() < 1 ) + if ( adjust_wsize.x1_ref() < 2 ) adjust_wsize.x1_ref() = 1; + else + adjust_wsize.x1_ref()--; + + adjust_wsize.x2_ref()--; } // move up if not enough space while ( getTermY() + int(getHeight()) - padding.bottom > woffset.getY2() + 2 ) { - adjust_wsize.y1_ref()--; - adjust_wsize.y2_ref()--; - - if ( adjust_wsize.y1_ref() < 1 ) + if ( adjust_wsize.y1_ref() < 2 ) adjust_wsize.y1_ref() = 1; + else + adjust_wsize.y1_ref()--; + + adjust_wsize.y2_ref()--; } // reduce the width if not enough space diff --git a/src/include/final/frect.h b/src/include/final/frect.h index 0768f1ae..15c4a25e 100644 --- a/src/include/final/frect.h +++ b/src/include/final/frect.h @@ -202,14 +202,14 @@ inline int FRect::getY() const //---------------------------------------------------------------------- inline std::size_t FRect::getWidth() const { - const int w = X2 - X1 + 1; + const int w = X2 - (X1 - 1); // overflow save return ( w < 0 ) ? 0 : std::size_t(w); } //---------------------------------------------------------------------- inline std::size_t FRect::getHeight() const { - const int h = Y2 - Y1 + 1; + const int h = Y2 - (Y1 - 1); // overflow save return ( h < 0 ) ? 0 : std::size_t(h); } diff --git a/src/include/final/fstring.h b/src/include/final/fstring.h index 7beec6aa..8102d4cd 100644 --- a/src/include/final/fstring.h +++ b/src/include/final/fstring.h @@ -49,6 +49,7 @@ #include #include +#include #include #include #include diff --git a/test/fkeyboard-test.cpp b/test/fkeyboard-test.cpp index a70ff8d0..3cff23c6 100644 --- a/test/fkeyboard-test.cpp +++ b/test/fkeyboard-test.cpp @@ -32,6 +32,23 @@ #include +#define CPPUNIT_ASSERT_CSTRING(expected, actual) \ + check_c_string (expected, actual, CPPUNIT_SOURCELINE()) + +//---------------------------------------------------------------------- +void check_c_string ( const char* s1 + , const char* s2 + , CppUnit::SourceLine sourceLine ) +{ + if ( s1 == 0 && s2 == 0 ) // Strings are equal + return; + + if ( s1 && s2 && std::strcmp (s1, s2) == 0 ) // Strings are equal + return; + + ::CppUnit::Asserter::fail ("Strings are not equal", sourceLine); +} + namespace test { @@ -379,6 +396,11 @@ void FKeyboardTest::noArgumentTest() keyboard->setReadBlockingTime(100000); // 100 ms CPPUNIT_ASSERT ( keyboard->getReadBlockingTime() == 100 * 1000 ); + + // Check key map + CPPUNIT_ASSERT ( test::fkey[0].num == finalcut::fc::Fkey_backspace ); + CPPUNIT_ASSERT_CSTRING ( test::fkey[0].string, "\177" ); + CPPUNIT_ASSERT_CSTRING ( test::fkey[0].tname, "kb" ); } //---------------------------------------------------------------------- From 73e587b9c275620b7a30ee238f8ba8babb512162 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Thu, 8 Oct 2020 16:46:14 +0200 Subject: [PATCH 26/30] Add some includes --- examples/checklist.cpp | 1 + examples/listview.cpp | 1 + src/fapplication.cpp | 1 + src/fterm.cpp | 1 + src/include/final/fcharmap.h | 2 ++ src/include/final/fkey_map.h | 2 ++ src/include/final/sgr_optimizer.h | 1 + 7 files changed, 9 insertions(+) diff --git a/examples/checklist.cpp b/examples/checklist.cpp index 6d748651..6469a68e 100644 --- a/examples/checklist.cpp +++ b/examples/checklist.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include #include #include #include diff --git a/examples/listview.cpp b/examples/listview.cpp index bdc9eec3..a0478895 100644 --- a/examples/listview.cpp +++ b/examples/listview.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include #include #include #include diff --git a/src/fapplication.cpp b/src/fapplication.cpp index b490a189..87fa16e1 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include #include #include #include diff --git a/src/fterm.cpp b/src/fterm.cpp index 0eeaf7ca..066f4336 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include #include #include #include diff --git a/src/include/final/fcharmap.h b/src/include/final/fcharmap.h index 9d20d745..8aafa7e8 100644 --- a/src/include/final/fcharmap.h +++ b/src/include/final/fcharmap.h @@ -27,6 +27,8 @@ #error "Only can be included directly." #endif +#include + #include "final/fc.h" #include "final/ftypes.h" diff --git a/src/include/final/fkey_map.h b/src/include/final/fkey_map.h index f2c74aae..ea5b6d47 100644 --- a/src/include/final/fkey_map.h +++ b/src/include/final/fkey_map.h @@ -27,6 +27,8 @@ #error "Only can be included directly." #endif +#include + #include "final/ftypes.h" namespace finalcut diff --git a/src/include/final/sgr_optimizer.h b/src/include/final/sgr_optimizer.h index 011ff67c..e67dcdd3 100644 --- a/src/include/final/sgr_optimizer.h +++ b/src/include/final/sgr_optimizer.h @@ -35,6 +35,7 @@ #error "Only can be included directly." #endif +#include #include namespace finalcut From 396cda69e8fed14faef1ee452aad54c48bf59e93 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 11 Oct 2020 09:14:52 +0200 Subject: [PATCH 27/30] Solaris build fix --- .travis.yml | 3 +- ChangeLog | 7 +++ doc/first-steps.md | 20 +++--- doc/user-theme.md | 2 +- examples/menu.cpp | 6 +- examples/ui.cpp | 5 +- src/fapplication.cpp | 105 ++++++++++++++++++------------- src/fdialog.cpp | 5 +- src/flog.cpp | 2 + src/flogger.cpp | 6 +- src/fmenubar.cpp | 1 + src/fterm_functions.cpp | 11 ++-- src/ftermcap.cpp | 2 +- src/ftermcapquirks.cpp | 20 ++++++ src/ftermdetection.cpp | 2 +- src/ftermlinux.cpp | 2 + src/ftermxterminal.cpp | 2 +- src/include/final/fapplication.h | 14 +++++ src/include/final/flog.h | 33 +++++++--- src/include/final/flogger.h | 31 +++++++-- 20 files changed, 193 insertions(+), 86 deletions(-) diff --git a/.travis.yml b/.travis.yml index dfeb55a3..fcabedb0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: cpp dist: xenial -sudo: required compiler: - gcc @@ -41,7 +40,7 @@ env: bL/epiiMBKJ37X1UcRU4WZYq+peLME8EefcPcXOSWNLwJtR7mtON8uMBrLL9CWmRMFD5Hy lQYALW2DhCnDBROKB3gxB/VkBGFNE0IPGeDtBGbLqDtKWPQoL125I= -matrix: +jobs: include: # # Coverity Scan diff --git a/ChangeLog b/ChangeLog index a65440a9..4b6ab317 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2020-10-11 Markus Gans + * Solaris build fix + * Added saving and restoring xterm titles to the stack + for vte terminals + * Menu key - activates the menu bar + * Shift-Menu - opens the dialog menu + 2020-10-08 Markus Gans * Better keyboard support for urxvt terminals * Screen reports (like Secondary DA) are now read directly diff --git a/doc/first-steps.md b/doc/first-steps.md index 172a4e64..7cafbacb 100644 --- a/doc/first-steps.md +++ b/doc/first-steps.md @@ -137,7 +137,7 @@ int main (int argc, char* argv[]) After entering the source code in *dialog.cpp* you can compile the above program with gcc: -```cpp +```bash g++ dialog.cpp -o dialog -O2 -lfinal ``` @@ -284,7 +284,7 @@ int main (int argc, char* argv[]) After entering the source code in *memory.cpp* you can compile the above program with gcc: -```cpp +```bash g++ memory.cpp -o memory -O2 -lfinal ``` @@ -424,7 +424,7 @@ int main (int argc, char* argv[]) After entering the source code in *timer.cpp* you can compile the above program with gcc: -```cpp +```bash g++ timer.cpp -o timer -O2 -lfinal -std=c++11 ``` @@ -537,7 +537,7 @@ int main (int argc, char* argv[]) After entering the source code in *user-event.cpp* you can compile the above program with gcc: -```cpp +```bash g++ user-event.cpp -o user-event -O2 -lfinal -std=c++11 ``` @@ -808,7 +808,7 @@ int main (int argc, char* argv[]) After entering the source code in *callback-function.cpp* you can compile the above program with gcc: -```cpp +```bash g++ callback-function.cpp -o callback-function -O2 -lfinal ```   @@ -871,7 +871,7 @@ int main (int argc, char* argv[]) After entering the source code in *callback-lambda.cpp* you can compile the above program with gcc: -```cpp +```bash g++ callback-lambda.cpp -o callback-lambda -O2 -lfinal -std=c++11 ```   @@ -930,7 +930,7 @@ int main (int argc, char* argv[]) After entering the source code in *callback-method.cpp* you can compile the above program with gcc: -```cpp +```bash g++ callback-method.cpp -o callback-method -O2 -lfinal -std=c++11 ```   @@ -1051,7 +1051,7 @@ int main (int argc, char* argv[]) After entering the source code in *emit-signal.cpp* you can compile the above program with gcc: -```cpp +```bash g++ emit-signal.cpp -o emit-signal -O2 -lfinal -std=c++11 ``` @@ -1322,7 +1322,7 @@ int main (int argc, char* argv[]) After entering the source code in *size-adjustment.cpp* you can compile the above program with gcc: -```cpp +```bash g++ size-adjustment.cpp -o size-adjustment -O2 -lfinal -std=c++11 ``` @@ -1450,6 +1450,6 @@ int main (int argc, char* argv[]) After entering the source code in *scrollview.cpp* you can compile the above program with gcc: -```cpp +```bash g++ scrollview.cpp -o scrollview -O2 -lfinal -std=c++11 ``` diff --git a/doc/user-theme.md b/doc/user-theme.md index 611a2c23..18156010 100644 --- a/doc/user-theme.md +++ b/doc/user-theme.md @@ -437,7 +437,7 @@ int main (int argc, char* argv[]) After entering the source code in *theme.cpp* you can compile the above program with gcc: -```cpp +```bash g++ theme.cpp -o theme -O2 -lfinal -std=c++11 ``` diff --git a/examples/menu.cpp b/examples/menu.cpp index 66099bf8..a60dd65e 100644 --- a/examples/menu.cpp +++ b/examples/menu.cpp @@ -151,8 +151,10 @@ Menu::Menu (finalcut::FWidget* parent) // Info label Info << " Activate menu bar\n" << "+ Activate menu bar\n" + << " Activate menu bar\n" + << "+ Open dialog menu\n" << "+ Exit"; - Info.setGeometry(FPoint{2, 1}, FSize{36, 3}); + Info.setGeometry(FPoint{2, 1}, FSize{36, 5}); } //---------------------------------------------------------------------- @@ -327,7 +329,7 @@ int main (int argc, char* argv[]) // Create main dialog object Menu main_dlg {&app}; main_dlg.setText ("Menu example"); - main_dlg.setSize ({40, 6}); + main_dlg.setSize ({40, 8}); main_dlg.setShadow(); // Set dialog main_dlg as main widget diff --git a/examples/ui.cpp b/examples/ui.cpp index 1b16c5f1..6e429bac 100644 --- a/examples/ui.cpp +++ b/examples/ui.cpp @@ -780,10 +780,9 @@ void MyDialog::initWidgetsCallbacks() //---------------------------------------------------------------------- void MyDialog::adjustSize() { - finalcut::FDialog::adjustSize(); - const auto h = getDesktopHeight() - 4; setHeight (h, false); + finalcut::FDialog::adjustSize(); // with new client area size auto x = int((getDesktopWidth() - getWidth()) / 2); if ( x < 1 ) @@ -792,7 +791,7 @@ void MyDialog::adjustSize() setPos (FPoint{x, 2}, false); if ( initialized ) - myList.setHeight (getHeight() - 3, true); + myList.setHeight (h - 3, true); } //---------------------------------------------------------------------- diff --git a/src/fapplication.cpp b/src/fapplication.cpp index 87fa16e1..7c43f8c7 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -66,9 +66,35 @@ FMouseControl* FApplication::mouse {nullptr}; // mouse control int FApplication::loop_level {0}; // event loop level int FApplication::quit_code {EXIT_SUCCESS}; bool FApplication::quit_now {false}; -uInt64 FApplication::next_event_wait {5000}; // preset to 5 ms /200 Hz +uInt64 FApplication::next_event_wait {5000}; // preset to 5 ms (200 Hz) struct timeval FApplication::time_last_event{}; + +constexpr FApplication::CmdOption FApplication::long_options[] = +{ + {"encoding", required_argument, nullptr, 'e' }, + {"log-file", required_argument, nullptr, 'l' }, + {"no-mouse", no_argument, nullptr, 'm' }, + {"no-optimized-cursor", no_argument, nullptr, 'o' }, + {"no-terminal-detection", no_argument, nullptr, 'd' }, + {"no-terminal-data-request", no_argument, nullptr, 'r' }, + {"no-color-change", no_argument, nullptr, 'c' }, + {"no-sgr-optimizer", no_argument, nullptr, 's' }, + {"vgafont", no_argument, nullptr, 'v' }, + {"newfont", no_argument, nullptr, 'n' }, + {"dark-theme", no_argument, nullptr, 't' }, + +#if defined(__FreeBSD__) || defined(__DragonFly__) + {"no-esc-for-alt-meta", no_argument, nullptr, 'E' }, + {"no-cursorstyle-change", no_argument, nullptr, 'C' }, +#elif defined(__NetBSD__) || defined(__OpenBSD__) + {"no-esc-for-alt-meta", no_argument, nullptr, 'E' }, +#endif + + {nullptr, 0, nullptr, 0 } +}; + + //---------------------------------------------------------------------- // class FApplication //---------------------------------------------------------------------- @@ -382,7 +408,9 @@ void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev) void FApplication::processExternalUserEvent() { // This method can be overloaded and replaced by own code - std::this_thread::sleep_for(std::chrono::milliseconds(5)); + + if ( FKeyboard::getReadBlockingTime() < 10000 ) + std::this_thread::sleep_for(std::chrono::milliseconds(5)); } @@ -463,81 +491,72 @@ void FApplication::cmd_options (const int& argc, char* argv[]) while ( true ) { - static struct option long_options[] = - { - {"encoding", required_argument, nullptr, 0 }, - {"log-file", required_argument, nullptr, 0 }, - {"no-mouse", no_argument, nullptr, 0 }, - {"no-optimized-cursor", no_argument, nullptr, 0 }, - {"no-terminal-detection", no_argument, nullptr, 0 }, - {"no-terminal-data-request", no_argument, nullptr, 0 }, - {"no-color-change", no_argument, nullptr, 0 }, - {"no-sgr-optimizer", no_argument, nullptr, 0 }, - {"vgafont", no_argument, nullptr, 0 }, - {"newfont", no_argument, nullptr, 0 }, - {"dark-theme", no_argument, nullptr, 0 }, - - #if defined(__FreeBSD__) || defined(__DragonFly__) - {"no-esc-for-alt-meta", no_argument, nullptr, 0 }, - {"no-cursorstyle-change", no_argument, nullptr, 0 }, - #elif defined(__NetBSD__) || defined(__OpenBSD__) - {"no-esc-for-alt-meta", no_argument, nullptr, 0 }, - #endif - - {nullptr, 0, nullptr, 0 } - }; - opterr = 0; int idx{0}; - const int c = getopt_long (argc, argv, "", long_options, &idx); + auto p = reinterpret_cast(long_options); + const int opt = getopt_long (argc, argv, "", p, &idx); - if ( c == -1 ) + if ( opt == -1 ) break; - if ( c == 0 ) + switch ( opt ) { - if ( std::strcmp(long_options[idx].name, "encoding") == 0 ) + case 'e': // --encoding setTerminalEncoding(FString(optarg)); + break; - if ( std::strcmp(long_options[idx].name, "log-file") == 0 ) + case 'l': // --log-file setLogFile(FString(optarg)); + break; - if ( std::strcmp(long_options[idx].name, "no-mouse") == 0 ) + case 'm': // --no-mouse getStartOptions().mouse_support = false; + break; - if ( std::strcmp(long_options[idx].name, "no-optimized-cursor") == 0 ) + case 'o': // --no-optimized-cursor getStartOptions().cursor_optimisation = false; + break; - if ( std::strcmp(long_options[idx].name, "no-terminal-detection") == 0 ) + case 'd': // --no-terminal-detection getStartOptions().terminal_detection = false; + break; - if ( std::strcmp(long_options[idx].name, "no-terminal-data-request") == 0 ) + case 'r': // --no-terminal-data-request getStartOptions().terminal_data_request = false; + break; - if ( std::strcmp(long_options[idx].name, "no-color-change") == 0 ) + case 'c': // --no-color-change getStartOptions().color_change = false; + break; - if ( std::strcmp(long_options[idx].name, "no-sgr-optimizer") == 0 ) + case 's': // --no-sgr-optimizer getStartOptions().sgr_optimizer = false; + break; - if ( std::strcmp(long_options[idx].name, "vgafont") == 0 ) + case 'v': // --vgafont getStartOptions().vgafont = true; + break; - if ( std::strcmp(long_options[idx].name, "newfont") == 0 ) + case 'n': // --newfont getStartOptions().newfont = true; + break; - if ( std::strcmp(long_options[idx].name, "dark-theme") == 0 ) + case 't': // --dark-theme getStartOptions().dark_theme = true; + break; #if defined(__FreeBSD__) || defined(__DragonFly__) - if ( std::strcmp(long_options[idx].name, "no-esc-for-alt-meta") == 0 ) + case 'E': // --no-esc-for-alt-meta getStartOptions().meta_sends_escape = false; + break; - if ( std::strcmp(long_options[idx].name, "no-cursorstyle-change") == 0 ) + case 'C': // --no-cursorstyle-change getStartOptions().change_cursorstyle = false; + break; #elif defined(__NetBSD__) || defined(__OpenBSD__) - if ( std::strcmp(long_options[idx].name, "no-esc-for-alt-meta") == 0 ) + case 'E': // --no-esc-for-alt-meta getStartOptions().meta_sends_escape = false; + break; #endif } } diff --git a/src/fdialog.cpp b/src/fdialog.cpp index d726452c..b4c6be82 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -459,8 +459,9 @@ void FDialog::onKeyPress (FKeyEvent* ev) cancelMouseResize(); - if ( ev->key() == fc::Fckey_caret // Ctrl+^ (Ctrl+6) - || ev->key() == fc::Fkey_f22 ) // Shift+F10 + if ( ev->key() == fc::Fckey_caret // Ctrl+^ (Ctrl+6) + || ev->key() == fc::Fkey_f22 // Shift+F10 + || ev->key() == fc::Fkey_smenu ) // Shift+Menu { ev->accept(); // open the titlebar menu diff --git a/src/flog.cpp b/src/flog.cpp index 9a244551..c06e1d2c 100644 --- a/src/flog.cpp +++ b/src/flog.cpp @@ -47,6 +47,7 @@ FLog& FLog::operator << (LogLevel l) { using std::placeholders::_1; sync(); + std::lock_guard lock_guard(mut); switch ( l ) { @@ -77,6 +78,7 @@ int FLog::sync() { if ( ! str().empty() ) { + std::lock_guard lock_guard(mut); current_log (str()); str(""); } diff --git a/src/flogger.cpp b/src/flogger.cpp index d75341b3..6f1bf2a7 100644 --- a/src/flogger.cpp +++ b/src/flogger.cpp @@ -72,8 +72,10 @@ std::string FLogger::getTimeString() const } //---------------------------------------------------------------------- -std::string FLogger::getEOL() const +std::string FLogger::getEOL() { + std::lock_guard lock_guard(getMutex()); + if ( getEnding() == FLog::LF ) return "\n"; else if ( getEnding() == FLog::CR ) @@ -89,6 +91,8 @@ void FLogger::printLogLine (const std::string& msg) { const std::string& log_level = [this] () { + std::lock_guard lock_guard(getMutex()); + switch ( getLevel() ) { case Info: diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index cb57dc8a..e03f7dd2 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -256,6 +256,7 @@ void FMenuBar::init() addAccelerator (fc::Fkey_f10); addAccelerator (fc::Fckey_space); + addAccelerator (fc::Fkey_menu); resetColors(); unsetFocusable(); } diff --git a/src/fterm_functions.cpp b/src/fterm_functions.cpp index e1e42515..0d9dba11 100644 --- a/src/fterm_functions.cpp +++ b/src/fterm_functions.cpp @@ -553,15 +553,13 @@ FPoint readCursorPos() FD_SET(stdin_no, &ifds); tv.tv_sec = 0; tv.tv_usec = 100000; // 100 ms + std::array temp{}; + std::size_t pos{0}; // Read the answer if ( select (stdin_no + 1, &ifds, nullptr, nullptr, &tv) != 1 ) return FPoint{x, y}; - constexpr auto parse = "\033[%4d;%4dR"; - std::array temp{}; - std::size_t pos{0}; - do { std::size_t bytes_free = temp.size() - pos - 1; @@ -572,10 +570,13 @@ FPoint readCursorPos() pos += std::size_t(bytes); } - while ( pos < temp.size() && std::strchr(temp.data(), 'R') == nullptr ); + while ( pos < temp.size() && ! std::strchr(temp.data(), 'R') ); if ( pos > 4 ) + { + constexpr auto parse = "\033[%4d;%4dR"; std::sscanf(temp.data(), parse, &x, &y); + } return FPoint{x, y}; } diff --git a/src/ftermcap.cpp b/src/ftermcap.cpp index 372173ca..ae2f712e 100644 --- a/src/ftermcap.cpp +++ b/src/ftermcap.cpp @@ -91,7 +91,7 @@ void FTermcap::termcap() // Open termcap file #if defined(__sun) && defined(__SVR4) - char* termtype = fterm_data->getTermType(); + char* termtype = const_cast(fterm_data->getTermType()); #else const char* termtype = fterm_data->getTermType(); #endif diff --git a/src/ftermcapquirks.cpp b/src/ftermcapquirks.cpp index 07faf1bd..ca93d2a8 100644 --- a/src/ftermcapquirks.cpp +++ b/src/ftermcapquirks.cpp @@ -20,6 +20,7 @@ * . * ***********************************************************************/ +#include #include #include "final/fc.h" @@ -267,6 +268,25 @@ void FTermcapQuirks::vte() // set exit underline for gnome terminal TCAP(fc::t_exit_underline_mode) = \ CSI "24m"; + + if ( term_detection->getGnomeTerminalID() >= 5300 ) // vte >= 0.53.0 + { + if ( ! std::strstr(TCAP(fc::t_enter_ca_mode), "\033[22;0;0t") ) + { + // Save the cursor position, enter alternate screen buffer + // and save xterm icon and window title on stack + TCAP(fc::t_enter_ca_mode) = \ + CSI "?1049h" CSI "22;0;0t"; + } + + if ( ! std::strstr(TCAP(fc::t_exit_ca_mode), "\033[23;0;0t") ) + { + // Use normal screen buffer, restore the cursor position + // and restore xterm icon and window title from stack + TCAP(fc::t_exit_ca_mode) = \ + CSI "?1049l" CSI "23;0;0t"; + } + } } //---------------------------------------------------------------------- diff --git a/src/ftermdetection.cpp b/src/ftermdetection.cpp index 8eed2bd6..d4d545de 100644 --- a/src/ftermdetection.cpp +++ b/src/ftermdetection.cpp @@ -843,7 +843,7 @@ FString FTermDetection::getSecDA() pos += std::size_t(bytes); } - while ( pos < temp.size() && std::strchr(temp.data(), 'c') == nullptr ); + while ( pos < temp.size() && ! std::strchr(temp.data(), 'c') ); if ( pos > 3 && std::sscanf(temp.data(), parse, &a, &b, &c) == 3 ) sec_da_str.sprintf("\033[>%d;%d;%dc", a, b, c); diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index fd8fade7..1d574d71 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -316,9 +316,11 @@ bool FTermLinux::loadNewFont() // Set the graphical font int ret; +#if defined(ISA_SYSCTL_SUPPORT) if ( has9BitCharacters() ) ret = setScreenFont(fc::__9x16graph, 256, 8, 16); // set 9×16 else +#endif ret = setScreenFont(fc::__8x16graph, 256, 8, 16); // set 8×16 if ( ret != 0 ) diff --git a/src/ftermxterminal.cpp b/src/ftermxterminal.cpp index a73717dd..d9651dd6 100644 --- a/src/ftermxterminal.cpp +++ b/src/ftermxterminal.cpp @@ -805,7 +805,7 @@ FString FTermXTerminal::captureXTermFont() const pos += std::size_t(bytes); } - while ( pos < temp.size() && std::strchr(temp.data(), '\a') == nullptr ); + while ( pos < temp.size() && ! std::strchr(temp.data(), '\a') ); if ( pos > 5 && temp[0] == ESC[0] && temp[1] == ']' && temp[2] == '5' && temp[3] == '0' && temp[4] == ';' ) diff --git a/src/include/final/fapplication.h b/src/include/final/fapplication.h index 4a0b0d07..17bf7daa 100644 --- a/src/include/final/fapplication.h +++ b/src/include/final/fapplication.h @@ -218,6 +218,20 @@ class FApplication : public FWidget static FMouseControl* mouse; static FKeyboard* keyboard; static FWidget* keyboard_widget; + +#if defined(__sun) && defined(__SVR4) + struct CmdOption + { + const char* name; // <- name is without 'const' in Solaris + int has_arg; + int* flag; + int val; + }; +#else + using CmdOption = struct option; +#endif + + static const CmdOption long_options[]; }; diff --git a/src/include/final/flog.h b/src/include/final/flog.h index 92f0e6f9..67e6f927 100644 --- a/src/include/final/flog.h +++ b/src/include/final/flog.h @@ -42,6 +42,7 @@ #include #include +#include #include #include #include @@ -97,15 +98,17 @@ class FLog : public std::stringbuf protected: int sync() override; - const LogLevel& getLevel() const; + const LogLevel& getLevel(); LogLevel& setLevel(); - const LineEnding& getEnding() const; + const LineEnding& getEnding(); LineEnding& setEnding(); + std::mutex& getMutex(); private: // Data member LogLevel level{Info}; LineEnding end_of_line{CRLF}; + std::mutex mut; FLogPrint current_log{std::bind(&FLog::info, this, std::placeholders::_1)}; std::ostream stream{this}; @@ -118,6 +121,7 @@ class FLog : public std::stringbuf template inline FLog& FLog::operator << (const T& s) { + std::lock_guard lock_guard(mut); stream << s; return *this; } @@ -125,6 +129,7 @@ inline FLog& FLog::operator << (const T& s) //---------------------------------------------------------------------- inline FLog& FLog::operator << (IOManip pf) { + std::lock_guard lock_guard(mut); pf(stream); return *this; } @@ -134,21 +139,33 @@ inline FString FLog::getClassName() const { return "FLog"; } //---------------------------------------------------------------------- -inline const FLog::LogLevel& FLog::getLevel() const -{ return level; } +inline const FLog::LogLevel& FLog::getLevel() +{ + return level; +} //---------------------------------------------------------------------- inline FLog::LogLevel& FLog::setLevel() -{ return level; } +{ + return level; +} //---------------------------------------------------------------------- -inline const FLog::LineEnding& FLog::getEnding() const -{ return end_of_line; } +inline const FLog::LineEnding& FLog::getEnding() +{ + std::lock_guard lock_guard(mut); + return end_of_line; +} //---------------------------------------------------------------------- inline FLog::LineEnding& FLog::setEnding() -{ return end_of_line; } +{ + return end_of_line; +} +//---------------------------------------------------------------------- +inline std::mutex& FLog::getMutex() +{ return mut; } } // namespace finalcut diff --git a/src/include/final/flogger.h b/src/include/final/flogger.h index 5f0d64ea..d5caff76 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() const; + std::string getEOL(); void printLogLine (const std::string&); // Data member @@ -103,6 +103,7 @@ inline FString FLogger::getClassName() const //---------------------------------------------------------------------- inline void FLogger::info (const std::string& msg) { + std::lock_guard lock_guard(getMutex()); setLevel() = Info; printLogLine (msg); } @@ -110,6 +111,7 @@ inline void FLogger::info (const std::string& msg) //---------------------------------------------------------------------- inline void FLogger::warn (const std::string& msg) { + std::lock_guard lock_guard(getMutex()); setLevel() = Warn; printLogLine (msg); } @@ -117,6 +119,7 @@ inline void FLogger::warn (const std::string& msg) //---------------------------------------------------------------------- inline void FLogger::error (const std::string& msg) { + std::lock_guard lock_guard(getMutex()); setLevel() = Error; printLogLine (msg); } @@ -124,29 +127,45 @@ inline void FLogger::error (const std::string& msg) //---------------------------------------------------------------------- inline void FLogger::debug (const std::string& msg) { + std::lock_guard lock_guard(getMutex()); setLevel() = Debug; printLogLine (msg); } //---------------------------------------------------------------------- inline void FLogger::flush() -{ output.flush(); } +{ + std::lock_guard lock_guard(getMutex()); + output.flush(); +} //---------------------------------------------------------------------- inline void FLogger::setOutputStream (const std::ostream& os) -{ output.rdbuf(os.rdbuf()); } +{ + std::lock_guard lock_guard(getMutex()); + output.rdbuf(os.rdbuf()); +} //---------------------------------------------------------------------- inline void FLogger::setLineEnding (LineEnding eol) -{ setEnding() = eol; } +{ + std::lock_guard lock_guard(getMutex()); + setEnding() = eol; +} //---------------------------------------------------------------------- inline void FLogger::enableTimestamp() -{ timestamp = true; } +{ + std::lock_guard lock_guard(getMutex()); + timestamp = true; +} //---------------------------------------------------------------------- inline void FLogger::disableTimestamp() -{ timestamp = false; } +{ + std::lock_guard lock_guard(getMutex()); + timestamp = false; +} } // namespace finalcut From 12ec2b057433836ed8c8bfeb04b622ab7cfb76b7 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 11 Oct 2020 22:50:08 +0200 Subject: [PATCH 28/30] Refactoring of some methods --- examples/event-log.cpp | 5 +- src/fapplication.cpp | 158 +++++++++++++---------------- src/fbuttongroup.cpp | 169 +++++++++++++++++-------------- src/flistbox.cpp | 32 +++--- src/fmenubar.cpp | 2 +- src/fterm.cpp | 18 ++-- src/ftermlinux.cpp | 6 +- src/fwidget.cpp | 18 ++-- src/fwindow.cpp | 11 +- src/include/final/fapplication.h | 8 +- src/include/final/fbuttongroup.h | 4 + src/include/final/flog.h | 4 +- 12 files changed, 218 insertions(+), 217 deletions(-) diff --git a/examples/event-log.cpp b/examples/event-log.cpp index a3bd7095..0153d1d7 100644 --- a/examples/event-log.cpp +++ b/examples/event-log.cpp @@ -283,10 +283,7 @@ EventLog::EventLog (finalcut::FWidget* parent) //---------------------------------------------------------------------- EventLog::~EventLog() // destructor -{ - if ( event_dialog ) - delete event_dialog; -} +{ } //---------------------------------------------------------------------- void EventLog::onTimer (finalcut::FTimerEvent*) diff --git a/src/fapplication.cpp b/src/fapplication.cpp index 7c43f8c7..65ce075e 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -20,7 +20,6 @@ * . * ***********************************************************************/ -#include #include #include #include @@ -70,7 +69,7 @@ uInt64 FApplication::next_event_wait {5000}; // preset to 5 ms (200 struct timeval FApplication::time_last_event{}; -constexpr FApplication::CmdOption FApplication::long_options[] = +const std::vector FApplication::long_options = { {"encoding", required_argument, nullptr, 'e' }, {"log-file", required_argument, nullptr, 'l' }, @@ -485,81 +484,70 @@ void FApplication::setTerminalEncoding (const FString& enc_str) } //---------------------------------------------------------------------- -void FApplication::cmd_options (const int& argc, char* argv[]) +inline FApplication::CmdMap& FApplication::mapCmdOptions() +{ + using std::placeholders::_1; + auto enc = std::bind(&FApplication::setTerminalEncoding, _1); + auto log = std::bind(&FApplication::setLogFile, _1); + auto opt = &FApplication::getStartOptions; + static CmdMap cmd_map{}; + + // --encoding + cmd_map['e'] = [enc] (char* arg) { enc(FString(arg)); }; + // --log-file + cmd_map['l'] = [log] (char* arg) { log(FString(arg)); }; + // --no-mouse + cmd_map['m'] = [opt] (char*) { opt().mouse_support = false; }; + // --no-optimized-cursor + cmd_map['o'] = [opt] (char*) { opt().cursor_optimisation = false; }; + // --no-terminal-detection + cmd_map['d'] = [opt] (char*) { opt().terminal_detection = false; }; + // --no-terminal-data-request + cmd_map['r'] = [opt] (char*) { opt().terminal_data_request = false; }; + // --no-color-change + cmd_map['c'] = [opt] (char*) { opt().color_change = false; }; + // --no-sgr-optimizer + cmd_map['s'] = [opt] (char*) { opt().sgr_optimizer = false; }; + // --vgafont + cmd_map['v'] = [opt] (char*) { opt().vgafont = true; }; + // --newfont + cmd_map['n'] = [opt] (char*) { opt().newfont = true; }; + // --dark-theme + cmd_map['t'] = [opt] (char*) { opt().dark_theme = true; }; +#if defined(__FreeBSD__) || defined(__DragonFly__) + // --no-esc-for-alt-meta + cmd_map['E'] = [opt] (char*) { opt().meta_sends_escape = false; }; + // --no-cursorstyle-change + cmd_map['C'] = [opt] (char*) { opt().change_cursorstyle = false; }; +#elif defined(__NetBSD__) || defined(__OpenBSD__) + // --no-esc-for-alt-meta + cmd_map['E'] = [opt] (char*) { opt().meta_sends_escape = false; }; +#endif + return cmd_map; +} + +//---------------------------------------------------------------------- +void FApplication::cmdOptions (const int& argc, char* argv[]) { // Interpret the command line options + auto& cmd_map = mapCmdOptions(); + while ( true ) { opterr = 0; int idx{0}; - auto p = reinterpret_cast(long_options); + auto p = reinterpret_cast(long_options.data()); const int opt = getopt_long (argc, argv, "", p, &idx); if ( opt == -1 ) break; - switch ( opt ) - { - case 'e': // --encoding - setTerminalEncoding(FString(optarg)); - break; - - case 'l': // --log-file - setLogFile(FString(optarg)); - break; - - case 'm': // --no-mouse - getStartOptions().mouse_support = false; - break; - - case 'o': // --no-optimized-cursor - getStartOptions().cursor_optimisation = false; - break; - - case 'd': // --no-terminal-detection - getStartOptions().terminal_detection = false; - break; - - case 'r': // --no-terminal-data-request - getStartOptions().terminal_data_request = false; - break; - - case 'c': // --no-color-change - getStartOptions().color_change = false; - break; - - case 's': // --no-sgr-optimizer - getStartOptions().sgr_optimizer = false; - break; - - case 'v': // --vgafont - getStartOptions().vgafont = true; - break; - - case 'n': // --newfont - getStartOptions().newfont = true; - break; - - case 't': // --dark-theme - getStartOptions().dark_theme = true; - break; - - #if defined(__FreeBSD__) || defined(__DragonFly__) - case 'E': // --no-esc-for-alt-meta - getStartOptions().meta_sends_escape = false; - break; - - case 'C': // --no-cursorstyle-change - getStartOptions().change_cursorstyle = false; - break; - #elif defined(__NetBSD__) || defined(__OpenBSD__) - case 'E': // --no-esc-for-alt-meta - getStartOptions().meta_sends_escape = false; - break; - #endif - } + if ( cmd_map.find(opt) != cmd_map.end() ) + cmd_map[opt](optarg); } + + cmd_map.clear(); } //---------------------------------------------------------------------- @@ -848,34 +836,30 @@ bool FApplication::processAccelerator (const FWidget* const& widget) const { bool accpt{false}; - if ( widget - && ! widget->getAcceleratorList().empty() ) + if ( widget && widget->getAcceleratorList().empty() ) + return accpt; + + for (auto&& item : widget->getAcceleratorList()) { - auto iter = widget->getAcceleratorList().begin(); - const auto& last = widget->getAcceleratorList().end(); - - while ( iter != last && ! quit_now && ! app_exit_loop ) + if ( item.key == keyboard->getKey() ) { - if ( iter->key == keyboard->getKey() ) + // unset the move/size mode + auto move_size = getMoveSizeWidget(); + + if ( move_size ) { - // unset the move/size mode - auto move_size = getMoveSizeWidget(); - - if ( move_size ) - { - auto w = move_size; - setMoveSizeWidget(nullptr); - w->redraw(); - } - - FAccelEvent a_ev (fc::Accelerator_Event, getFocusWidget()); - sendEvent (iter->object, &a_ev); - accpt = a_ev.isAccepted(); - break; + setMoveSizeWidget(nullptr); + move_size->redraw(); } - ++iter; + FAccelEvent a_ev (fc::Accelerator_Event, getFocusWidget()); + sendEvent (item.object, &a_ev); + accpt = a_ev.isAccepted(); + break; } + + if ( quit_now || app_exit_loop ) + break; } return accpt; @@ -1225,7 +1209,7 @@ FWidget* FApplication::processParameters (const int& argc, char* argv[]) FApplication::exit(EXIT_SUCCESS); } - cmd_options (argc, argv); + cmdOptions (argc, argv); return nullptr; } diff --git a/src/fbuttongroup.cpp b/src/fbuttongroup.cpp index 1ae70041..85675a74 100644 --- a/src/fbuttongroup.cpp +++ b/src/fbuttongroup.cpp @@ -309,40 +309,7 @@ void FButtonGroup::onAccel (FAccelEvent*) void FButtonGroup::onFocusIn (FFocusEvent* in_ev) { in_ev->ignore(); // Change default value to ignore - - if ( hasCheckedButton() && ! buttonlist.empty() ) - { - for (auto&& item : buttonlist) - { - auto toggle_button = static_cast(item); - - if ( toggle_button->isChecked() ) - { - if ( isRadioButton(toggle_button) ) - { - auto prev_element = getFocusWidget(); - - toggle_button->setFocus(); - - FFocusEvent cfi (fc::ChildFocusIn_Event); - FApplication::sendEvent(this, &cfi); - - FFocusEvent in (fc::FocusIn_Event); - FApplication::sendEvent(toggle_button, &in); - - if ( in.isAccepted() ) - in_ev->accept(); - - if ( prev_element ) - prev_element->redraw(); - - toggle_button->redraw(); - } - - break; - } - } // end of range-based for loop - } + focusInRadioButton (in_ev); if ( ! in_ev->isAccepted() ) { @@ -483,54 +450,63 @@ void FButtonGroup::drawText ( const FString& label_text setReverse(true); } +//---------------------------------------------------------------------- +bool FButtonGroup::directFocusCheckedRadioButton (FToggleButton* item) +{ + if ( ! isRadioButton(item) ) + return false; + + auto focused_widget = getFocusWidget(); + item->setFocus(); + + if ( focused_widget ) + focused_widget->redraw(); + + focused_widget = getFocusWidget(); + + if ( focused_widget ) + focused_widget->redraw(); + + return true; +} + +//---------------------------------------------------------------------- +bool FButtonGroup::directFocusRadioButton() +{ + if ( ! hasCheckedButton() || buttonlist.empty() ) + return false; + + bool found_checked{false}; + + for (auto&& item : buttonlist) + { + auto toggle_button = static_cast(item); + + if ( toggle_button->isChecked() ) + { + found_checked = directFocusCheckedRadioButton(toggle_button); + break; + } + } + + return found_checked; +} + //---------------------------------------------------------------------- void FButtonGroup::directFocus() { - if ( ! hasFocusedButton() ) + if ( ! hasFocusedButton() && ! directFocusRadioButton() ) { - bool found_checked{false}; + auto focused_widget = getFocusWidget(); + focusFirstChild(); - if ( hasCheckedButton() && ! buttonlist.empty() ) - { - for (auto&& item : buttonlist) - { - auto toggle_button = static_cast(item); + if ( focused_widget ) + focused_widget->redraw(); - if ( toggle_button->isChecked() ) - { - if ( isRadioButton(toggle_button) ) - { - found_checked = true; - auto focused_widget = getFocusWidget(); - toggle_button->setFocus(); + focused_widget = getFocusWidget(); - if ( focused_widget ) - focused_widget->redraw(); - - focused_widget = getFocusWidget(); - - if ( focused_widget ) - focused_widget->redraw(); - } - - break; - } - } // end of range-based for loop - } - - if ( ! found_checked ) - { - auto focused_widget = getFocusWidget(); - focusFirstChild(); - - if ( focused_widget ) - focused_widget->redraw(); - - focused_widget = getFocusWidget(); - - if ( focused_widget ) - focused_widget->redraw(); - } + if ( focused_widget ) + focused_widget->redraw(); } if ( getStatusBar() ) @@ -541,6 +517,49 @@ void FButtonGroup::directFocus() } } +//---------------------------------------------------------------------- +void FButtonGroup::focusCheckedRadioButton ( FToggleButton* toggle_button + , FFocusEvent* in_ev ) +{ + auto prev_element = getFocusWidget(); + + toggle_button->setFocus(); + + FFocusEvent cfi (fc::ChildFocusIn_Event); + FApplication::sendEvent(this, &cfi); + + FFocusEvent in (fc::FocusIn_Event); + FApplication::sendEvent(toggle_button, &in); + + if ( in.isAccepted() ) + in_ev->accept(); + + if ( prev_element ) + prev_element->redraw(); + + toggle_button->redraw(); +} + +//---------------------------------------------------------------------- +void FButtonGroup::focusInRadioButton (FFocusEvent* in_ev) +{ + if ( ! hasCheckedButton() || buttonlist.empty() ) + return; + + for (auto&& item : buttonlist) + { + auto toggle_button = static_cast(item); + + if ( toggle_button->isChecked() ) + { + if ( isRadioButton(toggle_button) ) + focusCheckedRadioButton (toggle_button, in_ev); + + break; + } + } +} + //---------------------------------------------------------------------- void FButtonGroup::cb_buttonToggled (const FToggleButton* button) const { diff --git a/src/flistbox.cpp b/src/flistbox.cpp index e840233e..0d4d589b 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -1622,31 +1622,29 @@ inline bool FListBox::deletePreviousCharacter() { const std::size_t inc_len = inc_search.getLength(); - if ( inc_len > 0 ) + if ( inc_len <= 0 ) + return false; + + inc_search.remove(inc_len - 1, 1); + + if ( inc_len > 1 ) { - inc_search.remove(inc_len - 1, 1); + auto iter = itemlist.begin(); - if ( inc_len > 1 ) + while ( iter != itemlist.end() ) { - auto iter = itemlist.begin(); - - while ( iter != itemlist.end() ) + if ( inc_search.toLower() + == iter->getText().left(inc_len - 1).toLower() ) { - if ( inc_search.toLower() - == iter->getText().left(inc_len - 1).toLower() ) - { - setCurrentItem(iter); - break; - } - - ++iter; + setCurrentItem(iter); + break; } - } - return true; + ++iter; + } } - return false; + return true; } //---------------------------------------------------------------------- diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index e03f7dd2..347a20fa 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -50,7 +50,7 @@ FMenuBar::FMenuBar(FWidget* parent) //---------------------------------------------------------------------- FMenuBar::~FMenuBar() // destructor { - setMenuBar(nullptr); + FWidget::setMenuBar(nullptr); } diff --git a/src/fterm.cpp b/src/fterm.cpp index 066f4336..f4c9b047 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -713,6 +713,7 @@ bool FTerm::setVGAFont() data->setVGAFont(true); // Set font in xterm to vga getFTermXTerminal()->setFont("vga"); + data->setTermEncoding (fc::PC); data->setNewFont(false); } #if defined(__linux__) @@ -1362,13 +1363,13 @@ void FTerm::init_global_values() //---------------------------------------------------------------------- void FTerm::init_terminal_device_path() { - char termfilename[256]{}; + std::array termfilename{}; const int stdout_no = FTermios::getStdOut(); - if ( ttyname_r(stdout_no, termfilename, sizeof(termfilename)) ) + if ( ttyname_r(stdout_no, termfilename.data(), termfilename.size()) ) termfilename[0] = '\0'; - data->setTermFileName(termfilename); + data->setTermFileName(termfilename.data()); } //---------------------------------------------------------------------- @@ -2005,21 +2006,22 @@ const char* FTerm::enableCursorString() // Returns the cursor enable string static constexpr std::size_t SIZE = 32; - static char enable_str[SIZE]{}; + static std::array enable_str{}; const auto& vs = TCAP(fc::t_cursor_visible); const auto& ve = TCAP(fc::t_cursor_normal); if ( ve ) - std::strncpy (enable_str, ve, SIZE - 1); + std::strncpy (enable_str.data(), ve, SIZE - 1); else if ( vs ) - std::strncpy (enable_str, vs, SIZE - 1); + std::strncpy (enable_str.data(), vs, SIZE - 1); #if defined(__linux__) if ( isLinuxTerm() ) { // Restore the last used Linux console cursor style const char* cstyle = linux->getCursorStyleString(); - std::strncat (enable_str, cstyle, SIZE - std::strlen(enable_str) - 1); + std::size_t length = std::strlen(enable_str.data()); + std::strncat (enable_str.data(), cstyle, SIZE - length - 1); } #endif // defined(__linux__) @@ -2033,7 +2035,7 @@ const char* FTerm::enableCursorString() } #endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) - return enable_str; + return enable_str.data(); } //---------------------------------------------------------------------- diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index 1d574d71..fa1534a6 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -76,10 +76,10 @@ char* FTermLinux::getCursorStyleString() { // Gets the current cursor style string of the Linux console - static char buf[16]{}; + static std::array buf{}; std::fill (std::begin(buf), std::end(buf), '\0'); - std::snprintf (buf, sizeof(buf), CSI "?%dc", getCursorStyle()); - return buf; + std::snprintf (buf.data(), buf.size(), CSI "?%dc", getCursorStyle()); + return buf.data(); } //---------------------------------------------------------------------- diff --git a/src/fwidget.cpp b/src/fwidget.cpp index 5dfb4856..279f9c8c 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -966,13 +966,10 @@ void FWidget::show() { for (auto&& child : getChildren()) { - if ( child->isWidget() ) - { - auto widget = static_cast(child); + auto widget = static_cast(child); - if ( ! widget->flags.hidden ) - widget->show(); - } + if ( child->isWidget() && ! widget->flags.hidden ) + widget->show(); } } @@ -1316,13 +1313,10 @@ void FWidget::adjustSize() { for (auto&& child : getChildren()) { - if ( child->isWidget() ) - { - auto widget = static_cast(child); + auto widget = static_cast(child); - if ( ! widget->isWindowWidget() ) - widget->adjustSize(); - } + if ( child->isWidget() && ! widget->isWindowWidget() ) + widget->adjustSize(); } } } diff --git a/src/fwindow.cpp b/src/fwindow.cpp index 5d005844..b1b50c8d 100644 --- a/src/fwindow.cpp +++ b/src/fwindow.cpp @@ -437,13 +437,12 @@ FWindow* FWindow::getWindowWidgetAt (int x, int y) do { --iter; - if ( *iter ) - { - auto w = static_cast(*iter); + auto w = static_cast(*iter); - if ( ! w->isWindowHidden() - && w->getTermGeometry().contains(x, y) ) - return w; + if ( *iter && ! w->isWindowHidden() + && w->getTermGeometry().contains(x, y) ) + { + return w; } } while ( iter != begin ); diff --git a/src/include/final/fapplication.h b/src/include/final/fapplication.h index 17bf7daa..e9803d9d 100644 --- a/src/include/final/fapplication.h +++ b/src/include/final/fapplication.h @@ -64,6 +64,8 @@ #include #include #include +#include +#include #include "final/ftypes.h" #include "final/fwidget.h" @@ -151,11 +153,13 @@ class FApplication : public FWidget // Typedefs typedef std::pair EventPair; typedef std::deque FEventQueue; + typedef std::unordered_map> CmdMap; // Methods void init(); static void setTerminalEncoding (const FString&); - static void cmd_options (const int&, char*[]); + static CmdMap& mapCmdOptions(); + static void cmdOptions (const int&, char*[]); static FStartOptions& getStartOptions(); static void showParameterUsage(); void destroyLog(); @@ -231,7 +235,7 @@ class FApplication : public FWidget using CmdOption = struct option; #endif - static const CmdOption long_options[]; + static const std::vector long_options; }; diff --git a/src/include/final/fbuttongroup.h b/src/include/final/fbuttongroup.h index 410f186a..65a0c6b8 100644 --- a/src/include/final/fbuttongroup.h +++ b/src/include/final/fbuttongroup.h @@ -127,7 +127,11 @@ class FButtonGroup : public FScrollView // Methods void init(); void drawText (const FString&, std::size_t); + bool directFocusCheckedRadioButton (FToggleButton*); + bool directFocusRadioButton(); void directFocus(); + void focusCheckedRadioButton (FToggleButton*, FFocusEvent*); + void focusInRadioButton (FFocusEvent*); // Callback method void cb_buttonToggled (const FToggleButton*) const; diff --git a/src/include/final/flog.h b/src/include/final/flog.h index 67e6f927..ffc5b56f 100644 --- a/src/include/final/flog.h +++ b/src/include/final/flog.h @@ -98,7 +98,7 @@ class FLog : public std::stringbuf protected: int sync() override; - const LogLevel& getLevel(); + const LogLevel& getLevel() const; LogLevel& setLevel(); const LineEnding& getEnding(); LineEnding& setEnding(); @@ -139,7 +139,7 @@ inline FString FLog::getClassName() const { return "FLog"; } //---------------------------------------------------------------------- -inline const FLog::LogLevel& FLog::getLevel() +inline const FLog::LogLevel& FLog::getLevel() const { return level; } From 493b1231fdd21d965819df0c4d8304f062eb9dc1 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Sun, 11 Oct 2020 23:22:53 +0200 Subject: [PATCH 29/30] Small fixes --- src/fapplication.cpp | 30 +++++++++++++++--------------- src/fbuttongroup.cpp | 2 +- src/flistbox.cpp | 2 +- src/include/final/fbuttongroup.h | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/fapplication.cpp b/src/fapplication.cpp index 65ce075e..b4170ee9 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -493,35 +493,35 @@ inline FApplication::CmdMap& FApplication::mapCmdOptions() static CmdMap cmd_map{}; // --encoding - cmd_map['e'] = [enc] (char* arg) { enc(FString(arg)); }; + cmd_map['e'] = [enc] (const char* arg) { enc(FString(arg)); }; // --log-file - cmd_map['l'] = [log] (char* arg) { log(FString(arg)); }; + cmd_map['l'] = [log] (const char* arg) { log(FString(arg)); }; // --no-mouse - cmd_map['m'] = [opt] (char*) { opt().mouse_support = false; }; + cmd_map['m'] = [opt] (const char*) { opt().mouse_support = false; }; // --no-optimized-cursor - cmd_map['o'] = [opt] (char*) { opt().cursor_optimisation = false; }; + cmd_map['o'] = [opt] (const char*) { opt().cursor_optimisation = false; }; // --no-terminal-detection - cmd_map['d'] = [opt] (char*) { opt().terminal_detection = false; }; + cmd_map['d'] = [opt] (const char*) { opt().terminal_detection = false; }; // --no-terminal-data-request - cmd_map['r'] = [opt] (char*) { opt().terminal_data_request = false; }; + cmd_map['r'] = [opt] (const char*) { opt().terminal_data_request = false; }; // --no-color-change - cmd_map['c'] = [opt] (char*) { opt().color_change = false; }; + cmd_map['c'] = [opt] (const char*) { opt().color_change = false; }; // --no-sgr-optimizer - cmd_map['s'] = [opt] (char*) { opt().sgr_optimizer = false; }; + cmd_map['s'] = [opt] (const char*) { opt().sgr_optimizer = false; }; // --vgafont - cmd_map['v'] = [opt] (char*) { opt().vgafont = true; }; + cmd_map['v'] = [opt] (const char*) { opt().vgafont = true; }; // --newfont - cmd_map['n'] = [opt] (char*) { opt().newfont = true; }; + cmd_map['n'] = [opt] (const char*) { opt().newfont = true; }; // --dark-theme - cmd_map['t'] = [opt] (char*) { opt().dark_theme = true; }; + cmd_map['t'] = [opt] (const char*) { opt().dark_theme = true; }; #if defined(__FreeBSD__) || defined(__DragonFly__) // --no-esc-for-alt-meta - cmd_map['E'] = [opt] (char*) { opt().meta_sends_escape = false; }; + cmd_map['E'] = [opt] (const char*) { opt().meta_sends_escape = false; }; // --no-cursorstyle-change - cmd_map['C'] = [opt] (char*) { opt().change_cursorstyle = false; }; + cmd_map['C'] = [opt] (const char*) { opt().change_cursorstyle = false; }; #elif defined(__NetBSD__) || defined(__OpenBSD__) // --no-esc-for-alt-meta - cmd_map['E'] = [opt] (char*) { opt().meta_sends_escape = false; }; + cmd_map['E'] = [opt] (const char*) { opt().meta_sends_escape = false; }; #endif return cmd_map; } @@ -836,7 +836,7 @@ bool FApplication::processAccelerator (const FWidget* const& widget) const { bool accpt{false}; - if ( widget && widget->getAcceleratorList().empty() ) + if ( widget || widget->getAcceleratorList().empty() ) return accpt; for (auto&& item : widget->getAcceleratorList()) diff --git a/src/fbuttongroup.cpp b/src/fbuttongroup.cpp index 85675a74..fa695dcd 100644 --- a/src/fbuttongroup.cpp +++ b/src/fbuttongroup.cpp @@ -451,7 +451,7 @@ void FButtonGroup::drawText ( const FString& label_text } //---------------------------------------------------------------------- -bool FButtonGroup::directFocusCheckedRadioButton (FToggleButton* item) +bool FButtonGroup::directFocusCheckedRadioButton (FToggleButton* item) const { if ( ! isRadioButton(item) ) return false; diff --git a/src/flistbox.cpp b/src/flistbox.cpp index 0d4d589b..c3eb068a 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -1622,7 +1622,7 @@ inline bool FListBox::deletePreviousCharacter() { const std::size_t inc_len = inc_search.getLength(); - if ( inc_len <= 0 ) + if ( inc_len == 0 ) return false; inc_search.remove(inc_len - 1, 1); diff --git a/src/include/final/fbuttongroup.h b/src/include/final/fbuttongroup.h index 65a0c6b8..923dbff7 100644 --- a/src/include/final/fbuttongroup.h +++ b/src/include/final/fbuttongroup.h @@ -127,7 +127,7 @@ class FButtonGroup : public FScrollView // Methods void init(); void drawText (const FString&, std::size_t); - bool directFocusCheckedRadioButton (FToggleButton*); + bool directFocusCheckedRadioButton (FToggleButton*) const; bool directFocusRadioButton(); void directFocus(); void focusCheckedRadioButton (FToggleButton*, FFocusEvent*); From 8d189e9ec439ff90e8421eb4088d67eea34d917e Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Mon, 12 Oct 2020 00:01:11 +0200 Subject: [PATCH 30/30] Small fix-up --- src/fapplication.cpp | 2 +- src/fbuttongroup.cpp | 2 +- src/include/final/fbuttongroup.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fapplication.cpp b/src/fapplication.cpp index b4170ee9..e2c80028 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -836,7 +836,7 @@ bool FApplication::processAccelerator (const FWidget* const& widget) const { bool accpt{false}; - if ( widget || widget->getAcceleratorList().empty() ) + if ( ! widget || widget->getAcceleratorList().empty() ) return accpt; for (auto&& item : widget->getAcceleratorList()) diff --git a/src/fbuttongroup.cpp b/src/fbuttongroup.cpp index fa695dcd..0d9c3362 100644 --- a/src/fbuttongroup.cpp +++ b/src/fbuttongroup.cpp @@ -471,7 +471,7 @@ bool FButtonGroup::directFocusCheckedRadioButton (FToggleButton* item) const } //---------------------------------------------------------------------- -bool FButtonGroup::directFocusRadioButton() +bool FButtonGroup::directFocusRadioButton() const { if ( ! hasCheckedButton() || buttonlist.empty() ) return false; diff --git a/src/include/final/fbuttongroup.h b/src/include/final/fbuttongroup.h index 923dbff7..d2c59f0c 100644 --- a/src/include/final/fbuttongroup.h +++ b/src/include/final/fbuttongroup.h @@ -128,7 +128,7 @@ class FButtonGroup : public FScrollView void init(); void drawText (const FString&, std::size_t); bool directFocusCheckedRadioButton (FToggleButton*) const; - bool directFocusRadioButton(); + bool directFocusRadioButton() const; void directFocus(); void focusCheckedRadioButton (FToggleButton*, FFocusEvent*); void focusInRadioButton (FFocusEvent*);