Minor bug fixes

This commit is contained in:
Markus Gans 2020-04-02 09:59:34 +02:00
parent a1b31179c2
commit 53f1059312
15 changed files with 88 additions and 74 deletions

View File

@ -79,7 +79,7 @@ The calculator example in newfont mode:
Benchmark 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 Virtual terminal

View File

@ -14,7 +14,7 @@ Formatting
Naming Naming
------ ------
* class name: upperCamelCase * class name: UpperCamelCase
* Function: lowerCamelCase * Function: lowerCamelCase
* Callback function: cb_lowerCamelCase (beginning with "cb_" as prefix) * Callback function: cb_lowerCamelCase (beginning with "cb_" as prefix)
* Variable: lower_case_underscored * Variable: lower_case_underscored

View File

@ -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) : finalcut::FDialog(parent)
, benchmark(b) , benchmark(b)
, loops(i) , loops(l)
{ {
setText ("Rotozoomer effect"); setText ("Rotozoomer effect");
@ -186,7 +186,7 @@ void RotoZoomer::generateReport()
std::wostringstream rep; std::wostringstream rep;
dimension_str << getDesktopWidth() dimension_str << getDesktopWidth()
<< "x" << getDesktopHeight(); << "x" << getDesktopHeight();
int elapsed_ms = duration_cast<milliseconds>(end - start).count(); int elapsed_ms = int(duration_cast<milliseconds>(end - start).count());
time_str << double(elapsed_ms) / 1000 << "ms"; time_str << double(elapsed_ms) / 1000 << "ms";
fps_str << double(loops) * 1000.0 / double(elapsed_ms); fps_str << double(loops) * 1000.0 / double(elapsed_ms);

View File

@ -36,7 +36,7 @@ function replacementFound ()
if [ $# != 2 ] if [ $# != 2 ]
then then
echo "usage: $(basename $0) font1.bdf font2.bdf > newfont.bdf" echo "usage: $(basename "$0") font1.bdf font2.bdf > newfont.bdf"
exit 1 exit 1
fi fi

View File

@ -1138,7 +1138,7 @@ void FApplication::processResizeEvent()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::processCloseWidget() void FApplication::processCloseWidget()
{ {
updateTerminal (FVTerm::stop_refresh); setTerminalUpdates (FVTerm::stop_terminal_updates);
if ( getWidgetCloseList() && ! getWidgetCloseList()->empty() ) if ( getWidgetCloseList() && ! getWidgetCloseList()->empty() )
{ {
@ -1153,7 +1153,7 @@ void FApplication::processCloseWidget()
getWidgetCloseList()->clear(); getWidgetCloseList()->clear();
} }
updateTerminal (FVTerm::start_refresh); setTerminalUpdates (FVTerm::start_terminal_updates);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -124,7 +124,7 @@ bool FKeyboard::isKeyPressed()
FD_ZERO(&ifds); FD_ZERO(&ifds);
FD_SET(stdin_no, &ifds); FD_SET(stdin_no, &ifds);
tv.tv_sec = 0; 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); const int result = select (stdin_no + 1, &ifds, nullptr, nullptr, &tv);
if ( result > 0 && FD_ISSET(stdin_no, &ifds) ) if ( result > 0 && FD_ISSET(stdin_no, &ifds) )

View File

@ -41,9 +41,6 @@
namespace finalcut namespace finalcut
{ {
// Static class attribute
FObject::iterator FListView::null_iter;
// Function prototypes // Function prototypes
uInt64 firstNumberFromString (const FString&); uInt64 firstNumberFromString (const FString&);
bool sortAscendingByName (const FObject*, const FObject*); bool sortAscendingByName (const FObject*, const FObject*);
@ -298,7 +295,7 @@ FObject::iterator FListViewItem::insert (FListViewItem* child)
{ {
// Add a FListViewItem as child element // Add a FListViewItem as child element
if ( ! child ) if ( ! child )
return FListView::null_iter; return FListView::getNullIterator();
return appendItem(child); return appendItem(child);
} }
@ -307,8 +304,8 @@ FObject::iterator FListViewItem::insert (FListViewItem* child)
FObject::iterator FListViewItem::insert ( FListViewItem* child FObject::iterator FListViewItem::insert ( FListViewItem* child
, iterator parent_iter ) , iterator parent_iter )
{ {
if ( parent_iter == FListView::null_iter ) if ( parent_iter == FListView::getNullIterator() )
return FListView::null_iter; return FListView::getNullIterator();
if ( *parent_iter ) 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) void FListViewItem::remove (FListViewItem* item)
{ {
if ( item == nullptr || item == *FListView::null_iter ) if ( item == nullptr || item == *FListView::getNullIterator() )
return; return;
auto parent = item->getParent(); auto parent = item->getParent();
@ -816,8 +813,8 @@ FObject::iterator FListView::insert ( FListViewItem* item
{ {
iterator item_iter; iterator item_iter;
if ( parent_iter == FListView::null_iter ) if ( parent_iter == getNullIterator() )
return FListView::null_iter; return getNullIterator();
beforeInsertion(item); // preprocessing beforeInsertion(item); // preprocessing
@ -840,10 +837,10 @@ FObject::iterator FListView::insert ( FListViewItem* item
item_iter = parent->appendItem (item); item_iter = parent->appendItem (item);
} }
else else
item_iter = FListView::null_iter; item_iter = getNullIterator();
} }
else else
item_iter = FListView::null_iter; item_iter = getNullIterator();
afterInsertion(); // post-processing afterInsertion(); // post-processing
return item_iter; return item_iter;
@ -856,20 +853,20 @@ FObject::iterator FListView::insert ( const FStringList& cols
{ {
FListViewItem* item; FListViewItem* item;
if ( cols.empty() || parent_iter == FListView::null_iter ) if ( cols.empty() || parent_iter == getNullIterator() )
return FListView::null_iter; return getNullIterator();
if ( ! *parent_iter ) if ( ! *parent_iter )
parent_iter = root; parent_iter = root;
try try
{ {
item = new FListViewItem (cols, d, FListView::null_iter); item = new FListViewItem (cols, d, getNullIterator());
} }
catch (const std::bad_alloc& ex) catch (const std::bad_alloc& ex)
{ {
std::cerr << bad_alloc_str << ex.what() << std::endl; std::cerr << bad_alloc_str << ex.what() << std::endl;
return FListView::null_iter; return getNullIterator();
} }
item->replaceControlCodes(); item->replaceControlCodes();
@ -933,9 +930,9 @@ void FListView::remove (FListViewItem* item)
if ( itemlist.empty() ) if ( itemlist.empty() )
{ {
current_iter = FListView::null_iter; current_iter = getNullIterator();
first_visible_line = FListView::null_iter; first_visible_line = getNullIterator();
last_visible_line = FListView::null_iter; last_visible_line = getNullIterator();
clearList(); clearList();
} }
else else
@ -951,9 +948,9 @@ void FListView::remove (FListViewItem* item)
void FListView::clear() void FListView::clear()
{ {
itemlist.clear(); itemlist.clear();
current_iter = FListView::null_iter; current_iter = getNullIterator();
first_visible_line = FListView::null_iter; first_visible_line = getNullIterator();
last_visible_line = FListView::null_iter; last_visible_line = getNullIterator();
recalculateVerticalBar (0); recalculateVerticalBar (0);
first_line_position_before = -1; first_line_position_before = -1;
xoffset = 0; xoffset = 0;
@ -1451,6 +1448,19 @@ void FListView::adjustSize()
// private methods of FListView // 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() void FListView::init()
{ {
@ -1458,7 +1468,7 @@ void FListView::init()
initScrollbar (hbar, fc::horizontal, this, &FListView::cb_hbarChange); initScrollbar (hbar, fc::horizontal, this, &FListView::cb_hbarChange);
selflist.push_back(this); selflist.push_back(this);
root = selflist.begin(); root = selflist.begin();
null_iter = selflist.end(); getNullIterator() = selflist.end();
setGeometry (FPoint(1, 1), FSize(5, 4), false); // initialize geometry values setGeometry (FPoint(1, 1), FSize(5, 4), false); // initialize geometry values
const auto& wc = getFWidgetColors(); const auto& wc = getFWidgetColors();
setForegroundColor (wc.dialog_fg); setForegroundColor (wc.dialog_fg);
@ -1554,14 +1564,14 @@ FObject::iterator FListView::getListEnd (FListViewItem* item)
auto parent = item->getParent(); auto parent = item->getParent();
if ( ! parent ) if ( ! parent )
return null_iter; return getNullIterator();
if ( this == parent ) if ( this == parent )
return itemlist.end(); return itemlist.end();
else if ( parent->isInstanceOf("FListViewItem") ) else if ( parent->isInstanceOf("FListViewItem") )
return static_cast<FListViewItem*>(parent)->end(); return static_cast<FListViewItem*>(parent)->end();
else else
return null_iter; return getNullIterator();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -305,7 +305,7 @@ bool FMenuBar::selectNextItem()
if ( next == *iter ) if ( next == *iter )
return false; return false;
updateTerminal (FVTerm::stop_refresh); setTerminalUpdates (FVTerm::stop_terminal_updates);
unselectItem(); unselectItem();
next->setSelected(); next->setSelected();
setSelectedItem(next); setSelectedItem(next);
@ -328,7 +328,7 @@ bool FMenuBar::selectNextItem()
getStatusBar()->drawMessage(); getStatusBar()->drawMessage();
redraw(); redraw();
updateTerminal (FVTerm::start_refresh); setTerminalUpdates (FVTerm::start_terminal_updates);
break; break;
} }
@ -369,7 +369,7 @@ bool FMenuBar::selectPrevItem()
if ( prev == *iter ) if ( prev == *iter )
return false; return false;
updateTerminal (FVTerm::stop_refresh); setTerminalUpdates (FVTerm::stop_terminal_updates);
unselectItem(); unselectItem();
prev->setSelected(); prev->setSelected();
prev->setFocus(); prev->setFocus();
@ -392,7 +392,7 @@ bool FMenuBar::selectPrevItem()
setSelectedItem(prev); setSelectedItem(prev);
redraw(); redraw();
updateTerminal (FVTerm::stop_refresh); setTerminalUpdates (FVTerm::stop_terminal_updates);
break; break;
} }
} }

View File

@ -527,7 +527,7 @@ int FMouseGPM::gpmEvent (bool clear)
FD_SET(stdin_no, &ifds); FD_SET(stdin_no, &ifds);
FD_SET(gpm_fd, &ifds); FD_SET(gpm_fd, &ifds);
tv.tv_sec = 0; 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); const int result = select (max + 1, &ifds, nullptr, nullptr, &tv);
if ( result > 0 && FD_ISSET(stdin_no, &ifds) ) if ( result > 0 && FD_ISSET(stdin_no, &ifds) )

View File

@ -52,7 +52,7 @@ static FVTerm* init_object{nullptr};
bool FVTerm::terminal_update_complete{false}; bool FVTerm::terminal_update_complete{false};
bool FVTerm::terminal_update_pending{false}; bool FVTerm::terminal_update_pending{false};
bool FVTerm::force_terminal_update{false}; bool FVTerm::force_terminal_update{false};
bool FVTerm::stop_terminal_updates{false}; bool FVTerm::no_terminal_updates{false};
int FVTerm::skipped_terminal_update{}; int FVTerm::skipped_terminal_update{};
uInt FVTerm::erase_char_length{}; uInt FVTerm::erase_char_length{};
uInt FVTerm::repeat_char_length{}; uInt FVTerm::repeat_char_length{};
@ -148,6 +148,24 @@ void FVTerm::setTermXY (int x, int y)
term_pos->setPoint(x, 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) void FVTerm::hideCursor (bool enable)
{ {
@ -227,30 +245,12 @@ void FVTerm::putVTerm()
updateTerminal(); 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() void FVTerm::updateTerminal()
{ {
// Updates pending changes to the terminal // Updates pending changes to the terminal
if ( stop_terminal_updates if ( no_terminal_updates
|| FApplication::getApplicationObject()->isQuit() ) || FApplication::getApplicationObject()->isQuit() )
return; return;

View File

@ -676,7 +676,7 @@ void FWindow::switchToPrevWindow (FWidget* widget)
// Disable terminal updates to avoid flickering // Disable terminal updates to avoid flickering
// when redrawing the focused widget // when redrawing the focused widget
if ( widget ) if ( widget )
widget->updateTerminal (FVTerm::stop_refresh); widget->setTerminalUpdates (FVTerm::stop_terminal_updates);
const bool is_activated = activatePrevWindow(); const bool is_activated = activatePrevWindow();
auto active_win = static_cast<FWindow*>(getActiveWindow()); auto active_win = static_cast<FWindow*>(getActiveWindow());
@ -726,7 +726,7 @@ void FWindow::switchToPrevWindow (FWidget* widget)
// Enable terminal updates again // Enable terminal updates again
if ( widget ) if ( widget )
widget->updateTerminal (FVTerm::continue_refresh); widget->setTerminalUpdates (FVTerm::continue_terminal_updates);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -348,9 +348,6 @@ class FListView : public FWidget
void onFocusIn (FFocusEvent*) override; void onFocusIn (FFocusEvent*) override;
void onFocusOut (FFocusEvent*) override; void onFocusOut (FFocusEvent*) override;
// Data members
static iterator null_iter;
protected: protected:
// Methods // Methods
void adjustViewport (const int); void adjustViewport (const int);
@ -373,6 +370,12 @@ class FListView : public FWidget
// Constants // Constants
static constexpr int USE_MAX_SIZE = -1; static constexpr int USE_MAX_SIZE = -1;
// Accessors
static iterator& getNullIterator();
// Mutators
static void setNullIterator (iterator&);
// Inquiry // Inquiry
bool isHorizontallyScrollable(); bool isHorizontallyScrollable();
bool isVerticallyScrollable(); bool isVerticallyScrollable();

View File

@ -117,9 +117,9 @@ class FVTerm
enum terminal_update enum terminal_update
{ {
stop_refresh, stop_terminal_updates, // No terminal refresh
continue_refresh, continue_terminal_updates, // Resuming terminal refresh
start_refresh start_terminal_updates // Allowing terminal refresh
}; };
// Constructor // Constructor
@ -164,10 +164,12 @@ class FVTerm
// Mutators // Mutators
void setTermXY (int, int); void setTermXY (int, int);
void setTerminalUpdates (terminal_update);
void hideCursor (bool); void hideCursor (bool);
void hideCursor(); void hideCursor();
void showCursor(); void showCursor();
void setPrintCursor (const FPoint&); void setPrintCursor (const FPoint&);
FColor rgb2ColorIndex (uInt8, uInt8, uInt8); FColor rgb2ColorIndex (uInt8, uInt8, uInt8);
static void setColor (FColor, FColor); static void setColor (FColor, FColor);
static void setNormal(); static void setNormal();
@ -293,7 +295,6 @@ class FVTerm
void createVTerm (const FSize&); void createVTerm (const FSize&);
void resizeVTerm (const FSize&); void resizeVTerm (const FSize&);
void putVTerm(); void putVTerm();
void updateTerminal (terminal_update);
void updateTerminal(); void updateTerminal();
virtual void addPreprocessingHandler ( FVTerm* virtual void addPreprocessingHandler ( FVTerm*
, FPreprocessingFunction ); , FPreprocessingFunction );
@ -496,7 +497,7 @@ class FVTerm
static bool terminal_update_complete; static bool terminal_update_complete;
static bool terminal_update_pending; static bool terminal_update_pending;
static bool force_terminal_update; static bool force_terminal_update;
static bool stop_terminal_updates; static bool no_terminal_updates;
static int skipped_terminal_update; static int skipped_terminal_update;
static uInt erase_char_length; static uInt erase_char_length;
static uInt repeat_char_length; static uInt repeat_char_length;

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * 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 * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * 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 << "vt100" << "\t" << "ttyp6" << std::endl;
ttytype.close(); ttytype.close();
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
detect.setTerminalDetection(true); detect.setTerminalDetection(true);
detect.setTtyTypeFileName(C_STR("new-root-dir/etc/ttytype")); detect.setTtyTypeFileName(C_STR("new-root-dir/etc/ttytype"));
@ -1501,6 +1500,7 @@ void FTermDetectionTest::ttytypeTest()
unsetenv("KONSOLE_DBUS_SESSION"); unsetenv("KONSOLE_DBUS_SESSION");
unsetenv("KONSOLE_DCOP"); unsetenv("KONSOLE_DCOP");
unsetenv("TMUX"); unsetenv("TMUX");
finalcut::FTermData& data = *finalcut::FTerm::getFTermData();
// Test /dev/tty3 with linux // Test /dev/tty3 with linux
data.setTermFileName(C_STR("/dev/tty3")); data.setTermFileName(C_STR("/dev/tty3"));

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the Final Cut widget toolkit * * 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 * * The Final Cut is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License * * 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.length = 8;
fb_terminal_info.blue.msb_right = 0; fb_terminal_info.blue.msb_right = 0;
fb_terminal_info.transp.offset = 0; fb_terminal_info.transp.offset = 0;
fb_terminal_info.blue.length = 0; fb_terminal_info.transp.length = 0;
fb_terminal_info.blue.msb_right = 0; fb_terminal_info.transp.msb_right = 0;
fb_terminal_info.nonstd = 0; fb_terminal_info.nonstd = 0;
fb_terminal_info.activate = 0; fb_terminal_info.activate = 0;
fb_terminal_info.height = 0xffffffff; fb_terminal_info.height = 0xffffffff;