diff --git a/README.md b/README.md index 71c36dfb..74c793ef 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ The calculator example in newfont mode: Benchmark --------- -Here you can find a test for ![measuring the character speed](doc/benchmark.md) in the terminal. +Here you can find a test for ![measuring the character speed](doc/benchmark.md#benchmark) in the terminal. Virtual terminal diff --git a/doc/coding-style.txt b/doc/coding-style.txt index 649825d4..726a5f2e 100644 --- a/doc/coding-style.txt +++ b/doc/coding-style.txt @@ -14,7 +14,7 @@ Formatting Naming ------ -* class name: upperCamelCase +* class name: UpperCamelCase * Function: lowerCamelCase * Callback function: cb_lowerCamelCase (beginning with "cb_" as prefix) * Variable: lower_case_underscored diff --git a/examples/rotozoomer.cpp b/examples/rotozoomer.cpp index d2fca73b..276a17d4 100644 --- a/examples/rotozoomer.cpp +++ b/examples/rotozoomer.cpp @@ -79,10 +79,10 @@ class RotoZoomer : public finalcut::FDialog //---------------------------------------------------------------------- -RotoZoomer::RotoZoomer (finalcut::FWidget* parent, bool b, int i) +RotoZoomer::RotoZoomer (finalcut::FWidget* parent, bool b, int l) : finalcut::FDialog(parent) , benchmark(b) - , loops(i) + , loops(l) { setText ("Rotozoomer effect"); @@ -186,7 +186,7 @@ void RotoZoomer::generateReport() std::wostringstream rep; dimension_str << getDesktopWidth() << "x" << getDesktopHeight(); - int elapsed_ms = duration_cast(end - start).count(); + int elapsed_ms = int(duration_cast(end - start).count()); time_str << double(elapsed_ms) / 1000 << "ms"; fps_str << double(loops) * 1000.0 / double(elapsed_ms); diff --git a/fonts/bdfmerge.sh b/fonts/bdfmerge.sh index 0c94ab89..e013dbf9 100755 --- a/fonts/bdfmerge.sh +++ b/fonts/bdfmerge.sh @@ -36,7 +36,7 @@ function replacementFound () if [ $# != 2 ] then - echo "usage: $(basename $0) font1.bdf font2.bdf > newfont.bdf" + echo "usage: $(basename "$0") font1.bdf font2.bdf > newfont.bdf" exit 1 fi diff --git a/src/fapplication.cpp b/src/fapplication.cpp index d868ee04..dadec438 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -1138,7 +1138,7 @@ void FApplication::processResizeEvent() //---------------------------------------------------------------------- void FApplication::processCloseWidget() { - updateTerminal (FVTerm::stop_refresh); + setTerminalUpdates (FVTerm::stop_terminal_updates); if ( getWidgetCloseList() && ! getWidgetCloseList()->empty() ) { @@ -1153,7 +1153,7 @@ void FApplication::processCloseWidget() getWidgetCloseList()->clear(); } - updateTerminal (FVTerm::start_refresh); + setTerminalUpdates (FVTerm::start_terminal_updates); } //---------------------------------------------------------------------- diff --git a/src/fkeyboard.cpp b/src/fkeyboard.cpp index e71537b0..b27e0f62 100644 --- a/src/fkeyboard.cpp +++ b/src/fkeyboard.cpp @@ -124,7 +124,7 @@ bool FKeyboard::isKeyPressed() FD_ZERO(&ifds); FD_SET(stdin_no, &ifds); tv.tv_sec = 0; - tv.tv_usec = FKeyboard::read_blocking_time; // preset to 100 ms + tv.tv_usec = suseconds_t(FKeyboard::read_blocking_time); // preset to 100 ms const int result = select (stdin_no + 1, &ifds, nullptr, nullptr, &tv); if ( result > 0 && FD_ISSET(stdin_no, &ifds) ) diff --git a/src/flistview.cpp b/src/flistview.cpp index 1c1ed2d2..4688adca 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -41,9 +41,6 @@ namespace finalcut { -// Static class attribute -FObject::iterator FListView::null_iter; - // Function prototypes uInt64 firstNumberFromString (const FString&); bool sortAscendingByName (const FObject*, const FObject*); @@ -298,7 +295,7 @@ FObject::iterator FListViewItem::insert (FListViewItem* child) { // Add a FListViewItem as child element if ( ! child ) - return FListView::null_iter; + return FListView::getNullIterator(); return appendItem(child); } @@ -307,8 +304,8 @@ FObject::iterator FListViewItem::insert (FListViewItem* child) FObject::iterator FListViewItem::insert ( FListViewItem* child , iterator parent_iter ) { - if ( parent_iter == FListView::null_iter ) - return FListView::null_iter; + if ( parent_iter == FListView::getNullIterator() ) + return FListView::getNullIterator(); if ( *parent_iter ) { @@ -326,13 +323,13 @@ FObject::iterator FListViewItem::insert ( FListViewItem* child } } - return FListView::null_iter; + return FListView::getNullIterator(); } //---------------------------------------------------------------------- void FListViewItem::remove (FListViewItem* item) { - if ( item == nullptr || item == *FListView::null_iter ) + if ( item == nullptr || item == *FListView::getNullIterator() ) return; auto parent = item->getParent(); @@ -816,8 +813,8 @@ FObject::iterator FListView::insert ( FListViewItem* item { iterator item_iter; - if ( parent_iter == FListView::null_iter ) - return FListView::null_iter; + if ( parent_iter == getNullIterator() ) + return getNullIterator(); beforeInsertion(item); // preprocessing @@ -840,10 +837,10 @@ FObject::iterator FListView::insert ( FListViewItem* item item_iter = parent->appendItem (item); } else - item_iter = FListView::null_iter; + item_iter = getNullIterator(); } else - item_iter = FListView::null_iter; + item_iter = getNullIterator(); afterInsertion(); // post-processing return item_iter; @@ -856,20 +853,20 @@ FObject::iterator FListView::insert ( const FStringList& cols { FListViewItem* item; - if ( cols.empty() || parent_iter == FListView::null_iter ) - return FListView::null_iter; + if ( cols.empty() || parent_iter == getNullIterator() ) + return getNullIterator(); if ( ! *parent_iter ) parent_iter = root; try { - item = new FListViewItem (cols, d, FListView::null_iter); + item = new FListViewItem (cols, d, getNullIterator()); } catch (const std::bad_alloc& ex) { std::cerr << bad_alloc_str << ex.what() << std::endl; - return FListView::null_iter; + return getNullIterator(); } item->replaceControlCodes(); @@ -933,9 +930,9 @@ void FListView::remove (FListViewItem* item) if ( itemlist.empty() ) { - current_iter = FListView::null_iter; - first_visible_line = FListView::null_iter; - last_visible_line = FListView::null_iter; + current_iter = getNullIterator(); + first_visible_line = getNullIterator(); + last_visible_line = getNullIterator(); clearList(); } else @@ -951,9 +948,9 @@ void FListView::remove (FListViewItem* item) void FListView::clear() { itemlist.clear(); - current_iter = FListView::null_iter; - first_visible_line = FListView::null_iter; - last_visible_line = FListView::null_iter; + current_iter = getNullIterator(); + first_visible_line = getNullIterator(); + last_visible_line = getNullIterator(); recalculateVerticalBar (0); first_line_position_before = -1; xoffset = 0; @@ -1451,6 +1448,19 @@ void FListView::adjustSize() // private methods of FListView +//---------------------------------------------------------------------- +FObject::iterator& FListView::getNullIterator() +{ + static iterator null_iter; // Saves the global null iterator + return null_iter; +} + +//---------------------------------------------------------------------- +void FListView::setNullIterator (iterator& null_iter) +{ + getNullIterator() = null_iter; +} + //---------------------------------------------------------------------- void FListView::init() { @@ -1458,7 +1468,7 @@ void FListView::init() initScrollbar (hbar, fc::horizontal, this, &FListView::cb_hbarChange); selflist.push_back(this); root = selflist.begin(); - null_iter = selflist.end(); + getNullIterator() = selflist.end(); setGeometry (FPoint(1, 1), FSize(5, 4), false); // initialize geometry values const auto& wc = getFWidgetColors(); setForegroundColor (wc.dialog_fg); @@ -1554,14 +1564,14 @@ FObject::iterator FListView::getListEnd (FListViewItem* item) auto parent = item->getParent(); if ( ! parent ) - return null_iter; + return getNullIterator(); if ( this == parent ) return itemlist.end(); else if ( parent->isInstanceOf("FListViewItem") ) return static_cast(parent)->end(); else - return null_iter; + return getNullIterator(); } //---------------------------------------------------------------------- diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index ca04221a..3dfe7b65 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -305,7 +305,7 @@ bool FMenuBar::selectNextItem() if ( next == *iter ) return false; - updateTerminal (FVTerm::stop_refresh); + setTerminalUpdates (FVTerm::stop_terminal_updates); unselectItem(); next->setSelected(); setSelectedItem(next); @@ -328,7 +328,7 @@ bool FMenuBar::selectNextItem() getStatusBar()->drawMessage(); redraw(); - updateTerminal (FVTerm::start_refresh); + setTerminalUpdates (FVTerm::start_terminal_updates); break; } @@ -369,7 +369,7 @@ bool FMenuBar::selectPrevItem() if ( prev == *iter ) return false; - updateTerminal (FVTerm::stop_refresh); + setTerminalUpdates (FVTerm::stop_terminal_updates); unselectItem(); prev->setSelected(); prev->setFocus(); @@ -392,7 +392,7 @@ bool FMenuBar::selectPrevItem() setSelectedItem(prev); redraw(); - updateTerminal (FVTerm::stop_refresh); + setTerminalUpdates (FVTerm::stop_terminal_updates); break; } } diff --git a/src/fmouse.cpp b/src/fmouse.cpp index 7f135a43..a4c0281e 100644 --- a/src/fmouse.cpp +++ b/src/fmouse.cpp @@ -527,7 +527,7 @@ int FMouseGPM::gpmEvent (bool clear) FD_SET(stdin_no, &ifds); FD_SET(gpm_fd, &ifds); tv.tv_sec = 0; - tv.tv_usec = FKeyboard::getReadBlockingTime(); // preset to 100 ms + tv.tv_usec = suseconds_t(FKeyboard::getReadBlockingTime()); // preset to 100 ms const int result = select (max + 1, &ifds, nullptr, nullptr, &tv); if ( result > 0 && FD_ISSET(stdin_no, &ifds) ) diff --git a/src/fvterm.cpp b/src/fvterm.cpp index ebd13121..f18b116f 100644 --- a/src/fvterm.cpp +++ b/src/fvterm.cpp @@ -52,7 +52,7 @@ static FVTerm* init_object{nullptr}; bool FVTerm::terminal_update_complete{false}; bool FVTerm::terminal_update_pending{false}; bool FVTerm::force_terminal_update{false}; -bool FVTerm::stop_terminal_updates{false}; +bool FVTerm::no_terminal_updates{false}; int FVTerm::skipped_terminal_update{}; uInt FVTerm::erase_char_length{}; uInt FVTerm::repeat_char_length{}; @@ -148,6 +148,24 @@ void FVTerm::setTermXY (int x, int y) term_pos->setPoint(x, y); } +//---------------------------------------------------------------------- +void FVTerm::setTerminalUpdates (terminal_update refresh_state) +{ + switch ( refresh_state ) + { + case stop_terminal_updates: + no_terminal_updates = true; + break; + + case continue_terminal_updates: + case start_terminal_updates: + no_terminal_updates = false; + } + + if ( refresh_state == start_terminal_updates ) + updateTerminal(); +} + //---------------------------------------------------------------------- void FVTerm::hideCursor (bool enable) { @@ -227,30 +245,12 @@ void FVTerm::putVTerm() updateTerminal(); } -//---------------------------------------------------------------------- -void FVTerm::updateTerminal (terminal_update refresh_state) -{ - switch ( refresh_state ) - { - case stop_refresh: - stop_terminal_updates = true; - break; - - case continue_refresh: - case start_refresh: - stop_terminal_updates = false; - } - - if ( refresh_state == start_refresh ) - updateTerminal(); -} - //---------------------------------------------------------------------- void FVTerm::updateTerminal() { // Updates pending changes to the terminal - if ( stop_terminal_updates + if ( no_terminal_updates || FApplication::getApplicationObject()->isQuit() ) return; diff --git a/src/fwindow.cpp b/src/fwindow.cpp index ce59fee9..00b3c7f2 100644 --- a/src/fwindow.cpp +++ b/src/fwindow.cpp @@ -676,7 +676,7 @@ void FWindow::switchToPrevWindow (FWidget* widget) // Disable terminal updates to avoid flickering // when redrawing the focused widget if ( widget ) - widget->updateTerminal (FVTerm::stop_refresh); + widget->setTerminalUpdates (FVTerm::stop_terminal_updates); const bool is_activated = activatePrevWindow(); auto active_win = static_cast(getActiveWindow()); @@ -726,7 +726,7 @@ void FWindow::switchToPrevWindow (FWidget* widget) // Enable terminal updates again if ( widget ) - widget->updateTerminal (FVTerm::continue_refresh); + widget->setTerminalUpdates (FVTerm::continue_terminal_updates); } //---------------------------------------------------------------------- diff --git a/src/include/final/flistview.h b/src/include/final/flistview.h index 43c6a383..05bafd44 100644 --- a/src/include/final/flistview.h +++ b/src/include/final/flistview.h @@ -348,9 +348,6 @@ class FListView : public FWidget void onFocusIn (FFocusEvent*) override; void onFocusOut (FFocusEvent*) override; - // Data members - static iterator null_iter; - protected: // Methods void adjustViewport (const int); @@ -373,6 +370,12 @@ class FListView : public FWidget // Constants static constexpr int USE_MAX_SIZE = -1; + // Accessors + static iterator& getNullIterator(); + + // Mutators + static void setNullIterator (iterator&); + // Inquiry bool isHorizontallyScrollable(); bool isVerticallyScrollable(); diff --git a/src/include/final/fvterm.h b/src/include/final/fvterm.h index 2d7ad947..b18dabd1 100644 --- a/src/include/final/fvterm.h +++ b/src/include/final/fvterm.h @@ -117,9 +117,9 @@ class FVTerm enum terminal_update { - stop_refresh, - continue_refresh, - start_refresh + stop_terminal_updates, // No terminal refresh + continue_terminal_updates, // Resuming terminal refresh + start_terminal_updates // Allowing terminal refresh }; // Constructor @@ -164,10 +164,12 @@ class FVTerm // Mutators void setTermXY (int, int); + void setTerminalUpdates (terminal_update); void hideCursor (bool); void hideCursor(); void showCursor(); void setPrintCursor (const FPoint&); + FColor rgb2ColorIndex (uInt8, uInt8, uInt8); static void setColor (FColor, FColor); static void setNormal(); @@ -293,7 +295,6 @@ class FVTerm void createVTerm (const FSize&); void resizeVTerm (const FSize&); void putVTerm(); - void updateTerminal (terminal_update); void updateTerminal(); virtual void addPreprocessingHandler ( FVTerm* , FPreprocessingFunction ); @@ -496,7 +497,7 @@ class FVTerm static bool terminal_update_complete; static bool terminal_update_pending; static bool force_terminal_update; - static bool stop_terminal_updates; + static bool no_terminal_updates; static int skipped_terminal_update; static uInt erase_char_length; static uInt repeat_char_length; diff --git a/test/ftermdetection-test.cpp b/test/ftermdetection-test.cpp index 9fe72b56..2524def6 100644 --- a/test/ftermdetection-test.cpp +++ b/test/ftermdetection-test.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2018-2019 Markus Gans * +* Copyright 2018-2020 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -1482,7 +1482,6 @@ void FTermDetectionTest::ttytypeTest() ttytype << "vt100" << "\t" << "ttyp6" << std::endl; ttytype.close(); - finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); finalcut::FTermDetection detect; detect.setTerminalDetection(true); detect.setTtyTypeFileName(C_STR("new-root-dir/etc/ttytype")); @@ -1501,6 +1500,7 @@ void FTermDetectionTest::ttytypeTest() unsetenv("KONSOLE_DBUS_SESSION"); unsetenv("KONSOLE_DCOP"); unsetenv("TMUX"); + finalcut::FTermData& data = *finalcut::FTerm::getFTermData(); // Test /dev/tty3 with linux data.setTermFileName(C_STR("/dev/tty3")); diff --git a/test/ftermlinux-test.cpp b/test/ftermlinux-test.cpp index 6974c5da..a17c3e9d 100644 --- a/test/ftermlinux-test.cpp +++ b/test/ftermlinux-test.cpp @@ -3,7 +3,7 @@ * * * This file is part of the Final Cut widget toolkit * * * -* Copyright 2019 Markus Gans * +* Copyright 2019-2020 Markus Gans * * * * The Final Cut is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -1416,8 +1416,8 @@ void FSystemTest::initVScreenInfo() fb_terminal_info.blue.length = 8; fb_terminal_info.blue.msb_right = 0; fb_terminal_info.transp.offset = 0; - fb_terminal_info.blue.length = 0; - fb_terminal_info.blue.msb_right = 0; + fb_terminal_info.transp.length = 0; + fb_terminal_info.transp.msb_right = 0; fb_terminal_info.nonstd = 0; fb_terminal_info.activate = 0; fb_terminal_info.height = 0xffffffff;