Small fixes

This commit is contained in:
Markus Gans 2020-12-06 02:11:54 +01:00
parent 47cb79a7f0
commit 4146b20028
25 changed files with 354 additions and 348 deletions

View File

@ -126,7 +126,7 @@ void EventDialog::logMouseEvent ( const finalcut::FString& state
const int mouse_x = ev.getX(); const int mouse_x = ev.getX();
const int mouse_y = ev.getY(); const int mouse_y = ev.getY();
log << finalcut::FLog::Info log << finalcut::FLog::LogLevel::Info
<< getMouseButtonName(ev.getButton()) << getMouseButtonName(ev.getButton())
<< " mouse button " << state << " at (" << " mouse button " << state << " at ("
<< mouse_x << ", " << mouse_y << ")" << std::flush; << mouse_x << ", " << mouse_y << ")" << std::flush;
@ -162,7 +162,7 @@ void EventDialog::onKeyPress (finalcut::FKeyEvent* ev)
key_name = wchar_t(key_id); key_name = wchar_t(key_id);
// std::clog redirects all stream data to FLogger // std::clog redirects all stream data to FLogger
std::clog << finalcut::FLog::Info std::clog << finalcut::FLog::LogLevel::Info
<< "Key " << key_name << "Key " << key_name
<< " (id " << key_id << ")" << std::flush; << " (id " << key_id << ")" << std::flush;
@ -322,7 +322,7 @@ int main (int argc, char* argv[])
finalcut::FLog& log = *finalcut::FApplication::getLog(); finalcut::FLog& log = *finalcut::FApplication::getLog();
// Set the line endings (default = CRLF) // Set the line endings (default = CRLF)
log.setLineEnding (finalcut::FLog::LF); log.setLineEnding (finalcut::FLog::LineEnding::LF);
// Write a timestamp before each output line // Write a timestamp before each output line
log.enableTimestamp(); log.enableTimestamp();

View File

@ -344,7 +344,7 @@ void FApplication::setLogFile (const FString& filename)
FLog& log = *FApplication::getLog(); FLog& log = *FApplication::getLog();
log.setOutputStream(log_stream); log.setOutputStream(log_stream);
log.enableTimestamp(); log.enableTimestamp();
log.setLineEnding (finalcut::FLog::LF); log.setLineEnding (FLog::LineEnding::LF);
} }
else else
{ {
@ -434,7 +434,7 @@ void FApplication::init()
// Initialize logging // Initialize logging
if ( ! getStartOptions().logfile_stream.is_open() ) if ( ! getStartOptions().logfile_stream.is_open() )
getLog()->setLineEnding(FLog::CRLF); getLog()->setLineEnding(FLog::LineEnding::CRLF);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -718,15 +718,15 @@ inline void FApplication::performMouseAction() const
switch ( keyboard->getKey() ) switch ( keyboard->getKey() )
{ {
case fc::Fkey_mouse: case fc::Fkey_mouse:
mouse->setRawData (FMouse::x11, buffer); mouse->setRawData (FMouse::MouseType::x11, buffer);
break; break;
case fc::Fkey_extended_mouse: case fc::Fkey_extended_mouse:
mouse->setRawData (FMouse::sgr, buffer); mouse->setRawData (FMouse::MouseType::sgr, buffer);
break; break;
case fc::Fkey_urxvt_mouse: case fc::Fkey_urxvt_mouse:
mouse->setRawData (FMouse::urxvt, buffer); mouse->setRawData (FMouse::MouseType::urxvt, buffer);
break; break;
default: default:

View File

@ -826,7 +826,7 @@ inline FLineEdit::offsetPair FLineEdit::endPosToOffset (std::size_t pos)
} }
catch (const std::out_of_range& ex) catch (const std::out_of_range& ex)
{ {
std::clog << FLog::Error std::clog << FLog::LogLevel::Error
<< "Out of Range error: " << ex.what() << std::endl; << "Out of Range error: " << ex.what() << std::endl;
} }
@ -850,7 +850,7 @@ inline FLineEdit::offsetPair FLineEdit::endPosToOffset (std::size_t pos)
} }
catch (const std::out_of_range& ex) catch (const std::out_of_range& ex)
{ {
std::clog << FLog::Error std::clog << FLog::LogLevel::Error
<< "Out of Range error: " << ex.what() << std::endl; << "Out of Range error: " << ex.what() << std::endl;
} }
} }
@ -886,7 +886,7 @@ std::size_t FLineEdit::clickPosToCursorPos (std::size_t pos)
} }
catch (const std::out_of_range& ex) catch (const std::out_of_range& ex)
{ {
std::clog << FLog::Error std::clog << FLog::LogLevel::Error
<< "Out of Range error: " << ex.what() << std::endl; << "Out of Range error: " << ex.what() << std::endl;
} }
@ -920,7 +920,7 @@ void FLineEdit::adjustTextOffset()
} }
catch (const std::out_of_range& ex) catch (const std::out_of_range& ex)
{ {
std::clog << FLog::Error std::clog << FLog::LogLevel::Error
<< "Out of Range error: " << ex.what() << std::endl; << "Out of Range error: " << ex.what() << std::endl;
} }
} }
@ -933,7 +933,7 @@ void FLineEdit::adjustTextOffset()
} }
catch (const std::out_of_range& ex) catch (const std::out_of_range& ex)
{ {
std::clog << FLog::Error std::clog << FLog::LogLevel::Error
<< "Out of Range error: " << ex.what() << std::endl; << "Out of Range error: " << ex.what() << std::endl;
} }
} }

View File

