Optimize terminal output buffer queue with differencing for strings, and control characters and control sequences

This commit is contained in:
Markus Gans 2021-02-20 11:29:52 +01:00
parent 28f41f5d6c
commit a55b33977c
44 changed files with 561 additions and 862 deletions

View File

@ -1,3 +1,7 @@
2021-02-20 Markus Gans <guru.mail@muenster.de>
* Optimize terminal output buffer queue with differencing
for strings, and control characters and control sequences
2021-02-09 Markus Gans <guru.mail@muenster.de>
* Added support for combined unicode characters
* Added a unit test for the FTermBuffera class

View File

@ -886,7 +886,7 @@ bool FOptiAttr::setTermAttributes ( FChar& term
{
if ( F_set_attributes.cap )
{
const char* sgr = FTermcap::encodeParameter ( F_set_attributes.cap
const auto sgr = FTermcap::encodeParameter ( F_set_attributes.cap
, p1 && ! fake_reverse
, p2
, p3 && ! fake_reverse
@ -896,7 +896,7 @@ bool FOptiAttr::setTermAttributes ( FChar& term
, p7
, p8
, p9 );
append_sequence (sgr);
append_sequence (sgr.data());
resetColor(term);
term.attr.bit.standout = p1;
term.attr.bit.underline = p2;
@ -1386,13 +1386,13 @@ inline void FOptiAttr::change_current_color ( const FChar& term
if ( term.fg_color != fg || frev )
{
color_str = FTermcap::encodeParameter(AF, uInt16(ansi_fg), 0, 0, 0, 0, 0, 0, 0, 0);
color_str = FTermcap::encodeParameter(AF, uInt16(ansi_fg), 0, 0, 0, 0, 0, 0, 0, 0).data();
append_sequence (color_str);
}
if ( term.bg_color != bg || frev )
{
color_str = FTermcap::encodeParameter(AB, uInt16(ansi_bg), 0, 0, 0, 0, 0, 0, 0, 0);
color_str = FTermcap::encodeParameter(AB, uInt16(ansi_bg), 0, 0, 0, 0, 0, 0, 0, 0).data();
append_sequence (color_str);
}
}
@ -1400,13 +1400,13 @@ inline void FOptiAttr::change_current_color ( const FChar& term
{
if ( term.fg_color != fg || frev )
{
color_str = FTermcap::encodeParameter(Sf, uInt16(fg), 0, 0, 0, 0, 0, 0, 0, 0);
color_str = FTermcap::encodeParameter(Sf, uInt16(fg), 0, 0, 0, 0, 0, 0, 0, 0).data();
append_sequence (color_str);
}
if ( term.bg_color != bg || frev )
{
color_str = FTermcap::encodeParameter(Sb, uInt16(bg), 0, 0, 0, 0, 0, 0, 0, 0);
color_str = FTermcap::encodeParameter(Sb, uInt16(bg), 0, 0, 0, 0, 0, 0, 0, 0).data();
append_sequence (color_str);
}
}
@ -1414,7 +1414,7 @@ inline void FOptiAttr::change_current_color ( const FChar& term
{
fg = vga2ansi(fg);
bg = vga2ansi(bg);
color_str = FTermcap::encodeParameter(sp, uInt16(fg), uInt16(bg), 0, 0, 0, 0, 0, 0, 0);
color_str = FTermcap::encodeParameter(sp, uInt16(fg), uInt16(bg), 0, 0, 0, 0, 0, 0, 0).data();
append_sequence (color_str);
}
}

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2015-2020 Markus Gans *
* Copyright 2015-2021 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 *
@ -266,9 +266,9 @@ void FOptiMove::set_cursor_address (const char cap[])
{
if ( cap && FTermcap::isInitialized() )
{
const char* temp = FTermcap::encodeMotionParameter(cap, 23, 23);
const auto temp = FTermcap::encodeMotionParameter(cap, 23, 23);
F_cursor_address.cap = cap;
F_cursor_address.duration = capDuration (temp, 1);
F_cursor_address.duration = capDuration (temp.data(), 1);
F_cursor_address.length = capDurationToLength (F_cursor_address.duration);
}
else
@ -284,9 +284,9 @@ void FOptiMove::set_column_address (const char cap[])
{
if ( cap && FTermcap::isInitialized() )
{
const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
const auto temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
F_column_address.cap = cap;
F_column_address.duration = capDuration (temp, 1);
F_column_address.duration = capDuration (temp.data(), 1);
F_column_address.length = capDurationToLength (F_column_address.duration);
}
else
@ -302,7 +302,7 @@ void FOptiMove::set_row_address (const char cap[])
{
if ( cap && FTermcap::isInitialized() )
{
const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0).data();
F_row_address.cap = cap;
F_row_address.duration = capDuration (temp, 1);
F_row_address.length = capDurationToLength (F_row_address.duration);
@ -320,7 +320,7 @@ void FOptiMove::set_parm_up_cursor (const char cap[])
{
if ( cap && FTermcap::isInitialized() )
{
const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0).data();
F_parm_up_cursor.cap = cap;
F_parm_up_cursor.duration = capDuration (temp, 1);
F_parm_up_cursor.length = capDurationToLength (F_parm_up_cursor.duration);
@ -338,7 +338,7 @@ void FOptiMove::set_parm_down_cursor (const char cap[])
{
if ( cap && FTermcap::isInitialized() )
{
const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0).data();
F_parm_down_cursor.cap = cap;
F_parm_down_cursor.duration = capDuration (temp, 1);
F_parm_down_cursor.length = capDurationToLength (F_parm_down_cursor.duration);
@ -356,7 +356,7 @@ void FOptiMove::set_parm_left_cursor (const char cap[])
{
if ( cap && FTermcap::isInitialized() )
{
const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0).data();
F_parm_left_cursor.cap = cap;
F_parm_left_cursor.duration = capDuration (temp, 1);
F_parm_left_cursor.length = capDurationToLength (F_parm_left_cursor.duration);
@ -374,7 +374,7 @@ void FOptiMove::set_parm_right_cursor (const char cap[])
{
if ( cap && FTermcap::isInitialized() )
{
const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0).data();
F_parm_right_cursor.cap = cap;
F_parm_right_cursor.duration = capDuration (temp, 1);
F_parm_right_cursor.length = capDurationToLength (F_parm_right_cursor.duration);
@ -392,7 +392,7 @@ void FOptiMove::set_erase_chars (const char cap[])
{
if ( cap && FTermcap::isInitialized() )
{
const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0);
const char* temp = FTermcap::encodeParameter(cap, 23, 0, 0, 0, 0, 0, 0, 0, 0).data();
F_erase_chars.cap = cap;
F_erase_chars.duration = capDuration (temp, 1);
F_erase_chars.length = capDurationToLength (F_erase_chars.duration);
@ -410,7 +410,7 @@ void FOptiMove::set_repeat_char (const char cap[])
{
if ( cap && FTermcap::isInitialized() )
{
const char* temp = FTermcap::encodeParameter(cap, ' ', 23, 0, 0, 0, 0, 0, 0, 0);
const char* temp = FTermcap::encodeParameter(cap, ' ', 23, 0, 0, 0, 0, 0, 0, 0).data();
F_repeat_char.cap = cap;
F_repeat_char.duration = capDuration (temp, 1);
F_repeat_char.length = capDurationToLength (F_repeat_char.duration);
@ -686,7 +686,7 @@ inline int FOptiMove::verticalMove (char move[], int from_y, int to_y) const
if ( move )
{
std::strncpy ( move
, FTermcap::encodeParameter(F_row_address.cap, to_y, 0, 0, 0, 0, 0, 0, 0, 0)
, FTermcap::encodeParameter(F_row_address.cap, to_y, 0, 0, 0, 0, 0, 0, 0, 0).data()
, BUF_SIZE );
move[BUF_SIZE - 1] = '\0';
}
@ -713,7 +713,7 @@ inline void FOptiMove::downMove ( char move[], int& vtime
if ( move )
{
std::strncpy ( move
, FTermcap::encodeParameter(F_parm_down_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
, FTermcap::encodeParameter(F_parm_down_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0).data()
, BUF_SIZE );
move[BUF_SIZE - 1] = '\0';
}
@ -741,7 +741,7 @@ inline void FOptiMove::upMove ( char move[], int& vtime
if ( move )
{
std::strncpy ( move
, FTermcap::encodeParameter(F_parm_up_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
, FTermcap::encodeParameter(F_parm_up_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0).data()
, BUF_SIZE );
move[BUF_SIZE - 1] = '\0';
}
@ -767,7 +767,7 @@ inline int FOptiMove::horizontalMove (char hmove[], int from_x, int to_x) const
{
// Move to fixed column position1
std::strncat ( hmove
, FTermcap::encodeParameter(F_column_address.cap, to_x, 0, 0, 0, 0, 0, 0, 0, 0)
, FTermcap::encodeParameter(F_column_address.cap, to_x, 0, 0, 0, 0, 0, 0, 0, 0).data()
, BUF_SIZE - std::strlen(hmove) - 1 );
hmove[BUF_SIZE - 1] = '\0';
htime = F_column_address.duration;
@ -790,7 +790,7 @@ inline void FOptiMove::rightMove ( char hmove[], int& htime
if ( F_parm_right_cursor.cap && F_parm_right_cursor.duration < htime )
{
std::strncpy ( hmove
, FTermcap::encodeParameter(F_parm_right_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
, FTermcap::encodeParameter(F_parm_right_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0).data()
, BUF_SIZE - 1);
hmove[BUF_SIZE - 1] = '\0';
htime = F_parm_right_cursor.duration;
@ -845,7 +845,7 @@ inline void FOptiMove::leftMove ( char hmove[], int& htime
if ( F_parm_left_cursor.cap && F_parm_left_cursor.duration < htime )
{
std::strncpy ( hmove
, FTermcap::encodeParameter(F_parm_left_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0)
, FTermcap::encodeParameter(F_parm_left_cursor.cap, num, 0, 0, 0, 0, 0, 0, 0, 0).data()
, BUF_SIZE - 1);
hmove[BUF_SIZE - 1] = '\0';
htime = F_parm_left_cursor.duration;
@ -906,13 +906,17 @@ inline bool FOptiMove::isMethod0Faster ( int& move_time
, int xnew, int ynew )
{
// Test method 0: direct cursor addressing
const char* move_xy = \
if ( ! F_cursor_address.cap )
return false;
const auto move_xy = \
FTermcap::encodeMotionParameter(F_cursor_address.cap, xnew, ynew);
if ( move_xy )
if ( ! move_xy.empty() )
{
std::strncpy ( reinterpret_cast<char*>(move_buf)
, move_xy, BUF_SIZE - 1 );
, move_xy.data(), BUF_SIZE - 1 );
move_buf[BUF_SIZE - 1] = '\0';
move_time = F_cursor_address.duration;
return true;

View File

@ -151,14 +151,14 @@ int FTerm::getTTYFileDescriptor()
}
//----------------------------------------------------------------------
const char* FTerm::getTermType()
std::string FTerm::getTermType()
{
const auto& data = FTerm::getFTermData();
return data->getTermType();
}
//----------------------------------------------------------------------
const char* FTerm::getTermFileName()
std::string FTerm::getTermFileName()
{
const auto& data = FTerm::getFTermData();
return data->getTermFileName();
@ -504,7 +504,7 @@ bool FTerm::canChangeColorPalette()
}
//----------------------------------------------------------------------
void FTerm::setTermType (const char term_name[])
void FTerm::setTermType (const std::string& term_name)
{
const auto& data = FTerm::getFTermData();
data->setTermType(term_name);
@ -691,7 +691,13 @@ int FTerm::openConsole()
{
const auto& data = FTerm::getFTermData();
int fd = data->getTTYFileDescriptor();
const char* termfilename = data->getTermFileName();
const auto& termfilename = data->getTermFileName();
if ( ! termfilename.empty() )
return 0;
if ( fd >= 0 ) // console is already opened
return 0;
constexpr std::array<const char*, 6> terminal_devices =
{{
@ -703,12 +709,6 @@ int FTerm::openConsole()
"/dev/console"
}};
if ( fd >= 0 ) // console is already opened
return 0;
if ( ! *termfilename )
return 0;
for (auto&& entry : terminal_devices)
{
const auto& fsys = FTerm::getFSystem();
@ -755,7 +755,7 @@ const char* FTerm::moveCursorString (int xold, int yold, int xnew, int ynew)
return opti_move->moveCursor (xold, yold, xnew, ynew);
}
else
return FTermcap::encodeMotionParameter(TCAP(t_cursor_address), xnew, ynew);
return FTermcap::encodeMotionParameter(TCAP(t_cursor_address), xnew, ynew).data();
}
//----------------------------------------------------------------------
@ -896,7 +896,7 @@ void FTerm::setPalette (FColor index, int r, int g, int b)
if ( Ic || Ip )
{
const char* color_str{};
std::string color_str{};
const int rr = (r * 1001) / 256;
const int gg = (g * 1001) / 256;
@ -907,7 +907,7 @@ void FTerm::setPalette (FColor index, int r, int g, int b)
else if ( Ip )
color_str = FTermcap::encodeParameter(Ip, uInt16(index), 0, 0, 0, rr, gg, bb, 0, 0);
if ( color_str )
if ( ! color_str.empty() )
{
putstring (color_str);
state = true;
@ -1115,7 +1115,7 @@ FTerm::defaultPutChar& FTerm::putchar()
}
//----------------------------------------------------------------------
void FTerm::putstring (const char str[], int affcnt)
void FTerm::putstring (const std::string& str, int affcnt)
{
FTermcap::paddingPrint (str, affcnt, FTerm::putchar_ASCII);
}
@ -1564,7 +1564,7 @@ void FTerm::init_locale()
// Init current locale
const auto& data = FTerm::getFTermData();
const char* termtype = data->getTermType();
const auto& termtype = data->getTermType();
const char* locale_name = std::setlocale (LC_ALL, "");
std::setlocale (LC_NUMERIC, "");
@ -1584,7 +1584,7 @@ void FTerm::init_locale()
locale_name = std::setlocale (LC_ALL, "C");
// Sun (color) workstation console can't show UTF-8 character
if ( std::strncmp(termtype, "sun", 3) == 0
if ( termtype.substr(0,3) == "sun"
&& ! std::strcmp(nl_langinfo(CODESET), "UTF-8") )
locale_name = std::setlocale (LC_ALL, "C");
@ -1656,7 +1656,7 @@ void FTerm::init_term_encoding()
{
const int stdout_no = FTermios::getStdOut();
const auto& data = FTerm::getFTermData();
const char* termtype = data->getTermType();
const auto& termtype = data->getTermType();
const auto& fsys = FTerm::getFSystem();
if ( fsys->isTTY(stdout_no)
@ -1671,7 +1671,7 @@ void FTerm::init_term_encoding()
keyboard->enableUTF8();
}
else if ( fsys->isTTY(stdout_no)
&& (std::strlen(termtype) > 0)
&& (termtype.length() > 0)
&& (TCAP(t_exit_alt_charset_mode) != nullptr) )
{
data->setVT100Console (true);

View File

@ -179,13 +179,13 @@ void FTermBuffer::add ( FString::const_iterator& begin
// FTermBuffer non-member operators
//----------------------------------------------------------------------
FTermBuffer::FCharVector& operator << ( FTermBuffer::FCharVector& termString
FTermBuffer::FCharVector& operator << ( FTermBuffer::FCharVector& term_string
, const FTermBuffer& buf )
{
if ( ! buf.data.empty() )
termString.assign(buf.data.begin(), buf.data.end());
term_string.assign(buf.data.begin(), buf.data.end());
return termString;
return term_string;
}
} // namespace finalcut

View File

@ -87,11 +87,7 @@ void FTermcap::termcap()
const bool color256 = term_detection->canDisplay256Colors();
// Open termcap file
#if defined(__sun) && defined(__SVR4)
char* termtype = const_cast<char*>(fterm_data->getTermType());
#else
const char* termtype = fterm_data->getTermType();
#endif
const auto& termtype = fterm_data->getTermType();
terminals.emplace_back(termtype); // available terminal type
if ( color256 ) // 1st fallback if not found
@ -104,10 +100,15 @@ void FTermcap::termcap()
while ( iter != terminals.end() )
{
fterm_data->setTermType(iter->c_str());
fterm_data->setTermType(*iter);
// Open the termcap file + load entry for termtype
status = tgetent(term_buffer, termtype);
#if defined(__sun) && defined(__SVR4)
status = tgetent(term_buffer, const_cast<char*>(termtype.data()));
#else
status = tgetent(term_buffer, termtype.data());
#endif
if ( status == success )
initialized = true;
@ -132,7 +133,7 @@ void FTermcap::termcapError (int status)
if ( status == no_entry || status == uninitialized )
{
const auto& fterm_data = FTerm::getFTermData();
const char* termtype = fterm_data->getTermType();
const auto& termtype = fterm_data->getTermType();
std::clog << FLog::LogLevel::Error
<< "Unknown terminal: \"" << termtype << "\". "
<< "Check the TERM environment variable. "

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2018-2020 Markus Gans *
* Copyright 2018-2021 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 *
@ -225,10 +225,10 @@ void FTermcapQuirks::rxvt()
{
// Set enter/exit alternative charset mode for rxvt terminal
const auto& fterm_data = FTerm::getFTermData();
const char* termtype = fterm_data->getTermType();
const auto& termtype = fterm_data->getTermType();
const auto& term_detection = FTerm::getFTermDetection();
if ( std::strncmp(termtype, "rxvt-16color", 12) == 0 )
if ( termtype.substr(0,12) == "rxvt-16color" )
{
TCAP(t_enter_alt_charset_mode) = ESC "(0";
TCAP(t_exit_alt_charset_mode) = ESC "(B";

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2018-2020 Markus Gans *
* Copyright 2018-2021 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 *
@ -168,7 +168,7 @@ void FTermDetection::getSystemTermType()
termtype[sizeof(termtype) - 1] = '\0';
return;
}
else if ( *termfilename ) // 1st fallback: use the teminal file name
else if ( ! termfilename.empty() ) // 1st fallback: use the teminal file name
{
if ( getTTYtype() ) // Look into /etc/ttytype
return;
@ -198,11 +198,11 @@ bool FTermDetection::getTTYtype()
// Get term basename
const auto& fterm_data = FTerm::getFTermData();
const char* termfilename = fterm_data->getTermFileName();
const char* term_basename = std::strrchr(termfilename, '/');
const auto& termfilename = fterm_data->getTermFileName();
const char* term_basename = std::strrchr(termfilename.data(), '/');
if ( term_basename == nullptr )
term_basename = termfilename;
term_basename = termfilename.data();
else
term_basename++;
@ -254,11 +254,11 @@ bool FTermDetection::getTTYSFileEntry()
// get term basename
const auto& fterm_data = FTerm::getFTermData();
const char* termfilename = fterm_data->getTermFileName();
const char* term_basename = std::strrchr(termfilename, '/');
const auto& termfilename = fterm_data->getTermFileName();
const char* term_basename = std::strrchr(termfilename.data(), '/');
if ( term_basename == nullptr )
term_basename = termfilename;
term_basename = termfilename.data();
else
term_basename++;

View File

@ -24,6 +24,7 @@
#include <unistd.h> // need for ttyname_r
#endif
#include <numeric>
#include <queue>
#include <string>
#include <vector>
@ -68,10 +69,7 @@ uInt FVTerm::clr_eol_length{};
uInt FVTerm::cursor_address_length{};
struct timeval FVTerm::time_last_flush{};
struct timeval FVTerm::last_term_size_check{};
std::vector<int>* FVTerm::output_buffer{nullptr};
FPoint* FVTerm::term_pos{nullptr};
const FVTerm* FVTerm::init_object{nullptr};
FTerm* FVTerm::fterm{nullptr};
FVTerm::FTermArea* FVTerm::vterm{nullptr};
FVTerm::FTermArea* FVTerm::vdesktop{nullptr};
FVTerm::FTermArea* FVTerm::active_area{nullptr};
@ -91,6 +89,12 @@ FVTerm::FVTerm()
{
if ( ! init_object )
init();
else
{
fterm = std::shared_ptr<FTerm>(init_object->fterm);
term_pos = std::shared_ptr<FPoint>(init_object->term_pos);
output_buffer = std::shared_ptr<OutputBuffer>(init_object->output_buffer);
}
}
//----------------------------------------------------------------------
@ -150,7 +154,7 @@ void FVTerm::setTermXY (int x, int y) const
const char* move_str = FTerm::moveCursorString (term_x, term_y, x, y);
if ( move_str )
appendOutputBuffer(move_str);
appendOutputBuffer(FTermControl{move_str});
term_pos->setPoint(x, y);
}
@ -185,7 +189,7 @@ void FVTerm::hideCursor (bool enable) const
if ( ! visibility_str ) // Exit the function if the string is empty
return;
appendOutputBuffer(visibility_str);
appendOutputBuffer(FTermControl{visibility_str});
flush();
}
@ -565,7 +569,7 @@ void FVTerm::print (const FColorPair& pair)
}
//----------------------------------------------------------------------
void FVTerm::flush()
void FVTerm::flush() const
{
// Flush the output buffer
@ -573,15 +577,28 @@ void FVTerm::flush()
|| ! (isFlushTimeout() || force_terminal_update) )
return;
while ( ! output_buffer->empty() )
{
const auto& first = output_buffer->front();
const auto& type = std::get<0>(first);
const auto& wstring = std::get<1>(first);
if ( type == OutputType::String )
{
static const FTerm::defaultPutChar& FTermPutchar = FTerm::putchar();
if ( ! FTermPutchar )
return;
for (auto&& ch : *output_buffer)
FTermPutchar(ch);
for (auto&& ch : wstring)
FTermPutchar(int(ch));
}
else if ( type == OutputType::Control )
FTerm::putstring (std::string(wstring.begin(), wstring.end()));
output_buffer->pop();
}
output_buffer->clear();
std::fflush(stdout);
const auto& mouse = FTerm::getFMouseControl();
mouse->drawPointer();
@ -1809,9 +1826,9 @@ void FVTerm::init()
try
{
fterm = new FTerm();
term_pos = new FPoint(-1, -1);
output_buffer = new std::vector<int>;
fterm = std::make_shared<FTerm>();
term_pos = std::make_shared<FPoint>(-1, -1);
output_buffer = std::make_shared<OutputBuffer>();
}
catch (const std::bad_alloc&)
{
@ -1823,9 +1840,6 @@ void FVTerm::init()
// The final setting is made later in FTerm::init_locale().
std::setlocale (LC_ALL, "");
// Reserve memory on the terminal output buffer
output_buffer->reserve(TERMINAL_OUTPUT_BUFFER_SIZE + 256);
// term_attribute stores the current state of the terminal
term_attribute.ch = {{ L'\0' }};
term_attribute.fg_color = FColor::Default;
@ -1921,19 +1935,10 @@ void FVTerm::finish()
forceTerminalUpdate();
if ( output_buffer )
delete output_buffer;
// remove virtual terminal + virtual desktop area
removeArea (vdesktop);
removeArea (vterm);
if ( term_pos )
delete term_pos;
if ( fterm )
delete fterm;
init_object = nullptr;
}
@ -2046,13 +2051,13 @@ bool FVTerm::clearTerm (wchar_t fillchar) const
if ( cl ) // Clear screen
{
appendOutputBuffer (cl);
appendOutputBuffer (FTermControl{cl});
term_pos->setPoint(0, 0);
}
else if ( cd ) // Clear to end of screen
{
setTermXY (0, 0);
appendOutputBuffer (cd);
appendOutputBuffer (FTermControl{cd});
term_pos->setPoint(-1, -1);
}
else if ( cb ) // Clear to end of line
@ -2062,7 +2067,7 @@ bool FVTerm::clearTerm (wchar_t fillchar) const
for (auto i{0}; i < int(FTerm::getLineNumber()); i++)
{
setTermXY (0, i);
appendOutputBuffer (cb);
appendOutputBuffer (FTermControl{cb});
}
setTermXY (0, 0);
@ -2382,7 +2387,7 @@ void FVTerm::printFullWidthCharacter ( uInt& x, uInt y
{
// Print ellipses for the 1st full-width character column
appendAttributes (print_char);
appendOutputBuffer (int(UniChar::HorizontalEllipsis));
appendOutputBuffer (FTermChar{wchar_t(UniChar::HorizontalEllipsis)});
term_pos->x_ref()++;
markAsPrinted (x, y);
@ -2391,7 +2396,7 @@ void FVTerm::printFullWidthCharacter ( uInt& x, uInt y
// Print ellipses for the 2nd full-width character column
x++;
appendAttributes (next_char);
appendOutputBuffer (int(UniChar::HorizontalEllipsis));
appendOutputBuffer (FTermChar{wchar_t(UniChar::HorizontalEllipsis)});
term_pos->x_ref()++;
markAsPrinted (x, y);
}
@ -2417,9 +2422,9 @@ void FVTerm::printFullWidthPaddingCharacter ( uInt& x, uInt y
const auto& LE = TCAP(t_parm_left_cursor);
if ( le )
appendOutputBuffer (le);
appendOutputBuffer (FTermControl{le});
else if ( LE )
appendOutputBuffer (FTermcap::encodeParameter(LE, 1, 0, 0, 0, 0, 0, 0, 0, 0));
appendOutputBuffer (FTermControl{FTermcap::encodeParameter(LE, 1, 0, 0, 0, 0, 0, 0, 0, 0)});
else
{
skipPaddingCharacter (x, y, prev_char);
@ -2437,7 +2442,7 @@ void FVTerm::printFullWidthPaddingCharacter ( uInt& x, uInt y
{
// Print ellipses for the 1st full-width character column
appendAttributes (print_char);
appendOutputBuffer (int(UniChar::HorizontalEllipsis));
appendOutputBuffer (FTermChar{wchar_t(UniChar::HorizontalEllipsis)});
term_pos->x_ref()++;
markAsPrinted (x, y);
}
@ -2457,9 +2462,9 @@ void FVTerm::printHalfCovertFullWidthCharacter ( uInt& x, uInt y
const auto& LE = TCAP(t_parm_left_cursor);
if ( le )
appendOutputBuffer (le);
appendOutputBuffer (FTermControl{le});
else if ( LE )
appendOutputBuffer (FTermcap::encodeParameter(LE, 1, 0, 0, 0, 0, 0, 0, 0, 0));
appendOutputBuffer (FTermControl{FTermcap::encodeParameter(LE, 1, 0, 0, 0, 0, 0, 0, 0, 0)});
if ( le || LE )
{
@ -2467,7 +2472,7 @@ void FVTerm::printHalfCovertFullWidthCharacter ( uInt& x, uInt y
x--;
term_pos->x_ref()--;
appendAttributes (prev_char);
appendOutputBuffer (int(UniChar::HorizontalEllipsis));
appendOutputBuffer (FTermChar{wchar_t(UniChar::HorizontalEllipsis)});
term_pos->x_ref()++;
markAsPrinted (x, y);
x++;
@ -2531,7 +2536,7 @@ FVTerm::PrintState FVTerm::eraseCharacters ( uInt& x, uInt xmax, uInt y
&& (ut || normal) )
{
appendAttributes (print_char);
appendOutputBuffer (FTermcap::encodeParameter(ec, whitespace, 0, 0, 0, 0, 0, 0, 0, 0));
appendOutputBuffer (FTermControl{FTermcap::encodeParameter(ec, whitespace, 0, 0, 0, 0, 0, 0, 0, 0)});
if ( x + whitespace - 1 < xmax || draw_trailing_ws )
setTermXY (int(x + whitespace), int(y));
@ -2596,7 +2601,7 @@ FVTerm::PrintState FVTerm::repeatCharacter (uInt& x, uInt xmax, uInt y) const
newFontChanges (print_char);
charsetChanges (print_char);
appendAttributes (print_char);
appendOutputBuffer (FTermcap::encodeParameter(rp, print_char.ch[0], repetitions, 0, 0, 0, 0, 0, 0, 0));
appendOutputBuffer (FTermControl{FTermcap::encodeParameter(rp, print_char.ch[0], repetitions, 0, 0, 0, 0, 0, 0, 0)});
term_pos->x_ref() += int(repetitions);
x = x + repetitions - 1;
}
@ -2630,7 +2635,7 @@ inline bool FVTerm::isFullWidthPaddingChar (const FChar& ch) const
}
//----------------------------------------------------------------------
void FVTerm::cursorWrap()
void FVTerm::cursorWrap() const
{
// Wrap the cursor
const auto& vt = vterm;
@ -2790,7 +2795,7 @@ bool FVTerm::updateTerminalLine (uInt y) const
{
auto& min_char = vt->data[y * uInt(vt->width) + xmin];
appendAttributes (min_char);
appendOutputBuffer (ce);
appendOutputBuffer (FTermControl{ce});
markAsPrinted (xmin, uInt(vt->width - 1), y);
}
else
@ -2800,7 +2805,7 @@ bool FVTerm::updateTerminalLine (uInt y) const
const auto& cb = TCAP(t_clr_bol);
auto& first_char = vt->data[y * uInt(vt->width)];
appendAttributes (first_char);
appendOutputBuffer (cb);
appendOutputBuffer (FTermControl{cb});
markAsPrinted (0, xmin, y);
}
@ -2810,7 +2815,7 @@ bool FVTerm::updateTerminalLine (uInt y) const
{
auto& last_char = vt->data[(y + 1) * uInt(vt->width) - 1];
appendAttributes (last_char);
appendOutputBuffer (ce);
appendOutputBuffer (FTermControl{ce});
markAsPrinted (xmax + 1, uInt(vt->width - 1), y);
}
}
@ -3006,7 +3011,7 @@ inline void FVTerm::appendChar (FChar& next_char) const
for (auto&& ch : next_char.encoded_char)
{
if ( ch != L'\0')
appendOutputBuffer(ch);
appendOutputBuffer (FTermChar{ch});
if ( ! combined_char_support )
return;
@ -3020,7 +3025,7 @@ inline void FVTerm::appendAttributes (FChar& next_attr) const
const auto& attr_str = FTerm::changeAttribute (term_attribute, next_attr);
if ( attr_str )
appendOutputBuffer (attr_str);
appendOutputBuffer (FTermControl{attr_str});
}
//----------------------------------------------------------------------
@ -3035,9 +3040,9 @@ void FVTerm::appendLowerRight (FChar& last_char) const
}
else if ( SA && RA )
{
appendOutputBuffer (RA);
appendOutputBuffer (FTermControl{RA});
appendChar (last_char);
appendOutputBuffer (SA);
appendOutputBuffer (FTermControl{SA});
}
else
{
@ -3058,32 +3063,32 @@ void FVTerm::appendLowerRight (FChar& last_char) const
if ( IC )
{
appendOutputBuffer (FTermcap::encodeParameter(IC, 1, 0, 0, 0, 0, 0, 0, 0, 0));
appendOutputBuffer (FTermControl{FTermcap::encodeParameter(IC, 1, 0, 0, 0, 0, 0, 0, 0, 0)});
appendChar (second_last);
}
else if ( im && ei )
{
appendOutputBuffer (im);
appendOutputBuffer (FTermControl{im});
appendChar (second_last);
if ( ip )
appendOutputBuffer (ip);
appendOutputBuffer (FTermControl{ip});
appendOutputBuffer (ei);
appendOutputBuffer (FTermControl{ei});
}
else if ( ic )
{
appendOutputBuffer (ic);
appendOutputBuffer (FTermControl{ic});
appendChar (second_last);
if ( ip )
appendOutputBuffer (ip);
appendOutputBuffer (FTermControl{ip});
}
}
}
//----------------------------------------------------------------------
inline void FVTerm::characterFilter (FChar& next_char)
inline void FVTerm::characterFilter (FChar& next_char) const
{
charSubstitution& sub_map = fterm->getCharSubstitutionMap();
@ -3092,22 +3097,50 @@ inline void FVTerm::characterFilter (FChar& next_char)
}
//----------------------------------------------------------------------
inline void FVTerm::appendOutputBuffer (const std::string& str)
inline bool FVTerm::isOutputBufferLimitReached() const
{
for (auto&& ch : str)
FVTerm::appendOutputBuffer(int(ch));
return output_buffer->size() >= TERMINAL_OUTPUT_BUFFER_LIMIT;
}
//----------------------------------------------------------------------
int FVTerm::appendOutputBuffer (int ch)
inline void FVTerm::appendOutputBuffer (const FTermControl& ctrl) const
{
// append method for unicode character
output_buffer->push_back(ch);
const auto& wstring = std::wstring{ctrl.string.begin(), ctrl.string.end()};
output_buffer->emplace(std::make_tuple(OutputType::Control, wstring));
if ( output_buffer->size() >= TERMINAL_OUTPUT_BUFFER_SIZE )
if ( isOutputBufferLimitReached() )
flush();
}
//----------------------------------------------------------------------
inline void FVTerm::appendOutputBuffer (const FTermChar& c) const
{
if ( c.ch != L'\0' )
appendOutputBuffer(FTermString{std::wstring(1, c.ch)});
}
//----------------------------------------------------------------------
void FVTerm::appendOutputBuffer (const FTermString& str) const
{
if ( ! output_buffer->empty()
&& std::get<0>(output_buffer->back()) == OutputType::String )
{
// Append string data to the back element
auto& string_buf = std::get<1>(output_buffer->back());
std::transform ( str.string.begin()
, str.string.end()
, std::back_inserter(string_buf)
, [] (wchar_t ch)
{
return ch;
}
);
}
else
output_buffer->emplace(std::make_tuple(OutputType::String, str.string));
if ( isOutputBufferLimitReached() )
flush();
}
} // namespace finalcut

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2012-2020 Markus Gans *
* Copyright 2012-2021 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 *
@ -89,27 +89,20 @@ class FButton : public FWidget
void setInactiveForegroundColor (FColor);
void setInactiveBackgroundColor (FColor);
void resetColors() override;
bool setNoUnderline(bool);
bool setNoUnderline();
bool setNoUnderline (bool = true);
bool unsetNoUnderline();
bool setEnable(bool) override;
bool setEnable() override;
bool setEnable (bool = true) override;
bool unsetEnable() override;
bool setDisable() override;
bool setFocus(bool) override;
bool setFocus() override;
bool setFocus (bool = true) override;
bool unsetFocus() override;
bool setFlat(bool);
bool setFlat();
bool setFlat (bool = true);
bool unsetFlat();
bool setShadow(bool);
bool setShadow();
bool setShadow (bool = true);
bool unsetShadow();
bool setDown(bool);
bool setDown();
bool setDown (bool = true);
bool setUp();
bool setClickAnimation(bool);
bool setClickAnimation();
bool setClickAnimation (bool = true);
bool unsetClickAnimation();
void setText (const FString&);
@ -181,18 +174,10 @@ inline FString FButton::getClassName() const
inline FString FButton::getText() const
{ return text; }
//----------------------------------------------------------------------
inline bool FButton::setNoUnderline()
{ return setNoUnderline(true); }
//----------------------------------------------------------------------
inline bool FButton::unsetNoUnderline()
{ return setNoUnderline(false); }
//----------------------------------------------------------------------
inline bool FButton::setEnable()
{ return setEnable(true); }
//----------------------------------------------------------------------
inline bool FButton::unsetEnable()
{ return setEnable(false); }
@ -201,34 +186,18 @@ inline bool FButton::unsetEnable()
inline bool FButton::setDisable()
{ return setEnable(false); }
//----------------------------------------------------------------------
inline bool FButton::setFocus()
{ return setFocus(true); }
//----------------------------------------------------------------------
inline bool FButton::unsetFocus()
{ return setFocus(false); }
//----------------------------------------------------------------------
inline bool FButton::setFlat()
{ return setFlat(true); }
//----------------------------------------------------------------------
inline bool FButton::unsetFlat()
{ return setFlat(false); }
//----------------------------------------------------------------------
inline bool FButton::setShadow()
{ return setShadow(true); }
//----------------------------------------------------------------------
inline bool FButton::unsetShadow()
{ return setShadow(false); }
//----------------------------------------------------------------------
inline bool FButton::setDown()
{ return setDown(true); }
//----------------------------------------------------------------------
inline bool FButton::setUp()
{ return setDown(false); }
@ -237,10 +206,6 @@ inline bool FButton::setUp()
inline bool FButton::setClickAnimation(bool enable)
{ return (click_animation = enable); }
//----------------------------------------------------------------------
inline bool FButton::setClickAnimation()
{ return setClickAnimation(true); }
//----------------------------------------------------------------------
inline bool FButton::unsetClickAnimation()
{ return setClickAnimation(false); }

View File

@ -4,7 +4,7 @@
* *
* 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 *
* it under the terms of the GNU Lesser General Public License as *
@ -86,8 +86,7 @@ class FButtonGroup : public FScrollView
FString& getText();
// Mutator
bool setEnable(bool) override;
bool setEnable() override;
bool setEnable (bool = true) override;
bool unsetEnable() override;
bool setDisable() override;
void setText (const FString&);
@ -146,10 +145,6 @@ class FButtonGroup : public FScrollView
inline FString FButtonGroup::getClassName() const
{ return "FButtonGroup"; }
//----------------------------------------------------------------------
inline bool FButtonGroup::setEnable()
{ return setEnable(true); }
//----------------------------------------------------------------------
inline bool FButtonGroup::unsetEnable()
{ return setEnable(false); }

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2019-2020 Markus Gans *
* Copyright 2019-2021 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 *
@ -162,18 +162,14 @@ class FComboBox : public FWidget
void setSize (const FSize&, bool = true) override;
void setGeometry ( const FPoint&, const FSize&
, bool = true ) override;
bool setEnable (bool) override;
bool setEnable() override;
bool setEnable (bool = true) override;
bool unsetEnable() override;
bool setDisable() override;
bool setFocus (bool) override;
bool setFocus() override;
bool setFocus (bool = true) override;
bool unsetFocus() override;
bool setShadow (bool);
bool setShadow();
bool setShadow (bool = true);
bool unsetShadow();
bool setEditable (bool);
bool setEditable();
bool setEditable (bool = true);
bool unsetEditable();
void setCurrentItem (std::size_t);
void setMaxVisibleItems (std::size_t);
@ -265,10 +261,6 @@ inline clean_fdata_t<DT>& FComboBox::getItemData()
inline FLineEdit::LabelOrientation FComboBox::getLabelOrientation() const
{ return input_field.getLabelOrientation(); }
//----------------------------------------------------------------------
inline bool FComboBox::setEnable()
{ return setEnable(true); }
//----------------------------------------------------------------------
inline bool FComboBox::unsetEnable()
{ return setEnable(false); }
@ -277,26 +269,14 @@ inline bool FComboBox::unsetEnable()
inline bool FComboBox::setDisable()
{ return setEnable(false); }
//----------------------------------------------------------------------
inline bool FComboBox::setFocus()
{ return setFocus(true); }
//----------------------------------------------------------------------
inline bool FComboBox::unsetFocus()
{ return setFocus(false); }
//----------------------------------------------------------------------
inline bool FComboBox::setShadow()
{ return setShadow(true); }
//----------------------------------------------------------------------
inline bool FComboBox::unsetShadow()
{ return setShadow(false); }
//----------------------------------------------------------------------
inline bool FComboBox::setEditable()
{ return setEditable(true); }
//----------------------------------------------------------------------
inline bool FComboBox::unsetEditable()
{ return setEditable(false); }

View File

@ -97,18 +97,14 @@ class FDialog : public FWindow
virtual FString getText() const;
// Mutators
bool setDialogWidget (bool);
bool setDialogWidget();
bool setDialogWidget (bool = true);
bool unsetDialogWidget();
bool setModal (bool);
bool setModal();
bool setModal (bool = true);
bool unsetModal();
bool setResizeable (bool) override;
bool setScrollable (bool);
bool setScrollable();
bool setResizeable (bool = true) override;
bool setScrollable (bool = true);
bool unsetScrollable();
bool setBorder (bool);
bool setBorder();
bool setBorder (bool = true);
bool unsetBorder();
void resetColors() override;
virtual void setText (const FString&);
@ -252,34 +248,18 @@ inline FString FDialog::getClassName() const
inline FString FDialog::getText() const
{ return tb_text; }
//----------------------------------------------------------------------
inline bool FDialog::setDialogWidget()
{ return setDialogWidget(true); }
//----------------------------------------------------------------------
inline bool FDialog::unsetDialogWidget()
{ return setDialogWidget(false); }
//----------------------------------------------------------------------
inline bool FDialog::setModal()
{ return setModal(true); }
//----------------------------------------------------------------------
inline bool FDialog::unsetModal()
{ return setModal(false); }
//----------------------------------------------------------------------
inline bool FDialog::setScrollable()
{ return setScrollable(true); }
//----------------------------------------------------------------------
inline bool FDialog::unsetScrollable()
{ return setScrollable(false); }
//----------------------------------------------------------------------
inline bool FDialog::setBorder()
{ return setBorder(true); }
//----------------------------------------------------------------------
inline bool FDialog::unsetBorder()
{ return setBorder(false); }

View File

@ -3,7 +3,7 @@
* *
* 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 *
* it under the terms of the GNU Lesser General Public License as *
@ -121,8 +121,7 @@ class FFileDialog : public FDialog
// Mutators
void setPath (const FString&);
void setFilter (const FString&);
bool setShowHiddenFiles(bool);
bool setShowHiddenFiles();
bool setShowHiddenFiles (bool = true);
bool unsetShowHiddenFiles();
// Event handler
@ -249,10 +248,6 @@ inline FString FFileDialog::getPath() const
inline FString FFileDialog::getFilter() const
{ return filter_pattern; }
//----------------------------------------------------------------------
inline bool FFileDialog::setShowHiddenFiles()
{ return setShowHiddenFiles(true); }
//----------------------------------------------------------------------
inline bool FFileDialog::unsetShowHiddenFiles()
{ return setShowHiddenFiles(false); }

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2018-2020 Markus Gans *
* Copyright 2018-2021 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 *
@ -118,9 +118,8 @@ class FKeyboard final
void setTermcapMap();
static void setKeypressTimeout (const uInt64);
static void setReadBlockingTime (const uInt64);
static void setNonBlockingInputSupport (bool);
bool setNonBlockingInput (bool);
bool setNonBlockingInput();
static void setNonBlockingInputSupport (bool = true);
bool setNonBlockingInput (bool = true);
bool unsetNonBlockingInput();
void enableUTF8();
void disableUTF8();
@ -250,10 +249,6 @@ inline void FKeyboard::setReadBlockingTime (const uInt64 blocking_time)
inline void FKeyboard::setNonBlockingInputSupport (bool enable)
{ non_blocking_input_support = enable; }
//----------------------------------------------------------------------
inline bool FKeyboard::setNonBlockingInput()
{ return setNonBlockingInput(true); }
//----------------------------------------------------------------------
inline bool FKeyboard::unsetNonBlockingInput()
{ return setNonBlockingInput(false); }

View File

@ -3,7 +3,7 @@
* *
* 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 *
* it under the terms of the GNU Lesser General Public License as *
@ -95,14 +95,12 @@ class FLabel : public FWidget
// Mutators
void setAccelWidget (FWidget* = nullptr);
void setAlignment (Align);
bool setEmphasis (bool);
bool setEmphasis();
bool setEmphasis (bool = true);
bool unsetEmphasis();
void resetColors() override;
bool setReverseMode (bool);
bool setReverseMode();
bool setReverseMode (bool = true);
bool unsetReverseMode();
bool setEnable (bool) override;
bool setEnable (bool = true) override;
void setNumber (uLong);
void setNumber (long);
void setNumber (float, int = FLT_DIG);
@ -184,10 +182,6 @@ inline FString& FLabel::getText()
inline bool FLabel::setEmphasis (bool enable)
{ return (emphasis = enable); }
//----------------------------------------------------------------------
inline bool FLabel::setEmphasis()
{ return setEmphasis(true); }
//----------------------------------------------------------------------
inline bool FLabel::unsetEmphasis()
{ return setEmphasis(false); }
@ -196,10 +190,6 @@ inline bool FLabel::unsetEmphasis()
inline bool FLabel::setReverseMode (bool enable)
{ return (reverse_mode = enable); }
//----------------------------------------------------------------------
inline bool FLabel::setReverseMode()
{ return setReverseMode(true); }
//----------------------------------------------------------------------
inline bool FLabel::unsetReverseMode()
{ return setReverseMode(false); }

View File

@ -125,18 +125,14 @@ class FLineEdit : public FWidget
void setSize (const FSize&, bool = true) override;
void setGeometry ( const FPoint&, const FSize&
, bool = true ) override;
bool setEnable (bool) override;
bool setEnable() override;
bool setEnable (bool = true) override;
bool unsetEnable() override;
bool setDisable() override;
bool setFocus (bool) override;
bool setFocus() override;
bool setFocus (bool = true) override;
bool unsetFocus() override;
bool setShadow (bool);
bool setShadow();
bool setShadow (bool = true);
bool unsetShadow();
bool setReadOnly (bool);
bool setReadOnly();
bool setReadOnly (bool = true);
bool unsetReadOnly();
// Inquiry
@ -273,10 +269,6 @@ inline void FLineEdit::setInputType (const InputType type)
inline void FLineEdit::setLabelAssociatedWidget (FWidget* w)
{ label_associated_widget = w; }
//----------------------------------------------------------------------
inline bool FLineEdit::setEnable()
{ return setEnable(true); }
//----------------------------------------------------------------------
inline bool FLineEdit::unsetEnable()
{ return setEnable(false); }
@ -285,26 +277,14 @@ inline bool FLineEdit::unsetEnable()
inline bool FLineEdit::setDisable()
{ return setEnable(false); }
//----------------------------------------------------------------------
inline bool FLineEdit::setFocus()
{ return setFocus(true); }
//----------------------------------------------------------------------
inline bool FLineEdit::unsetFocus()
{ return setFocus(false); }
//----------------------------------------------------------------------
inline bool FLineEdit::setShadow()
{ return setShadow(true); }
//----------------------------------------------------------------------
inline bool FLineEdit::unsetShadow()
{ return setShadow(false); }
//----------------------------------------------------------------------
inline bool FLineEdit::setReadOnly()
{ return setReadOnly(true); }
//----------------------------------------------------------------------
inline bool FLineEdit::unsetReadOnly()
{ return setReadOnly(true); }

View File

@ -214,8 +214,7 @@ class FListBox : public FWidget
void setSize (const FSize&, bool = true) override;
void setGeometry ( const FPoint&, const FSize&
, bool = true ) override;
void setMultiSelection (bool);
void setMultiSelection ();
void setMultiSelection (bool = true);
void unsetMultiSelection ();
bool setDisable() override;
void setText (const FString&);
@ -501,10 +500,6 @@ inline void FListBox::showNoBrackets (FListBoxItems::iterator iter) const
inline void FListBox::setMultiSelection (bool enable)
{ multi_select = enable; }
//----------------------------------------------------------------------
inline void FListBox::setMultiSelection()
{ setMultiSelection(true); }
//----------------------------------------------------------------------
inline void FListBox::unsetMultiSelection()
{ setMultiSelection(false); }

View File

@ -101,8 +101,8 @@ class FListViewItem : public FObject
void setText (int, const FString&);
template <typename DT>
void setData (DT&&);
void setCheckable (bool);
void setChecked (bool);
void setCheckable (bool = true);
void setChecked (bool = true);
// Inquiry
bool isChecked() const;
@ -335,9 +335,8 @@ class FListView : public FWidget
void setUserAscendingCompare (Compare);
template <typename Compare>
void setUserDescendingCompare (Compare);
void hideSortIndicator (bool);
bool setTreeView (bool);
bool setTreeView();
void hideSortIndicator (bool = true);
bool setTreeView (bool = true);
bool unsetTreeView();
// Methods
@ -585,10 +584,6 @@ inline void FListView::hideSortIndicator (bool hide)
inline bool FListView::setTreeView (bool enable)
{ return (tree_view = enable); }
//----------------------------------------------------------------------
inline bool FListView::setTreeView()
{ return setTreeView(true); }
//----------------------------------------------------------------------
inline bool FListView::unsetTreeView()
{ return setTreeView(false); }

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2015-2020 Markus Gans *
* Copyright 2015-2021 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 *
@ -96,14 +96,12 @@ class FMenu : public FWindow, public FMenuList
FMenuItem* getItem();
// Mutators
bool setEnable (bool) override;
bool setEnable() override;
bool setEnable (bool = true) override;
bool unsetEnable() override;
bool setDisable() override;
void setSelected();
void unsetSelected();
bool setMenuWidget (bool);
bool setMenuWidget();
bool setMenuWidget (bool = true);
bool unsetMenuWidget();
void setStatusbarMessage (const FString&) override;
void setMenu (FMenu*);
@ -262,10 +260,6 @@ inline FMenuItem* FMenu::getItem()
inline bool FMenu::setEnable (bool enable)
{ return menuitem.setEnable(enable); }
//----------------------------------------------------------------------
inline bool FMenu::setEnable()
{ return menuitem.setEnable(); }
//----------------------------------------------------------------------
inline bool FMenu::unsetEnable()
{ return menuitem.unsetEnable(); }
@ -282,10 +276,6 @@ inline void FMenu::setSelected()
inline void FMenu::unsetSelected()
{ menuitem.unsetSelected(); }
//----------------------------------------------------------------------
inline bool FMenu::setMenuWidget()
{ return setMenuWidget(true); }
//----------------------------------------------------------------------
inline bool FMenu::unsetMenuWidget()
{ return setMenuWidget(false); }

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2015-2020 Markus Gans *
* Copyright 2015-2021 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 *
@ -96,9 +96,8 @@ class FMenuItem : public FWidget
FString getText() const;
// Mutators
bool setEnable (bool) override;
bool setFocus (bool) override;
bool setFocus() override;
bool setEnable (bool = true) override;
bool setFocus (bool = true) override;
bool unsetFocus() override;
void setSelected();
void unsetSelected();
@ -219,10 +218,6 @@ inline std::size_t FMenuItem::getTextWidth() const
inline FString FMenuItem::getText() const
{ return text; }
//----------------------------------------------------------------------
inline bool FMenuItem::setFocus()
{ return setFocus(true); }
//----------------------------------------------------------------------
inline bool FMenuItem::unsetFocus()
{ return setFocus(false); }

View File

@ -3,7 +3,7 @@
* *
* 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 *
* it under the terms of the GNU Lesser General Public License as *
@ -117,8 +117,7 @@ class FMessageBox : public FDialog
// Mutator
void setTitlebarText (const FString&);
void setHeadline (const FString&);
bool setCenterText(bool);
bool setCenterText();
bool setCenterText (bool = true);
bool unsetCenterText();
void setText (const FString&) override;
@ -206,10 +205,6 @@ inline void FMessageBox::setTitlebarText (const FString& txt)
inline bool FMessageBox::setCenterText(bool enable)
{ return (center_text = enable); }
//----------------------------------------------------------------------
inline bool FMessageBox::setCenterText()
{ return setCenterText(true); }
//----------------------------------------------------------------------
inline bool FMessageBox::unsetCenterText()
{ return setCenterText(false); }

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2018-2020 Markus Gans *
* Copyright 2018-2021 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 *
@ -213,7 +213,7 @@ class FMouse : public FMouseData
// Mutator
void setNewPos (int, int);
void setPending (bool);
void setPending (bool = true);
void setEvent();
void setMousePressedTime (const timeval*);
void resetMousePressedTime();
@ -264,13 +264,13 @@ class FMouseGPM final : public FMouse
// Methods
void setRawData (FKeyboard::keybuffer&) override;
void processEvent (struct timeval*) override;
bool gpmMouse (bool);
bool gpmMouse (bool = true);
bool enableGpmMouse();
bool disableGpmMouse();
bool hasSignificantEvents() const;
void interpretKeyDown();
void interpretKeyUp();
bool getGpmKeyPressed(bool);
bool getGpmKeyPressed (bool = true);
void drawPointer() const;
private:
@ -545,7 +545,7 @@ class FMouseControl
, FKeyboard::keybuffer& );
virtual void processEvent (struct timeval* time);
void processQueuedInput();
bool getGpmKeyPressed (bool);
bool getGpmKeyPressed (bool = true);
void drawPointer();
private:
@ -557,7 +557,7 @@ class FMouseControl
// Accessor
FMouse::MouseType getMouseWithData();
FMouse::MouseType getMouseWithEvent();
void xtermMouse (bool) const;
void xtermMouse (bool = true) const;
void enableXTermMouse() const;
void disableXTermMouse() const;

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2015-2020 Markus Gans *
* Copyright 2015-2021 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 *
@ -158,7 +158,7 @@ class FObject
FTimerList* getTimerList() const;
// Mutator
void setWidgetProperty (bool);
void setWidgetProperty (bool = true);
// Method
uInt processTimerEvent();

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2015-2020 Markus Gans *
* Copyright 2015-2021 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 *
@ -138,8 +138,8 @@ class FOptiMove final
void set_repeat_char (const char[]);
void set_clr_bol (const char[]);
void set_clr_eol (const char[]);
void set_auto_left_margin (bool);
void set_eat_newline_glitch (bool);
void set_auto_left_margin (bool = true);
void set_eat_newline_glitch (bool = true);
// Methods
void check_boundaries (int&, int&, int&, int&) const;

View File

@ -3,7 +3,7 @@
* *
* 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 *
* it under the terms of the GNU Lesser General Public License as *
@ -77,8 +77,7 @@ class FProgressbar : public FWidget
void setSize (const FSize&, bool = true) override;
void setGeometry ( const FPoint&, const FSize&
, bool = true ) override;
bool setShadow (bool);
bool setShadow();
bool setShadow (bool = true);
bool unsetShadow();
// Inquiries
@ -115,10 +114,6 @@ inline FString FProgressbar::getClassName() const
inline std::size_t FProgressbar::getPercentage() const
{ return percentage; }
//----------------------------------------------------------------------
inline bool FProgressbar::setShadow()
{ return setShadow(true); }
//----------------------------------------------------------------------
inline bool FProgressbar::unsetShadow()
{ return setShadow(false); }

View File

@ -105,12 +105,10 @@ class FScrollView : public FWidget
, bool = true ) override;
bool setCursorPos (const FPoint&) override;
void setPrintPos (const FPoint&) override;
bool setViewportPrint (bool);
bool setViewportPrint();
bool setViewportPrint (bool = true);
bool unsetViewportPrint();
void resetColors() override;
bool setBorder (bool);
bool setBorder();
bool setBorder (bool = true);
bool unsetBorder();
void setHorizontalScrollBarMode (ScrollBarMode);
void setVerticalScrollBarMode (ScrollBarMode);
@ -230,18 +228,10 @@ inline int FScrollView::getScrollX() const
inline int FScrollView::getScrollY() const
{ return viewport_geometry.getY(); }
//----------------------------------------------------------------------
inline bool FScrollView::setViewportPrint()
{ return setViewportPrint(true); }
//----------------------------------------------------------------------
inline bool FScrollView::unsetViewportPrint()
{ return setViewportPrint(false); }
//----------------------------------------------------------------------
inline bool FScrollView::setBorder()
{ return setBorder(true); }
//----------------------------------------------------------------------
inline bool FScrollView::unsetBorder()
{ return setBorder(false); }

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2019-2020 Markus Gans *
* Copyright 2019-2021 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 *
@ -91,15 +91,12 @@ class FSpinBox : public FWidget
void setSize (const FSize&, bool = true) override;
void setGeometry ( const FPoint&, const FSize&
, bool = true ) override;
bool setEnable (bool) override;
bool setEnable() override;
bool setEnable (bool = true) override;
bool unsetEnable() override;
bool setDisable() override;
bool setFocus (bool) override;
bool setFocus() override;
bool setFocus (bool = true) override;
bool unsetFocus() override;
bool setShadow (bool);
bool setShadow();
bool setShadow (bool = true);
bool unsetShadow();
void setValue (sInt64);
void setMinValue (sInt64);
@ -181,10 +178,6 @@ inline FString FSpinBox::getSuffix() const
inline FLineEdit::LabelOrientation FSpinBox::getLabelOrientation() const
{ return input_field.getLabelOrientation(); }
//----------------------------------------------------------------------
inline bool FSpinBox::setEnable()
{ return setEnable(true); }
//----------------------------------------------------------------------
inline bool FSpinBox::unsetEnable()
{ return setEnable(false); }
@ -193,18 +186,10 @@ inline bool FSpinBox::unsetEnable()
inline bool FSpinBox::setDisable()
{ return setEnable(false); }
//----------------------------------------------------------------------
inline bool FSpinBox::setFocus()
{ return setFocus(true); }
//----------------------------------------------------------------------
inline bool FSpinBox::unsetFocus()
{ return setFocus(false); }
//----------------------------------------------------------------------
inline bool FSpinBox::setShadow()
{ return setShadow(true); }
//----------------------------------------------------------------------
inline bool FSpinBox::unsetShadow()
{ return setShadow(false); }

View File

@ -3,7 +3,7 @@
* *
* 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 *
* it under the terms of the GNU Lesser General Public License as *
@ -96,8 +96,7 @@ class FStatusKey : public FWidget
void setText (const FString&);
void setActive();
void unsetActive();
bool setMouseFocus(bool);
bool setMouseFocus();
bool setMouseFocus (bool = true);
bool unsetMouseFocus();
// Inquiry
@ -151,10 +150,6 @@ inline void FStatusKey::setText (const FString& txt)
inline void FStatusKey::unsetActive()
{ active = false; }
//----------------------------------------------------------------------
inline bool FStatusKey::setMouseFocus()
{ return setMouseFocus(true); }
//----------------------------------------------------------------------
inline bool FStatusKey::unsetMouseFocus()
{ return setMouseFocus(false); }

View File

@ -184,8 +184,8 @@ class FTerm final
static FString getKeyName (FKey);
charSubstitution& getCharSubstitutionMap();
static int getTTYFileDescriptor();
static const char* getTermType();
static const char* getTermFileName();
static std::string getTermType();
static std::string getTermFileName();
static int getTabstop();
static int getMaxColor();
static auto getColorPaletteTheme() -> std::shared_ptr<FColorPalette>&;
@ -252,15 +252,13 @@ class FTerm final
// Mutators
static void setFSystem (std::unique_ptr<FSystem>&);
static void setTermType (const char[]);
static void setInsertCursor (bool);
static void setInsertCursor();
static void setTermType (const std::string&);
static void setInsertCursor (bool = true);
static void unsetInsertCursor();
static void redefineDefaultColors (bool);
static void redefineDefaultColors (bool = true);
static void setDblclickInterval (const uInt64);
static void useAlternateScreen (bool);
static bool setUTF8 (bool);
static bool setUTF8();
static void useAlternateScreen (bool = true);
static bool setUTF8 (bool = true);
static bool unsetUTF8();
// Methods
@ -270,7 +268,7 @@ class FTerm final
static int openConsole();
static int closeConsole();
static const char* moveCursorString (int, int, int, int);
static const char* cursorsVisibilityString (bool);
static const char* cursorsVisibilityString (bool = true);
static void detectTermSize();
static void setTermSize (const FSize&);
static void setTermTitle (const FString&);
@ -296,8 +294,8 @@ class FTerm final
static defaultPutChar& putchar(); // function pointer
template <typename... Args>
static void putstringf (const char[], Args&&...);
static void putstring (const char[], int = 1);
static void putstringf (const std::string&, Args&&...);
static void putstring (const std::string&, int = 1);
static int putchar_ASCII (int);
static int putchar_UTF8 (int);
@ -409,18 +407,10 @@ inline void FTerm::setFSystem (std::unique_ptr<FSystem>& fsystem)
getFSystem().swap(fsystem);
}
//----------------------------------------------------------------------
inline void FTerm::setInsertCursor()
{ return setInsertCursor(true); }
//----------------------------------------------------------------------
inline void FTerm::unsetInsertCursor()
{ return setInsertCursor(false); }
//----------------------------------------------------------------------
inline bool FTerm::setUTF8()
{ return setUTF8(true); }
//----------------------------------------------------------------------
inline bool FTerm::unsetUTF8()
{ return setUTF8(false); }
@ -435,18 +425,17 @@ inline void FTerm::setColorPaletteTheme (const FSetPalette& f)
//----------------------------------------------------------------------
template <typename... Args>
inline void FTerm::putstringf (const char format[], Args&&... args)
inline void FTerm::putstringf (const std::string& format, Args&&... args)
{
const int size = std::snprintf (nullptr, 0, format, args...) + 1;
const int size = std::snprintf (nullptr, 0, format.data(), args...) + 1;
if ( size == -1 )
return;
const auto count = std::size_t(size);
std::vector<char> buf(count);
std::snprintf (&buf[0], count, format, std::forward<Args>(args)...);
const auto& fsys = FTerm::getFSystem();
fsys->tputs (&buf[0], 1, FTerm::putchar_ASCII);
std::snprintf (&buf[0], count, format.data(), std::forward<Args>(args)...);
putstring (std::string(&buf[0]), 1);
}
//----------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2016-2020 Markus Gans *
* Copyright 2016-2021 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 *
@ -60,8 +60,6 @@
#include <utility>
#include <vector>
#include "final/ftermcap.h"
// FTermcap string macro
#define TCAP(...) FTermcap::strings[int(Termcap::__VA_ARGS__)].string
@ -93,19 +91,13 @@ class FTermcap final
// Accessors
FString getClassName() const;
template <typename CharT>
static bool getFlag (const CharT&);
template <typename CharT>
static int getNumber (const CharT&);
template <typename CharT>
static char* getString (const CharT&);
template <typename CharT>
static char* encodeMotionParameter (const CharT&, int, int);
template <typename CharT
, typename... Args>
static char* encodeParameter (const CharT&, Args&&...);
template <typename CharT>
static int paddingPrint (const CharT&, int, fn_putc);
static bool getFlag (const std::string&);
static int getNumber (const std::string&);
static char* getString (const std::string&);
static std::string encodeMotionParameter (const std::string&, int, int);
template <typename... Args>
static std::string encodeParameter (const std::string&, Args&&...);
static int paddingPrint (const std::string&, int, fn_putc);
// Inquiry
static bool isInitialized();
@ -154,46 +146,42 @@ inline FString FTermcap::getClassName() const
{ return "FTermcap"; }
//----------------------------------------------------------------------
template <typename CharT>
bool FTermcap::getFlag (const CharT& cap)
inline bool FTermcap::getFlag (const std::string& cap)
{
return ::tgetflag(C_STR(cap));
return ::tgetflag(C_STR(cap.data()));
}
//----------------------------------------------------------------------
template <typename CharT>
int FTermcap::getNumber (const CharT& cap)
inline int FTermcap::getNumber (const std::string& cap)
{
return ::tgetnum(C_STR(cap));
return ::tgetnum(C_STR(cap.data()));
}
//----------------------------------------------------------------------
template <typename CharT>
char* FTermcap::getString (const CharT& cap)
inline char* FTermcap::getString (const std::string& cap)
{
return ::tgetstr(C_STR(cap), reinterpret_cast<char**>(&string_buf));
return ::tgetstr(C_STR(cap.data()), reinterpret_cast<char**>(&string_buf));
}
//----------------------------------------------------------------------
template <typename CharT>
char* FTermcap::encodeMotionParameter (const CharT& cap, int col, int row)
inline std::string FTermcap::encodeMotionParameter (const std::string& cap, int col, int row)
{
return ::tgoto(C_STR(cap), col, row);
auto str = ::tgoto(C_STR(cap.data()), col, row);
return ( str ) ? str : std::string();
}
//----------------------------------------------------------------------
template <typename CharT
, typename... Args>
inline char* FTermcap::encodeParameter (const CharT& cap, Args&&... args)
template <typename... Args>
inline std::string FTermcap::encodeParameter (const std::string& cap, Args&&... args)
{
return ::tparm (C_STR(cap), std::forward<Args>(args)...);
auto str = ::tparm (C_STR(cap.data()), std::forward<Args>(args)...);
return ( str ) ? str : std::string();
}
//----------------------------------------------------------------------
template <typename CharT>
int FTermcap::paddingPrint (const CharT& str, int affcnt, fn_putc putc)
inline int FTermcap::paddingPrint (const std::string& str, int affcnt, fn_putc putc)
{
return _tputs (C_STR(str), affcnt, putc);
return _tputs (C_STR(str.data()), affcnt, putc);
}
//----------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2018-2020 Markus Gans *
* Copyright 2018-2021 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 *
@ -76,8 +76,8 @@ class FTermData final
FRect& getTermGeometry();
int getTTYFileDescriptor() const;
uInt getBaudrate() const;
const char* getTermType() const;
const char* getTermFileName() const;
const std::string& getTermType() const;
const std::string& getTermFileName() const;
const FString& getXtermFont() const;
const FString& getXtermTitle() const;
const FString& getExitMessage() const;
@ -105,22 +105,22 @@ class FTermData final
void setTermEncoding (Encoding);
void setTTYFileDescriptor (int);
void setBaudrate (uInt);
void supportShadowCharacter (bool);
void supportHalfBlockCharacter (bool);
void supportCursorOptimisation (bool);
void setCursorHidden (bool);
void useAlternateScreen (bool);
void setAlternateScreenInUse (bool);
void setASCIIConsole (bool);
void setVT100Console (bool);
void setUTF8Console (bool);
void setUTF8 (bool);
void setNewFont (bool);
void setVGAFont (bool);
void setMonochron (bool);
void setTermResized (bool);
void setTermType (const char[]);
void setTermFileName (const char[]);
void supportShadowCharacter (bool = true);
void supportHalfBlockCharacter (bool = true);
void supportCursorOptimisation (bool = true);
void setCursorHidden (bool = true);
void useAlternateScreen (bool = true);
void setAlternateScreenInUse (bool = true);
void setASCIIConsole (bool = true);
void setVT100Console (bool = true);
void setUTF8Console (bool = true);
void setUTF8 (bool = true);
void setNewFont (bool = true);
void setVGAFont (bool = true);
void setMonochron (bool = true);
void setTermResized (bool = true);
void setTermType (const std::string&);
void setTermFileName (const std::string&);
void setXtermFont (const FString&);
void setXtermTitle (const FString&);
void setExitMessage (const FString&);
@ -144,8 +144,8 @@ class FTermData final
#endif
uInt baudrate{0};
char termtype[256]{'\0'};
char termfilename[256]{'\0'};
std::string termtype{};
std::string termfilename{};
bool shadow_character{true};
bool half_block_character{true};
bool cursor_optimisation{true};
@ -192,11 +192,11 @@ inline uInt FTermData::getBaudrate() const
{ return baudrate; }
//----------------------------------------------------------------------
inline const char* FTermData::getTermType() const
inline const std::string& FTermData::getTermType() const
{ return termtype; }
//----------------------------------------------------------------------
inline const char* FTermData::getTermFileName() const
inline const std::string& FTermData::getTermFileName() const
{ return termfilename; }
//----------------------------------------------------------------------
@ -342,23 +342,17 @@ inline void FTermData::setTermResized (bool resize)
{ resize_term = resize; }
//----------------------------------------------------------------------
inline void FTermData::setTermType (const char name[])
inline void FTermData::setTermType (const std::string& name)
{
if ( ! name )
return;
std::strncpy (termtype, name, sizeof(termtype) - 1);
termtype[sizeof(termtype) - 1] = '\0';
if ( ! name.empty() )
termtype = name;
}
//----------------------------------------------------------------------
inline void FTermData::setTermFileName (const char file_name[])
inline void FTermData::setTermFileName (const std::string& file_name)
{
if ( ! file_name )
return;
std::strncpy (termfilename, file_name, sizeof(termfilename) - 1);
termfilename[sizeof(termfilename) - 1] = '\0';
if ( ! file_name.empty() )
termfilename = file_name;
}
//----------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2018-2020 Markus Gans *
* Copyright 2018-2021 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 *
@ -130,27 +130,27 @@ class FTermDetection final
static bool hasSetCursorStyleSupport();
// Mutators
static void setAnsiTerminal (bool);
static void setXTerminal (bool);
static void setRxvtTerminal (bool);
static void setUrxvtTerminal (bool);
static void setKdeTerminal (bool);
static void setGnomeTerminal (bool);
static void setPuttyTerminal (bool);
static void setWindowsTerminal (bool);
static void setTeraTerm (bool);
static void setCygwinTerminal (bool);
static void setMinttyTerm (bool);
static void setLinuxTerm (bool);
static void setFreeBSDTerm (bool);
static void setNetBSDTerm (bool);
static void setOpenBSDTerm (bool);
static void setSunTerminal (bool);
static void setScreenTerm (bool);
static void setTmuxTerm (bool);
static void setKtermTerminal (bool);
static void setMltermTerminal (bool);
static void setTerminalDetection (bool);
static void setAnsiTerminal (bool = true);
static void setXTerminal (bool = true);
static void setRxvtTerminal (bool = true);
static void setUrxvtTerminal (bool = true);
static void setKdeTerminal (bool = true);
static void setGnomeTerminal (bool = true);
static void setPuttyTerminal (bool = true);
static void setWindowsTerminal (bool = true);
static void setTeraTerm (bool = true);
static void setCygwinTerminal (bool = true);
static void setMinttyTerm (bool = true);
static void setLinuxTerm (bool = true);
static void setFreeBSDTerm (bool = true);
static void setNetBSDTerm (bool = true);
static void setOpenBSDTerm (bool = true);
static void setSunTerminal (bool = true);
static void setScreenTerm (bool = true);
static void setTmuxTerm (bool = true);
static void setKtermTerminal (bool = true);
static void setMltermTerminal (bool = true);
static void setTerminalDetection (bool = true);
static void setTtyTypeFileName (const char[]);
// Methods

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2018-2020 Markus Gans *
* Copyright 2018-2021 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 *
@ -76,8 +76,7 @@ class FTermios final
static void unsetHardwareEcho();
static void setCaptureSendCharacters();
static void unsetCaptureSendCharacters();
static bool setRawMode (bool);
static bool setRawMode();
static bool setRawMode (bool = true);
static bool unsetRawMode();
static bool setCookedMode();
static uInt getBaudRate();
@ -113,10 +112,6 @@ inline int FTermios::getStdErr()
inline bool FTermios::isRaw()
{ return raw_mode; }
//----------------------------------------------------------------------
inline bool FTermios::setRawMode()
{ return setRawMode(true); }
//----------------------------------------------------------------------
inline bool FTermios::unsetRawMode()
{ return setRawMode(false); }

View File

@ -99,7 +99,7 @@ class FTermLinux final
// Mutators
bool setCursorStyle (CursorStyle);
bool setPalette (FColor, int, int, int);
void setUTF8 (bool) const;
void setUTF8 (bool = true) const;
// Inquiries
static bool isLinuxConsole();
@ -202,7 +202,7 @@ class FTermLinux final
void writeAttributeController (uChar, uChar) const;
uChar getAttributeMode() const;
void setAttributeMode (uChar) const;
int setBlinkAsIntensity (bool) const;
int setBlinkAsIntensity (bool = true) const;
bool has9BitCharacters() const;
void getVGAPalette();
void setVGADefaultPalette();

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2018-2020 Markus Gans *
* Copyright 2018-2021 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 *
@ -61,7 +61,7 @@ class FTermXTerminal final
FTermXTerminal& operator = (const FTermXTerminal&) = delete;
// Mutators
void redefineDefaultColors (bool);
void redefineDefaultColors (bool = true);
void setCursorStyle (XTermCursorStyle);
void setFont (const FString&);
void setTitle (const FString&);
@ -72,10 +72,9 @@ class FTermXTerminal final
void setMouseForeground (const FString&);
void setMouseBackground (const FString&);
void setHighlightBackground (const FString&);
static void setMouseSupport (bool);
static void setMouseSupport();
static void setMouseSupport (bool = true);
static void unsetMouseSupport();
void metaSendsESC (bool);
void metaSendsESC (bool = true);
// Accessors
FString getClassName() const;
@ -212,10 +211,6 @@ inline bool FTermXTerminal::hasFont() const
inline bool FTermXTerminal::hasTitle() const
{ return bool(xterm_title.getLength() > 0); }
//----------------------------------------------------------------------
inline void FTermXTerminal::setMouseSupport()
{ setMouseSupport (true); }
//----------------------------------------------------------------------
inline void FTermXTerminal::unsetMouseSupport()
{ setMouseSupport (false); }

View File

@ -3,7 +3,7 @@
* *
* 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 *
* it under the terms of the GNU Lesser General Public License as *
@ -87,18 +87,14 @@ class FToggleButton : public FWidget
void setGeometry ( const FPoint&, const FSize&
, bool = true ) override;
void resetColors() override;
bool setNoUnderline (bool);
bool setNoUnderline();
bool setNoUnderline (bool = true);
bool unsetNoUnderline();
bool setEnable (bool) override;
bool setEnable() override;
bool setEnable (bool = true) override;
bool unsetEnable() override;
bool setDisable() override;
bool setFocus (bool) override;
bool setFocus() override;
bool setFocus (bool = true) override;
bool unsetFocus() override;
bool setChecked (bool);
bool setChecked();
bool setChecked (bool = true);
bool unsetChecked();
virtual void setText (const FString&);
@ -172,18 +168,9 @@ inline FString FToggleButton::getClassName() const
inline FString& FToggleButton::getText()
{ return text; }
//----------------------------------------------------------------------
inline bool FToggleButton::setNoUnderline()
{ return setNoUnderline(true); }
//----------------------------------------------------------------------
inline bool FToggleButton::unsetNoUnderline()
{ return setNoUnderline(false); }
//----------------------------------------------------------------------
inline bool FToggleButton::setEnable()
{ return setEnable(true); }
//----------------------------------------------------------------------
inline bool FToggleButton::unsetEnable()
{ return setEnable(false); }
@ -192,18 +179,10 @@ inline bool FToggleButton::unsetEnable()
inline bool FToggleButton::setDisable()
{ return setEnable(false); }
//----------------------------------------------------------------------
inline bool FToggleButton::setFocus()
{ return setFocus(true); }
//----------------------------------------------------------------------
inline bool FToggleButton::unsetFocus()
{ return setFocus(false); }
//----------------------------------------------------------------------
inline bool FToggleButton::setChecked()
{ return setChecked(true); }
//----------------------------------------------------------------------
inline bool FToggleButton::unsetChecked()
{ return setChecked(false); }

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2016-2020 Markus Gans *
* Copyright 2016-2021 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 *
@ -86,8 +86,7 @@ class FToolTip : public FWindow
// Mutators
void setText (const FString&);
void resetColors() override;
bool setBorder (bool);
bool setBorder();
bool setBorder (bool = true);
bool unsetBorder();
// Inquiries
@ -123,10 +122,6 @@ inline FString FToolTip::getClassName() const
inline FString FToolTip::getText() const
{ return text; }
//----------------------------------------------------------------------
inline bool FToolTip::setBorder()
{ return setBorder(true); }
//----------------------------------------------------------------------
inline bool FToolTip::unsetBorder()
{ return setBorder(false); }

View File

@ -51,7 +51,9 @@
#include <sys/time.h> // need for timeval (cygwin)
#include <memory>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
@ -152,81 +154,45 @@ class FVTerm
// Mutators
void setTermXY (int, int) const;
void setTerminalUpdates (TerminalUpdate) const;
void hideCursor (bool) const;
void hideCursor() const;
void hideCursor (bool = true) const;
void showCursor() const;
void setPrintCursor (const FPoint&);
FColor rgb2ColorIndex (uInt8, uInt8, uInt8) const;
static void setColor (FColor, FColor);
static void setNormal();
static bool setBold (bool);
static bool setBold();
static bool setBold (bool = true);
static bool unsetBold();
static bool setDim (bool);
static bool setDim();
static bool setDim (bool = true);
static bool unsetDim();
static bool setItalic (bool);
static bool setItalic();
static bool setItalic (bool = true);
static bool unsetItalic();
static bool setUnderline (bool);
static bool setUnderline();
static bool setUnderline (bool = true);
static bool unsetUnderline();
static bool setBlink (bool);
static bool setBlink();
static bool setBlink (bool = true);
static bool unsetBlink();
static bool setReverse (bool);
static bool setReverse();
static bool setReverse (bool = true);
static bool unsetReverse();
static bool setStandout (bool);
static bool setStandout();
static bool setStandout (bool = true);
static bool unsetStandout();
static bool setInvisible (bool);
static bool setInvisible();
static bool setInvisible (bool = true);
static bool unsetInvisible();
static bool setProtected (bool);
static bool setProtected();
static bool setProtected (bool = true);
static bool unsetProtected();
static bool setCrossedOut (bool);
static bool setCrossedOut();
static bool setCrossedOut (bool = true);
static bool unsetCrossedOut();
static bool setDoubleUnderline (bool);
static bool setDoubleUnderline();
static bool setDoubleUnderline (bool = true);
static bool unsetDoubleUnderline();
static bool setAltCharset (bool);
static bool setAltCharset();
static bool setAltCharset (bool = true);
static bool unsetAltCharset();
static bool setPCcharset (bool);
static bool setPCcharset();
static bool setPCcharset (bool = true);
static bool unsetPCcharset();
static bool setTransparent (bool);
static bool setTransparent();
static bool setTransparent (bool = true);
static bool unsetTransparent();
static bool setColorOverlay (bool);
static bool setColorOverlay();
static bool setColorOverlay (bool = true);
static bool unsetColorOverlay();
static bool setInheritBackground (bool);
static bool setInheritBackground();
static bool setInheritBackground (bool = true);
static bool unsetInheritBackground();
static void setNonBlockingRead (bool);
static void setNonBlockingRead();
static void setNonBlockingRead (bool = true);
static void unsetNonBlockingRead();
// Inquiries
@ -273,7 +239,7 @@ class FVTerm
virtual void print (const FStyle&);
virtual void print (const FColorPair&);
virtual FVTerm& print();
static void flush();
void flush() const;
protected:
// Accessor
@ -322,6 +288,21 @@ class FVTerm
virtual void initTerminal();
private:
struct FTermControl
{
std::string string;
};
struct FTermChar
{
wchar_t ch;
};
struct FTermString
{
std::wstring string;
};
// Enumerations
enum class CharacterType
{
@ -337,9 +318,19 @@ class FVTerm
LineCompletelyPrinted
};
enum class OutputType : uInt8 // Output data type of the terminal
{
String,
Control
};
// Using-declaration
using OutputData = std::tuple<OutputType, std::wstring>;
using OutputBuffer = std::queue<OutputData>;
// Constants
// Buffer size for character output on the terminal
static constexpr std::size_t TERMINAL_OUTPUT_BUFFER_SIZE = 131072;
// Buffer limit for character output on the terminal
static constexpr std::size_t TERMINAL_OUTPUT_BUFFER_LIMIT = 1024;
// Methods
void resetTextAreaToDefault ( const FTermArea*
@ -396,7 +387,7 @@ class FVTerm
PrintState repeatCharacter (uInt&, uInt, uInt) const;
bool isFullWidthChar (const FChar&) const;
bool isFullWidthPaddingChar (const FChar&) const;
static void cursorWrap();
void cursorWrap() const;
bool printWrap (FTermArea*) const;
void printCharacterOnCoordinate ( FTermArea*
, const int&
@ -418,25 +409,27 @@ class FVTerm
void appendChar (FChar&) const;
void appendAttributes (FChar&) const;
void appendLowerRight (FChar&) const;
static void characterFilter (FChar&);
static void appendOutputBuffer (const std::string&);
static int appendOutputBuffer (int);
void characterFilter (FChar&) const;
bool isOutputBufferLimitReached() const;
void appendOutputBuffer (const FTermControl&) const;
void appendOutputBuffer (const FTermChar&) const;
void appendOutputBuffer (const FTermString&) const;
// Data members
FTermArea* print_area{nullptr}; // print area for this object
FTermArea* child_print_area{nullptr}; // print area for children
FTermArea* vwin{nullptr}; // virtual window
std::shared_ptr<FTerm> fterm{};
std::shared_ptr<FPoint> term_pos{}; // terminal cursor position
std::shared_ptr<OutputBuffer> output_buffer{};
static const FVTerm* init_object; // Global FVTerm object
static FTerm* fterm;
static FTermArea* vterm; // virtual terminal
static FTermArea* vdesktop; // virtual desktop
static FTermArea* active_area; // active area
static std::vector<int>* output_buffer;
static FChar term_attribute;
static FChar next_attribute;
static FChar s_ch; // shadow character
static FChar i_ch; // inherit background character
static FPoint* term_pos; // terminal cursor position
static timeval time_last_flush;
static timeval last_term_size_check;
static bool draw_completed;
@ -608,10 +601,6 @@ inline FChar FVTerm::getAttribute()
inline FTerm& FVTerm::getFTerm() const
{ return *fterm; }
//----------------------------------------------------------------------
inline void FVTerm::hideCursor() const
{ return hideCursor(true); }
//----------------------------------------------------------------------
inline void FVTerm::showCursor() const
{ return hideCursor(false); }
@ -639,10 +628,6 @@ inline void FVTerm::setNormal()
inline bool FVTerm::setBold (bool enable)
{ return (next_attribute.attr.bit.bold = enable); }
//----------------------------------------------------------------------
inline bool FVTerm::setBold()
{ return setBold(true); }
//----------------------------------------------------------------------
inline bool FVTerm::unsetBold()
{ return setBold(false); }
@ -651,10 +636,6 @@ inline bool FVTerm::unsetBold()
inline bool FVTerm::setDim (bool enable)
{ return (next_attribute.attr.bit.dim = enable); }
//----------------------------------------------------------------------
inline bool FVTerm::setDim()
{ return setDim(true); }
//----------------------------------------------------------------------
inline bool FVTerm::unsetDim()
{ return setDim(false); }
@ -663,10 +644,6 @@ inline bool FVTerm::unsetDim()
inline bool FVTerm::setItalic (bool enable)
{ return (next_attribute.attr.bit.italic = enable); }
//----------------------------------------------------------------------
inline bool FVTerm::setItalic()
{ return setItalic(true); }
//----------------------------------------------------------------------
inline bool FVTerm::unsetItalic()
{ return setItalic(false); }
@ -675,10 +652,6 @@ inline bool FVTerm::unsetItalic()
inline bool FVTerm::setUnderline (bool enable)
{ return (next_attribute.attr.bit.underline = enable); }
//----------------------------------------------------------------------
inline bool FVTerm::setUnderline()
{ return setUnderline(true); }
//----------------------------------------------------------------------
inline bool FVTerm::unsetUnderline()
{ return setUnderline(false); }
@ -687,10 +660,6 @@ inline bool FVTerm::unsetUnderline()
inline bool FVTerm::setBlink (bool enable)
{ return (next_attribute.attr.bit.blink = enable); }
//----------------------------------------------------------------------
inline bool FVTerm::setBlink()
{ return setBlink(true); }
//----------------------------------------------------------------------
inline bool FVTerm::unsetBlink()
{ return setBlink(false); }
@ -699,10 +668,6 @@ inline bool FVTerm::unsetBlink()
inline bool FVTerm::setReverse (bool enable)
{ return (next_attribute.attr.bit.reverse = enable); }
//----------------------------------------------------------------------
inline bool FVTerm::setReverse()
{ return setReverse(true); }
//----------------------------------------------------------------------
inline bool FVTerm::unsetReverse()
{ return setReverse(false); }
@ -711,10 +676,6 @@ inline bool FVTerm::unsetReverse()
inline bool FVTerm::setStandout (bool enable)
{ return (next_attribute.attr.bit.standout = enable); }
//----------------------------------------------------------------------
inline bool FVTerm::setStandout()
{ return setStandout(true); }
//----------------------------------------------------------------------
inline bool FVTerm::unsetStandout()
{ return setStandout(false); }
@ -723,10 +684,6 @@ inline bool FVTerm::unsetStandout()
inline bool FVTerm::setInvisible (bool enable)
{ return (next_attribute.attr.bit.invisible = enable); }
//----------------------------------------------------------------------
inline bool FVTerm::setInvisible()
{ return setInvisible(true); }
//----------------------------------------------------------------------
inline bool FVTerm::unsetInvisible()
{ return setInvisible(false); }
@ -735,10 +692,6 @@ inline bool FVTerm::unsetInvisible()
inline bool FVTerm::setProtected (bool enable)
{ return (next_attribute.attr.bit.protect = enable); }
//----------------------------------------------------------------------
inline bool FVTerm::setProtected()
{ return setProtected(true); }
//----------------------------------------------------------------------
inline bool FVTerm::unsetProtected()
{ return setProtected(false); }
@ -747,10 +700,6 @@ inline bool FVTerm::unsetProtected()
inline bool FVTerm::setCrossedOut (bool enable)
{ return (next_attribute.attr.bit.crossed_out = enable); }
//----------------------------------------------------------------------
inline bool FVTerm::setCrossedOut()
{ return setCrossedOut(true); }
//----------------------------------------------------------------------
inline bool FVTerm::unsetCrossedOut()
{ return setCrossedOut(false); }
@ -759,10 +708,6 @@ inline bool FVTerm::unsetCrossedOut()
inline bool FVTerm::setDoubleUnderline (bool enable)
{ return (next_attribute.attr.bit.dbl_underline = enable); }
//----------------------------------------------------------------------
inline bool FVTerm::setDoubleUnderline()
{ return setDoubleUnderline(true); }
//----------------------------------------------------------------------
inline bool FVTerm::unsetDoubleUnderline()
{ return setDoubleUnderline(false); }
@ -771,10 +716,6 @@ inline bool FVTerm::unsetDoubleUnderline()
inline bool FVTerm::setAltCharset (bool enable)
{ return (next_attribute.attr.bit.alt_charset = enable); }
//----------------------------------------------------------------------
inline bool FVTerm::setAltCharset()
{ return setAltCharset(true); }
//----------------------------------------------------------------------
inline bool FVTerm::unsetAltCharset()
{ return setAltCharset(false); }
@ -783,10 +724,6 @@ inline bool FVTerm::unsetAltCharset()
inline bool FVTerm::setPCcharset (bool enable)
{ return (next_attribute.attr.bit.pc_charset = enable); }
//----------------------------------------------------------------------
inline bool FVTerm::setPCcharset()
{ return setPCcharset(true); }
//----------------------------------------------------------------------
inline bool FVTerm::unsetPCcharset()
{ return setPCcharset(false); }
@ -795,10 +732,6 @@ inline bool FVTerm::unsetPCcharset()
inline bool FVTerm::setTransparent (bool enable)
{ return (next_attribute.attr.bit.transparent = enable); }
//----------------------------------------------------------------------
inline bool FVTerm::setTransparent()
{ return setTransparent(true); }
//----------------------------------------------------------------------
inline bool FVTerm::unsetTransparent()
{ return setTransparent(false); }
@ -807,10 +740,6 @@ inline bool FVTerm::unsetTransparent()
inline bool FVTerm::setColorOverlay (bool enable)
{ return (next_attribute.attr.bit.color_overlay = enable); }
//----------------------------------------------------------------------
inline bool FVTerm::setColorOverlay()
{ return setColorOverlay(true); }
//----------------------------------------------------------------------
inline bool FVTerm::unsetColorOverlay()
{ return setColorOverlay(false); }
@ -819,18 +748,10 @@ inline bool FVTerm::unsetColorOverlay()
inline bool FVTerm::setInheritBackground (bool enable)
{ return (next_attribute.attr.bit.inherit_background = enable); }
//----------------------------------------------------------------------
inline bool FVTerm::setInheritBackground()
{ return setInheritBackground(true); }
//----------------------------------------------------------------------
inline bool FVTerm::unsetInheritBackground()
{ return setInheritBackground(false); }
//----------------------------------------------------------------------
inline void FVTerm::setNonBlockingRead()
{ setNonBlockingRead(true); }
//----------------------------------------------------------------------
inline void FVTerm::unsetNonBlockingRead()
{ setNonBlockingRead(false); }

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2015-2020 Markus Gans *
* Copyright 2015-2021 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 *
@ -235,24 +235,19 @@ class FWidget : public FVTerm, public FObject
static void setColorTheme();
FAcceleratorList& setAcceleratorList();
virtual void setStatusbarMessage (const FString&);
bool setVisible (bool);
bool setVisible();
bool setVisible (bool = true);
bool unsetVisible();
virtual bool setEnable (bool);
virtual bool setEnable();
virtual bool setEnable (bool = true);
virtual bool unsetEnable();
virtual bool setDisable();
virtual bool setVisibleCursor (bool); // input cursor visibility
virtual bool setVisibleCursor(); // for the widget
virtual bool unsetVisibleCursor();
virtual bool setFocus (bool);
virtual bool setFocus();
virtual bool setVisibleCursor (bool = true); // input cursor visibility
virtual bool unsetVisibleCursor(); // for the widget
virtual bool setFocus (bool = true);
virtual bool unsetFocus();
void setFocusable();
void setFocusable (bool = true);
void unsetFocusable();
bool ignorePadding (bool); // ignore padding from
bool ignorePadding(); // the parent widget
bool acceptPadding();
bool ignorePadding (bool = true); // ignore padding from
bool acceptPadding(); // the parent widget
virtual void setForegroundColor (FColor);
virtual void setBackgroundColor (FColor);
virtual void resetColors();
@ -434,7 +429,7 @@ class FWidget : public FVTerm, public FObject
void KeyPressEvent (FKeyEvent*);
void KeyDownEvent (FKeyEvent*);
void emitWheelCallback (const FWheelEvent*) const;
void setWindowFocus (bool);
void setWindowFocus (bool = true);
bool changeFocus (FWidget*, FWidget*, FocusTypes);
void processDestroy() const;
virtual void draw();
@ -443,7 +438,7 @@ class FWidget : public FVTerm, public FObject
static bool isDefaultTheme();
static void initColorTheme();
void removeQueuedEvent() const;
void setStatusbarText (bool) const;
void setStatusbarText (bool = true) const;
// Data members
struct FWidgetFlags flags{};
@ -775,18 +770,10 @@ inline void FWidget::setMoveSizeWidget (FWidget* obj)
inline void FWidget::setStatusbarMessage (const FString& msg)
{ statusbar_message = msg; }
//----------------------------------------------------------------------
inline bool FWidget::setVisible()
{ return setVisible(true); }
//----------------------------------------------------------------------
inline bool FWidget::unsetVisible()
{ return setVisible(false); }
//----------------------------------------------------------------------
inline bool FWidget::setEnable()
{ return setEnable(true); }
//----------------------------------------------------------------------
inline bool FWidget::unsetEnable()
{ return setEnable(false); }
@ -799,25 +786,17 @@ inline bool FWidget::setDisable()
inline bool FWidget::setVisibleCursor (bool enable)
{ return (flags.visible_cursor = enable); }
//----------------------------------------------------------------------
inline bool FWidget::setVisibleCursor()
{ return setVisibleCursor(true); }
//----------------------------------------------------------------------
inline bool FWidget::unsetVisibleCursor()
{ return setVisibleCursor(false); }
//----------------------------------------------------------------------
inline bool FWidget::setFocus()
{ return setFocus(true); }
//----------------------------------------------------------------------
inline bool FWidget::unsetFocus()
{ return setFocus(false); }
//----------------------------------------------------------------------
inline void FWidget::setFocusable()
{ flags.focusable = true; }
inline void FWidget::setFocusable (bool enable)
{ flags.focusable = enable; }
//----------------------------------------------------------------------
inline void FWidget::unsetFocusable()
@ -827,10 +806,6 @@ inline void FWidget::unsetFocusable()
inline bool FWidget::ignorePadding (bool enable)
{ return (ignore_padding = enable); }
//----------------------------------------------------------------------
inline bool FWidget::ignorePadding()
{ return (ignore_padding = true); }
//----------------------------------------------------------------------
inline bool FWidget::acceptPadding()
{ return (ignore_padding = false); }

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2015-2020 Markus Gans *
* Copyright 2015-2021 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 *
@ -89,26 +89,20 @@ class FWindow : public FWidget
FWidget* getWindowFocusWidget() const;
// Mutators
bool setWindowWidget (bool);
bool setWindowWidget();
bool setWindowWidget (bool = true);
bool unsetWindowWidget();
static void setActiveWindow (FWindow*);
void setWindowFocusWidget (FWidget*);
bool activateWindow (bool);
bool activateWindow();
bool activateWindow (bool = true);
void unsetActiveWindow() const;
bool deactivateWindow();
virtual bool setResizeable (bool);
virtual bool setResizeable();
virtual bool setResizeable (bool = true);
bool unsetResizeable();
bool setTransparentShadow (bool);
bool setTransparentShadow();
bool setTransparentShadow (bool = true);
bool unsetTransparentShadow();
bool setShadow (bool);
bool setShadow();
bool setShadow (bool = true);
bool unsetShadow();
bool setAlwaysOnTop (bool);
bool setAlwaysOnTop();
bool setAlwaysOnTop (bool = true);
bool unsetAlwaysOnTop();
// Inquiries
@ -184,50 +178,26 @@ void closeDropDown (const FWidget*, const FPoint&);
inline FString FWindow::getClassName() const
{ return "FWindow"; }
//----------------------------------------------------------------------
inline bool FWindow::setWindowWidget()
{ return setWindowWidget(true); }
//----------------------------------------------------------------------
inline bool FWindow::unsetWindowWidget()
{ return setWindowWidget(false); }
//----------------------------------------------------------------------
inline bool FWindow::activateWindow()
{ return activateWindow(true); }
//----------------------------------------------------------------------
inline bool FWindow::deactivateWindow()
{ return activateWindow(false); }
//----------------------------------------------------------------------
inline bool FWindow::setResizeable()
{ return setResizeable(true); }
//----------------------------------------------------------------------
inline bool FWindow::unsetResizeable()
{ return setResizeable(false); }
//----------------------------------------------------------------------
inline bool FWindow::setTransparentShadow()
{ return setTransparentShadow(true); }
//----------------------------------------------------------------------
inline bool FWindow::unsetTransparentShadow()
{ return setTransparentShadow(false); }
//----------------------------------------------------------------------
inline bool FWindow::setShadow()
{ return setShadow(true); }
//----------------------------------------------------------------------
inline bool FWindow::unsetShadow()
{ return setShadow(false); }
//----------------------------------------------------------------------
inline bool FWindow::setAlwaysOnTop()
{ return setAlwaysOnTop(true); }
//----------------------------------------------------------------------
inline bool FWindow::unsetAlwaysOnTop()
{ return setAlwaysOnTop(false); }

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2018-2020 Markus Gans *
* Copyright 2018-2021 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 *
@ -142,7 +142,7 @@ void FOptiMoveTest::noArgumentTest()
om.set_parm_right_cursor (0);
om.set_parm_left_cursor (0);
CPPUNIT_ASSERT (om.moveCursor (1, 1, 5, 5) == 0);
CPPUNIT_ASSERT (om.moveCursor (1, 1, 5, 5) == nullptr);
}
//----------------------------------------------------------------------

View File

@ -446,6 +446,47 @@ void FTermBufferTest::streamTest()
CPPUNIT_ASSERT ( term_buf.getBuffer()[i].attr.byte[2] != 0 );
CPPUNIT_ASSERT ( term_buf.getBuffer()[i].attr.byte[3] == 0 );
}
// Stream into FCharVector
fchar_vec.clear();
CPPUNIT_ASSERT ( fchar_vec.empty() );
CPPUNIT_ASSERT ( fchar_vec.size() == 0 );
CPPUNIT_ASSERT ( fchar_vec.begin() == fchar_vec.end() );
fchar_vec << term_buf;
CPPUNIT_ASSERT ( ! fchar_vec.empty() );
CPPUNIT_ASSERT ( fchar_vec.size() == 6 );
CPPUNIT_ASSERT ( fchar_vec.begin() + 6 == fchar_vec.end() );
CPPUNIT_ASSERT ( fchar_vec[0].ch[0] == L'a' );
CPPUNIT_ASSERT ( fchar_vec[1].ch[0] == L'1' );
CPPUNIT_ASSERT ( fchar_vec[2].ch[0] == L'\U0000e1f9' );
CPPUNIT_ASSERT ( fchar_vec[3].ch[0] == L'🚧' );
CPPUNIT_ASSERT ( fchar_vec[4].ch[0] == L'🚀' );
CPPUNIT_ASSERT ( fchar_vec[5].ch[0] == L'🚴' );
CPPUNIT_ASSERT ( fchar_vec[0].fg_color == finalcut::FColor::Default );
CPPUNIT_ASSERT ( fchar_vec[0].bg_color == finalcut::FColor::Default );
CPPUNIT_ASSERT ( fchar_vec[1].fg_color == finalcut::FColor::Yellow );
CPPUNIT_ASSERT ( fchar_vec[1].bg_color == finalcut::FColor::Blue );
CPPUNIT_ASSERT ( fchar_vec[2].fg_color == finalcut::FColor::Cyan );
CPPUNIT_ASSERT ( fchar_vec[2].bg_color == finalcut::FColor::White );
CPPUNIT_ASSERT ( fchar_vec[3].fg_color == finalcut::FColor::White );
CPPUNIT_ASSERT ( fchar_vec[3].bg_color == finalcut::FColor::Cyan );
CPPUNIT_ASSERT ( fchar_vec[4].fg_color == finalcut::FColor::Cyan );
CPPUNIT_ASSERT ( fchar_vec[4].bg_color == finalcut::FColor::White );
CPPUNIT_ASSERT ( fchar_vec[5].fg_color == finalcut::FColor::Black );
CPPUNIT_ASSERT ( fchar_vec[5].bg_color == finalcut::FColor::White );
CPPUNIT_ASSERT ( fchar_vec[0].attr.byte[0] == 0 );
CPPUNIT_ASSERT ( fchar_vec[0].attr.byte[1] == 0 );
CPPUNIT_ASSERT ( fchar_vec[1].attr.byte[0] == 0 );
CPPUNIT_ASSERT ( fchar_vec[1].attr.byte[1] == 0 );
CPPUNIT_ASSERT ( fchar_vec[2].attr.byte[0] != 0 );
CPPUNIT_ASSERT ( fchar_vec[2].attr.byte[1] == 0 );
CPPUNIT_ASSERT ( fchar_vec[3].attr.byte[0] == 0 );
CPPUNIT_ASSERT ( fchar_vec[3].attr.byte[1] == 0 );
CPPUNIT_ASSERT ( fchar_vec[4].attr.byte[0] != 0 );
CPPUNIT_ASSERT ( fchar_vec[4].attr.byte[1] == 0 );
CPPUNIT_ASSERT ( fchar_vec[5].attr.byte[0] == 0 );
CPPUNIT_ASSERT ( fchar_vec[5].attr.byte[1] != 0 );
}
//----------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* *
* This file is part of the FINAL CUT widget toolkit *
* *
* Copyright 2018-2020 Markus Gans *
* Copyright 2018-2021 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 *
@ -93,8 +93,8 @@ void FTermDataTest::defaultDataTest()
CPPUNIT_ASSERT ( data.getTermGeometry() == finalcut::FRect() );
CPPUNIT_ASSERT ( data.getTTYFileDescriptor() == -1 );
CPPUNIT_ASSERT ( data.getBaudrate() == 0 );
CPPUNIT_ASSERT_CSTRING ( data.getTermType(), "" );
CPPUNIT_ASSERT_CSTRING ( data.getTermFileName(), "" );
CPPUNIT_ASSERT_CSTRING ( data.getTermType().data(), "" );
CPPUNIT_ASSERT_CSTRING ( data.getTermFileName().data(), "" );
CPPUNIT_ASSERT ( data.getXtermFont() == finalcut::FString() );
CPPUNIT_ASSERT ( data.getXtermTitle() == finalcut::FString() );
CPPUNIT_ASSERT ( data.getExitMessage() == finalcut::FString() );
@ -178,13 +178,13 @@ void FTermDataTest::dataTest()
CPPUNIT_ASSERT ( data.getBaudrate() != 9600 );
CPPUNIT_ASSERT ( data.getBaudrate() == 38400 );
CPPUNIT_ASSERT_CSTRING ( data.getTermType(), "" );
CPPUNIT_ASSERT ( data.getTermType() == "" );
data.setTermType("linux");
CPPUNIT_ASSERT_CSTRING ( data.getTermType(), "linux" );
CPPUNIT_ASSERT ( data.getTermType() == "linux" );
CPPUNIT_ASSERT_CSTRING ( data.getTermFileName(), "" );
CPPUNIT_ASSERT ( data.getTermFileName() == "" );
data.setTermFileName("/dev/pts/2");
CPPUNIT_ASSERT_CSTRING ( data.getTermFileName(), "/dev/pts/2" );
CPPUNIT_ASSERT ( data.getTermFileName() == "/dev/pts/2" );
CPPUNIT_ASSERT ( data.getXtermFont() == finalcut::FString() );
data.setXtermFont("terminus-20");