Moving the creator methods from FTerm to its own class

This commit is contained in:
Markus Gans 2021-06-19 23:05:18 +02:00
parent 65c249dfe0
commit 9931f75a51
54 changed files with 537 additions and 558 deletions

View File

@ -1,3 +1,6 @@
2021-06-19 Markus Gans <guru.mail@muenster.de>
* Moving the creator methods from FTerm to its own class
2021-06-16 Markus Gans <guru.mail@muenster.de> 2021-06-16 Markus Gans <guru.mail@muenster.de>
* Converted the internal timer from timeval * Converted the internal timer from timeval
to std::chrono::time_point<system_clock> to std::chrono::time_point<system_clock>

View File

@ -203,7 +203,7 @@ DirectLogger::~DirectLogger() noexcept = default; // destructor
int main (int argc, char* argv[]) int main (int argc, char* argv[])
{ {
// Disable mouse, color palette changes and terminal data requests // Disable mouse, color palette changes and terminal data requests
auto& start_options = finalcut::FStartOptions::getFStartOptions(); auto& start_options = finalcut::FStartOptions::getInstance();
start_options.mouse_support = false; start_options.mouse_support = false;
start_options.color_change = false; start_options.color_change = false;
start_options.terminal_data_request = false; start_options.terminal_data_request = false;
@ -265,7 +265,7 @@ int main (int argc, char* argv[])
std::cout << "\r" << line << std::flush; std::cout << "\r" << line << std::flush;
// Generation of a logger in a shared_ptr via a pointer // Generation of a logger in a shared_ptr via a pointer
finalcut::FApplication::setLog(std::make_shared<DirectLogger>()); finalcut::FApplication::setLog(std::make_shared<DirectLogger>());
const auto& opti_move = finalcut::FTerm::getFOptiMove(); const auto& opti_move = finalcut::FOptiMove::getInstance();
finalcut::printDurations(opti_move); finalcut::printDurations(opti_move);
// Waiting for keypress // Waiting for keypress

View File

@ -308,7 +308,7 @@ int main (int argc, char* argv[])
{ {
benchmark = true; benchmark = true;
// Disable terminal data requests // Disable terminal data requests
auto& start_options = finalcut::FStartOptions::getFStartOptions(); auto& start_options = finalcut::FStartOptions::getInstance();
start_options.terminal_data_request = false; start_options.terminal_data_request = false;
} }

View File

@ -33,7 +33,7 @@ using finalcut::Termcap;
void tcapBoolean (const std::string&, bool); void tcapBoolean (const std::string&, bool);
void tcapNumeric (const std::string&, int); void tcapNumeric (const std::string&, int);
void tcapString (const std::string&, const char[]); void tcapString (const std::string&, const char[]);
void debug (const finalcut::FApplication&); void debug();
void booleans(); void booleans();
void numeric(); void numeric();
void string(); void string();
@ -210,10 +210,9 @@ void tcapString (const std::string& name, const char cap_string[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
#if DEBUG #if DEBUG
void debug (const finalcut::FApplication& TermApp) void debug()
{ {
const auto& fterm = TermApp.getFTerm(); auto& debug_data = finalcut::FTermDebugData::getInstance();
auto& debug_data = fterm.getFTermDebugData();
const auto& ab_s = debug_data.getAnswerbackString(); const auto& ab_s = debug_data.getAnswerbackString();
const auto& sec_da = debug_data.getSecDAString(); const auto& sec_da = debug_data.getSecDAString();
std::cout << "\n.------------------- debug -------------------\r\n"; std::cout << "\n.------------------- debug -------------------\r\n";
@ -310,7 +309,7 @@ int main (int argc, char* argv[])
finalcut::FTerm::useAlternateScreen(false); finalcut::FTerm::useAlternateScreen(false);
// Disable color palette changes and terminal data requests // Disable color palette changes and terminal data requests
auto& start_options = finalcut::FStartOptions::getFStartOptions(); auto& start_options = finalcut::FStartOptions::getInstance();
start_options.color_change = false; start_options.color_change = false;
start_options.terminal_data_request = false; start_options.terminal_data_request = false;
@ -326,7 +325,7 @@ int main (int argc, char* argv[])
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 (term_app); debug();
booleans(); booleans();
numeric(); numeric();

View File

@ -427,7 +427,7 @@ void MyDialog::initMenu()
Drive.setStatusbarMessage ("Show drive symbols"); Drive.setStatusbarMessage ("Show drive symbols");
Line3.setSeparator(); Line3.setSeparator();
if ( finalcut::FStartOptions::getFStartOptions().dark_theme ) if ( finalcut::FStartOptions::getInstance().dark_theme )
Theme.setChecked(); Theme.setChecked();
} }

View File

@ -90,7 +90,7 @@ FApplication::FApplication (const int& arg_c, char* arg_v[])
if ( internal::var::app_object ) if ( internal::var::app_object )
{ {
auto& fterm_data = FTerm::getFTermData(); auto& fterm_data = FTermData::getInstance();
fterm_data.setExitMessage("FApplication: There should be " fterm_data.setExitMessage("FApplication: There should be "
"only one application object"); "only one application object");
FApplication::exit(EXIT_FAILURE); FApplication::exit(EXIT_FAILURE);
@ -339,7 +339,7 @@ void FApplication::setLogFile (const FString& filename)
} }
else else
{ {
auto& fterm_data = FTerm::getFTermData(); auto& fterm_data = FTermData::getInstance();
fterm_data.setExitMessage ( "Could not open log file \"" fterm_data.setExitMessage ( "Could not open log file \""
+ filename + "\"" ); + filename + "\"" );
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -395,7 +395,7 @@ void FApplication::init()
time_last_event = TimeValue{}; time_last_event = TimeValue{};
// Initialize keyboard // Initialize keyboard
auto& keyboard = FTerm::getFKeyboard(); auto& keyboard = FKeyboard::getInstance();
auto cmd1 = [this] () { this->keyPressed(); }; auto cmd1 = [this] () { this->keyPressed(); };
auto cmd2 = [this] () { this->keyReleased(); }; auto cmd2 = [this] () { this->keyReleased(); };
auto cmd3 = [this] () { this->escapeKeyPressed(); }; auto cmd3 = [this] () { this->escapeKeyPressed(); };
@ -412,7 +412,7 @@ void FApplication::init()
keyboard.setKeypressTimeout (key_timeout); keyboard.setKeypressTimeout (key_timeout);
// Initialize mouse control // Initialize mouse control
auto& mouse = FTerm::getFMouseControl(); auto& mouse = FMouseControl::getInstance();
auto cmd = [this] (const FMouseData& md) { this->mouseEvent(md); }; auto cmd = [this] (const FMouseData& md) { this->mouseEvent(md); };
FMouseCommand mouse_cmd (cmd); FMouseCommand mouse_cmd (cmd);
mouse.setEventCommand (mouse_cmd); mouse.setEventCommand (mouse_cmd);
@ -443,7 +443,7 @@ void FApplication::setTerminalEncoding (const FString& enc_str)
showParameterUsage(); showParameterUsage();
else else
{ {
auto& fterm_data = FTerm::getFTermData(); auto& fterm_data = FTermData::getInstance();
fterm_data.setExitMessage ( "Unknown encoding \"" + enc_str fterm_data.setExitMessage ( "Unknown encoding \"" + enc_str
+ "\"\n(Valid encodings are utf8, " + "\"\n(Valid encodings are utf8, "
+ "vt100, pc and ascii)" ); + "vt100, pc and ascii)" );
@ -562,7 +562,7 @@ void FApplication::cmdOptions (const Args& args)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FStartOptions& FApplication::getStartOptions() inline FStartOptions& FApplication::getStartOptions()
{ {
return FStartOptions::getFStartOptions(); return FStartOptions::getInstance();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -657,8 +657,8 @@ inline void FApplication::findKeyboardWidget() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FApplication::isKeyPressed() const inline bool FApplication::isKeyPressed() const
{ {
auto& mouse = FTerm::getFMouseControl(); auto& mouse = FMouseControl::getInstance();
auto& keyboard = FTerm::getFKeyboard(); auto& keyboard = FKeyboard::getInstance();
if ( mouse.isGpmMouseEnabled() ) if ( mouse.isGpmMouseEnabled() )
return mouse.getGpmKeyPressed(keyboard.hasUnprocessedInput()); return mouse.getGpmKeyPressed(keyboard.hasUnprocessedInput());
@ -693,7 +693,7 @@ void FApplication::mouseTracking() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FApplication::performKeyboardAction() inline void FApplication::performKeyboardAction()
{ {
const auto& keyboard = FTerm::getFKeyboard(); const auto& keyboard = FKeyboard::getInstance();
if ( keyboard.getKey() == FKey::Ctrl_l ) // Ctrl-L (redraw the screen) if ( keyboard.getKey() == FKey::Ctrl_l ) // Ctrl-L (redraw the screen)
{ {
@ -712,8 +712,8 @@ inline void FApplication::performKeyboardAction()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FApplication::performMouseAction() const inline void FApplication::performMouseAction() const
{ {
auto& mouse = FTerm::getFMouseControl(); auto& mouse = FMouseControl::getInstance();
auto& keyboard = FTerm::getFKeyboard(); auto& keyboard = FKeyboard::getInstance();
const auto key = keyboard.getKey(); const auto key = keyboard.getKey();
auto& buffer = keyboard.getKeyBuffer(); auto& buffer = keyboard.getKeyBuffer();
@ -760,7 +760,7 @@ inline void FApplication::sendEscapeKeyPressEvent() const
inline bool FApplication::sendKeyDownEvent (FWidget* widget) const inline bool FApplication::sendKeyDownEvent (FWidget* widget) const
{ {
// Send key down event // Send key down event
const auto& keyboard = FTerm::getFKeyboard(); const auto& keyboard = FKeyboard::getInstance();
FKeyEvent k_down_ev (Event::KeyDown, keyboard.getKey()); FKeyEvent k_down_ev (Event::KeyDown, keyboard.getKey());
sendEvent (widget, &k_down_ev); sendEvent (widget, &k_down_ev);
return k_down_ev.isAccepted(); return k_down_ev.isAccepted();
@ -770,7 +770,7 @@ inline bool FApplication::sendKeyDownEvent (FWidget* widget) const
inline bool FApplication::sendKeyPressEvent (FWidget* widget) const inline bool FApplication::sendKeyPressEvent (FWidget* widget) const
{ {
// Send key press event // Send key press event
const auto& keyboard = FTerm::getFKeyboard(); const auto& keyboard = FKeyboard::getInstance();
FKeyEvent k_press_ev (Event::KeyPress, keyboard.getKey()); FKeyEvent k_press_ev (Event::KeyPress, keyboard.getKey());
sendEvent (widget, &k_press_ev); sendEvent (widget, &k_press_ev);
return k_press_ev.isAccepted(); return k_press_ev.isAccepted();
@ -780,7 +780,7 @@ inline bool FApplication::sendKeyPressEvent (FWidget* widget) const
inline bool FApplication::sendKeyUpEvent (FWidget* widget) const inline bool FApplication::sendKeyUpEvent (FWidget* widget) const
{ {
// Send key up event // Send key up event
const auto& keyboard = FTerm::getFKeyboard(); const auto& keyboard = FKeyboard::getInstance();
FKeyEvent k_up_ev (Event::KeyUp, keyboard.getKey()); FKeyEvent k_up_ev (Event::KeyUp, keyboard.getKey());
sendEvent (widget, &k_up_ev); sendEvent (widget, &k_up_ev);
return k_up_ev.isAccepted(); return k_up_ev.isAccepted();
@ -817,8 +817,8 @@ inline void FApplication::sendKeyboardAccelerator()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FApplication::hasDataInQueue() const inline bool FApplication::hasDataInQueue() const
{ {
const auto& keyboard = FTerm::getFKeyboard(); const auto& keyboard = FKeyboard::getInstance();
const auto& mouse = FTerm::getFMouseControl(); const auto& mouse = FMouseControl::getInstance();
if ( keyboard.hasDataInQueue() if ( keyboard.hasDataInQueue()
|| mouse.hasDataInQueue() || mouse.hasDataInQueue()
@ -837,7 +837,7 @@ void FApplication::queuingKeyboardInput() const
return; return;
findKeyboardWidget(); findKeyboardWidget();
auto& keyboard = FTerm::getFKeyboard(); auto& keyboard = FKeyboard::getInstance();
keyboard.escapeKeyHandling(); // special case: Esc key keyboard.escapeKeyHandling(); // special case: Esc key
keyboard.clearKeyBufferOnTimeout(); keyboard.clearKeyBufferOnTimeout();
@ -848,7 +848,7 @@ void FApplication::queuingKeyboardInput() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::queuingMouseInput() const void FApplication::queuingMouseInput() const
{ {
auto& mouse = FTerm::getFMouseControl(); auto& mouse = FMouseControl::getInstance();
if ( quit_now if ( quit_now
|| internal::var::exit_loop || internal::var::exit_loop
@ -856,7 +856,7 @@ void FApplication::queuingMouseInput() const
|| FTerm::hasChangedTermSize() ) || FTerm::hasChangedTermSize() )
return; return;
auto& keyboard = FTerm::getFKeyboard(); auto& keyboard = FKeyboard::getInstance();
auto time_keypressed = keyboard.getKeyPressedTime(); auto time_keypressed = keyboard.getKeyPressedTime();
mouse.processEvent (time_keypressed); mouse.processEvent (time_keypressed);
keyboard.hasUnprocessedInput() = mouse.hasUnprocessedInput(); keyboard.hasUnprocessedInput() = mouse.hasUnprocessedInput();
@ -871,7 +871,7 @@ void FApplication::processKeyboardEvent() const
|| FTerm::hasChangedTermSize() ) || FTerm::hasChangedTermSize() )
return; return;
auto& keyboard = FTerm::getFKeyboard(); auto& keyboard = FKeyboard::getInstance();
keyboard.processQueuedInput(); keyboard.processQueuedInput();
} }
@ -883,13 +883,13 @@ void FApplication::processMouseEvent() const
|| FTerm::hasChangedTermSize() ) || FTerm::hasChangedTermSize() )
return; return;
FTerm::getFMouseControl().processQueuedInput(); FMouseControl::getInstance().processQueuedInput();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FApplication::processDialogSwitchAccelerator() const bool FApplication::processDialogSwitchAccelerator() const
{ {
const auto& keyboard = FTerm::getFKeyboard(); const auto& keyboard = FKeyboard::getInstance();
if ( keyboard.getKey() >= FKey::Meta_1 if ( keyboard.getKey() >= FKey::Meta_1
&& keyboard.getKey() <= FKey::Meta_9 ) && keyboard.getKey() <= FKey::Meta_9 )
@ -927,7 +927,7 @@ bool FApplication::processAccelerator (const FWidget& widget) const
for (auto&& item : widget.getAcceleratorList()) for (auto&& item : widget.getAcceleratorList())
{ {
if ( item.key == FTerm::getFKeyboard().getKey() ) if ( item.key == FKeyboard::getInstance().getKey() )
{ {
// unset the move/size mode // unset the move/size mode
auto move_size = getMoveSizeWidget(); auto move_size = getMoveSizeWidget();
@ -1257,7 +1257,7 @@ void FApplication::processResizeEvent() const
return; return;
FTerm::detectTermSize(); // Detect and save the current terminal size FTerm::detectTermSize(); // Detect and save the current terminal size
auto& mouse = FTerm::getFMouseControl(); auto& mouse = FMouseControl::getInstance();
mouse.setMaxWidth (uInt16(getDesktopWidth())); mouse.setMaxWidth (uInt16(getDesktopWidth()));
mouse.setMaxHeight (uInt16(getDesktopHeight())); mouse.setMaxHeight (uInt16(getDesktopHeight()));
FResizeEvent r_ev(Event::Resize); FResizeEvent r_ev(Event::Resize);

View File

@ -319,6 +319,12 @@ void FButton::onMouseMove (FMouseEvent* ev)
} }
} }
//----------------------------------------------------------------------
void FButton::onWheel (FWheelEvent*)
{
setUp();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButton::onTimer (FTimerEvent* ev) void FButton::onTimer (FTimerEvent* ev)
{ {

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the FINAL CUT widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2020 Markus Gans * * Copyright 2020-2021 Markus Gans *
* * * *
* FINAL CUT is free software; you can redistribute it and/or modify * * FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -39,6 +39,15 @@ FColorPalette::FColorPalette (const FSetPalette& f)
FColorPalette::~FColorPalette() noexcept = default; // destructor FColorPalette::~FColorPalette() noexcept = default; // destructor
// public methods of FColorPalette
//----------------------------------------------------------------------
auto FColorPalette::getInstance() -> std::shared_ptr<FColorPalette>&
{
static const auto& color_theme = make_unique<std::shared_ptr<FColorPalette>>();
return *color_theme.get();
}
// protected methods of FColorPalette // protected methods of FColorPalette
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FColorPalette::setPalette (FColor index, int r, int g, int b) const void FColorPalette::setPalette (FColor index, int r, int g, int b) const

View File

@ -611,7 +611,7 @@ void FComboBox::cb_closeComboBox()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FComboBox::cb_inputFieldSwitch() void FComboBox::cb_inputFieldSwitch()
{ {
auto& mouse = FTerm::getFMouseControl(); auto& mouse = FMouseControl::getInstance();
if ( ! mouse.isLeftButtonPressed() ) if ( ! mouse.isLeftButtonPressed() )
return; return;
@ -630,7 +630,7 @@ void FComboBox::cb_inputFieldSwitch()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FComboBox::cb_inputFieldHandOver() void FComboBox::cb_inputFieldHandOver()
{ {
auto& mouse = FTerm::getFMouseControl(); auto& mouse = FMouseControl::getInstance();
if ( list_window.isHidden() ) if ( list_window.isHidden() )
return; return;

View File

@ -100,7 +100,7 @@ bool FDialog::setModal (bool enable)
if ( enable ) if ( enable )
{ {
setModalDialogCounter()++; setModalDialogCounter()++;
FTerm::getFKeyboard().clearKeyBuffer(); FKeyboard::getInstance().clearKeyBuffer();
} }
else else
setModalDialogCounter()--; setModalDialogCounter()--;

View File

@ -162,7 +162,7 @@ void FFileDialog::setPath (const FString& dir)
return; return;
} }
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
if ( fsystem->realpath(dir.c_str(), resolved_path.data()) != nullptr ) if ( fsystem->realpath(dir.c_str(), resolved_path.data()) != nullptr )
r_dir.setString(resolved_path.data()); r_dir.setString(resolved_path.data());
@ -478,15 +478,13 @@ int FFileDialog::readDir()
getEntry(dir, next); getEntry(dir, next);
} }
else if ( errno != 0 )
{
FMessageBox::error (this, "Reading directory\n" + directory);
if ( errno == EOVERFLOW ) // Value too large to be stored in data type
break;
}
else else
{
if ( errno != 0 )
FMessageBox::error (this, "Reading directory\n" + directory);
break; break;
}
} // end while } // end while
if ( closedir(directory_stream) != 0 ) if ( closedir(directory_stream) != 0 )
@ -551,7 +549,7 @@ void FFileDialog::followSymLink (const char* const dir, FDirEntry& entry) const
std::string symLink{}; std::string symLink{};
symLink.reserve(MAXPATHLEN); symLink.reserve(MAXPATHLEN);
struct stat sb{}; struct stat sb{};
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
symLink = dir + entry.name; symLink = dir + entry.name;
if ( fsystem->realpath(symLink.data(), resolved_path.data()) == nullptr ) if ( fsystem->realpath(symLink.data(), resolved_path.data()) == nullptr )
@ -684,7 +682,7 @@ FString FFileDialog::getHomeDir()
struct passwd* pwd_ptr{}; struct passwd* pwd_ptr{};
std::array<char, 1024> buf{}; std::array<char, 1024> buf{};
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
const uid_t euid = fsystem->geteuid(); const uid_t euid = fsystem->geteuid();
if ( fsystem->getpwuid_r(euid, &pwd, buf.data(), buf.size(), &pwd_ptr) ) if ( fsystem->getpwuid_r(euid, &pwd, buf.data(), buf.size(), &pwd_ptr) )

View File

@ -74,6 +74,13 @@ FKeyboard::FKeyboard()
// public methods of FKeyboard // public methods of FKeyboard
//----------------------------------------------------------------------
auto FKeyboard::getInstance() -> FKeyboard&
{
static const auto& keyboard = make_unique<FKeyboard>();
return *keyboard;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FKeyboard::fetchKeyCode() void FKeyboard::fetchKeyCode()
{ {
@ -536,7 +543,7 @@ FKey FKeyboard::keyCorrection (const FKey& keycode) const
#if defined(__linux__) #if defined(__linux__)
if ( FTerm::isLinuxTerm() ) if ( FTerm::isLinuxTerm() )
{ {
auto& linux_console = FTerm::getFTermLinux(); auto& linux_console = FTermLinux::getInstance();
key_correction = linux_console.modifierKeyCorrection(keycode); key_correction = linux_console.modifierKeyCorrection(keycode);
} }
else else

View File

@ -258,7 +258,7 @@ uInt64 FMouse::getDblclickInterval() const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
TimeValue FMouse::getMousePressedTime() TimeValue FMouse::getMousePressedTime() const
{ {
return time_mousepressed; return time_mousepressed;
} }
@ -1204,14 +1204,16 @@ void FMouseUrxvt::setButtonState (const int btn, const TimeValue& time)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FMouseControl::FMouseControl() FMouseControl::FMouseControl()
{ {
using mt = FMouse::MouseType;
#ifdef F_HAVE_LIBGPM #ifdef F_HAVE_LIBGPM
if ( FTermLinux::isLinuxConsole() ) if ( FTermLinux::isLinuxConsole() )
mouse_protocol[FMouse::MouseType::Gpm].reset(FMouse::createMouseObject<FMouseGPM>()); mouse_protocol[mt::Gpm].reset(FMouse::createMouseObject<FMouseGPM>());
#endif #endif
mouse_protocol[FMouse::MouseType::X11].reset(FMouse::createMouseObject<FMouseX11>()); mouse_protocol[mt::X11].reset(FMouse::createMouseObject<FMouseX11>());
mouse_protocol[FMouse::MouseType::Sgr].reset(FMouse::createMouseObject<FMouseSGR>()); mouse_protocol[mt::Sgr].reset(FMouse::createMouseObject<FMouseSGR>());
mouse_protocol[FMouse::MouseType::Urxvt].reset(FMouse::createMouseObject<FMouseUrxvt>()); mouse_protocol[mt::Urxvt].reset(FMouse::createMouseObject<FMouseUrxvt>());
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1219,6 +1221,13 @@ FMouseControl::~FMouseControl() = default; // destructor
// public methods of FMouseControl // public methods of FMouseControl
//----------------------------------------------------------------------
auto FMouseControl::getInstance() -> FMouseControl&
{
static const auto& mouse = make_unique<FMouseControl>();
return *mouse;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FPoint& FMouseControl::getPos() const FPoint& FMouseControl::getPos()
{ {

View File

@ -344,18 +344,17 @@ void FObject::onUserEvent (FUserEvent*)
uInt FObject::processTimerEvent() uInt FObject::processTimerEvent()
{ {
uInt activated{0}; uInt activated{0};
auto currentTime = getCurrentTime(); std::unique_lock<std::mutex> unique_lock( internal::var::timer_mutex
, std::defer_lock );
if ( ! internal::var::timer_mutex.try_lock() ) if ( ! unique_lock.try_lock() )
return 0; return 0;
auto currentTime = getCurrentTime();
auto& timer_list = globalTimerList(); auto& timer_list = globalTimerList();
if ( ! timer_list || timer_list->empty() ) if ( ! timer_list || timer_list->empty() )
{
internal::var::timer_mutex.unlock();
return 0; return 0;
}
for (auto&& timer : *timer_list) for (auto&& timer : *timer_list)
{ {
@ -376,7 +375,6 @@ uInt FObject::processTimerEvent()
performTimerAction (timer.object, &t_ev); performTimerAction (timer.object, &t_ev);
} }
internal::var::timer_mutex.unlock();
return activated; return activated;
} }

View File

@ -51,6 +51,13 @@ FOptiAttr::FOptiAttr()
// public methods of FOptiAttr // public methods of FOptiAttr
//----------------------------------------------------------------------
auto FOptiAttr::getInstance() -> FOptiAttr&
{
static const auto& opti_attr = make_unique<FOptiAttr>();
return *opti_attr;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiAttr::setTermEnvironment (const TermEnv& term_env) void FOptiAttr::setTermEnvironment (const TermEnv& term_env)
{ {
@ -577,7 +584,7 @@ std::string FOptiAttr::changeAttribute (FChar& term, FChar& next)
changeAttributeSeparately (term, next); changeAttributeSeparately (term, next);
} }
if ( FStartOptions::getFStartOptions().sgr_optimizer ) if ( FStartOptions::getInstance().sgr_optimizer )
sgr_optimizer.optimize(); sgr_optimizer.optimize();
return attr_buf; return attr_buf;

View File

@ -55,6 +55,13 @@ FOptiMove::FOptiMove (int baud)
// public methods of FOptiMove // public methods of FOptiMove
//----------------------------------------------------------------------
auto FOptiMove::getInstance() -> FOptiMove&
{
static const auto& opti_move = make_unique<FOptiMove>();
return *opti_move;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiMove::setBaudRate (int baud) void FOptiMove::setBaudRate (int baud)
{ {

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the FINAL CUT widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2019-2020 Markus Gans * * Copyright 2019-2021 Markus Gans *
* * * *
* FINAL CUT is free software; you can redistribute it and/or modify * * FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -54,7 +54,7 @@ FStartOptions::FStartOptions()
// public methods of FStartOptions // public methods of FStartOptions
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FStartOptions& FStartOptions::getFStartOptions() auto FStartOptions::getInstance() -> FStartOptions&
{ {
static const auto& start_options = make_unique<FStartOptions>(); static const auto& start_options = make_unique<FStartOptions>();
return *start_options; return *start_options;

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the FINAL CUT widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2019-2020 Markus Gans * * Copyright 2019-2021 Markus Gans *
* * * *
* FINAL CUT is free software; you can redistribute it and/or modify * * FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -21,6 +21,7 @@
***********************************************************************/ ***********************************************************************/
#include "final/fsystem.h" #include "final/fsystem.h"
#include "final/fsystemimpl.h"
namespace finalcut namespace finalcut
{ {
@ -33,5 +34,14 @@ namespace finalcut
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FSystem::~FSystem() noexcept = default; // destructor FSystem::~FSystem() noexcept = default; // destructor
// public methods of FSystem
//----------------------------------------------------------------------
auto FSystem::getInstance() -> std::unique_ptr<FSystem>&
{
static const auto& fsys = make_unique<std::unique_ptr<FSystem>>(make_unique<FSystemImpl>());
return *fsys.get();
}
} // namespace finalcut } // namespace finalcut

File diff suppressed because it is too large Load Diff

View File

@ -251,8 +251,8 @@ void FTermcap::termcap()
static char term_buffer[BUF_SIZE]{}; static char term_buffer[BUF_SIZE]{};
std::vector<std::string> terminals{}; std::vector<std::string> terminals{};
int status = uninitialized; int status = uninitialized;
auto& fterm_data = FTerm::getFTermData(); auto& fterm_data = FTermData::getInstance();
const auto& term_detection = FTerm::getFTermDetection(); const auto& term_detection = FTermDetection::getInstance();
const bool color256 = term_detection.canDisplay256Colors(); const bool color256 = term_detection.canDisplay256Colors();
baudrate = int(fterm_data.getBaudrate()); baudrate = int(fterm_data.getBaudrate());
@ -301,7 +301,7 @@ void FTermcap::termcapError (int status)
if ( status == no_entry || status == uninitialized ) if ( status == no_entry || status == uninitialized )
{ {
const auto& termtype = FTerm::getFTermData().getTermType(); const auto& termtype = FTermData::getInstance().getTermType();
std::clog << FLog::LogLevel::Error std::clog << FLog::LogLevel::Error
<< "Unknown terminal: \"" << termtype << "\". " << "Unknown terminal: \"" << termtype << "\". "
<< "Check the TERM environment variable. " << "Check the TERM environment variable. "
@ -376,7 +376,7 @@ void FTermcap::termcapNumerics()
{ {
// Get termcap numerics // Get termcap numerics
auto& fterm_data = FTerm::getFTermData(); auto& fterm_data = FTermData::getInstance();
// Maximum number of colors on screen // Maximum number of colors on screen
max_color = std::max(max_color, getNumber("Co")); max_color = std::max(max_color, getNumber("Co"));

View File

@ -42,7 +42,7 @@ namespace finalcut
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermcapQuirks::terminalFixup() void FTermcapQuirks::terminalFixup()
{ {
const auto& td = FTerm::getFTermDetection(); const auto& td = FTermDetection::getInstance();
if ( td.isCygwinTerminal() ) if ( td.isCygwinTerminal() )
{ {
@ -228,7 +228,7 @@ void FTermcapQuirks::xterm()
void FTermcapQuirks::rxvt() void FTermcapQuirks::rxvt()
{ {
// Set enter/exit alternative charset mode for rxvt terminal // Set enter/exit alternative charset mode for rxvt terminal
const auto& termtype = FTerm::getFTermData().getTermType(); const auto& termtype = FTermData::getInstance().getTermType();
if ( termtype.substr(0,12) == "rxvt-16color" ) if ( termtype.substr(0,12) == "rxvt-16color" )
{ {
@ -237,7 +237,7 @@ void FTermcapQuirks::rxvt()
} }
// Set ansi foreground and background color // Set ansi foreground and background color
if ( ! FTerm::getFTermDetection().isUrxvtTerminal() ) if ( ! FTermDetection::getInstance().isUrxvtTerminal() )
{ {
TCAP(t_set_a_foreground) = \ TCAP(t_set_a_foreground) = \
CSI "%?%p1%{8}%<%t%p1%{30}%+%e%p1%'R'%+%;%dm"; CSI "%?%p1%{8}%<%t%p1%{30}%+%e%p1%'R'%+%;%dm";
@ -249,7 +249,7 @@ void FTermcapQuirks::rxvt()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermcapQuirks::vte() void FTermcapQuirks::vte()
{ {
const auto& term_detection = FTerm::getFTermDetection(); const auto& term_detection = FTermDetection::getInstance();
// gnome-terminal has NC=16 however, it can use the dim attribute // gnome-terminal has NC=16 however, it can use the dim attribute
FTermcap::attr_without_color = 0; FTermcap::attr_without_color = 0;
@ -448,7 +448,7 @@ void FTermcapQuirks::screen()
{ {
FTermcap::can_change_color_palette = true; FTermcap::can_change_color_palette = true;
if ( FTerm::getFTermDetection().isTmuxTerm() ) if ( FTermDetection::getInstance().isTmuxTerm() )
{ {
TCAP(t_initialize_color) = \ TCAP(t_initialize_color) = \
ESC "Ptmux;" ESC OSC "4;%p1%d;rgb:" ESC "Ptmux;" ESC OSC "4;%p1%d;rgb:"

View File

@ -36,38 +36,45 @@ namespace finalcut
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// public methods of FTermDebugData // public methods of FTermDebugData
//----------------------------------------------------------------------
auto FTermDebugData::getInstance() -> FTermDebugData&
{
static const auto& debug_data = make_unique<FTermDebugData>();
return *debug_data;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FString& FTermDebugData::getAnswerbackString() const FString& FTermDebugData::getAnswerbackString()
{ {
auto& term_detection = FTerm::getFTermDetection(); auto& term_detection = FTermDetection::getInstance();
return term_detection.getAnswerbackString(); return term_detection.getAnswerbackString();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FString& FTermDebugData::getSecDAString() const FString& FTermDebugData::getSecDAString()
{ {
auto& term_detection = FTerm::getFTermDetection(); auto& term_detection = FTermDetection::getInstance();
return term_detection.getSecDAString(); return term_detection.getSecDAString();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FString& FTermDebugData::getTermType_256color() const FString& FTermDebugData::getTermType_256color()
{ {
auto& term_detection = FTerm::getFTermDetection(); auto& term_detection = FTermDetection::getInstance();
return term_detection.getTermType_256color(); return term_detection.getTermType_256color();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FString& FTermDebugData::getTermType_Answerback() const FString& FTermDebugData::getTermType_Answerback()
{ {
auto& term_detection = FTerm::getFTermDetection(); auto& term_detection = FTermDetection::getInstance();
return term_detection.getTermType_Answerback(); return term_detection.getTermType_Answerback();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FString& FTermDebugData::getTermType_SecDA() const FString& FTermDebugData::getTermType_SecDA()
{ {
auto& term_detection = FTerm::getFTermDetection(); auto& term_detection = FTermDetection::getInstance();
return term_detection.getTermType_SecDA(); return term_detection.getTermType_SecDA();
} }
@ -75,7 +82,7 @@ const FString& FTermDebugData::getTermType_SecDA()
#if defined(__linux__) #if defined(__linux__)
int FTermDebugData::getFramebufferBpp() int FTermDebugData::getFramebufferBpp()
{ {
auto& fterm_data = FTerm::getFTermData(); auto& fterm_data = FTermData::getInstance();
return fterm_data.getFramebufferBpp(); return fterm_data.getFramebufferBpp();
} }
#endif // defined(__linux__) #endif // defined(__linux__)

View File

@ -63,6 +63,13 @@ FTermDetection::~FTermDetection() = default; // destructor
// public methods of FTermDetection // public methods of FTermDetection
//----------------------------------------------------------------------
auto FTermDetection::getInstance() -> FTermDetection&
{
static const auto& term_detection = make_unique<FTermDetection>();
return *term_detection;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
#if DEBUG #if DEBUG
const FString& FTermDetection::getAnswerbackString() const const FString& FTermDetection::getAnswerbackString() const
@ -106,7 +113,7 @@ void FTermDetection::getSystemTermType()
{ {
// Import the untrusted environment variable TERM // Import the untrusted environment variable TERM
const auto& term_env = std::getenv("TERM"); const auto& term_env = std::getenv("TERM");
const auto& termfilename = FTerm::getFTermData().getTermFileName(); const auto& termfilename = FTermData::getInstance().getTermFileName();
if ( term_env ) if ( term_env )
{ {
@ -142,7 +149,7 @@ bool FTermDetection::getTTYtype()
// vt100 ttys0 // vt100 ttys0
// Get term basename // Get term basename
const auto& termfilename = FTerm::getFTermData().getTermFileName(); const auto& termfilename = FTermData::getInstance().getTermFileName();
const char* term_basename = std::strrchr(termfilename.data(), '/'); const char* term_basename = std::strrchr(termfilename.data(), '/');
if ( term_basename == nullptr ) if ( term_basename == nullptr )
@ -152,7 +159,7 @@ bool FTermDetection::getTTYtype()
std::FILE* fp{}; std::FILE* fp{};
std::array<char, BUFSIZ> str{}; std::array<char, BUFSIZ> str{};
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
if ( (fp = fsystem->fopen(ttytypename.c_str(), "r")) == nullptr ) if ( (fp = fsystem->fopen(ttytypename.c_str(), "r")) == nullptr )
return false; return false;
@ -196,7 +203,7 @@ bool FTermDetection::getTTYSFileEntry()
// Analyse /etc/ttys and get the term name // Analyse /etc/ttys and get the term name
// get term basename // get term basename
const auto& termfilename = FTerm::getFTermData().getTermFileName(); const auto& termfilename = FTermData::getInstance().getTermFileName();
const char* term_basename = std::strrchr(termfilename.data(), '/'); const char* term_basename = std::strrchr(termfilename.data(), '/');
if ( term_basename == nullptr ) if ( term_basename == nullptr )
@ -303,7 +310,7 @@ void FTermDetection::detectTerminal()
if ( terminal_detection ) if ( terminal_detection )
{ {
FTermios::setCaptureSendCharacters(); FTermios::setCaptureSendCharacters();
auto& keyboard = FTerm::getFKeyboard(); auto& keyboard = FKeyboard::getInstance();
keyboard.setNonBlockingInput(); keyboard.setNonBlockingInput();
// Initialize 256 colors terminals // Initialize 256 colors terminals
@ -346,7 +353,7 @@ void FTermDetection::detectTerminal()
} }
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
auto& fterm_data = FTerm::getFTermData(); auto& fterm_data = FTermData::getInstance();
const auto& termfilename = fterm_data.getTermFileName(); const auto& termfilename = fterm_data.getTermFileName();
// Fixes problem with mouse input // Fixes problem with mouse input
@ -463,7 +470,7 @@ FString FTermDetection::determineMaxColor (const FString& current_termtype)
// Determine xterm maximum number of colors via OSC 4 // Determine xterm maximum number of colors via OSC 4
FString new_termtype{current_termtype}; FString new_termtype{current_termtype};
auto& keyboard = FTerm::getFKeyboard(); auto& keyboard = FKeyboard::getInstance();
keyboard.setNonBlockingInput(); keyboard.setNonBlockingInput();
if ( ! color256 if ( ! color256
@ -556,7 +563,7 @@ FString FTermDetection::getXTermColorName (FColor color) const
FString FTermDetection::parseAnswerbackMsg (const FString& current_termtype) FString FTermDetection::parseAnswerbackMsg (const FString& current_termtype)
{ {
FString new_termtype{current_termtype}; FString new_termtype{current_termtype};
auto& keyboard = FTerm::getFKeyboard(); auto& keyboard = FKeyboard::getInstance();
keyboard.setNonBlockingInput(); keyboard.setNonBlockingInput();
// send ENQ and read the answerback message // send ENQ and read the answerback message
answer_back = getAnswerbackMsg(); answer_back = getAnswerbackMsg();

View File

@ -46,6 +46,13 @@ bool FTermFreeBSD::meta_sends_escape{true};
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// public methods of FTermFreeBSD // public methods of FTermFreeBSD
//----------------------------------------------------------------------
auto FTermFreeBSD::getInstance() -> FTermFreeBSD&
{
static const auto& freebsd_console = make_unique<FTermFreeBSD>();
return *freebsd_console;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FTermFreeBSD::CursorStyle FTermFreeBSD::getCursorStyle() FTermFreeBSD::CursorStyle FTermFreeBSD::getCursorStyle()
{ {
@ -61,7 +68,7 @@ bool FTermFreeBSD::setCursorStyle (CursorStyle style)
return false; return false;
cursor_style = style; cursor_style = style;
auto& fterm_data = FTerm::getFTermData(); auto& fterm_data = FTermData::getInstance();
if ( fterm_data.isCursorHidden() ) if ( fterm_data.isCursorHidden() )
return false; return false;
@ -75,7 +82,7 @@ bool FTermFreeBSD::isFreeBSDConsole()
// Check if it's a FreeBSD console // Check if it's a FreeBSD console
keymap_t keymap{}; keymap_t keymap{};
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
if ( fsystem->ioctl(0, GIO_KEYMAP, &keymap) == 0 ) if ( fsystem->ioctl(0, GIO_KEYMAP, &keymap) == 0 )
return true; return true;
@ -187,7 +194,7 @@ bool FTermFreeBSD::saveFreeBSDAltKey()
static constexpr int left_alt = 0x38; static constexpr int left_alt = 0x38;
int ret{-1}; int ret{-1};
keymap_t keymap{}; keymap_t keymap{};
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap); ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
if ( ret < 0 ) if ( ret < 0 )
@ -206,7 +213,7 @@ bool FTermFreeBSD::setFreeBSDAltKey (uInt key)
static constexpr int left_alt = 0x38; static constexpr int left_alt = 0x38;
int ret{-1}; int ret{-1};
keymap_t keymap{}; keymap_t keymap{};
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap); ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
if ( ret < 0 ) if ( ret < 0 )
@ -241,7 +248,7 @@ bool FTermFreeBSD::resetFreeBSDAlt2Meta()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTermFreeBSD::setFreeBSDCursorStyle (CursorStyle style) bool FTermFreeBSD::setFreeBSDCursorStyle (CursorStyle style)
{ {
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
if ( fsystem->ioctl(0, CONS_CURSORTYPE, &style) == 0 ) if ( fsystem->ioctl(0, CONS_CURSORTYPE, &style) == 0 )
return true; return true;

View File

@ -61,6 +61,13 @@ FTermLinux::~FTermLinux() // destructor
} }
// public methods of FTermLinux // public methods of FTermLinux
//----------------------------------------------------------------------
auto FTermLinux::getInstance() -> FTermLinux&
{
static const auto& linux_console = make_unique<FTermLinux>();
return *linux_console;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FTermLinux::CursorStyle FTermLinux::getCursorStyle() const FTermLinux::CursorStyle FTermLinux::getCursorStyle() const
{ {
@ -90,7 +97,7 @@ bool FTermLinux::setCursorStyle (CursorStyle style)
linux_console_cursor_style = style; linux_console_cursor_style = style;
if ( FTerm::getFTermData().isCursorHidden() ) if ( FTermData::getInstance().isCursorHidden() )
return false; return false;
setLinuxCursorStyle(style); setLinuxCursorStyle(style);
@ -134,7 +141,7 @@ bool FTermLinux::isLinuxConsole()
char arg{0}; char arg{0};
int fd_tty = FTerm::getTTYFileDescriptor(); int fd_tty = FTerm::getTTYFileDescriptor();
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
if ( fd_tty < 0 ) // Undefined tty file descriptor if ( fd_tty < 0 ) // Undefined tty file descriptor
fd_tty = 0; fd_tty = 0;
@ -150,7 +157,7 @@ void FTermLinux::init()
{ {
// Initialize Linux console // Initialize Linux console
auto& fterm_data = FTerm::getFTermData(); auto& fterm_data = FTermData::getInstance();
screen_unicode_map.entries = nullptr; screen_unicode_map.entries = nullptr;
screen_font.data = nullptr; screen_font.data = nullptr;
fterm_data.supportShadowCharacter (true); fterm_data.supportShadowCharacter (true);
@ -163,7 +170,7 @@ void FTermLinux::init()
if ( FTerm::openConsole() == 0 ) if ( FTerm::openConsole() == 0 )
{ {
FTerm::getFTermDetection().setLinuxTerm (isLinuxConsole()); FTermDetection::getInstance().setLinuxTerm(isLinuxConsole());
if ( FTerm::isLinuxTerm() ) if ( FTerm::isLinuxTerm() )
{ {
@ -282,7 +289,7 @@ bool FTermLinux::loadVGAFont()
if ( vga_font ) if ( vga_font )
{ {
auto& fterm_data = FTerm::getFTermData(); auto& fterm_data = FTermData::getInstance();
fterm_data.supportShadowCharacter (true); fterm_data.supportShadowCharacter (true);
fterm_data.supportHalfBlockCharacter (true); fterm_data.supportHalfBlockCharacter (true);
} }
@ -330,7 +337,7 @@ bool FTermLinux::loadNewFont()
if ( new_font ) if ( new_font )
{ {
auto& fterm_data = FTerm::getFTermData(); auto& fterm_data = FTermData::getInstance();
fterm_data.supportShadowCharacter (true); fterm_data.supportShadowCharacter (true);
fterm_data.supportHalfBlockCharacter (true); fterm_data.supportHalfBlockCharacter (true);
} }
@ -462,7 +469,7 @@ int FTermLinux::getFramebuffer_bpp() const
const char* fb = "/dev/fb/0"; const char* fb = "/dev/fb/0";
struct fb_var_screeninfo fb_var{}; struct fb_var_screeninfo fb_var{};
struct fb_fix_screeninfo fb_fix{}; struct fb_fix_screeninfo fb_fix{};
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
if ( (fd = fsystem->open(fb, O_RDWR)) < 0 ) if ( (fd = fsystem->open(fb, O_RDWR)) < 0 )
{ {
@ -521,7 +528,7 @@ bool FTermLinux::getScreenFont()
} }
// Font operation // Font operation
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
ret = fsystem->ioctl (fd_tty, KDFONTOP, &font); ret = fsystem->ioctl (fd_tty, KDFONTOP, &font);
if ( ret != 0 ) if ( ret != 0 )
@ -552,7 +559,7 @@ bool FTermLinux::getUnicodeMap()
screen_unicode_map.entries = nullptr; screen_unicode_map.entries = nullptr;
// Get count // Get count
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
ret = fsystem->ioctl (fd_tty, GIO_UNIMAP, &screen_unicode_map); ret = fsystem->ioctl (fd_tty, GIO_UNIMAP, &screen_unicode_map);
if ( ret != 0 ) if ( ret != 0 )
@ -592,7 +599,7 @@ FTermLinux::ModifierKey& FTermLinux::getModifierKey()
// Fill bit field with 0 // Fill bit field with 0
std::memset (&mod_key, 0x00, sizeof(mod_key)); std::memset (&mod_key, 0x00, sizeof(mod_key));
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
// TIOCLINUX, subcode = 6 (TIOCL_GETSHIFTSTATE) // TIOCLINUX, subcode = 6 (TIOCL_GETSHIFTSTATE)
if ( fsystem->ioctl(0, TIOCLINUX, &subcode) >= 0 ) if ( fsystem->ioctl(0, TIOCLINUX, &subcode) >= 0 )
@ -658,7 +665,7 @@ int FTermLinux::setScreenFont ( const uChar fontdata[], uInt count
} }
// Font operation // Font operation
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
ret = fsystem->ioctl (fd_tty, KDFONTOP, &font); ret = fsystem->ioctl (fd_tty, KDFONTOP, &font);
if ( ret != 0 && errno != ENOSYS && errno != EINVAL ) if ( ret != 0 && errno != ENOSYS && errno != EINVAL )
@ -695,7 +702,7 @@ int FTermLinux::setUnicodeMap (struct unimapdesc* unimap) const
do do
{ {
// Clear the unicode-to-font table // Clear the unicode-to-font table
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
ret = fsystem->ioctl (fd_tty, PIO_UNIMAPCLR, &advice); ret = fsystem->ioctl (fd_tty, PIO_UNIMAPCLR, &advice);
if ( ret != 0 ) if ( ret != 0 )
@ -727,7 +734,7 @@ inline uInt16 FTermLinux::getInputStatusRegisterOne() const
{ {
// Gets the VGA input-status-register-1 // Gets the VGA input-status-register-1
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
// Miscellaneous output (read port) // Miscellaneous output (read port)
static constexpr uInt16 misc_read = 0x3cc; static constexpr uInt16 misc_read = 0x3cc;
@ -743,7 +750,7 @@ uChar FTermLinux::readAttributeController (uChar index) const
{ {
// Reads a byte from the attribute controller from a given index // Reads a byte from the attribute controller from a given index
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
// Attribute controller (write port) // Attribute controller (write port)
static constexpr uInt16 attrib_cntlr_write = 0x3c0; static constexpr uInt16 attrib_cntlr_write = 0x3c0;
@ -769,7 +776,7 @@ void FTermLinux::writeAttributeController (uChar index, uChar data) const
{ {
// Writes a byte from the attribute controller from a given index // Writes a byte from the attribute controller from a given index
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
// Attribute controller (write port) // Attribute controller (write port)
static constexpr uInt16 attrib_cntlr_write = 0x3c0; static constexpr uInt16 attrib_cntlr_write = 0x3c0;
@ -808,7 +815,7 @@ int FTermLinux::setBlinkAsIntensity (bool enable) const
// Uses blink-bit as background intensity. // Uses blink-bit as background intensity.
// That permits 16 colors for background // That permits 16 colors for background
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
const int fd_tty = FTerm::getTTYFileDescriptor(); const int fd_tty = FTerm::getTTYFileDescriptor();
@ -847,7 +854,7 @@ bool FTermLinux::has9BitCharacters() const
// 0xc0...0xdf - copying the eighth pixel into the ninth pixel // 0xc0...0xdf - copying the eighth pixel into the ninth pixel
// The rest - the ninth pixel has the background color // The rest - the ninth pixel has the background color
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
const int fd_tty = FTerm::getTTYFileDescriptor(); const int fd_tty = FTerm::getTTYFileDescriptor();
if ( fsystem->getuid() != 0 ) // Direct hardware access requires root privileges if ( fsystem->getuid() != 0 ) // Direct hardware access requires root privileges
@ -872,7 +879,7 @@ bool FTermLinux::has9BitCharacters() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermLinux::getVGAPalette() void FTermLinux::getVGAPalette()
{ {
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
if ( fsystem->ioctl(0, GIO_CMAP, cmap.color.data()) != 0 ) if ( fsystem->ioctl(0, GIO_CMAP, cmap.color.data()) != 0 )
setVGADefaultPalette(); // Fallback, if GIO_CMAP does not work setVGADefaultPalette(); // Fallback, if GIO_CMAP does not work
@ -917,7 +924,7 @@ bool FTermLinux::setVGAPalette (FColor index, int r, int g, int b)
cmap.color[uInt16(index)].blue = uChar(b); cmap.color[uInt16(index)].blue = uChar(b);
} }
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
if ( fsystem->ioctl(0, PIO_CMAP, cmap.color.data()) == 0 ) if ( fsystem->ioctl(0, PIO_CMAP, cmap.color.data()) == 0 )
return true; return true;
@ -930,7 +937,7 @@ bool FTermLinux::saveVGAPalette()
{ {
// Save the current vga color map // Save the current vga color map
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
if ( fsystem->ioctl(0, GIO_CMAP, saved_color_map.color.data()) == 0 ) if ( fsystem->ioctl(0, GIO_CMAP, saved_color_map.color.data()) == 0 )
has_saved_palette = true; has_saved_palette = true;
@ -945,7 +952,7 @@ bool FTermLinux::resetVGAPalette()
{ {
// Reset the vga color map // Reset the vga color map
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
if ( has_saved_palette ) if ( has_saved_palette )
{ {
@ -1128,7 +1135,7 @@ inline void FTermLinux::shiftCtrlAltKeyCorrection()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FTermLinux::initSpecialCharacter() const inline void FTermLinux::initSpecialCharacter() const
{ {
auto& fterm_data = FTerm::getFTermData(); auto& fterm_data = FTermData::getInstance();
const auto c1 = wchar_t(UniChar::UpperHalfBlock); // ▀ const auto c1 = wchar_t(UniChar::UpperHalfBlock); // ▀
const auto c2 = wchar_t(UniChar::LowerHalfBlock); // ▄ const auto c2 = wchar_t(UniChar::LowerHalfBlock); // ▄
const auto c3 = wchar_t(UniChar::FullBlock); // █ const auto c3 = wchar_t(UniChar::FullBlock); // █
@ -1169,7 +1176,7 @@ void FTermLinux::characterFallback ( wchar_t ucs
, const std::vector<wchar_t>& fallback ) const , const std::vector<wchar_t>& fallback ) const
{ {
constexpr sInt16 NOT_FOUND = -1; constexpr sInt16 NOT_FOUND = -1;
auto& fterm_data = FTerm::getFTermData(); auto& fterm_data = FTermData::getInstance();
charSubstitution& sub_map = fterm_data.getCharSubstitutionMap(); charSubstitution& sub_map = fterm_data.getCharSubstitutionMap();
if ( fallback.size() < 2 || ucs != fallback[0] ) if ( fallback.size() < 2 || ucs != fallback[0] )

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the FINAL CUT widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2018-2020 Markus Gans * * Copyright 2018-2021 Markus Gans *
* * * *
* FINAL CUT is free software; you can redistribute it and/or modify * * FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -41,13 +41,20 @@ bool FTermOpenBSD::meta_sends_escape{true};
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// public methods of FTermOpenBSD // public methods of FTermOpenBSD
//----------------------------------------------------------------------
auto FTermOpenBSD::getInstance() -> FTermOpenBSD&
{
static const auto& openbsd_console = make_unique<FTermOpenBSD>();
return *openbsd_console;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTermOpenBSD::isBSDConsole() bool FTermOpenBSD::isBSDConsole()
{ {
// Check if it's a NetBSD/OpenBSD workstation console // Check if it's a NetBSD/OpenBSD workstation console
static kbd_t kbdencoding{}; static kbd_t kbdencoding{};
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
if ( fsystem->ioctl(0, WSKBDIO_GETENCODING, &kbdencoding) == 0 ) if ( fsystem->ioctl(0, WSKBDIO_GETENCODING, &kbdencoding) == 0 )
return true; return true;
@ -102,7 +109,7 @@ bool FTermOpenBSD::setBeep (int Hz, int ms)
bell.pitch = uInt(Hz); bell.pitch = uInt(Hz);
bell.period = uInt(ms); bell.period = uInt(ms);
bell.volume = 50; // 50% volume bell.volume = 50; // 50% volume
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
if ( fsystem->ioctl(0, WSKBDIO_SETBELL, &bell) < 0 ) if ( fsystem->ioctl(0, WSKBDIO_SETBELL, &bell) < 0 )
return false; return false;
@ -114,7 +121,7 @@ bool FTermOpenBSD::setBeep (int Hz, int ms)
bool FTermOpenBSD::resetBeep() bool FTermOpenBSD::resetBeep()
{ {
wskbd_bell_data default_bell; wskbd_bell_data default_bell;
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
// Gets the default setting for the bell // Gets the default setting for the bell
if ( fsystem->ioctl(0, WSKBDIO_GETDEFAULTBELL, &default_bell) < 0 ) if ( fsystem->ioctl(0, WSKBDIO_GETDEFAULTBELL, &default_bell) < 0 )
@ -147,7 +154,7 @@ bool FTermOpenBSD::saveBSDConsoleEncoding()
static kbd_t k_encoding{}; static kbd_t k_encoding{};
int ret{-1}; int ret{-1};
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
ret = fsystem->ioctl (0, WSKBDIO_GETENCODING, &k_encoding); ret = fsystem->ioctl (0, WSKBDIO_GETENCODING, &k_encoding);
if ( ret < 0 ) if ( ret < 0 )
@ -161,7 +168,7 @@ bool FTermOpenBSD::saveBSDConsoleEncoding()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTermOpenBSD::setBSDConsoleEncoding (kbd_t k_encoding) bool FTermOpenBSD::setBSDConsoleEncoding (kbd_t k_encoding)
{ {
const auto& fsystem = FTerm::getFSystem(); const auto& fsystem = FSystem::getInstance();
if ( fsystem->ioctl(0, WSKBDIO_SETENCODING, &k_encoding) < 0 ) if ( fsystem->ioctl(0, WSKBDIO_SETENCODING, &k_encoding) < 0 )
return false; return false;

View File

@ -51,6 +51,13 @@ bool FTermXTerminal::mouse_support{false};
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// public methods of FTermXTerminal // public methods of FTermXTerminal
//----------------------------------------------------------------------
auto FTermXTerminal::getInstance() -> FTermXTerminal&
{
static const auto& xterm = make_unique<FTermXTerminal>();
return *xterm;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::setCursorStyle (XTermCursorStyle style) void FTermXTerminal::setCursorStyle (XTermCursorStyle style)
{ {
@ -241,7 +248,7 @@ void FTermXTerminal::resetHighlightBackground()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::resetDefaults() void FTermXTerminal::resetDefaults()
{ {
if ( FTerm::getFTermDetection().isPuttyTerminal() ) if ( FTermDetection::getInstance().isPuttyTerminal() )
return; return;
// Redefines the cursor color if resetCursorColor() doesn't work // Redefines the cursor color if resetCursorColor() doesn't work
@ -272,14 +279,14 @@ void FTermXTerminal::resetTitle()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::captureFontAndTitle() void FTermXTerminal::captureFontAndTitle()
{ {
const auto& term_detection = FTerm::getFTermDetection(); const auto& term_detection = FTermDetection::getInstance();
if ( ( term_detection.isXTerminal() if ( ( term_detection.isXTerminal()
|| term_detection.isUrxvtTerminal() ) || term_detection.isUrxvtTerminal() )
&& ! term_detection.isRxvtTerminal() ) && ! term_detection.isRxvtTerminal() )
{ {
FTermios::setCaptureSendCharacters(); FTermios::setCaptureSendCharacters();
auto& keyboard = FTerm::getFKeyboard(); auto& keyboard = FKeyboard::getInstance();
keyboard.setNonBlockingInput(); keyboard.setNonBlockingInput();
xterm_font = captureXTermFont(); xterm_font = captureXTermFont();
xterm_title = captureXTermTitle(); xterm_title = captureXTermTitle();
@ -310,7 +317,7 @@ void FTermXTerminal::setXTermCursorStyle()
return; return;
#endif #endif
const auto& term_detection = FTerm::getFTermDetection(); const auto& term_detection = FTermDetection::getInstance();
if ( term_detection.isGnomeTerminal() if ( term_detection.isGnomeTerminal()
&& ! term_detection.hasSetCursorStyleSupport() ) && ! term_detection.hasSetCursorStyleSupport() )
@ -334,7 +341,7 @@ void FTermXTerminal::setXTermCursorStyle()
void FTermXTerminal::setXTermTitle() void FTermXTerminal::setXTermTitle()
{ {
// Set the xterm title // Set the xterm title
const auto& term_detection = FTerm::getFTermDetection(); const auto& term_detection = FTermDetection::getInstance();
if ( term_detection.isXTerminal() if ( term_detection.isXTerminal()
|| term_detection.isScreenTerm() || term_detection.isScreenTerm()
@ -355,7 +362,7 @@ void FTermXTerminal::setXTermTitle()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::setXTermSize() const void FTermXTerminal::setXTermSize() const
{ {
if ( ! FTerm::getFTermDetection().isXTerminal() ) if ( ! FTermDetection::getInstance().isXTerminal() )
return; return;
FTerm::putstringf ( CSI "8;%lu;%lut" FTerm::putstringf ( CSI "8;%lu;%lut"
@ -369,7 +376,7 @@ void FTermXTerminal::setXTermFont()
{ {
// Change the XTerm font (needs the allowFontOps resource) // Change the XTerm font (needs the allowFontOps resource)
const auto& term_detection = FTerm::getFTermDetection(); const auto& term_detection = FTermDetection::getInstance();
if ( term_detection.isXTerminal() if ( term_detection.isXTerminal()
|| term_detection.isScreenTerm() || term_detection.isScreenTerm()
@ -387,7 +394,7 @@ void FTermXTerminal::setXTermForeground()
{ {
// Set the XTerm text foreground color // Set the XTerm text foreground color
const auto& term_detection = FTerm::getFTermDetection(); const auto& term_detection = FTermDetection::getInstance();
if ( term_detection.isXTerminal() if ( term_detection.isXTerminal()
|| term_detection.isScreenTerm() || term_detection.isScreenTerm()
@ -407,7 +414,7 @@ void FTermXTerminal::setXTermBackground()
{ {
// Set the XTerm text background color // Set the XTerm text background color
const auto& term_detection = FTerm::getFTermDetection(); const auto& term_detection = FTermDetection::getInstance();
if ( term_detection.isXTerminal() if ( term_detection.isXTerminal()
|| term_detection.isScreenTerm() || term_detection.isScreenTerm()
@ -427,7 +434,7 @@ void FTermXTerminal::setXTermCursorColor()
{ {
// Set the text cursor color // Set the text cursor color
const auto& term_detection = FTerm::getFTermDetection(); const auto& term_detection = FTermDetection::getInstance();
if ( term_detection.isXTerminal() if ( term_detection.isXTerminal()
|| term_detection.isScreenTerm() || term_detection.isScreenTerm()
@ -447,7 +454,7 @@ void FTermXTerminal::setXTermMouseForeground()
{ {
// Set the mouse foreground color // Set the mouse foreground color
const auto& term_detection = FTerm::getFTermDetection(); const auto& term_detection = FTermDetection::getInstance();
if ( term_detection.isXTerminal() if ( term_detection.isXTerminal()
|| term_detection.isScreenTerm() || term_detection.isScreenTerm()
@ -466,7 +473,7 @@ void FTermXTerminal::setXTermMouseBackground()
{ {
// Set the mouse background color // Set the mouse background color
const auto& term_detection = FTerm::getFTermDetection(); const auto& term_detection = FTermDetection::getInstance();
if ( term_detection.isXTerminal() if ( term_detection.isXTerminal()
|| term_detection.isScreenTerm() || term_detection.isScreenTerm()
@ -484,7 +491,7 @@ void FTermXTerminal::setXTermHighlightBackground()
{ {
// Set the highlight background color // Set the highlight background color
const auto& term_detection = FTerm::getFTermDetection(); const auto& term_detection = FTermDetection::getInstance();
if ( term_detection.isXTerminal() if ( term_detection.isXTerminal()
|| term_detection.isScreenTerm() || term_detection.isScreenTerm()
@ -504,7 +511,7 @@ void FTermXTerminal::setXTerm8ColorDefaults()
// Redefinition of the XTerm default colors // Redefinition of the XTerm default colors
// for the final cut 8 color theme // for the final cut 8 color theme
if ( FTerm::getFTermDetection().isPuttyTerminal() ) if ( FTermDetection::getInstance().isPuttyTerminal() )
return; return;
setXTermDefaultsMouseCursor(); setXTermDefaultsMouseCursor();
@ -524,7 +531,7 @@ void FTermXTerminal::setXTerm16ColorDefaults()
// Redefinition of the XTerm default colors // Redefinition of the XTerm default colors
// for the final cut 16 color theme // for the final cut 16 color theme
if ( FTerm::getFTermDetection().isPuttyTerminal() ) if ( FTermDetection::getInstance().isPuttyTerminal() )
return; return;
setXTermDefaultsMouseCursor(); setXTermDefaultsMouseCursor();
@ -544,14 +551,14 @@ inline void FTermXTerminal::setXTermDefaultsMouseCursor()
setMouseBackground("rgb:ffff/ffff/ffff"); // white setMouseBackground("rgb:ffff/ffff/ffff"); // white
setMouseForeground ("rgb:0000/0000/0000"); // black setMouseForeground ("rgb:0000/0000/0000"); // black
if ( ! FTerm::getFTermDetection().isGnomeTerminal() ) if ( ! FTermDetection::getInstance().isGnomeTerminal() )
setCursorColor("rgb:ffff/ffff/ffff"); // white setCursorColor("rgb:ffff/ffff/ffff"); // white
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermXTerminal::canSetXTermBackground() const inline bool FTermXTerminal::canSetXTermBackground() const
{ {
const auto& term_detection = FTerm::getFTermDetection(); const auto& term_detection = FTermDetection::getInstance();
if ( xterm_default_colors if ( xterm_default_colors
&& ! (term_detection.isMinttyTerm() && ! (term_detection.isMinttyTerm()
@ -568,7 +575,7 @@ void FTermXTerminal::resetXTermColorMap() const
{ {
// Reset the entire color table // Reset the entire color table
if ( FTerm::getFTermDetection().isMinttyTerm() ) if ( FTermDetection::getInstance().isMinttyTerm() )
{ {
FTerm::putstring (ESC "c"); // Full Reset (RIS) FTerm::putstring (ESC "c"); // Full Reset (RIS)
} }
@ -668,7 +675,7 @@ void FTermXTerminal::resetXTermHighlightBackground() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTermXTerminal::canResetColor() const bool FTermXTerminal::canResetColor() const
{ {
const auto& term_detection = FTerm::getFTermDetection(); const auto& term_detection = FTermDetection::getInstance();
if ( term_detection.isGnomeTerminal() if ( term_detection.isGnomeTerminal()
&& term_detection.getGnomeTerminalID() < 3502 ) && term_detection.getGnomeTerminalID() < 3502 )
@ -689,7 +696,7 @@ bool FTermXTerminal::canResetColor() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::oscPrefix() const void FTermXTerminal::oscPrefix() const
{ {
const auto& term_detection = FTerm::getFTermDetection(); const auto& term_detection = FTermDetection::getInstance();
if ( term_detection.isTmuxTerm() ) if ( term_detection.isTmuxTerm() )
{ {
@ -706,7 +713,7 @@ void FTermXTerminal::oscPrefix() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::oscPostfix() const void FTermXTerminal::oscPostfix() const
{ {
const auto& term_detection = FTerm::getFTermDetection(); const auto& term_detection = FTermDetection::getInstance();
if ( term_detection.isScreenTerm() if ( term_detection.isScreenTerm()
|| term_detection.isTmuxTerm() ) || term_detection.isTmuxTerm() )
@ -719,7 +726,7 @@ void FTermXTerminal::oscPostfix() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FString FTermXTerminal::captureXTermFont() const FString FTermXTerminal::captureXTermFont() const
{ {
const auto& term_detection = FTerm::getFTermDetection(); const auto& term_detection = FTermDetection::getInstance();
if ( ! term_detection.isXTerminal() if ( ! term_detection.isXTerminal()
&& ! term_detection.isScreenTerm() && ! term_detection.isScreenTerm()
@ -781,7 +788,7 @@ FString FTermXTerminal::captureXTermFont() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FString FTermXTerminal::captureXTermTitle() const FString FTermXTerminal::captureXTermTitle() const
{ {
if ( FTerm::getFTermDetection().isKdeTerminal() ) if ( FTermDetection::getInstance().isKdeTerminal() )
return {}; return {};
fd_set ifds{}; fd_set ifds{};

View File

@ -599,7 +599,7 @@ void FVTerm::flush() const
} }
std::fflush(stdout); std::fflush(stdout);
auto& mouse = FTerm::getFMouseControl(); auto& mouse = FMouseControl::getInstance();
mouse.drawPointer(); mouse.drawPointer();
time_last_flush = FObject::getCurrentTime(); time_last_flush = FObject::getCurrentTime();
} }
@ -1881,7 +1881,7 @@ void FVTerm::init()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::init_characterLengths() void FVTerm::init_characterLengths()
{ {
const auto& opti_move = FTerm::getFOptiMove(); const auto& opti_move = FOptiMove::getInstance();
cursor_address_length = opti_move.getCursorAddressLength(); cursor_address_length = opti_move.getCursorAddressLength();
erase_char_length = opti_move.getEraseCharsLength(); erase_char_length = opti_move.getEraseCharsLength();
repeat_char_length = opti_move.getRepeatCharLength(); repeat_char_length = opti_move.getRepeatCharLength();
@ -1915,7 +1915,7 @@ void FVTerm::init_combined_character()
if ( FTerm::getEncoding() != Encoding::UTF8 ) if ( FTerm::getEncoding() != Encoding::UTF8 )
return; return;
const auto& term_detection = FTerm::getFTermDetection(); const auto& term_detection = FTermDetection::getInstance();
if ( term_detection.isCygwinTerminal() ) if ( term_detection.isCygwinTerminal() )
return; return;
@ -1939,7 +1939,7 @@ void FVTerm::finish() const
setNormal(); setNormal();
if ( FTerm::hasAlternateScreen() if ( FTerm::hasAlternateScreen()
&& FTerm::getFTermData().isInAlternateScreen() ) && FTermData::getInstance().isInAlternateScreen() )
clearTerm(); clearTerm();
forceTerminalUpdate(); forceTerminalUpdate();

View File

@ -85,7 +85,7 @@ FWidget::FWidget (FWidget* parent)
{ {
if ( internal::var::root_widget ) if ( internal::var::root_widget )
{ {
auto& fterm_data = FTerm::getFTermData(); auto& fterm_data = FTermData::getInstance();
fterm_data.setExitMessage("FWidget: No parent defined! " fterm_data.setExitMessage("FWidget: No parent defined! "
"There should be only one root object"); "There should be only one root object");
FApplication::exit(EXIT_FAILURE); FApplication::exit(EXIT_FAILURE);
@ -2082,7 +2082,7 @@ void FWidget::initColorTheme()
if ( getColorTheme().use_count() > 0 && ! isDefaultTheme() ) if ( getColorTheme().use_count() > 0 && ! isDefaultTheme() )
return; // A user theme is in use return; // A user theme is in use
if ( FStartOptions::getFStartOptions().dark_theme ) if ( FStartOptions::getInstance().dark_theme )
{ {
if ( FTerm::getMaxColor() < 16 ) // for 8 color mode if ( FTerm::getMaxColor() < 16 ) // for 8 color mode
setColorTheme<default8ColorDarkTheme>(); setColorTheme<default8ColorDarkTheme>();

View File

@ -120,6 +120,7 @@ class FButton : public FWidget
void onMouseDown (FMouseEvent*) override; void onMouseDown (FMouseEvent*) override;
void onMouseUp (FMouseEvent*) override; void onMouseUp (FMouseEvent*) override;
void onMouseMove (FMouseEvent*) override; void onMouseMove (FMouseEvent*) override;
void onWheel (FWheelEvent*) override;
void onTimer (FTimerEvent*) override; void onTimer (FTimerEvent*) override;
void onAccel (FAccelEvent*) override; void onAccel (FAccelEvent*) override;
void onFocusIn (FFocusEvent*) override; void onFocusIn (FFocusEvent*) override;

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the FINAL CUT widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2018-2020 Markus Gans * * Copyright 2018-2021 Markus Gans *
* * * *
* FINAL CUT is free software; you can redistribute it and/or modify * * FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -60,6 +60,7 @@ class FColorPalette
// Accessor // Accessor
virtual FString getClassName() const; virtual FString getClassName() const;
static auto getInstance() -> std::shared_ptr<FColorPalette>&;
// Methods // Methods
virtual void setColorPalette() = 0; virtual void setColorPalette() = 0;

View File

@ -105,10 +105,11 @@ class FKeyboard final
// Accessors // Accessors
FString getClassName() const; FString getClassName() const;
static auto getInstance() -> FKeyboard&;
FKey getKey() const; FKey getKey() const;
FString getKeyName (const FKey) const; FString getKeyName (const FKey) const;
keybuffer& getKeyBuffer(); keybuffer& getKeyBuffer();
TimeValue getKeyPressedTime(); TimeValue getKeyPressedTime() const;
static uInt64 getKeypressTimeout(); static uInt64 getKeypressTimeout();
static uInt64 getReadBlockingTime(); static uInt64 getReadBlockingTime();
@ -214,7 +215,7 @@ inline FKeyboard::keybuffer& FKeyboard::getKeyBuffer()
{ return fifo_buf; } { return fifo_buf; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline TimeValue FKeyboard::getKeyPressedTime() inline TimeValue FKeyboard::getKeyPressedTime() const
{ return time_keypressed; } { return time_keypressed; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -209,7 +209,7 @@ class FMouse : public FMouseData
uInt16 getMaxWidth() const; uInt16 getMaxWidth() const;
uInt16 getMaxHeight() const; uInt16 getMaxHeight() const;
uInt64 getDblclickInterval() const; uInt64 getDblclickInterval() const;
TimeValue getMousePressedTime(); TimeValue getMousePressedTime() const;
// Mutator // Mutator
void setNewPos (int, int); void setNewPos (int, int);
@ -506,6 +506,7 @@ class FMouseControl
// Accessors // Accessors
virtual FString getClassName() const; virtual FString getClassName() const;
static auto getInstance() -> FMouseControl&;
const FPoint& getPos(); const FPoint& getPos();
void clearEvent(); void clearEvent();

View File

@ -107,6 +107,7 @@ class FOptiAttr final
// Accessors // Accessors
FString getClassName() const; FString getClassName() const;
static auto getInstance() -> FOptiAttr&;
// Mutators // Mutators
void setTermEnvironment (const TermEnv&); void setTermEnvironment (const TermEnv&);

View File

@ -93,6 +93,7 @@ class FOptiMove final
// Accessors // Accessors
FString getClassName() const; FString getClassName() const;
static auto getInstance() -> FOptiMove&;
uInt getCursorHomeLength() const; uInt getCursorHomeLength() const;
uInt getCarriageReturnLength() const; uInt getCarriageReturnLength() const;
uInt getCursorToLLLength() const; uInt getCursorToLLLength() const;

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the FINAL CUT widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2019-2020 Markus Gans * * Copyright 2019-2021 Markus Gans *
* * * *
* FINAL CUT is free software; you can redistribute it and/or modify * * FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -66,7 +66,7 @@ class FStartOptions final
// Accessors // Accessors
static FString getClassName(); static FString getClassName();
static FStartOptions& getFStartOptions(); static auto getInstance() -> FStartOptions&;
// Mutator // Mutator
void setDefault(); void setDefault();

View File

@ -57,6 +57,9 @@ class FSystem
// Destructor // Destructor
virtual ~FSystem() noexcept; virtual ~FSystem() noexcept;
// Accessor
static auto getInstance() -> std::unique_ptr<FSystem>&;
// Methods // Methods
virtual uChar inPortByte (uShort) = 0; virtual uChar inPortByte (uShort) = 0;
virtual void outPortByte (uChar, uShort) = 0; virtual void outPortByte (uChar, uShort) = 0;

View File

@ -127,31 +127,12 @@ namespace finalcut
// class forward declaration // class forward declaration
class FColorPalette; class FColorPalette;
class FKeyboard;
class FMouseControl;
class FOptiAttr;
class FOptiMove;
class FPoint; class FPoint;
class FStartOptions; class FStartOptions;
class FSize; class FSize;
class FString; class FString;
class FTermBuffer; class FTermBuffer;
class FTermData;
class FTermDebugData;
class FTermDetection;
class FTermXTerminal;
#if defined(__linux__) || defined(UNIT_TEST)
class FTermLinux;
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
class FTermFreeBSD;
#endif
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
class FTermOpenBSD;
#endif
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FTerm // class FTerm
@ -187,31 +168,6 @@ class FTerm final
static std::string getTermFileName(); static std::string getTermFileName();
static int getTabstop(); static int getTabstop();
static int getMaxColor(); static int getMaxColor();
static auto getColorPaletteTheme() -> std::shared_ptr<FColorPalette>&;
static auto getFSystem() -> std::unique_ptr<FSystem>&;
static auto getFTermData() -> FTermData&;
static auto getFOptiMove() -> FOptiMove&;
static auto getFOptiAttr() -> FOptiAttr&;
static auto getFTermDetection() -> FTermDetection&;
static auto getFTermXTerminal() -> FTermXTerminal&;
static auto getFKeyboard() -> FKeyboard&;
static auto getFMouseControl() -> FMouseControl&;
#if defined(__linux__) || defined(UNIT_TEST)
static auto getFTermLinux() -> FTermLinux&;
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
static auto getFTermFreeBSD() -> FTermFreeBSD&;
#endif
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
static auto getFTermOpenBSD() -> FTermOpenBSD&;
#endif
#if DEBUG
static auto getFTermDebugData() -> FTermDebugData&;
#endif
// Inquiries // Inquiries
static bool isNormal (const FChar&); static bool isNormal (const FChar&);
@ -404,7 +360,7 @@ inline FString FTerm::getClassName()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FTerm::setFSystem (std::unique_ptr<FSystem>& fsystem) inline void FTerm::setFSystem (std::unique_ptr<FSystem>& fsystem)
{ {
getFSystem().swap(fsystem); FSystem::getInstance().swap(fsystem);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -419,8 +375,8 @@ inline bool FTerm::unsetUTF8()
template <typename ClassT> template <typename ClassT>
inline void FTerm::setColorPaletteTheme (const FSetPalette& f) inline void FTerm::setColorPaletteTheme (const FSetPalette& f)
{ {
getColorPaletteTheme() = std::make_shared<ClassT>(f); FColorPalette::getInstance() = std::make_shared<ClassT>(f); // Set instance
getColorPaletteTheme()->setColorPalette(); FColorPalette::getInstance()->setColorPalette(); // Set palette
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -72,6 +72,7 @@ class FTermData final
// Accessors // Accessors
FString getClassName() const; FString getClassName() const;
static auto getInstance() -> FTermData&;
EncodingMap& getEncodingList(); EncodingMap& getEncodingList();
charSubstitution& getCharSubstitutionMap(); charSubstitution& getCharSubstitutionMap();
Encoding getTermEncoding() const; Encoding getTermEncoding() const;
@ -170,6 +171,13 @@ class FTermData final
inline FString FTermData::getClassName() const inline FString FTermData::getClassName() const
{ return "FTermData"; } { return "FTermData"; }
//----------------------------------------------------------------------
inline auto FTermData::getInstance() -> FTermData&
{
static const auto& data = make_unique<FTermData>();
return *data;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FTermData::EncodingMap& FTermData::getEncodingList() inline FTermData::EncodingMap& FTermData::getEncodingList()
{ return encoding_list; } { return encoding_list; }

View File

@ -35,14 +35,13 @@
#error "Only <final/final.h> can be included directly." #error "Only <final/final.h> can be included directly."
#endif #endif
#include "final/fstring.h"
#if DEBUG #if DEBUG
namespace finalcut namespace finalcut
{ {
// class forward declaration
class FTerm;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FTermDebugData // class FTermDebugData
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -63,6 +62,8 @@ class FTermDebugData final
FTermDebugData& operator = (const FTermDebugData&) = delete; FTermDebugData& operator = (const FTermDebugData&) = delete;
// Accessors // Accessors
static FString getClassName();
static auto getInstance() -> FTermDebugData&;
const FString& getAnswerbackString(); const FString& getAnswerbackString();
const FString& getSecDAString(); const FString& getSecDAString();
const FString& getTermType_256color(); const FString& getTermType_256color();
@ -73,6 +74,9 @@ class FTermDebugData final
#endif #endif
}; };
inline FString FTermDebugData::getClassName()
{ return "FTermDebugData"; }
} // namespace finalcut } // namespace finalcut
#endif // DEBUG #endif // DEBUG

View File

@ -100,6 +100,7 @@ class FTermDetection final
// Accessor // Accessor
FString getClassName() const; FString getClassName() const;
static auto getInstance() -> FTermDetection&;
const FString& getTermType() const; const FString& getTermType() const;
int getGnomeTerminalID() const; int getGnomeTerminalID() const;
kittyVersion getKittyVersion() const; kittyVersion getKittyVersion() const;

View File

@ -83,6 +83,7 @@ class FTermFreeBSD final
// Accessors // Accessors
FString getClassName() const; FString getClassName() const;
static auto getInstance() -> FTermFreeBSD&;
static CursorStyle getCursorStyle(); static CursorStyle getCursorStyle();
// Inquiry // Inquiry

View File

@ -92,6 +92,7 @@ class FTermLinux final
// Accessors // Accessors
FString getClassName() const; FString getClassName() const;
static auto getInstance() -> FTermLinux&;
CursorStyle getCursorStyle() const; CursorStyle getCursorStyle() const;
char* getCursorStyleString(); char* getCursorStyleString();
int getFramebufferBpp() const; int getFramebufferBpp() const;

View File

@ -73,6 +73,7 @@ class FTermOpenBSD final
public: public:
// Accessor // Accessor
FString getClassName() const; FString getClassName() const;
static auto getInstance() -> FTermOpenBSD&;
// Inquiries // Inquiries
static bool isBSDConsole(); static bool isBSDConsole();

View File

@ -66,6 +66,7 @@ class FTermXTerminal final
// Accessors // Accessors
FString getClassName() const; FString getClassName() const;
static auto getInstance() -> FTermXTerminal&;
XTermCursorStyle getCursorStyle() const; XTermCursorStyle getCursorStyle() const;
FString getFont() const; FString getFont() const;
FString getTitle() const; FString getTitle() const;

View File

@ -134,7 +134,7 @@ void FOptiAttrTest::sgrOptimizerTest()
{ {
// Test with FOptiAttr // Test with FOptiAttr
// ------------------- // -------------------
finalcut::FStartOptions::getFStartOptions().sgr_optimizer = true; finalcut::FStartOptions::getInstance().sgr_optimizer = true;
finalcut::FOptiAttr oa; finalcut::FOptiAttr oa;
oa.setDefaultColorSupport(); // ANSI default color oa.setDefaultColorSupport(); // ANSI default color
oa.setMaxColor (8); oa.setMaxColor (8);
@ -349,7 +349,7 @@ void FOptiAttrTest::vga2ansiTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FOptiAttrTest::fakeReverseTest() void FOptiAttrTest::fakeReverseTest()
{ {
finalcut::FStartOptions::getFStartOptions().sgr_optimizer = false; finalcut::FStartOptions::getInstance().sgr_optimizer = false;
finalcut::FOptiAttr oa; finalcut::FOptiAttr oa;
oa.setDefaultColorSupport(); // ANSI default color oa.setDefaultColorSupport(); // ANSI default color
oa.setMaxColor (8); oa.setMaxColor (8);
@ -435,7 +435,7 @@ void FOptiAttrTest::ansiTest()
{ {
// Simulate an ansi terminal // Simulate an ansi terminal
finalcut::FStartOptions::getFStartOptions().sgr_optimizer = false; finalcut::FStartOptions::getInstance().sgr_optimizer = false;
finalcut::FOptiAttr oa; finalcut::FOptiAttr oa;
oa.setDefaultColorSupport(); // ANSI default color oa.setDefaultColorSupport(); // ANSI default color
oa.setMaxColor (8); oa.setMaxColor (8);
@ -900,7 +900,7 @@ void FOptiAttrTest::vt100Test()
{ {
// Simulate a vt100 terminal // Simulate a vt100 terminal
finalcut::FStartOptions::getFStartOptions().sgr_optimizer = false; finalcut::FStartOptions::getInstance().sgr_optimizer = false;
finalcut::FOptiAttr oa; finalcut::FOptiAttr oa;
oa.unsetDefaultColorSupport(); // No ANSI default color oa.unsetDefaultColorSupport(); // No ANSI default color
oa.setMaxColor (1); oa.setMaxColor (1);
@ -1358,7 +1358,7 @@ void FOptiAttrTest::xtermTest()
{ {
// Simulate an xterm-256color terminal // Simulate an xterm-256color terminal
finalcut::FStartOptions::getFStartOptions().sgr_optimizer = false; finalcut::FStartOptions::getInstance().sgr_optimizer = false;
finalcut::FOptiAttr oa; finalcut::FOptiAttr oa;
oa.setDefaultColorSupport(); // ANSI default color oa.setDefaultColorSupport(); // ANSI default color
oa.setMaxColor (256); oa.setMaxColor (256);
@ -1837,7 +1837,7 @@ void FOptiAttrTest::rxvtTest()
{ {
// Simulate an rxvt terminal // Simulate an rxvt terminal
finalcut::FStartOptions::getFStartOptions().sgr_optimizer = false; finalcut::FStartOptions::getInstance().sgr_optimizer = false;
finalcut::FOptiAttr oa; finalcut::FOptiAttr oa;
oa.setDefaultColorSupport(); // ANSI default color oa.setDefaultColorSupport(); // ANSI default color
oa.setMaxColor (8); oa.setMaxColor (8);
@ -2306,7 +2306,7 @@ void FOptiAttrTest::linuxTest()
{ {
// Simulate a Linux terminal with 16 colors // Simulate a Linux terminal with 16 colors
finalcut::FStartOptions::getFStartOptions().sgr_optimizer = false; finalcut::FStartOptions::getInstance().sgr_optimizer = false;
finalcut::FOptiAttr oa; finalcut::FOptiAttr oa;
oa.setDefaultColorSupport(); // ANSI default color oa.setDefaultColorSupport(); // ANSI default color
oa.setMaxColor (16); oa.setMaxColor (16);
@ -2778,7 +2778,7 @@ void FOptiAttrTest::puttyTest()
{ {
// Simulate a putty-256color terminal // Simulate a putty-256color terminal
finalcut::FStartOptions::getFStartOptions().sgr_optimizer = false; finalcut::FStartOptions::getInstance().sgr_optimizer = false;
finalcut::FOptiAttr oa; finalcut::FOptiAttr oa;
oa.unsetDefaultColorSupport(); // No ANSI default color oa.unsetDefaultColorSupport(); // No ANSI default color
oa.setMaxColor (256); oa.setMaxColor (256);
@ -3257,7 +3257,7 @@ void FOptiAttrTest::teratermTest()
{ {
// Simulate a Tera Term terminal // Simulate a Tera Term terminal
finalcut::FStartOptions::getFStartOptions().sgr_optimizer = false; finalcut::FStartOptions::getInstance().sgr_optimizer = false;
finalcut::FOptiAttr oa; finalcut::FOptiAttr oa;
oa.unsetDefaultColorSupport(); // No ANSI default color oa.unsetDefaultColorSupport(); // No ANSI default color
oa.setMaxColor (16); oa.setMaxColor (16);
@ -3719,7 +3719,7 @@ void FOptiAttrTest::ibmColorTest()
{ {
// Simulate IBM color definitions // Simulate IBM color definitions
finalcut::FStartOptions::getFStartOptions().sgr_optimizer = false; finalcut::FStartOptions::getInstance().sgr_optimizer = false;
finalcut::FOptiAttr oa; finalcut::FOptiAttr oa;
oa.unsetDefaultColorSupport(); // No ANSI default color oa.unsetDefaultColorSupport(); // No ANSI default color
oa.setMaxColor (8); oa.setMaxColor (8);
@ -4155,7 +4155,7 @@ void FOptiAttrTest::wyse50Test()
{ {
// Simulate an Wyse-50 terminal // Simulate an Wyse-50 terminal
finalcut::FStartOptions::getFStartOptions().sgr_optimizer = false; finalcut::FStartOptions::getInstance().sgr_optimizer = false;
finalcut::FOptiAttr oa; finalcut::FOptiAttr oa;
finalcut::FOptiAttr::TermEnv optiattr_env = finalcut::FOptiAttr::TermEnv optiattr_env =
{ {

View File

@ -488,7 +488,7 @@ void FTermFunctionsTest::FullWidthHalfWidthTest()
CPPUNIT_ASSERT ( finalcut::getHalfWidth(L"") == L"" ); CPPUNIT_ASSERT ( finalcut::getHalfWidth(L"") == L"" );
// Column width (wchar_t) // Column width (wchar_t)
auto& fterm_data = finalcut::FTerm::getFTermData(); auto& fterm_data = finalcut::FTermData::getInstance();
fterm_data.setTermEncoding (finalcut::Encoding::UTF8); fterm_data.setTermEncoding (finalcut::Encoding::UTF8);
CPPUNIT_ASSERT ( finalcut::getColumnWidth(L"\t") == 0 ); CPPUNIT_ASSERT ( finalcut::getColumnWidth(L"\t") == 0 );
CPPUNIT_ASSERT ( finalcut::getColumnWidth(L"\r") == 0 ); CPPUNIT_ASSERT ( finalcut::getColumnWidth(L"\r") == 0 );
@ -2551,7 +2551,7 @@ void FTermFunctionsTest::combiningCharacterTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermFunctionsTest::readCursorPosTest() void FTermFunctionsTest::readCursorPosTest()
{ {
auto& fterm_data = finalcut::FTerm::getFTermData(); auto& fterm_data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
fterm_data.setTermType("xterm"); fterm_data.setTermType("xterm");
detect.setTerminalDetection(true); detect.setTerminalDetection(true);

View File

@ -100,7 +100,7 @@ void FTermBufferTest::noArgumentTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermBufferTest::writeTest() void FTermBufferTest::writeTest()
{ {
auto& fterm_data = finalcut::FTerm::getFTermData(); auto& fterm_data = finalcut::FTermData::getInstance();
fterm_data.setTermEncoding (finalcut::Encoding::UTF8); fterm_data.setTermEncoding (finalcut::Encoding::UTF8);
finalcut::FTermBuffer term_buf{}; finalcut::FTermBuffer term_buf{};
@ -361,7 +361,7 @@ void FTermBufferTest::writeTest()
void FTermBufferTest::streamTest() void FTermBufferTest::streamTest()
{ {
auto multi_color_emojis = bool( wcswidth(L"🚧🚀🚴", 3) == 6 ); auto multi_color_emojis = bool( wcswidth(L"🚧🚀🚴", 3) == 6 );
auto& fterm_data = finalcut::FTerm::getFTermData(); auto& fterm_data = finalcut::FTermData::getInstance();
fterm_data.setTermEncoding (finalcut::Encoding::UTF8); fterm_data.setTermEncoding (finalcut::Encoding::UTF8);
finalcut::FTermBuffer::FCharVector fchar_vec = { finalcut::FChar{} }; finalcut::FTermBuffer::FCharVector fchar_vec = { finalcut::FChar{} };
CPPUNIT_ASSERT ( fchar_vec.size() == 1 ); CPPUNIT_ASSERT ( fchar_vec.size() == 1 );
@ -499,7 +499,7 @@ void FTermBufferTest::streamTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermBufferTest::combiningCharacterTest() void FTermBufferTest::combiningCharacterTest()
{ {
auto& fterm_data = finalcut::FTerm::getFTermData(); auto& fterm_data = finalcut::FTermData::getInstance();
fterm_data.setTermEncoding (finalcut::Encoding::UTF8); fterm_data.setTermEncoding (finalcut::Encoding::UTF8);
finalcut::FTermBuffer term_buf{}; finalcut::FTermBuffer term_buf{};
// Skip leading zero-width characters // Skip leading zero-width characters

View File

@ -122,7 +122,7 @@ void FTermcapTest::classNameTest()
void FTermcapTest::initTest() void FTermcapTest::initTest()
{ {
// Without a terminal type // Without a terminal type
auto& fterm_data = finalcut::FTerm::getFTermData(); auto& fterm_data = finalcut::FTermData::getInstance();
CPPUNIT_ASSERT ( fterm_data.getTermType().empty() ); CPPUNIT_ASSERT ( fterm_data.getTermType().empty() );
finalcut::FTermcap tcap; finalcut::FTermcap tcap;
CPPUNIT_ASSERT ( ! tcap.isInitialized() ); CPPUNIT_ASSERT ( ! tcap.isInitialized() );
@ -141,7 +141,7 @@ void FTermcapTest::initTest()
tcap.init(); tcap.init();
CPPUNIT_ASSERT ( fterm_data.getTermType() == "xterm" ); CPPUNIT_ASSERT ( fterm_data.getTermType() == "xterm" );
setenv ("TERM", "xterm-256color", 1); // 256 color terminal setenv ("TERM", "xterm-256color", 1); // 256 color terminal
auto& term_detection = finalcut::FTerm::getFTermDetection(); auto& term_detection = finalcut::FTermDetection::getInstance();
CPPUNIT_ASSERT ( ! term_detection.canDisplay256Colors() ); CPPUNIT_ASSERT ( ! term_detection.canDisplay256Colors() );
term_detection.detect(); term_detection.detect();
CPPUNIT_ASSERT ( term_detection.canDisplay256Colors() ); CPPUNIT_ASSERT ( term_detection.canDisplay256Colors() );
@ -156,7 +156,7 @@ void FTermcapTest::initTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermcapTest::getFlagTest() void FTermcapTest::getFlagTest()
{ {
auto& fterm_data = finalcut::FTerm::getFTermData(); auto& fterm_data = finalcut::FTermData::getInstance();
fterm_data.setTermType("ansi"); fterm_data.setTermType("ansi");
finalcut::FTermcap tcap; finalcut::FTermcap tcap;
tcap.init(); tcap.init();
@ -171,7 +171,7 @@ void FTermcapTest::getFlagTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermcapTest::getNumberTest() void FTermcapTest::getNumberTest()
{ {
auto& fterm_data = finalcut::FTerm::getFTermData(); auto& fterm_data = finalcut::FTermData::getInstance();
fterm_data.setTermType("xterm"); fterm_data.setTermType("xterm");
finalcut::FTermcap tcap; finalcut::FTermcap tcap;
tcap.init(); tcap.init();
@ -188,7 +188,7 @@ void FTermcapTest::getNumberTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermcapTest::getStringTest() void FTermcapTest::getStringTest()
{ {
auto& fterm_data = finalcut::FTerm::getFTermData(); auto& fterm_data = finalcut::FTermData::getInstance();
fterm_data.setTermType("ansi"); fterm_data.setTermType("ansi");
finalcut::FTermcap tcap; finalcut::FTermcap tcap;
tcap.init(); tcap.init();
@ -206,7 +206,7 @@ void FTermcapTest::getStringTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermcapTest::encodeMotionParameterTest() void FTermcapTest::encodeMotionParameterTest()
{ {
auto& fterm_data = finalcut::FTerm::getFTermData(); auto& fterm_data = finalcut::FTermData::getInstance();
fterm_data.setTermType("ansi"); fterm_data.setTermType("ansi");
finalcut::FTermcap tcap; finalcut::FTermcap tcap;
tcap.init(); tcap.init();
@ -222,7 +222,7 @@ void FTermcapTest::encodeMotionParameterTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermcapTest::encodeParameterTest() void FTermcapTest::encodeParameterTest()
{ {
auto& fterm_data = finalcut::FTerm::getFTermData(); auto& fterm_data = finalcut::FTermData::getInstance();
fterm_data.setTermType("ansi"); fterm_data.setTermType("ansi");
finalcut::FTermcap tcap; finalcut::FTermcap tcap;
tcap.init(); tcap.init();
@ -248,7 +248,7 @@ void FTermcapTest::paddingPrintTest()
finalcut::FTermcap tcap; finalcut::FTermcap tcap;
setenv ("TERM", "xterm", 1); // xterm has no padding character setenv ("TERM", "xterm", 1); // xterm has no padding character
unsetenv("TERMCAP"); unsetenv("TERMCAP");
auto& fterm_data = finalcut::FTerm::getFTermData(); auto& fterm_data = finalcut::FTermData::getInstance();
fterm_data.setTermType("xterm"); fterm_data.setTermType("xterm");
CPPUNIT_ASSERT ( ! tcap.xon_xoff_flow_control ); CPPUNIT_ASSERT ( ! tcap.xon_xoff_flow_control );
tcap.init(); tcap.init();

View File

@ -293,8 +293,8 @@ void FTermcapQuirksTest::xtermTest()
for (std::size_t i = 0; i < last_item; i++) for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
auto& detect = finalcut::FTerm::getFTermDetection(); auto& detect = finalcut::FTermDetection::getInstance();
finalcut::FTermcapQuirks quirks; finalcut::FTermcapQuirks quirks;
finalcut::FTermcap::can_change_color_palette = false; finalcut::FTermcap::can_change_color_palette = false;
detect.setXTerminal (true); detect.setXTerminal (true);
@ -324,8 +324,8 @@ void FTermcapQuirksTest::freebsdTest()
for (std::size_t i = 0; i < last_item; i++) for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
auto& detect = finalcut::FTerm::getFTermDetection(); auto& detect = finalcut::FTermDetection::getInstance();
finalcut::FTermcap::attr_without_color = -1; finalcut::FTermcap::attr_without_color = -1;
finalcut::FTermcapQuirks quirks; finalcut::FTermcapQuirks quirks;
detect.setFreeBSDTerm (true); detect.setFreeBSDTerm (true);
@ -363,8 +363,8 @@ void FTermcapQuirksTest::cygwinTest()
for (std::size_t i = 0; i < last_item; i++) for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
auto& detect = finalcut::FTerm::getFTermDetection(); auto& detect = finalcut::FTermDetection::getInstance();
finalcut::FTermcap::background_color_erase = false; finalcut::FTermcap::background_color_erase = false;
finalcut::FTermcapQuirks quirks; finalcut::FTermcapQuirks quirks;
detect.setCygwinTerminal (true); detect.setCygwinTerminal (true);
@ -388,8 +388,8 @@ void FTermcapQuirksTest::linuxTest()
for (std::size_t i = 0; i < last_item; i++) for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
auto& detect = finalcut::FTerm::getFTermDetection(); auto& detect = finalcut::FTermDetection::getInstance();
finalcut::FTermcap::max_color = 8; finalcut::FTermcap::max_color = 8;
finalcut::FTermcap::attr_without_color = -1; finalcut::FTermcap::attr_without_color = -1;
finalcut::FTermcapQuirks quirks; finalcut::FTermcapQuirks quirks;
@ -460,8 +460,8 @@ void FTermcapQuirksTest::rxvtTest()
for (std::size_t i = 0; i < last_item; i++) for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
auto& detect = finalcut::FTerm::getFTermDetection(); auto& detect = finalcut::FTermDetection::getInstance();
finalcut::FTermcapQuirks quirks; finalcut::FTermcapQuirks quirks;
detect.setRxvtTerminal (true); detect.setRxvtTerminal (true);
data.setTermType ("rxvt"); data.setTermType ("rxvt");
@ -501,8 +501,8 @@ void FTermcapQuirksTest::vteTest()
for (std::size_t i = 0; i < last_item; i++) for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
auto& detect = finalcut::FTerm::getFTermDetection(); auto& detect = finalcut::FTermDetection::getInstance();
finalcut::FTermcap::attr_without_color = -1; finalcut::FTermcap::attr_without_color = -1;
finalcut::FTermcapQuirks quirks; finalcut::FTermcapQuirks quirks;
detect.setGnomeTerminal (true); detect.setGnomeTerminal (true);
@ -527,8 +527,8 @@ void FTermcapQuirksTest::kittyTest()
caps[int(finalcut::Termcap::t_enter_ca_mode)].string = CSI "?1049h"; caps[int(finalcut::Termcap::t_enter_ca_mode)].string = CSI "?1049h";
caps[int(finalcut::Termcap::t_exit_ca_mode)].string = CSI "?1049l"; caps[int(finalcut::Termcap::t_exit_ca_mode)].string = CSI "?1049l";
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
auto& detect = finalcut::FTerm::getFTermDetection(); auto& detect = finalcut::FTermDetection::getInstance();
finalcut::FTermcapQuirks quirks; finalcut::FTermcapQuirks quirks;
detect.setKittyTerminal (true); detect.setKittyTerminal (true);
data.setTermType ("xterm-kitty"); data.setTermType ("xterm-kitty");
@ -551,8 +551,8 @@ void FTermcapQuirksTest::puttyTest()
for (std::size_t i = 0; i < last_item; i++) for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
auto& detect = finalcut::FTerm::getFTermDetection(); auto& detect = finalcut::FTermDetection::getInstance();
finalcut::FTermcap::background_color_erase = false; finalcut::FTermcap::background_color_erase = false;
finalcut::FTermcap::can_change_color_palette = false; finalcut::FTermcap::can_change_color_palette = false;
finalcut::FTermcap::osc_support = false; finalcut::FTermcap::osc_support = false;
@ -641,8 +641,8 @@ void FTermcapQuirksTest::teratermTest()
for (std::size_t i = 0; i < last_item; i++) for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
auto& detect = finalcut::FTerm::getFTermDetection(); auto& detect = finalcut::FTermDetection::getInstance();
finalcut::FTermcap::eat_nl_glitch = false; finalcut::FTermcap::eat_nl_glitch = false;
finalcut::FTermcapQuirks quirks; finalcut::FTermcapQuirks quirks;
detect.setTeraTerm (true); detect.setTeraTerm (true);
@ -671,8 +671,8 @@ void FTermcapQuirksTest::sunTest()
for (std::size_t i = 0; i < last_item; i++) for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
auto& detect = finalcut::FTerm::getFTermDetection(); auto& detect = finalcut::FTermDetection::getInstance();
finalcut::FTermcap::eat_nl_glitch = false; finalcut::FTermcap::eat_nl_glitch = false;
finalcut::FTermcapQuirks quirks; finalcut::FTermcapQuirks quirks;
detect.setSunTerminal (true); detect.setSunTerminal (true);
@ -789,8 +789,8 @@ void FTermcapQuirksTest::screenTest()
for (std::size_t i = 0; i < last_item; i++) for (std::size_t i = 0; i < last_item; i++)
memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0])); memcpy(&caps[i], &test::tcap[i], sizeof(test::tcap[0]));
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
auto& detect = finalcut::FTerm::getFTermDetection(); auto& detect = finalcut::FTermDetection::getInstance();
finalcut::FTermcapQuirks quirks; finalcut::FTermcapQuirks quirks;
finalcut::FTermcap::can_change_color_palette = false; finalcut::FTermcap::can_change_color_palette = false;
detect.setScreenTerm (true); detect.setScreenTerm (true);

View File

@ -124,7 +124,7 @@ void FTermDetectionTest::classNameTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::ansiTest() void FTermDetectionTest::ansiTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
setenv ("TERM", "ansi", 1); setenv ("TERM", "ansi", 1);
data.setTermType("ansi"); data.setTermType("ansi");
@ -197,7 +197,7 @@ void FTermDetectionTest::ansiTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::xtermTest() void FTermDetectionTest::xtermTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
data.setTermType("xterm"); data.setTermType("xterm");
detect.setTerminalDetection(true); detect.setTerminalDetection(true);
@ -262,7 +262,7 @@ void FTermDetectionTest::xtermTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::rxvtTest() void FTermDetectionTest::rxvtTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
data.setTermType("rxvt-cygwin-native"); data.setTermType("rxvt-cygwin-native");
detect.setTerminalDetection(true); detect.setTerminalDetection(true);
@ -328,7 +328,7 @@ void FTermDetectionTest::rxvtTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::urxvtTest() void FTermDetectionTest::urxvtTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
data.setTermType("rxvt-unicode-256color"); data.setTermType("rxvt-unicode-256color");
detect.setTerminalDetection(true); detect.setTerminalDetection(true);
@ -393,7 +393,7 @@ void FTermDetectionTest::urxvtTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::kdeKonsoleTest() void FTermDetectionTest::kdeKonsoleTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
data.setTermType("xterm-256color"); data.setTermType("xterm-256color");
detect.setTerminalDetection(true); detect.setTerminalDetection(true);
@ -458,7 +458,7 @@ void FTermDetectionTest::kdeKonsoleTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::gnomeTerminalTest() void FTermDetectionTest::gnomeTerminalTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
data.setTermType("xterm-256color"); data.setTermType("xterm-256color");
detect.setTerminalDetection(true); detect.setTerminalDetection(true);
@ -523,7 +523,7 @@ void FTermDetectionTest::gnomeTerminalTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::newerVteTerminalTest() void FTermDetectionTest::newerVteTerminalTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
data.setTermType("xterm-256color"); data.setTermType("xterm-256color");
detect.setTerminalDetection(true); detect.setTerminalDetection(true);
@ -588,7 +588,7 @@ void FTermDetectionTest::newerVteTerminalTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::puttyTest() void FTermDetectionTest::puttyTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
data.setTermType("xterm"); data.setTermType("xterm");
detect.setTerminalDetection(true); detect.setTerminalDetection(true);
@ -654,7 +654,7 @@ void FTermDetectionTest::puttyTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::windowsTerminalTest() void FTermDetectionTest::windowsTerminalTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
data.setTermType("xterm"); data.setTermType("xterm");
detect.setTerminalDetection(true); detect.setTerminalDetection(true);
@ -721,7 +721,7 @@ void FTermDetectionTest::windowsTerminalTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::teraTermTest() void FTermDetectionTest::teraTermTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
data.setTermType("xterm"); data.setTermType("xterm");
detect.setTerminalDetection(true); detect.setTerminalDetection(true);
@ -786,7 +786,7 @@ void FTermDetectionTest::teraTermTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::cygwinTest() void FTermDetectionTest::cygwinTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
data.setTermType("cygwin"); data.setTermType("cygwin");
detect.setTerminalDetection(true); detect.setTerminalDetection(true);
@ -851,7 +851,7 @@ void FTermDetectionTest::cygwinTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::minttyTest() void FTermDetectionTest::minttyTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
data.setTermType("xterm-256color"); data.setTermType("xterm-256color");
detect.setTerminalDetection(true); detect.setTerminalDetection(true);
@ -916,7 +916,7 @@ void FTermDetectionTest::minttyTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::linuxTest() void FTermDetectionTest::linuxTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
data.setTermType("linux"); data.setTermType("linux");
detect.setTerminalDetection(true); detect.setTerminalDetection(true);
@ -988,7 +988,7 @@ void FTermDetectionTest::linuxTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::freebsdTest() void FTermDetectionTest::freebsdTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
data.setTermType("xterm"); data.setTermType("xterm");
detect.setTerminalDetection(true); detect.setTerminalDetection(true);
@ -1063,7 +1063,7 @@ void FTermDetectionTest::freebsdTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::netbsdTest() void FTermDetectionTest::netbsdTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
data.setTermType("wsvt25"); data.setTermType("wsvt25");
detect.setTerminalDetection(true); detect.setTerminalDetection(true);
@ -1136,7 +1136,7 @@ void FTermDetectionTest::netbsdTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::openbsdTest() void FTermDetectionTest::openbsdTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
data.setTermType("vt220"); data.setTermType("vt220");
detect.setTerminalDetection(true); detect.setTerminalDetection(true);
@ -1209,7 +1209,7 @@ void FTermDetectionTest::openbsdTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::sunTest() void FTermDetectionTest::sunTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
data.setTermType("sun-color"); data.setTermType("sun-color");
@ -1280,7 +1280,7 @@ void FTermDetectionTest::sunTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::screenTest() void FTermDetectionTest::screenTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
data.setTermType("screen"); data.setTermType("screen");
detect.setTerminalDetection(true); detect.setTerminalDetection(true);
@ -1351,7 +1351,7 @@ void FTermDetectionTest::screenTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::tmuxTest() void FTermDetectionTest::tmuxTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
data.setTermType("screen"); data.setTermType("screen");
detect.setTerminalDetection(true); detect.setTerminalDetection(true);
@ -1423,7 +1423,7 @@ void FTermDetectionTest::tmuxTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::ktermTest() void FTermDetectionTest::ktermTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
data.setTermType("kterm"); data.setTermType("kterm");
detect.setTerminalDetection(true); detect.setTerminalDetection(true);
@ -1495,7 +1495,7 @@ void FTermDetectionTest::ktermTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::mltermTest() void FTermDetectionTest::mltermTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
data.setTermType("mlterm"); data.setTermType("mlterm");
detect.setTerminalDetection(true); detect.setTerminalDetection(true);
@ -1568,7 +1568,7 @@ void FTermDetectionTest::mltermTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetectionTest::kittyTest() void FTermDetectionTest::kittyTest()
{ {
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
finalcut::FTermDetection detect; finalcut::FTermDetection detect;
data.setTermType("xterm-kitty"); data.setTermType("xterm-kitty");
detect.setTerminalDetection(true); detect.setTerminalDetection(true);
@ -1692,7 +1692,7 @@ void FTermDetectionTest::ttytypeTest()
unsetenv("KONSOLE_DCOP"); unsetenv("KONSOLE_DCOP");
unsetenv("TMUX"); unsetenv("TMUX");
unsetenv("KITTY_WINDOW_ID"); unsetenv("KITTY_WINDOW_ID");
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
// Test /dev/tty3 with linux // Test /dev/tty3 with linux
data.setTermFileName("/dev/tty3"); data.setTermFileName("/dev/tty3");

View File

@ -622,7 +622,7 @@ void ftermfreebsdTest::freebsdConsoleTest()
std::unique_ptr<finalcut::FSystem> fsys = finalcut::make_unique<test::FSystemTest>(); std::unique_ptr<finalcut::FSystem> fsys = finalcut::make_unique<test::FSystemTest>();
finalcut::FTerm::setFSystem(fsys); finalcut::FTerm::setFSystem(fsys);
std::cout << "\n"; std::cout << "\n";
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
auto& encoding_list = data.getEncodingList(); auto& encoding_list = data.getEncodingList();
encoding_list["UTF-8"] = finalcut::Encoding::UTF8; encoding_list["UTF-8"] = finalcut::Encoding::UTF8;
@ -651,7 +651,7 @@ void ftermfreebsdTest::freebsdConsoleTest()
data.setTermResized (false); data.setTermResized (false);
// setupterm is needed for tputs in ncurses >= 6.1 // setupterm is needed for tputs in ncurses >= 6.1
setupterm (static_cast<char*>(0), 1, static_cast<int*>(0)); setupterm (static_cast<char*>(0), 1, static_cast<int*>(0));
auto& term_detection = finalcut::FTerm::getFTermDetection(); auto& term_detection = finalcut::FTermDetection::getInstance();
term_detection.setTerminalDetection(true); term_detection.setTerminalDetection(true);
pid_t pid = forkConEmu(); pid_t pid = forkConEmu();
@ -660,7 +660,7 @@ void ftermfreebsdTest::freebsdConsoleTest()
// (gdb) set follow-fork-mode child // (gdb) set follow-fork-mode child
static constexpr int left_alt = 0x38; static constexpr int left_alt = 0x38;
finalcut::FTermFreeBSD freebsd; finalcut::FTermFreeBSD freebsd;
const auto& fsystem = finalcut::FTerm::getFSystem(); const auto& fsystem = finalcut::FSystem::getInstance();
auto fsystest = static_cast<test::FSystemTest*>(fsystem.get()); auto fsystest = static_cast<test::FSystemTest*>(fsystem.get());
struct keymap_t& keymap = fsystest->getTerminalKeymap(); struct keymap_t& keymap = fsystest->getTerminalKeymap();
@ -759,7 +759,7 @@ void ftermfreebsdTest::freebsdConsoleTest()
#if DEBUG #if DEBUG
const finalcut::FString& sec_da = \ const finalcut::FString& sec_da = \
finalcut::FTerm::getFTermDebugData().getSecDAString(); finalcut::FTermDebugData::getInstance().getSecDAString();
CPPUNIT_ASSERT ( sec_da == "\033[>0;10;0c" ); CPPUNIT_ASSERT ( sec_da == "\033[>0;10;0c" );
#endif #endif

View File

@ -2066,7 +2066,7 @@ void FTermLinuxTest::linuxConsoleTest()
std::unique_ptr<finalcut::FSystem> fsys = finalcut::make_unique<test::FSystemTest>(); std::unique_ptr<finalcut::FSystem> fsys = finalcut::make_unique<test::FSystemTest>();
finalcut::FTerm::setFSystem(fsys); finalcut::FTerm::setFSystem(fsys);
std::cout << "\n"; std::cout << "\n";
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
auto& encoding_list = data.getEncodingList(); auto& encoding_list = data.getEncodingList();
encoding_list["UTF-8"] = finalcut::Encoding::UTF8; encoding_list["UTF-8"] = finalcut::Encoding::UTF8;
@ -2098,7 +2098,7 @@ void FTermLinuxTest::linuxConsoleTest()
data.setMonochron (false); data.setMonochron (false);
data.setTermResized (false); data.setTermResized (false);
auto& term_detection = finalcut::FTerm::getFTermDetection(); auto& term_detection = finalcut::FTermDetection::getInstance();
finalcut::FTermLinux linux; finalcut::FTermLinux linux;
// setupterm is needed for tputs in ncurses >= 6.1 // setupterm is needed for tputs in ncurses >= 6.1
@ -2134,7 +2134,7 @@ void FTermLinuxTest::linuxConsoleTest()
CPPUNIT_ASSERT ( data.hasHalfBlockCharacter() ); CPPUNIT_ASSERT ( data.hasHalfBlockCharacter() );
CPPUNIT_ASSERT ( linux.getFramebufferBpp() == 32 ); CPPUNIT_ASSERT ( linux.getFramebufferBpp() == 32 );
const auto& fsystem = finalcut::FTerm::getFSystem(); const auto& fsystem = finalcut::FSystem::getInstance();
auto fsystest = static_cast<test::FSystemTest*>(fsystem.get()); auto fsystest = static_cast<test::FSystemTest*>(fsystem.get());
std::string& characters = fsystest->getCharacters(); std::string& characters = fsystest->getCharacters();
linux.setUTF8 (false); linux.setUTF8 (false);
@ -2190,7 +2190,7 @@ void FTermLinuxTest::linuxConsoleLat15Test()
fsystest->setCodeset(test::FSystemTest::Codeset::lat15); fsystest->setCodeset(test::FSystemTest::Codeset::lat15);
finalcut::FTerm::setFSystem(fsys); finalcut::FTerm::setFSystem(fsys);
std::cout << "\n"; std::cout << "\n";
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
auto& encoding_list = data.getEncodingList(); auto& encoding_list = data.getEncodingList();
encoding_list["UTF-8"] = finalcut::Encoding::UTF8; encoding_list["UTF-8"] = finalcut::Encoding::UTF8;
@ -2223,7 +2223,7 @@ void FTermLinuxTest::linuxConsoleLat15Test()
data.setMonochron (false); data.setMonochron (false);
data.setTermResized (false); data.setTermResized (false);
auto& term_detection = finalcut::FTerm::getFTermDetection(); auto& term_detection = finalcut::FTermDetection::getInstance();
finalcut::FTermLinux linux; finalcut::FTermLinux linux;
// setupterm is needed for tputs in ncurses >= 6.1 // setupterm is needed for tputs in ncurses >= 6.1
@ -2282,7 +2282,7 @@ void FTermLinuxTest::linuxCursorStyleTest()
std::unique_ptr<finalcut::FSystem> fsys = finalcut::make_unique<test::FSystemTest>(); std::unique_ptr<finalcut::FSystem> fsys = finalcut::make_unique<test::FSystemTest>();
finalcut::FTerm::setFSystem(fsys); finalcut::FTerm::setFSystem(fsys);
std::cout << "\n"; std::cout << "\n";
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
auto& encoding_list = data.getEncodingList(); auto& encoding_list = data.getEncodingList();
encoding_list["UTF-8"] = finalcut::Encoding::UTF8; encoding_list["UTF-8"] = finalcut::Encoding::UTF8;
@ -2316,7 +2316,7 @@ void FTermLinuxTest::linuxCursorStyleTest()
// setupterm is needed for tputs in ncurses >= 6.1 // setupterm is needed for tputs in ncurses >= 6.1
setupterm (static_cast<char*>(0), 1, static_cast<int*>(0)); setupterm (static_cast<char*>(0), 1, static_cast<int*>(0));
auto& term_detection = finalcut::FTerm::getFTermDetection(); auto& term_detection = finalcut::FTermDetection::getInstance();
finalcut::FTermLinux linux; finalcut::FTermLinux linux;
pid_t pid = forkConEmu(); pid_t pid = forkConEmu();
@ -2340,7 +2340,7 @@ void FTermLinuxTest::linuxCursorStyleTest()
term_detection.detect(); term_detection.detect();
linux.init(); linux.init();
const auto& fsystem = finalcut::FTerm::getFSystem(); const auto& fsystem = finalcut::FSystem::getInstance();
auto fsystest = static_cast<test::FSystemTest*>(fsystem.get()); auto fsystest = static_cast<test::FSystemTest*>(fsystem.get());
std::string& characters = fsystest->getCharacters(); std::string& characters = fsystest->getCharacters();
characters.clear(); characters.clear();
@ -2472,7 +2472,7 @@ void FTermLinuxTest::linuxColorPaletteTest()
std::unique_ptr<finalcut::FSystem> fsys = finalcut::make_unique<test::FSystemTest>(); std::unique_ptr<finalcut::FSystem> fsys = finalcut::make_unique<test::FSystemTest>();
finalcut::FTerm::setFSystem(fsys); finalcut::FTerm::setFSystem(fsys);
std::cout << "\n"; std::cout << "\n";
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
auto& encoding_list = data.getEncodingList(); auto& encoding_list = data.getEncodingList();
encoding_list["UTF-8"] = finalcut::Encoding::UTF8; encoding_list["UTF-8"] = finalcut::Encoding::UTF8;
@ -2506,7 +2506,7 @@ void FTermLinuxTest::linuxColorPaletteTest()
// setupterm is needed for tputs in ncurses >= 6.1 // setupterm is needed for tputs in ncurses >= 6.1
setupterm (static_cast<char*>(0), 1, static_cast<int*>(0)); setupterm (static_cast<char*>(0), 1, static_cast<int*>(0));
auto& term_detection = finalcut::FTerm::getFTermDetection(); auto& term_detection = finalcut::FTermDetection::getInstance();
finalcut::FTermLinux linux; finalcut::FTermLinux linux;
term_detection.setLinuxTerm(true); term_detection.setLinuxTerm(true);
@ -2530,7 +2530,7 @@ void FTermLinuxTest::linuxColorPaletteTest()
term_detection.detect(); term_detection.detect();
linux.init(); linux.init();
const auto& fsystem = finalcut::FTerm::getFSystem(); const auto& fsystem = finalcut::FSystem::getInstance();
auto fsystest = static_cast<test::FSystemTest*>(fsystem.get()); auto fsystest = static_cast<test::FSystemTest*>(fsystem.get());
CPPUNIT_ASSERT ( linux.resetColorMap() == true ); CPPUNIT_ASSERT ( linux.resetColorMap() == true );
@ -2748,7 +2748,7 @@ void FTermLinuxTest::linuxFontTest()
std::unique_ptr<finalcut::FSystem> fsys = finalcut::make_unique<test::FSystemTest>(); std::unique_ptr<finalcut::FSystem> fsys = finalcut::make_unique<test::FSystemTest>();
finalcut::FTerm::setFSystem(fsys); finalcut::FTerm::setFSystem(fsys);
std::cout << "\n"; std::cout << "\n";
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
auto& encoding_list = data.getEncodingList(); auto& encoding_list = data.getEncodingList();
encoding_list["UTF-8"] = finalcut::Encoding::UTF8; encoding_list["UTF-8"] = finalcut::Encoding::UTF8;
@ -2782,7 +2782,7 @@ void FTermLinuxTest::linuxFontTest()
// setupterm is needed for tputs in ncurses >= 6.1 // setupterm is needed for tputs in ncurses >= 6.1
setupterm (static_cast<char*>(0), 1, static_cast<int*>(0)); setupterm (static_cast<char*>(0), 1, static_cast<int*>(0));
auto& term_detection = finalcut::FTerm::getFTermDetection(); auto& term_detection = finalcut::FTermDetection::getInstance();
finalcut::FTermLinux linux; finalcut::FTermLinux linux;
pid_t pid = forkConEmu(); pid_t pid = forkConEmu();
@ -2805,7 +2805,7 @@ void FTermLinuxTest::linuxFontTest()
term_detection.detect(); term_detection.detect();
linux.init(); linux.init();
const auto& fsystem = finalcut::FTerm::getFSystem(); const auto& fsystem = finalcut::FSystem::getInstance();
auto fsystest = static_cast<test::FSystemTest*>(fsystem.get()); auto fsystest = static_cast<test::FSystemTest*>(fsystem.get());
console_font_op& font = fsystest->getConsoleFont(); console_font_op& font = fsystest->getConsoleFont();
CPPUNIT_ASSERT ( font.op == KD_FONT_OP_GET ); CPPUNIT_ASSERT ( font.op == KD_FONT_OP_GET );
@ -2892,7 +2892,7 @@ void FTermLinuxTest::modifierKeyTest()
std::unique_ptr<finalcut::FSystem> fsys = finalcut::make_unique<test::FSystemTest>(); std::unique_ptr<finalcut::FSystem> fsys = finalcut::make_unique<test::FSystemTest>();
finalcut::FTerm::setFSystem(fsys); finalcut::FTerm::setFSystem(fsys);
const auto& fsystem = finalcut::FTerm::getFSystem(); const auto& fsystem = finalcut::FSystem::getInstance();
auto fsystest = static_cast<test::FSystemTest*>(fsystem.get()); auto fsystest = static_cast<test::FSystemTest*>(fsystem.get());
test::FSystemTest::ShiftState& mod_key = fsystest->getShiftState(); test::FSystemTest::ShiftState& mod_key = fsystest->getShiftState();
finalcut::FTermLinux linux{}; finalcut::FTermLinux linux{};

View File

@ -344,7 +344,7 @@ void ftermopenbsdTest::netbsdConsoleTest()
std::unique_ptr<finalcut::FSystem> fsys = finalcut::make_unique<test::FSystemTest>(); std::unique_ptr<finalcut::FSystem> fsys = finalcut::make_unique<test::FSystemTest>();
finalcut::FTerm::setFSystem(fsys); finalcut::FTerm::setFSystem(fsys);
std::cout << "\n"; std::cout << "\n";
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
auto& encoding_list = data.getEncodingList(); auto& encoding_list = data.getEncodingList();
encoding_list["UTF-8"] = finalcut::Encoding::UTF8; encoding_list["UTF-8"] = finalcut::Encoding::UTF8;
@ -374,7 +374,7 @@ void ftermopenbsdTest::netbsdConsoleTest()
// setupterm is needed for tputs in ncurses >= 6.1 // setupterm is needed for tputs in ncurses >= 6.1
setupterm (static_cast<char*>(0), 1, static_cast<int*>(0)); setupterm (static_cast<char*>(0), 1, static_cast<int*>(0));
auto& term_detection = finalcut::FTerm::getFTermDetection(); auto& term_detection = finalcut::FTermDetection::getInstance();
term_detection.setTerminalDetection(true); term_detection.setTerminalDetection(true);
pid_t pid = forkConEmu(); pid_t pid = forkConEmu();
@ -403,7 +403,7 @@ void ftermopenbsdTest::netbsdConsoleTest()
#if DEBUG #if DEBUG
const finalcut::FString& sec_da = \ const finalcut::FString& sec_da = \
finalcut::FTerm::getFTermDebugData().getSecDAString(); finalcut::FTermDebugData::getInstance().getSecDAString();
CPPUNIT_ASSERT ( sec_da == "\033[>24;20;0c" ); CPPUNIT_ASSERT ( sec_da == "\033[>24;20;0c" );
#endif #endif
@ -449,7 +449,7 @@ void ftermopenbsdTest::openbsdConsoleTest()
std::unique_ptr<finalcut::FSystem> fsys = finalcut::make_unique<test::FSystemTest>(); std::unique_ptr<finalcut::FSystem> fsys = finalcut::make_unique<test::FSystemTest>();
finalcut::FTerm::setFSystem(fsys); finalcut::FTerm::setFSystem(fsys);
std::cout << "\n"; std::cout << "\n";
auto& data = finalcut::FTerm::getFTermData(); auto& data = finalcut::FTermData::getInstance();
auto& encoding_list = data.getEncodingList(); auto& encoding_list = data.getEncodingList();
encoding_list["UTF-8"] = finalcut::Encoding::UTF8; encoding_list["UTF-8"] = finalcut::Encoding::UTF8;
@ -479,7 +479,7 @@ void ftermopenbsdTest::openbsdConsoleTest()
// setupterm is needed for tputs in ncurses >= 6.1 // setupterm is needed for tputs in ncurses >= 6.1
setupterm (static_cast<char*>(0), 1, static_cast<int*>(0)); setupterm (static_cast<char*>(0), 1, static_cast<int*>(0));
auto& term_detection = finalcut::FTerm::getFTermDetection(); auto& term_detection = finalcut::FTermDetection::getInstance();
term_detection.setTerminalDetection(true); term_detection.setTerminalDetection(true);
pid_t pid = forkConEmu(); pid_t pid = forkConEmu();
@ -501,7 +501,7 @@ void ftermopenbsdTest::openbsdConsoleTest()
unsetenv("KONSOLE_DCOP"); unsetenv("KONSOLE_DCOP");
unsetenv("TMUX"); unsetenv("TMUX");
const auto& fsystem = finalcut::FTerm::getFSystem(); const auto& fsystem = finalcut::FSystem::getInstance();
auto fsystest = static_cast<test::FSystemTest*>(fsystem.get()); auto fsystest = static_cast<test::FSystemTest*>(fsystem.get());
wskbd_bell_data& speaker = fsystest->getBell(); wskbd_bell_data& speaker = fsystest->getBell();
openbsd.disableMetaSendsEscape(); openbsd.disableMetaSendsEscape();
@ -511,7 +511,7 @@ void ftermopenbsdTest::openbsdConsoleTest()
#if DEBUG #if DEBUG
const finalcut::FString& sec_da = \ const finalcut::FString& sec_da = \
finalcut::FTerm::getFTermDebugData().getSecDAString(); finalcut::FTermDebugData::getInstance().getSecDAString();
CPPUNIT_ASSERT ( sec_da == "\033[>24;20;0c" ); CPPUNIT_ASSERT ( sec_da == "\033[>24;20;0c" );
#endif #endif