@ -1731,49 +1731,49 @@ void FListBox::lazyConvert(FListBoxItems::iterator iter, std::size_t y)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListBox::cb_vbarChange (const FWidget*) void FListBox::cb_vbarChange (const FWidget*)
{ {
FScrollbar::sType scrollType; FScrollbar::SType scrollType;
const std::size_t current_before = current; const std::size_t current_before = current;
static constexpr int wheel_distance = 4; static constexpr int wheel_distance = 4;
int distance{1}; int distance{1};
const int yoffset_before = yoffset; const int yoffset_before = yoffset;
scrollType = vbar->getScrollType(); scrollType = vbar->getScrollType();
assert ( scrollType == FScrollbar::noScroll assert ( scrollType == FScrollbar::SType::noScroll
|| scrollType == FScrollbar::scrollJump || scrollType == FScrollbar::SType::scrollJump
|| scrollType == FScrollbar::scrollStepBackward || scrollType == FScrollbar::SType::scrollStepBackward
|| scrollType == FScrollbar::scrollStepForward || scrollType == FScrollbar::SType::scrollStepForward
|| scrollType == FScrollbar::scrollPageBackward || scrollType == FScrollbar::SType::scrollPageBackward
|| scrollType == FScrollbar::scrollPageForward || scrollType == FScrollbar::SType::scrollPageForward
|| scrollType == FScrollbar::scrollWheelUp || scrollType == FScrollbar::SType::scrollWheelUp
|| scrollType == FScrollbar::scrollWheelDown ); || scrollType == FScrollbar::SType::scrollWheelDown );
switch ( scrollType ) switch ( scrollType )
{ {
case FScrollbar::noScroll: case FScrollbar::SType::noScroll:
break; break;
case FScrollbar::scrollPageBackward: case FScrollbar::SType::scrollPageBackward:
distance = int(getClientHeight()); distance = int(getClientHeight());
// fall through // fall through
case FScrollbar::scrollStepBackward: case FScrollbar::SType::scrollStepBackward:
prevListItem (distance); prevListItem (distance);
break; break;
case FScrollbar::scrollPageForward: case FScrollbar::SType::scrollPageForward:
distance = int(getClientHeight()); distance = int(getClientHeight());
// fall through // fall through
case FScrollbar::scrollStepForward: case FScrollbar::SType::scrollStepForward:
nextListItem (distance); nextListItem (distance);
break; break;
case FScrollbar::scrollJump: case FScrollbar::SType::scrollJump:
scrollToY (vbar->getValue()); scrollToY (vbar->getValue());
break; break;
case FScrollbar::scrollWheelUp: case FScrollbar::SType::scrollWheelUp:
wheelUp (wheel_distance); wheelUp (wheel_distance);
break; break;
case FScrollbar::scrollWheelDown: case FScrollbar::SType::scrollWheelDown:
wheelDown (wheel_distance); wheelDown (wheel_distance);
break; break;
} }
@ -1787,7 +1787,7 @@ void FListBox::cb_vbarChange (const FWidget*)
if ( isShown() ) if ( isShown() )
drawList(); drawList();
if ( scrollType >= FScrollbar::scrollStepBackward ) if ( scrollType >= FScrollbar::SType::scrollStepBackward )
{ {
vbar->setValue (yoffset); vbar->setValue (yoffset);
@ -1803,47 +1803,47 @@ void FListBox::cb_hbarChange (const FWidget*)
{ {
static constexpr int padding_space = 2; // 1 leading space + 1 trailing space static constexpr int padding_space = 2; // 1 leading space + 1 trailing space
static constexpr int wheel_distance = 4; static constexpr int wheel_distance = 4;
FScrollbar::sType scrollType; FScrollbar::SType scrollType;
int distance{1}; int distance{1};
const int xoffset_before = xoffset; const int xoffset_before = xoffset;
scrollType = hbar->getScrollType(); scrollType = hbar->getScrollType();
assert ( scrollType == FScrollbar::noScroll assert ( scrollType == FScrollbar::SType::noScroll
|| scrollType == FScrollbar::scrollJump || scrollType == FScrollbar::SType::scrollJump
|| scrollType == FScrollbar::scrollStepBackward || scrollType == FScrollbar::SType::scrollStepBackward
|| scrollType == FScrollbar::scrollStepForward || scrollType == FScrollbar::SType::scrollStepForward
|| scrollType == FScrollbar::scrollPageBackward || scrollType == FScrollbar::SType::scrollPageBackward
|| scrollType == FScrollbar::scrollPageForward || scrollType == FScrollbar::SType::scrollPageForward
|| scrollType == FScrollbar::scrollWheelUp || scrollType == FScrollbar::SType::scrollWheelUp
|| scrollType == FScrollbar::scrollWheelDown ); || scrollType == FScrollbar::SType::scrollWheelDown );
switch ( scrollType ) switch ( scrollType )
{ {
case FScrollbar::noScroll: case FScrollbar::SType::noScroll:
break; break;
case FScrollbar::scrollPageBackward: case FScrollbar::SType::scrollPageBackward:
distance = int(getClientWidth()) - padding_space; distance = int(getClientWidth()) - padding_space;
// fall through // fall through
case FScrollbar::scrollStepBackward: case FScrollbar::SType::scrollStepBackward:
scrollLeft (distance); scrollLeft (distance);
break; break;
case FScrollbar::scrollPageForward: case FScrollbar::SType::scrollPageForward:
distance = int(getClientWidth()) - padding_space; distance = int(getClientWidth()) - padding_space;
// fall through // fall through
case FScrollbar::scrollStepForward: case FScrollbar::SType::scrollStepForward:
scrollRight (distance); scrollRight (distance);
break; break;
case FScrollbar::scrollJump: case FScrollbar::SType::scrollJump:
scrollToX (hbar->getValue()); scrollToX (hbar->getValue());
break; break;
case FScrollbar::scrollWheelUp: case FScrollbar::SType::scrollWheelUp:
scrollLeft (wheel_distance); scrollLeft (wheel_distance);
break; break;
case FScrollbar::scrollWheelDown: case FScrollbar::SType::scrollWheelDown:
scrollRight (wheel_distance); scrollRight (wheel_distance);
break; break;
} }
@ -1855,7 +1855,7 @@ void FListBox::cb_hbarChange (const FWidget*)
drawList(); drawList();
if ( scrollType >= FScrollbar::scrollStepBackward ) if ( scrollType >= FScrollbar::SType::scrollStepBackward )
{ {
hbar->setValue (xoffset); hbar->setValue (xoffset);

View File

@ -2765,47 +2765,47 @@ void FListView::scrollBy (int dx, int dy)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::cb_vbarChange (const FWidget*) void FListView::cb_vbarChange (const FWidget*)
{ {
FScrollbar::sType scrollType = vbar->getScrollType(); FScrollbar::SType scrollType = vbar->getScrollType();
static constexpr int wheel_distance = 4; static constexpr int wheel_distance = 4;
int distance{1}; int distance{1};
first_line_position_before = first_visible_line.getPosition(); first_line_position_before = first_visible_line.getPosition();
assert ( scrollType == FScrollbar::noScroll assert ( scrollType == FScrollbar::SType::noScroll
|| scrollType == FScrollbar::scrollJump || scrollType == FScrollbar::SType::scrollJump
|| scrollType == FScrollbar::scrollStepBackward || scrollType == FScrollbar::SType::scrollStepBackward
|| scrollType == FScrollbar::scrollStepForward || scrollType == FScrollbar::SType::scrollStepForward
|| scrollType == FScrollbar::scrollPageBackward || scrollType == FScrollbar::SType::scrollPageBackward
|| scrollType == FScrollbar::scrollPageForward || scrollType == FScrollbar::SType::scrollPageForward
|| scrollType == FScrollbar::scrollWheelUp || scrollType == FScrollbar::SType::scrollWheelUp
|| scrollType == FScrollbar::scrollWheelDown ); || scrollType == FScrollbar::SType::scrollWheelDown );
switch ( scrollType ) switch ( scrollType )
{ {
case FScrollbar::noScroll: case FScrollbar::SType::noScroll:
break; break;
case FScrollbar::scrollPageBackward: case FScrollbar::SType::scrollPageBackward:
distance = int(getClientHeight()); distance = int(getClientHeight());
// fall through // fall through
case FScrollbar::scrollStepBackward: case FScrollbar::SType::scrollStepBackward:
stepBackward(distance); stepBackward(distance);
break; break;
case FScrollbar::scrollPageForward: case FScrollbar::SType::scrollPageForward:
distance = int(getClientHeight()); distance = int(getClientHeight());
// fall through // fall through
case FScrollbar::scrollStepForward: case FScrollbar::SType::scrollStepForward:
stepForward(distance); stepForward(distance);
break; break;
case FScrollbar::scrollJump: case FScrollbar::SType::scrollJump:
scrollToY (vbar->getValue()); scrollToY (vbar->getValue());
break; break;
case FScrollbar::scrollWheelUp: case FScrollbar::SType::scrollWheelUp:
wheelUp (wheel_distance); wheelUp (wheel_distance);
break; break;
case FScrollbar::scrollWheelDown: case FScrollbar::SType::scrollWheelDown:
wheelDown (wheel_distance); wheelDown (wheel_distance);
break; break;
} }
@ -2813,8 +2813,8 @@ void FListView::cb_vbarChange (const FWidget*)
if ( isShown() ) if ( isShown() )
drawList(); drawList();
if ( scrollType >= FScrollbar::scrollStepBackward if ( scrollType >= FScrollbar::SType::scrollStepBackward
&& scrollType <= FScrollbar::scrollPageForward ) && scrollType <= FScrollbar::SType::scrollPageForward )
{ {
vbar->setValue (first_visible_line.getPosition()); vbar->setValue (first_visible_line.getPosition());
@ -2828,47 +2828,47 @@ void FListView::cb_vbarChange (const FWidget*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FListView::cb_hbarChange (const FWidget*) void FListView::cb_hbarChange (const FWidget*)
{ {
FScrollbar::sType scrollType = hbar->getScrollType(); FScrollbar::SType scrollType = hbar->getScrollType();
static constexpr int wheel_distance = 4; static constexpr int wheel_distance = 4;
int distance{1}; int distance{1};
const int xoffset_before = xoffset; const int xoffset_before = xoffset;
assert ( scrollType == FScrollbar::noScroll assert ( scrollType == FScrollbar::SType::noScroll
|| scrollType == FScrollbar::scrollJump || scrollType == FScrollbar::SType::scrollJump
|| scrollType == FScrollbar::scrollStepBackward || scrollType == FScrollbar::SType::scrollStepBackward
|| scrollType == FScrollbar::scrollStepForward || scrollType == FScrollbar::SType::scrollStepForward
|| scrollType == FScrollbar::scrollPageBackward || scrollType == FScrollbar::SType::scrollPageBackward
|| scrollType == FScrollbar::scrollPageForward || scrollType == FScrollbar::SType::scrollPageForward
|| scrollType == FScrollbar::scrollWheelUp || scrollType == FScrollbar::SType::scrollWheelUp
|| scrollType == FScrollbar::scrollWheelDown ); || scrollType == FScrollbar::SType::scrollWheelDown );
switch ( scrollType ) switch ( scrollType )
{ {
case FScrollbar::noScroll: case FScrollbar::SType::noScroll:
break; break;
case FScrollbar::scrollPageBackward: case FScrollbar::SType::scrollPageBackward:
distance = int(getClientWidth()); distance = int(getClientWidth());
// fall through // fall through
case FScrollbar::scrollStepBackward: case FScrollbar::SType::scrollStepBackward:
scrollBy (-distance, 0); scrollBy (-distance, 0);
break; break;
case FScrollbar::scrollPageForward: case FScrollbar::SType::scrollPageForward:
distance = int(getClientWidth()); distance = int(getClientWidth());
// fall through // fall through
case FScrollbar::scrollStepForward: case FScrollbar::SType::scrollStepForward:
scrollBy (distance, 0); scrollBy (distance, 0);
break; break;
case FScrollbar::scrollJump: case FScrollbar::SType::scrollJump:
scrollToX (hbar->getValue()); scrollToX (hbar->getValue());
break; break;
case FScrollbar::scrollWheelUp: case FScrollbar::SType::scrollWheelUp:
scrollBy (-wheel_distance, 0); scrollBy (-wheel_distance, 0);
break; break;
case FScrollbar::scrollWheelDown: case FScrollbar::SType::scrollWheelDown:
scrollBy (wheel_distance, 0); scrollBy (wheel_distance, 0);
break; break;
} }
@ -2879,7 +2879,7 @@ void FListView::cb_hbarChange (const FWidget*)
drawList(); drawList();
} }
if ( scrollType >= FScrollbar::scrollStepBackward ) if ( scrollType >= FScrollbar::SType::scrollStepBackward )
{ {
hbar->setValue (xoffset); hbar->setValue (xoffset);

View File

@ -47,19 +47,19 @@ FLog& FLog::operator << (LogLevel l)
switch ( l ) switch ( l )
{ {
case Info: case LogLevel::Info:
current_log = std::bind(&FLog::info, this, _1); current_log = std::bind(&FLog::info, this, _1);
break; break;
case Warn: case LogLevel::Warn:
current_log = std::bind(&FLog::warn, this, _1); current_log = std::bind(&FLog::warn, this, _1);
break; break;
case Error: case LogLevel::Error:
current_log = std::bind(&FLog::error, this, _1); current_log = std::bind(&FLog::error, this, _1);
break; break;
case Debug: case LogLevel::Debug:
current_log = std::bind(&FLog::debug, this, _1); current_log = std::bind(&FLog::debug, this, _1);
break; break;
} }

View File

@ -71,11 +71,11 @@ std::string FLogger::getEOL()
{ {
std::lock_guard<std::mutex> lock_guard(getMutex()); std::lock_guard<std::mutex> lock_guard(getMutex());
if ( getEnding() == FLog::LF ) if ( getEnding() == LineEnding::LF )
return "\n"; return "\n";
else if ( getEnding() == FLog::CR ) else if ( getEnding() == LineEnding::CR )
return "\r"; return "\r";
else if ( getEnding() == FLog::CRLF ) else if ( getEnding() == LineEnding::CRLF )
return "\r\n"; return "\r\n";
return ""; return "";
@ -90,16 +90,16 @@ void FLogger::printLogLine (const std::string& msg)
switch ( getLevel() ) switch ( getLevel() )
{ {
case Info: case LogLevel::Info:
return "INFO"; return "INFO";
case Warn: case LogLevel::Warn:
return "WARNING"; return "WARNING";
case Error: case LogLevel::Error:
return "ERROR"; return "ERROR";
case Debug: case LogLevel::Debug:
return "DEBUG"; return "DEBUG";
} }

View File

@ -64,42 +64,42 @@ const FPoint& FMouseData::getPos() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseData::isLeftButtonPressed() const bool FMouseData::isLeftButtonPressed() const
{ {
return bool(getButtonState().left_button == Pressed); return bool(getButtonState().left_button == State::Pressed);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseData::isLeftButtonReleased() const bool FMouseData::isLeftButtonReleased() const
{ {
return bool(getButtonState().left_button == Released); return bool(getButtonState().left_button == State::Released);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseData::isLeftButtonDoubleClick() const bool FMouseData::isLeftButtonDoubleClick() const
{ {
return bool(getButtonState().left_button == DoubleClick); return bool(getButtonState().left_button == State::DoubleClick);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseData::isRightButtonPressed() const bool FMouseData::isRightButtonPressed() const
{ {
return bool(getButtonState().right_button == Pressed); return bool(getButtonState().right_button == State::Pressed);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseData::isRightButtonReleased() const bool FMouseData::isRightButtonReleased() const
{ {
return bool(getButtonState().right_button == Released); return bool(getButtonState().right_button == State::Released);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseData::isMiddleButtonPressed() const bool FMouseData::isMiddleButtonPressed() const
{ {
return bool(getButtonState().middle_button == Pressed); return bool(getButtonState().middle_button == State::Pressed);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouseData::isMiddleButtonReleased() const bool FMouseData::isMiddleButtonReleased() const
{ {
return bool(getButtonState().middle_button == Released); return bool(getButtonState().middle_button == State::Released);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -141,8 +141,15 @@ bool FMouseData::isMoved() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseData::clearButtonState() void FMouseData::clearButtonState()
{ {
// Fill bit field with 0 b_state.left_button = State::Undefined;
std::memset(&b_state, 0x00, sizeof(b_state)); b_state.right_button = State::Undefined;
b_state.middle_button = State::Undefined;
b_state.shift_button = 0;
b_state.control_button = 0;
b_state.meta_button = 0;
b_state.wheel_up = 0;
b_state.wheel_down = 0;
b_state.mouse_moved = 0;
} }
@ -433,16 +440,16 @@ void FMouseGPM::interpretKeyDown()
if ( gpm_ev.buttons & GPM_B_LEFT ) if ( gpm_ev.buttons & GPM_B_LEFT )
{ {
if ( gpm_ev.type & GPM_DOUBLE ) if ( gpm_ev.type & GPM_DOUBLE )
getButtonState().left_button = DoubleClick; getButtonState().left_button = State::DoubleClick;
else else
getButtonState().left_button = Pressed; getButtonState().left_button = State::Pressed;
} }
if ( gpm_ev.buttons & GPM_B_MIDDLE ) if ( gpm_ev.buttons & GPM_B_MIDDLE )
getButtonState().middle_button = Pressed; getButtonState().middle_button = State::Pressed;
if ( gpm_ev.buttons & GPM_B_RIGHT ) if ( gpm_ev.buttons & GPM_B_RIGHT )
getButtonState().right_button = Pressed; getButtonState().right_button = State::Pressed;
if ( gpm_ev.buttons & GPM_B_UP ) if ( gpm_ev.buttons & GPM_B_UP )
getButtonState().wheel_up = true; getButtonState().wheel_up = true;
@ -465,13 +472,13 @@ void FMouseGPM::interpretKeyDown()
void FMouseGPM::interpretKeyUp() void FMouseGPM::interpretKeyUp()
{ {
if ( gpm_ev.buttons & GPM_B_LEFT ) if ( gpm_ev.buttons & GPM_B_LEFT )
getButtonState().left_button = Released; getButtonState().left_button = State::Released;
if ( gpm_ev.buttons & GPM_B_MIDDLE ) if ( gpm_ev.buttons & GPM_B_MIDDLE )
getButtonState().middle_button = Released; getButtonState().middle_button = State::Released;
if ( gpm_ev.buttons & GPM_B_RIGHT ) if ( gpm_ev.buttons & GPM_B_RIGHT )
getButtonState().right_button = Released; getButtonState().right_button = State::Released;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -619,13 +626,13 @@ void FMouseX11::processEvent (struct timeval* time)
void FMouseX11::setKeyState (int btn) void FMouseX11::setKeyState (int btn)
{ {
if ( (btn & key_shift) == key_shift ) if ( (btn & key_shift) == key_shift )
getButtonState().shift_button = Pressed; getButtonState().shift_button = true;
if ( (btn & key_meta) == key_meta ) if ( (btn & key_meta) == key_meta )
getButtonState().meta_button = Pressed; getButtonState().meta_button = true;
if ( (btn & key_ctrl) == key_ctrl ) if ( (btn & key_ctrl) == key_ctrl )
getButtonState().control_button = Pressed; getButtonState().control_button = true;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -655,25 +662,25 @@ void FMouseX11::setButtonState (const int btn, const struct timeval* time)
&& ! isDblclickTimeout(getMousePressedTime()) ) && ! isDblclickTimeout(getMousePressedTime()) )
{ {
resetMousePressedTime(); resetMousePressedTime();
getButtonState().left_button = DoubleClick; getButtonState().left_button = State::DoubleClick;
} }
else else
{ {
setMousePressedTime (time); // save click time setMousePressedTime (time); // save click time
getButtonState().left_button = Pressed; getButtonState().left_button = State::Pressed;
} }
break; break;
case button2_pressed: case button2_pressed:
case button2_pressed_move: case button2_pressed_move:
resetMousePressedTime(); resetMousePressedTime();
getButtonState().middle_button = Pressed; getButtonState().middle_button = State::Pressed;
break; break;
case button3_pressed: case button3_pressed:
case button3_pressed_move: case button3_pressed_move:
resetMousePressedTime(); resetMousePressedTime();
getButtonState().right_button = Pressed; getButtonState().right_button = State::Pressed;
break; break;
case all_buttons_released: case all_buttons_released:
@ -681,17 +688,17 @@ void FMouseX11::setButtonState (const int btn, const struct timeval* time)
{ {
case button1_pressed: case button1_pressed:
case button1_pressed_move: case button1_pressed_move:
getButtonState().left_button = Released; getButtonState().left_button = State::Released;
break; break;
case button2_pressed: case button2_pressed:
case button2_pressed_move: case button2_pressed_move:
getButtonState().middle_button = Released; getButtonState().middle_button = State::Released;
break; break;
case button3_pressed: case button3_pressed:
case button3_pressed_move: case button3_pressed_move:
getButtonState().right_button = Released; getButtonState().right_button = State::Released;
break; break;
default: default:
@ -701,12 +708,12 @@ void FMouseX11::setButtonState (const int btn, const struct timeval* time)
case button_up: case button_up:
resetMousePressedTime(); resetMousePressedTime();
getButtonState().wheel_up = Pressed; getButtonState().wheel_up = true;
break; break;
case button_down: case button_down:
resetMousePressedTime(); resetMousePressedTime();
getButtonState().wheel_down = Pressed; getButtonState().wheel_down = true;
break; break;
default: default:
@ -881,25 +888,25 @@ void FMouseSGR::setPressedButtonState ( const int btn
&& ! isDblclickTimeout(getMousePressedTime()) ) && ! isDblclickTimeout(getMousePressedTime()) )
{ {
resetMousePressedTime(); resetMousePressedTime();
getButtonState().left_button = DoubleClick; getButtonState().left_button = State::DoubleClick;
} }
else else
{ {
setMousePressedTime (time); // save click time setMousePressedTime (time); // save click time
getButtonState().left_button = Pressed; getButtonState().left_button = State::Pressed;
} }
break; break;
case button2: case button2:
case button2_move: case button2_move:
resetMousePressedTime(); resetMousePressedTime();
getButtonState().middle_button = Pressed; getButtonState().middle_button = State::Pressed;
break; break;
case button3: case button3:
case button3_move: case button3_move:
resetMousePressedTime(); resetMousePressedTime();
getButtonState().right_button = Pressed; getButtonState().right_button = State::Pressed;
break; break;
case button_up: case button_up:
@ -926,17 +933,17 @@ void FMouseSGR::setReleasedButtonState (const int btn)
{ {
case button1: case button1:
case button1_move: case button1_move:
getButtonState().left_button = Released; getButtonState().left_button = State::Released;
break; break;
case button2: case button2:
case button2_move: case button2_move:
getButtonState().middle_button = Released; getButtonState().middle_button = State::Released;
break; break;
case button3: case button3:
case button3_move: case button3_move:
getButtonState().right_button = Released; getButtonState().right_button = State::Released;
break; break;
default: default:
@ -1100,13 +1107,13 @@ void FMouseUrxvt::processEvent (struct timeval* time)
void FMouseUrxvt::setKeyState (int btn) void FMouseUrxvt::setKeyState (int btn)
{ {
if ( (btn & key_shift) == key_shift ) if ( (btn & key_shift) == key_shift )
getButtonState().shift_button = Pressed; getButtonState().shift_button = true;
if ( (btn & key_meta) == key_meta ) if ( (btn & key_meta) == key_meta )
getButtonState().meta_button = Pressed; getButtonState().meta_button = true;
if ( (btn & key_ctrl) == key_ctrl ) if ( (btn & key_ctrl) == key_ctrl )
getButtonState().control_button = Pressed; getButtonState().control_button = true;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1136,25 +1143,25 @@ void FMouseUrxvt::setButtonState (const int btn, const struct timeval* time)
&& ! isDblclickTimeout(getMousePressedTime()) ) && ! isDblclickTimeout(getMousePressedTime()) )
{ {
resetMousePressedTime(); resetMousePressedTime();
getButtonState().left_button = DoubleClick; getButtonState().left_button = State::DoubleClick;
} }
else else
{ {
setMousePressedTime (time); // save click time setMousePressedTime (time); // save click time
getButtonState().left_button = Pressed; getButtonState().left_button = State::Pressed;
} }
break; break;
case button2_pressed: case button2_pressed:
case button2_pressed_move: case button2_pressed_move:
resetMousePressedTime(); resetMousePressedTime();
getButtonState().middle_button = Pressed; getButtonState().middle_button = State::Pressed;
break; break;
case button3_pressed: case button3_pressed:
case button3_pressed_move: case button3_pressed_move:
resetMousePressedTime(); resetMousePressedTime();
getButtonState().right_button = Pressed; getButtonState().right_button = State::Pressed;
break; break;
case all_buttons_released: case all_buttons_released:
@ -1162,17 +1169,17 @@ void FMouseUrxvt::setButtonState (const int btn, const struct timeval* time)
{ {
case button1_pressed: case button1_pressed:
case button1_pressed_move: case button1_pressed_move:
getButtonState().left_button = Released; getButtonState().left_button = State::Released;
break; break;
case button2_pressed: case button2_pressed:
case button2_pressed_move: case button2_pressed_move:
getButtonState().middle_button = Released; getButtonState().middle_button = State::Released;
break; break;
case button3_pressed: case button3_pressed:
case button3_pressed_move: case button3_pressed_move:
getButtonState().right_button = Released; getButtonState().right_button = State::Released;
break; break;
default: default:
@ -1182,12 +1189,12 @@ void FMouseUrxvt::setButtonState (const int btn, const struct timeval* time)
case button_up: case button_up:
resetMousePressedTime(); resetMousePressedTime();
getButtonState().wheel_up = Pressed; getButtonState().wheel_up = true;
break; break;
case button_down: case button_down:
resetMousePressedTime(); resetMousePressedTime();
getButtonState().wheel_down = Pressed; getButtonState().wheel_down = true;
break; break;
default: default:
@ -1206,12 +1213,12 @@ FMouseControl::FMouseControl()
{ {
#ifdef F_HAVE_LIBGPM #ifdef F_HAVE_LIBGPM
if ( FTerm::isLinuxTerm() ) if ( FTerm::isLinuxTerm() )
mouse_protocol[FMouse::gpm].reset(FMouse::createMouseObject<FMouseGPM>()); mouse_protocol[FMouse::MouseType::gpm].reset(FMouse::createMouseObject<FMouseGPM>());
#endif #endif
mouse_protocol[FMouse::x11].reset(FMouse::createMouseObject<FMouseX11>()); mouse_protocol[FMouse::MouseType::x11].reset(FMouse::createMouseObject<FMouseX11>());
mouse_protocol[FMouse::sgr].reset(FMouse::createMouseObject<FMouseSGR>()); mouse_protocol[FMouse::MouseType::sgr].reset(FMouse::createMouseObject<FMouseSGR>());
mouse_protocol[FMouse::urxvt].reset(FMouse::createMouseObject<FMouseUrxvt>()); mouse_protocol[FMouse::MouseType::urxvt].reset(FMouse::createMouseObject<FMouseUrxvt>());
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1234,7 +1241,7 @@ const FPoint& FMouseControl::getPos()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseControl::clearEvent() void FMouseControl::clearEvent()
{ {
FMouse::mouse_type mtype; FMouse::MouseType mtype;
do do
{ {
@ -1243,14 +1250,14 @@ void FMouseControl::clearEvent()
if ( mouse_protocol[mtype] ) if ( mouse_protocol[mtype] )
mouse_protocol[mtype]->clearEvent(); mouse_protocol[mtype]->clearEvent();
} }
while ( mtype != FMouse::none ); while ( mtype != FMouse::MouseType::none );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
#ifdef F_HAVE_LIBGPM #ifdef F_HAVE_LIBGPM
void FMouseControl::setStdinNo (int file_descriptor) void FMouseControl::setStdinNo (int file_descriptor)
{ {
auto mouse = mouse_protocol[FMouse::gpm].get(); auto mouse = mouse_protocol[FMouse::MouseType::gpm].get();
auto gpm_mouse = static_cast<FMouseGPM*>(mouse); auto gpm_mouse = static_cast<FMouseGPM*>(mouse);
if ( gpm_mouse ) if ( gpm_mouse )
@ -1264,13 +1271,13 @@ void FMouseControl::setStdinNo (int)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseControl::setMaxWidth (uInt16 x_max) void FMouseControl::setMaxWidth (uInt16 x_max)
{ {
mouse_protocol[FMouse::urxvt]->setMaxWidth(x_max); mouse_protocol[FMouse::MouseType::urxvt]->setMaxWidth(x_max);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseControl::setMaxHeight (uInt16 y_max) void FMouseControl::setMaxHeight (uInt16 y_max)
{ {
mouse_protocol[FMouse::urxvt]->setMaxHeight(y_max); mouse_protocol[FMouse::MouseType::urxvt]->setMaxHeight(y_max);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1479,7 +1486,7 @@ bool FMouseControl::isGpmMouseEnabled()
if ( mouse_protocol.empty() ) if ( mouse_protocol.empty() )
return false; return false;
const auto& mouse = mouse_protocol[FMouse::gpm].get(); const auto& mouse = mouse_protocol[FMouse::MouseType::gpm].get();
const auto& gpm_mouse = static_cast<FMouseGPM*>(mouse); const auto& gpm_mouse = static_cast<FMouseGPM*>(mouse);
if ( gpm_mouse ) if ( gpm_mouse )
@ -1500,7 +1507,7 @@ void FMouseControl::enable()
#ifdef F_HAVE_LIBGPM #ifdef F_HAVE_LIBGPM
if ( use_gpm_mouse ) if ( use_gpm_mouse )
{ {
auto mouse = mouse_protocol[FMouse::gpm].get(); auto mouse = mouse_protocol[FMouse::MouseType::gpm].get();
auto gpm_mouse = static_cast<FMouseGPM*>(mouse); auto gpm_mouse = static_cast<FMouseGPM*>(mouse);
if ( gpm_mouse ) if ( gpm_mouse )
@ -1518,7 +1525,7 @@ void FMouseControl::disable()
#ifdef F_HAVE_LIBGPM #ifdef F_HAVE_LIBGPM
if ( use_gpm_mouse ) if ( use_gpm_mouse )
{ {
auto mouse = mouse_protocol[FMouse::gpm].get(); auto mouse = mouse_protocol[FMouse::MouseType::gpm].get();
auto gpm_mouse = static_cast<FMouseGPM*>(mouse); auto gpm_mouse = static_cast<FMouseGPM*>(mouse);
if ( gpm_mouse ) if ( gpm_mouse )
@ -1531,7 +1538,7 @@ void FMouseControl::disable()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseControl::setRawData ( FMouse::mouse_type mt void FMouseControl::setRawData ( FMouse::MouseType mt
, FKeyboard::keybuffer& fifo_buf) , FKeyboard::keybuffer& fifo_buf)
{ {
auto mouse = mouse_protocol[mt].get(); auto mouse = mouse_protocol[mt].get();
@ -1583,7 +1590,7 @@ bool FMouseControl::getGpmKeyPressed (bool pending)
if ( mouse_protocol.empty() ) if ( mouse_protocol.empty() )
return false; return false;
auto mouse = mouse_protocol[FMouse::gpm].get(); auto mouse = mouse_protocol[FMouse::MouseType::gpm].get();
auto gpm_mouse = static_cast<FMouseGPM*>(mouse); auto gpm_mouse = static_cast<FMouseGPM*>(mouse);
if ( gpm_mouse ) if ( gpm_mouse )
@ -1605,7 +1612,7 @@ void FMouseControl::drawPointer()
if ( mouse_protocol.empty() ) if ( mouse_protocol.empty() )
return; return;
auto mouse = mouse_protocol[FMouse::gpm].get(); auto mouse = mouse_protocol[FMouse::MouseType::gpm].get();
auto gpm_mouse = static_cast<FMouseGPM*>(mouse); auto gpm_mouse = static_cast<FMouseGPM*>(mouse);
if ( gpm_mouse ) if ( gpm_mouse )
@ -1619,7 +1626,7 @@ void FMouseControl::drawPointer()
// private methods of FMouseControl // private methods of FMouseControl
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FMouse::mouse_type FMouseControl::getMouseWithData() FMouse::MouseType FMouseControl::getMouseWithData()
{ {
const auto& iter = \ const auto& iter = \
std::find_if ( std::begin(mouse_protocol) std::find_if ( std::begin(mouse_protocol)
@ -1631,11 +1638,11 @@ FMouse::mouse_type FMouseControl::getMouseWithData()
} }
); );
return ( iter != mouse_protocol.end() ) ? iter->first : FMouse::none; return ( iter != mouse_protocol.end() ) ? iter->first : FMouse::MouseType::none;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FMouse::mouse_type FMouseControl::getMouseWithEvent() FMouse::MouseType FMouseControl::getMouseWithEvent()
{ {
const auto& iter = \ const auto& iter = \
std::find_if ( std::begin(mouse_protocol) std::find_if ( std::begin(mouse_protocol)
@ -1647,7 +1654,7 @@ FMouse::mouse_type FMouseControl::getMouseWithEvent()
} }
); );
return ( iter != mouse_protocol.end() ) ? iter->first : FMouse::none; return ( iter != mouse_protocol.end() ) ? iter->first : FMouse::MouseType::none;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -261,16 +261,16 @@ void FScrollbar::onMouseDown (FMouseEvent* ev)
// Process left mouse button // Process left mouse button
scroll_type = getClickedScrollType(mouse_x, mouse_y); scroll_type = getClickedScrollType(mouse_x, mouse_y);
if ( scroll_type == FScrollbar::noScroll ) if ( scroll_type == SType::noScroll )
{ {
slider_click_pos = getSliderClickPos (mouse_x, mouse_y); slider_click_pos = getSliderClickPos (mouse_x, mouse_y);
if ( slider_click_pos > 0 ) if ( slider_click_pos > 0 )
scroll_type = FScrollbar::scrollJump; scroll_type = SType::scrollJump;
} }
if ( scroll_type == FScrollbar::scrollPageBackward if ( scroll_type == SType::scrollPageBackward
|| scroll_type == FScrollbar::scrollPageForward ) || scroll_type == SType::scrollPageForward )
{ {
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
slider_click_stop_pos = mouse_y - 2; slider_click_stop_pos = mouse_y - 2;
@ -285,8 +285,8 @@ void FScrollbar::onMouseDown (FMouseEvent* ev)
else else
slider_click_stop_pos = -1; slider_click_stop_pos = -1;
if ( scroll_type >= FScrollbar::scrollStepBackward if ( scroll_type >= SType::scrollStepBackward
&& scroll_type <= FScrollbar::scrollPageForward ) && scroll_type <= SType::scrollPageForward )
{ {
processScroll(); processScroll();
threshold_reached = false; threshold_reached = false;
@ -303,10 +303,10 @@ void FScrollbar::onMouseUp (FMouseEvent* ev)
slider_click_pos = -1; slider_click_pos = -1;
if ( scroll_type != FScrollbar::noScroll ) if ( scroll_type != SType::noScroll )
{ {
delOwnTimers(); delOwnTimers();
scroll_type = FScrollbar::noScroll; scroll_type = SType::noScroll;
} }
} }
@ -327,9 +327,9 @@ void FScrollbar::onMouseMove (FMouseEvent* ev)
} }
// Process left mouse button // Process left mouse button
const int new_scroll_type = getClickedScrollType(mouse_x, mouse_y); const auto new_scroll_type = getClickedScrollType(mouse_x, mouse_y);
if ( scroll_type == FScrollbar::scrollJump ) if ( scroll_type == SType::scrollJump )
{ {
int new_val{}; int new_val{};
@ -362,7 +362,7 @@ void FScrollbar::onMouseMove (FMouseEvent* ev)
{ {
delOwnTimers(); delOwnTimers();
} }
else if ( scroll_type != FScrollbar::scrollJump ) else if ( scroll_type != SType::scrollJump )
{ {
addTimer(repeat_time); addTimer(repeat_time);
} }
@ -378,16 +378,16 @@ void FScrollbar::onWheel (FWheelEvent* ev)
{ {
const int wheel = ev->getWheel(); const int wheel = ev->getWheel();
if ( scroll_type != FScrollbar::noScroll ) if ( scroll_type != SType::noScroll )
{ {
delOwnTimers(); delOwnTimers();
scroll_type = FScrollbar::noScroll; scroll_type = SType::noScroll;
} }
if ( wheel == fc::WheelUp ) if ( wheel == fc::WheelUp )
scroll_type = FScrollbar::scrollWheelUp; scroll_type = SType::scrollWheelUp;
else if ( wheel == fc::WheelDown ) else if ( wheel == fc::WheelDown )
scroll_type = FScrollbar::scrollWheelDown; scroll_type = SType::scrollWheelDown;
processScroll(); processScroll();
} }
@ -395,7 +395,7 @@ void FScrollbar::onWheel (FWheelEvent* ev)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollbar::onTimer (FTimerEvent*) void FScrollbar::onTimer (FTimerEvent*)
{ {
if ( scroll_type == FScrollbar::noScroll ) if ( scroll_type == SType::noScroll )
return; return;
if ( ! threshold_reached ) if ( ! threshold_reached )
@ -406,20 +406,20 @@ void FScrollbar::onTimer (FTimerEvent*)
} }
// Timer stop condition // Timer stop condition
if ( ( scroll_type == FScrollbar::scrollPageBackward if ( ( scroll_type == SType::scrollPageBackward
&& slider_pos == slider_click_stop_pos ) && slider_pos == slider_click_stop_pos )
|| ( scroll_type == FScrollbar::scrollPageForward || ( scroll_type == SType::scrollPageForward
&& slider_pos == slider_click_stop_pos ) ) && slider_pos == slider_click_stop_pos ) )
{ {
const auto max_slider_pos = int(bar_length - slider_length); const auto max_slider_pos = int(bar_length - slider_length);
if ( scroll_type == FScrollbar::scrollPageBackward if ( scroll_type == SType::scrollPageBackward
&& slider_pos == 0 ) && slider_pos == 0 )
{ {
jumpToClickPos(0); // Scroll to the start jumpToClickPos(0); // Scroll to the start
processScroll(); processScroll();
} }
else if ( scroll_type == FScrollbar::scrollPageForward else if ( scroll_type == SType::scrollPageForward
&& slider_pos == max_slider_pos ) && slider_pos == max_slider_pos )
{ {
jumpToClickPos (max_slider_pos); // Scroll to the end jumpToClickPos (max_slider_pos); // Scroll to the end
@ -613,7 +613,7 @@ void FScrollbar::drawButtons()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FScrollbar::sType FScrollbar::getClickedScrollType (int x, int y) const FScrollbar::SType FScrollbar::getClickedScrollType (int x, int y) const
{ {
if ( bar_orientation == fc::vertical ) if ( bar_orientation == fc::vertical )
{ {
@ -626,72 +626,72 @@ FScrollbar::sType FScrollbar::getClickedScrollType (int x, int y) const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FScrollbar::sType FScrollbar::getVerticalClickedScrollType (int y) const FScrollbar::SType FScrollbar::getVerticalClickedScrollType (int y) const
{ {
if ( y == 1 ) if ( y == 1 )
{ {
return FScrollbar::scrollStepBackward; // decrement button return SType::scrollStepBackward; // decrement button
} }
else if ( y > 1 && y <= slider_pos + 1 ) else if ( y > 1 && y <= slider_pos + 1 )
{ {
return FScrollbar::scrollPageBackward; // before slider return SType::scrollPageBackward; // before slider
} }
else if ( y > slider_pos + int(slider_length) + 1 && y < int(getHeight()) ) else if ( y > slider_pos + int(slider_length) + 1 && y < int(getHeight()) )
{ {
return FScrollbar::scrollPageForward; // after slider return SType::scrollPageForward; // after slider
} }
else if ( y == int(getHeight()) ) else if ( y == int(getHeight()) )
{ {
return FScrollbar::scrollStepForward; // increment button return SType::scrollStepForward; // increment button
} }
return FScrollbar::noScroll; return SType::noScroll;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FScrollbar::sType FScrollbar::getHorizontalClickedScrollType (int x) const FScrollbar::SType FScrollbar::getHorizontalClickedScrollType (int x) const
{ {
if ( FTerm::isNewFont() ) if ( FTerm::isNewFont() )
{ {
if ( x == 1 || x == 2 ) if ( x == 1 || x == 2 )
{ {
return FScrollbar::scrollStepBackward; // decrement button return SType::scrollStepBackward; // decrement button
} }
else if ( x > 2 && x <= slider_pos + 2 ) else if ( x > 2 && x <= slider_pos + 2 )
{ {
return FScrollbar::scrollPageBackward; // before slider return SType::scrollPageBackward; // before slider
} }
else if ( x > slider_pos + int(slider_length) + 2 && x < int(getWidth()) - 1 ) else if ( x > slider_pos + int(slider_length) + 2 && x < int(getWidth()) - 1 )
{ {
return FScrollbar::scrollPageForward; // after slider return SType::scrollPageForward; // after slider
} }
else if ( x == int(getWidth()) - 1 || x == int(getWidth()) ) else if ( x == int(getWidth()) - 1 || x == int(getWidth()) )
{ {
return FScrollbar::scrollStepForward; // increment button return SType::scrollStepForward; // increment button
} }
return FScrollbar::noScroll; return SType::noScroll;
} }
else else
{ {
if ( x == 1 ) if ( x == 1 )
{ {
return FScrollbar::scrollStepBackward; // decrement button return SType::scrollStepBackward; // decrement button
} }
else if ( x > 1 && x <= slider_pos + 1 ) else if ( x > 1 && x <= slider_pos + 1 )
{ {
return FScrollbar::scrollPageBackward; // before slider return SType::scrollPageBackward; // before slider
} }
else if ( x > slider_pos + int(slider_length) + 1 && x < int(getWidth()) ) else if ( x > slider_pos + int(slider_length) + 1 && x < int(getWidth()) )
{ {
return FScrollbar::scrollPageForward; // after slider return SType::scrollPageForward; // after slider
} }
else if ( x == int(getWidth()) ) else if ( x == int(getWidth()) )
{ {
return FScrollbar::scrollStepForward; // increment button return SType::scrollStepForward; // increment button
} }
return FScrollbar::noScroll; return SType::noScroll;
} }
} }
@ -758,7 +758,7 @@ void FScrollbar::jumpToClickPos (int x, int y)
setValue(new_val); setValue(new_val);
drawBar(); drawBar();
forceTerminalUpdate(); forceTerminalUpdate();
scroll_type = FScrollbar::scrollJump; scroll_type = SType::scrollJump;
processScroll(); processScroll();
} }
} }
@ -781,9 +781,9 @@ void FScrollbar::jumpToClickPos (int pos)
void FScrollbar::avoidScrollOvershoot() void FScrollbar::avoidScrollOvershoot()
{ {
// Avoid overshoot // Avoid overshoot
if ( ( scroll_type == FScrollbar::scrollPageBackward if ( ( scroll_type == SType::scrollPageBackward
&& slider_pos < slider_click_stop_pos ) && slider_pos < slider_click_stop_pos )
|| ( scroll_type == FScrollbar::scrollPageForward || ( scroll_type == SType::scrollPageForward
&& slider_pos > slider_click_stop_pos ) ) && slider_pos > slider_click_stop_pos ) )
{ {
jumpToClickPos (slider_click_stop_pos); jumpToClickPos (slider_click_stop_pos);

View File

@ -865,19 +865,19 @@ void FScrollView::setViewportCursor()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::cb_vbarChange (const FWidget*) void FScrollView::cb_vbarChange (const FWidget*)
{ {
FScrollbar::sType scrollType = vbar->getScrollType(); FScrollbar::SType scrollType = vbar->getScrollType();
static constexpr int wheel_distance = 4; static constexpr int wheel_distance = 4;
int distance{1}; int distance{1};
assert ( scrollType == FScrollbar::noScroll assert ( scrollType == FScrollbar::SType::noScroll
|| scrollType == FScrollbar::scrollJump || scrollType == FScrollbar::SType::scrollJump
|| scrollType == FScrollbar::scrollStepBackward || scrollType == FScrollbar::SType::scrollStepBackward
|| scrollType == FScrollbar::scrollStepForward || scrollType == FScrollbar::SType::scrollStepForward
|| scrollType == FScrollbar::scrollPageBackward || scrollType == FScrollbar::SType::scrollPageBackward
|| scrollType == FScrollbar::scrollPageForward || scrollType == FScrollbar::SType::scrollPageForward
|| scrollType == FScrollbar::scrollWheelUp || scrollType == FScrollbar::SType::scrollWheelUp
|| scrollType == FScrollbar::scrollWheelDown ); || scrollType == FScrollbar::SType::scrollWheelDown );
if ( scrollType >= FScrollbar::scrollStepBackward ) if ( scrollType >= FScrollbar::SType::scrollStepBackward )
{ {
update_scrollbar = true; update_scrollbar = true;
} }
@ -888,32 +888,32 @@ void FScrollView::cb_vbarChange (const FWidget*)
switch ( scrollType ) switch ( scrollType )
{ {
case FScrollbar::noScroll: case FScrollbar::SType::noScroll:
break; break;
case FScrollbar::scrollPageBackward: case FScrollbar::SType::scrollPageBackward:
distance = int(getViewportHeight()); distance = int(getViewportHeight());
// fall through // fall through
case FScrollbar::scrollStepBackward: case FScrollbar::SType::scrollStepBackward:
scrollBy (0, -distance); scrollBy (0, -distance);
break; break;
case FScrollbar::scrollPageForward: case FScrollbar::SType::scrollPageForward:
distance = int(getViewportHeight()); distance = int(getViewportHeight());
// fall through // fall through
case FScrollbar::scrollStepForward: case FScrollbar::SType::scrollStepForward:
scrollBy (0, distance); scrollBy (0, distance);
break; break;
case FScrollbar::scrollJump: case FScrollbar::SType::scrollJump:
scrollToY (1 + int(vbar->getValue())); scrollToY (1 + int(vbar->getValue()));
break; break;
case FScrollbar::scrollWheelUp: case FScrollbar::SType::scrollWheelUp:
scrollBy (0, -wheel_distance); scrollBy (0, -wheel_distance);
break; break;
case FScrollbar::scrollWheelDown: case FScrollbar::SType::scrollWheelDown:
scrollBy (0, wheel_distance); scrollBy (0, wheel_distance);
break; break;
} }
@ -924,19 +924,19 @@ void FScrollView::cb_vbarChange (const FWidget*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FScrollView::cb_hbarChange (const FWidget*) void FScrollView::cb_hbarChange (const FWidget*)
{ {
FScrollbar::sType scrollType = hbar->getScrollType(); FScrollbar::SType scrollType = hbar->getScrollType();
static constexpr int wheel_distance = 4; static constexpr int wheel_distance = 4;
int distance{1}; int distance{1};
assert ( scrollType == FScrollbar::noScroll assert ( scrollType == FScrollbar::SType::noScroll
|| scrollType == FScrollbar::scrollJump || scrollType == FScrollbar::SType::scrollJump
|| scrollType == FScrollbar::scrollStepBackward || scrollType == FScrollbar::SType::scrollStepBackward
|| scrollType == FScrollbar::scrollStepForward || scrollType == FScrollbar::SType::scrollStepForward
|| scrollType == FScrollbar::scrollPageBackward || scrollType == FScrollbar::SType::scrollPageBackward
|| scrollType == FScrollbar::scrollPageForward || scrollType == FScrollbar::SType::scrollPageForward
|| scrollType == FScrollbar::scrollWheelUp || scrollType == FScrollbar::SType::scrollWheelUp
|| scrollType == FScrollbar::scrollWheelDown ); || scrollType == FScrollbar::SType::scrollWheelDown );
if ( scrollType >= FScrollbar::scrollStepBackward ) if ( scrollType >= FScrollbar::SType::scrollStepBackward )
{ {
update_scrollbar = true; update_scrollbar = true;
} }
@ -947,32 +947,32 @@ void FScrollView::cb_hbarChange (const FWidget*)
switch ( scrollType ) switch ( scrollType )
{ {
case FScrollbar::noScroll: case FScrollbar::SType::noScroll:
break; break;
case FScrollbar::scrollPageBackward: case FScrollbar::SType::scrollPageBackward:
distance = int(getViewportWidth()); distance = int(getViewportWidth());
// fall through // fall through
case FScrollbar::scrollStepBackward: case FScrollbar::SType::scrollStepBackward:
scrollBy (-distance, 0); scrollBy (-distance, 0);
break; break;
case FScrollbar::scrollPageForward: case FScrollbar::SType::scrollPageForward:
distance = int(getViewportWidth()); distance = int(getViewportWidth());
// fall through // fall through
case FScrollbar::scrollStepForward: case FScrollbar::SType::scrollStepForward:
scrollBy (distance, 0); scrollBy (distance, 0);
break; break;
case FScrollbar::scrollJump: case FScrollbar::SType::scrollJump:
scrollToX (1 + int(hbar->getValue())); scrollToX (1 + int(hbar->getValue()));
break; break;
case FScrollbar::scrollWheelUp: case FScrollbar::SType::scrollWheelUp:
scrollBy (-wheel_distance, 0); scrollBy (-wheel_distance, 0);
break; break;
case FScrollbar::scrollWheelDown: case FScrollbar::SType::scrollWheelDown:
scrollBy (wheel_distance, 0); scrollBy (wheel_distance, 0);
break; break;
} }

View File

@ -460,7 +460,7 @@ std::size_t getColumnWidth (const FString& s, std::size_t pos)
} }
catch (const std::out_of_range& ex) catch (const std::out_of_range& ex)
{ {
std::clog << FLog::Error std::clog << FLog::LogLevel::Error
<< "Out of Range error: " << ex.what() << std::endl; << "Out of Range error: " << ex.what() << std::endl;
} }
} }

View File

@ -133,7 +133,7 @@ void FTermcap::termcapError (int status)
{ {
const auto& fterm_data = FTerm::getFTermData(); 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::LogLevel::Error
<< "Unknown terminal: \"" << termtype << "\". " << "Unknown terminal: \"" << termtype << "\". "
<< "Check the TERM environment variable. " << "Check the TERM environment variable. "
<< "Also make sure that the terminal " << "Also make sure that the terminal "

View File

@ -172,7 +172,7 @@ void FTermFreeBSD::finish()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermFreeBSD::warnNotInitialized() void FTermFreeBSD::warnNotInitialized()
{ {
std::clog << FLog::Warn std::clog << FLog::LogLevel::Warn
<< "The FTermFreeBSD object has " << "The FTermFreeBSD object has "
<< "not yet been initialized! " << "not yet been initialized! "
<< "Please call the init() method first." << "Please call the init() method first."

View File

@ -192,7 +192,7 @@ void FTermLinux::init()
} }
else else
{ {
std::clog << FLog::Error << "Can not open the console." << std::endl; std::clog << FLog::LogLevel::Error << "Can not open the console." << std::endl;
std::abort(); std::abort();
} }
} }

View File

@ -134,7 +134,7 @@ bool FTermOpenBSD::resetBeep()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermOpenBSD::warnNotInitialized() void FTermOpenBSD::warnNotInitialized()
{ {
std::clog << FLog::Warn std::clog << FLog::LogLevel::Warn
<< "The FTermOpenBSD object has " << "The FTermOpenBSD object has "
<< "not yet been initialized! " << "not yet been initialized! "
<< "Please call the init() method first." << "Please call the init() method first."

View File

@ -295,7 +295,7 @@ void FTermXTerminal::captureFontAndTitle()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTermXTerminal::warnNotInitialized() const void FTermXTerminal::warnNotInitialized() const
{ {
std::clog << FLog::Warn std::clog << FLog::LogLevel::Warn
<< "The FTermXTerminal object has " << "The FTermXTerminal object has "
<< "not yet been initialized! " << "not yet been initialized! "
<< "Please call the init() method first." << "Please call the init() method first."

View File

@ -761,51 +761,51 @@ void FTextView::changeOnResize() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::cb_vbarChange (const FWidget*) void FTextView::cb_vbarChange (const FWidget*)
{ {
const FScrollbar::sType scrollType = vbar->getScrollType(); const FScrollbar::SType scrollType = vbar->getScrollType();
static constexpr int wheel_distance = 4; static constexpr int wheel_distance = 4;
int distance{1}; int distance{1};
assert ( scrollType == FScrollbar::noScroll assert ( scrollType == FScrollbar::SType::noScroll
|| scrollType == FScrollbar::scrollJump || scrollType == FScrollbar::SType::scrollJump
|| scrollType == FScrollbar::scrollStepBackward || scrollType == FScrollbar::SType::scrollStepBackward
|| scrollType == FScrollbar::scrollStepForward || scrollType == FScrollbar::SType::scrollStepForward
|| scrollType == FScrollbar::scrollPageBackward || scrollType == FScrollbar::SType::scrollPageBackward
|| scrollType == FScrollbar::scrollPageForward || scrollType == FScrollbar::SType::scrollPageForward
|| scrollType == FScrollbar::scrollWheelUp || scrollType == FScrollbar::SType::scrollWheelUp
|| scrollType == FScrollbar::scrollWheelDown ); || scrollType == FScrollbar::SType::scrollWheelDown );
if ( scrollType >= FScrollbar::scrollStepBackward ) if ( scrollType >= FScrollbar::SType::scrollStepBackward )
update_scrollbar = true; update_scrollbar = true;
else else
update_scrollbar = false; update_scrollbar = false;
switch ( scrollType ) switch ( scrollType )
{ {
case FScrollbar::noScroll: case FScrollbar::SType::noScroll:
break; break;
case FScrollbar::scrollPageBackward: case FScrollbar::SType::scrollPageBackward:
distance = int(getClientHeight()); distance = int(getClientHeight());
// fall through // fall through
case FScrollbar::scrollStepBackward: case FScrollbar::SType::scrollStepBackward:
scrollBy (0, -distance); scrollBy (0, -distance);
break; break;
case FScrollbar::scrollPageForward: case FScrollbar::SType::scrollPageForward:
distance = int(getClientHeight()); distance = int(getClientHeight());
// fall through // fall through
case FScrollbar::scrollStepForward: case FScrollbar::SType::scrollStepForward:
scrollBy (0, distance); scrollBy (0, distance);
break; break;
case FScrollbar::scrollJump: case FScrollbar::SType::scrollJump:
scrollToY (vbar->getValue()); scrollToY (vbar->getValue());
break; break;
case FScrollbar::scrollWheelUp: case FScrollbar::SType::scrollWheelUp:
scrollBy (0, -wheel_distance); scrollBy (0, -wheel_distance);
break; break;
case FScrollbar::scrollWheelDown: case FScrollbar::SType::scrollWheelDown:
scrollBy (0, wheel_distance); scrollBy (0, wheel_distance);
break; break;
} }
@ -816,51 +816,51 @@ void FTextView::cb_vbarChange (const FWidget*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FTextView::cb_hbarChange (const FWidget*) void FTextView::cb_hbarChange (const FWidget*)
{ {
const FScrollbar::sType scrollType = hbar->getScrollType(); const FScrollbar::SType scrollType = hbar->getScrollType();
static constexpr int wheel_distance = 4; static constexpr int wheel_distance = 4;
int distance{1}; int distance{1};
assert ( scrollType == FScrollbar::noScroll assert ( scrollType == FScrollbar::SType::noScroll
|| scrollType == FScrollbar::scrollJump || scrollType == FScrollbar::SType::scrollJump
|| scrollType == FScrollbar::scrollStepBackward || scrollType == FScrollbar::SType::scrollStepBackward
|| scrollType == FScrollbar::scrollStepForward || scrollType == FScrollbar::SType::scrollStepForward
|| scrollType == FScrollbar::scrollPageBackward || scrollType == FScrollbar::SType::scrollPageBackward
|| scrollType == FScrollbar::scrollPageForward || scrollType == FScrollbar::SType::scrollPageForward
|| scrollType == FScrollbar::scrollWheelUp || scrollType == FScrollbar::SType::scrollWheelUp
|| scrollType == FScrollbar::scrollWheelDown ); || scrollType == FScrollbar::SType::scrollWheelDown );
if ( scrollType >= FScrollbar::scrollStepBackward ) if ( scrollType >= FScrollbar::SType::scrollStepBackward )
update_scrollbar = true; update_scrollbar = true;
else else
update_scrollbar = false; update_scrollbar = false;
switch ( scrollType ) switch ( scrollType )
{ {
case FScrollbar::noScroll: case FScrollbar::SType::noScroll:
break; break;
case FScrollbar::scrollPageBackward: case FScrollbar::SType::scrollPageBackward:
distance = int(getClientWidth()); distance = int(getClientWidth());
// fall through // fall through
case FScrollbar::scrollStepBackward: case FScrollbar::SType::scrollStepBackward:
scrollBy (-distance, 0); scrollBy (-distance, 0);
break; break;
case FScrollbar::scrollPageForward: case FScrollbar::SType::scrollPageForward:
distance = int(getClientWidth()); distance = int(getClientWidth());
// fall through // fall through
case FScrollbar::scrollStepForward: case FScrollbar::SType::scrollStepForward:
scrollBy (distance, 0); scrollBy (distance, 0);
break; break;
case FScrollbar::scrollJump: case FScrollbar::SType::scrollJump:
scrollToX (hbar->getValue()); scrollToX (hbar->getValue());
break; break;
case FScrollbar::scrollWheelUp: case FScrollbar::SType::scrollWheelUp:
scrollBy (-wheel_distance, 0); scrollBy (-wheel_distance, 0);
break; break;
case FScrollbar::scrollWheelDown: case FScrollbar::SType::scrollWheelDown:
scrollBy (wheel_distance, 0); scrollBy (wheel_distance, 0);
break; break;
} }

View File

@ -64,12 +64,12 @@ class FLog : public std::stringbuf
using IOManip = std::ostream& (*)(std::ostream&); using IOManip = std::ostream& (*)(std::ostream&);
// Enumerations // Enumerations
enum LogLevel enum class LogLevel
{ {
Info, Warn, Error, Debug Info, Warn, Error, Debug
}; };
enum LineEnding enum class LineEnding
{ {
LF, CR, CRLF LF, CR, CRLF
}; };
@ -106,8 +106,8 @@ class FLog : public std::stringbuf
private: private:
// Data member // Data member
LogLevel level{Info}; LogLevel level{LogLevel::Info};
LineEnding end_of_line{CRLF}; LineEnding end_of_line{LineEnding::CRLF};
std::mutex mut{}; std::mutex mut{};
FLogPrint current_log{std::bind(&FLog::info, this, std::placeholders::_1)}; FLogPrint current_log{std::bind(&FLog::info, this, std::placeholders::_1)};
std::ostream stream{this}; std::ostream stream{this};

View File

@ -104,7 +104,7 @@ inline FString FLogger::getClassName() const
inline void FLogger::info (const std::string& msg) inline void FLogger::info (const std::string& msg)
{ {
std::lock_guard<std::mutex> lock_guard(getMutex()); std::lock_guard<std::mutex> lock_guard(getMutex());
setLevel() = Info; setLevel() = LogLevel::Info;
printLogLine (msg); printLogLine (msg);
} }
@ -112,7 +112,7 @@ inline void FLogger::info (const std::string& msg)
inline void FLogger::warn (const std::string& msg) inline void FLogger::warn (const std::string& msg)
{ {
std::lock_guard<std::mutex> lock_guard(getMutex()); std::lock_guard<std::mutex> lock_guard(getMutex());
setLevel() = Warn; setLevel() = LogLevel::Warn;
printLogLine (msg); printLogLine (msg);
} }
@ -120,7 +120,7 @@ inline void FLogger::warn (const std::string& msg)
inline void FLogger::error (const std::string& msg) inline void FLogger::error (const std::string& msg)
{ {
std::lock_guard<std::mutex> lock_guard(getMutex()); std::lock_guard<std::mutex> lock_guard(getMutex());
setLevel() = Error; setLevel() = LogLevel::Error;
printLogLine (msg); printLogLine (msg);
} }
@ -128,7 +128,7 @@ inline void FLogger::error (const std::string& msg)
inline void FLogger::debug (const std::string& msg) inline void FLogger::debug (const std::string& msg)
{ {
std::lock_guard<std::mutex> lock_guard(getMutex()); std::lock_guard<std::mutex> lock_guard(getMutex());
setLevel() = Debug; setLevel() = LogLevel::Debug;
printLogLine (msg); printLogLine (msg);
} }

View File

@ -171,7 +171,7 @@ class FMessageBox : public FDialog
std::size_t max_line_width{0}; std::size_t max_line_width{0};
FColor emphasis_color{getColorTheme()->dialog_emphasis_fg}; FColor emphasis_color{getColorTheme()->dialog_emphasis_fg};
ButtonType result_code{ButtonType::Reject}; ButtonType result_code{ButtonType::Reject};
FButtonsDigit button_digit{ButtonType::Reject}; FButtonsDigit button_digit{};
std::size_t num_buttons{0}; std::size_t num_buttons{0};
std::size_t text_num_lines{0}; std::size_t text_num_lines{0};
bool center_text{false}; bool center_text{false};

View File

@ -122,22 +122,8 @@ class FMouseData
void clearButtonState(); void clearButtonState();
protected: protected:
struct FMouseButton // bit field
{
uChar left_button : 2; // 0..3
uChar right_button : 2; // 0..3
uChar middle_button : 2; // 0..3
uChar shift_button : 1; // 0..1
uChar control_button : 1; // 0..1
uChar meta_button : 1; // 0..1
uChar wheel_up : 1; // 0..1
uChar wheel_down : 1; // 0..1
uChar mouse_moved : 1; // 0..1
uChar : 4; // padding bits
};
// Enumerations // Enumerations
enum states enum class State : uChar
{ {
Undefined = 0, Undefined = 0,
Pressed = 1, Pressed = 1,
@ -145,6 +131,19 @@ class FMouseData
DoubleClick = 3 DoubleClick = 3
}; };
struct FMouseButton
{
State left_button{};
State right_button{};
State middle_button{};
bool shift_button{};
bool control_button{};
bool meta_button{};
bool wheel_up{};
bool wheel_down{};
bool mouse_moved{};
};
// Accessors // Accessors
FMouseButton& getButtonState(); FMouseButton& getButtonState();
const FMouseButton& getButtonState() const; const FMouseButton& getButtonState() const;
@ -167,7 +166,7 @@ class FMouse : public FMouseData
{ {
public: public:
// Enumeration // Enumeration
enum mouse_type enum class MouseType
{ {
none = 0, none = 0,
gpm = 1, gpm = 1,
@ -537,7 +536,7 @@ class FMouseControl
// Methods // Methods
void enable(); void enable();
void disable(); void disable();
virtual void setRawData ( FMouse::mouse_type virtual void setRawData ( FMouse::MouseType
, FKeyboard::keybuffer& ); , FKeyboard::keybuffer& );
virtual void processEvent (struct timeval* time); virtual void processEvent (struct timeval* time);
void processQueuedInput(); void processQueuedInput();
@ -548,11 +547,11 @@ class FMouseControl
// Using-declaration // Using-declaration
using FMousePtr = std::unique_ptr<FMouse>; using FMousePtr = std::unique_ptr<FMouse>;
using FMouseDataPtr = std::unique_ptr<FMouseData>; using FMouseDataPtr = std::unique_ptr<FMouseData>;
using FMouseProtocol = std::map<FMouse::mouse_type, FMousePtr>; using FMouseProtocol = std::map<FMouse::MouseType, FMousePtr>;
// Accessor // Accessor
FMouse::mouse_type getMouseWithData(); FMouse::MouseType getMouseWithData();
FMouse::mouse_type getMouseWithEvent(); FMouse::MouseType getMouseWithEvent();
void xtermMouse (bool) const; void xtermMouse (bool) const;
void enableXTermMouse() const; void enableXTermMouse() const;
void disableXTermMouse() const; void disableXTermMouse() const;

View File

@ -74,7 +74,7 @@ class FScrollbar : public FWidget
using FWidget::setGeometry; using FWidget::setGeometry;
// Enumeration // Enumeration
enum sType enum class SType
{ {
noScroll = 0, noScroll = 0,
scrollJump = 1, scrollJump = 1,
@ -102,7 +102,7 @@ class FScrollbar : public FWidget
// Accessors // Accessors
FString getClassName() const override; FString getClassName() const override;
int getValue() const; int getValue() const;
sType getScrollType() const; SType getScrollType() const;
// Mutators // Mutators
void setMinimum (int); void setMinimum (int);
@ -138,9 +138,9 @@ class FScrollbar : public FWidget
void drawHorizontalBar(); void drawHorizontalBar();
void drawHorizontalBackgroundColumn(); void drawHorizontalBackgroundColumn();
void drawButtons(); void drawButtons();
sType getClickedScrollType (int, int) const; SType getClickedScrollType (int, int) const;
sType getVerticalClickedScrollType (int) const; SType getVerticalClickedScrollType (int) const;
sType getHorizontalClickedScrollType (int) const; SType getHorizontalClickedScrollType (int) const;
int getSliderClickPos (int, int) const; int getSliderClickPos (int, int) const;
void jumpToClickPos (int, int); void jumpToClickPos (int, int);
void jumpToClickPos (int); void jumpToClickPos (int);
@ -149,7 +149,7 @@ class FScrollbar : public FWidget
void changeOnResize(); void changeOnResize();
// Data members // Data members
sType scroll_type{FScrollbar::noScroll}; SType scroll_type{SType::noScroll};
bool threshold_reached{false}; bool threshold_reached{false};
int threshold_time{500}; int threshold_time{500};
int repeat_time{80}; int repeat_time{80};
@ -211,7 +211,7 @@ inline int FScrollbar::getValue() const
{ return val; } { return val; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FScrollbar::sType FScrollbar::getScrollType() const inline FScrollbar::SType FScrollbar::getScrollType() const
{ return scroll_type; } { return scroll_type; }
} // namespace finalcut } // namespace finalcut

View File

@ -43,7 +43,7 @@
#define null nullptr #define null nullptr
#define badAllocOutput(object_name) \ #define badAllocOutput(object_name) \
std::clog << FLog::Error \ std::clog << FLog::LogLevel::Error \
<< __FILE__ << ":" << __LINE__ \ << __FILE__ << ":" << __LINE__ \
<< ": Not enough memory to alloc " \ << ": Not enough memory to alloc " \
<< (object_name) \ << (object_name) \

View File

@ -149,11 +149,11 @@ void FLoggerTest::defaultObjectTest()
CPPUNIT_ASSERT ( buf.str() == "[INFO] Hello, World!\n\r\n" ); CPPUNIT_ASSERT ( buf.str() == "[INFO] Hello, World!\n\r\n" );
buf.str(""); // Clear buffer buf.str(""); // Clear buffer
log << finalcut::FLog::Info << "Hello, World!" << std::flush; log << finalcut::FLog::LogLevel::Info << "Hello, World!" << std::flush;
CPPUNIT_ASSERT ( buf.str() == "[INFO] Hello, World!\r\n" ); CPPUNIT_ASSERT ( buf.str() == "[INFO] Hello, World!\r\n" );
buf.str(""); // Clear buffer buf.str(""); // Clear buffer
log << finalcut::FLog::Warn << "Hello, World!" << std::flush; log << finalcut::FLog::LogLevel::Warn << "Hello, World!" << std::flush;
CPPUNIT_ASSERT ( buf.str() == "[WARNING] Hello, World!\r\n" ); CPPUNIT_ASSERT ( buf.str() == "[WARNING] Hello, World!\r\n" );
buf.str(""); // Clear buffer buf.str(""); // Clear buffer
@ -161,7 +161,7 @@ void FLoggerTest::defaultObjectTest()
CPPUNIT_ASSERT ( buf.str() == "[WARNING] Hello, World!\r\n" ); CPPUNIT_ASSERT ( buf.str() == "[WARNING] Hello, World!\r\n" );
buf.str(""); // Clear buffer buf.str(""); // Clear buffer
log << finalcut::FLog::Error << "Hello, World!" << std::flush; log << finalcut::FLog::LogLevel::Error << "Hello, World!" << std::flush;
CPPUNIT_ASSERT ( buf.str() == "[ERROR] Hello, World!\r\n" ); CPPUNIT_ASSERT ( buf.str() == "[ERROR] Hello, World!\r\n" );
buf.str(""); // Clear buffer buf.str(""); // Clear buffer
@ -169,7 +169,7 @@ void FLoggerTest::defaultObjectTest()
CPPUNIT_ASSERT ( buf.str() == "[ERROR] Hello, World!\r\n" ); CPPUNIT_ASSERT ( buf.str() == "[ERROR] Hello, World!\r\n" );
buf.str(""); // Clear buffer buf.str(""); // Clear buffer
log << finalcut::FLog::Debug << "Hello, World!" << std::flush; log << finalcut::FLog::LogLevel::Debug << "Hello, World!" << std::flush;
CPPUNIT_ASSERT ( buf.str() == "[DEBUG] Hello, World!\r\n" ); CPPUNIT_ASSERT ( buf.str() == "[DEBUG] Hello, World!\r\n" );
buf.str(""); // Clear buffer buf.str(""); // Clear buffer
@ -206,17 +206,17 @@ void FLoggerTest::lineEndingTest()
CPPUNIT_ASSERT ( buf.str() == "[INFO] Line endings\r\n" ); CPPUNIT_ASSERT ( buf.str() == "[INFO] Line endings\r\n" );
buf.str(""); // Clear buffer buf.str(""); // Clear buffer
log.setLineEnding(finalcut::FLog::LF); log.setLineEnding(finalcut::FLog::LineEnding::LF);
log.warn("Line endings"); log.warn("Line endings");
CPPUNIT_ASSERT ( buf.str() == "[WARNING] Line endings\n" ); CPPUNIT_ASSERT ( buf.str() == "[WARNING] Line endings\n" );
buf.str(""); // Clear buffer buf.str(""); // Clear buffer
log.setLineEnding(finalcut::FLog::CR); log.setLineEnding(finalcut::FLog::LineEnding::CR);
log.error("Line endings"); log.error("Line endings");
CPPUNIT_ASSERT ( buf.str() == "[ERROR] Line endings\r" ); CPPUNIT_ASSERT ( buf.str() == "[ERROR] Line endings\r" );
buf.str(""); // Clear buffer buf.str(""); // Clear buffer
log.setLineEnding(finalcut::FLog::CRLF); log.setLineEnding(finalcut::FLog::LineEnding::CRLF);
log.debug("Line endings"); log.debug("Line endings");
CPPUNIT_ASSERT ( buf.str() == "[DEBUG] Line endings\r\n" ); CPPUNIT_ASSERT ( buf.str() == "[DEBUG] Line endings\r\n" );
buf.str(""); // Clear buffer buf.str(""); // Clear buffer
@ -258,17 +258,17 @@ void FLoggerTest::fileTest()
{ {
finalcut::FLogger log{}; finalcut::FLogger log{};
std::ofstream file_stream(filename, std::ofstream::out); std::ofstream file_stream(filename, std::ofstream::out);
log.setLineEnding (finalcut::FLog::LF); log.setLineEnding (finalcut::FLog::LineEnding::LF);
log.setOutputStream(file_stream); log.setOutputStream(file_stream);
log.info("test1"); log.info("test1");
log.warn("test2"); log.warn("test2");
log.error("test3"); log.error("test3");
log.debug("test4"); log.debug("test4");
log << finalcut::FLog::Info << "streaming test1"; log << finalcut::FLog::LogLevel::Info << "streaming test1";
log << finalcut::FLog::Warn << "streaming test2"; log << finalcut::FLog::LogLevel::Warn << "streaming test2";
log << finalcut::FLog::Error << "streaming test3"; log << finalcut::FLog::LogLevel::Error << "streaming test3";
log << finalcut::FLog::Debug << "streaming test4" << std::flush; log << finalcut::FLog::LogLevel::Debug << "streaming test4" << std::flush;
if ( file_stream.is_open() ) if ( file_stream.is_open() )
file_stream.close(); file_stream.close();
@ -308,7 +308,7 @@ void FLoggerTest::fileTest()
{ {
finalcut::FLogger log{}; finalcut::FLogger log{};
log.setOutputStream(std::cerr); log.setOutputStream(std::cerr);
log.setLineEnding (finalcut::FLog::LF); log.setLineEnding (finalcut::FLog::LineEnding::LF);
log.error("Cannot delete the test.log file"); log.error("Cannot delete the test.log file");
} }
} }
@ -347,16 +347,16 @@ void FLoggerTest::applicationObjectTest()
CPPUNIT_ASSERT ( buf.str() == "[INFO] test5\r\n" ); CPPUNIT_ASSERT ( buf.str() == "[INFO] test5\r\n" );
buf.str(""); // Clear buffer buf.str(""); // Clear buffer
*log << finalcut::FLog::Error << "test6" << std::flush; *log << finalcut::FLog::LogLevel::Error << "test6" << std::flush;
CPPUNIT_ASSERT ( buf.str() == "[ERROR] test6\r\n" ); CPPUNIT_ASSERT ( buf.str() == "[ERROR] test6\r\n" );
buf.str(""); // Clear buffer buf.str(""); // Clear buffer
// Logging to std::clog // Logging to std::clog
std::clog << finalcut::FLog::Info << "test7" << std::flush; std::clog << finalcut::FLog::LogLevel::Info << "test7" << std::flush;
CPPUNIT_ASSERT ( buf.str() == "[INFO] test7\r\n" ); CPPUNIT_ASSERT ( buf.str() == "[INFO] test7\r\n" );
buf.str(""); // Clear buffer buf.str(""); // Clear buffer
std::clog << finalcut::FLog::Warn << "test8" << std::endl; std::clog << finalcut::FLog::LogLevel::Warn << "test8" << std::endl;
CPPUNIT_ASSERT ( buf.str() == "[WARNING] test8\n\r\n" ); CPPUNIT_ASSERT ( buf.str() == "[WARNING] test8\n\r\n" );
buf.str(""); // Clear buffer buf.str(""); // Clear buffer
@ -382,11 +382,11 @@ void FLoggerTest::applicationObjectTest()
buf.str(""); // Clear buffer buf.str(""); // Clear buffer
// Logging to std::clog with the replaced logger // Logging to std::clog with the replaced logger
std::clog << finalcut::FLog::Info << "myLogger 5" << std::flush; std::clog << finalcut::FLog::LogLevel::Info << "myLogger 5" << std::flush;
CPPUNIT_ASSERT ( buf.str() == " Info: myLogger 5\n" ); CPPUNIT_ASSERT ( buf.str() == " Info: myLogger 5\n" );
buf.str(""); // Clear buffer buf.str(""); // Clear buffer
std::clog << finalcut::FLog::Error << "myLogger 6" << std::endl; std::clog << finalcut::FLog::LogLevel::Error << "myLogger 6" << std::endl;
CPPUNIT_ASSERT ( buf.str() == "Error: myLogger 6\n\n" ); CPPUNIT_ASSERT ( buf.str() == "Error: myLogger 6\n\n" );
buf.str(""); // Clear buffer buf.str(""); // Clear buffer

View File

@ -1267,7 +1267,7 @@ void FMouseTest::mouseControlTest()
finalcut::FKeyboard::keybuffer rawdata1 = \ finalcut::FKeyboard::keybuffer rawdata1 = \
{ 0x1b, '[', 'M', 0x20, 0x25, 0x28 { 0x1b, '[', 'M', 0x20, 0x25, 0x28
, 0x1b, '[', 'M', 0x23, 0x25, 0x28 }; , 0x1b, '[', 'M', 0x23, 0x25, 0x28 };
mouse_control.setRawData (finalcut::FMouse::x11, rawdata1); mouse_control.setRawData (finalcut::FMouse::MouseType::x11, rawdata1);
CPPUNIT_ASSERT ( mouse_control.hasData() ); CPPUNIT_ASSERT ( mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() );
@ -1292,7 +1292,7 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( ! mouse_control.isMoved() ); CPPUNIT_ASSERT ( ! mouse_control.isMoved() );
CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() );
mouse_control.setRawData (finalcut::FMouse::x11, rawdata1); mouse_control.setRawData (finalcut::FMouse::MouseType::x11, rawdata1);
mouse_control.processEvent (&tv); mouse_control.processEvent (&tv);
CPPUNIT_ASSERT ( ! mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! mouse_control.hasUnprocessedInput() );
CPPUNIT_ASSERT ( ! mouse_control.isLeftButtonPressed() ); CPPUNIT_ASSERT ( ! mouse_control.isLeftButtonPressed() );
@ -1303,7 +1303,7 @@ void FMouseTest::mouseControlTest()
finalcut::FKeyboard::keybuffer rawdata2 = \ finalcut::FKeyboard::keybuffer rawdata2 = \
{ 0x1b, '[', '<', '1', ';', '1', ';', '1', 'M' { 0x1b, '[', '<', '1', ';', '1', ';', '1', 'M'
, 0x1b, '[', '<', '1', ';', '1', ';', '1', 'm' }; , 0x1b, '[', '<', '1', ';', '1', ';', '1', 'm' };
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata2); mouse_control.setRawData (finalcut::FMouse::MouseType::sgr, rawdata2);
CPPUNIT_ASSERT ( mouse_control.hasData() ); CPPUNIT_ASSERT ( mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); finalcut::FObject::getCurrentTime(&tv);
@ -1325,7 +1325,7 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( ! mouse_control.isWheelDown() ); CPPUNIT_ASSERT ( ! mouse_control.isWheelDown() );
CPPUNIT_ASSERT ( ! mouse_control.isMoved() ); CPPUNIT_ASSERT ( ! mouse_control.isMoved() );
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata2); mouse_control.setRawData (finalcut::FMouse::MouseType::sgr, rawdata2);
mouse_control.processEvent (&tv); mouse_control.processEvent (&tv);
CPPUNIT_ASSERT ( ! mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! mouse_control.hasUnprocessedInput() );
CPPUNIT_ASSERT ( ! mouse_control.isMiddleButtonPressed() ); CPPUNIT_ASSERT ( ! mouse_control.isMiddleButtonPressed() );
@ -1334,7 +1334,7 @@ void FMouseTest::mouseControlTest()
// Right mouse button on a urxvt mouse // Right mouse button on a urxvt mouse
finalcut::FKeyboard::keybuffer rawdata3 = { 0x1b, '[', '3', '4', ';', '3', ';', '3', 'M' finalcut::FKeyboard::keybuffer rawdata3 = { 0x1b, '[', '3', '4', ';', '3', ';', '3', 'M'
, 0x1b, '[', '3', '5', ';', '3', ';', '4', 'M' }; , 0x1b, '[', '3', '5', ';', '3', ';', '4', 'M' };
mouse_control.setRawData (finalcut::FMouse::urxvt, rawdata3); mouse_control.setRawData (finalcut::FMouse::MouseType::urxvt, rawdata3);
CPPUNIT_ASSERT ( mouse_control.hasData() ); CPPUNIT_ASSERT ( mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); finalcut::FObject::getCurrentTime(&tv);
@ -1356,7 +1356,7 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( ! mouse_control.isWheelDown() ); CPPUNIT_ASSERT ( ! mouse_control.isWheelDown() );
CPPUNIT_ASSERT ( ! mouse_control.isMoved() ); CPPUNIT_ASSERT ( ! mouse_control.isMoved() );
mouse_control.setRawData (finalcut::FMouse::urxvt, rawdata3); mouse_control.setRawData (finalcut::FMouse::MouseType::urxvt, rawdata3);
mouse_control.processEvent (&tv); mouse_control.processEvent (&tv);
CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(3, 4) ); CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(3, 4) );
CPPUNIT_ASSERT ( ! mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! mouse_control.hasUnprocessedInput() );
@ -1367,7 +1367,7 @@ void FMouseTest::mouseControlTest()
finalcut::FKeyboard::keybuffer rawdata4 = \ finalcut::FKeyboard::keybuffer rawdata4 = \
{ 0x1b, '[', 'M', 0x60, 0x70, 0x39 { 0x1b, '[', 'M', 0x60, 0x70, 0x39
, 0x1b, '[', 'M', 0x61, 0x70, 0x39 }; , 0x1b, '[', 'M', 0x61, 0x70, 0x39 };
mouse_control.setRawData (finalcut::FMouse::x11, rawdata4); mouse_control.setRawData (finalcut::FMouse::MouseType::x11, rawdata4);
CPPUNIT_ASSERT ( mouse_control.hasData() ); CPPUNIT_ASSERT ( mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); finalcut::FObject::getCurrentTime(&tv);
@ -1389,7 +1389,7 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( ! mouse_control.isWheelDown() ); CPPUNIT_ASSERT ( ! mouse_control.isWheelDown() );
CPPUNIT_ASSERT ( ! mouse_control.isMoved() ); CPPUNIT_ASSERT ( ! mouse_control.isMoved() );
mouse_control.setRawData (finalcut::FMouse::x11, rawdata4); mouse_control.setRawData (finalcut::FMouse::MouseType::x11, rawdata4);
mouse_control.processEvent (&tv); mouse_control.processEvent (&tv);
CPPUNIT_ASSERT ( ! mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! mouse_control.hasUnprocessedInput() );
CPPUNIT_ASSERT ( mouse_control.isWheelDown() ); CPPUNIT_ASSERT ( mouse_control.isWheelDown() );
@ -1399,7 +1399,7 @@ void FMouseTest::mouseControlTest()
{ 0x1b, '[', '<', '0', ';', '1', ';', '2', 'M' { 0x1b, '[', '<', '0', ';', '1', ';', '2', 'M'
, 0x1b, '[', '<', '3', '2', ';', '2', ';', '3', 'M' , 0x1b, '[', '<', '3', '2', ';', '2', ';', '3', 'M'
, 0x1b, '[', '<', '0', ';', '3', ';', '4', 'm' }; , 0x1b, '[', '<', '0', ';', '3', ';', '4', 'm' };
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata5); mouse_control.setRawData (finalcut::FMouse::MouseType::sgr, rawdata5);
CPPUNIT_ASSERT ( mouse_control.hasData() ); CPPUNIT_ASSERT ( mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); finalcut::FObject::getCurrentTime(&tv);
@ -1421,12 +1421,12 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( ! mouse_control.isWheelDown() ); CPPUNIT_ASSERT ( ! mouse_control.isWheelDown() );
CPPUNIT_ASSERT ( ! mouse_control.isMoved() ); CPPUNIT_ASSERT ( ! mouse_control.isMoved() );
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata5); mouse_control.setRawData (finalcut::FMouse::MouseType::sgr, rawdata5);
mouse_control.processEvent (&tv); mouse_control.processEvent (&tv);
CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(2, 3) ); CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(2, 3) );
CPPUNIT_ASSERT ( mouse_control.isMoved() ); CPPUNIT_ASSERT ( mouse_control.isMoved() );
mouse_control.setRawData (finalcut::FMouse::sgr, rawdata5); mouse_control.setRawData (finalcut::FMouse::MouseType::sgr, rawdata5);
mouse_control.processEvent (&tv); mouse_control.processEvent (&tv);
CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(3, 4) ); CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(3, 4) );
CPPUNIT_ASSERT ( ! mouse_control.isMoved() ); CPPUNIT_ASSERT ( ! mouse_control.isMoved() );