Refactoring of some methods
This commit is contained in:
parent
396cda69e8
commit
12ec2b0574
|
@ -283,10 +283,7 @@ EventLog::EventLog (finalcut::FWidget* parent)
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
EventLog::~EventLog() // destructor
|
EventLog::~EventLog() // destructor
|
||||||
{
|
{ }
|
||||||
if ( event_dialog )
|
|
||||||
delete event_dialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void EventLog::onTimer (finalcut::FTimerEvent*)
|
void EventLog::onTimer (finalcut::FTimerEvent*)
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
* <http://www.gnu.org/licenses/>. *
|
* <http://www.gnu.org/licenses/>. *
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
|
|
||||||
#include <array>
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -70,7 +69,7 @@ uInt64 FApplication::next_event_wait {5000}; // preset to 5 ms (200
|
||||||
struct timeval FApplication::time_last_event{};
|
struct timeval FApplication::time_last_event{};
|
||||||
|
|
||||||
|
|
||||||
constexpr FApplication::CmdOption FApplication::long_options[] =
|
const std::vector<FApplication::CmdOption> FApplication::long_options =
|
||||||
{
|
{
|
||||||
{"encoding", required_argument, nullptr, 'e' },
|
{"encoding", required_argument, nullptr, 'e' },
|
||||||
{"log-file", required_argument, nullptr, 'l' },
|
{"log-file", required_argument, nullptr, 'l' },
|
||||||
|
@ -485,81 +484,70 @@ void FApplication::setTerminalEncoding (const FString& enc_str)
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FApplication::cmd_options (const int& argc, char* argv[])
|
inline FApplication::CmdMap& FApplication::mapCmdOptions()
|
||||||
|
{
|
||||||
|
using std::placeholders::_1;
|
||||||
|
auto enc = std::bind(&FApplication::setTerminalEncoding, _1);
|
||||||
|
auto log = std::bind(&FApplication::setLogFile, _1);
|
||||||
|
auto opt = &FApplication::getStartOptions;
|
||||||
|
static CmdMap cmd_map{};
|
||||||
|
|
||||||
|
// --encoding
|
||||||
|
cmd_map['e'] = [enc] (char* arg) { enc(FString(arg)); };
|
||||||
|
// --log-file
|
||||||
|
cmd_map['l'] = [log] (char* arg) { log(FString(arg)); };
|
||||||
|
// --no-mouse
|
||||||
|
cmd_map['m'] = [opt] (char*) { opt().mouse_support = false; };
|
||||||
|
// --no-optimized-cursor
|
||||||
|
cmd_map['o'] = [opt] (char*) { opt().cursor_optimisation = false; };
|
||||||
|
// --no-terminal-detection
|
||||||
|
cmd_map['d'] = [opt] (char*) { opt().terminal_detection = false; };
|
||||||
|
// --no-terminal-data-request
|
||||||
|
cmd_map['r'] = [opt] (char*) { opt().terminal_data_request = false; };
|
||||||
|
// --no-color-change
|
||||||
|
cmd_map['c'] = [opt] (char*) { opt().color_change = false; };
|
||||||
|
// --no-sgr-optimizer
|
||||||
|
cmd_map['s'] = [opt] (char*) { opt().sgr_optimizer = false; };
|
||||||
|
// --vgafont
|
||||||
|
cmd_map['v'] = [opt] (char*) { opt().vgafont = true; };
|
||||||
|
// --newfont
|
||||||
|
cmd_map['n'] = [opt] (char*) { opt().newfont = true; };
|
||||||
|
// --dark-theme
|
||||||
|
cmd_map['t'] = [opt] (char*) { opt().dark_theme = true; };
|
||||||
|
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
||||||
|
// --no-esc-for-alt-meta
|
||||||
|
cmd_map['E'] = [opt] (char*) { opt().meta_sends_escape = false; };
|
||||||
|
// --no-cursorstyle-change
|
||||||
|
cmd_map['C'] = [opt] (char*) { opt().change_cursorstyle = false; };
|
||||||
|
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
|
// --no-esc-for-alt-meta
|
||||||
|
cmd_map['E'] = [opt] (char*) { opt().meta_sends_escape = false; };
|
||||||
|
#endif
|
||||||
|
return cmd_map;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FApplication::cmdOptions (const int& argc, char* argv[])
|
||||||
{
|
{
|
||||||
// Interpret the command line options
|
// Interpret the command line options
|
||||||
|
|
||||||
|
auto& cmd_map = mapCmdOptions();
|
||||||
|
|
||||||
while ( true )
|
while ( true )
|
||||||
{
|
{
|
||||||
opterr = 0;
|
opterr = 0;
|
||||||
int idx{0};
|
int idx{0};
|
||||||
auto p = reinterpret_cast<const struct option*>(long_options);
|
auto p = reinterpret_cast<const struct option*>(long_options.data());
|
||||||
const int opt = getopt_long (argc, argv, "", p, &idx);
|
const int opt = getopt_long (argc, argv, "", p, &idx);
|
||||||
|
|
||||||
if ( opt == -1 )
|
if ( opt == -1 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
switch ( opt )
|
if ( cmd_map.find(opt) != cmd_map.end() )
|
||||||
{
|
cmd_map[opt](optarg);
|
||||||
case 'e': // --encoding
|
|
||||||
setTerminalEncoding(FString(optarg));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'l': // --log-file
|
|
||||||
setLogFile(FString(optarg));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'm': // --no-mouse
|
|
||||||
getStartOptions().mouse_support = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'o': // --no-optimized-cursor
|
|
||||||
getStartOptions().cursor_optimisation = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'd': // --no-terminal-detection
|
|
||||||
getStartOptions().terminal_detection = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'r': // --no-terminal-data-request
|
|
||||||
getStartOptions().terminal_data_request = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'c': // --no-color-change
|
|
||||||
getStartOptions().color_change = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 's': // --no-sgr-optimizer
|
|
||||||
getStartOptions().sgr_optimizer = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'v': // --vgafont
|
|
||||||
getStartOptions().vgafont = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'n': // --newfont
|
|
||||||
getStartOptions().newfont = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 't': // --dark-theme
|
|
||||||
getStartOptions().dark_theme = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
#if defined(__FreeBSD__) || defined(__DragonFly__)
|
|
||||||
case 'E': // --no-esc-for-alt-meta
|
|
||||||
getStartOptions().meta_sends_escape = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'C': // --no-cursorstyle-change
|
|
||||||
getStartOptions().change_cursorstyle = false;
|
|
||||||
break;
|
|
||||||
#elif defined(__NetBSD__) || defined(__OpenBSD__)
|
|
||||||
case 'E': // --no-esc-for-alt-meta
|
|
||||||
getStartOptions().meta_sends_escape = false;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd_map.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -848,34 +836,30 @@ bool FApplication::processAccelerator (const FWidget* const& widget) const
|
||||||
{
|
{
|
||||||
bool accpt{false};
|
bool accpt{false};
|
||||||
|
|
||||||
if ( widget
|
if ( widget && widget->getAcceleratorList().empty() )
|
||||||
&& ! widget->getAcceleratorList().empty() )
|
return accpt;
|
||||||
{
|
|
||||||
auto iter = widget->getAcceleratorList().begin();
|
|
||||||
const auto& last = widget->getAcceleratorList().end();
|
|
||||||
|
|
||||||
while ( iter != last && ! quit_now && ! app_exit_loop )
|
for (auto&& item : widget->getAcceleratorList())
|
||||||
{
|
{
|
||||||
if ( iter->key == keyboard->getKey() )
|
if ( item.key == keyboard->getKey() )
|
||||||
{
|
{
|
||||||
// unset the move/size mode
|
// unset the move/size mode
|
||||||
auto move_size = getMoveSizeWidget();
|
auto move_size = getMoveSizeWidget();
|
||||||
|
|
||||||
if ( move_size )
|
if ( move_size )
|
||||||
{
|
{
|
||||||
auto w = move_size;
|
|
||||||
setMoveSizeWidget(nullptr);
|
setMoveSizeWidget(nullptr);
|
||||||
w->redraw();
|
move_size->redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
FAccelEvent a_ev (fc::Accelerator_Event, getFocusWidget());
|
FAccelEvent a_ev (fc::Accelerator_Event, getFocusWidget());
|
||||||
sendEvent (iter->object, &a_ev);
|
sendEvent (item.object, &a_ev);
|
||||||
accpt = a_ev.isAccepted();
|
accpt = a_ev.isAccepted();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
++iter;
|
if ( quit_now || app_exit_loop )
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return accpt;
|
return accpt;
|
||||||
|
@ -1225,7 +1209,7 @@ FWidget* FApplication::processParameters (const int& argc, char* argv[])
|
||||||
FApplication::exit(EXIT_SUCCESS);
|
FApplication::exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_options (argc, argv);
|
cmdOptions (argc, argv);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -309,40 +309,7 @@ void FButtonGroup::onAccel (FAccelEvent*)
|
||||||
void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
|
void FButtonGroup::onFocusIn (FFocusEvent* in_ev)
|
||||||
{
|
{
|
||||||
in_ev->ignore(); // Change default value to ignore
|
in_ev->ignore(); // Change default value to ignore
|
||||||
|
focusInRadioButton (in_ev);
|
||||||
if ( hasCheckedButton() && ! buttonlist.empty() )
|
|
||||||
{
|
|
||||||
for (auto&& item : buttonlist)
|
|
||||||
{
|
|
||||||
auto toggle_button = static_cast<FToggleButton*>(item);
|
|
||||||
|
|
||||||
if ( toggle_button->isChecked() )
|
|
||||||
{
|
|
||||||
if ( isRadioButton(toggle_button) )
|
|
||||||
{
|
|
||||||
auto prev_element = getFocusWidget();
|
|
||||||
|
|
||||||
toggle_button->setFocus();
|
|
||||||
|
|
||||||
FFocusEvent cfi (fc::ChildFocusIn_Event);
|
|
||||||
FApplication::sendEvent(this, &cfi);
|
|
||||||
|
|
||||||
FFocusEvent in (fc::FocusIn_Event);
|
|
||||||
FApplication::sendEvent(toggle_button, &in);
|
|
||||||
|
|
||||||
if ( in.isAccepted() )
|
|
||||||
in_ev->accept();
|
|
||||||
|
|
||||||
if ( prev_element )
|
|
||||||
prev_element->redraw();
|
|
||||||
|
|
||||||
toggle_button->redraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} // end of range-based for loop
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! in_ev->isAccepted() )
|
if ( ! in_ev->isAccepted() )
|
||||||
{
|
{
|
||||||
|
@ -484,25 +451,13 @@ void FButtonGroup::drawText ( const FString& label_text
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FButtonGroup::directFocus()
|
bool FButtonGroup::directFocusCheckedRadioButton (FToggleButton* item)
|
||||||
{
|
{
|
||||||
if ( ! hasFocusedButton() )
|
if ( ! isRadioButton(item) )
|
||||||
{
|
return false;
|
||||||
bool found_checked{false};
|
|
||||||
|
|
||||||
if ( hasCheckedButton() && ! buttonlist.empty() )
|
|
||||||
{
|
|
||||||
for (auto&& item : buttonlist)
|
|
||||||
{
|
|
||||||
auto toggle_button = static_cast<FToggleButton*>(item);
|
|
||||||
|
|
||||||
if ( toggle_button->isChecked() )
|
|
||||||
{
|
|
||||||
if ( isRadioButton(toggle_button) )
|
|
||||||
{
|
|
||||||
found_checked = true;
|
|
||||||
auto focused_widget = getFocusWidget();
|
auto focused_widget = getFocusWidget();
|
||||||
toggle_button->setFocus();
|
item->setFocus();
|
||||||
|
|
||||||
if ( focused_widget )
|
if ( focused_widget )
|
||||||
focused_widget->redraw();
|
focused_widget->redraw();
|
||||||
|
@ -511,14 +466,36 @@ void FButtonGroup::directFocus()
|
||||||
|
|
||||||
if ( focused_widget )
|
if ( focused_widget )
|
||||||
focused_widget->redraw();
|
focused_widget->redraw();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
bool FButtonGroup::directFocusRadioButton()
|
||||||
|
{
|
||||||
|
if ( ! hasCheckedButton() || buttonlist.empty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool found_checked{false};
|
||||||
|
|
||||||
|
for (auto&& item : buttonlist)
|
||||||
|
{
|
||||||
|
auto toggle_button = static_cast<FToggleButton*>(item);
|
||||||
|
|
||||||
|
if ( toggle_button->isChecked() )
|
||||||
|
{
|
||||||
|
found_checked = directFocusCheckedRadioButton(toggle_button);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} // end of range-based for loop
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! found_checked )
|
return found_checked;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FButtonGroup::directFocus()
|
||||||
|
{
|
||||||
|
if ( ! hasFocusedButton() && ! directFocusRadioButton() )
|
||||||
{
|
{
|
||||||
auto focused_widget = getFocusWidget();
|
auto focused_widget = getFocusWidget();
|
||||||
focusFirstChild();
|
focusFirstChild();
|
||||||
|
@ -531,7 +508,6 @@ void FButtonGroup::directFocus()
|
||||||
if ( focused_widget )
|
if ( focused_widget )
|
||||||
focused_widget->redraw();
|
focused_widget->redraw();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( getStatusBar() )
|
if ( getStatusBar() )
|
||||||
{
|
{
|
||||||
|
@ -541,6 +517,49 @@ void FButtonGroup::directFocus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FButtonGroup::focusCheckedRadioButton ( FToggleButton* toggle_button
|
||||||
|
, FFocusEvent* in_ev )
|
||||||
|
{
|
||||||
|
auto prev_element = getFocusWidget();
|
||||||
|
|
||||||
|
toggle_button->setFocus();
|
||||||
|
|
||||||
|
FFocusEvent cfi (fc::ChildFocusIn_Event);
|
||||||
|
FApplication::sendEvent(this, &cfi);
|
||||||
|
|
||||||
|
FFocusEvent in (fc::FocusIn_Event);
|
||||||
|
FApplication::sendEvent(toggle_button, &in);
|
||||||
|
|
||||||
|
if ( in.isAccepted() )
|
||||||
|
in_ev->accept();
|
||||||
|
|
||||||
|
if ( prev_element )
|
||||||
|
prev_element->redraw();
|
||||||
|
|
||||||
|
toggle_button->redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FButtonGroup::focusInRadioButton (FFocusEvent* in_ev)
|
||||||
|
{
|
||||||
|
if ( ! hasCheckedButton() || buttonlist.empty() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (auto&& item : buttonlist)
|
||||||
|
{
|
||||||
|
auto toggle_button = static_cast<FToggleButton*>(item);
|
||||||
|
|
||||||
|
if ( toggle_button->isChecked() )
|
||||||
|
{
|
||||||
|
if ( isRadioButton(toggle_button) )
|
||||||
|
focusCheckedRadioButton (toggle_button, in_ev);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FButtonGroup::cb_buttonToggled (const FToggleButton* button) const
|
void FButtonGroup::cb_buttonToggled (const FToggleButton* button) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -1622,8 +1622,9 @@ inline bool FListBox::deletePreviousCharacter()
|
||||||
{
|
{
|
||||||
const std::size_t inc_len = inc_search.getLength();
|
const std::size_t inc_len = inc_search.getLength();
|
||||||
|
|
||||||
if ( inc_len > 0 )
|
if ( inc_len <= 0 )
|
||||||
{
|
return false;
|
||||||
|
|
||||||
inc_search.remove(inc_len - 1, 1);
|
inc_search.remove(inc_len - 1, 1);
|
||||||
|
|
||||||
if ( inc_len > 1 )
|
if ( inc_len > 1 )
|
||||||
|
@ -1646,9 +1647,6 @@ inline bool FListBox::deletePreviousCharacter()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline bool FListBox::keyIncSearchInput (FKey key)
|
inline bool FListBox::keyIncSearchInput (FKey key)
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,7 +50,7 @@ FMenuBar::FMenuBar(FWidget* parent)
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
FMenuBar::~FMenuBar() // destructor
|
FMenuBar::~FMenuBar() // destructor
|
||||||
{
|
{
|
||||||
setMenuBar(nullptr);
|
FWidget::setMenuBar(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -713,6 +713,7 @@ bool FTerm::setVGAFont()
|
||||||
data->setVGAFont(true);
|
data->setVGAFont(true);
|
||||||
// Set font in xterm to vga
|
// Set font in xterm to vga
|
||||||
getFTermXTerminal()->setFont("vga");
|
getFTermXTerminal()->setFont("vga");
|
||||||
|
data->setTermEncoding (fc::PC);
|
||||||
data->setNewFont(false);
|
data->setNewFont(false);
|
||||||
}
|
}
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
|
@ -1362,13 +1363,13 @@ void FTerm::init_global_values()
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FTerm::init_terminal_device_path()
|
void FTerm::init_terminal_device_path()
|
||||||
{
|
{
|
||||||
char termfilename[256]{};
|
std::array<char, 256> termfilename{};
|
||||||
const int stdout_no = FTermios::getStdOut();
|
const int stdout_no = FTermios::getStdOut();
|
||||||
|
|
||||||
if ( ttyname_r(stdout_no, termfilename, sizeof(termfilename)) )
|
if ( ttyname_r(stdout_no, termfilename.data(), termfilename.size()) )
|
||||||
termfilename[0] = '\0';
|
termfilename[0] = '\0';
|
||||||
|
|
||||||
data->setTermFileName(termfilename);
|
data->setTermFileName(termfilename.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -2005,21 +2006,22 @@ const char* FTerm::enableCursorString()
|
||||||
// Returns the cursor enable string
|
// Returns the cursor enable string
|
||||||
|
|
||||||
static constexpr std::size_t SIZE = 32;
|
static constexpr std::size_t SIZE = 32;
|
||||||
static char enable_str[SIZE]{};
|
static std::array<char, SIZE> enable_str{};
|
||||||
const auto& vs = TCAP(fc::t_cursor_visible);
|
const auto& vs = TCAP(fc::t_cursor_visible);
|
||||||
const auto& ve = TCAP(fc::t_cursor_normal);
|
const auto& ve = TCAP(fc::t_cursor_normal);
|
||||||
|
|
||||||
if ( ve )
|
if ( ve )
|
||||||
std::strncpy (enable_str, ve, SIZE - 1);
|
std::strncpy (enable_str.data(), ve, SIZE - 1);
|
||||||
else if ( vs )
|
else if ( vs )
|
||||||
std::strncpy (enable_str, vs, SIZE - 1);
|
std::strncpy (enable_str.data(), vs, SIZE - 1);
|
||||||
|
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
if ( isLinuxTerm() )
|
if ( isLinuxTerm() )
|
||||||
{
|
{
|
||||||
// Restore the last used Linux console cursor style
|
// Restore the last used Linux console cursor style
|
||||||
const char* cstyle = linux->getCursorStyleString();
|
const char* cstyle = linux->getCursorStyleString();
|
||||||
std::strncat (enable_str, cstyle, SIZE - std::strlen(enable_str) - 1);
|
std::size_t length = std::strlen(enable_str.data());
|
||||||
|
std::strncat (enable_str.data(), cstyle, SIZE - length - 1);
|
||||||
}
|
}
|
||||||
#endif // defined(__linux__)
|
#endif // defined(__linux__)
|
||||||
|
|
||||||
|
@ -2033,7 +2035,7 @@ const char* FTerm::enableCursorString()
|
||||||
}
|
}
|
||||||
#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
#endif // defined(__FreeBSD__) || defined(__DragonFly__) || defined(UNIT_TEST)
|
||||||
|
|
||||||
return enable_str;
|
return enable_str.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
|
@ -76,10 +76,10 @@ char* FTermLinux::getCursorStyleString()
|
||||||
{
|
{
|
||||||
// Gets the current cursor style string of the Linux console
|
// Gets the current cursor style string of the Linux console
|
||||||
|
|
||||||
static char buf[16]{};
|
static std::array<char, 16> buf{};
|
||||||
std::fill (std::begin(buf), std::end(buf), '\0');
|
std::fill (std::begin(buf), std::end(buf), '\0');
|
||||||
std::snprintf (buf, sizeof(buf), CSI "?%dc", getCursorStyle());
|
std::snprintf (buf.data(), buf.size(), CSI "?%dc", getCursorStyle());
|
||||||
return buf;
|
return buf.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
|
@ -965,16 +965,13 @@ void FWidget::show()
|
||||||
if ( hasChildren() )
|
if ( hasChildren() )
|
||||||
{
|
{
|
||||||
for (auto&& child : getChildren())
|
for (auto&& child : getChildren())
|
||||||
{
|
|
||||||
if ( child->isWidget() )
|
|
||||||
{
|
{
|
||||||
auto widget = static_cast<FWidget*>(child);
|
auto widget = static_cast<FWidget*>(child);
|
||||||
|
|
||||||
if ( ! widget->flags.hidden )
|
if ( child->isWidget() && ! widget->flags.hidden )
|
||||||
widget->show();
|
widget->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( show_root_widget && show_root_widget == this )
|
if ( show_root_widget && show_root_widget == this )
|
||||||
{
|
{
|
||||||
|
@ -1315,17 +1312,14 @@ void FWidget::adjustSize()
|
||||||
if ( hasChildren() )
|
if ( hasChildren() )
|
||||||
{
|
{
|
||||||
for (auto&& child : getChildren())
|
for (auto&& child : getChildren())
|
||||||
{
|
|
||||||
if ( child->isWidget() )
|
|
||||||
{
|
{
|
||||||
auto widget = static_cast<FWidget*>(child);
|
auto widget = static_cast<FWidget*>(child);
|
||||||
|
|
||||||
if ( ! widget->isWindowWidget() )
|
if ( child->isWidget() && ! widget->isWindowWidget() )
|
||||||
widget->adjustSize();
|
widget->adjustSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FWidget::adjustSizeGlobal() const
|
void FWidget::adjustSizeGlobal() const
|
||||||
|
|
|
@ -437,12 +437,11 @@ FWindow* FWindow::getWindowWidgetAt (int x, int y)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
--iter;
|
--iter;
|
||||||
if ( *iter )
|
|
||||||
{
|
|
||||||
auto w = static_cast<FWindow*>(*iter);
|
auto w = static_cast<FWindow*>(*iter);
|
||||||
|
|
||||||
if ( ! w->isWindowHidden()
|
if ( *iter && ! w->isWindowHidden()
|
||||||
&& w->getTermGeometry().contains(x, y) )
|
&& w->getTermGeometry().contains(x, y) )
|
||||||
|
{
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,8 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "final/ftypes.h"
|
#include "final/ftypes.h"
|
||||||
#include "final/fwidget.h"
|
#include "final/fwidget.h"
|
||||||
|
@ -151,11 +153,13 @@ class FApplication : public FWidget
|
||||||
// Typedefs
|
// Typedefs
|
||||||
typedef std::pair<FObject*, FEvent*> EventPair;
|
typedef std::pair<FObject*, FEvent*> EventPair;
|
||||||
typedef std::deque<EventPair> FEventQueue;
|
typedef std::deque<EventPair> FEventQueue;
|
||||||
|
typedef std::unordered_map<int, std::function<void(char*)>> CmdMap;
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
void init();
|
void init();
|
||||||
static void setTerminalEncoding (const FString&);
|
static void setTerminalEncoding (const FString&);
|
||||||
static void cmd_options (const int&, char*[]);
|
static CmdMap& mapCmdOptions();
|
||||||
|
static void cmdOptions (const int&, char*[]);
|
||||||
static FStartOptions& getStartOptions();
|
static FStartOptions& getStartOptions();
|
||||||
static void showParameterUsage();
|
static void showParameterUsage();
|
||||||
void destroyLog();
|
void destroyLog();
|
||||||
|
@ -231,7 +235,7 @@ class FApplication : public FWidget
|
||||||
using CmdOption = struct option;
|
using CmdOption = struct option;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const CmdOption long_options[];
|
static const std::vector<CmdOption> long_options;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,11 @@ class FButtonGroup : public FScrollView
|
||||||
// Methods
|
// Methods
|
||||||
void init();
|
void init();
|
||||||
void drawText (const FString&, std::size_t);
|
void drawText (const FString&, std::size_t);
|
||||||
|
bool directFocusCheckedRadioButton (FToggleButton*);
|
||||||
|
bool directFocusRadioButton();
|
||||||
void directFocus();
|
void directFocus();
|
||||||
|
void focusCheckedRadioButton (FToggleButton*, FFocusEvent*);
|
||||||
|
void focusInRadioButton (FFocusEvent*);
|
||||||
|
|
||||||
// Callback method
|
// Callback method
|
||||||
void cb_buttonToggled (const FToggleButton*) const;
|
void cb_buttonToggled (const FToggleButton*) const;
|
||||||
|
|
|
@ -98,7 +98,7 @@ class FLog : public std::stringbuf
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int sync() override;
|
int sync() override;
|
||||||
const LogLevel& getLevel();
|
const LogLevel& getLevel() const;
|
||||||
LogLevel& setLevel();
|
LogLevel& setLevel();
|
||||||
const LineEnding& getEnding();
|
const LineEnding& getEnding();
|
||||||
LineEnding& setEnding();
|
LineEnding& setEnding();
|
||||||
|
@ -139,7 +139,7 @@ inline FString FLog::getClassName() const
|
||||||
{ return "FLog"; }
|
{ return "FLog"; }
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
inline const FLog::LogLevel& FLog::getLevel()
|
inline const FLog::LogLevel& FLog::getLevel() const
|
||||||
{
|
{
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue