Using smart pointers for global objects

This commit is contained in:
Markus Gans 2020-12-03 10:43:20 +01:00
parent 7868a0dee9
commit 4517038521
75 changed files with 800 additions and 1315 deletions

View File

@ -122,7 +122,7 @@ class Calc final : public finalcut::FDialog
private: private:
// Typedef and Enumeration // Typedef and Enumeration
typedef std::function<void(lDouble&)> keyFunction; // Member function using keyFunction = std::function<void(lDouble&)>; // Member function
enum button enum button
{ {

View File

@ -51,7 +51,7 @@ class EventDialog final : public finalcut::FDialog
EventDialog (const EventDialog&) = delete; EventDialog (const EventDialog&) = delete;
// Destructor // Destructor
~EventDialog() override; ~EventDialog() noexcept override;
// Disable copy assignment operator (=) // Disable copy assignment operator (=)
EventDialog& operator = (const EventDialog&) = delete; EventDialog& operator = (const EventDialog&) = delete;
@ -99,8 +99,7 @@ EventDialog::EventDialog (finalcut::FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
EventDialog::~EventDialog() // destructor EventDialog::~EventDialog() noexcept = default; // destructor
{ }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
finalcut::FString EventDialog::getMouseButtonName (int btn_state) const finalcut::FString EventDialog::getMouseButtonName (int btn_state) const
@ -245,7 +244,7 @@ class EventLog final : public finalcut::FDialog, public std::ostringstream
EventLog (const EventLog&) = delete; EventLog (const EventLog&) = delete;
// Destructor // Destructor
~EventLog() override; ~EventLog() noexcept override;
// Disable copy assignment operator (=) // Disable copy assignment operator (=)
EventLog& operator = (const EventLog&) = delete; EventLog& operator = (const EventLog&) = delete;
@ -282,8 +281,7 @@ EventLog::EventLog (finalcut::FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
EventLog::~EventLog() // destructor EventLog::~EventLog() noexcept = default; // destructor
{ }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void EventLog::onTimer (finalcut::FTimerEvent*) void EventLog::onTimer (finalcut::FTimerEvent*)

View File

@ -50,7 +50,7 @@ void doubleToItem ( FListBoxItem& item
, FDataAccess* container , FDataAccess* container
, std::size_t index ) , std::size_t index )
{ {
typedef std::list<double> DblList; using DblList = std::list<double>;
DblList& dbl_list = flistboxhelper::getContainer<DblList>(container); DblList& dbl_list = flistboxhelper::getContainer<DblList>(container);
std::list<double>::iterator iter = dbl_list.begin(); std::list<double>::iterator iter = dbl_list.begin();
std::advance (iter, index); std::advance (iter, index);

View File

@ -136,10 +136,10 @@ class DirectLogger final : public finalcut::FLog
{ {
public: public:
// Constructor // Constructor
DirectLogger(); DirectLogger() = default;
// Destructor // Destructor
~DirectLogger() override; ~DirectLogger() noexcept override;
void info (const std::string& entry) override void info (const std::string& entry) override
{ {
@ -194,12 +194,7 @@ class DirectLogger final : public finalcut::FLog
}; };
//---------------------------------------------------------------------- //----------------------------------------------------------------------
DirectLogger::DirectLogger() // constructor DirectLogger::~DirectLogger() noexcept = default; // destructor
{ }
//----------------------------------------------------------------------
DirectLogger::~DirectLogger() // destructor
{ }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -212,22 +212,22 @@ void tcapString (const std::string& name, const char cap_str[])
void debug (const finalcut::FApplication& TermApp) void debug (const finalcut::FApplication& TermApp)
{ {
const auto& fterm = TermApp.getFTerm(); const auto& fterm = TermApp.getFTerm();
auto& debug_data = fterm.getFTermDebugData(); const auto& debug_data = fterm.getFTermDebugData();
const finalcut::FString& ab_s = debug_data.getAnswerbackString(); const finalcut::FString& ab_s = debug_data->getAnswerbackString();
const finalcut::FString& sec_da = debug_data.getSecDAString(); const finalcut::FString& sec_da = debug_data->getSecDAString();
std::cout << "\n.------------------- debug -------------------\r\n"; std::cout << "\n.------------------- debug -------------------\r\n";
#if defined(__linux__) #if defined(__linux__)
std::cout << "| Framebuffer bpp: " std::cout << "| Framebuffer bpp: "
<< debug_data.getFramebufferBpp() << "\r\n"; << debug_data->getFramebufferBpp() << "\r\n";
#endif #endif
std::cout << "| after init_256colorTerminal(): " std::cout << "| after init_256colorTerminal(): "
<< debug_data.getTermType_256color() << "\r\n"; << debug_data->getTermType_256color() << "\r\n";
std::cout << "| after parseAnswerbackMsg(): " std::cout << "| after parseAnswerbackMsg(): "
<< debug_data.getTermType_Answerback() << "\r\n"; << debug_data->getTermType_Answerback() << "\r\n";
std::cout << "| after parseSecDA(): " std::cout << "| after parseSecDA(): "
<< debug_data.getTermType_SecDA() << "\r\n"; << debug_data->getTermType_SecDA() << "\r\n";
if ( ! ab_s.isEmpty() ) if ( ! ab_s.isEmpty() )
tcapString ("| The answerback String", ab_s.c_str()); tcapString ("| The answerback String", ab_s.c_str());

View File

@ -161,12 +161,12 @@ class Treeview final : public finalcut::FDialog
struct TreeItem; // forward declaration struct TreeItem; // forward declaration
// Methods // Methods
auto initAfrica() -> std::initializer_list<TreeItem>; auto initAfrica() -> std::initializer_list<TreeItem> const;
auto initAsia() -> std::initializer_list<TreeItem>; auto initAsia() -> std::initializer_list<TreeItem> const;
auto initEurope() -> std::initializer_list<TreeItem>; auto initEurope() -> std::initializer_list<TreeItem> const;
auto initNorthAmerica() -> std::initializer_list<TreeItem>; auto initNorthAmerica() -> std::initializer_list<TreeItem> const;
auto initSouthAmerica() -> std::initializer_list<TreeItem>; auto initSouthAmerica() -> std::initializer_list<TreeItem> const;
auto initOceania() -> std::initializer_list<TreeItem>; auto initOceania() -> std::initializer_list<TreeItem> const;
void adjustSize() override; void adjustSize() override;
// Event handler // Event handler
@ -275,7 +275,7 @@ Treeview::Treeview (finalcut::FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
auto Treeview::initAfrica() -> std::initializer_list<Treeview::TreeItem> auto Treeview::initAfrica() -> std::initializer_list<Treeview::TreeItem> const
{ {
static const auto list = std::initializer_list<Treeview::TreeItem> static const auto list = std::initializer_list<Treeview::TreeItem>
{ {
@ -306,7 +306,7 @@ auto Treeview::initAfrica() -> std::initializer_list<Treeview::TreeItem>
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
auto Treeview::initAsia() -> std::initializer_list<Treeview::TreeItem> auto Treeview::initAsia() -> std::initializer_list<Treeview::TreeItem> const
{ {
static const auto list = std::initializer_list<Treeview::TreeItem> static const auto list = std::initializer_list<Treeview::TreeItem>
{ {
@ -334,7 +334,7 @@ auto Treeview::initAsia() -> std::initializer_list<Treeview::TreeItem>
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
auto Treeview::initEurope() -> std::initializer_list<Treeview::TreeItem> auto Treeview::initEurope() -> std::initializer_list<Treeview::TreeItem> const
{ {
static const auto list = std::initializer_list<Treeview::TreeItem> static const auto list = std::initializer_list<Treeview::TreeItem>
{ {
@ -362,7 +362,7 @@ auto Treeview::initEurope() -> std::initializer_list<Treeview::TreeItem>
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
auto Treeview::initNorthAmerica() -> std::initializer_list<Treeview::TreeItem> auto Treeview::initNorthAmerica() -> std::initializer_list<Treeview::TreeItem> const
{ {
static const auto list = std::initializer_list<Treeview::TreeItem> static const auto list = std::initializer_list<Treeview::TreeItem>
{ {
@ -379,7 +379,7 @@ auto Treeview::initNorthAmerica() -> std::initializer_list<Treeview::TreeItem>
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
auto Treeview::initSouthAmerica() -> std::initializer_list<Treeview::TreeItem> auto Treeview::initSouthAmerica() -> std::initializer_list<Treeview::TreeItem> const
{ {
static const auto list = std::initializer_list<Treeview::TreeItem> static const auto list = std::initializer_list<Treeview::TreeItem>
{ {
@ -398,7 +398,7 @@ auto Treeview::initSouthAmerica() -> std::initializer_list<Treeview::TreeItem>
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
auto Treeview::initOceania() -> std::initializer_list<Treeview::TreeItem> auto Treeview::initOceania() -> std::initializer_list<Treeview::TreeItem> const
{ {
static const auto list = std::initializer_list<Treeview::TreeItem> static const auto list = std::initializer_list<Treeview::TreeItem>
{ {

View File

@ -68,8 +68,6 @@ FWidget* FWidget::clicked_widget {nullptr}; // is focused by click
FWidget* FWidget::open_menu {nullptr}; // currently open menu FWidget* FWidget::open_menu {nullptr}; // currently open menu
FWidget* FWidget::move_size_widget {nullptr}; // move/size by keyboard FWidget* FWidget::move_size_widget {nullptr}; // move/size by keyboard
FWidget* FApplication::keyboard_widget {nullptr}; // has the keyboard focus FWidget* FApplication::keyboard_widget {nullptr}; // has the keyboard focus
FKeyboard* FApplication::keyboard {nullptr}; // keyboard access
FMouseControl* FApplication::mouse {nullptr}; // mouse control
int FApplication::loop_level {0}; // event loop level int FApplication::loop_level {0}; // event loop level
int FApplication::quit_code {EXIT_SUCCESS}; int FApplication::quit_code {EXIT_SUCCESS};
bool FApplication::quit_now {false}; bool FApplication::quit_now {false};
@ -93,9 +91,9 @@ FApplication::FApplication (const int& _argc, char* _argv[])
if ( internal::var::app_object ) if ( internal::var::app_object )
{ {
auto ftermdata = FTerm::getFTermData(); const auto& fterm_data = FTerm::getFTermData();
ftermdata->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);
return; return;
} }
@ -105,7 +103,7 @@ FApplication::FApplication (const int& _argc, char* _argv[])
if ( ! (_argc && _argv) ) if ( ! (_argc && _argv) )
{ {
typedef char* CString; using CString = char*;
static std::array<CString, 1> empty{{CString("")}}; static std::array<CString, 1> empty{{CString("")}};
app_argc = 0; app_argc = 0;
app_argv = empty.data(); app_argv = empty.data();
@ -350,9 +348,9 @@ void FApplication::setLogFile (const FString& filename)
} }
else else
{ {
auto ftermdata = FTerm::getFTermData(); const auto& fterm_data = FTerm::getFTermData();
ftermdata->setExitMessage ( "Could not open log file \"" fterm_data->setExitMessage ( "Could not open log file \""
+ filename + "\"" ); + filename + "\"" );
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
@ -405,41 +403,32 @@ void FApplication::init()
time_last_event.tv_usec = 0; time_last_event.tv_usec = 0;
// Initialize keyboard // Initialize keyboard
keyboard = FTerm::getFKeyboard(); const auto& keyboard = FTerm::getFKeyboard();
auto cmd1 = std::bind(&FApplication::keyPressed, this);
auto cmd2 = std::bind(&FApplication::keyReleased, this);
if ( keyboard ) auto cmd3 = std::bind(&FApplication::escapeKeyPressed, this);
{ auto cmd4 = std::bind(&FApplication::mouseTracking, this);
auto cmd1 = std::bind(&FApplication::keyPressed, this); FKeyboardCommand key_cmd1 (cmd1);
auto cmd2 = std::bind(&FApplication::keyReleased, this); FKeyboardCommand key_cmd2 (cmd2);
auto cmd3 = std::bind(&FApplication::escapeKeyPressed, this); FKeyboardCommand key_cmd3 (cmd3);
auto cmd4 = std::bind(&FApplication::mouseTracking, this); FKeyboardCommand key_cmd4 (cmd4);
FKeyboardCommand key_cmd1 (cmd1); keyboard->setPressCommand (key_cmd1);
FKeyboardCommand key_cmd2 (cmd2); keyboard->setReleaseCommand (key_cmd2);
FKeyboardCommand key_cmd3 (cmd3); keyboard->setEscPressedCommand (key_cmd3);
FKeyboardCommand key_cmd4 (cmd4); keyboard->setMouseTrackingCommand (key_cmd4);
keyboard->setPressCommand (key_cmd1); // Set the keyboard keypress timeout
keyboard->setReleaseCommand (key_cmd2); keyboard->setKeypressTimeout (key_timeout);
keyboard->setEscPressedCommand (key_cmd3);
keyboard->setMouseTrackingCommand (key_cmd4);
// Set the keyboard keypress timeout
keyboard->setKeypressTimeout (key_timeout);
}
// Initialize mouse control // Initialize mouse control
mouse = FTerm::getFMouseControl(); const auto& mouse = FTerm::getFMouseControl();
using namespace std::placeholders;
if ( mouse ) auto cmd = std::bind(&FApplication::mouseEvent, this, _1);
{ FMouseCommand mouse_cmd (cmd);
using namespace std::placeholders; mouse->setEventCommand (mouse_cmd);
auto cmd = std::bind(&FApplication::mouseEvent, this, _1); // Set stdin number for a gpm-mouse
FMouseCommand mouse_cmd (cmd); mouse->setStdinNo (FTermios::getStdIn());
mouse->setEventCommand (mouse_cmd); // Set the default double click interval
// Set stdin number for a gpm-mouse mouse->setDblclickInterval (dblclick_interval);
mouse->setStdinNo (FTermios::getStdIn());
// Set the default double click interval
mouse->setDblclickInterval (dblclick_interval);
}
// Initialize logging // Initialize logging
if ( ! getStartOptions().logfile_stream.is_open() ) if ( ! getStartOptions().logfile_stream.is_open() )
@ -463,10 +452,10 @@ void FApplication::setTerminalEncoding (const FString& enc_str)
showParameterUsage(); showParameterUsage();
else else
{ {
auto ftermdata = FTerm::getFTermData(); const auto& fterm_data = FTerm::getFTermData();
ftermdata->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)" );
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
@ -665,7 +654,10 @@ inline void FApplication::findKeyboardWidget() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FApplication::isKeyPressed() const inline bool FApplication::isKeyPressed() const
{ {
if ( mouse && mouse->isGpmMouseEnabled() ) const auto& mouse = FTerm::getFMouseControl();
const auto& keyboard = FTerm::getFKeyboard();
if ( mouse->isGpmMouseEnabled() )
return mouse->getGpmKeyPressed(keyboard->hasUnprocessedInput()); return mouse->getGpmKeyPressed(keyboard->hasUnprocessedInput());
return (keyboard->isKeyPressed() || keyboard->hasPendingInput()); return (keyboard->isKeyPressed() || keyboard->hasPendingInput());
@ -698,6 +690,8 @@ void FApplication::mouseTracking() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FApplication::performKeyboardAction() inline void FApplication::performKeyboardAction()
{ {
const auto& keyboard = FTerm::getFKeyboard();
if ( keyboard->getKey() == fc::Fckey_l ) // Ctrl-L (redraw the screen) if ( keyboard->getKey() == fc::Fckey_l ) // Ctrl-L (redraw the screen)
{ {
redraw(); redraw();
@ -715,9 +709,8 @@ inline void FApplication::performKeyboardAction()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FApplication::performMouseAction() const inline void FApplication::performMouseAction() const
{ {
if ( ! mouse ) const auto& mouse = FTerm::getFMouseControl();
return; const auto& keyboard = FTerm::getFKeyboard();
auto& buffer = keyboard->getKeyBuffer(); auto& buffer = keyboard->getKeyBuffer();
switch ( keyboard->getKey() ) switch ( keyboard->getKey() )
@ -768,6 +761,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();
FKeyEvent k_down_ev (fc::KeyDown_Event, keyboard->getKey()); FKeyEvent k_down_ev (fc::KeyDown_Event, keyboard->getKey());
sendEvent (widget, &k_down_ev); sendEvent (widget, &k_down_ev);
return k_down_ev.isAccepted(); return k_down_ev.isAccepted();
@ -777,6 +771,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();
FKeyEvent k_press_ev (fc::KeyPress_Event, keyboard->getKey()); FKeyEvent k_press_ev (fc::KeyPress_Event, keyboard->getKey());
sendEvent (widget, &k_press_ev); sendEvent (widget, &k_press_ev);
return k_press_ev.isAccepted(); return k_press_ev.isAccepted();
@ -786,6 +781,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();
FKeyEvent k_up_ev (fc::KeyUp_Event, keyboard->getKey()); FKeyEvent k_up_ev (fc::KeyUp_Event, keyboard->getKey());
sendEvent (widget, &k_up_ev); sendEvent (widget, &k_up_ev);
return k_up_ev.isAccepted(); return k_up_ev.isAccepted();
@ -822,9 +818,12 @@ inline void FApplication::sendKeyboardAccelerator()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FApplication::hasDataInQueue() const inline bool FApplication::hasDataInQueue() const
{ {
if ( keyboard && keyboard->hasDataInQueue() ) const auto& keyboard = FTerm::getFKeyboard();
const auto& mouse = FTerm::getFMouseControl();
if ( keyboard->hasDataInQueue() )
return true; return true;
else if ( mouse && mouse->hasDataInQueue() ) else if ( mouse->hasDataInQueue() )
return true; return true;
return false; return false;
@ -833,10 +832,11 @@ inline bool FApplication::hasDataInQueue() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::queuingKeyboardInput() const void FApplication::queuingKeyboardInput() const
{ {
if ( quit_now || internal::var::exit_loop || ! keyboard ) if ( quit_now || internal::var::exit_loop )
return; return;
findKeyboardWidget(); findKeyboardWidget();
const auto& keyboard = FTerm::getFKeyboard();
keyboard->escapeKeyHandling(); // special case: Esc key keyboard->escapeKeyHandling(); // special case: Esc key
keyboard->clearKeyBufferOnTimeout(); keyboard->clearKeyBufferOnTimeout();
@ -847,10 +847,12 @@ void FApplication::queuingKeyboardInput() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::queuingMouseInput() const void FApplication::queuingMouseInput() const
{ {
if ( quit_now || internal::var::exit_loop const auto& mouse = FTerm::getFMouseControl();
|| ! mouse || ! mouse->hasData() )
if ( quit_now || internal::var::exit_loop || ! mouse->hasData() )
return; return;
const auto& keyboard = FTerm::getFKeyboard();
struct timeval* time_keypressed = keyboard->getKeyPressedTime(); struct timeval* time_keypressed = keyboard->getKeyPressedTime();
mouse->processEvent (time_keypressed); mouse->processEvent (time_keypressed);
keyboard->hasUnprocessedInput() = mouse->hasUnprocessedInput(); keyboard->hasUnprocessedInput() = mouse->hasUnprocessedInput();
@ -860,24 +862,27 @@ void FApplication::queuingMouseInput() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::processKeyboardEvent() const void FApplication::processKeyboardEvent() const
{ {
if ( quit_now || internal::var::exit_loop || ! keyboard ) if ( quit_now || internal::var::exit_loop )
return; return;
const auto& keyboard = FTerm::getFKeyboard();
keyboard->processQueuedInput(); keyboard->processQueuedInput();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FApplication::processMouseEvent() const void FApplication::processMouseEvent() const
{ {
if ( quit_now || internal::var::exit_loop || ! mouse ) if ( quit_now || internal::var::exit_loop )
return; return;
mouse->processQueuedInput(); FTerm::getFMouseControl()->processQueuedInput();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FApplication::processDialogSwitchAccelerator() const bool FApplication::processDialogSwitchAccelerator() const
{ {
const auto& keyboard = FTerm::getFKeyboard();
if ( keyboard->getKey() >= fc::Fmkey_1 if ( keyboard->getKey() >= fc::Fmkey_1
&& keyboard->getKey() <= fc::Fmkey_9 ) && keyboard->getKey() <= fc::Fmkey_9 )
{ {
@ -914,7 +919,7 @@ bool FApplication::processAccelerator (const FWidget& widget) const
for (auto&& item : widget.getAcceleratorList()) for (auto&& item : widget.getAcceleratorList())
{ {
if ( item.key == keyboard->getKey() ) if ( item.key == FTerm::getFKeyboard()->getKey() )
{ {
// unset the move/size mode // unset the move/size mode
auto move_size = getMoveSizeWidget(); auto move_size = getMoveSizeWidget();
@ -1244,12 +1249,9 @@ void FApplication::processResizeEvent() const
if ( ! FTerm::hasChangedTermSize() ) if ( ! FTerm::hasChangedTermSize() )
return; return;
if ( mouse ) const auto& mouse = FTerm::getFMouseControl();
{ mouse->setMaxWidth (uInt16(getDesktopWidth()));
mouse->setMaxWidth (uInt16(getDesktopWidth())); mouse->setMaxHeight (uInt16(getDesktopHeight()));
mouse->setMaxHeight (uInt16(getDesktopHeight()));
}
FResizeEvent r_ev(fc::Resize_Event); FResizeEvent r_ev(fc::Resize_Event);
sendEvent(internal::var::app_object, &r_ev); sendEvent(internal::var::app_object, &r_ev);

View File

@ -39,8 +39,7 @@ FBusyIndicator::FBusyIndicator (FWidget* parent)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FBusyIndicator::~FBusyIndicator() // destructor FBusyIndicator::~FBusyIndicator() noexcept = default; // destructor
{ }
// public methods of FBusyIndicator // public methods of FBusyIndicator

View File

@ -374,7 +374,7 @@ void FButtonGroup::drawLabel()
else else
FWidget::setPrintPos (FPoint{0, 1}); FWidget::setPrintPos (FPoint{0, 1});
drawText (std::move(label_text), hotkeypos); drawText (label_text, hotkeypos);
setViewportPrint(); setViewportPrint();
} }
@ -397,7 +397,7 @@ void FButtonGroup::init()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FButtonGroup::drawText ( FString&& label_text void FButtonGroup::drawText ( const FString& label_text
, std::size_t hotkeypos ) , std::size_t hotkeypos )
{ {
const auto& wc = getColorTheme(); const auto& wc = getColorTheme();

View File

@ -29,16 +29,6 @@ namespace finalcut
// class FCallback // class FCallback
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// constructors and destructor
//----------------------------------------------------------------------
FCallback::FCallback()
{ }
//----------------------------------------------------------------------
FCallback::~FCallback() // destructor
{ }
// public methods of FCallback // public methods of FCallback
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FCallback::delCallback (const FString& cb_signal) void FCallback::delCallback (const FString& cb_signal)

View File

@ -36,8 +36,7 @@ FColorPalette::FColorPalette (const FSetPalette& f)
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FColorPalette::~FColorPalette() // destructor FColorPalette::~FColorPalette() noexcept = default; // destructor
{ }
// protected methods of FColorPalette // protected methods of FColorPalette
@ -79,8 +78,8 @@ default8ColorPalette::default8ColorPalette (const FSetPalette& f)
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
default8ColorPalette::~default8ColorPalette() default8ColorPalette::~default8ColorPalette() noexcept = default; // destructor
{ }
// public methods of default8ColorPalette // public methods of default8ColorPalette
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -123,8 +122,8 @@ default16ColorPalette::default16ColorPalette (const FSetPalette& f)
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
default16ColorPalette::~default16ColorPalette() default16ColorPalette::~default16ColorPalette() noexcept = default; // destructor
{ }
// public methods of default16ColorPalette // public methods of default16ColorPalette
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -166,8 +165,8 @@ default16DarkColorPalette::default16DarkColorPalette (const FSetPalette& f)
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
default16DarkColorPalette::~default16DarkColorPalette() default16DarkColorPalette::~default16DarkColorPalette() noexcept = default; // destructor
{ }
// public methods of default16DarkColorPalette // public methods of default16DarkColorPalette
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -31,12 +31,7 @@ namespace finalcut
// constructors and destructor // constructors and destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FDataAccess::FDataAccess() FDataAccess::~FDataAccess() noexcept = default; // destructor
{ }
//----------------------------------------------------------------------
FDataAccess::~FDataAccess() // destructor
{ }
} // namespace finalcut } // namespace finalcut

View File

@ -623,7 +623,7 @@ void FDialog::onMouseMove (FMouseEvent* ev)
// Mouse event handover to the menu // Mouse event handover to the menu
if ( ms.mouse_over_menu ) if ( ms.mouse_over_menu )
passEventToSubMenu (ms, std::move(*ev)); passEventToSubMenu (ms, *ev);
leaveZoomButton(ms); // Check zoom button pressed leaveZoomButton(ms); // Check zoom button pressed
resizeMouseUpMove(ms); // Resize the dialog resizeMouseUpMove(ms); // Resize the dialog
@ -1361,7 +1361,7 @@ inline bool FDialog::isMouseOverMenu (const FPoint& termpos) const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FDialog::passEventToSubMenu ( const MouseStates& ms inline void FDialog::passEventToSubMenu ( const MouseStates& ms
, const FMouseEvent&& ev ) , const FMouseEvent& ev )
{ {
// Mouse event handover to the dialog menu // Mouse event handover to the dialog menu
if ( ! ms.mouse_over_menu if ( ! ms.mouse_over_menu

View File

@ -89,9 +89,6 @@ FString fileChooser ( FWidget* parent
return ret; return ret;
} }
// static class attributes
FSystem* FFileDialog::fsystem{nullptr};
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FFileDialog // class FFileDialog
@ -202,7 +199,9 @@ void FFileDialog::setPath (const FString& dir)
return; return;
} }
if ( fsystem && fsystem->realpath(dir.c_str(), resolved_path.data()) != nullptr ) const auto& fsystem = FTerm::getFSystem();
if ( fsystem->realpath(dir.c_str(), resolved_path.data()) != nullptr )
r_dir.setString(resolved_path.data()); r_dir.setString(resolved_path.data());
else else
r_dir.setString(dir); r_dir.setString(dir);
@ -324,9 +323,6 @@ void FFileDialog::init()
int x{}; int x{};
int y{}; int y{};
if ( ! fsystem )
fsystem = FTerm::getFSystem();
setGeometry(FPoint{1, 1}, FSize{w, h}, false); setGeometry(FPoint{1, 1}, FSize{w, h}, false);
const auto& parent_widget = getParentWidget(); const auto& parent_widget = getParentWidget();
@ -600,9 +596,7 @@ void FFileDialog::followSymLink (const char* const dir, FDirEntry& entry) const
std::array<char, MAXPATHLEN> symLink{}; std::array<char, MAXPATHLEN> symLink{};
struct stat sb{}; struct stat sb{};
if ( ! fsystem ) const auto& fsystem = FTerm::getFSystem();
fsystem = FTerm::getFSystem();
std::strncpy (symLink.data(), dir, symLink.size() - 1); std::strncpy (symLink.data(), dir, symLink.size() - 1);
symLink[symLink.size() - 1] = '\0'; symLink[symLink.size() - 1] = '\0';
std::strncat ( symLink.data() std::strncat ( symLink.data()
@ -666,9 +660,6 @@ int FFileDialog::changeDir (const FString& dirname)
FString lastdir{directory}; FString lastdir{directory};
FString newdir{dirname}; FString newdir{dirname};
if ( ! fsystem )
fsystem = FTerm::getFSystem();
if ( newdir.includes('~') ) if ( newdir.includes('~') )
newdir = newdir.replace('~', getHomeDir()); newdir = newdir.replace('~', getHomeDir());
@ -743,9 +734,7 @@ FString FFileDialog::getHomeDir()
struct passwd* pwd_ptr{}; struct passwd* pwd_ptr{};
std::array<char, 1024> buf{}; std::array<char, 1024> buf{};
if ( ! fsystem ) const auto& fsystem = FTerm::getFSystem();
fsystem = FTerm::getFSystem();
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

@ -23,9 +23,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#if defined(__sun) && defined(__SVR4) #if defined(__CYGWIN__)
#include <sys/filio.h> // need for FIONREAD
#elif defined(__CYGWIN__)
#include <sys/select.h> // need for FD_ZERO, FD_SET, FD_CLR, ... #include <sys/select.h> // need for FD_ZERO, FD_SET, FD_CLR, ...
#endif #endif
@ -55,10 +53,6 @@ uInt64 FKeyboard::read_blocking_time_short{5000}; // 5 ms (200 Hz)
bool FKeyboard::non_blocking_input_support{true}; bool FKeyboard::non_blocking_input_support{true};
struct timeval FKeyboard::time_keypressed{}; struct timeval FKeyboard::time_keypressed{};
#if defined(__linux__)
FTermLinux* FKeyboard::linux{nullptr};
#endif
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FKeyboard // class FKeyboard
@ -77,8 +71,6 @@ FKeyboard::FKeyboard()
if ( stdin_status_flags == -1 ) if ( stdin_status_flags == -1 )
std::abort(); std::abort();
term_detection = FTerm::getFTermDetection();
} }
@ -136,14 +128,6 @@ bool FKeyboard::setNonBlockingInput (bool enable)
return non_blocking_stdin; return non_blocking_stdin;
} }
//----------------------------------------------------------------------
void FKeyboard::init()
{
#if defined(__linux__)
linux = FTerm::getFTermLinux();
#endif
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool& FKeyboard::hasUnprocessedInput() bool& FKeyboard::hasUnprocessedInput()
{ {
@ -465,13 +449,6 @@ FKey FKeyboard::UTF8decode (const char utf8[]) const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline ssize_t FKeyboard::readKey() inline ssize_t FKeyboard::readKey()
{ {
#if !defined(__CYGWIN__)
int len{0};
if ( ioctl(FTermios::getStdIn(), FIONREAD, &len) < 0 || len == 0 )
return 0;
#endif
setNonBlockingInput(); setNonBlockingInput();
const ssize_t bytes = read(FTermios::getStdIn(), &read_character, 1); const ssize_t bytes = read(FTermios::getStdIn(), &read_character, 1);
unsetNonBlockingInput(); unsetNonBlockingInput();
@ -562,8 +539,11 @@ FKey FKeyboard::keyCorrection (const FKey& keycode) const
FKey key_correction; FKey key_correction;
#if defined(__linux__) #if defined(__linux__)
if ( linux && FTerm::isLinuxTerm() ) if ( FTerm::isLinuxTerm() )
key_correction = linux->modifierKeyCorrection(keycode); {
const auto& linux_console = FTerm::getFTermLinux();
key_correction = linux_console->modifierKeyCorrection(keycode);
}
else else
key_correction = keycode; key_correction = keycode;
#else #else

View File

@ -30,10 +30,6 @@ namespace finalcut
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// constructors and destructor // constructors and destructor
//----------------------------------------------------------------------
FLog::FLog()
{ }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FLog::~FLog() // destructor FLog::~FLog() // destructor
{ {

View File

@ -34,12 +34,7 @@ namespace finalcut
// constructors and destructor // constructors and destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FLogger::FLogger() FLogger::~FLogger() noexcept = default; // destructor
{ }
//----------------------------------------------------------------------
FLogger::~FLogger() // destructor
{ }
// private methods of FLogger // private methods of FLogger

View File

@ -279,19 +279,19 @@ void FMenu::onMouseMove (FMouseEvent* ev)
if ( ms.mouse_over_submenu ) if ( ms.mouse_over_submenu )
{ {
passEventToSubMenu(std::move(*ev)); // Event handover to sub-menu passEventToSubMenu(*ev); // Event handover to sub-menu
return; return;
} }
if ( ! ms.mouse_over_menu && ms.mouse_over_supermenu ) if ( ! ms.mouse_over_menu && ms.mouse_over_supermenu )
{ {
passEventToSuperMenu(std::move(*ev)); // Event handover to super-menu passEventToSuperMenu(*ev); // Event handover to super-menu
return; return;
} }
if ( ms.mouse_over_menubar ) if ( ms.mouse_over_menubar )
{ {
passEventToMenuBar(std::move(*ev)); // Event handover to the menu bar passEventToMenuBar(*ev); // Event handover to the menu bar
return; return;
} }
@ -908,7 +908,7 @@ void FMenu::mouseMoveOverBorder (MouseStates& ms) const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::passEventToSubMenu (const FMouseEvent&& ev) void FMenu::passEventToSubMenu (const FMouseEvent& ev)
{ {
// Mouse event handover to sub-menu // Mouse event handover to sub-menu
@ -931,7 +931,7 @@ void FMenu::passEventToSubMenu (const FMouseEvent&& ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::passEventToSuperMenu (const FMouseEvent&& ev) void FMenu::passEventToSuperMenu (const FMouseEvent& ev)
{ {
// Mouse event handover to super-menu // Mouse event handover to super-menu
@ -955,7 +955,7 @@ void FMenu::passEventToSuperMenu (const FMouseEvent&& ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::passEventToMenuBar (const FMouseEvent&& ev) const void FMenu::passEventToMenuBar (const FMouseEvent& ev) const
{ {
// Mouse event handover to the menu bar // Mouse event handover to the menu bar

View File

@ -209,7 +209,7 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
// Handle menu entries // Handle menu entries
if ( mouse_down ) if ( mouse_down )
mouseMoveOverList(std::move(*ev)); mouseMoveOverList(*ev);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -868,7 +868,7 @@ void FMenuBar::mouseUpOverList (const FMouseEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuBar::mouseMoveOverList (const FMouseEvent&& ev) void FMenuBar::mouseMoveOverList (const FMouseEvent& ev)
{ {
auto list = getItemList(); auto list = getItemList();

View File

@ -44,14 +44,10 @@ namespace finalcut
// class FMouseData // class FMouseData
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// constructors and destructor // constructor and destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FMouseData::FMouseData() FMouseData::~FMouseData() noexcept = default; // destructor
{ }
//----------------------------------------------------------------------
FMouseData::~FMouseData()
{ }
// public methods of FMouseData // public methods of FMouseData
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -182,10 +178,6 @@ FMouse::FMouse()
clearButtonState(); clearButtonState();
} }
//----------------------------------------------------------------------
FMouse::~FMouse() // destructor
{ }
// public methods of FMouse // public methods of FMouse
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1282,7 +1274,7 @@ void FMouseControl::setMaxHeight (uInt16 y_max)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseControl::setDblclickInterval (const uInt64 timeout) void FMouseControl::setDblclickInterval (const uInt64 timeout) const
{ {
for (auto&& m : mouse_protocol) for (auto&& m : mouse_protocol)
if ( m.second ) if ( m.second )
@ -1580,7 +1572,7 @@ void FMouseControl::processEvent (struct timeval* time)
{ {
mouse_object->processEvent(time); mouse_object->processEvent(time);
auto& md = static_cast<FMouseData&>(*mouse_object); auto& md = static_cast<FMouseData&>(*mouse_object);
fmousedata_queue.emplace(new FMouseData(std::move(md))); fmousedata_queue.emplace(make_unique<FMouseData>(std::move(md)));
} }
} }

View File

@ -22,7 +22,6 @@
#include <memory> #include <memory>
#include "final/emptyfstring.h"
#include "final/fevent.h" #include "final/fevent.h"
#include "final/fc.h" #include "final/fc.h"
#include "final/fobject.h" #include "final/fobject.h"
@ -32,7 +31,6 @@ namespace finalcut
// static class attributes // static class attributes
bool FObject::timer_modify_lock; bool FObject::timer_modify_lock;
const FString* fc::emptyFString::empty_string{nullptr};
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -55,9 +53,6 @@ FObject::~FObject() // destructor
{ {
delOwnTimers(); // Delete all timers of this object delOwnTimers(); // Delete all timers of this object
if ( ! has_parent && ! fc::emptyFString::isNull() )
fc::emptyFString::clear();
// Delete children objects // Delete children objects
if ( hasChildren() ) if ( hasChildren() )
{ {
@ -425,7 +420,7 @@ void FObject::performTimerAction (FObject*, FEvent*)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FObject::FTimerListPtr& FObject::globalTimerList() auto FObject::globalTimerList() -> const FTimerListUniquePtr&
{ {
static const auto& timer_list = make_unique<FTimerList>(); static const auto& timer_list = make_unique<FTimerList>();
return timer_list; return timer_list;

View File

@ -76,10 +76,10 @@ FString::FString (const FString& s) // copy constructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FString::FString (FString&& s) noexcept // move constructor FString::FString (FString&& s) noexcept // move constructor
: string{std::move(s.string)} : string{s.string}
, length{s.length} , length{s.length}
, bufsize{s.bufsize} , bufsize{s.bufsize}
, c_string{std::move(s.c_string)} , c_string{s.c_string}
{ {
s.string = nullptr; s.string = nullptr;
s.length = 0; s.length = 0;
@ -185,10 +185,10 @@ FString& FString::operator = (FString&& s) noexcept
if ( c_string ) if ( c_string )
delete[](c_string); delete[](c_string);
string = std::move(s.string); string = s.string;
length = s.length; length = s.length;
bufsize = s.bufsize; bufsize = s.bufsize;
c_string = std::move(s.c_string); c_string = s.c_string;
s.string = nullptr; s.string = nullptr;
s.length = 0; s.length = 0;
@ -1456,6 +1456,9 @@ inline const wchar_t* FString::_to_wcstring (const char s[]) const
auto state = std::mbstate_t(); auto state = std::mbstate_t();
auto size = std::mbsrtowcs(nullptr, &src, 0, &state) + 1; auto size = std::mbsrtowcs(nullptr, &src, 0, &state) + 1;
if ( size == 0 ) // ...malformed UTF-8 string
return nullptr;
try try
{ {
dest = new wchar_t[size]; dest = new wchar_t[size];

View File

@ -54,8 +54,8 @@ FStringStream::FStringStream (FStringStream&& sstream) noexcept
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FStringStream::~FStringStream() // destructor FStringStream::~FStringStream() noexcept = default;
{ }
// public methods of FStringStream // public methods of FStringStream
//---------------------------------------------------------------------- //----------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -66,13 +66,12 @@ int FTermBuffer::write (const FString& string)
for (auto&& c : string) for (auto&& c : string)
{ {
FChar nc; // next character FChar nc{FVTerm::getAttribute()}; // next character
nc = FVTerm::getAttribute();
nc.ch[0] = c; nc.ch[0] = c;
nc.attr.byte[2] = 0; nc.attr.byte[2] = 0;
nc.attr.byte[3] = 0; nc.attr.byte[3] = 0;
getColumnWidth(nc); // add column width getColumnWidth(nc); // add column width
data.emplace_back(std::move(nc)); data.emplace_back(nc);
} }
return len; return len;
@ -81,12 +80,12 @@ int FTermBuffer::write (const FString& string)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FTermBuffer::write (wchar_t ch) int FTermBuffer::write (wchar_t ch)
{ {
FChar nc = FVTerm::getAttribute(); // next character FChar nc{FVTerm::getAttribute()}; // next character
nc.ch[0] = ch; nc.ch[0] = ch;
getColumnWidth(nc); // add column width getColumnWidth(nc); // add column width
nc.attr.bit.no_changes = false; nc.attr.bit.no_changes = false;
nc.attr.bit.printed = false; nc.attr.bit.printed = false;
data.emplace_back(std::move(nc)); data.emplace_back(nc);
return 1; return 1;
} }

View File

@ -38,6 +38,7 @@ namespace finalcut
{ {
// static class attributes // static class attributes
bool FTermcap::initialized {false};
bool FTermcap::background_color_erase {false}; bool FTermcap::background_color_erase {false};
bool FTermcap::can_change_color_palette {false}; bool FTermcap::can_change_color_palette {false};
bool FTermcap::automatic_left_margin {false}; bool FTermcap::automatic_left_margin {false};
@ -50,9 +51,6 @@ bool FTermcap::no_utf8_acs_chars {false};
int FTermcap::max_color {1}; int FTermcap::max_color {1};
int FTermcap::tabstop {8}; int FTermcap::tabstop {8};
int FTermcap::attr_without_color {0}; int FTermcap::attr_without_color {0};
FSystem* FTermcap::fsystem {nullptr};
FTermData* FTermcap::fterm_data {nullptr};
FTermDetection* FTermcap::term_detection {nullptr};
char FTermcap::string_buf[2048] {}; char FTermcap::string_buf[2048] {};
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -72,9 +70,6 @@ char FTermcap::string_buf[2048] {};
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermcap::init() void FTermcap::init()
{ {
fsystem = FTerm::getFSystem();
fterm_data = FTerm::getFTermData();
term_detection = FTerm::getFTermDetection();
termcap(); termcap();
} }
@ -82,11 +77,13 @@ void FTermcap::init()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermcap::termcap() void FTermcap::termcap()
{ {
const auto& fterm_data = FTerm::getFTermData();
std::vector<std::string> terminals{}; std::vector<std::string> terminals{};
static constexpr int success = 1; static constexpr int success = 1;
static constexpr int uninitialized = -2; static constexpr int uninitialized = -2;
static char term_buffer[BUF_SIZE]{}; static char term_buffer[BUF_SIZE]{};
int status = uninitialized; int status = uninitialized;
const auto& term_detection = FTerm::getFTermDetection();
const bool color256 = term_detection->canDisplay256Colors(); const bool color256 = term_detection->canDisplay256Colors();
// Open termcap file // Open termcap file
@ -112,6 +109,9 @@ void FTermcap::termcap()
// Open the termcap file + load entry for termtype // Open the termcap file + load entry for termtype
status = tgetent(term_buffer, termtype); status = tgetent(term_buffer, termtype);
if ( status == success )
initialized = true;
if ( status == success || ! term_detection->hasTerminalDetection() ) if ( status == success || ! term_detection->hasTerminalDetection() )
break; break;
@ -131,6 +131,7 @@ void FTermcap::termcapError (int status)
if ( status == no_entry || status == uninitialized ) if ( status == no_entry || status == uninitialized )
{ {
const auto& fterm_data = FTerm::getFTermData();
const char* termtype = fterm_data->getTermType(); const char* termtype = fterm_data->getTermType();
std::clog << FLog::Error std::clog << FLog::Error
<< "Unknown terminal: \"" << termtype << "\". " << "Unknown terminal: \"" << termtype << "\". "
@ -200,6 +201,8 @@ void FTermcap::termcapNumerics()
{ {
// Get termcap numerics // Get termcap numerics
const auto& fterm_data = FTerm::getFTermData();
// 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"));
@ -252,9 +255,7 @@ void FTermcap::termcapKeys()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int FTermcap::_tputs (const char* str, int affcnt, fn_putc putc) int FTermcap::_tputs (const char* str, int affcnt, fn_putc putc)
{ {
if ( ! fsystem ) const auto& fsystem = FTerm::getFSystem();
fsystem = FTerm::getFSystem();
return fsystem->tputs (str, affcnt, putc); return fsystem->tputs (str, affcnt, putc);
} }

View File

@ -34,11 +34,6 @@
namespace finalcut namespace finalcut
{ {
// static class attributes
FTermData* FTermcapQuirks::fterm_data {nullptr};
FTermDetection* FTermcapQuirks::term_detection {nullptr};
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FTermcapQuirks // class FTermcapQuirks
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -47,9 +42,7 @@ FTermDetection* FTermcapQuirks::term_detection {nullptr};
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermcapQuirks::terminalFixup() void FTermcapQuirks::terminalFixup()
{ {
fterm_data = FTerm::getFTermData(); const auto& td = FTerm::getFTermDetection();
term_detection = FTerm::getFTermDetection();
const auto& td = term_detection;
if ( td->isCygwinTerminal() ) if ( td->isCygwinTerminal() )
{ {
@ -231,7 +224,9 @@ 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& fterm_data = FTerm::getFTermData();
const char* termtype = fterm_data->getTermType(); const char* termtype = fterm_data->getTermType();
const auto& term_detection = FTerm::getFTermDetection();
if ( std::strncmp(termtype, "rxvt-16color", 12) == 0 ) if ( std::strncmp(termtype, "rxvt-16color", 12) == 0 )
{ {
@ -252,12 +247,13 @@ void FTermcapQuirks::rxvt()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermcapQuirks::vte() void FTermcapQuirks::vte()
{ {
const auto& term_detection = FTerm::getFTermDetection();
// 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;
// set exit underline for gnome terminal // set exit underline for gnome terminal
TCAP(fc::t_exit_underline_mode) = \ TCAP(fc::t_exit_underline_mode) = CSI "24m";
CSI "24m";
if ( term_detection->getGnomeTerminalID() >= 5300 ) // vte >= 0.53.0 if ( term_detection->getGnomeTerminalID() >= 5300 ) // vte >= 0.53.0
{ {
@ -266,8 +262,7 @@ void FTermcapQuirks::vte()
{ {
// Save the cursor position, enter alternate screen buffer // Save the cursor position, enter alternate screen buffer
// and save xterm icon and window title on stack // and save xterm icon and window title on stack
TCAP(fc::t_enter_ca_mode) = \ TCAP(fc::t_enter_ca_mode) = CSI "?1049h" CSI "22;0;0t";
CSI "?1049h" CSI "22;0;0t";
} }
if ( TCAP(fc::t_exit_ca_mode) if ( TCAP(fc::t_exit_ca_mode)
@ -275,8 +270,7 @@ void FTermcapQuirks::vte()
{ {
// Use normal screen buffer, restore the cursor position // Use normal screen buffer, restore the cursor position
// and restore xterm icon and window title from stack // and restore xterm icon and window title from stack
TCAP(fc::t_exit_ca_mode) = \ TCAP(fc::t_exit_ca_mode) = CSI "?1049l" CSI "23;0;0t";
CSI "?1049l" CSI "23;0;0t";
} }
} }
} }
@ -457,6 +451,8 @@ void FTermcapQuirks::sunConsole()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermcapQuirks::screen() void FTermcapQuirks::screen()
{ {
const auto& term_detection = FTerm::getFTermDetection();
// Fallback if "Ic" is not found // Fallback if "Ic" is not found
if ( ! TCAP(fc::t_initialize_color) ) if ( ! TCAP(fc::t_initialize_color) )
{ {

View File

@ -30,49 +30,44 @@ namespace finalcut
{ {
#if DEBUG #if DEBUG
// static class attributes
FTermData* FTermDebugData::data {nullptr};
FTermDetection* FTermDebugData::term_detection {nullptr};
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FTermDebugData // class FTermDebugData
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// public methods of FTermDebugData // public methods of FTermDebugData
//----------------------------------------------------------------------
void FTermDebugData::init()
{
data = FTerm::getFTermData();
term_detection = FTerm::getFTermDetection();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FString& FTermDebugData::getAnswerbackString() const FString& FTermDebugData::getAnswerbackString()
{ {
const auto& term_detection = FTerm::getFTermDetection();
return term_detection->getAnswerbackString(); return term_detection->getAnswerbackString();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const FString& FTermDebugData::getSecDAString() const FString& FTermDebugData::getSecDAString()
{ {
const auto& term_detection = FTerm::getFTermDetection();
return term_detection->getSecDAString(); return term_detection->getSecDAString();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const char* FTermDebugData::getTermType_256color() const char* FTermDebugData::getTermType_256color()
{ {
const auto& term_detection = FTerm::getFTermDetection();
return term_detection->getTermType_256color(); return term_detection->getTermType_256color();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const char* FTermDebugData::getTermType_Answerback() const char* FTermDebugData::getTermType_Answerback()
{ {
const auto& term_detection = FTerm::getFTermDetection();
return term_detection->getTermType_Answerback(); return term_detection->getTermType_Answerback();
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const char* FTermDebugData::getTermType_SecDA() const char* FTermDebugData::getTermType_SecDA()
{ {
const auto& term_detection = FTerm::getFTermDetection();
return term_detection->getTermType_SecDA(); return term_detection->getTermType_SecDA();
} }
@ -80,7 +75,8 @@ const char* FTermDebugData::getTermType_SecDA()
#if defined(__linux__) #if defined(__linux__)
int FTermDebugData::getFramebufferBpp() int FTermDebugData::getFramebufferBpp()
{ {
return data->getFramebufferBpp(); const auto& fterm_data = FTerm::getFTermData();
return fterm_data->getFramebufferBpp();
} }
#endif // defined(__linux__) #endif // defined(__linux__)

View File

@ -54,9 +54,6 @@ namespace finalcut
FTermDetection::FTerminalType FTermDetection::terminal_type{}; FTermDetection::FTerminalType FTermDetection::terminal_type{};
FTermDetection::colorEnv FTermDetection::color_env{}; FTermDetection::colorEnv FTermDetection::color_env{};
FTermDetection::secondaryDA FTermDetection::secondary_da{}; FTermDetection::secondaryDA FTermDetection::secondary_da{};
FTermData* FTermDetection::fterm_data{nullptr};
FSystem* FTermDetection::fsystem{nullptr};
FKeyboard* FTermDetection::keyboard{nullptr};
char FTermDetection::termtype[256]{}; char FTermDetection::termtype[256]{};
char FTermDetection::ttytypename[256]{}; char FTermDetection::ttytypename[256]{};
bool FTermDetection::decscusr_support{}; bool FTermDetection::decscusr_support{};
@ -133,9 +130,6 @@ void FTermDetection::setTtyTypeFileName (const char ttytype_filename[])
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermDetection::detect() void FTermDetection::detect()
{ {
fterm_data = FTerm::getFTermData();
fsystem = FTerm::getFSystem();
keyboard = FTerm::getFKeyboard();
deallocation(); deallocation();
// Set the variable 'termtype' to the predefined type of the terminal // Set the variable 'termtype' to the predefined type of the terminal
@ -165,6 +159,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& fterm_data = FTerm::getFTermData();
const auto& termfilename = fterm_data->getTermFileName(); const auto& termfilename = fterm_data->getTermFileName();
if ( term_env ) if ( term_env )
@ -203,6 +198,7 @@ bool FTermDetection::getTTYtype()
// vt100 ttys0 // vt100 ttys0
// Get term basename // Get term basename
const auto& fterm_data = FTerm::getFTermData();
const char* termfilename = fterm_data->getTermFileName(); const char* termfilename = fterm_data->getTermFileName();
const char* term_basename = std::strrchr(termfilename, '/'); const char* term_basename = std::strrchr(termfilename, '/');
@ -213,9 +209,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();
if ( ! fsystem )
return false;
if ( (fp = fsystem->fopen(ttytypename, "r")) == nullptr ) if ( (fp = fsystem->fopen(ttytypename, "r")) == nullptr )
return false; return false;
@ -260,6 +254,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& fterm_data = FTerm::getFTermData();
const char* termfilename = fterm_data->getTermFileName(); const char* termfilename = fterm_data->getTermFileName();
const char* term_basename = std::strrchr(termfilename, '/'); const char* term_basename = std::strrchr(termfilename, '/');
@ -364,6 +359,7 @@ void FTermDetection::detectTerminal()
if ( terminal_detection ) if ( terminal_detection )
{ {
FTermios::setCaptureSendCharacters(); FTermios::setCaptureSendCharacters();
const auto& keyboard = FTerm::getFKeyboard();
keyboard->setNonBlockingInput(); keyboard->setNonBlockingInput();
// Initialize 256 colors terminals // Initialize 256 colors terminals
@ -408,6 +404,7 @@ void FTermDetection::detectTerminal()
} }
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
const auto& fterm_data = FTerm::getFTermData();
const auto& termfilename = fterm_data->getTermFileName(); const auto& termfilename = fterm_data->getTermFileName();
// Fixes problem with mouse input // Fixes problem with mouse input
@ -541,6 +538,7 @@ const char* FTermDetection::determineMaxColor (const char current_termtype[])
// Determine xterm maximum number of colors via OSC 4 // Determine xterm maximum number of colors via OSC 4
const char* new_termtype = current_termtype; const char* new_termtype = current_termtype;
const auto& keyboard = FTerm::getFKeyboard();
keyboard->setNonBlockingInput(); keyboard->setNonBlockingInput();
if ( ! color256 if ( ! color256
@ -632,6 +630,7 @@ FString FTermDetection::getXTermColorName (FColor color)
const char* FTermDetection::parseAnswerbackMsg (const char current_termtype[]) const char* FTermDetection::parseAnswerbackMsg (const char current_termtype[])
{ {
const char* new_termtype = current_termtype; const char* new_termtype = current_termtype;
const auto& keyboard = FTerm::getFKeyboard();
keyboard->setNonBlockingInput(); keyboard->setNonBlockingInput();
// send ENQ and read the answerback message // send ENQ and read the answerback message
const auto& ans = getAnswerbackMsg(); const auto& ans = getAnswerbackMsg();

View File

@ -30,28 +30,15 @@
#include "final/ftypes.h" #include "final/ftypes.h"
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
#define initCheck(ret_value) \
if ( ! isInitialized() ) \
{ \
if ( ! FApplication::isQuit() ) \
warnNotInitialized(); \
\
return ret_value; \
}
#endif
namespace finalcut namespace finalcut
{ {
// static class attributes // static class attributes
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) uInt FTermFreeBSD::bsd_alt_keymap{0};
uInt FTermFreeBSD::bsd_alt_keymap{0}; FTermFreeBSD::CursorStyle FTermFreeBSD::cursor_style{fc::normal_cursor};
FTermFreeBSD::CursorStyle FTermFreeBSD::cursor_style{fc::normal_cursor}; bool FTermFreeBSD::change_cursorstyle{true};
bool FTermFreeBSD::change_cursorstyle{true}; bool FTermFreeBSD::meta_sends_escape{true};
bool FTermFreeBSD::meta_sends_escape{true};
FSystem* FTermFreeBSD::fsystem{nullptr};
FTermData* FTermFreeBSD::fterm_data{nullptr};
#endif
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -60,7 +47,6 @@ namespace finalcut
// public methods of FTermFreeBSD // public methods of FTermFreeBSD
//---------------------------------------------------------------------- //----------------------------------------------------------------------
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
FTermFreeBSD::CursorStyle FTermFreeBSD::getCursorStyle() FTermFreeBSD::CursorStyle FTermFreeBSD::getCursorStyle()
{ {
return cursor_style; return cursor_style;
@ -71,15 +57,11 @@ bool FTermFreeBSD::setCursorStyle (CursorStyle style)
{ {
// Set cursor style in a BSD console // Set cursor style in a BSD console
if ( ! fterm_data ) if ( ! isFreeBSDConsole() || ! change_cursorstyle )
fterm_data = FTerm::getFTermData();
initCheck(false);
if ( ! fsystem || ! isFreeBSDConsole() || ! change_cursorstyle )
return false; return false;
cursor_style = style; cursor_style = style;
const auto& fterm_data = FTerm::getFTermData();
if ( fterm_data->isCursorHidden() ) if ( fterm_data->isCursorHidden() )
return false; return false;
@ -93,11 +75,9 @@ 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();
if ( ! fsystem ) if ( fsystem->ioctl(0, GIO_KEYMAP, &keymap) == 0 )
fsystem = FTerm::getFSystem();
if ( fsystem && fsystem->ioctl(0, GIO_KEYMAP, &keymap) == 0 )
return true; return true;
else else
return false; return false;
@ -141,9 +121,6 @@ void FTermFreeBSD::init()
{ {
// Initialize BSD console // Initialize BSD console
fsystem = FTerm::getFSystem();
fterm_data = FTerm::getFTermData();
if ( ! isFreeBSDConsole() ) if ( ! isFreeBSDConsole() )
return; return;
@ -210,7 +187,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{};
initCheck(false); const auto& fsystem = FTerm::getFSystem();
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap); ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
if ( ret < 0 ) if ( ret < 0 )
@ -229,7 +206,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{};
initCheck(false); const auto& fsystem = FTerm::getFSystem();
ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap); ret = fsystem->ioctl (0, GIO_KEYMAP, &keymap);
if ( ret < 0 ) if ( ret < 0 )
@ -239,7 +216,7 @@ bool FTermFreeBSD::setFreeBSDAltKey (uInt key)
keymap.key[left_alt].map[0] = int(key); keymap.key[left_alt].map[0] = int(key);
if ( (keymap.n_keys > 0) if ( (keymap.n_keys > 0)
&& fsystem && (fsystem->ioctl(0, PIO_KEYMAP, &keymap) < 0) ) && (fsystem->ioctl(0, PIO_KEYMAP, &keymap) < 0) )
return false; return false;
else else
return true; return true;
@ -264,13 +241,14 @@ bool FTermFreeBSD::resetFreeBSDAlt2Meta()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTermFreeBSD::setFreeBSDCursorStyle (CursorStyle style) bool FTermFreeBSD::setFreeBSDCursorStyle (CursorStyle style)
{ {
initCheck(false); const auto& fsystem = FTerm::getFSystem();
if ( fsystem->ioctl(0, CONS_CURSORTYPE, &style) == 0 ) if ( fsystem->ioctl(0, CONS_CURSORTYPE, &style) == 0 )
return true; return true;
else else
return false; return false;
} }
#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
} // namespace finalcut } // namespace finalcut
#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)

View File

@ -35,11 +35,12 @@
#include "final/ftypes.h" #include "final/ftypes.h"
#if defined(__linux__) #if defined(__linux__)
#include <linux/keyboard.h> // need keyboard modifiers
#include "../fonts/newfont.h" #include <linux/keyboard.h> // need keyboard modifiers
#include "../fonts/unicodemap.h" #include "../fonts/newfont.h"
#include "../fonts/vgafont.h" #include "../fonts/unicodemap.h"
#endif #include "../fonts/vgafont.h"
namespace finalcut namespace finalcut
{ {
@ -52,18 +53,15 @@ namespace finalcut
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FTermLinux::~FTermLinux() // destructor FTermLinux::~FTermLinux() // destructor
{ {
#if defined(__linux__)
if ( screen_font.data ) if ( screen_font.data )
delete[] screen_font.data; delete[] screen_font.data;
if ( screen_unicode_map.entries ) if ( screen_unicode_map.entries )
delete[] screen_unicode_map.entries; delete[] screen_unicode_map.entries;
#endif // defined(__linux__)
} }
// public methods of FTermLinux // public methods of FTermLinux
//---------------------------------------------------------------------- //----------------------------------------------------------------------
#if defined(__linux__)
fc::linuxConsoleCursorStyle FTermLinux::getCursorStyle() const fc::linuxConsoleCursorStyle FTermLinux::getCursorStyle() const
{ {
// Get the current set cursor style // Get the current set cursor style
@ -87,8 +85,7 @@ bool FTermLinux::setCursorStyle (fc::linuxConsoleCursorStyle style)
{ {
// Set cursor style in linux console // Set cursor style in linux console
if ( ! fterm_data ) const auto& fterm_data = FTerm::getFTermData();
fterm_data = FTerm::getFTermData();
if ( ! FTerm::isLinuxTerm() ) if ( ! FTerm::isLinuxTerm() )
return false; return false;
@ -137,11 +134,9 @@ bool FTermLinux::isLinuxConsole()
{ {
// Check if it's a Linux console // Check if it's a Linux console
if ( ! fsystem )
fsystem = FTerm::getFSystem();
char arg{0}; char arg{0};
const int fd_tty = FTerm::getTTYFileDescriptor(); const int fd_tty = FTerm::getTTYFileDescriptor();
const auto& fsystem = FTerm::getFSystem();
// Get keyboard type an compare // Get keyboard type an compare
return ( fsystem->isTTY(fd_tty) return ( fsystem->isTTY(fd_tty)
@ -154,14 +149,8 @@ void FTermLinux::init()
{ {
// Initialize Linux console // Initialize Linux console
if ( ! fsystem ) const auto& fterm_data = FTerm::getFTermData();
fsystem = FTerm::getFSystem(); const auto& term_detection = FTerm::getFTermDetection();
if ( ! fterm_data )
fterm_data = FTerm::getFTermData();
fsystem = FTerm::getFSystem();
term_detection = FTerm::getFTermDetection();
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);
@ -292,9 +281,7 @@ bool FTermLinux::loadVGAFont()
if ( vga_font ) if ( vga_font )
{ {
if ( ! fterm_data ) const auto& fterm_data = FTerm::getFTermData();
fterm_data = FTerm::getFTermData();
fterm_data->supportShadowCharacter (true); fterm_data->supportShadowCharacter (true);
fterm_data->supportHalfBlockCharacter (true); fterm_data->supportHalfBlockCharacter (true);
} }
@ -342,9 +329,7 @@ bool FTermLinux::loadNewFont()
if ( new_font ) if ( new_font )
{ {
if ( ! fterm_data ) const auto& fterm_data = FTerm::getFTermData();
fterm_data = FTerm::getFTermData();
fterm_data->supportShadowCharacter (true); fterm_data->supportShadowCharacter (true);
fterm_data->supportHalfBlockCharacter (true); fterm_data->supportHalfBlockCharacter (true);
} }
@ -458,9 +443,6 @@ FKey FTermLinux::modifierKeyCorrection (const FKey& key_id)
{ {
// Get the current modifier key state // Get the current modifier key state
if ( ! fsystem )
fsystem = FTerm::getFSystem();
const ModifierKey& m = getModifierKey(); const ModifierKey& m = getModifierKey();
if ( ! (m.shift || m.ctrl || m.alt) ) if ( ! (m.shift || m.ctrl || m.alt) )
@ -508,9 +490,7 @@ int FTermLinux::getFramebuffer_bpp()
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();
if ( ! fsystem )
fsystem = FTerm::getFSystem();
if ( (fd = fsystem->open(fb, O_RDWR)) < 0 ) if ( (fd = fsystem->open(fb, O_RDWR)) < 0 )
{ {
@ -569,8 +549,8 @@ bool FTermLinux::getScreenFont()
} }
// Font operation // Font operation
if ( fsystem ) const auto& fsystem = FTerm::getFSystem();
ret = fsystem->ioctl (fd_tty, KDFONTOP, &font); ret = fsystem->ioctl (fd_tty, KDFONTOP, &font);
if ( ret != 0 ) if ( ret != 0 )
{ {
@ -600,8 +580,8 @@ bool FTermLinux::getUnicodeMap()
screen_unicode_map.entries = nullptr; screen_unicode_map.entries = nullptr;
// Get count // Get count
if ( fsystem ) const auto& fsystem = FTerm::getFSystem();
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 )
{ {
@ -621,8 +601,7 @@ bool FTermLinux::getUnicodeMap()
} }
// Get unicode-to-font mapping from kernel // Get unicode-to-font mapping from kernel
if ( fsystem ) 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 )
return false; return false;
@ -641,8 +620,10 @@ 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();
// TIOCLINUX, subcode = 6 (TIOCL_GETSHIFTSTATE) // TIOCLINUX, subcode = 6 (TIOCL_GETSHIFTSTATE)
if ( fsystem && fsystem->ioctl(0, TIOCLINUX, &subcode) >= 0 ) if ( fsystem->ioctl(0, TIOCLINUX, &subcode) >= 0 )
{ {
if ( subcode & (1 << KG_SHIFT) ) if ( subcode & (1 << KG_SHIFT) )
mod_key.shift = true; mod_key.shift = true;
@ -705,8 +686,8 @@ int FTermLinux::setScreenFont ( const uChar fontdata[], uInt count
} }
// Font operation // Font operation
if ( fsystem ) const auto& fsystem = FTerm::getFSystem();
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 )
{ {
@ -742,15 +723,14 @@ int FTermLinux::setUnicodeMap (struct unimapdesc* unimap)
do do
{ {
// Clear the unicode-to-font table // Clear the unicode-to-font table
if ( fsystem ) const auto& fsystem = FTerm::getFSystem();
ret = fsystem->ioctl (fd_tty, PIO_UNIMAPCLR, &advice); ret = fsystem->ioctl (fd_tty, PIO_UNIMAPCLR, &advice);
if ( ret != 0 ) if ( ret != 0 )
return -1; return -1;
// Put the new unicode-to-font mapping in kernel // Put the new unicode-to-font mapping in kernel
if ( fsystem ) ret = fsystem->ioctl (fd_tty, PIO_UNIMAP, unimap);
ret = fsystem->ioctl (fd_tty, PIO_UNIMAP, unimap);
if ( ret != 0 ) if ( ret != 0 )
advice.advised_hashlevel++; advice.advised_hashlevel++;
@ -775,8 +755,7 @@ inline uInt16 FTermLinux::getInputStatusRegisterOne()
{ {
// Gets the VGA input-status-register-1 // Gets the VGA input-status-register-1
if ( ! fsystem ) const auto& fsystem = FTerm::getFSystem();
fsystem = FTerm::getFSystem();
// Miscellaneous output (read port) // Miscellaneous output (read port)
static constexpr uInt16 misc_read = 0x3cc; static constexpr uInt16 misc_read = 0x3cc;
@ -792,8 +771,7 @@ uChar FTermLinux::readAttributeController (uChar index)
{ {
// Reads a byte from the attribute controller from a given index // Reads a byte from the attribute controller from a given index
if ( ! fsystem ) const auto& fsystem = FTerm::getFSystem();
fsystem = FTerm::getFSystem();
// Attribute controller (write port) // Attribute controller (write port)
static constexpr uInt16 attrib_cntlr_write = 0x3c0; static constexpr uInt16 attrib_cntlr_write = 0x3c0;
@ -819,8 +797,7 @@ void FTermLinux::writeAttributeController (uChar index, uChar data)
{ {
// Writes a byte from the attribute controller from a given index // Writes a byte from the attribute controller from a given index
if ( ! fsystem ) const auto& fsystem = FTerm::getFSystem();
fsystem = FTerm::getFSystem();
// Attribute controller (write port) // Attribute controller (write port)
static constexpr uInt16 attrib_cntlr_write = 0x3c0; static constexpr uInt16 attrib_cntlr_write = 0x3c0;
@ -859,8 +836,7 @@ int FTermLinux::setBlinkAsIntensity (bool enable)
// Uses blink-bit as background intensity. // Uses blink-bit as background intensity.
// That permits 16 colors for background // That permits 16 colors for background
if ( ! fsystem ) const auto& fsystem = FTerm::getFSystem();
fsystem = FTerm::getFSystem();
const int fd_tty = FTerm::getTTYFileDescriptor(); const int fd_tty = FTerm::getTTYFileDescriptor();
@ -899,9 +875,7 @@ bool FTermLinux::has9BitCharacters()
// 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
if ( ! fsystem ) const auto& fsystem = FTerm::getFSystem();
fsystem = FTerm::getFSystem();
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
@ -926,7 +900,9 @@ bool FTermLinux::has9BitCharacters()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermLinux::getVGAPalette() void FTermLinux::getVGAPalette()
{ {
if ( fsystem && fsystem->ioctl(0, GIO_CMAP, &cmap) != 0 ) const auto& fsystem = FTerm::getFSystem();
if ( fsystem->ioctl(0, GIO_CMAP, &cmap) != 0 )
setVGADefaultPalette(); // Fallback, if GIO_CMAP does not work setVGADefaultPalette(); // Fallback, if GIO_CMAP does not work
} }
@ -967,7 +943,9 @@ bool FTermLinux::setVGAPalette (FColor index, int r, int g, int b)
cmap.color[index].blue = uChar(b); cmap.color[index].blue = uChar(b);
} }
if ( fsystem && fsystem->ioctl(0, PIO_CMAP, &cmap) == 0 ) const auto& fsystem = FTerm::getFSystem();
if ( fsystem->ioctl(0, PIO_CMAP, &cmap) == 0 )
return true; return true;
else else
return false; return false;
@ -978,7 +956,9 @@ bool FTermLinux::saveVGAPalette()
{ {
// Save the current vga color map // Save the current vga color map
if ( fsystem && fsystem->ioctl(0, GIO_CMAP, &saved_color_map) == 0 ) const auto& fsystem = FTerm::getFSystem();
if ( fsystem->ioctl(0, GIO_CMAP, &saved_color_map) == 0 )
has_saved_palette = true; has_saved_palette = true;
else else
has_saved_palette = false; has_saved_palette = false;
@ -991,16 +971,18 @@ bool FTermLinux::resetVGAPalette()
{ {
// Reset the vga color map // Reset the vga color map
const auto& fsystem = FTerm::getFSystem();
if ( has_saved_palette ) if ( has_saved_palette )
{ {
if ( fsystem && fsystem->ioctl (0, PIO_CMAP, &saved_color_map) ) if ( fsystem->ioctl (0, PIO_CMAP, &saved_color_map) )
return false; return false;
} }
else else
{ {
setVGADefaultPalette(); setVGADefaultPalette();
if ( fsystem && fsystem->ioctl(0, PIO_CMAP, &cmap) != 0 ) if ( fsystem->ioctl(0, PIO_CMAP, &cmap) != 0 )
return false; return false;
} }
@ -1291,13 +1273,11 @@ FKey FTermLinux::shiftCtrlAltKeyCorrection (const FKey& key_id) const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FTermLinux::initSpecialCharacter() inline void FTermLinux::initSpecialCharacter()
{ {
const auto& fterm_data = FTerm::getFTermData();
const wchar_t c1 = fc::UpperHalfBlock; const wchar_t c1 = fc::UpperHalfBlock;
const wchar_t c2 = fc::LowerHalfBlock; const wchar_t c2 = fc::LowerHalfBlock;
const wchar_t c3 = fc::FullBlock; const wchar_t c3 = fc::FullBlock;
if ( ! fterm_data )
fterm_data = FTerm::getFTermData();
if ( FTerm::charEncode(c1, fc::PC) == FTerm::charEncode(c1, fc::ASCII) if ( FTerm::charEncode(c1, fc::PC) == FTerm::charEncode(c1, fc::ASCII)
|| FTerm::charEncode(c2, fc::PC) == FTerm::charEncode(c2, fc::ASCII) || FTerm::charEncode(c2, fc::PC) == FTerm::charEncode(c2, fc::ASCII)
|| FTerm::charEncode(c3, fc::PC) == FTerm::charEncode(c3, fc::ASCII) ) || FTerm::charEncode(c3, fc::PC) == FTerm::charEncode(c3, fc::ASCII) )
@ -1334,10 +1314,7 @@ void FTermLinux::characterFallback ( wchar_t ucs
, std::vector<wchar_t> fallback ) , std::vector<wchar_t> fallback )
{ {
constexpr sInt16 NOT_FOUND = -1; constexpr sInt16 NOT_FOUND = -1;
const auto& fterm_data = FTerm::getFTermData();
if ( ! fterm_data )
fterm_data = FTerm::getFTermData();
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] )
@ -1355,6 +1332,6 @@ void FTermLinux::characterFallback ( wchar_t ucs
} }
} }
#endif // defined(__linux__)
} // namespace finalcut } // namespace finalcut
#endif // defined(__linux__)

View File

@ -27,25 +27,13 @@
#include "final/ftermopenbsd.h" #include "final/ftermopenbsd.h"
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
#define initCheck(ret_value) \
if ( ! isInitialized() ) \
{ \
if ( ! FApplication::isQuit() ) \
warnNotInitialized(); \
\
return ret_value; \
}
#endif
namespace finalcut namespace finalcut
{ {
// static class attributes // static class attributes
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) kbd_t FTermOpenBSD::bsd_keyboard_encoding{0};
kbd_t FTermOpenBSD::bsd_keyboard_encoding{0}; bool FTermOpenBSD::meta_sends_escape{true};
bool FTermOpenBSD::meta_sends_escape{true};
FSystem* FTermOpenBSD::fsystem{nullptr};
#endif
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -54,18 +42,14 @@ namespace finalcut
// public methods of FTermOpenBSD // public methods of FTermOpenBSD
//---------------------------------------------------------------------- //----------------------------------------------------------------------
#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
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();
if ( ! fsystem ) if ( fsystem->ioctl(0, WSKBDIO_GETENCODING, &kbdencoding) == 0 )
fsystem = FTerm::getFSystem();
if ( fsystem
&& fsystem->ioctl(0, WSKBDIO_GETENCODING, &kbdencoding) == 0 )
return true; return true;
else else
return false; return false;
@ -76,8 +60,6 @@ void FTermOpenBSD::init()
{ {
// Initialize BSD workstation console // Initialize BSD workstation console
fsystem = FTerm::getFSystem();
if ( ! isBSDConsole() ) if ( ! isBSDConsole() )
return; return;
@ -94,8 +76,6 @@ void FTermOpenBSD::init()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermOpenBSD::finish() void FTermOpenBSD::finish()
{ {
initCheck();
if ( ! isBSDConsole() ) if ( ! isBSDConsole() )
return; return;
@ -106,8 +86,6 @@ void FTermOpenBSD::finish()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTermOpenBSD::setBeep (int Hz, int ms) bool FTermOpenBSD::setBeep (int Hz, int ms)
{ {
initCheck(false);
if ( ! isBSDConsole() ) if ( ! isBSDConsole() )
return false; return false;
@ -124,8 +102,9 @@ 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();
if ( fsystem && fsystem->ioctl(0, WSKBDIO_SETBELL, &bell) < 0 ) if ( fsystem->ioctl(0, WSKBDIO_SETBELL, &bell) < 0 )
return false; return false;
else else
return true; return true;
@ -134,19 +113,17 @@ bool FTermOpenBSD::setBeep (int Hz, int ms)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTermOpenBSD::resetBeep() bool FTermOpenBSD::resetBeep()
{ {
initCheck(false);
wskbd_bell_data default_bell; wskbd_bell_data default_bell;
const auto& fsystem = FTerm::getFSystem();
// Gets the default setting for the bell // Gets the default setting for the bell
if ( fsystem if ( fsystem->ioctl(0, WSKBDIO_GETDEFAULTBELL, &default_bell) < 0 )
&& fsystem->ioctl(0, WSKBDIO_GETDEFAULTBELL, &default_bell) < 0 )
return false; return false;
default_bell.which = WSKBD_BELL_DOALL; default_bell.which = WSKBD_BELL_DOALL;
// Sets the bell settings // Sets the bell settings
if ( fsystem if ( fsystem->ioctl(0, WSKBDIO_SETBELL, &default_bell) < 0 )
&& fsystem->ioctl(0, WSKBDIO_SETBELL, &default_bell) < 0 )
return false; return false;
else else
return true; return true;
@ -170,8 +147,8 @@ bool FTermOpenBSD::saveBSDConsoleEncoding()
static kbd_t k_encoding{}; static kbd_t k_encoding{};
int ret{-1}; int ret{-1};
if ( fsystem ) const auto& fsystem = FTerm::getFSystem();
ret = fsystem->ioctl (0, WSKBDIO_GETENCODING, &k_encoding); ret = fsystem->ioctl (0, WSKBDIO_GETENCODING, &k_encoding);
if ( ret < 0 ) if ( ret < 0 )
return false; return false;
@ -184,8 +161,9 @@ bool FTermOpenBSD::saveBSDConsoleEncoding()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTermOpenBSD::setBSDConsoleEncoding (kbd_t k_encoding) bool FTermOpenBSD::setBSDConsoleEncoding (kbd_t k_encoding)
{ {
if ( fsystem const auto& fsystem = FTerm::getFSystem();
&& fsystem->ioctl(0, WSKBDIO_SETENCODING, &k_encoding) < 0 )
if ( fsystem->ioctl(0, WSKBDIO_SETENCODING, &k_encoding) < 0 )
return false; return false;
else else
return true; return true;
@ -204,6 +182,7 @@ bool FTermOpenBSD::resetBSDConsoleEncoding()
{ {
return setBSDConsoleEncoding (bsd_keyboard_encoding); return setBSDConsoleEncoding (bsd_keyboard_encoding);
} }
#endif // defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
} // namespace finalcut } // namespace finalcut
#endif // defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)

View File

@ -39,38 +39,17 @@
#include "final/ftermxterminal.h" #include "final/ftermxterminal.h"
#include "final/fsize.h" #include "final/fsize.h"
#define initCheck(ret_value) \
if ( ! isInitialized() ) \
{ \
if ( ! FApplication::isQuit() ) \
warnNotInitialized(); \
\
return ret_value; \
}
namespace finalcut namespace finalcut
{ {
// static class attributes // static class attributes
bool FTermXTerminal::mouse_support{false}; bool FTermXTerminal::mouse_support{false};
FSystem* FTermXTerminal::fsystem{nullptr};
FKeyboard* FTermXTerminal::keyboard{nullptr};
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FTermXTerminal // class FTermXTerminal
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// constructors and destructor
//----------------------------------------------------------------------
FTermXTerminal::FTermXTerminal()
{
// Get FSystem object
fsystem = FTerm::getFSystem();
keyboard = FTerm::getFKeyboard();
}
// public methods of FTermXTerminal // public methods of FTermXTerminal
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::setCursorStyle (fc::xtermCursorStyle style) void FTermXTerminal::setCursorStyle (fc::xtermCursorStyle style)
@ -185,12 +164,6 @@ void FTermXTerminal::metaSendsESC (bool enable)
disableXTermMetaSendsESC(); disableXTermMetaSendsESC();
} }
//----------------------------------------------------------------------
void FTermXTerminal::init()
{
term_detection = FTerm::getFTermDetection();
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::setDefaults() void FTermXTerminal::setDefaults()
{ {
@ -268,7 +241,7 @@ void FTermXTerminal::resetHighlightBackground()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::resetDefaults() void FTermXTerminal::resetDefaults()
{ {
initCheck(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection->isPuttyTerminal() ) if ( term_detection->isPuttyTerminal() )
return; return;
@ -301,13 +274,14 @@ void FTermXTerminal::resetTitle()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::captureFontAndTitle() void FTermXTerminal::captureFontAndTitle()
{ {
initCheck(); const auto& term_detection = FTerm::getFTermDetection();
if ( ( term_detection->isXTerminal() if ( ( term_detection->isXTerminal()
|| term_detection->isUrxvtTerminal() ) || term_detection->isUrxvtTerminal() )
&& ! term_detection->isRxvtTerminal() ) && ! term_detection->isRxvtTerminal() )
{ {
FTermios::setCaptureSendCharacters(); FTermios::setCaptureSendCharacters();
const auto& keyboard = FTerm::getFKeyboard();
keyboard->setNonBlockingInput(); keyboard->setNonBlockingInput();
xterm_font = captureXTermFont(); xterm_font = captureXTermFont();
xterm_title = captureXTermTitle(); xterm_title = captureXTermTitle();
@ -338,7 +312,7 @@ void FTermXTerminal::setXTermCursorStyle()
return; return;
#endif #endif
initCheck(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection->isGnomeTerminal() if ( term_detection->isGnomeTerminal()
&& ! term_detection->hasSetCursorStyleSupport() ) && ! term_detection->hasSetCursorStyleSupport() )
@ -362,7 +336,7 @@ void FTermXTerminal::setXTermCursorStyle()
void FTermXTerminal::setXTermTitle() void FTermXTerminal::setXTermTitle()
{ {
// Set the xterm title // Set the xterm title
initCheck(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection->isXTerminal() if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm() || term_detection->isScreenTerm()
@ -387,7 +361,7 @@ void FTermXTerminal::setXTermTitle()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::setXTermSize() const void FTermXTerminal::setXTermSize() const
{ {
initCheck(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection->isXTerminal() ) if ( term_detection->isXTerminal() )
{ {
@ -403,7 +377,7 @@ void FTermXTerminal::setXTermFont()
{ {
// Change the XTerm font (needs the allowFontOps resource) // Change the XTerm font (needs the allowFontOps resource)
initCheck(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection->isXTerminal() if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm() || term_detection->isScreenTerm()
@ -421,7 +395,7 @@ void FTermXTerminal::setXTermForeground()
{ {
// Set the XTerm text foreground color // Set the XTerm text foreground color
initCheck(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection->isXTerminal() if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm() || term_detection->isScreenTerm()
@ -441,7 +415,7 @@ void FTermXTerminal::setXTermBackground()
{ {
// Set the XTerm text background color // Set the XTerm text background color
initCheck(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection->isXTerminal() if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm() || term_detection->isScreenTerm()
@ -461,7 +435,7 @@ void FTermXTerminal::setXTermCursorColor()
{ {
// Set the text cursor color // Set the text cursor color
initCheck(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection->isXTerminal() if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm() || term_detection->isScreenTerm()
@ -481,7 +455,7 @@ void FTermXTerminal::setXTermMouseForeground()
{ {
// Set the mouse foreground color // Set the mouse foreground color
initCheck(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection->isXTerminal() if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm() || term_detection->isScreenTerm()
@ -500,7 +474,7 @@ void FTermXTerminal::setXTermMouseBackground()
{ {
// Set the mouse background color // Set the mouse background color
initCheck(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection->isXTerminal() if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm() || term_detection->isScreenTerm()
@ -518,7 +492,7 @@ void FTermXTerminal::setXTermHighlightBackground()
{ {
// Set the highlight background color // Set the highlight background color
initCheck(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection->isXTerminal() if ( term_detection->isXTerminal()
|| term_detection->isScreenTerm() || term_detection->isScreenTerm()
@ -538,7 +512,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
initCheck(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection->isPuttyTerminal() ) if ( term_detection->isPuttyTerminal() )
return; return;
@ -560,7 +534,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
initCheck(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection->isPuttyTerminal() ) if ( term_detection->isPuttyTerminal() )
return; return;
@ -582,7 +556,7 @@ 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
initCheck(); const auto& term_detection = FTerm::getFTermDetection();
if ( ! term_detection->isGnomeTerminal() ) if ( ! term_detection->isGnomeTerminal() )
setCursorColor("rgb:ffff/ffff/ffff"); // white setCursorColor("rgb:ffff/ffff/ffff"); // white
@ -591,7 +565,7 @@ inline void FTermXTerminal::setXTermDefaultsMouseCursor()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermXTerminal::canSetXTermBackground() const inline bool FTermXTerminal::canSetXTermBackground() const
{ {
initCheck(false); const auto& term_detection = FTerm::getFTermDetection();
if ( xterm_default_colors if ( xterm_default_colors
&& ! (term_detection->isMinttyTerm() && ! (term_detection->isMinttyTerm()
@ -608,7 +582,7 @@ void FTermXTerminal::resetXTermColorMap() const
{ {
// Reset the entire color table // Reset the entire color table
initCheck(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection->isMinttyTerm() ) if ( term_detection->isMinttyTerm() )
{ {
@ -710,7 +684,7 @@ void FTermXTerminal::resetXTermHighlightBackground() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FTermXTerminal::canResetColor() const bool FTermXTerminal::canResetColor() const
{ {
initCheck(false); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection->isGnomeTerminal() if ( term_detection->isGnomeTerminal()
&& term_detection->getGnomeTerminalID() < 3502 ) && term_detection->getGnomeTerminalID() < 3502 )
@ -731,7 +705,7 @@ bool FTermXTerminal::canResetColor() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::oscPrefix() const void FTermXTerminal::oscPrefix() const
{ {
initCheck(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection->isTmuxTerm() ) if ( term_detection->isTmuxTerm() )
{ {
@ -748,7 +722,7 @@ void FTermXTerminal::oscPrefix() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::oscPostfix() const void FTermXTerminal::oscPostfix() const
{ {
initCheck(); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection->isScreenTerm() if ( term_detection->isScreenTerm()
|| term_detection->isTmuxTerm() ) || term_detection->isTmuxTerm() )
@ -761,7 +735,7 @@ void FTermXTerminal::oscPostfix() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FString FTermXTerminal::captureXTermFont() const FString FTermXTerminal::captureXTermFont() const
{ {
initCheck(FString{}); const auto& term_detection = FTerm::getFTermDetection();
if ( ! term_detection->isXTerminal() if ( ! term_detection->isXTerminal()
&& ! term_detection->isScreenTerm() && ! term_detection->isScreenTerm()
@ -823,7 +797,7 @@ FString FTermXTerminal::captureXTermFont() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FString FTermXTerminal::captureXTermTitle() const FString FTermXTerminal::captureXTermTitle() const
{ {
initCheck(FString{}); const auto& term_detection = FTerm::getFTermDetection();
if ( term_detection->isKdeTerminal() ) if ( term_detection->isKdeTerminal() )
return FString{}; return FString{};
@ -887,9 +861,6 @@ void FTermXTerminal::enableXTermMouse()
if ( mouse_support ) if ( mouse_support )
return; // The mouse is already activated return; // The mouse is already activated
if ( ! fsystem )
fsystem = FTerm::getFSystem();
FTerm::putstring (CSI "?1001s" // save old highlight mouse tracking FTerm::putstring (CSI "?1001s" // save old highlight mouse tracking
CSI "?1000;" // enable x11 mouse tracking CSI "?1000;" // enable x11 mouse tracking
"1002;" // enable cell motion mouse tracking "1002;" // enable cell motion mouse tracking

View File

@ -402,7 +402,7 @@ void FToggleButton::drawLabel()
FString label_text{}; FString label_text{};
auto hotkeypos = finalcut::getHotkeyPos(txt, label_text); auto hotkeypos = finalcut::getHotkeyPos(txt, label_text);
print() << FPoint{1 + int(label_offset_pos), 1}; print() << FPoint{1 + int(label_offset_pos), 1};
drawText (std::move(label_text), hotkeypos); drawText (label_text, hotkeypos);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -485,7 +485,7 @@ void FToggleButton::init()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FToggleButton::drawText (FString&& label_text, std::size_t hotkeypos) void FToggleButton::drawText (const FString& label_text, std::size_t hotkeypos)
{ {
if ( FTerm::isMonochron() ) if ( FTerm::isMonochron() )
setReverse(true); setReverse(true);

View File

@ -68,12 +68,10 @@ struct timeval FVTerm::last_term_size_check{};
std::vector<int>* FVTerm::output_buffer{nullptr}; std::vector<int>* FVTerm::output_buffer{nullptr};
FPoint* FVTerm::term_pos{nullptr}; FPoint* FVTerm::term_pos{nullptr};
const FVTerm* FVTerm::init_object{nullptr}; const FVTerm* FVTerm::init_object{nullptr};
FSystem* FVTerm::fsystem{nullptr};
FTerm* FVTerm::fterm{nullptr}; FTerm* FVTerm::fterm{nullptr};
FVTerm::FTermArea* FVTerm::vterm{nullptr}; FVTerm::FTermArea* FVTerm::vterm{nullptr};
FVTerm::FTermArea* FVTerm::vdesktop{nullptr}; FVTerm::FTermArea* FVTerm::vdesktop{nullptr};
FVTerm::FTermArea* FVTerm::active_area{nullptr}; FVTerm::FTermArea* FVTerm::active_area{nullptr};
FMouseControl* FVTerm::mouse{nullptr};
FChar FVTerm::term_attribute{}; FChar FVTerm::term_attribute{};
FChar FVTerm::next_attribute{}; FChar FVTerm::next_attribute{};
FChar FVTerm::s_ch{}; FChar FVTerm::s_ch{};
@ -276,6 +274,7 @@ bool FVTerm::updateTerminal() const
// Check if terminal updates were stopped, application is stopping, // Check if terminal updates were stopped, application is stopping,
// VTerm has no changes, or the drawing is not completed // VTerm has no changes, or the drawing is not completed
if ( no_terminal_updates || FApplication::isQuit() if ( no_terminal_updates || FApplication::isQuit()
|| ! isFlushTimeout()
|| ! (hasPendingUpdates(vterm) && draw_completed) ) || ! (hasPendingUpdates(vterm) && draw_completed) )
{ {
return false; return false;
@ -308,7 +307,7 @@ void FVTerm::addPreprocessingHandler ( const FVTerm* instance
{ {
FVTermPreprocessing obj{ instance, function }; FVTermPreprocessing obj{ instance, function };
delPreprocessingHandler (instance); delPreprocessingHandler (instance);
print_area->preproc_list.push_back(obj); print_area->preproc_list.emplace_back(std::move(obj));
} }
} }
@ -325,8 +324,8 @@ void FVTerm::delPreprocessingHandler (const FVTerm* instance)
while ( iter != print_area->preproc_list.end() ) while ( iter != print_area->preproc_list.end() )
{ {
if ( iter->instance == instance ) if ( iter->instance.get() == instance )
iter = print_area->preproc_list.erase(iter); iter = std::move(print_area->preproc_list.erase(iter));
else else
++iter; ++iter;
} }
@ -590,6 +589,7 @@ void FVTerm::flush()
output_buffer->clear(); output_buffer->clear();
std::fflush(stdout); std::fflush(stdout);
const auto& mouse = FTerm::getFMouseControl();
mouse->drawPointer(); mouse->drawPointer();
FObject::getCurrentTime (&time_last_flush); FObject::getCurrentTime (&time_last_flush);
} }
@ -1278,15 +1278,12 @@ void FVTerm::initTerminal()
if ( fterm ) if ( fterm )
fterm->initTerminal(); fterm->initTerminal();
// Get the global FMouseControl object
mouse = FTerm::getFMouseControl();
// Hide the input cursor // Hide the input cursor
cursor_hideable = FTerm::isCursorHideable(); cursor_hideable = FTerm::isCursorHideable();
hideCursor(); hideCursor();
// Initialize character lengths // Initialize character lengths
init_characterLengths(FTerm::getFOptiMove()); init_characterLengths();
} }
@ -1812,7 +1809,6 @@ void FVTerm::init()
init_object = this; init_object = this;
vterm = nullptr; vterm = nullptr;
vdesktop = nullptr; vdesktop = nullptr;
fsystem = FTerm::getFSystem();
try try
{ {
@ -1863,24 +1859,29 @@ void FVTerm::init()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::init_characterLengths (const FOptiMove* optimove) void FVTerm::init_characterLengths()
{ {
if ( optimove ) const auto& opti_move = FTerm::getFOptiMove();
{ cursor_address_length = opti_move->getCursorAddressLength();
cursor_address_length = optimove->getCursorAddressLength(); erase_char_length = opti_move->getEraseCharsLength();
erase_char_length = optimove->getEraseCharsLength(); repeat_char_length = opti_move->getRepeatCharLength();
repeat_char_length = optimove->getRepeatCharLength(); clr_bol_length = opti_move->getClrBolLength();
clr_bol_length = optimove->getClrBolLength(); clr_eol_length = opti_move->getClrEolLength();
clr_eol_length = optimove->getClrEolLength();
} if ( cursor_address_length == 0 )
else
{
cursor_address_length = INT_MAX; cursor_address_length = INT_MAX;
erase_char_length = INT_MAX;
repeat_char_length = INT_MAX; if ( erase_char_length == 0 )
clr_bol_length = INT_MAX; erase_char_length = INT_MAX;
clr_eol_length = INT_MAX;
} if ( repeat_char_length == 0 )
repeat_char_length = INT_MAX;
if ( clr_bol_length == 0 )
clr_bol_length = INT_MAX;
if ( clr_eol_length == 0 )
clr_eol_length = INT_MAX;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -85,9 +85,9 @@ FWidget::FWidget (FWidget* parent)
{ {
if ( internal::var::root_widget ) if ( internal::var::root_widget )
{ {
auto ftermdata = FTerm::getFTermData(); const auto& fterm_data = FTerm::getFTermData();
ftermdata->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);
return; return;
} }

View File

@ -33,12 +33,7 @@ namespace finalcut
// constructors and destructor // constructors and destructor
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FWidgetColors::FWidgetColors() FWidgetColors::~FWidgetColors() noexcept = default;
{ }
//----------------------------------------------------------------------
FWidgetColors::~FWidgetColors()
{ }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -53,8 +48,8 @@ default8ColorTheme::default8ColorTheme()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
default8ColorTheme::~default8ColorTheme() default8ColorTheme::~default8ColorTheme() noexcept = default;
{ }
// public methods of default8ColorTheme // public methods of default8ColorTheme
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -161,8 +156,8 @@ default16ColorTheme::default16ColorTheme()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
default16ColorTheme::~default16ColorTheme() default16ColorTheme::~default16ColorTheme() noexcept = default;
{ }
// public methods of default16ColorTheme // public methods of default16ColorTheme
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -271,8 +266,8 @@ default8ColorDarkTheme::default8ColorDarkTheme()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
default8ColorDarkTheme::~default8ColorDarkTheme() default8ColorDarkTheme::~default8ColorDarkTheme() noexcept = default;
{ }
// public methods of default8ColorDarkTheme // public methods of default8ColorDarkTheme
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -379,8 +374,8 @@ default16ColorDarkTheme::default16ColorDarkTheme()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
default16ColorDarkTheme::~default16ColorDarkTheme() default16ColorDarkTheme::~default16ColorDarkTheme() noexcept = default;
{ }
// public methods of default16ColorDarkTheme // public methods of default16ColorDarkTheme
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -52,62 +52,28 @@ namespace fc
class emptyFString final class emptyFString final
{ {
public: public:
// Constructors // Constructors
emptyFString() = delete; emptyFString() = delete;
// Disable copy constructor // Disable copy constructor
emptyFString (const emptyFString&) = delete; emptyFString (const emptyFString&) = delete;
// Disable copy assignment operator (=) // Disable copy assignment operator (=)
emptyFString& operator = (const emptyFString&) = delete; emptyFString& operator = (const emptyFString&) = delete;
static FString getClassName(); static FString getClassName()
static bool isNull(); {
static const FString& get(); return "emptyFString";
static void clear(); }
private: static const FString& get()
// Data member {
static const FString* empty_string; static const auto& empty_string = make_unique<FString>("");
return *empty_string.get();
}
}; };
// emptyFString inline functions
//----------------------------------------------------------------------
inline FString emptyFString::getClassName()
{ return "emptyFString"; }
//----------------------------------------------------------------------
inline bool emptyFString::isNull()
{
return ( empty_string ) ? false : true;
}
//----------------------------------------------------------------------
inline const FString& emptyFString::get()
{
if ( ! empty_string )
{
try
{
empty_string = new FString("");
}
catch (const std::bad_alloc&)
{
badAllocOutput ("FString");
}
}
return *empty_string;
}
//----------------------------------------------------------------------
inline void emptyFString::clear()
{
delete empty_string;
empty_string = nullptr;
}
} // namespace fc } // namespace fc
} // namespace finalcut } // namespace finalcut

View File

@ -86,7 +86,6 @@ class FStartOptions;
class FTimerEvent; class FTimerEvent;
class FWheelEvent; class FWheelEvent;
class FMouseControl; class FMouseControl;
class FKeyboard;
class FPoint; class FPoint;
class FObject; class FObject;
@ -98,7 +97,7 @@ class FApplication : public FWidget
{ {
public: public:
// Typedef // Typedef
typedef std::shared_ptr<FLog> FLogPtr; using FLogPtr = std::shared_ptr<FLog>;
// Constructor // Constructor
FApplication (const int&, char*[]); FApplication (const int&, char*[]);
@ -164,9 +163,9 @@ class FApplication : public FWidget
#endif #endif
// Typedefs // Typedefs
typedef std::pair<FObject*, FEvent*> EventPair; using EventPair = std::pair<FObject*, FEvent*>;
typedef std::deque<EventPair> FEventQueue; using FEventQueue = std::deque<EventPair>;
typedef std::unordered_map<int, std::function<void(char*)>> CmdMap; using CmdMap = std::unordered_map<int, std::function<void(char*)>>;
// Methods // Methods
void init(); void init();
@ -244,8 +243,6 @@ class FApplication : public FWidget
static int loop_level; static int loop_level;
static int quit_code; static int quit_code;
static bool quit_now; static bool quit_now;
static FMouseControl* mouse;
static FKeyboard* keyboard;
static FWidget* keyboard_widget; static FWidget* keyboard_widget;
}; };

View File

@ -76,7 +76,7 @@ class FBusyIndicator : public FToolTip
FBusyIndicator (const FBusyIndicator&) = delete; FBusyIndicator (const FBusyIndicator&) = delete;
// Destructor // Destructor
~FBusyIndicator() override; ~FBusyIndicator() noexcept override;
// Disable copy assignment operator (=) // Disable copy assignment operator (=)
FBusyIndicator& operator = (const FBusyIndicator&) = delete; FBusyIndicator& operator = (const FBusyIndicator&) = delete;

View File

@ -126,7 +126,7 @@ class FButtonGroup : public FScrollView
// Methods // Methods
void init(); void init();
void drawText (FString&&, std::size_t); void drawText (const FString&, std::size_t);
bool directFocusCheckedRadioButton (FToggleButton*) const; bool directFocusCheckedRadioButton (FToggleButton*) const;
bool directFocusRadioButton() const; bool directFocusRadioButton() const;
void directFocus(); void directFocus();

View File

@ -135,13 +135,13 @@ class FCallback
, std::nullptr_t >; , std::nullptr_t >;
// Constructors // Constructors
FCallback(); FCallback() = default;
// Disable copy constructor // Disable copy constructor
FCallback (const FCallback&) = delete; FCallback (const FCallback&) = delete;
// Destructor // Destructor
~FCallback(); ~FCallback() noexcept = default;
// Disable copy assignment operator (=) // Disable copy assignment operator (=)
FCallback& operator = (const FCallback&) = delete; FCallback& operator = (const FCallback&) = delete;

View File

@ -56,7 +56,7 @@ class FColorPalette
explicit FColorPalette (const FSetPalette&); explicit FColorPalette (const FSetPalette&);
// Destructor // Destructor
virtual ~FColorPalette(); virtual ~FColorPalette() noexcept;
// Accessor // Accessor
virtual FString getClassName() const; virtual FString getClassName() const;
@ -104,7 +104,7 @@ class default8ColorPalette final : public FColorPalette
explicit default8ColorPalette (const FSetPalette&); explicit default8ColorPalette (const FSetPalette&);
// Destructor // Destructor
~default8ColorPalette() override; ~default8ColorPalette() noexcept override;
// Accessor // Accessor
FString getClassName() const override; FString getClassName() const override;
@ -144,7 +144,7 @@ class default16ColorPalette final : public FColorPalette
explicit default16ColorPalette (const FSetPalette&); explicit default16ColorPalette (const FSetPalette&);
// Destructor // Destructor
~default16ColorPalette() override; ~default16ColorPalette() noexcept override;
// Accessor // Accessor
FString getClassName() const override; FString getClassName() const override;
@ -183,7 +183,7 @@ class default16DarkColorPalette final : public FColorPalette
explicit default16DarkColorPalette (const FSetPalette&); explicit default16DarkColorPalette (const FSetPalette&);
// Destructor // Destructor
~default16DarkColorPalette() override; ~default16DarkColorPalette() noexcept override;
// Accessor // Accessor
FString getClassName() const override; FString getClassName() const override;

View File

@ -118,10 +118,10 @@ class FDataAccess
{ {
public: public:
// Constructor // Constructor
FDataAccess(); FDataAccess() = default;
// Destructor // Destructor
virtual ~FDataAccess(); virtual ~FDataAccess() noexcept;
// Accessors // Accessors
virtual FString getClassName() const virtual FString getClassName() const
@ -166,8 +166,7 @@ class FData : public FDataAccess
{ } { }
// Destructor // Destructor
~FData() override ~FData() noexcept override = default;
{ }
FData (const FData& d) // Copy constructor FData (const FData& d) // Copy constructor
: value{d.value} : value{d.value}

View File

@ -195,7 +195,7 @@ class FDialog : public FWindow
void pressZoomButton (const MouseStates&); void pressZoomButton (const MouseStates&);
bool isMouseOverMenu (const FPoint&) const; bool isMouseOverMenu (const FPoint&) const;
void passEventToSubMenu ( const MouseStates& void passEventToSubMenu ( const MouseStates&
, const FMouseEvent&& ); , const FMouseEvent& );
void moveSizeKey (FKeyEvent*); void moveSizeKey (FKeyEvent*);
void raiseActivateDialog(); void raiseActivateDialog();
void lowerActivateDialog(); void lowerActivateDialog();

View File

@ -80,9 +80,6 @@
namespace finalcut namespace finalcut
{ {
// class forward declaration
class FSystem;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FFileDialog // class FFileDialog
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -214,7 +211,6 @@ class FFileDialog : public FDialog
void cb_processShowHidden(); void cb_processShowHidden();
// Data members // Data members
static FSystem* fsystem;
DIR* directory_stream{nullptr}; DIR* directory_stream{nullptr};
DirEntries dir_entries{}; DirEntries dir_entries{};
FString directory{}; FString directory{};

View File

@ -52,8 +52,6 @@ namespace finalcut
// class forward declaration // class forward declaration
class FApplication; class FApplication;
class FString; class FString;
class FTermDetection;
class FTermLinux;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FKeyboardCommand // class FKeyboardCommand
@ -137,7 +135,6 @@ class FKeyboard final
bool hasDataInQueue() const; bool hasDataInQueue() const;
// Methods // Methods
static void init();
bool& hasUnprocessedInput(); bool& hasUnprocessedInput();
bool isKeyPressed (uInt64 = read_blocking_time); bool isKeyPressed (uInt64 = read_blocking_time);
void clearKeyBuffer(); void clearKeyBuffer();
@ -182,12 +179,6 @@ class FKeyboard final
FKeyboardCommand escape_key_cmd{}; FKeyboardCommand escape_key_cmd{};
FKeyboardCommand mouse_tracking_cmd{}; FKeyboardCommand mouse_tracking_cmd{};
#if defined(__linux__)
#undef linux
static FTermLinux* linux;
#endif
FTermDetection* term_detection{nullptr};
static timeval time_keypressed; static timeval time_keypressed;
static uInt64 read_blocking_time; static uInt64 read_blocking_time;
static uInt64 read_blocking_time_short; static uInt64 read_blocking_time_short;

View File

@ -221,8 +221,13 @@ class FListViewIterator
// Constructor // Constructor
FListViewIterator () = default; FListViewIterator () = default;
FListViewIterator (iterator); FListViewIterator (iterator);
FListViewIterator (const FListViewIterator&) = default;
FListViewIterator (FListViewIterator&& )
noexcept (std::is_nothrow_move_constructible<FListViewIterator>::value)
= default;
// Overloaded operators // Overloaded operators
FListViewIterator& operator = (const FListViewIterator&) = default;
FListViewIterator& operator = (FListViewIterator&&) noexcept = default;
FListViewIterator& operator ++ (); // prefix FListViewIterator& operator ++ (); // prefix
FListViewIterator operator ++ (int); // postfix FListViewIterator operator ++ (int); // postfix
FListViewIterator& operator -- (); // prefix FListViewIterator& operator -- (); // prefix

View File

@ -75,7 +75,7 @@ class FLog : public std::stringbuf
}; };
// Constructor // Constructor
FLog(); FLog() = default;
// Destructor // Destructor
~FLog() override; ~FLog() override;

View File

@ -66,10 +66,10 @@ class FLogger : public FLog
{ {
public: public:
// Constructor // Constructor
FLogger(); FLogger() = default;
// Destructor // Destructor
~FLogger() override; ~FLogger() noexcept override;
// Methods // Methods
FString getClassName() const override; FString getClassName() const override;

View File

@ -192,9 +192,9 @@ class FMenu : public FWindow, public FMenuList
void mouseMoveDeselection (FMenuItem*, MouseStates&); void mouseMoveDeselection (FMenuItem*, MouseStates&);
void mouseUpOverBorder(); void mouseUpOverBorder();
void mouseMoveOverBorder (MouseStates&) const; void mouseMoveOverBorder (MouseStates&) const;
void passEventToSubMenu (const FMouseEvent&&); void passEventToSubMenu (const FMouseEvent&);
void passEventToSuperMenu (const FMouseEvent&&); void passEventToSuperMenu (const FMouseEvent&);
void passEventToMenuBar (const FMouseEvent&&) const; void passEventToMenuBar (const FMouseEvent&) const;
bool containsMenuStructure (const FPoint&); bool containsMenuStructure (const FPoint&);
bool containsMenuStructure (int, int); bool containsMenuStructure (int, int);
FMenu* superMenuAt (const FPoint&); FMenu* superMenuAt (const FPoint&);

View File

@ -138,7 +138,7 @@ class FMenuBar : public FWindow, public FMenuList
void selectMenuItem (FMenuItem*); void selectMenuItem (FMenuItem*);
void mouseDownOverList (const FMouseEvent*); void mouseDownOverList (const FMouseEvent*);
void mouseUpOverList (const FMouseEvent*); void mouseUpOverList (const FMouseEvent*);
void mouseMoveOverList (const FMouseEvent&&); void mouseMoveOverList (const FMouseEvent&);
void passEventToMenu (const FMouseEvent&&) const; void passEventToMenu (const FMouseEvent&&) const;
void leaveMenuBar(); void leaveMenuBar();

View File

@ -99,7 +99,7 @@ class FMessageBox : public FDialog
, ButtonType, ButtonType, ButtonType , ButtonType, ButtonType, ButtonType
, FWidget* = nullptr ); , FWidget* = nullptr );
// Destructor // Destructor
virtual ~FMessageBox() noexcept override; ~FMessageBox() noexcept override;
// copy assignment operator (=) // copy assignment operator (=)
FMessageBox& operator = (const FMessageBox&); FMessageBox& operator = (const FMessageBox&);

View File

@ -90,25 +90,19 @@ namespace finalcut
class FMouseData class FMouseData
{ {
public: public:
// Constructor
FMouseData() = default;
// Copy constructor
FMouseData (const FMouseData&) = default;
// Destructor
virtual ~FMouseData() noexcept;
// Accessors // Accessors
virtual FString getClassName() const; virtual FString getClassName() const;
const FPoint& getPos() const; const FPoint& getPos() const;
// Constructor
FMouseData();
// Default copy constructor
FMouseData (const FMouseData&) = default;
// Default move constructor
FMouseData (FMouseData&&) = default;
// Default copy assignment operator (=)
FMouseData& operator = (const FMouseData&) = default;
// Default move assignment operator (=)
FMouseData& operator = (FMouseData&&) = default;
// Destructor
virtual ~FMouseData();
// Inquiries // Inquiries
bool isLeftButtonPressed() const; bool isLeftButtonPressed() const;
bool isLeftButtonReleased() const; bool isLeftButtonReleased() const;
@ -185,9 +179,6 @@ class FMouse : public FMouseData
// Constructor // Constructor
FMouse(); FMouse();
// Destructor
~FMouse() override;
// Accessors // Accessors
FString getClassName() const override; FString getClassName() const override;
void clearEvent(); void clearEvent();
@ -256,9 +247,6 @@ class FMouseGPM final : public FMouse
// Constructor // Constructor
FMouseGPM(); FMouseGPM();
// Destructor
~FMouseGPM() override = default;
// Accessors // Accessors
FString getClassName() const override; FString getClassName() const override;
@ -321,12 +309,6 @@ inline bool FMouseGPM::isGpmMouseEnabled() const
class FMouseX11 final : public FMouse class FMouseX11 final : public FMouse
{ {
public: public:
// Constructor
FMouseX11() = default;
// Destructor
~FMouseX11() override = default;
// Accessors // Accessors
FString getClassName() const override; FString getClassName() const override;
@ -380,12 +362,6 @@ class FMouseX11 final : public FMouse
class FMouseSGR final : public FMouse class FMouseSGR final : public FMouse
{ {
public: public:
// Constructor
FMouseSGR() = default;
// Destructor
~FMouseSGR() override = default;
// Accessors // Accessors
FString getClassName() const override; FString getClassName() const override;
@ -439,12 +415,6 @@ class FMouseSGR final : public FMouse
class FMouseUrxvt final : public FMouse class FMouseUrxvt final : public FMouse
{ {
public: public:
// Constructor
FMouseUrxvt() = default;
// Destructor
~FMouseUrxvt() override = default;
// Accessors // Accessors
FString getClassName() const override; FString getClassName() const override;
@ -527,15 +497,9 @@ class FMouseControl
// Constructor // Constructor
FMouseControl(); FMouseControl();
// Disable copy constructor
FMouseControl (const FMouseControl&) = delete;
// Destructor // Destructor
virtual ~FMouseControl(); virtual ~FMouseControl();
// Disable copy assignment operator (=)
FMouseControl& operator = (const FMouseControl&) = delete;
// Accessors // Accessors
virtual FString getClassName() const; virtual FString getClassName() const;
const FPoint& getPos(); const FPoint& getPos();
@ -545,7 +509,7 @@ class FMouseControl
void setStdinNo (int); void setStdinNo (int);
void setMaxWidth (uInt16); void setMaxWidth (uInt16);
void setMaxHeight (uInt16); void setMaxHeight (uInt16);
void setDblclickInterval (const uInt64); void setDblclickInterval (const uInt64) const;
void setEventCommand (const FMouseCommand&); void setEventCommand (const FMouseCommand&);
void useGpmMouse (bool = true); void useGpmMouse (bool = true);
void useXtermMouse (bool = true); void useXtermMouse (bool = true);

View File

@ -152,7 +152,7 @@ class FObject
// Using-declaration // Using-declaration
using FTimerList = std::vector<FTimerData>; using FTimerList = std::vector<FTimerData>;
using FTimerListPtr = const std::unique_ptr<FTimerList>; using FTimerListUniquePtr = std::unique_ptr<FTimerList>;
// Accessor // Accessor
FTimerList* getTimerList() const; FTimerList* getTimerList() const;
@ -170,7 +170,7 @@ class FObject
private: private:
// Method // Method
virtual void performTimerAction (FObject*, FEvent*); virtual void performTimerAction (FObject*, FEvent*);
static FTimerListPtr& globalTimerList(); static auto globalTimerList() -> const FTimerListUniquePtr&;
// Data members // Data members
FObject* parent_obj{nullptr}; FObject* parent_obj{nullptr};

View File

@ -59,7 +59,7 @@ class FPoint
FPoint& operator -= (const FPoint&); FPoint& operator -= (const FPoint&);
// Accessors // Accessors
FString getClassName(); FString getClassName() const;
int getX() const; int getX() const;
int getY() const; int getY() const;
void setX (int); void setX (int);
@ -102,7 +102,7 @@ inline FPoint::FPoint (int x, int y)
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString FPoint::getClassName() inline FString FPoint::getClassName() const
{ return "FPoint"; } { return "FPoint"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -65,7 +65,7 @@ class FRect
FRect (const FPoint&, const FPoint&); FRect (const FPoint&, const FPoint&);
// Accessors // Accessors
FString getClassName(); FString getClassName() const;
int getX1() const; int getX1() const;
int getY1() const; int getY1() const;
int getX2() const; int getX2() const;
@ -147,7 +147,7 @@ inline FRect::FRect (int x, int y, std::size_t width, std::size_t height)
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString FRect::getClassName() inline FString FRect::getClassName() const
{ return "FRect"; } { return "FRect"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -64,7 +64,7 @@ class FSize
FSize& operator -= (const FSize&); FSize& operator -= (const FSize&);
// Accessors // Accessors
FString getClassName(); FString getClassName() const;
std::size_t getWidth() const; std::size_t getWidth() const;
std::size_t getHeight() const; std::size_t getHeight() const;
std::size_t getArea() const; std::size_t getArea() const;
@ -111,7 +111,7 @@ inline FSize::FSize (std::size_t w, std::size_t h)
{ } { }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FString FSize::getClassName() inline FString FSize::getClassName() const
{ return "FSize"; } { return "FSize"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -72,13 +72,13 @@ class FStringStream : public std::wiostream
FStringStream (FStringStream&&) noexcept; FStringStream (FStringStream&&) noexcept;
// Destructor // Destructor
~FStringStream(); ~FStringStream() noexcept;
// Disable copy assignment operator (=) // Disable copy assignment operator (=)
FStringStream& operator = (const FStringStream&) = delete; FStringStream& operator = (const FStringStream&) = delete;
// Move assignment operator (=) // Move assignment operator (=)
FStringStream& operator = (FStringStream&& sstream) noexcept; FStringStream& operator = (FStringStream&&) noexcept;
virtual FString getClassName() const; virtual FString getClassName() const;
void swap (FStringStream&) noexcept; void swap (FStringStream&) noexcept;

View File

@ -142,15 +142,15 @@ class FTermDebugData;
class FTermDetection; class FTermDetection;
class FTermXTerminal; class FTermXTerminal;
#if defined(UNIT_TEST) #if defined(__linux__) || defined(UNIT_TEST)
class FTermLinux; class FTermLinux;
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
class FTermFreeBSD; class FTermFreeBSD;
class FTermOpenBSD; #endif
#elif defined(__linux__)
class FTermLinux; #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
#elif defined(__FreeBSD__) || defined(__DragonFly__)
class FTermFreeBSD;
#elif defined(__NetBSD__) || defined(__OpenBSD__)
class FTermOpenBSD; class FTermOpenBSD;
#endif #endif
@ -163,7 +163,6 @@ class FTerm final
public: public:
// Using-declarations // Using-declarations
using defaultPutChar = std::function<int(int)>; using defaultPutChar = std::function<int(int)>;
using FColorPalettePtr = std::shared_ptr<FColorPalette>;
using FSetPalette = FColorPalette::FSetPalette; using FSetPalette = FColorPalette::FSetPalette;
// Constructor // Constructor
@ -183,36 +182,36 @@ class FTerm final
static std::size_t getLineNumber(); static std::size_t getLineNumber();
static std::size_t getColumnNumber(); static std::size_t getColumnNumber();
static FString getKeyName (FKey); static FString getKeyName (FKey);
charSubstitution& getCharSubstitutionMap();
static int getTTYFileDescriptor(); static int getTTYFileDescriptor();
static const char* getTermType(); static const char* getTermType();
static const char* getTermFileName(); static const char* getTermFileName();
static int getTabstop(); static int getTabstop();
static int getMaxColor(); static int getMaxColor();
static FColorPalettePtr& getColorPaletteTheme(); static auto getColorPaletteTheme() -> std::shared_ptr<FColorPalette>&;
charSubstitution& getCharSubstitutionMap(); static auto getFTermData() -> const std::unique_ptr<FTermData>&;
static FTermData* getFTermData(); static auto getFSystem() -> std::unique_ptr<FSystem>&;
static FSystem* getFSystem(); static auto getFOptiMove() -> const std::unique_ptr<FOptiMove>&;
static FOptiMove* getFOptiMove(); static auto getFOptiAttr() -> const std::unique_ptr<FOptiAttr>&;
static FOptiAttr* getFOptiAttr(); static auto getFTermDetection() -> const std::unique_ptr<FTermDetection>&;
static FTermDetection* getFTermDetection(); static auto getFTermXTerminal() -> const std::unique_ptr<FTermXTerminal>&;
static FTermXTerminal* getFTermXTerminal(); static auto getFKeyboard() -> const std::unique_ptr<FKeyboard>&;
static FKeyboard* getFKeyboard(); static auto getFMouseControl() -> const std::unique_ptr<FMouseControl>&;
static FMouseControl* getFMouseControl();
#if defined(UNIT_TEST) #if defined(__linux__) || defined(UNIT_TEST)
static FTermLinux* getFTermLinux(); static auto getFTermLinux() -> const std::unique_ptr<FTermLinux>&;
static FTermFreeBSD* getFTermFreeBSD(); #endif
static FTermOpenBSD* getFTermOpenBSD();
#elif defined(__linux__) #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
static FTermLinux* getFTermLinux(); static auto getFTermFreeBSD() -> const std::unique_ptr<FTermFreeBSD>&;
#elif defined(__FreeBSD__) || defined(__DragonFly__) #endif
static FTermFreeBSD* getFTermFreeBSD();
#elif defined(__NetBSD__) || defined(__OpenBSD__) #if defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
static FTermOpenBSD* getFTermOpenBSD(); static auto getFTermOpenBSD() -> const std::unique_ptr<FTermOpenBSD>&;
#endif #endif
#if DEBUG #if DEBUG
static FTermDebugData& getFTermDebugData(); static auto getFTermDebugData() -> const std::unique_ptr<FTermDebugData>&;
#endif #endif
// Inquiries // Inquiries
@ -252,7 +251,7 @@ class FTerm final
static bool canChangeColorPalette(); static bool canChangeColorPalette();
// Mutators // Mutators
static void setFSystem (FSystem*); static void setFSystem (std::unique_ptr<FSystem>&&);
static void setTermType (const char[]); static void setTermType (const char[]);
static void setInsertCursor (bool); static void setInsertCursor (bool);
static void setInsertCursor(); static void setInsertCursor();
@ -319,7 +318,6 @@ class FTerm final
static void init_cygwin_charmap(); static void init_cygwin_charmap();
static void init_teraterm_charmap(); static void init_teraterm_charmap();
static void init_fixed_max_color(); static void init_fixed_max_color();
static void init_keyboard();
static void init_termcap(); static void init_termcap();
static void init_quirks(); static void init_quirks();
static void init_optiMove(); static void init_optiMove();
@ -351,8 +349,6 @@ class FTerm final
static void enableAlternateCharset(); static void enableAlternateCharset();
static void useAlternateScreenBuffer(); static void useAlternateScreenBuffer();
static void useNormalScreenBuffer(); static void useNormalScreenBuffer();
void allocationValues() const;
void deallocationValues();
void init(); void init();
bool init_terminal() const; bool init_terminal() const;
void initOSspecifics() const; void initOSspecifics() const;
@ -361,41 +357,12 @@ class FTerm final
void finish() const; void finish() const;
void finishOSspecifics() const; void finishOSspecifics() const;
void finish_encoding() const; void finish_encoding() const;
void destroyColorPaletteTheme();
static void printExitMessage(); static void printExitMessage();
static void terminalSizeChange(); static void terminalSizeChange();
[[noreturn]] static void processTermination (int); [[noreturn]] static void processTermination (int);
static void setSignalHandler(); static void setSignalHandler();
static void resetSignalHandler(); static void resetSignalHandler();
static void signal_handler (int); static void signal_handler (int);
// Data members
static FTermData* data;
static FSystem* fsys;
static FOptiMove* opti_move;
static FOptiAttr* opti_attr;
static FTermDetection* term_detection;
static FTermXTerminal* xterm;
static FKeyboard* keyboard;
static FMouseControl* mouse;
#if defined(UNIT_TEST)
#undef linux
static FTermLinux* linux;
static FTermFreeBSD* freebsd;
static FTermOpenBSD* openbsd;
#elif defined(__linux__)
#undef linux
static FTermLinux* linux;
#elif defined(__FreeBSD__) || defined(__DragonFly__)
static FTermFreeBSD* freebsd;
#elif defined(__NetBSD__) || defined(__OpenBSD__)
static FTermOpenBSD* openbsd;
#endif
#if DEBUG
static FTermDebugData* debug_data;
#endif
}; };
@ -424,8 +391,10 @@ inline FString FTerm::getClassName()
{ return "FTerm"; } { return "FTerm"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FTerm::setFSystem (FSystem* fsystem) inline void FTerm::setFSystem (std::unique_ptr<FSystem>&& fsystem)
{ fsys = fsystem; } {
getFSystem().swap(fsystem);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FTerm::setInsertCursor() inline void FTerm::setInsertCursor()
@ -460,15 +429,11 @@ inline void FTerm::putstringf (const char format[], Args&&... args)
if ( size == -1 ) if ( size == -1 )
return; return;
if ( ! fsys )
getFSystem(); // Trying to set fsys
const auto count = std::size_t(size); const auto count = std::size_t(size);
std::vector<char> buf(count); std::vector<char> buf(count);
std::snprintf (&buf[0], count, format, std::forward<Args>(args)...); std::snprintf (&buf[0], count, format, std::forward<Args>(args)...);
const auto& fsys = FTerm::getFSystem();
if ( fsys ) fsys->tputs (&buf[0], 1, FTerm::putchar_ASCII);
fsys->tputs (&buf[0], 1, FTerm::putchar_ASCII);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -60,17 +60,14 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "final/ftermcap.h"
// FTermcap string macro // FTermcap string macro
#define TCAP(...) FTermcap::strings[__VA_ARGS__].string #define TCAP(...) FTermcap::strings[__VA_ARGS__].string
namespace finalcut namespace finalcut
{ {
// class forward declaration
class FSystem;
class FTermData;
class FTermDetection;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FTermcap // class FTermcap
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -148,10 +145,8 @@ class FTermcap final
static int _tputs (const char*, int, fn_putc); static int _tputs (const char*, int, fn_putc);
// Data member // Data member
static FSystem* fsystem; static char string_buf[BUF_SIZE];
static FTermData* fterm_data; static bool initialized;
static FTermDetection* term_detection;
static char string_buf[BUF_SIZE];
}; };
@ -206,7 +201,7 @@ int FTermcap::paddingPrint (const CharT& str, int affcnt, fn_putc putc)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FTermcap::isInitialized() inline bool FTermcap::isInitialized()
{ {
return bool(fsystem && fterm_data && term_detection); return initialized;
} }
} // namespace finalcut } // namespace finalcut

View File

@ -38,10 +38,6 @@
namespace finalcut namespace finalcut
{ {
// class forward declaration
class FTermData;
class FTermDetection;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FTermcapsQuirks // class FTermcapsQuirks
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -77,10 +73,6 @@ class FTermcapQuirks final
static void screen(); static void screen();
static void general(); static void general();
static void ecma48(); static void ecma48();
// Data members
static FTermData* fterm_data;
static FTermDetection* term_detection;
}; };
// FTermcapQuirks inline functions // FTermcapQuirks inline functions

View File

@ -40,8 +40,6 @@ namespace finalcut
// class forward declaration // class forward declaration
class FTerm; class FTerm;
class FTermData;
class FTermDetection;
#if DEBUG #if DEBUG
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -72,14 +70,6 @@ class FTermDebugData final
#if defined(__linux__) #if defined(__linux__)
int getFramebufferBpp(); int getFramebufferBpp();
#endif #endif
// Methods
static void init();
private:
// Data members
static FTermData* data;
static FTermDetection* term_detection;
}; };
#endif // DEBUG #endif // DEBUG

View File

@ -207,9 +207,6 @@ class FTermDetection final
static int gnome_terminal_id; static int gnome_terminal_id;
static const FString* answer_back; static const FString* answer_back;
static const FString* sec_da; static const FString* sec_da;
static FTermData* fterm_data;
static FSystem* fsystem;
static FKeyboard* keyboard;
static FTerminalType terminal_type; static FTerminalType terminal_type;
static colorEnv color_env; static colorEnv color_env;
static secondaryDA secondary_da; static secondaryDA secondary_da;

View File

@ -69,7 +69,6 @@ namespace finalcut
{ {
// class forward declaration // class forward declaration
class FSystem;
class FTermData; class FTermData;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -123,15 +122,12 @@ class FTermFreeBSD final
static bool setFreeBSDAlt2Meta(); static bool setFreeBSDAlt2Meta();
static bool resetFreeBSDAlt2Meta(); static bool resetFreeBSDAlt2Meta();
static bool setFreeBSDCursorStyle (CursorStyle); static bool setFreeBSDCursorStyle (CursorStyle);
static bool isInitialized();
// Data members // Data members
static uInt bsd_alt_keymap; static uInt bsd_alt_keymap;
static CursorStyle cursor_style; static CursorStyle cursor_style;
static bool change_cursorstyle; static bool change_cursorstyle;
static bool meta_sends_escape; static bool meta_sends_escape;
static FSystem* fsystem;
static FTermData* fterm_data;
}; };
@ -157,9 +153,6 @@ inline void FTermFreeBSD::enableMetaSendsEscape()
inline void FTermFreeBSD::disableMetaSendsEscape() inline void FTermFreeBSD::disableMetaSendsEscape()
{ meta_sends_escape = false; } { meta_sends_escape = false; }
//----------------------------------------------------------------------
inline bool FTermFreeBSD::isInitialized()
{ return bool(fsystem && fterm_data); }
#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST) #endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
} // namespace finalcut } // namespace finalcut

View File

@ -65,11 +65,6 @@
namespace finalcut namespace finalcut
{ {
// class forward declaration
class FSystem;
class FTermData;
class FTermDetection;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FTermLinux // class FTermLinux
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -148,7 +143,7 @@ class FTermLinux final
int getFramebuffer_bpp(); int getFramebuffer_bpp();
bool getScreenFont(); bool getScreenFont();
bool getUnicodeMap (); bool getUnicodeMap ();
ModifierKey& getModifierKey(); ModifierKey& getModifierKey();
// Mutators // Mutators
int setScreenFont ( const uChar[], uInt, uInt, uInt int setScreenFont ( const uChar[], uInt, uInt, uInt
@ -187,9 +182,6 @@ class FTermLinux final
bool vga_font{}; bool vga_font{};
bool new_font{}; bool new_font{};
bool has_saved_palette{}; bool has_saved_palette{};
FTermData* fterm_data{nullptr};
FSystem* fsystem{nullptr};
FTermDetection* term_detection{nullptr};
CursorStyle linux_console_cursor_style{}; CursorStyle linux_console_cursor_style{};
console_font_op screen_font{}; console_font_op screen_font{};
unimapdesc screen_unicode_map{}; unimapdesc screen_unicode_map{};

View File

@ -64,9 +64,6 @@
namespace finalcut namespace finalcut
{ {
// class forward declaration
class FSystem;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FTermOpenBSD // class FTermOpenBSD
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -110,12 +107,10 @@ class FTermOpenBSD final
static bool setBSDConsoleEncoding (kbd_t); static bool setBSDConsoleEncoding (kbd_t);
static bool setBSDConsoleMetaEsc(); static bool setBSDConsoleMetaEsc();
static bool resetBSDConsoleEncoding(); static bool resetBSDConsoleEncoding();
static bool isInitialized();
// Data members // Data members
static kbd_t bsd_keyboard_encoding; static kbd_t bsd_keyboard_encoding;
static bool meta_sends_escape; static bool meta_sends_escape;
static FSystem* fsystem;
#endif // defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) #endif // defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
}; };
@ -134,9 +129,6 @@ inline void FTermOpenBSD::enableMetaSendsEscape()
inline void FTermOpenBSD::disableMetaSendsEscape() inline void FTermOpenBSD::disableMetaSendsEscape()
{ meta_sends_escape = false; } { meta_sends_escape = false; }
//----------------------------------------------------------------------
inline bool FTermOpenBSD::isInitialized()
{ return bool(fsystem); }
#endif // defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST) #endif // defined(__NetBSD__) || defined(__OpenBSD__) || defined(UNIT_TEST)
} // namespace finalcut } // namespace finalcut

View File

@ -40,9 +40,6 @@ namespace finalcut
// class forward declaration // class forward declaration
class FString; class FString;
class FSystem;
class FKeyboard;
class FTermDetection;
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FTermXTerminal // class FTermXTerminal
@ -52,7 +49,7 @@ class FTermXTerminal final
{ {
public: public:
// Constructors // Constructors
FTermXTerminal(); FTermXTerminal() = default;
// Disable copy constructor // Disable copy constructor
FTermXTerminal (const FTermXTerminal&) = delete; FTermXTerminal (const FTermXTerminal&) = delete;
@ -97,7 +94,6 @@ class FTermXTerminal final
bool hasTitle() const; bool hasTitle() const;
// Methods // Methods
void init();
void setDefaults(); void setDefaults();
void resetColorMap() const; void resetColorMap() const;
void resetForeground(); void resetForeground();
@ -134,7 +130,6 @@ class FTermXTerminal final
void resetXTermMouseForeground() const; void resetXTermMouseForeground() const;
void resetXTermMouseBackground() const; void resetXTermMouseBackground() const;
void resetXTermHighlightBackground() const; void resetXTermHighlightBackground() const;
bool isInitialized() const;
bool canResetColor() const; bool canResetColor() const;
void oscPrefix() const; void oscPrefix() const;
void oscPostfix() const; void oscPostfix() const;
@ -160,9 +155,6 @@ class FTermXTerminal final
FString mouse_foreground_color{}; FString mouse_foreground_color{};
FString mouse_background_color{}; FString mouse_background_color{};
FString highlight_background_color{}; FString highlight_background_color{};
static FSystem* fsystem;
static FKeyboard* keyboard;
FTermDetection* term_detection{nullptr};
fc::xtermCursorStyle cursor_style{fc::unknown_cursor_style}; fc::xtermCursorStyle cursor_style{fc::unknown_cursor_style};
}; };
@ -228,10 +220,6 @@ inline void FTermXTerminal::setMouseSupport()
inline void FTermXTerminal::unsetMouseSupport() inline void FTermXTerminal::unsetMouseSupport()
{ setMouseSupport (false); } { setMouseSupport (false); }
//----------------------------------------------------------------------
inline bool FTermXTerminal::isInitialized() const
{ return bool(fsystem && term_detection); }
} // namespace finalcut } // namespace finalcut
#endif // FTERMXTERMINAL_H #endif // FTERMXTERMINAL_H

View File

@ -148,7 +148,7 @@ class FToggleButton : public FWidget
// Methods // Methods
void init(); void init();
void drawText (FString&&, std::size_t); void drawText (const FString&, std::size_t);
void correctSize (FSize&) const; void correctSize (FSize&) const;
// Data members // Data members

View File

@ -68,12 +68,10 @@ namespace finalcut
// class forward declaration // class forward declaration
class FColorPair; class FColorPair;
class FMouseControl;
class FPoint; class FPoint;
class FRect; class FRect;
class FSize; class FSize;
class FString; class FString;
class FSystem;
class FTerm; class FTerm;
class FTermBuffer; class FTermBuffer;
class FTermDebugData; class FTermDebugData;
@ -370,7 +368,7 @@ class FVTerm
static FChar getCoveredCharacter (const FPoint&, const FTermArea*); static FChar getCoveredCharacter (const FPoint&, const FTermArea*);
static FChar getOverlappedCharacter (const FPoint&, const FTermArea*); static FChar getOverlappedCharacter (const FPoint&, const FTermArea*);
void init(); void init();
static void init_characterLengths (const FOptiMove*); static void init_characterLengths();
void finish(); void finish();
static void putAreaLine (const FChar&, FChar&, std::size_t); static void putAreaLine (const FChar&, FChar&, std::size_t);
static void putAreaCharacter ( const FPoint&, const FTermArea* static void putAreaCharacter ( const FPoint&, const FTermArea*
@ -426,7 +424,6 @@ class FVTerm
FTermArea* child_print_area{nullptr}; // print area for children FTermArea* child_print_area{nullptr}; // print area for children
FTermArea* vwin{nullptr}; // virtual window FTermArea* vwin{nullptr}; // virtual window
static const FVTerm* init_object; // Global FVTerm object static const FVTerm* init_object; // Global FVTerm object
static FSystem* fsystem;
static FTerm* fterm; static FTerm* fterm;
static FTermArea* vterm; // virtual terminal static FTermArea* vterm; // virtual terminal
static FTermArea* vdesktop; // virtual desktop static FTermArea* vdesktop; // virtual desktop
@ -437,7 +434,6 @@ class FVTerm
static FChar s_ch; // shadow character static FChar s_ch; // shadow character
static FChar i_ch; // inherit background character static FChar i_ch; // inherit background character
static FPoint* term_pos; // terminal cursor position static FPoint* term_pos; // terminal cursor position
static FMouseControl* mouse;
static timeval time_last_flush; static timeval time_last_flush;
static timeval last_term_size_check; static timeval last_term_size_check;
static bool draw_completed; static bool draw_completed;
@ -492,6 +488,11 @@ struct FVTerm::FTermArea // define virtual terminal character properties
bool visible{false}; bool visible{false};
}; };
struct D
{
void operator () (const FVTerm*) const
{ }
};
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// struct FVTerm::FVTermPreprocessing // struct FVTerm::FVTermPreprocessing
@ -500,16 +501,19 @@ struct FVTerm::FTermArea // define virtual terminal character properties
struct FVTerm::FVTermPreprocessing struct FVTerm::FVTermPreprocessing
{ {
// Constructor // Constructor
FVTermPreprocessing() = default;
FVTermPreprocessing (const FVTerm* i, const FPreprocessingFunction& f) FVTermPreprocessing (const FVTerm* i, const FPreprocessingFunction& f)
: instance(i) : instance(std::unique_ptr<const FVTerm, D>(i))
, function(f) , function(f)
{ } { }
FVTermPreprocessing (const FVTermPreprocessing&) = delete;
FVTermPreprocessing (FVTermPreprocessing&&) = default;
FVTermPreprocessing& operator = (const FVTermPreprocessing&) = delete;
FVTermPreprocessing& operator = (FVTermPreprocessing&&) noexcept = default;
// Data members // Data members
const FVTerm* instance{nullptr}; std::unique_ptr<const FVTerm, D> instance{};
FPreprocessingFunction function{nullptr}; FPreprocessingFunction function{};
}; };

View File

@ -48,10 +48,10 @@ class FWidgetColors
{ {
public: public:
// Constructor // Constructor
FWidgetColors(); FWidgetColors() = default;
// Destructor // Destructor
virtual ~FWidgetColors(); virtual ~FWidgetColors() noexcept;
// Method // Method
virtual FString getClassName() const; virtual FString getClassName() const;
@ -176,7 +176,7 @@ class default8ColorTheme final : public FWidgetColors
default8ColorTheme(); default8ColorTheme();
// Destructor // Destructor
~default8ColorTheme() override; ~default8ColorTheme() noexcept override;
// Method // Method
FString getClassName() const override; FString getClassName() const override;
@ -213,7 +213,7 @@ class default16ColorTheme final : public FWidgetColors
default16ColorTheme(); default16ColorTheme();
// Destructor // Destructor
~default16ColorTheme() override; ~default16ColorTheme() noexcept override;
// Method // Method
FString getClassName() const override; FString getClassName() const override;
@ -250,7 +250,7 @@ class default8ColorDarkTheme final : public FWidgetColors
default8ColorDarkTheme(); default8ColorDarkTheme();
// Destructor // Destructor
~default8ColorDarkTheme() override; ~default8ColorDarkTheme() noexcept override;
// Method // Method
FString getClassName() const override; FString getClassName() const override;
@ -287,7 +287,7 @@ class default16ColorDarkTheme final : public FWidgetColors
default16ColorDarkTheme(); default16ColorDarkTheme();
// Destructor // Destructor
~default16ColorDarkTheme() override; ~default16ColorDarkTheme() noexcept override;
// Method // Method
FString getClassName() const override; FString getClassName() const override;

View File

@ -531,7 +531,7 @@ inline pid_t ConEmu::forkConEmu()
#ifdef TIOCSWINSZ #ifdef TIOCSWINSZ
// Set slave tty window size // Set slave tty window size
struct winsize size; struct winsize size{};
size.ws_row = 25; size.ws_row = 25;
size.ws_col = 80; size.ws_col = 80;

View File

@ -573,7 +573,6 @@ struct keymap_t& FSystemTest::getTerminalKeymap()
return terminal_keymap; return terminal_keymap;
} }
} // namespace test } // namespace test
@ -624,11 +623,10 @@ void ftermfreebsdTest::freebsdConsoleTest()
setenv ("COLUMNS", "80", 1); setenv ("COLUMNS", "80", 1);
setenv ("LINES", "25", 1); setenv ("LINES", "25", 1);
finalcut::FSystem* fsys = new test::FSystemTest(); auto fsys = finalcut::make_unique<test::FSystemTest>();
finalcut::FTermDetection* term_detection{}; finalcut::FTerm::setFSystem(std::move(fsys));
finalcut::FTerm::setFSystem(fsys);
std::cout << "\n"; std::cout << "\n";
finalcut::FTermData* data = finalcut::FTerm::getFTermData(); const auto& data = finalcut::FTerm::getFTermData();
auto& encoding_list = data->getEncodingList(); auto& encoding_list = data->getEncodingList();
encoding_list["UTF-8"] = finalcut::fc::UTF8; encoding_list["UTF-8"] = finalcut::fc::UTF8;
@ -655,10 +653,9 @@ void ftermfreebsdTest::freebsdConsoleTest()
data->setVGAFont (false); data->setVGAFont (false);
data->setMonochron (false); data->setMonochron (false);
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));
term_detection = finalcut::FTerm::getFTermDetection(); const auto& term_detection = finalcut::FTerm::getFTermDetection();
term_detection->setTerminalDetection(true); term_detection->setTerminalDetection(true);
pid_t pid = forkConEmu(); pid_t pid = forkConEmu();
@ -666,7 +663,8 @@ void ftermfreebsdTest::freebsdConsoleTest()
{ {
static constexpr int left_alt = 0x38; static constexpr int left_alt = 0x38;
finalcut::FTermFreeBSD freebsd; finalcut::FTermFreeBSD freebsd;
test::FSystemTest* fsystest = static_cast<test::FSystemTest*>(fsys); const auto& fsystem = finalcut::FTerm::getFSystem();
auto fsystest = static_cast<test::FSystemTest*>(fsystem.get());
struct keymap_t& keymap = fsystest->getTerminalKeymap(); struct keymap_t& keymap = fsystest->getTerminalKeymap();
setenv ("TERM", "xterm", 1); setenv ("TERM", "xterm", 1);
@ -760,7 +758,7 @@ void ftermfreebsdTest::freebsdConsoleTest()
#if DEBUG #if DEBUG
const finalcut::FString& sec_da = \ const finalcut::FString& sec_da = \
finalcut::FTerm::getFTermDebugData().getSecDAString(); finalcut::FTerm::getFTermDebugData()->getSecDAString();
CPPUNIT_ASSERT ( sec_da == "\033[>0;10;0c" ); CPPUNIT_ASSERT ( sec_da == "\033[>0;10;0c" );
#endif #endif
@ -773,6 +771,7 @@ void ftermfreebsdTest::freebsdConsoleTest()
data->setCursorHidden (false); data->setCursorHidden (false);
freebsd.setCursorStyle (finalcut::fc::normal_cursor); freebsd.setCursorStyle (finalcut::fc::normal_cursor);
CPPUNIT_ASSERT ( fsystest->getCursorType() == finalcut::fc::normal_cursor ); CPPUNIT_ASSERT ( fsystest->getCursorType() == finalcut::fc::normal_cursor );
freebsd.setCursorStyle (finalcut::fc::blink_cursor); freebsd.setCursorStyle (finalcut::fc::blink_cursor);
@ -812,8 +811,6 @@ void ftermfreebsdTest::freebsdConsoleTest()
if ( waitpid(pid, 0, WUNTRACED) != pid ) if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl; std::cerr << "waitpid error" << std::endl;
} }
delete fsys;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -994,10 +994,16 @@ FSystemTest::FSystemTest() // constructor
FSystemTest::~FSystemTest() // destructor FSystemTest::~FSystemTest() // destructor
{ {
if ( terminal_font.data ) if ( terminal_font.data )
{
delete[] terminal_font.data; delete[] terminal_font.data;
terminal_font.data = nullptr;
}
if ( terminal_unicode_map.entries ) if ( terminal_unicode_map.entries )
{
delete[] terminal_unicode_map.entries; delete[] terminal_unicode_map.entries;
terminal_unicode_map.entries = nullptr;
}
} }
@ -1091,19 +1097,25 @@ int FSystemTest::ioctl (int fd, uLong request, ...)
constexpr std::size_t font_data_size = 4 * 32 * 512; constexpr std::size_t font_data_size = 4 * 32 * 512;
struct console_font_op* fn = static_cast<console_font_op*>(argp); struct console_font_op* fn = static_cast<console_font_op*>(argp);
// Set Default
if ( terminal_font.data && terminal_font.data[219 * 32] == 0 )
{
terminal_font.width = 8;
terminal_font.height = 16;
terminal_font.charcount = 256;
if ( fn->data )
std::memcpy (terminal_font.data, &vga8x16, sizeof(vga8x16));
}
if ( fn->op == KD_FONT_OP_GET ) if ( fn->op == KD_FONT_OP_GET )
{ {
// If data is empty
if ( ! terminal_font.data )
{
terminal_font.data = new uChar[font_data_size]{ };
}
// Set Default
if ( terminal_font.data[219 * 32] == 0 )
{
terminal_font.width = 8;
terminal_font.height = 16;
terminal_font.charcount = 256;
if ( fn->data )
std::memcpy (terminal_font.data, &vga8x16, sizeof(vga8x16));
}
fn->flags = terminal_font.flags; fn->flags = terminal_font.flags;
fn->width = terminal_font.width; fn->width = terminal_font.width;
fn->height = terminal_font.height; fn->height = terminal_font.height;
@ -1117,11 +1129,17 @@ int FSystemTest::ioctl (int fd, uLong request, ...)
if ( fn->op == KD_FONT_OP_SET ) if ( fn->op == KD_FONT_OP_SET )
{ {
terminal_font.flags = fn->flags; terminal_font.flags = fn->flags;
terminal_font.width = fn->width; terminal_font.width = fn->width;
terminal_font.height = fn->height; terminal_font.height = fn->height;
terminal_font.charcount = fn->charcount; terminal_font.charcount = fn->charcount;
auto size = fn->width / 8 * fn->height * fn->charcount; constexpr int fix_height = 32; // This value is identical for all fonts
auto size = fn->width / 8 * fix_height * fn->charcount;
if ( ! terminal_font.data ) // If data is empty on a second run
{
terminal_font.data = new uChar[font_data_size]{ };
}
if ( fn->data && terminal_font.data ) if ( fn->data && terminal_font.data )
std::memcpy (terminal_font.data, fn->data, size); std::memcpy (terminal_font.data, fn->data, size);
@ -1194,7 +1212,7 @@ int FSystemTest::ioctl (int fd, uLong request, ...)
std::size_t pairs_size = pairs * sizeof(unipair); std::size_t pairs_size = pairs * sizeof(unipair);
// Sets the default unicode map of the terminal on the first call // Sets the default unicode map of the terminal on the first call
if ( terminal_unicode_map.entries == 0 ) if ( ! terminal_unicode_map.entries )
{ {
terminal_unicode_map.entry_ct = pairs; terminal_unicode_map.entry_ct = pairs;
terminal_unicode_map.entries = new unipair[pairs](); terminal_unicode_map.entries = new unipair[pairs]();
@ -1222,8 +1240,30 @@ int FSystemTest::ioctl (int fd, uLong request, ...)
{ {
req_string = "PIO_UNIMAP"; req_string = "PIO_UNIMAP";
unimapdesc* umap = static_cast<unimapdesc*>(argp); unimapdesc* umap = static_cast<unimapdesc*>(argp);
std::memcpy (&terminal_unicode_map, umap, sizeof(*umap)); std::size_t pairs = umap->entry_ct;
ret_val = 0; std::size_t pairs_size = pairs * sizeof(unipair);
terminal_unicode_map.entry_ct = umap->entry_ct;
if ( terminal_unicode_map.entries )
{
delete[] terminal_unicode_map.entries;
terminal_unicode_map.entries = nullptr;
}
terminal_unicode_map.entries = new unipair[pairs]();
if ( umap->entries && terminal_unicode_map.entries )
{
std::memcpy (terminal_unicode_map.entries, umap->entries, pairs_size);
errno = 0;
ret_val = 0;
}
else
{
errno = ENOMEM;
ret_val = 0;
}
break; break;
} }
@ -1519,11 +1559,10 @@ void FTermLinuxTest::classNameTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermLinuxTest::linuxConsoleTest() void FTermLinuxTest::linuxConsoleTest()
{ {
finalcut::FSystem* fsys = new test::FSystemTest(); auto fsys = finalcut::make_unique<test::FSystemTest>();
finalcut::FTerm::setFSystem(fsys); finalcut::FTerm::setFSystem(std::move(fsys));
finalcut::FTermDetection* term_detection{};
std::cout << "\n"; std::cout << "\n";
finalcut::FTermData* data = finalcut::FTerm::getFTermData(); const auto& data = finalcut::FTerm::getFTermData();
auto& encoding_list = data->getEncodingList(); auto& encoding_list = data->getEncodingList();
encoding_list["UTF-8"] = finalcut::fc::UTF8; encoding_list["UTF-8"] = finalcut::fc::UTF8;
@ -1555,7 +1594,7 @@ void FTermLinuxTest::linuxConsoleTest()
data->setMonochron (false); data->setMonochron (false);
data->setTermResized (false); data->setTermResized (false);
term_detection = finalcut::FTerm::getFTermDetection(); const auto& term_detection = finalcut::FTerm::getFTermDetection();
finalcut::FTermLinux linux; finalcut::FTermLinux linux;
// setupterm is needed for tputs in ncurses >= 6.1 // setupterm is needed for tputs in ncurses >= 6.1
@ -1590,7 +1629,8 @@ void FTermLinuxTest::linuxConsoleTest()
CPPUNIT_ASSERT ( data->hasHalfBlockCharacter() ); CPPUNIT_ASSERT ( data->hasHalfBlockCharacter() );
CPPUNIT_ASSERT ( linux.getFramebufferBpp() == 32 ); CPPUNIT_ASSERT ( linux.getFramebufferBpp() == 32 );
test::FSystemTest* fsystest = static_cast<test::FSystemTest*>(fsys); const auto& fsystem = finalcut::FTerm::getFSystem();
auto fsystest = static_cast<test::FSystemTest*>(fsystem.get());
std::string& characters = fsystest->getCharacters(); std::string& characters = fsystest->getCharacters();
linux.setUTF8 (false); linux.setUTF8 (false);
CPPUNIT_ASSERT ( characters == ESC "%@" ); CPPUNIT_ASSERT ( characters == ESC "%@" );
@ -1636,18 +1676,15 @@ void FTermLinuxTest::linuxConsoleTest()
if ( waitpid(pid, 0, WUNTRACED) != pid ) if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl; std::cerr << "waitpid error" << std::endl;
} }
delete fsys;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermLinuxTest::linuxCursorStyleTest() void FTermLinuxTest::linuxCursorStyleTest()
{ {
finalcut::FSystem* fsys = new test::FSystemTest(); auto fsys = finalcut::make_unique<test::FSystemTest>();
finalcut::FTerm::setFSystem(fsys); finalcut::FTerm::setFSystem(std::move(fsys));
finalcut::FTermDetection* term_detection{};
std::cout << "\n"; std::cout << "\n";
finalcut::FTermData* data = finalcut::FTerm::getFTermData(); const auto& data = finalcut::FTerm::getFTermData();
auto& encoding_list = data->getEncodingList(); auto& encoding_list = data->getEncodingList();
encoding_list["UTF-8"] = finalcut::fc::UTF8; encoding_list["UTF-8"] = finalcut::fc::UTF8;
@ -1681,7 +1718,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));
term_detection = finalcut::FTerm::getFTermDetection(); const auto& term_detection = finalcut::FTerm::getFTermDetection();
finalcut::FTermLinux linux; finalcut::FTermLinux linux;
pid_t pid = forkConEmu(); pid_t pid = forkConEmu();
@ -1704,7 +1741,8 @@ void FTermLinuxTest::linuxCursorStyleTest()
term_detection->detect(); term_detection->detect();
linux.init(); linux.init();
test::FSystemTest* fsystest = static_cast<test::FSystemTest*>(fsys); const auto& fsystem = finalcut::FTerm::getFSystem();
auto fsystest = static_cast<test::FSystemTest*>(fsystem.get());
std::string& characters = fsystest->getCharacters(); std::string& characters = fsystest->getCharacters();
characters.clear(); characters.clear();
linux.setCursorStyle (finalcut::fc::default_cursor); linux.setCursorStyle (finalcut::fc::default_cursor);
@ -1827,18 +1865,15 @@ void FTermLinuxTest::linuxCursorStyleTest()
if ( waitpid(pid, 0, WUNTRACED) != pid ) if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl; std::cerr << "waitpid error" << std::endl;
} }
delete fsys;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermLinuxTest::linuxColorPaletteTest() void FTermLinuxTest::linuxColorPaletteTest()
{ {
finalcut::FSystem* fsys = new test::FSystemTest(); auto fsys = finalcut::make_unique<test::FSystemTest>();
finalcut::FTerm::setFSystem(fsys); finalcut::FTerm::setFSystem(std::move(fsys));
finalcut::FTermDetection* term_detection{};
std::cout << "\n"; std::cout << "\n";
finalcut::FTermData* data = finalcut::FTerm::getFTermData(); const auto& data = finalcut::FTerm::getFTermData();
auto& encoding_list = data->getEncodingList(); auto& encoding_list = data->getEncodingList();
encoding_list["UTF-8"] = finalcut::fc::UTF8; encoding_list["UTF-8"] = finalcut::fc::UTF8;
@ -1872,7 +1907,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));
term_detection = finalcut::FTerm::getFTermDetection(); const auto& term_detection = finalcut::FTerm::getFTermDetection();
finalcut::FTermLinux linux; finalcut::FTermLinux linux;
term_detection->setLinuxTerm(true); term_detection->setLinuxTerm(true);
@ -1895,7 +1930,8 @@ void FTermLinuxTest::linuxColorPaletteTest()
term_detection->detect(); term_detection->detect();
linux.init(); linux.init();
test::FSystemTest* fsystest = static_cast<test::FSystemTest*>(fsys); const auto& fsystem = finalcut::FTerm::getFSystem();
auto fsystest = static_cast<test::FSystemTest*>(fsystem.get());
CPPUNIT_ASSERT ( linux.resetColorMap() == true ); CPPUNIT_ASSERT ( linux.resetColorMap() == true );
CPPUNIT_ASSERT ( linux.saveColorMap() == true ); CPPUNIT_ASSERT ( linux.saveColorMap() == true );
@ -2104,18 +2140,15 @@ void FTermLinuxTest::linuxColorPaletteTest()
if ( waitpid(pid, 0, WUNTRACED) != pid ) if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl; std::cerr << "waitpid error" << std::endl;
} }
delete fsys;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermLinuxTest::linuxFontTest() void FTermLinuxTest::linuxFontTest()
{ {
finalcut::FSystem* fsys = new test::FSystemTest(); auto fsys = finalcut::make_unique<test::FSystemTest>();
finalcut::FTerm::setFSystem(fsys); finalcut::FTerm::setFSystem(std::move(fsys));
finalcut::FTermDetection* term_detection{};
std::cout << "\n"; std::cout << "\n";
finalcut::FTermData* data = finalcut::FTerm::getFTermData(); const auto& data = finalcut::FTerm::getFTermData();
auto& encoding_list = data->getEncodingList(); auto& encoding_list = data->getEncodingList();
encoding_list["UTF-8"] = finalcut::fc::UTF8; encoding_list["UTF-8"] = finalcut::fc::UTF8;
@ -2149,7 +2182,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));
term_detection = finalcut::FTerm::getFTermDetection(); const auto& term_detection = finalcut::FTerm::getFTermDetection();
finalcut::FTermLinux linux; finalcut::FTermLinux linux;
pid_t pid = forkConEmu(); pid_t pid = forkConEmu();
@ -2171,18 +2204,19 @@ void FTermLinuxTest::linuxFontTest()
term_detection->detect(); term_detection->detect();
linux.init(); linux.init();
test::FSystemTest* fsystest = static_cast<test::FSystemTest*>(fsys); const auto& fsystem = finalcut::FTerm::getFSystem();
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 );
CPPUNIT_ASSERT ( ! linux.isVGAFontUsed() ); CPPUNIT_ASSERT ( ! linux.isVGAFontUsed() );
CPPUNIT_ASSERT ( ! linux.isNewFontUsed() ); CPPUNIT_ASSERT ( ! linux.isNewFontUsed() );
linux.loadVGAFont(); linux.loadVGAFont();
/* CPPUNIT_ASSERT ( data->hasShadowCharacter() ); CPPUNIT_ASSERT ( data->hasShadowCharacter() );
CPPUNIT_ASSERT ( data->hasHalfBlockCharacter() ); CPPUNIT_ASSERT ( data->hasHalfBlockCharacter() );
CPPUNIT_ASSERT ( font.op == KD_FONT_OP_SET ); CPPUNIT_ASSERT ( font.op == KD_FONT_OP_SET );
CPPUNIT_ASSERT ( linux.isVGAFontUsed() ); CPPUNIT_ASSERT ( linux.isVGAFontUsed() );
CPPUNIT_ASSERT ( ! linux.isNewFontUsed() ); CPPUNIT_ASSERT ( ! linux.isNewFontUsed() );
CPPUNIT_ASSERT ( font.data );
// Full block character test // Full block character test
for (std::size_t i = 0; i < 16 ; i++) for (std::size_t i = 0; i < 16 ; i++)
@ -2235,7 +2269,7 @@ void FTermLinuxTest::linuxFontTest()
CPPUNIT_ASSERT ( font.data[249 * 32 + 13] == 0x00 ); CPPUNIT_ASSERT ( font.data[249 * 32 + 13] == 0x00 );
CPPUNIT_ASSERT ( font.data[249 * 32 + 14] == 0x00 ); CPPUNIT_ASSERT ( font.data[249 * 32 + 14] == 0x00 );
CPPUNIT_ASSERT ( font.data[249 * 32 + 15] == 0x00 ); CPPUNIT_ASSERT ( font.data[249 * 32 + 15] == 0x00 );
*/
linux.finish(); linux.finish();
closeConEmuStdStreams(); closeConEmuStdStreams();
@ -2249,19 +2283,20 @@ void FTermLinuxTest::linuxFontTest()
if ( waitpid(pid, 0, WUNTRACED) != pid ) if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl; std::cerr << "waitpid error" << std::endl;
} }
delete fsys;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermLinuxTest::modifierKeyTest() void FTermLinuxTest::modifierKeyTest()
{ {
auto fsys = finalcut::make_unique<test::FSystemTest>();
finalcut::FTerm::setFSystem(std::move(fsys));
const auto& fsystem = finalcut::FTerm::getFSystem();
auto fsystest = static_cast<test::FSystemTest*>(fsystem.get());
test::FSystemTest::ShiftState& mod_key = fsystest->getShiftState();
finalcut::FTermLinux linux{};
FKey keycode{}; FKey keycode{};
FKey mod_keycode{}; FKey mod_keycode{};
finalcut::FTermLinux linux{};
finalcut::FSystem* fsys(new test::FSystemTest());
test::FSystemTest* fsystest = static_cast<test::FSystemTest*>(fsys);
test::FSystemTest::ShiftState& mod_key = fsystest->getShiftState();
// Up key // Up key
keycode = finalcut::fc::Fkey_up; keycode = finalcut::fc::Fkey_up;
@ -2721,7 +2756,6 @@ void FTermLinuxTest::modifierKeyTest()
mod_key.shift = 1; mod_key.shift = 1;
mod_keycode = linux.modifierKeyCorrection(keycode); mod_keycode = linux.modifierKeyCorrection(keycode);
CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_space ); CPPUNIT_ASSERT ( mod_keycode == finalcut::fc::Fkey_space );
delete fsys;
} }
// Put the test suite in the registry // Put the test suite in the registry

View File

@ -345,11 +345,10 @@ void ftermopenbsdTest::classNameTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void ftermopenbsdTest::netbsdConsoleTest() void ftermopenbsdTest::netbsdConsoleTest()
{ {
finalcut::FSystem* fsys = new test::FSystemTest(); auto fsys = finalcut::make_unique<test::FSystemTest>();
finalcut::FTerm::setFSystem(fsys); finalcut::FTerm::setFSystem(std::move(fsys));
finalcut::FTermDetection* term_detection{};
std::cout << "\n"; std::cout << "\n";
finalcut::FTermData* data = finalcut::FTerm::getFTermData(); const auto& data = finalcut::FTerm::getFTermData();
auto& encoding_list = data->getEncodingList(); auto& encoding_list = data->getEncodingList();
encoding_list["UTF-8"] = finalcut::fc::UTF8; encoding_list["UTF-8"] = finalcut::fc::UTF8;
@ -379,7 +378,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));
term_detection = finalcut::FTerm::getFTermDetection(); const auto& term_detection = finalcut::FTerm::getFTermDetection();
term_detection->setTerminalDetection(true); term_detection->setTerminalDetection(true);
pid_t pid = forkConEmu(); pid_t pid = forkConEmu();
@ -407,7 +406,7 @@ void ftermopenbsdTest::netbsdConsoleTest()
#if DEBUG #if DEBUG
const finalcut::FString& sec_da = \ const finalcut::FString& sec_da = \
finalcut::FTerm::getFTermDebugData().getSecDAString(); finalcut::FTerm::getFTermDebugData()->getSecDAString();
CPPUNIT_ASSERT ( sec_da == "\033[>24;20;0c" ); CPPUNIT_ASSERT ( sec_da == "\033[>24;20;0c" );
#endif #endif
@ -445,18 +444,15 @@ void ftermopenbsdTest::netbsdConsoleTest()
if ( waitpid(pid, 0, WUNTRACED) != pid ) if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl; std::cerr << "waitpid error" << std::endl;
} }
delete fsys;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void ftermopenbsdTest::openbsdConsoleTest() void ftermopenbsdTest::openbsdConsoleTest()
{ {
finalcut::FSystem* fsys = new test::FSystemTest(); auto fsys = finalcut::make_unique<test::FSystemTest>();
finalcut::FTerm::setFSystem(fsys); finalcut::FTerm::setFSystem(std::move(fsys));
finalcut::FTermDetection* term_detection{};
std::cout << "\n"; std::cout << "\n";
finalcut::FTermData* data = finalcut::FTerm::getFTermData(); const auto& data = finalcut::FTerm::getFTermData();
auto& encoding_list = data->getEncodingList(); auto& encoding_list = data->getEncodingList();
encoding_list["UTF-8"] = finalcut::fc::UTF8; encoding_list["UTF-8"] = finalcut::fc::UTF8;
@ -486,7 +482,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));
term_detection = finalcut::FTerm::getFTermDetection(); const auto& term_detection = finalcut::FTerm::getFTermDetection();
term_detection->setTerminalDetection(true); term_detection->setTerminalDetection(true);
pid_t pid = forkConEmu(); pid_t pid = forkConEmu();
@ -507,7 +503,8 @@ void ftermopenbsdTest::openbsdConsoleTest()
unsetenv("KONSOLE_DCOP"); unsetenv("KONSOLE_DCOP");
unsetenv("TMUX"); unsetenv("TMUX");
test::FSystemTest* fsystest = static_cast<test::FSystemTest*>(fsys); const auto& fsystem = finalcut::FTerm::getFSystem();
auto fsystest = static_cast<test::FSystemTest*>(fsystem.get());
wskbd_bell_data& speaker = fsystest->getBell(); wskbd_bell_data& speaker = fsystest->getBell();
openbsd.disableMetaSendsEscape(); openbsd.disableMetaSendsEscape();
openbsd.init(); openbsd.init();
@ -516,7 +513,7 @@ void ftermopenbsdTest::openbsdConsoleTest()
#if DEBUG #if DEBUG
const finalcut::FString& sec_da = \ const finalcut::FString& sec_da = \
finalcut::FTerm::getFTermDebugData().getSecDAString(); finalcut::FTerm::getFTermDebugData()->getSecDAString();
CPPUNIT_ASSERT ( sec_da == "\033[>24;20;0c" ); CPPUNIT_ASSERT ( sec_da == "\033[>24;20;0c" );
#endif #endif
@ -583,8 +580,6 @@ void ftermopenbsdTest::openbsdConsoleTest()
if ( waitpid(pid, 0, WUNTRACED) != pid ) if ( waitpid(pid, 0, WUNTRACED) != pid )
std::cerr << "waitpid error" << std::endl; std::cerr << "waitpid error" << std::endl;
} }
delete fsys;
} }