Lazy terminal initialization on show()

This commit is contained in:
Markus Gans 2020-06-06 21:10:06 +02:00
parent 70eabe93d6
commit 3d2a0c6dd2
39 changed files with 626 additions and 389 deletions

View File

@ -1,3 +1,7 @@
2020-06-06 Markus Gans <guru.mail@muenster.de>
* Now, the terminal is not initialized before the method show()
is called. Or you force it explicitly via the FApplication object.
2020-05-30 Markus Gans <guru.mail@muenster.de> 2020-05-30 Markus Gans <guru.mail@muenster.de>
* With the two new methods FApplication::setDarkTheme() and * With the two new methods FApplication::setDarkTheme() and
FApplication::setDefaultTheme() you can now change the theme FApplication::setDefaultTheme() you can now change the theme

View File

@ -1135,12 +1135,13 @@ class dialogWidget : public FDialog
setGeometry (FPoint{28, 2}, FSize{24, 21}); setGeometry (FPoint{28, 2}, FSize{24, 21});
scrollview.setGeometry(FPoint{1, 1}, FSize{22, 11}); scrollview.setGeometry(FPoint{1, 1}, FSize{22, 11});
scrollview.setScrollSize(FSize{60, 27}); scrollview.setScrollSize(FSize{60, 27});
const auto& wc = getFWidgetColors(); // Attention: getColorTheme() requires an initialized terminal
setColor (wc.label_inactive_fg, wc.dialog_bg); const auto& wc = getColorTheme();
setColor (wc->label_inactive_fg, wc->dialog_bg);
scrollview.clearArea(); scrollview.clearArea();
FColorPair red (fc::LightRed, wc.dialog_bg); FColorPair red (fc::LightRed, wc->dialog_bg);
FColorPair black (fc::Black, wc.dialog_bg); FColorPair black (fc::Black, wc->dialog_bg);
FColorPair cyan (fc::Cyan, wc.dialog_bg); FColorPair cyan (fc::Cyan, wc->dialog_bg);
static std::vector<direction> d static std::vector<direction> d
{ {
@ -1188,6 +1189,7 @@ class dialogWidget : public FDialog
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
FApplication app(argc, argv); FApplication app(argc, argv);
app.initTerminal(); // Terminal initialization
dialogWidget dialog(&app); dialogWidget dialog(&app);
FWidget::setMainWidget(&dialog); FWidget::setMainWidget(&dialog);
dialog.show(); dialog.show();

View File

@ -217,8 +217,13 @@ void Background::cb_choice (const finalcut::FWidget*, const FDataPtr)
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
// Create the application object
finalcut::FApplication app(argc, argv); finalcut::FApplication app(argc, argv);
// Force terminal initialization without calling show()
app.initTerminal();
// The following lines require an initialized terminal
if ( finalcut::FTerm::canChangeColorPalette() ) if ( finalcut::FTerm::canChangeColorPalette() )
app.setBackgroundColor(finalcut::fc::LightMagenta); app.setBackgroundColor(finalcut::fc::LightMagenta);

View File

@ -95,6 +95,9 @@ int main (int argc, char* argv[])
{ {
// Create the application object // Create the application object
finalcut::FApplication app{argc, argv}; finalcut::FApplication app{argc, argv};
// Force terminal initialization without calling show()
app.initTerminal();
app.setForegroundColor(finalcut::fc::Default); app.setForegroundColor(finalcut::fc::Default);
app.setBackgroundColor(finalcut::fc::Default); app.setBackgroundColor(finalcut::fc::Default);

View File

@ -78,16 +78,6 @@ ColorChooser::ColorChooser (finalcut::FWidget* parent)
setFixedSize (FSize{8, 12}); setFixedSize (FSize{8, 12});
unsetFocusable(); unsetFocusable();
if ( parent )
{
const FColor fg = parent->getForegroundColor();
const FColor bg = parent->getBackgroundColor();
FWidget::setForegroundColor(fg);
FWidget::setBackgroundColor(bg);
headline.setForegroundColor(fg);
headline.setBackgroundColor(bg);
}
// Text label // Text label
headline.setGeometry (FPoint{1, 1}, FSize{8, 1}); headline.setGeometry (FPoint{1, 1}, FSize{8, 1});
headline.setEmphasis(); headline.setEmphasis();
@ -122,6 +112,8 @@ void ColorChooser::setSize (const FSize& size, bool adjust)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void ColorChooser::draw() void ColorChooser::draw()
{ {
useParentWidgetColor();
headline.setBackgroundColor(getBackgroundColor());
setColor(); setColor();
drawBorder(); drawBorder();
@ -232,16 +224,6 @@ Brushes::Brushes (finalcut::FWidget* parent)
setFixedSize (FSize{8, 4}); setFixedSize (FSize{8, 4});
unsetFocusable(); unsetFocusable();
if ( parent )
{
const FColor fg = parent->getForegroundColor();
const FColor bg = parent->getBackgroundColor();
FWidget::setForegroundColor(fg);
FWidget::setBackgroundColor(bg);
headline.setForegroundColor(fg);
headline.setBackgroundColor(bg);
}
// Text label // Text label
headline.setGeometry(FPoint{1, 1}, FSize{8, 1}); headline.setGeometry(FPoint{1, 1}, FSize{8, 1});
headline.setEmphasis(); headline.setEmphasis();
@ -265,6 +247,8 @@ void Brushes::setSize (const FSize& size, bool adjust)
void Brushes::draw() void Brushes::draw()
{ {
int pos{0}; int pos{0};
useParentWidgetColor();
headline.setBackgroundColor(getBackgroundColor());
setColor(); setColor();
drawBorder(); drawBorder();
print() << FPoint{2, 3} print() << FPoint{2, 3}
@ -361,6 +345,7 @@ class MouseDraw final : public finalcut::FDialog
void draw() override; void draw() override;
void drawBrush (int, int, bool = false); void drawBrush (int, int, bool = false);
void drawCanvas(); void drawCanvas();
void createCanvas();
void adjustSize() override; void adjustSize() override;
// Event handler // Event handler
@ -390,10 +375,6 @@ MouseDraw::MouseDraw (finalcut::FWidget* parent)
); );
brush.setPos (FPoint{1, 12}); brush.setPos (FPoint{1, 12});
FSize no_shadow{0, 0};
finalcut::FRect scroll_geometry{0, 0, 1, 1};
createArea (scroll_geometry, no_shadow, canvas);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -407,6 +388,10 @@ void MouseDraw::setGeometry ( const FPoint& p, const FSize& s, bool adjust)
const std::size_t w = s.getWidth(); const std::size_t w = s.getWidth();
const std::size_t h = s.getHeight(); const std::size_t h = s.getHeight();
const finalcut::FRect scroll_geometry (FPoint{0, 0}, FSize{w - 11, h - 3}); const finalcut::FRect scroll_geometry (FPoint{0, 0}, FSize{w - 11, h - 3});
if ( ! canvas )
return;
const FSize no_shadow{0, 0}; const FSize no_shadow{0, 0};
const int old_w = canvas->width; const int old_w = canvas->width;
const int old_h = canvas->height; const int old_h = canvas->height;
@ -504,6 +489,10 @@ void MouseDraw::drawCanvas()
if ( ! hasPrintArea() ) if ( ! hasPrintArea() )
finalcut::FVTerm::getPrintArea(); finalcut::FVTerm::getPrintArea();
// Create canvas after initializing the desktop and color theme
if ( ! canvas )
createCanvas();
if ( ! (hasPrintArea() && canvas) ) if ( ! (hasPrintArea() && canvas) )
return; return;
@ -534,6 +523,15 @@ void MouseDraw::drawCanvas()
printarea->has_changes = true; printarea->has_changes = true;
} }
//----------------------------------------------------------------------
void MouseDraw::createCanvas()
{
FSize no_shadow{0, 0};
finalcut::FRect scroll_geometry{0, 0, 1, 1};
createArea (scroll_geometry, no_shadow, canvas);
adjustSize();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void MouseDraw::adjustSize() void MouseDraw::adjustSize()
{ {

View File

@ -133,62 +133,103 @@ void move (int xold, int yold, int xnew, int ynew)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
class DirectLogger : public finalcut::FLog class DirectLogger final : public finalcut::FLog
{ {
public: public:
// Constructor
DirectLogger();
// Destructor
~DirectLogger() override;
void info (const std::string& entry) override void info (const std::string& entry) override
{ {
output << entry << "\r" << std::endl; output << entry << "\r" << std::endl;
} }
void warn (const std::string&) override void warn (const std::string&) override
{ } {
// An implementation is not required in this context
}
void error (const std::string&) override void error (const std::string&) override
{ } {
// An implementation is not required in this context
}
void debug (const std::string&) override void debug (const std::string&) override
{ } {
// An implementation is not required in this context
}
void setOutputStream (const std::ostream& os) override void setOutputStream (const std::ostream& os) override
{ output.rdbuf(os.rdbuf()); } { output.rdbuf(os.rdbuf()); }
void setLineEnding (LineEnding) override void setLineEnding (LineEnding) override
{ } {
// An implementation is not required in this context
}
void enableTimestamp() override void enableTimestamp() override
{ } {
// An implementation is not required in this context
}
void disableTimestamp() override void disableTimestamp() override
{ } {
// An implementation is not required in this context
}
private: private:
// Data member // Data member
std::ostream output{std::cerr.rdbuf()}; std::ostream output{std::cerr.rdbuf()};
}; };
//----------------------------------------------------------------------
DirectLogger::DirectLogger() // constructor
{ }
//----------------------------------------------------------------------
DirectLogger::~DirectLogger() // destructor
{ }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// main part // main part
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
// Disable mouse
finalcut::FStartOptions::getFStartOptions().mouse_support = false;
// Create the application object // Create the application object
finalcut::FApplication TermApp{argc, argv}; finalcut::FApplication term_app{argc, argv};
// Force terminal initialization without calling show()
term_app.initTerminal();
// Pointer to the global virtual terminal object // Pointer to the global virtual terminal object
app = &TermApp; app = &term_app;
if ( app->isQuit() )
return 0;
// Get screen dimension // Get screen dimension
int xmax = int(TermApp.getDesktopWidth() - 1); int xmax = int(term_app.getDesktopWidth() - 1);
int ymax = int(TermApp.getDesktopHeight() - 1); int ymax = int(term_app.getDesktopHeight() - 1);
finalcut::FString line{std::size_t(xmax) + 1, '-'}; finalcut::FString line{std::size_t(xmax) + 1, '-'};
// Place the cursor in the upper left corner // Place the cursor in the upper left corner
TermApp.setTermXY(0, 0); term_app.setTermXY(0, 0);
// Reset all terminal attributes // Reset all terminal attributes
TermApp.setNormal(); term_app.setNormal();
// Clear the screen // Clear the screen
TermApp.clearArea(); term_app.clearArea();
// Show the determined terminal name and text resolution // Show the determined terminal name and text resolution
std::cout << "Terminal: " << finalcut::FTerm::getTermType() << "\r\n"; std::cout << "Terminal: " << finalcut::FTerm::getTermType() << "\r\n";
@ -230,8 +271,10 @@ int main (int argc, char* argv[])
std::shared_ptr<finalcut::FLog> log = finalcut::FApplication::getLog(); std::shared_ptr<finalcut::FLog> log = finalcut::FApplication::getLog();
const finalcut::FOptiMove& opti_move = *finalcut::FTerm::getFOptiMove(); const finalcut::FOptiMove& opti_move = *finalcut::FTerm::getFOptiMove();
finalcut::printDurations(opti_move); finalcut::printDurations(opti_move);
delete &log;
// Waiting for keypress // Waiting for keypress
keyPressed(); keyPressed();
app = nullptr; // End of TermApp object scope app = nullptr; // End of term_app object scope
return 0;
} }

View File

@ -62,11 +62,15 @@ class AttribDlg final : public finalcut::FDialog
void cb_back (const finalcut::FWidget* = nullptr, const FDataPtr = nullptr); void cb_back (const finalcut::FWidget* = nullptr, const FDataPtr = nullptr);
private: private:
// Constants
static constexpr FColor UNDEFINED = static_cast<FColor>(-2);
// Method // Method
void adjustSize() override; void adjustSize() override;
void draw() override;
// Data members // Data members
FColor bgcolor{getColorTheme()->label_bg}; FColor bgcolor{UNDEFINED};
finalcut::FButton next_button{"&Next >", this}; finalcut::FButton next_button{"&Next >", this};
finalcut::FButton back_button{"< &Back", this}; finalcut::FButton back_button{"< &Back", this};
}; };
@ -75,10 +79,6 @@ class AttribDlg final : public finalcut::FDialog
AttribDlg::AttribDlg (finalcut::FWidget* parent) AttribDlg::AttribDlg (finalcut::FWidget* parent)
: finalcut::FDialog{parent} : finalcut::FDialog{parent}
{ {
FDialog::setText ( "A terminal attributes test ("
+ finalcut::FString{finalcut::FTerm::getTermType()}
+ ")");
next_button.setGeometry ( FPoint{int(getWidth()) - 13, int(getHeight()) - 4} next_button.setGeometry ( FPoint{int(getWidth()) - 13, int(getHeight()) - 4}
, FSize{10, 1} ); , FSize{10, 1} );
next_button.addAccelerator (fc::Fkey_right); next_button.addAccelerator (fc::Fkey_right);
@ -194,6 +194,26 @@ void AttribDlg::adjustSize()
finalcut::FDialog::adjustSize(); finalcut::FDialog::adjustSize();
} }
//----------------------------------------------------------------------
void AttribDlg::draw()
{
if ( bgcolor == UNDEFINED )
{
// Get the color after initializing the color theme in show()
if ( finalcut::FTerm::isMonochron() )
bgcolor = fc::Default;
else
bgcolor = getColorTheme()->label_bg;
// Get the terminal type after the terminal detection in show()
FDialog::setText ( "A terminal attributes test ("
+ finalcut::FString{finalcut::FTerm::getTermType()}
+ ")");
}
FDialog::draw();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class AttribDemo // class AttribDemo
@ -238,18 +258,13 @@ class AttribDemo final : public finalcut::FWidget
void draw() override; void draw() override;
// Data member // Data member
FColor last_color{FColor(finalcut::FTerm::getMaxColor())}; FColor last_color{1};
}; };
//---------------------------------------------------------------------- //----------------------------------------------------------------------
AttribDemo::AttribDemo (finalcut::FWidget* parent) AttribDemo::AttribDemo (finalcut::FWidget* parent)
: finalcut::FWidget{parent} : finalcut::FWidget{parent}
{ {
if ( finalcut::FTerm::isMonochron() )
last_color = 1;
else if ( last_color > 16 )
last_color = 16;
unsetFocusable(); unsetFocusable();
} }
@ -417,8 +432,15 @@ void AttribDemo::printProtected()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void AttribDemo::draw() void AttribDemo::draw()
{ {
// test alternate character set
const auto& wc = getColorTheme(); const auto& wc = getColorTheme();
last_color = FColor(finalcut::FTerm::getMaxColor());
if ( finalcut::FTerm::isMonochron() )
last_color = 1;
else if ( last_color > 16 )
last_color = 16;
// test alternate character set
printAltCharset(); printAltCharset();
const std::vector<std::function<void()> > effect const std::vector<std::function<void()> > effect

View File

@ -296,15 +296,30 @@ void string()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
const bool disable_alt_screen{true}; // Disabling the switch to the alternative screen
finalcut::FApplication TermApp {argc, argv, disable_alt_screen}; finalcut::FTerm::useAlternateScreen(false);
// Disable color palette changes and terminal data requests
auto& start_options = finalcut::FStartOptions::getFStartOptions();
start_options.color_change = false;
start_options.terminal_data_request = false;
// Create the application object as root widget
finalcut::FApplication term_app {argc, argv};
// Force terminal initialization without calling show()
term_app.initTerminal();
if ( term_app.isQuit() )
return 0;
std::cout << "--------\r\nFTermcap\r\n--------\r\n\n"; std::cout << "--------\r\nFTermcap\r\n--------\r\n\n";
std::cout << "Terminal: " << finalcut::FTerm::getTermType() << "\r\n"; std::cout << "Terminal: " << finalcut::FTerm::getTermType() << "\r\n";
debug (TermApp); debug (term_app);
booleans(); booleans();
numeric(); numeric();
string(); string();
return 0;
} }

View File

@ -101,6 +101,9 @@ int main (int argc, char* argv[])
{ {
// Create the application object // Create the application object
finalcut::FApplication app{argc, argv}; finalcut::FApplication app{argc, argv};
// Force terminal initialization without calling show()
app.initTerminal();
app.setForegroundColor(fc::Default); app.setForegroundColor(fc::Default);
app.setBackgroundColor(fc::Default); app.setBackgroundColor(fc::Default);

View File

@ -1049,17 +1049,6 @@ int main (int argc, char* argv[])
// Create the application object app // Create the application object app
finalcut::FApplication app{argc, argv}; finalcut::FApplication app{argc, argv};
app.setNonBlockingRead(); app.setNonBlockingRead();
finalcut::FTerm::redefineDefaultColors(true);
finalcut::FTerm::setTermTitle (title);
// Force vt100 encoding
//finalcut::FTerm::setEncoding(finalcut::fc::VT100);
// Sets the terminal size to 94×30
//finalcut::FTerm::setTermSize(FSize{94, 30});
// Enable the final cut graphical font
//finalcut::FTerm::setNewFont();
// Create main dialog object d // Create main dialog object d
MyDialog d{&app}; MyDialog d{&app};
@ -1075,6 +1064,18 @@ int main (int argc, char* argv[])
// Show the dialog d // Show the dialog d
d.show(); d.show();
finalcut::FTerm::redefineDefaultColors(true);
finalcut::FTerm::setTermTitle (title);
// Force vt100 encoding
//finalcut::FTerm::setEncoding(finalcut::fc::VT100);
// Sets the terminal size to 94×30
//finalcut::FTerm::setTermSize(FSize{94, 30});
// Enable the final cut graphical font
//finalcut::FTerm::setNewFont();
// Start the application // Start the application
// and return the result to the operating system // and return the result to the operating system
return app.exec(); return app.exec();

View File

@ -58,7 +58,7 @@ FWidget* FApplication::keyboard_widget {nullptr}; // has the keyboard foc
FKeyboard* FApplication::keyboard {nullptr}; // keyboard access FKeyboard* FApplication::keyboard {nullptr}; // keyboard access
FMouseControl* FApplication::mouse {nullptr}; // mouse control FMouseControl* FApplication::mouse {nullptr}; // mouse control
int FApplication::loop_level {0}; // event loop level int FApplication::loop_level {0}; // event loop level
int FApplication::quit_code {0}; int FApplication::quit_code {EXIT_SUCCESS};
bool FApplication::quit_now {false}; bool FApplication::quit_now {false};
@ -68,13 +68,14 @@ bool FApplication::quit_now {false};
// constructors and destructor // constructors and destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FApplication::FApplication ( const int& _argc FApplication::FApplication (const int& _argc, char* _argv[])
, char* _argv[] : FWidget{processParameters(_argc, _argv)}
, bool disable_alt_screen )
: FWidget{processParameters(_argc, _argv), disable_alt_screen}
, app_argc{_argc} , app_argc{_argc}
, app_argv{_argv} , app_argv{_argv}
{ {
if ( quit_now )
return;
if ( app_object ) if ( app_object )
{ {
auto ftermdata = FTerm::getFTermData(); auto ftermdata = FTerm::getFTermData();
@ -84,6 +85,7 @@ FApplication::FApplication ( const int& _argc
return; return;
} }
// First define the application object
app_object = this; app_object = this;
if ( ! (_argc && _argv) ) if ( ! (_argc && _argv) )
@ -145,10 +147,10 @@ int FApplication::exec() // run
if ( quit_now ) if ( quit_now )
{ {
quit_now = false; quit_now = false;
return EXIT_FAILURE; return quit_code;
} }
quit_code = 0; quit_code = EXIT_SUCCESS;
enterLoop(); enterLoop();
return quit_code; return quit_code;
} }
@ -263,23 +265,10 @@ bool FApplication::removeQueuedEvent (const FObject* receiver)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::processExternalUserEvent() void FApplication::initTerminal()
{ {
// This method can be overloaded and replaced by own code if ( ! isQuit() )
} FWidget::initTerminal();
//----------------------------------------------------------------------
FWidget* FApplication::processParameters (const int& argc, char* argv[])
{
if ( argc > 0 && argv[1] && ( std::strcmp(argv[1], "--help") == 0
|| std::strcmp(argv[1], "-h") == 0 ) )
{
showParameterUsage();
}
getStartOptions().setDefault();
cmd_options (argc, argv);
return nullptr;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -313,56 +302,6 @@ void FApplication::setDarkTheme()
setColorTheme<default16ColorDarkTheme>(); setColorTheme<default16ColorDarkTheme>();
} }
//----------------------------------------------------------------------
void FApplication::showParameterUsage()
{
std::cout \
<< "Generic options:\n"
<< " -h, --help "
<< " Display this help and exit\n"
<< "\n"
<< "The Final Cut options:\n"
<< " --encoding <name> "
<< " Sets the character encoding mode\n"
<< " "
<< " {utf8, vt100, pc, ascii}\n"
<< " --no-mouse "
<< " Disable mouse support\n"
<< " --no-optimized-cursor "
<< " Disable cursor optimization\n"
<< " --no-terminal-detection "
<< " Disable terminal detection\n"
<< " --no-terminal-data-request"
<< " Do not determine terminal font and title\n"
<< " --no-color-change "
<< " Do not redefine the color palette\n"
<< " --no-sgr-optimizer "
<< " Do not optimize SGR sequences\n"
<< " --vgafont "
<< " Set the standard vga 8x16 font\n"
<< " --newfont "
<< " Enables the graphical font\n"
<< " --dark-theme "
<< " Enables the dark theme\n"
#if defined(__FreeBSD__) || defined(__DragonFly__)
<< "\n"
<< "FreeBSD console options:\n"
<< " --no-esc-for-alt-meta "
<< " Do not send a ESC prefix for the alt/meta key\n"
<< " --no-cursorstyle-change "
<< " Do not change the current cursor style\n"
#elif defined(__NetBSD__) || defined(__OpenBSD__)
<< "\n"
<< "NetBSD/OpenBSD console options:\n"
<< " --no-esc-for-alt-meta "
<< " Do not send a ESC prefix for the alt/meta key\n"
#endif
<< std::endl; // newline character + flushes the output stream
std::exit(EXIT_SUCCESS);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev) void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev)
{ {
@ -384,6 +323,15 @@ void FApplication::closeConfirmationDialog (FWidget* w, FCloseEvent* ev)
} }
} }
// protected methods of FApplication
//----------------------------------------------------------------------
void FApplication::processExternalUserEvent()
{
// This method can be overloaded and replaced by own code
}
// private methods of FApplication // private methods of FApplication
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::init (uInt64 key_time, uInt64 dblclick_time) void FApplication::init (uInt64 key_time, uInt64 dblclick_time)
@ -476,8 +424,12 @@ void FApplication::cmd_options (const int& argc, char* argv[])
else if ( encoding.includes("help") ) else if ( encoding.includes("help") )
showParameterUsage(); showParameterUsage();
else else
FTerm::exitWithMessage ( "Unknown encoding " {
auto ftermdata = FTerm::getFTermData();
ftermdata->setExitMessage ( "Unknown encoding "
+ std::string(encoding.c_str()) ); + std::string(encoding.c_str()) );
exit(EXIT_FAILURE);
}
} }
if ( std::strcmp(long_options[idx].name, "no-mouse") == 0 ) if ( std::strcmp(long_options[idx].name, "no-mouse") == 0 )
@ -527,6 +479,55 @@ inline FStartOptions& FApplication::getStartOptions()
return FStartOptions::getFStartOptions(); return FStartOptions::getFStartOptions();
} }
//----------------------------------------------------------------------
void FApplication::showParameterUsage()
{
std::cout \
<< "Generic options:\n"
<< " -h, --help "
<< " Display this help and exit\n"
<< "\n"
<< "The Final Cut options:\n"
<< " --encoding <name> "
<< " Sets the character encoding mode\n"
<< " "
<< " {utf8, vt100, pc, ascii}\n"
<< " --no-mouse "
<< " Disable mouse support\n"
<< " --no-optimized-cursor "
<< " Disable cursor optimization\n"
<< " --no-terminal-detection "
<< " Disable terminal detection\n"
<< " --no-terminal-data-request"
<< " Do not determine terminal font and title\n"
<< " --no-color-change "
<< " Do not redefine the color palette\n"
<< " --no-sgr-optimizer "
<< " Do not optimize SGR sequences\n"
<< " --vgafont "
<< " Set the standard vga 8x16 font\n"
<< " --newfont "
<< " Enables the graphical font\n"
<< " --dark-theme "
<< " Enables the dark theme\n"
#if defined(__FreeBSD__) || defined(__DragonFly__)
<< "\n"
<< "FreeBSD console options:\n"
<< " --no-esc-for-alt-meta "
<< " Do not send a ESC prefix for the alt/meta key\n"
<< " --no-cursorstyle-change "
<< " Do not change the current cursor style\n"
#elif defined(__NetBSD__) || defined(__OpenBSD__)
<< "\n"
<< "NetBSD/OpenBSD console options:\n"
<< " --no-esc-for-alt-meta "
<< " Do not send a ESC prefix for the alt/meta key\n"
#endif
<< std::endl; // newline character + flushes the output stream
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FApplication::destroyLog() inline void FApplication::destroyLog()
{ {
@ -1119,6 +1120,20 @@ void FApplication::sendWheelEvent ( const FPoint& widgetMousePos
} }
} }
//----------------------------------------------------------------------
FWidget* FApplication::processParameters (const int& argc, char* argv[])
{
if ( argc > 0 && argv[1] && ( std::strcmp(argv[1], "--help") == 0
|| std::strcmp(argv[1], "-h") == 0 ) )
{
showParameterUsage();
FApplication::exit(EXIT_SUCCESS);
}
cmd_options (argc, argv);
return nullptr;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::processMouseEvent() void FApplication::processMouseEvent()
{ {

View File

@ -402,8 +402,9 @@ void FButton::onFocusOut (FFocusEvent*)
void FButton::init() void FButton::init()
{ {
const auto& wc = getColorTheme(); const auto& wc = getColorTheme();
setForegroundColor (wc->button_active_fg); button_fg = wc->button_active_fg;
setBackgroundColor (wc->button_active_bg); button_bg = wc->button_active_bg;
resetColors();
setShadow(); setShadow();
if ( ! text.isEmpty() ) if ( ! text.isEmpty() )

View File

@ -74,7 +74,7 @@ void FCheckBox::draw()
void FCheckBox::drawCheckButton() void FCheckBox::drawCheckButton()
{ {
print() << FPoint{1, 1}; print() << FPoint{1, 1};
useParentWidgetColor(); setColor();
if ( FTerm::isMonochron() ) if ( FTerm::isMonochron() )
{ {

View File

@ -180,7 +180,7 @@ void default16DarkColorPalette::setColorPalette()
setPalette (fc::Red, 0xa5, 0x40, 0x40); setPalette (fc::Red, 0xa5, 0x40, 0x40);
setPalette (fc::Magenta, 0xb2, 0x18, 0xb2); setPalette (fc::Magenta, 0xb2, 0x18, 0xb2);
setPalette (fc::Brown, 0xe8, 0x87, 0x1f); setPalette (fc::Brown, 0xe8, 0x87, 0x1f);
setPalette (fc::LightGray, 0xd2, 0xd2, 0xd2); setPalette (fc::LightGray, 0xdc, 0xdc, 0xdc);
setPalette (fc::DarkGray, 0x27, 0x33, 0x39); setPalette (fc::DarkGray, 0x27, 0x33, 0x39);
setPalette (fc::LightBlue, 0xb0, 0xb0, 0xb8); setPalette (fc::LightBlue, 0xb0, 0xb0, 0xb8);
setPalette (fc::LightGreen, 0x5e, 0xeb, 0x5c); setPalette (fc::LightGreen, 0x5e, 0xeb, 0x5c);

View File

@ -124,8 +124,11 @@ void FDropDownListBox::init()
void FDropDownListBox::draw() void FDropDownListBox::draw()
{ {
// Fill the background // Fill the background
const auto& wc = getColorTheme(); const auto& wc = getColorTheme();
setColor (wc->menu_active_fg, wc->menu_active_bg); setForegroundColor (wc->list_fg);
setBackgroundColor (wc->list_bg);
setColor();
if ( FTerm::isMonochron() ) if ( FTerm::isMonochron() )
setReverse(true); setReverse(true);

View File

@ -166,7 +166,7 @@ void FDialog::show()
FWindow::show(); FWindow::show();
if ( isModal() ) if ( isModal() && ! FApplication::isQuit() )
{ {
auto fapp = FApplication::getApplicationObject(); auto fapp = FApplication::getApplicationObject();
fapp->enterLoop(); fapp->enterLoop();

View File

@ -115,6 +115,15 @@ void FLabel::setAlignment (fc::text_alignment align)
alignment = align; alignment = align;
} }
//----------------------------------------------------------------------
void FLabel::resetColors()
{
useParentWidgetColor();
const auto& wc = getColorTheme();
emphasis_color = wc->label_emphasis_fg;
ellipsis_color = wc->label_ellipsis_fg;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FLabel::setEnable (bool enable) bool FLabel::setEnable (bool enable)
{ {
@ -247,6 +256,7 @@ void FLabel::cb_accelWidgetDestroyed (const FWidget*, const FDataPtr)
void FLabel::init() void FLabel::init()
{ {
unsetFocusable(); unsetFocusable();
useParentWidgetColor();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -290,7 +300,7 @@ void FLabel::draw()
if ( text.isEmpty() ) if ( text.isEmpty() )
return; return;
useParentWidgetColor();
if ( FTerm::isMonochron() ) if ( FTerm::isMonochron() )
{ {

View File

@ -721,7 +721,6 @@ void FListBox::draw()
useParentWidgetColor(); useParentWidgetColor();
if ( FTerm::isMonochron() ) if ( FTerm::isMonochron() )
setReverse(true); setReverse(true);

View File

@ -268,7 +268,7 @@ void FOptiMove::set_cursor_right (const char cap[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::set_cursor_address (const char cap[]) void FOptiMove::set_cursor_address (const char cap[])
{ {
if ( cap ) if ( cap && FTermcap::isInitialized() )
{ {
const char* temp = FTermcap::encodeMotionParameter(cap, 23, 23); const char* temp = FTermcap::encodeMotionParameter(cap, 23, 23);
F_cursor_address.cap = cap; F_cursor_address.cap = cap;
@ -286,7 +286,7 @@ void FOptiMove::set_cursor_address (const char cap[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::set_column_address (const char cap[]) void FOptiMove::set_column_address (const char cap[])
{ {
if ( cap ) if ( cap && FTermcap::isInitialized() )
{ {
const char* temp = FTermcap::encodeParameter(cap, 23); const char* temp = FTermcap::encodeParameter(cap, 23);
F_column_address.cap = cap; F_column_address.cap = cap;
@ -304,7 +304,7 @@ void FOptiMove::set_column_address (const char cap[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::set_row_address (const char cap[]) void FOptiMove::set_row_address (const char cap[])
{ {
if ( cap ) if ( cap && FTermcap::isInitialized() )
{ {
const char* temp = FTermcap::encodeParameter(cap, 23); const char* temp = FTermcap::encodeParameter(cap, 23);
F_row_address.cap = cap; F_row_address.cap = cap;
@ -322,7 +322,7 @@ void FOptiMove::set_row_address (const char cap[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::set_parm_up_cursor (const char cap[]) void FOptiMove::set_parm_up_cursor (const char cap[])
{ {
if ( cap ) if ( cap && FTermcap::isInitialized() )
{ {
const char* temp = FTermcap::encodeParameter(cap, 23); const char* temp = FTermcap::encodeParameter(cap, 23);
F_parm_up_cursor.cap = cap; F_parm_up_cursor.cap = cap;
@ -340,7 +340,7 @@ void FOptiMove::set_parm_up_cursor (const char cap[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::set_parm_down_cursor (const char cap[]) void FOptiMove::set_parm_down_cursor (const char cap[])
{ {
if ( cap ) if ( cap && FTermcap::isInitialized() )
{ {
const char* temp = FTermcap::encodeParameter(cap, 23); const char* temp = FTermcap::encodeParameter(cap, 23);
F_parm_down_cursor.cap = cap; F_parm_down_cursor.cap = cap;
@ -358,7 +358,7 @@ void FOptiMove::set_parm_down_cursor (const char cap[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::set_parm_left_cursor (const char cap[]) void FOptiMove::set_parm_left_cursor (const char cap[])
{ {
if ( cap ) if ( cap && FTermcap::isInitialized() )
{ {
const char* temp = FTermcap::encodeParameter(cap, 23); const char* temp = FTermcap::encodeParameter(cap, 23);
F_parm_left_cursor.cap = cap; F_parm_left_cursor.cap = cap;
@ -376,7 +376,7 @@ void FOptiMove::set_parm_left_cursor (const char cap[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::set_parm_right_cursor (const char cap[]) void FOptiMove::set_parm_right_cursor (const char cap[])
{ {
if ( cap ) if ( cap && FTermcap::isInitialized() )
{ {
const char* temp = FTermcap::encodeParameter(cap, 23); const char* temp = FTermcap::encodeParameter(cap, 23);
F_parm_right_cursor.cap = cap; F_parm_right_cursor.cap = cap;
@ -394,7 +394,7 @@ void FOptiMove::set_parm_right_cursor (const char cap[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::set_erase_chars (const char cap[]) void FOptiMove::set_erase_chars (const char cap[])
{ {
if ( cap ) if ( cap && FTermcap::isInitialized() )
{ {
const char* temp = FTermcap::encodeParameter(cap, 23); const char* temp = FTermcap::encodeParameter(cap, 23);
F_erase_chars.cap = cap; F_erase_chars.cap = cap;
@ -412,7 +412,7 @@ void FOptiMove::set_erase_chars (const char cap[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::set_repeat_char (const char cap[]) void FOptiMove::set_repeat_char (const char cap[])
{ {
if ( cap ) if ( cap && FTermcap::isInitialized() )
{ {
const char* temp = FTermcap::encodeParameter(cap, ' ', 23); const char* temp = FTermcap::encodeParameter(cap, ' ', 23);
F_repeat_char.cap = cap; F_repeat_char.cap = cap;

View File

@ -74,7 +74,7 @@ void FRadioButton::draw()
void FRadioButton::drawRadioButton() void FRadioButton::drawRadioButton()
{ {
print() << FPoint{1, 1}; print() << FPoint{1, 1};
useParentWidgetColor(); setColor();
if ( FTerm::isMonochron() ) if ( FTerm::isMonochron() )
{ {

View File

@ -453,6 +453,7 @@ void FScrollbar::draw()
drawButtons(); drawButtons();
current_slider_pos = -1; current_slider_pos = -1;
max_color = FTerm::getMaxColor();
drawBar(); drawBar();
} }

View File

@ -62,13 +62,16 @@
namespace finalcut namespace finalcut
{ {
// global FTerm object // Global FTerm object
static FTerm* init_term_object{nullptr}; static FTerm* init_term_object{nullptr};
// global init state // Global init state
static bool term_initialized{false}; static bool term_initialized{false};
// static class attributes // Counts the number of object instances
static uInt object_counter{0};
// Static class attributes
FTermData* FTerm::data {nullptr}; FTermData* FTerm::data {nullptr};
FSystem* FTerm::fsys {nullptr}; FSystem* FTerm::fsys {nullptr};
FOptiMove* FTerm::opti_move {nullptr}; FOptiMove* FTerm::opti_move {nullptr};
@ -101,10 +104,12 @@ FMouseControl* FTerm::mouse {nullptr};
// constructors and destructor // constructors and destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FTerm::FTerm (bool disable_alt_screen) FTerm::FTerm()
{ {
if ( ! term_initialized ) if ( object_counter == 0 )
init (disable_alt_screen); allocationValues(); // Allocation of global objects
object_counter++;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -112,6 +117,14 @@ FTerm::~FTerm() // destructor
{ {
if ( init_term_object == this ) if ( init_term_object == this )
finish(); // Resetting console settings finish(); // Resetting console settings
object_counter--;
if ( object_counter == 0 )
{
printExitMessage();
deallocationValues(); // Deallocation of global objects
}
} }
@ -119,6 +132,9 @@ FTerm::~FTerm() // destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::size_t FTerm::getLineNumber() std::size_t FTerm::getLineNumber()
{ {
if ( ! data )
data = FTerm::getFTermData();
const auto& term_geometry = data->getTermGeometry(); const auto& term_geometry = data->getTermGeometry();
if ( term_geometry.getHeight() == 0 ) if ( term_geometry.getHeight() == 0 )
@ -130,6 +146,9 @@ std::size_t FTerm::getLineNumber()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
std::size_t FTerm::getColumnNumber() std::size_t FTerm::getColumnNumber()
{ {
if ( ! data )
data = FTerm::getFTermData();
const auto& term_geometry = data->getTermGeometry(); const auto& term_geometry = data->getTermGeometry();
if ( term_geometry.getWidth() == 0 ) if ( term_geometry.getWidth() == 0 )
@ -217,7 +236,7 @@ FSystem* FTerm::getFSystem()
} }
catch (const std::bad_alloc&) catch (const std::bad_alloc&)
{ {
badAllocOutput ("FTermData"); badAllocOutput ("FSystemImpl");
std::abort(); std::abort();
} }
} }
@ -640,6 +659,14 @@ void FTerm::setDblclickInterval (const uInt64 timeout)
mouse->setDblclickInterval(timeout); mouse->setDblclickInterval(timeout);
} }
//----------------------------------------------------------------------
void FTerm::useAlternateScreen (bool enable)
{
// Sets alternate screen usage
getFTermData()->useAlternateScreen(enable);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTerm::setUTF8 (bool enable) // UTF-8 (Unicode) bool FTerm::setUTF8 (bool enable) // UTF-8 (Unicode)
{ {
@ -1293,22 +1320,6 @@ void FTerm::changeTermSizeFinished()
data->setTermResized(false); data->setTermResized(false);
} }
//----------------------------------------------------------------------
void FTerm::exitWithMessage (const FString& message)
{
// Exit the programm
if ( init_term_object )
init_term_object->finish();
std::fflush (stderr);
std::fflush (stdout);
if ( ! message.isEmpty() )
FApplication::getLog()->warn(message.c_str());
std::exit (EXIT_FAILURE);
}
// private methods of FTerm // private methods of FTerm
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1318,16 +1329,13 @@ inline FStartOptions& FTerm::getStartOptions()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::init_global_values (bool disable_alt_screen) void FTerm::init_global_values()
{ {
// Initialize global values // Initialize global values
// Preset to false // Preset to false
data->setNewFont(false); data->setNewFont(false);
// Sets alternate screen usage
data->useAlternateScreen(! disable_alt_screen);
// Initialize xterm object // Initialize xterm object
getFTermXTerminal()->init(); getFTermXTerminal()->init();
@ -1653,13 +1661,21 @@ void FTerm::init_optiAttr()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::init_font() bool FTerm::init_font()
{ {
if ( getStartOptions().vgafont && ! setVGAFont() ) if ( getStartOptions().vgafont && ! setVGAFont() )
exitWithMessage ("VGAfont is not supported by this terminal"); {
data->setExitMessage("VGAfont is not supported by this terminal");
FApplication::exit(EXIT_FAILURE);
}
if ( getStartOptions().newfont && ! setNewFont() ) if ( getStartOptions().newfont && ! setNewFont() )
exitWithMessage ("Newfont is not supported by this terminal"); {
data->setExitMessage("Newfont is not supported by this terminal");
FApplication::exit(EXIT_FAILURE);
}
return ( ! FApplication::isQuit() );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -2112,6 +2128,7 @@ void FTerm::useAlternateScreenBuffer()
{ {
putstring (TCAP(fc::t_enter_ca_mode)); putstring (TCAP(fc::t_enter_ca_mode));
std::fflush(stdout); std::fflush(stdout);
getFTermData()->setAlternateScreenInUse(true);
} }
} }
@ -2128,6 +2145,7 @@ void FTerm::useNormalScreenBuffer()
{ {
putstring (TCAP(fc::t_exit_ca_mode)); putstring (TCAP(fc::t_exit_ca_mode));
std::fflush(stdout); std::fflush(stdout);
getFTermData()->setAlternateScreenInUse(false);
} }
// restore cursor to position of last save_cursor // restore cursor to position of last save_cursor
@ -2209,17 +2227,17 @@ inline void FTerm::deallocationValues()
const defaultPutChar* putchar_ptr = &(putchar()); const defaultPutChar* putchar_ptr = &(putchar());
delete putchar_ptr; delete putchar_ptr;
destroyColorPaletteTheme();
FStartOptions::destroyObject(); FStartOptions::destroyObject();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::init (bool disable_alt_screen) void FTerm::init()
{ {
init_term_object = this; init_term_object = this;
// Initialize global values for all objects // Initialize global values for all objects
allocationValues(); init_global_values();
init_global_values(disable_alt_screen);
// Initialize the terminal // Initialize the terminal
if ( ! init_terminal() ) if ( ! init_terminal() )
@ -2294,7 +2312,8 @@ void FTerm::init (bool disable_alt_screen)
// Activate the VGA or the new graphic font // Activate the VGA or the new graphic font
// (depending on the initialization values) // (depending on the initialization values)
init_font(); if ( ! init_font() )
return;
// Turn off hardware echo // Turn off hardware echo
FTermios::unsetHardwareEcho(); FTermios::unsetHardwareEcho();
@ -2474,14 +2493,6 @@ void FTerm::finish()
if ( data->isNewFont() || data->isVGAFont() ) if ( data->isNewFont() || data->isVGAFont() )
setOldFont(); setOldFont();
// Print exit message
const auto& exit_message = data->getExitMessage();
if ( ! exit_message.isEmpty() )
FApplication::getLog()->info(exit_message.c_str());
deallocationValues();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -2512,6 +2523,48 @@ void FTerm::destroyColorPaletteTheme()
delete theme; delete theme;
} }
//----------------------------------------------------------------------
void FTerm::printExitMessage()
{
// Print exit message
const auto& exit_message = data->getExitMessage();
if ( ! exit_message.isEmpty() )
std::cerr << "Exit: " << exit_message << std::endl;
}
//----------------------------------------------------------------------
void FTerm::terminalSizeChange()
{
if ( ! data )
return;
if ( data->hasTermResized() )
return;
// Initialize a resize event to the root element
data->setTermResized(true);
}
//----------------------------------------------------------------------
void FTerm::processTermination (int signum)
{
init_term_object->finish();
std::fflush (stderr);
std::fflush (stdout);
if ( data )
{
FStringStream msg{};
msg << "Program stopped: signal " << signum
<< " (" << strsignal(signum) << ")";
data->setExitMessage(msg.str());
printExitMessage();
}
std::terminate();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTerm::setSignalHandler() void FTerm::setSignalHandler()
{ {
@ -2542,14 +2595,7 @@ void FTerm::signal_handler (int signum)
switch (signum) switch (signum)
{ {
case SIGWINCH: case SIGWINCH:
if ( ! data ) terminalSizeChange();
break;
if ( data->hasTermResized() )
break;
// initialize a resize event to the root element
data->setTermResized(true);
break; break;
case SIGTERM: case SIGTERM:
@ -2558,15 +2604,7 @@ void FTerm::signal_handler (int signum)
case SIGABRT: case SIGABRT:
case SIGILL: case SIGILL:
case SIGSEGV: case SIGSEGV:
init_term_object->finish(); processTermination(signum);
std::fflush (stderr);
std::fflush (stdout);
*FApplication::getLog() << FLog::Error
<< "\nProgram stopped: signal "
<< signum
<< " (" << strsignal(signum) << ")"
<< std::endl;
std::terminate();
default: default:
break; break;

View File

@ -33,6 +33,7 @@
#define initCheck(ret_value) \ #define initCheck(ret_value) \
if ( ! isInitialized() ) \ if ( ! isInitialized() ) \
{ \ { \
if ( ! FApplication::isQuit() ) \
warnNotInitialized(); \ warnNotInitialized(); \
return ret_value; \ return ret_value; \
} }

View File

@ -30,6 +30,7 @@
#define initCheck(ret_value) \ #define initCheck(ret_value) \
if ( ! isInitialized() ) \ if ( ! isInitialized() ) \
{ \ { \
if ( ! FApplication::isQuit() ) \
warnNotInitialized(); \ warnNotInitialized(); \
return ret_value; \ return ret_value; \
} }

View File

@ -39,6 +39,7 @@
#define initCheck(ret_value) \ #define initCheck(ret_value) \
if ( ! isInitialized() ) \ if ( ! isInitialized() ) \
{ \ { \
if ( ! FApplication::isQuit() ) \
warnNotInitialized(); \ warnNotInitialized(); \
return ret_value; \ return ret_value; \
} }

View File

@ -148,29 +148,12 @@ bool FToggleButton::setNoUnderline (bool enable)
bool FToggleButton::setEnable (bool enable) bool FToggleButton::setEnable (bool enable)
{ {
FWidget::setEnable(enable); FWidget::setEnable(enable);
const auto& wc = getColorTheme(); resetColors();
if ( enable ) if ( enable )
{
setHotkeyAccelerator(); setHotkeyAccelerator();
if ( hasFocus() )
{
setForegroundColor (wc->toggle_button_active_focus_fg);
setBackgroundColor (wc->toggle_button_active_focus_bg);
}
else else
{
setForegroundColor (wc->toggle_button_active_fg);
setBackgroundColor (wc->toggle_button_active_bg);
}
}
else
{
delAccelerator(); delAccelerator();
setForegroundColor (wc->toggle_button_inactive_fg);
setBackgroundColor (wc->toggle_button_inactive_bg);
}
return enable; return enable;
} }
@ -179,26 +162,11 @@ bool FToggleButton::setEnable (bool enable)
bool FToggleButton::setFocus (bool enable) bool FToggleButton::setFocus (bool enable)
{ {
FWidget::setFocus(enable); FWidget::setFocus(enable);
resetColors();
if ( isEnabled() ) if ( isEnabled() && hasFocus() && isRadioButton() )
{
const auto& wc = getColorTheme();
if ( enable )
{
if ( isRadioButton() )
focus_inside_group = false; focus_inside_group = false;
setForegroundColor (wc->toggle_button_active_focus_fg);
setBackgroundColor (wc->toggle_button_active_focus_bg);
}
else
{
setForegroundColor (wc->toggle_button_active_fg);
setBackgroundColor (wc->toggle_button_active_bg);
}
}
return enable; return enable;
} }

View File

@ -54,6 +54,7 @@ bool FVTerm::terminal_update_complete{false};
bool FVTerm::terminal_update_pending{false}; bool FVTerm::terminal_update_pending{false};
bool FVTerm::force_terminal_update{false}; bool FVTerm::force_terminal_update{false};
bool FVTerm::no_terminal_updates{false}; bool FVTerm::no_terminal_updates{false};
bool FVTerm::cursor_hideable{false};
int FVTerm::skipped_terminal_update{}; int FVTerm::skipped_terminal_update{};
uInt FVTerm::erase_char_length{}; uInt FVTerm::erase_char_length{};
uInt FVTerm::repeat_char_length{}; uInt FVTerm::repeat_char_length{};
@ -80,10 +81,10 @@ FChar FVTerm::i_ch{};
// constructors and destructor // constructors and destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FVTerm::FVTerm (bool initialize, bool disable_alt_screen) FVTerm::FVTerm()
{ {
if ( initialize ) if ( ! init_object )
init (disable_alt_screen); init();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -171,6 +172,9 @@ void FVTerm::hideCursor (bool enable)
{ {
// Hides or shows the input cursor on the terminal // Hides or shows the input cursor on the terminal
if ( ! cursor_hideable )
return;
const char* visibility_str = FTerm::cursorsVisibilityString (enable); const char* visibility_str = FTerm::cursorsVisibilityString (enable);
if ( visibility_str ) if ( visibility_str )
@ -644,6 +648,9 @@ void FVTerm::flush()
{ {
// Flush the output buffer // Flush the output buffer
if ( ! output_buffer )
return;
while ( ! output_buffer->empty() ) while ( ! output_buffer->empty() )
{ {
const static FTerm::defaultPutChar& FTermPutchar = FTerm::putchar(); const static FTerm::defaultPutChar& FTermPutchar = FTerm::putchar();
@ -798,6 +805,9 @@ void FVTerm::removeArea (FTermArea*& area)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::restoreVTerm (const FRect& box) void FVTerm::restoreVTerm (const FRect& box)
{ {
if ( ! vterm )
return;
int x = box.getX() - 1; int x = box.getX() - 1;
int y = box.getY() - 1; int y = box.getY() - 1;
int w = int(box.getWidth()); int w = int(box.getWidth());
@ -1339,6 +1349,23 @@ void FVTerm::finishTerminalUpdate()
terminal_update_complete = true; terminal_update_complete = true;
} }
//----------------------------------------------------------------------
void FVTerm::initTerminal()
{
if ( fterm )
fterm->initTerminal();
// Get FKeyboard object
keyboard = FTerm::getFKeyboard();
// Hide the input cursor
cursor_hideable = FTerm::isCursorHideable();
hideCursor();
// Initialize character lengths
init_characterLengths(FTerm::getFOptiMove());
}
// private methods of FVTerm // private methods of FVTerm
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1897,7 +1924,7 @@ const FChar FVTerm::getOverlappedCharacter (const FPoint& pos, FVTerm* obj)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::init (bool disable_alt_screen) void FVTerm::init()
{ {
init_object = this; init_object = this;
vterm = nullptr; vterm = nullptr;
@ -1906,16 +1933,20 @@ void FVTerm::init (bool disable_alt_screen)
try try
{ {
fterm = new FTerm (disable_alt_screen); fterm = new FTerm();
term_pos = new FPoint(-1, -1); term_pos = new FPoint(-1, -1);
output_buffer = new std::queue<int>; output_buffer = new std::queue<int>;
} }
catch (const std::bad_alloc&) catch (const std::bad_alloc&)
{ {
badAllocOutput ("FTerm, FPoint, or std::queue<int>"); badAllocOutput ("FTerm, FPoint, or std::queue<int>");
std::abort(); return;
} }
// Presetting of the current locale for full-width character support.
// The final setting is made later in FTerm::init_locale().
std::setlocale (LC_ALL, "");
// term_attribute stores the current state of the terminal // term_attribute stores the current state of the terminal
term_attribute.ch = '\0'; term_attribute.ch = '\0';
term_attribute.fg_color = fc::Default; term_attribute.fg_color = fc::Default;
@ -1937,15 +1968,6 @@ void FVTerm::init (bool disable_alt_screen)
createArea (term_geometry, shadow_size, vdesktop); createArea (term_geometry, shadow_size, vdesktop);
vdesktop->visible = true; vdesktop->visible = true;
active_area = vdesktop; active_area = vdesktop;
// Get FKeyboard object
keyboard = FTerm::getFKeyboard();
// Hide the input cursor
hideCursor();
// Initialize character lengths
init_characterLengths (FTerm::getFOptiMove());
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1978,7 +2000,8 @@ void FVTerm::finish()
// Clear the terminal // Clear the terminal
setNormal(); setNormal();
if ( FTerm::hasAlternateScreen() ) if ( FTerm::hasAlternateScreen()
&& FTerm::getFTermData()->isInAlternateScreen() )
clearTerm(); clearTerm();
flush(); flush();

View File

@ -49,8 +49,8 @@ FWidget::FWidgetList* FWidget::window_list{nullptr};
FWidget::FWidgetList* FWidget::dialog_list{nullptr}; FWidget::FWidgetList* FWidget::dialog_list{nullptr};
FWidget::FWidgetList* FWidget::always_on_top_list{nullptr}; FWidget::FWidgetList* FWidget::always_on_top_list{nullptr};
FWidget::FWidgetList* FWidget::close_widget{nullptr}; FWidget::FWidgetList* FWidget::close_widget{nullptr};
bool FWidget::init_terminal{false};
bool FWidget::init_desktop{false}; bool FWidget::init_desktop{false};
bool FWidget::hideable{false};
uInt FWidget::modal_dialog_counter{}; uInt FWidget::modal_dialog_counter{};
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -59,8 +59,8 @@ uInt FWidget::modal_dialog_counter{};
// constructors and destructor // constructors and destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FWidget::FWidget (FWidget* parent, bool disable_alt_screen) FWidget::FWidget (FWidget* parent)
: FVTerm{ ! (bool(parent) || root_widget), disable_alt_screen} : FVTerm{}
, FObject{parent} , FObject{parent}
{ {
// init bit field with 0 // init bit field with 0
@ -83,22 +83,18 @@ FWidget::FWidget (FWidget* parent, bool disable_alt_screen)
return; return;
} }
root_widget = this;
show_root_widget = nullptr;
redraw_root_widget = nullptr;
modal_dialog_counter = 0;
statusbar = nullptr;
initRootWidget(); initRootWidget();
} }
else else
{ {
flags.visible_cursor = ! hideable;
woffset = parent->wclient_offset; woffset = parent->wclient_offset;
}
flags.visible_cursor = false;
double_flatline_mask.top.resize (getWidth(), false); double_flatline_mask.top.resize (getWidth(), false);
double_flatline_mask.right.resize (getHeight(), false); double_flatline_mask.right.resize (getHeight(), false);
double_flatline_mask.bottom.resize (getWidth(), false); double_flatline_mask.bottom.resize (getWidth(), false);
double_flatline_mask.left.resize (getHeight(), false); double_flatline_mask.left.resize (getHeight(), false);
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -658,9 +654,10 @@ bool FWidget::setCursorPos (const FPoint& pos)
woffsetY += (1 - area->widget->getTopPadding()); woffsetY += (1 - area->widget->getTopPadding());
} }
bool visible = ! isCursorHideable() || flags.visible_cursor;
setAreaCursor ( { woffsetX + pos.getX() setAreaCursor ( { woffsetX + pos.getX()
, woffsetY + pos.getY() } , woffsetY + pos.getY() }
, flags.visible_cursor , visible
, area ); , area );
return true; return true;
} }
@ -1032,20 +1029,12 @@ void FWidget::show()
{ {
// Make the widget visible and draw it // Make the widget visible and draw it
if ( ! isVisible() ) if ( ! isVisible() || FApplication::isQuit() )
return; return;
if ( ! init_desktop ) // Initialize desktop on first call
{ if ( ! init_desktop && root_widget )
// Sets the initial screen settings root_widget->initDesktop();
FTerm::initScreenSettings();
// Initializing vdesktop
const auto& r = getRootWidget();
setColor(r->getForegroundColor(), r->getBackgroundColor());
clearArea (getVirtualDesktop());
// Destop is now initialized
init_desktop = true;
}
if ( ! show_root_widget ) if ( ! show_root_widget )
{ {
@ -1320,6 +1309,49 @@ void FWidget::setTermOffsetWithPadding()
, int(r->getHeight()) - 1 - r->getBottomPadding() ); , int(r->getHeight()) - 1 - r->getBottomPadding() );
} }
//----------------------------------------------------------------------
void FWidget::initTerminal()
{
if ( hasParent() || init_terminal )
return;
// Initialize the physical and virtual terminal
FVTerm::initTerminal();
// Initialize default widget colors (after terminal detection)
initColorTheme();
// Set default foreground and background color of the desktop/terminal
auto color_theme = getColorTheme();
root_widget->foreground_color = color_theme->term_fg;
root_widget->background_color = color_theme->term_bg;
resetColors();
// The terminal is now initialized
init_terminal = true;
}
//----------------------------------------------------------------------
void FWidget::initDesktop()
{
if ( hasParent() || init_desktop )
return;
if ( ! init_terminal )
initTerminal();
// Sets the initial screen settings
FTerm::initScreenSettings();
// Initializing vdesktop
const auto& r = getRootWidget();
setColor(r->getForegroundColor(), r->getBackgroundColor());
clearArea (getVirtualDesktop());
// Destop is now initialized
init_desktop = true;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::adjustSize() void FWidget::adjustSize()
{ {
@ -1713,6 +1745,18 @@ void FWidget::onClose (FCloseEvent* ev)
// private methods of FWidget // private methods of FWidget
//----------------------------------------------------------------------
void FWidget::determineDesktopSize()
{
// Determine width and height of the terminal
detectTermSize();
wsize.setRect(1, 1, getDesktopWidth(), getDesktopHeight());
adjust_wsize = wsize;
woffset.setRect(0, 0, getDesktopWidth(), getDesktopHeight());
wclient_offset = woffset;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::initRootWidget() void FWidget::initRootWidget()
{ {
@ -1730,29 +1774,18 @@ void FWidget::initRootWidget()
return; return;
} }
hideable = FTerm::isCursorHideable(); // Root widget basic initialization
flags.visible_cursor = ! hideable; root_widget = this;
show_root_widget = nullptr;
redraw_root_widget = nullptr;
modal_dialog_counter = 0;
statusbar = nullptr;
// Determine width and height of the terminal // Determine width and height of the terminal
detectTermSize(); determineDesktopSize();
wsize.setRect(1, 1, getDesktopWidth(), getDesktopHeight());
adjust_wsize = wsize;
woffset.setRect(0, 0, getDesktopWidth(), getDesktopHeight());
wclient_offset = woffset;
double_flatline_mask.top.resize (getWidth(), false); // Initialize default widget colors (before terminal detection)
double_flatline_mask.right.resize (getHeight(), false);
double_flatline_mask.bottom.resize (getWidth(), false);
double_flatline_mask.left.resize (getHeight(), false);
// Initialize default widget colors
initColorTheme(); initColorTheme();
// Default foreground and background color of the desktop/terminal
auto color_theme = getColorTheme();
foreground_color = color_theme->term_fg;
background_color = color_theme->term_bg;
init_desktop = false;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -94,7 +94,7 @@ class FApplication : public FWidget
typedef std::shared_ptr<FLog> FLogPtr; typedef std::shared_ptr<FLog> FLogPtr;
// Constructor // Constructor
FApplication (const int&, char*[], bool = false); FApplication (const int&, char*[]);
// Disable copy constructor // Disable copy constructor
FApplication (const FApplication&) = delete; FApplication (const FApplication&) = delete;
@ -122,27 +122,24 @@ class FApplication : public FWidget
int exec(); // run int exec(); // run
int enterLoop(); int enterLoop();
void exitLoop(); void exitLoop();
static void exit (int = 0); static void exit (int = EXIT_SUCCESS);
void quit(); void quit();
static bool sendEvent (FObject*, FEvent*); static bool sendEvent (FObject*, FEvent*);
void queueEvent (FObject*, FEvent*); void queueEvent (FObject*, FEvent*);
void sendQueuedEvents(); void sendQueuedEvents();
bool eventInQueue(); bool eventInQueue();
bool removeQueuedEvent (const FObject*); bool removeQueuedEvent (const FObject*);
virtual void processExternalUserEvent(); void initTerminal();
static FWidget* processParameters (const int&, char*[]);
static void setDefaultTheme(); static void setDefaultTheme();
static void setDarkTheme(); static void setDarkTheme();
static void showParameterUsage ()
#if defined(__clang__) || defined(__GNUC__)
__attribute__((noreturn))
#endif
;
static void closeConfirmationDialog (FWidget*, FCloseEvent*); static void closeConfirmationDialog (FWidget*, FCloseEvent*);
// Callback method // Callback method
void cb_exitApp (const FWidget*, const FDataPtr); void cb_exitApp (const FWidget*, const FDataPtr);
protected:
virtual void processExternalUserEvent();
private: private:
// Typedefs // Typedefs
typedef std::pair<FObject*, FEvent*> EventPair; typedef std::pair<FObject*, FEvent*> EventPair;
@ -152,6 +149,7 @@ class FApplication : public FWidget
void init (uInt64, uInt64); void init (uInt64, uInt64);
static void cmd_options (const int&, char*[]); static void cmd_options (const int&, char*[]);
static FStartOptions& getStartOptions(); static FStartOptions& getStartOptions();
static void showParameterUsage();
void destroyLog(); void destroyLog();
void findKeyboardWidget(); void findKeyboardWidget();
bool isKeyPressed() const; bool isKeyPressed() const;
@ -186,6 +184,7 @@ class FApplication : public FWidget
, const FPoint& , const FPoint&
, int ); , int );
void sendWheelEvent (const FPoint&, const FPoint&); void sendWheelEvent (const FPoint&, const FPoint&);
static FWidget* processParameters (const int&, char*[]);
void processMouseEvent(); void processMouseEvent();
void processResizeEvent(); void processResizeEvent();
void processCloseWidget(); void processCloseWidget();

View File

@ -158,13 +158,13 @@ class FButton : public FWidget
bool click_animation{true}; bool click_animation{true};
int click_time{150}; int click_time{150};
int space_char{int(' ')}; int space_char{int(' ')};
FColor button_fg{getColorTheme()->button_active_fg}; FColor button_fg{fc::Default};
FColor button_bg{getColorTheme()->button_active_bg}; FColor button_bg{fc::Default};
FColor button_hotkey_fg{getColorTheme()->button_hotkey_fg}; FColor button_hotkey_fg{fc::Default};
FColor button_focus_fg{getColorTheme()->button_active_focus_fg}; FColor button_focus_fg{fc::Default};
FColor button_focus_bg{getColorTheme()->button_active_focus_bg}; FColor button_focus_bg{fc::Default};
FColor button_inactive_fg{getColorTheme()->button_inactive_fg}; FColor button_inactive_fg{fc::Default};
FColor button_inactive_bg{getColorTheme()->button_inactive_bg}; FColor button_inactive_bg{fc::Default};
std::size_t hotkeypos{NOT_SET}; std::size_t hotkeypos{NOT_SET};
std::size_t indent{0}; std::size_t indent{0};
std::size_t center_offset{0}; std::size_t center_offset{0};

View File

@ -98,6 +98,7 @@ class FLabel : public FWidget
bool setEmphasis (bool); bool setEmphasis (bool);
bool setEmphasis(); bool setEmphasis();
bool unsetEmphasis(); bool unsetEmphasis();
void resetColors() override;
bool setReverseMode (bool); bool setReverseMode (bool);
bool setReverseMode(); bool setReverseMode();
bool unsetReverseMode(); bool unsetReverseMode();
@ -145,8 +146,8 @@ class FLabel : public FWidget
std::size_t align_offset{0}; std::size_t align_offset{0};
std::size_t hotkeypos{NOT_SET}; std::size_t hotkeypos{NOT_SET};
std::size_t column_width{0}; std::size_t column_width{0};
FColor emphasis_color{getColorTheme()->label_emphasis_fg}; FColor emphasis_color{fc::Default};
FColor ellipsis_color{getColorTheme()->label_ellipsis_fg}; FColor ellipsis_color{fc::Default};
bool multiline{false}; bool multiline{false};
bool emphasis{false}; bool emphasis{false};
bool reverse_mode{false}; bool reverse_mode{false};

View File

@ -166,7 +166,7 @@ class FTerm final
typedef FColorPalette::FSetPalette FSetPalette; typedef FColorPalette::FSetPalette FSetPalette;
// Constructor // Constructor
explicit FTerm (bool = false); explicit FTerm();
// Disable copy constructor // Disable copy constructor
FTerm (const FTerm&) = delete; FTerm (const FTerm&) = delete;
@ -189,7 +189,6 @@ class FTerm final
static int getMaxColor(); static int getMaxColor();
static FColorPalettePtr& getColorPaletteTheme(); static FColorPalettePtr& getColorPaletteTheme();
charSubstitution& getCharSubstitutionMap(); charSubstitution& getCharSubstitutionMap();
static FTermData* getFTermData(); static FTermData* getFTermData();
static FSystem* getFSystem(); static FSystem* getFSystem();
static FOptiMove* getFOptiMove(); static FOptiMove* getFOptiMove();
@ -257,6 +256,7 @@ class FTerm final
static void unsetInsertCursor(); static void unsetInsertCursor();
static void redefineDefaultColors (bool); static void redefineDefaultColors (bool);
static void setDblclickInterval (const uInt64); static void setDblclickInterval (const uInt64);
static void useAlternateScreen (bool);
static bool setUTF8 (bool); static bool setUTF8 (bool);
static bool setUTF8(); static bool setUTF8();
static bool unsetUTF8(); static bool unsetUTF8();
@ -299,18 +299,15 @@ class FTerm final
static int putchar_ASCII (int); static int putchar_ASCII (int);
static int putchar_UTF8 (int); static int putchar_UTF8 (int);
void initTerminal();
static void initScreenSettings(); static void initScreenSettings();
static const char* changeAttribute (FChar*&, FChar*&); static const char* changeAttribute (FChar*&, FChar*&);
static void changeTermSizeFinished(); static void changeTermSizeFinished();
static void exitWithMessage (const FString&)
#if defined(__clang__) || defined(__GNUC__)
__attribute__((noreturn))
#endif
;
private: private:
// Methods // Methods
static FStartOptions& getStartOptions(); static FStartOptions& getStartOptions();
static void init_global_values (bool); static void init_global_values();
static void init_terminal_device_path(); static void init_terminal_device_path();
static void oscPrefix(); static void oscPrefix();
static void oscPostfix(); static void oscPostfix();
@ -324,7 +321,7 @@ class FTerm final
static void init_quirks(); static void init_quirks();
static void init_optiMove(); static void init_optiMove();
static void init_optiAttr(); static void init_optiAttr();
static void init_font(); static bool init_font();
static void init_locale(); static void init_locale();
static void init_encoding(); static void init_encoding();
static void init_encoding_set(); static void init_encoding_set();
@ -352,7 +349,7 @@ class FTerm final
static void useNormalScreenBuffer(); static void useNormalScreenBuffer();
void allocationValues(); void allocationValues();
void deallocationValues(); void deallocationValues();
void init (bool); void init();
bool init_terminal(); bool init_terminal();
void initOSspecifics(); void initOSspecifics();
void initTermspecifics(); void initTermspecifics();
@ -361,6 +358,9 @@ class FTerm final
void finishOSspecifics1(); void finishOSspecifics1();
void finish_encoding(); void finish_encoding();
void destroyColorPaletteTheme(); void destroyColorPaletteTheme();
static void printExitMessage();
static void terminalSizeChange();
[[noreturn]] static void processTermination (int);
static void setSignalHandler(); static void setSignalHandler();
static void resetSignalHandler(); static void resetSignalHandler();
static void signal_handler (int); static void signal_handler (int);
@ -467,6 +467,10 @@ inline void FTerm::putstringf (const char format[], Args&&... args)
fsys->tputs (&buf[0], 1, FTerm::putchar_ASCII); fsys->tputs (&buf[0], 1, FTerm::putchar_ASCII);
} }
//----------------------------------------------------------------------
inline void FTerm::initTerminal()
{ init(); }
} // namespace finalcut } // namespace finalcut

View File

@ -108,6 +108,9 @@ class FTermcap final
template<typename CharT> template<typename CharT>
static int paddingPrint (const CharT&, int, fn_putc); static int paddingPrint (const CharT&, int, fn_putc);
// Inquiry
static bool isInitialized();
// Methods // Methods
static void init(); static void init();
@ -129,6 +132,7 @@ class FTermcap final
// Constant // Constant
static constexpr std::size_t BUF_SIZE{2048}; static constexpr std::size_t BUF_SIZE{2048};
// Methods // Methods
static void termcap(); static void termcap();
static void termcapError (int); static void termcapError (int);
@ -194,6 +198,12 @@ int FTermcap::paddingPrint (const CharT& str, int affcnt, fn_putc putc)
return _tputs (C_STR(str), affcnt, putc); return _tputs (C_STR(str), affcnt, putc);
} }
//----------------------------------------------------------------------
inline bool FTermcap::isInitialized()
{
return bool(fsystem && fterm_data && term_detection);
}
} // namespace finalcut } // namespace finalcut

View File

@ -93,6 +93,7 @@ class FTermData final
bool hasCursorOptimisation() const; bool hasCursorOptimisation() const;
bool isCursorHidden() const; bool isCursorHidden() const;
bool hasAlternateScreen() const; bool hasAlternateScreen() const;
bool isInAlternateScreen() const;
bool hasASCIIConsole() const; bool hasASCIIConsole() const;
bool hasVT100Console() const; bool hasVT100Console() const;
bool hasUTF8Console() const; bool hasUTF8Console() const;
@ -111,6 +112,7 @@ class FTermData final
void supportCursorOptimisation (bool); void supportCursorOptimisation (bool);
void setCursorHidden (bool); void setCursorHidden (bool);
void useAlternateScreen (bool); void useAlternateScreen (bool);
void setAlternateScreenInUse (bool);
void setASCIIConsole (bool); void setASCIIConsole (bool);
void setVT100Console (bool); void setVT100Console (bool);
void setUTF8Console (bool); void setUTF8Console (bool);
@ -151,6 +153,7 @@ class FTermData final
bool cursor_optimisation{true}; bool cursor_optimisation{true};
bool hidden_cursor{false}; // Global cursor hidden state bool hidden_cursor{false}; // Global cursor hidden state
bool use_alternate_screen{true}; bool use_alternate_screen{true};
bool alternate_screen{false};
bool ascii_console{false}; bool ascii_console{false};
bool vt100_console{false}; bool vt100_console{false};
bool utf8_console{false}; bool utf8_console{false};
@ -236,6 +239,10 @@ inline bool FTermData::isCursorHidden() const
inline bool FTermData::hasAlternateScreen() const inline bool FTermData::hasAlternateScreen() const
{ return use_alternate_screen; } { return use_alternate_screen; }
//----------------------------------------------------------------------
inline bool FTermData::isInAlternateScreen() const
{ return alternate_screen; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermData::hasASCIIConsole() const inline bool FTermData::hasASCIIConsole() const
{ return ascii_console; } { return ascii_console; }
@ -300,6 +307,10 @@ inline void FTermData::setCursorHidden (bool hidden_state)
inline void FTermData::useAlternateScreen (bool use) inline void FTermData::useAlternateScreen (bool use)
{ use_alternate_screen = use; } { use_alternate_screen = use; }
//----------------------------------------------------------------------
inline void FTermData::setAlternateScreenInUse (bool in_use)
{ alternate_screen = in_use; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FTermData::setASCIIConsole (bool ascii) inline void FTermData::setASCIIConsole (bool ascii)
{ ascii_console = ascii; } { ascii_console = ascii; }

View File

@ -118,7 +118,7 @@ class FVTerm
}; };
// Constructor // Constructor
explicit FVTerm (bool, bool = false); explicit FVTerm();
// Disable copy constructor // Disable copy constructor
FVTerm (const FVTerm&) = delete; FVTerm (const FVTerm&) = delete;
@ -293,9 +293,9 @@ class FVTerm
bool hasPrintArea() const; bool hasPrintArea() const;
bool hasChildPrintArea() const; bool hasChildPrintArea() const;
bool isVirtualWindow() const; bool isVirtualWindow() const;
bool isCursorHideable() const;
// Methods // Methods
void createArea ( const FRect& void createArea ( const FRect&
, const FSize& , const FSize&
, FTermArea*& ); , FTermArea*& );
@ -317,6 +317,7 @@ class FVTerm
void processTerminalUpdate(); void processTerminalUpdate();
static void startTerminalUpdate(); static void startTerminalUpdate();
static void finishTerminalUpdate(); static void finishTerminalUpdate();
void initTerminal();
private: private:
// Enumerations // Enumerations
@ -373,7 +374,7 @@ class FVTerm
, FVTerm* ); , FVTerm* );
static const FChar getCoveredCharacter (const FPoint&, FVTerm*); static const FChar getCoveredCharacter (const FPoint&, FVTerm*);
static const FChar getOverlappedCharacter (const FPoint&, FVTerm*); static const FChar getOverlappedCharacter (const FPoint&, FVTerm*);
void init (bool); void init();
static void init_characterLengths (const FOptiMove*); static void init_characterLengths (const FOptiMove*);
void finish(); void finish();
static void putAreaLine (const FChar*, FChar*, int); static void putAreaLine (const FChar*, FChar*, int);
@ -445,6 +446,7 @@ class FVTerm
static uInt clr_bol_length; static uInt clr_bol_length;
static uInt clr_eol_length; static uInt clr_eol_length;
static uInt cursor_address_length; static uInt cursor_address_length;
static bool cursor_hideable;
}; };
@ -970,6 +972,10 @@ inline bool FVTerm::hasChildPrintArea() const
inline bool FVTerm::isVirtualWindow() const inline bool FVTerm::isVirtualWindow() const
{ return vwin; } { return vwin; }
//----------------------------------------------------------------------
inline bool FVTerm::isCursorHideable() const
{ return cursor_hideable; }
} // namespace finalcut } // namespace finalcut

View File

@ -173,7 +173,7 @@ class FWidget : public FVTerm, public FObject
}; };
// Constructor // Constructor
explicit FWidget (FWidget* = nullptr, bool = false); explicit FWidget (FWidget* = nullptr);
// Disable copy constructor // Disable copy constructor
FWidget (const FWidget&) = delete; FWidget (const FWidget&) = delete;
@ -374,6 +374,8 @@ class FWidget : public FVTerm, public FObject
void setTermOffsetWithPadding(); void setTermOffsetWithPadding();
// Methods // Methods
void initTerminal();
void initDesktop();
virtual void adjustSize(); virtual void adjustSize();
void adjustSizeGlobal(); void adjustSizeGlobal();
void hideArea (const FSize&); void hideArea (const FSize&);
@ -447,6 +449,7 @@ class FWidget : public FVTerm, public FObject
}; };
// Methods // Methods
void determineDesktopSize();
void initRootWidget(); void initRootWidget();
void finish(); void finish();
void insufficientSpaceAdjust(); void insufficientSpaceAdjust();
@ -507,8 +510,8 @@ class FWidget : public FVTerm, public FObject
static FWidgetList* always_on_top_list; static FWidgetList* always_on_top_list;
static FWidgetList* close_widget; static FWidgetList* close_widget;
static uInt modal_dialog_counter; static uInt modal_dialog_counter;
static bool init_terminal;
static bool init_desktop; static bool init_desktop;
static bool hideable;
// Friend classes // Friend classes
friend class FToggleButton; friend class FToggleButton;
@ -876,14 +879,7 @@ inline bool FWidget::setDisable()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FWidget::setVisibleCursor (bool enable) inline bool FWidget::setVisibleCursor (bool enable)
{ { return (flags.visible_cursor = enable); }
if ( enable )
flags.visible_cursor = true;
else
flags.visible_cursor = ( hideable ) ? false : true;
return flags.visible_cursor;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FWidget::setVisibleCursor() inline bool FWidget::setVisibleCursor()

View File

@ -80,6 +80,16 @@ class ConEmu
, PROT_READ | PROT_WRITE , PROT_READ | PROT_WRITE
, MAP_SHARED | MAP_ANONYMOUS, -1 , MAP_SHARED | MAP_ANONYMOUS, -1
, 0 ); , 0 );
if ( ptr == MAP_FAILED )
{
std::cerr << "mmap error: "
<< strerror(errno)
<< " (" << errno << ")"
<< std::endl;
return;
}
shared_state = static_cast<bool*>(ptr); shared_state = static_cast<bool*>(ptr);
*shared_state = false; *shared_state = false;
} }

View File

@ -61,8 +61,7 @@ void check_c_string ( const char* s1
class FOptiMoveTest : public CPPUNIT_NS::TestFixture class FOptiMoveTest : public CPPUNIT_NS::TestFixture
{ {
public: public:
FOptiMoveTest() FOptiMoveTest();
{ }
protected: protected:
void classNameTest(); void classNameTest();
@ -104,6 +103,11 @@ class FOptiMoveTest : public CPPUNIT_NS::TestFixture
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
}; };
//----------------------------------------------------------------------
FOptiMoveTest::FOptiMoveTest()
{
finalcut::FTermcap::init();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMoveTest::classNameTest() void FOptiMoveTest::classNameTest()

View File

@ -108,6 +108,7 @@ void FTermDataTest::defaultDataTest()
CPPUNIT_ASSERT ( data.hasCursorOptimisation() == true ); CPPUNIT_ASSERT ( data.hasCursorOptimisation() == true );
CPPUNIT_ASSERT ( data.isCursorHidden() == false ); CPPUNIT_ASSERT ( data.isCursorHidden() == false );
CPPUNIT_ASSERT ( data.hasAlternateScreen() == true ); CPPUNIT_ASSERT ( data.hasAlternateScreen() == true );
CPPUNIT_ASSERT ( data.isInAlternateScreen() == false );
CPPUNIT_ASSERT ( data.hasASCIIConsole() == false ); CPPUNIT_ASSERT ( data.hasASCIIConsole() == false );
CPPUNIT_ASSERT ( data.hasVT100Console() == false ); CPPUNIT_ASSERT ( data.hasVT100Console() == false );
CPPUNIT_ASSERT ( data.hasUTF8Console() == false ); CPPUNIT_ASSERT ( data.hasUTF8Console() == false );
@ -223,6 +224,11 @@ void FTermDataTest::dataTest()
data.useAlternateScreen (false); data.useAlternateScreen (false);
CPPUNIT_ASSERT ( data.hasAlternateScreen() == false ); CPPUNIT_ASSERT ( data.hasAlternateScreen() == false );
CPPUNIT_ASSERT ( data.isInAlternateScreen() == false );
data.setAlternateScreenInUse (true);
CPPUNIT_ASSERT ( data.isInAlternateScreen() == true );
CPPUNIT_ASSERT ( data.hasASCIIConsole() == false ); CPPUNIT_ASSERT ( data.hasASCIIConsole() == false );
data.setASCIIConsole (true); data.setASCIIConsole (true);
CPPUNIT_ASSERT ( data.hasASCIIConsole() == true ); CPPUNIT_ASSERT ( data.hasASCIIConsole() == true );