No refreshing of the terminal during resizing of a dialog

This commit is contained in:
Markus Gans 2021-03-30 15:20:36 +02:00
parent 597f9e772b
commit 9df509dd3b
18 changed files with 67 additions and 57 deletions

View File

@ -1,3 +1,7 @@
2021-03-30 Markus Gans <guru.mail@muenster.de>
* Stops terminal refresh during dialog resizing until all
child widgets have been redrawn
2021-03-28 Markus Gans <guru.mail@muenster.de> 2021-03-28 Markus Gans <guru.mail@muenster.de>
* Widget now have the virtual method initLayout() to set * Widget now have the virtual method initLayout() to set
the widget layouts automatically before the first drawing the widget layouts automatically before the first drawing

View File

@ -324,6 +324,9 @@ inline void Brushes::setBackground (FColor color)
class MouseDraw final : public finalcut::FDialog class MouseDraw final : public finalcut::FDialog
{ {
public: public:
// Using-declaration
using FWidget::setGeometry;
// Constructor // Constructor
explicit MouseDraw (finalcut::FWidget* = nullptr); explicit MouseDraw (finalcut::FWidget* = nullptr);

View File

@ -195,7 +195,7 @@ struct Treeview::TreeItem
{ return &name; } { return &name; }
const char* const* end() const const char* const* end() const
{ return reinterpret_cast<const char* const*>(&child_element); } { return &density + 1; }
// Data members // Data members
const char* name; const char* name;

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 2013-2020 Markus Gans * * Copyright 2013-2021 Markus Gans *
* * * *
* FINAL CUT is free software; you can redistribute it and/or modify * * FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -168,7 +168,7 @@ void FApplication::setLog (const FLogPtr& log)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FApplication::isQuit() bool FApplication::isQuit()
{ {
return ( internal::var::app_object ) ? quit_now : true; return internal::var::app_object ? quit_now : true;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -359,6 +359,7 @@ void FDialog::setSize (const FSize& size, bool adjust)
const auto d_width = std::size_t(dw); const auto d_width = std::size_t(dw);
const auto d_height = std::size_t(dh); const auto d_height = std::size_t(dh);
setTerminalUpdates (FVTerm::TerminalUpdate::Stop);
// restoring the non-covered terminal areas // restoring the non-covered terminal areas
if ( dw > 0 ) if ( dw > 0 )
@ -377,6 +378,8 @@ void FDialog::setSize (const FSize& size, bool adjust)
// set the cursor to the focus widget // set the cursor to the focus widget
setCursorToFocusWidget(); setCursorToFocusWidget();
setTerminalUpdates (FVTerm::TerminalUpdate::Start);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -282,7 +282,7 @@ inline FKey FKeyboard::getTermcapKey()
for (auto&& entry : *key_map) for (auto&& entry : *key_map)
{ {
const char* kstr = entry.string; const char* kstr = entry.string;
const std::size_t len = ( kstr ) ? std::strlen(kstr) : 0; const std::size_t len = kstr ? std::strlen(kstr) : 0;
if ( kstr && std::strncmp(kstr, fifo_buf, len) == 0 ) // found if ( kstr && std::strncmp(kstr, fifo_buf, len) == 0 ) // found
{ {

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 2014-2020 Markus Gans * * Copyright 2014-2021 Markus Gans *
* * * *
* FINAL CUT is free software; you can redistribute it and/or modify * * FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -996,7 +996,7 @@ inline void FListBox::setLineAttributes ( int y
{ {
setColor ( wc->current_element_focus_fg setColor ( wc->current_element_focus_fg
, wc->current_element_focus_bg ); , wc->current_element_focus_bg );
const int b = ( lineHasBrackets ) ? 1: 0; const int b = lineHasBrackets ? 1 : 0;
if ( inc_len > 0 ) // incremental search if ( inc_len > 0 ) // incremental search
{ {

View File

@ -1618,7 +1618,7 @@ void FListView::drawList()
const bool is_current_line( iter == current_iter ); const bool is_current_line( iter == current_iter );
const auto& item = static_cast<FListViewItem*>(*iter); const auto& item = static_cast<FListViewItem*>(*iter);
const int tree_offset = ( tree_view ) ? int(item->getDepth() << 1) + 1 : 0; const int tree_offset = ( tree_view ) ? int(item->getDepth() << 1) + 1 : 0;
const int checkbox_offset = ( item->isCheckable() ) ? 1 : 0; const int checkbox_offset = item->isCheckable() ? 1 : 0;
path_end = getListEnd(item); path_end = getListEnd(item);
print() << FPoint{2, 2 + int(y)}; print() << FPoint{2, 2 + int(y)};

View File

@ -373,7 +373,7 @@ bool FMenu::isSubMenu() const
bool FMenu::isDialogMenu() const bool FMenu::isDialogMenu() const
{ {
const auto& super = getSuperMenu(); const auto& super = getSuperMenu();
return ( super ) ? super->isDialogWidget() : false; return super ? super->isDialogWidget() : false;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1350,7 +1350,7 @@ inline void FMenu::drawMenuText (MenuText& data)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FMenu::drawSubMenuIndicator (std::size_t& startpos) inline void FMenu::drawSubMenuIndicator (std::size_t& startpos)
{ {
const std::size_t c = ( has_checkable_items ) ? 1 : 0; const std::size_t c = has_checkable_items ? 1 : 0;
const std::size_t len = max_item_width - (startpos + c + 3); const std::size_t len = max_item_width - (startpos + c + 3);
if ( len > 0 ) if ( len > 0 )
@ -1367,7 +1367,7 @@ inline void FMenu::drawSubMenuIndicator (std::size_t& startpos)
inline void FMenu::drawAcceleratorKey (std::size_t& startpos, FKey accel_key) inline void FMenu::drawAcceleratorKey (std::size_t& startpos, FKey accel_key)
{ {
const FString accel_name {FTerm::getKeyName(accel_key)}; const FString accel_name {FTerm::getKeyName(accel_key)};
const std::size_t c = ( has_checkable_items ) ? 1 : 0; const std::size_t c = has_checkable_items ? 1 : 0;
const std::size_t accel_len = accel_name.getLength(); const std::size_t accel_len = accel_name.getLength();
const std::size_t plain_text_length = startpos + accel_len + c + 2; const std::size_t plain_text_length = startpos + accel_len + c + 2;
@ -1384,7 +1384,7 @@ inline void FMenu::drawAcceleratorKey (std::size_t& startpos, FKey accel_key)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FMenu::drawTrailingSpaces (std::size_t startpos) inline void FMenu::drawTrailingSpaces (std::size_t startpos)
{ {
const std::size_t c = ( has_checkable_items ) ? 1 : 0; const std::size_t c = has_checkable_items ? 1 : 0;
// Print trailing blank space // Print trailing blank space
for (std::size_t i = startpos + c; i < max_item_width - 1; i++) for (std::size_t i = startpos + c; i < max_item_width - 1; i++)

View File

@ -451,13 +451,13 @@ void FMenuItem::onFocusOut (FFocusEvent*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMenuItem::isDialog (const FWidget* w) const bool FMenuItem::isDialog (const FWidget* w) const
{ {
return ( w ) ? w->isDialogWidget() : false; return w ? w->isDialogWidget() : false;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMenuItem::isMenuBar (const FWidget* w) const bool FMenuItem::isMenuBar (const FWidget* w) const
{ {
return ( w ) ? w->isInstanceOf("FMenuBar") : false; return w ? w->isInstanceOf("FMenuBar") : false;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -580,7 +580,7 @@ void FMenuItem::updateSuperMenuDimensions()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::updateMenubarDimensions() void FMenuItem::updateMenubarDimensions() const
{ {
FWidget* parent = getParentWidget(); FWidget* parent = getParentWidget();

View File

@ -403,7 +403,7 @@ void FMessageBox::adjustButtons()
std::size_t max_width; std::size_t max_width;
const auto& root_widget = getRootWidget(); const auto& root_widget = getRootWidget();
setWidth(btn_width + 5); setWidth(btn_width + 5);
max_width = ( root_widget ) ? root_widget->getClientWidth() : 80; max_width = root_widget ? root_widget->getClientWidth() : 80;
setX (int((max_width - getWidth()) / 2)); setX (int((max_width - getWidth()) / 2));
} }

View File

@ -914,7 +914,7 @@ inline bool FOptiMove::isMethod0Faster ( int& move_time
if ( ! move_xy.empty() ) if ( ! move_xy.empty() )
{ {
std::strncpy ( reinterpret_cast<char*>(move_buf) std::strncpy ( static_cast<char*>(move_buf)
, move_xy.data(), BUF_SIZE - 1 ); , move_xy.data(), BUF_SIZE - 1 );
move_buf[BUF_SIZE - 1] = '\0'; move_buf[BUF_SIZE - 1] = '\0';
move_time = F_cursor_address.duration; move_time = F_cursor_address.duration;

View File

@ -159,10 +159,10 @@ FString::FString (const char c)
FString::~FString() // destructor FString::~FString() // destructor
{ {
if ( string ) if ( string )
delete[](string); delete[] string;
if ( c_string ) if ( c_string )
delete[](c_string); delete[] c_string;
} }
@ -182,10 +182,10 @@ FString& FString::operator = (FString&& s) noexcept
if ( &s != this ) if ( &s != this )
{ {
if ( string ) if ( string )
delete[](string); delete[] string;
if ( c_string ) if ( c_string )
delete[](c_string); delete[] c_string;
string = s.string; string = s.string;
length = s.length; length = s.length;
@ -348,7 +348,7 @@ const FString& FString::operator () () const
FString FString::clear() FString FString::clear()
{ {
if ( string ) if ( string )
delete[](string); delete[] string;
length = 0; length = 0;
bufsize = 0; bufsize = 0;
@ -1231,7 +1231,7 @@ void FString::_assign (const wchar_t s[])
if ( ! string || new_length > capacity() ) if ( ! string || new_length > capacity() )
{ {
if ( string ) if ( string )
delete[](string); delete[] string;
bufsize = FWDBUFFER + new_length + 1; bufsize = FWDBUFFER + new_length + 1;
@ -1258,7 +1258,7 @@ void FString::_insert (std::size_t len, const wchar_t s[])
return; return;
if ( string ) if ( string )
delete[](string); delete[] string;
length = len; length = len;
bufsize = FWDBUFFER + length + 1; bufsize = FWDBUFFER + length + 1;
@ -1312,7 +1312,7 @@ void FString::_insert ( std::size_t pos
try try
{ {
sptr = new wchar_t[bufsize]; // generate new string sptr = new wchar_t[bufsize]; // generate new string
} }
catch (const std::bad_alloc&) catch (const std::bad_alloc&)
{ {
@ -1332,7 +1332,7 @@ void FString::_insert ( std::size_t pos
sptr[y++] = string[x]; sptr[y++] = string[x];
length += len; length += len;
delete[](string); // delete old string delete[] string; // delete old string
string = sptr; string = sptr;
} }
} }
@ -1356,7 +1356,7 @@ void FString::_remove (std::size_t pos, std::size_t len)
try try
{ {
sptr = new wchar_t[bufsize]; // generate new string sptr = new wchar_t[bufsize]; // generate new string
} }
catch (const std::bad_alloc&) catch (const std::bad_alloc&)
{ {
@ -1367,13 +1367,13 @@ void FString::_remove (std::size_t pos, std::size_t len)
std::size_t x{}; std::size_t x{};
std::size_t y{}; std::size_t y{};
for (x = 0; x < pos; x++) // left side for (x = 0; x < pos; x++) // left side
sptr[y++] = string[x]; sptr[y++] = string[x];
for (x = pos + len; x < length + 1; x++) // right side + '\0' for (x = pos + len; x < length + 1; x++) // right side + '\0'
sptr[y++] = string[x]; sptr[y++] = string[x];
delete[](string); // delete old string delete[] string; // delete old string
string = sptr; string = sptr;
length -= len; length -= len;
} }
@ -1425,7 +1425,7 @@ inline const char* FString::_to_cstring (const wchar_t s[]) const
if ( mblength == static_cast<std::size_t>(-1) && errno != EILSEQ ) if ( mblength == static_cast<std::size_t>(-1) && errno != EILSEQ )
{ {
delete[](c_string); delete[] c_string;
c_string = nullptr; c_string = nullptr;
return ""; return "";
} }
@ -1503,7 +1503,7 @@ inline const wchar_t* FString::_extractToken ( wchar_t* rest[]
, const wchar_t s[] , const wchar_t s[]
, const wchar_t delim[] ) const , const wchar_t delim[] ) const
{ {
wchar_t* token = ( s ) ? const_cast<wchar_t*>(s) : *rest; wchar_t* token = s ? const_cast<wchar_t*>(s) : *rest;
if ( ! token ) if ( ! token )
return nullptr; return nullptr;

View File

@ -133,49 +133,49 @@ FTermcap::Status FTermcap::paddingPrint ( const std::string& string
auto iter = string.begin(); auto iter = string.begin();
using iter_type = decltype(iter); using iter_type = decltype(iter);
auto read_digits = [] (iter_type& iter, int& number) auto read_digits = [] (iter_type& it, int& number)
{ {
while ( std::isdigit(int(*iter)) && number < 1000 ) while ( std::isdigit(int(*it)) && number < 1000 )
{ {
number = number * 10 + (*iter - '0'); number = number * 10 + (*it - '0');
++iter; ++it;
} }
number *= 10; number *= 10;
}; };
auto decimal_point = [] (iter_type& iter, int& number) auto decimal_point = [] (iter_type& it, int& number)
{ {
if ( *iter == '.' ) if ( *it == '.' )
{ {
++iter; ++it;
if ( std::isdigit(int(*iter)) ) if ( std::isdigit(int(*it)) )
{ {
number += (*iter - '0'); // Position after decimal point number += (*it - '0'); // Position after decimal point
++iter; ++it;
} }
while ( std::isdigit(int(*iter)) ) while ( std::isdigit(int(*it)) )
++iter; ++it;
} }
}; };
auto asterisk_slash = [&affcnt, &has_delay] (iter_type& iter, int& number) auto asterisk_slash = [&affcnt, &has_delay] (iter_type& it, int& number)
{ {
while ( *iter == '*' || *iter == '/' ) while ( *it == '*' || *it == '/' )
{ {
if ( *iter == '*' ) if ( *it == '*' )
{ {
// Padding is proportional to the number of affected lines (suffix '*') // Padding is proportional to the number of affected lines (suffix '*')
number *= affcnt; number *= affcnt;
++iter; ++it;
} }
else else
{ {
// Padding is mandatory (suffix '/') // Padding is mandatory (suffix '/')
has_delay = true; has_delay = true;
++iter; ++it;
} }
} }
}; };
@ -444,7 +444,7 @@ std::string FTermcap::encodeParams ( const std::string& cap
auto str = ::tparm ( C_STR(cap.data()), params[0], params[1] auto str = ::tparm ( C_STR(cap.data()), params[0], params[1]
, params[2], params[3], params[4], params[5] , params[2], params[3], params[4], params[5]
, params[6], params[7], params[8] ); , params[6], params[7], params[8] );
return ( str ) ? str : std::string(); return str ? str : std::string();
} }

View File

@ -124,8 +124,8 @@ void FToolTip::init()
void FToolTip::draw() void FToolTip::draw()
{ {
bool border = hasBorder(); bool border = hasBorder();
int y{( border ) ? 2 : 1}; int y{border ? 2 : 1};
int x{( border ) ? 3 : 2}; int x{border ? 3 : 2};
setColor(); setColor();
clearArea(); clearArea();
@ -160,8 +160,8 @@ void FToolTip::calculateDimensions()
int x{}; int x{};
int y{}; int y{};
bool border = hasBorder(); bool border = hasBorder();
const std::size_t h = ( border ) ? text_num_lines + 2 : text_num_lines; const std::size_t h = border ? text_num_lines + 2 : text_num_lines;
const std::size_t w = ( border ) ? max_line_width + 4 : max_line_width + 2; const std::size_t w = border ? max_line_width + 4 : max_line_width + 2;
const auto& r = getRootWidget(); const auto& r = getRootWidget();
if ( r ) if ( r )

View File

@ -233,7 +233,7 @@ void FVTerm::setNonBlockingRead (bool enable)
} }
#endif #endif
uInt64 blocking_time = (enable) ? 5000 : 100000; // 5 or 100 ms uInt64 blocking_time = enable ? 5000 : 100000; // 5 or 100 ms
FKeyboard::setReadBlockingTime (blocking_time); FKeyboard::setReadBlockingTime (blocking_time);
} }
@ -1925,7 +1925,7 @@ void FVTerm::init_combined_character()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::finish() void FVTerm::finish() const
{ {
// Show the input cursor // Show the input cursor
showCursor(); showCursor();
@ -2907,7 +2907,7 @@ inline void FVTerm::flushTimeAdjustment() const
} }
else else
{ {
uInt64 usec = diff.tv_usec; auto usec = uInt64(diff.tv_usec);
if ( usec < MIN_FLUSH_WAIT ) if ( usec < MIN_FLUSH_WAIT )
usec = MIN_FLUSH_WAIT; usec = MIN_FLUSH_WAIT;

View File

@ -159,7 +159,7 @@ class FMenuItem : public FWidget
void init(); void init();
void calculateTextDimensions(); void calculateTextDimensions();
void updateSuperMenuDimensions(); void updateSuperMenuDimensions();
void updateMenubarDimensions(); void updateMenubarDimensions() const;
void processEnable() const; void processEnable() const;
void processDisable() const; void processDisable() const;
void processActivate() const; void processActivate() const;

View File

@ -380,7 +380,7 @@ class FVTerm
void init(); void init();
static void init_characterLengths(); static void init_characterLengths();
static void init_combined_character(); static void init_combined_character();
void finish(); void finish() const;
static void putAreaLine (const FChar&, FChar&, std::size_t); static void putAreaLine (const FChar&, FChar&, std::size_t);
static void putAreaCharacter ( const FPoint&, const FTermArea* static void putAreaCharacter ( const FPoint&, const FTermArea*
, const FChar&, FChar& ); , const FChar&, FChar& );