diff --git a/examples/event-log.cpp b/examples/event-log.cpp index 900b3941..98bc6a3b 100644 --- a/examples/event-log.cpp +++ b/examples/event-log.cpp @@ -126,7 +126,7 @@ void EventDialog::logMouseEvent ( const finalcut::FString& state const int mouse_x = ev.getX(); const int mouse_y = ev.getY(); - log << finalcut::FLog::Info + log << finalcut::FLog::LogLevel::Info << getMouseButtonName(ev.getButton()) << " mouse button " << state << " at (" << mouse_x << ", " << mouse_y << ")" << std::flush; @@ -162,7 +162,7 @@ void EventDialog::onKeyPress (finalcut::FKeyEvent* ev) key_name = wchar_t(key_id); // std::clog redirects all stream data to FLogger - std::clog << finalcut::FLog::Info + std::clog << finalcut::FLog::LogLevel::Info << "Key " << key_name << " (id " << key_id << ")" << std::flush; @@ -322,7 +322,7 @@ int main (int argc, char* argv[]) finalcut::FLog& log = *finalcut::FApplication::getLog(); // Set the line endings (default = CRLF) - log.setLineEnding (finalcut::FLog::LF); + log.setLineEnding (finalcut::FLog::LineEnding::LF); // Write a timestamp before each output line log.enableTimestamp(); diff --git a/src/fapplication.cpp b/src/fapplication.cpp index ee744e0e..b7db789f 100644 --- a/src/fapplication.cpp +++ b/src/fapplication.cpp @@ -344,7 +344,7 @@ void FApplication::setLogFile (const FString& filename) FLog& log = *FApplication::getLog(); log.setOutputStream(log_stream); log.enableTimestamp(); - log.setLineEnding (finalcut::FLog::LF); + log.setLineEnding (FLog::LineEnding::LF); } else { @@ -434,7 +434,7 @@ void FApplication::init() // Initialize logging 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() ) { case fc::Fkey_mouse: - mouse->setRawData (FMouse::x11, buffer); + mouse->setRawData (FMouse::MouseType::x11, buffer); break; case fc::Fkey_extended_mouse: - mouse->setRawData (FMouse::sgr, buffer); + mouse->setRawData (FMouse::MouseType::sgr, buffer); break; case fc::Fkey_urxvt_mouse: - mouse->setRawData (FMouse::urxvt, buffer); + mouse->setRawData (FMouse::MouseType::urxvt, buffer); break; default: diff --git a/src/flineedit.cpp b/src/flineedit.cpp index 65d376f6..4dc72aa1 100644 --- a/src/flineedit.cpp +++ b/src/flineedit.cpp @@ -826,7 +826,7 @@ inline FLineEdit::offsetPair FLineEdit::endPosToOffset (std::size_t pos) } catch (const std::out_of_range& ex) { - std::clog << FLog::Error + std::clog << FLog::LogLevel::Error << "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) { - std::clog << FLog::Error + std::clog << FLog::LogLevel::Error << "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) { - std::clog << FLog::Error + std::clog << FLog::LogLevel::Error << "Out of Range error: " << ex.what() << std::endl; } @@ -920,7 +920,7 @@ void FLineEdit::adjustTextOffset() } catch (const std::out_of_range& ex) { - std::clog << FLog::Error + std::clog << FLog::LogLevel::Error << "Out of Range error: " << ex.what() << std::endl; } } @@ -933,7 +933,7 @@ void FLineEdit::adjustTextOffset() } catch (const std::out_of_range& ex) { - std::clog << FLog::Error + std::clog << FLog::LogLevel::Error << "Out of Range error: " << ex.what() << std::endl; } } diff --git a/src/flistbox.cpp b/src/flistbox.cpp index bfc278c6..ebd34929 100644 --- a/src/flistbox.cpp +++ b/src/flistbox.cpp @@ -1731,49 +1731,49 @@ void FListBox::lazyConvert(FListBoxItems::iterator iter, std::size_t y) //---------------------------------------------------------------------- void FListBox::cb_vbarChange (const FWidget*) { - FScrollbar::sType scrollType; + FScrollbar::SType scrollType; const std::size_t current_before = current; static constexpr int wheel_distance = 4; int distance{1}; const int yoffset_before = yoffset; scrollType = vbar->getScrollType(); - assert ( scrollType == FScrollbar::noScroll - || scrollType == FScrollbar::scrollJump - || scrollType == FScrollbar::scrollStepBackward - || scrollType == FScrollbar::scrollStepForward - || scrollType == FScrollbar::scrollPageBackward - || scrollType == FScrollbar::scrollPageForward - || scrollType == FScrollbar::scrollWheelUp - || scrollType == FScrollbar::scrollWheelDown ); + assert ( scrollType == FScrollbar::SType::noScroll + || scrollType == FScrollbar::SType::scrollJump + || scrollType == FScrollbar::SType::scrollStepBackward + || scrollType == FScrollbar::SType::scrollStepForward + || scrollType == FScrollbar::SType::scrollPageBackward + || scrollType == FScrollbar::SType::scrollPageForward + || scrollType == FScrollbar::SType::scrollWheelUp + || scrollType == FScrollbar::SType::scrollWheelDown ); switch ( scrollType ) { - case FScrollbar::noScroll: + case FScrollbar::SType::noScroll: break; - case FScrollbar::scrollPageBackward: + case FScrollbar::SType::scrollPageBackward: distance = int(getClientHeight()); // fall through - case FScrollbar::scrollStepBackward: + case FScrollbar::SType::scrollStepBackward: prevListItem (distance); break; - case FScrollbar::scrollPageForward: + case FScrollbar::SType::scrollPageForward: distance = int(getClientHeight()); // fall through - case FScrollbar::scrollStepForward: + case FScrollbar::SType::scrollStepForward: nextListItem (distance); break; - case FScrollbar::scrollJump: + case FScrollbar::SType::scrollJump: scrollToY (vbar->getValue()); break; - case FScrollbar::scrollWheelUp: + case FScrollbar::SType::scrollWheelUp: wheelUp (wheel_distance); break; - case FScrollbar::scrollWheelDown: + case FScrollbar::SType::scrollWheelDown: wheelDown (wheel_distance); break; } @@ -1787,7 +1787,7 @@ void FListBox::cb_vbarChange (const FWidget*) if ( isShown() ) drawList(); - if ( scrollType >= FScrollbar::scrollStepBackward ) + if ( scrollType >= FScrollbar::SType::scrollStepBackward ) { 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 wheel_distance = 4; - FScrollbar::sType scrollType; + FScrollbar::SType scrollType; int distance{1}; const int xoffset_before = xoffset; scrollType = hbar->getScrollType(); - assert ( scrollType == FScrollbar::noScroll - || scrollType == FScrollbar::scrollJump - || scrollType == FScrollbar::scrollStepBackward - || scrollType == FScrollbar::scrollStepForward - || scrollType == FScrollbar::scrollPageBackward - || scrollType == FScrollbar::scrollPageForward - || scrollType == FScrollbar::scrollWheelUp - || scrollType == FScrollbar::scrollWheelDown ); + assert ( scrollType == FScrollbar::SType::noScroll + || scrollType == FScrollbar::SType::scrollJump + || scrollType == FScrollbar::SType::scrollStepBackward + || scrollType == FScrollbar::SType::scrollStepForward + || scrollType == FScrollbar::SType::scrollPageBackward + || scrollType == FScrollbar::SType::scrollPageForward + || scrollType == FScrollbar::SType::scrollWheelUp + || scrollType == FScrollbar::SType::scrollWheelDown ); switch ( scrollType ) { - case FScrollbar::noScroll: + case FScrollbar::SType::noScroll: break; - case FScrollbar::scrollPageBackward: + case FScrollbar::SType::scrollPageBackward: distance = int(getClientWidth()) - padding_space; // fall through - case FScrollbar::scrollStepBackward: + case FScrollbar::SType::scrollStepBackward: scrollLeft (distance); break; - case FScrollbar::scrollPageForward: + case FScrollbar::SType::scrollPageForward: distance = int(getClientWidth()) - padding_space; // fall through - case FScrollbar::scrollStepForward: + case FScrollbar::SType::scrollStepForward: scrollRight (distance); break; - case FScrollbar::scrollJump: + case FScrollbar::SType::scrollJump: scrollToX (hbar->getValue()); break; - case FScrollbar::scrollWheelUp: + case FScrollbar::SType::scrollWheelUp: scrollLeft (wheel_distance); break; - case FScrollbar::scrollWheelDown: + case FScrollbar::SType::scrollWheelDown: scrollRight (wheel_distance); break; } @@ -1855,7 +1855,7 @@ void FListBox::cb_hbarChange (const FWidget*) drawList(); - if ( scrollType >= FScrollbar::scrollStepBackward ) + if ( scrollType >= FScrollbar::SType::scrollStepBackward ) { hbar->setValue (xoffset); diff --git a/src/flistview.cpp b/src/flistview.cpp index 084f1d00..652a6bb8 100644 --- a/src/flistview.cpp +++ b/src/flistview.cpp @@ -2765,47 +2765,47 @@ void FListView::scrollBy (int dx, int dy) //---------------------------------------------------------------------- void FListView::cb_vbarChange (const FWidget*) { - FScrollbar::sType scrollType = vbar->getScrollType(); + FScrollbar::SType scrollType = vbar->getScrollType(); static constexpr int wheel_distance = 4; int distance{1}; first_line_position_before = first_visible_line.getPosition(); - assert ( scrollType == FScrollbar::noScroll - || scrollType == FScrollbar::scrollJump - || scrollType == FScrollbar::scrollStepBackward - || scrollType == FScrollbar::scrollStepForward - || scrollType == FScrollbar::scrollPageBackward - || scrollType == FScrollbar::scrollPageForward - || scrollType == FScrollbar::scrollWheelUp - || scrollType == FScrollbar::scrollWheelDown ); + assert ( scrollType == FScrollbar::SType::noScroll + || scrollType == FScrollbar::SType::scrollJump + || scrollType == FScrollbar::SType::scrollStepBackward + || scrollType == FScrollbar::SType::scrollStepForward + || scrollType == FScrollbar::SType::scrollPageBackward + || scrollType == FScrollbar::SType::scrollPageForward + || scrollType == FScrollbar::SType::scrollWheelUp + || scrollType == FScrollbar::SType::scrollWheelDown ); switch ( scrollType ) { - case FScrollbar::noScroll: + case FScrollbar::SType::noScroll: break; - case FScrollbar::scrollPageBackward: + case FScrollbar::SType::scrollPageBackward: distance = int(getClientHeight()); // fall through - case FScrollbar::scrollStepBackward: + case FScrollbar::SType::scrollStepBackward: stepBackward(distance); break; - case FScrollbar::scrollPageForward: + case FScrollbar::SType::scrollPageForward: distance = int(getClientHeight()); // fall through - case FScrollbar::scrollStepForward: + case FScrollbar::SType::scrollStepForward: stepForward(distance); break; - case FScrollbar::scrollJump: + case FScrollbar::SType::scrollJump: scrollToY (vbar->getValue()); break; - case FScrollbar::scrollWheelUp: + case FScrollbar::SType::scrollWheelUp: wheelUp (wheel_distance); break; - case FScrollbar::scrollWheelDown: + case FScrollbar::SType::scrollWheelDown: wheelDown (wheel_distance); break; } @@ -2813,8 +2813,8 @@ void FListView::cb_vbarChange (const FWidget*) if ( isShown() ) drawList(); - if ( scrollType >= FScrollbar::scrollStepBackward - && scrollType <= FScrollbar::scrollPageForward ) + if ( scrollType >= FScrollbar::SType::scrollStepBackward + && scrollType <= FScrollbar::SType::scrollPageForward ) { vbar->setValue (first_visible_line.getPosition()); @@ -2828,47 +2828,47 @@ void FListView::cb_vbarChange (const FWidget*) //---------------------------------------------------------------------- void FListView::cb_hbarChange (const FWidget*) { - FScrollbar::sType scrollType = hbar->getScrollType(); + FScrollbar::SType scrollType = hbar->getScrollType(); static constexpr int wheel_distance = 4; int distance{1}; const int xoffset_before = xoffset; - assert ( scrollType == FScrollbar::noScroll - || scrollType == FScrollbar::scrollJump - || scrollType == FScrollbar::scrollStepBackward - || scrollType == FScrollbar::scrollStepForward - || scrollType == FScrollbar::scrollPageBackward - || scrollType == FScrollbar::scrollPageForward - || scrollType == FScrollbar::scrollWheelUp - || scrollType == FScrollbar::scrollWheelDown ); + assert ( scrollType == FScrollbar::SType::noScroll + || scrollType == FScrollbar::SType::scrollJump + || scrollType == FScrollbar::SType::scrollStepBackward + || scrollType == FScrollbar::SType::scrollStepForward + || scrollType == FScrollbar::SType::scrollPageBackward + || scrollType == FScrollbar::SType::scrollPageForward + || scrollType == FScrollbar::SType::scrollWheelUp + || scrollType == FScrollbar::SType::scrollWheelDown ); switch ( scrollType ) { - case FScrollbar::noScroll: + case FScrollbar::SType::noScroll: break; - case FScrollbar::scrollPageBackward: + case FScrollbar::SType::scrollPageBackward: distance = int(getClientWidth()); // fall through - case FScrollbar::scrollStepBackward: + case FScrollbar::SType::scrollStepBackward: scrollBy (-distance, 0); break; - case FScrollbar::scrollPageForward: + case FScrollbar::SType::scrollPageForward: distance = int(getClientWidth()); // fall through - case FScrollbar::scrollStepForward: + case FScrollbar::SType::scrollStepForward: scrollBy (distance, 0); break; - case FScrollbar::scrollJump: + case FScrollbar::SType::scrollJump: scrollToX (hbar->getValue()); break; - case FScrollbar::scrollWheelUp: + case FScrollbar::SType::scrollWheelUp: scrollBy (-wheel_distance, 0); break; - case FScrollbar::scrollWheelDown: + case FScrollbar::SType::scrollWheelDown: scrollBy (wheel_distance, 0); break; } @@ -2879,7 +2879,7 @@ void FListView::cb_hbarChange (const FWidget*) drawList(); } - if ( scrollType >= FScrollbar::scrollStepBackward ) + if ( scrollType >= FScrollbar::SType::scrollStepBackward ) { hbar->setValue (xoffset); diff --git a/src/flog.cpp b/src/flog.cpp index 37567fff..49c5d08f 100644 --- a/src/flog.cpp +++ b/src/flog.cpp @@ -47,19 +47,19 @@ FLog& FLog::operator << (LogLevel l) switch ( l ) { - case Info: + case LogLevel::Info: current_log = std::bind(&FLog::info, this, _1); break; - case Warn: + case LogLevel::Warn: current_log = std::bind(&FLog::warn, this, _1); break; - case Error: + case LogLevel::Error: current_log = std::bind(&FLog::error, this, _1); break; - case Debug: + case LogLevel::Debug: current_log = std::bind(&FLog::debug, this, _1); break; } diff --git a/src/flogger.cpp b/src/flogger.cpp index 216e0b7d..b71a9c31 100644 --- a/src/flogger.cpp +++ b/src/flogger.cpp @@ -71,11 +71,11 @@ std::string FLogger::getEOL() { std::lock_guard lock_guard(getMutex()); - if ( getEnding() == FLog::LF ) + if ( getEnding() == LineEnding::LF ) return "\n"; - else if ( getEnding() == FLog::CR ) + else if ( getEnding() == LineEnding::CR ) return "\r"; - else if ( getEnding() == FLog::CRLF ) + else if ( getEnding() == LineEnding::CRLF ) return "\r\n"; return ""; @@ -90,16 +90,16 @@ void FLogger::printLogLine (const std::string& msg) switch ( getLevel() ) { - case Info: + case LogLevel::Info: return "INFO"; - case Warn: + case LogLevel::Warn: return "WARNING"; - case Error: + case LogLevel::Error: return "ERROR"; - case Debug: + case LogLevel::Debug: return "DEBUG"; } diff --git a/src/fmouse.cpp b/src/fmouse.cpp index f4f13951..d1d683c5 100644 --- a/src/fmouse.cpp +++ b/src/fmouse.cpp @@ -64,42 +64,42 @@ const FPoint& FMouseData::getPos() const //---------------------------------------------------------------------- bool FMouseData::isLeftButtonPressed() const { - return bool(getButtonState().left_button == Pressed); + return bool(getButtonState().left_button == State::Pressed); } //---------------------------------------------------------------------- bool FMouseData::isLeftButtonReleased() const { - return bool(getButtonState().left_button == Released); + return bool(getButtonState().left_button == State::Released); } //---------------------------------------------------------------------- bool FMouseData::isLeftButtonDoubleClick() const { - return bool(getButtonState().left_button == DoubleClick); + return bool(getButtonState().left_button == State::DoubleClick); } //---------------------------------------------------------------------- bool FMouseData::isRightButtonPressed() const { - return bool(getButtonState().right_button == Pressed); + return bool(getButtonState().right_button == State::Pressed); } //---------------------------------------------------------------------- bool FMouseData::isRightButtonReleased() const { - return bool(getButtonState().right_button == Released); + return bool(getButtonState().right_button == State::Released); } //---------------------------------------------------------------------- bool FMouseData::isMiddleButtonPressed() const { - return bool(getButtonState().middle_button == Pressed); + return bool(getButtonState().middle_button == State::Pressed); } //---------------------------------------------------------------------- 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() { - // Fill bit field with 0 - std::memset(&b_state, 0x00, sizeof(b_state)); + b_state.left_button = State::Undefined; + 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.type & GPM_DOUBLE ) - getButtonState().left_button = DoubleClick; + getButtonState().left_button = State::DoubleClick; else - getButtonState().left_button = Pressed; + getButtonState().left_button = State::Pressed; } if ( gpm_ev.buttons & GPM_B_MIDDLE ) - getButtonState().middle_button = Pressed; + getButtonState().middle_button = State::Pressed; if ( gpm_ev.buttons & GPM_B_RIGHT ) - getButtonState().right_button = Pressed; + getButtonState().right_button = State::Pressed; if ( gpm_ev.buttons & GPM_B_UP ) getButtonState().wheel_up = true; @@ -465,13 +472,13 @@ void FMouseGPM::interpretKeyDown() void FMouseGPM::interpretKeyUp() { if ( gpm_ev.buttons & GPM_B_LEFT ) - getButtonState().left_button = Released; + getButtonState().left_button = State::Released; if ( gpm_ev.buttons & GPM_B_MIDDLE ) - getButtonState().middle_button = Released; + getButtonState().middle_button = State::Released; 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) { if ( (btn & key_shift) == key_shift ) - getButtonState().shift_button = Pressed; + getButtonState().shift_button = true; if ( (btn & key_meta) == key_meta ) - getButtonState().meta_button = Pressed; + getButtonState().meta_button = true; 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()) ) { resetMousePressedTime(); - getButtonState().left_button = DoubleClick; + getButtonState().left_button = State::DoubleClick; } else { setMousePressedTime (time); // save click time - getButtonState().left_button = Pressed; + getButtonState().left_button = State::Pressed; } break; case button2_pressed: case button2_pressed_move: resetMousePressedTime(); - getButtonState().middle_button = Pressed; + getButtonState().middle_button = State::Pressed; break; case button3_pressed: case button3_pressed_move: resetMousePressedTime(); - getButtonState().right_button = Pressed; + getButtonState().right_button = State::Pressed; break; case all_buttons_released: @@ -681,17 +688,17 @@ void FMouseX11::setButtonState (const int btn, const struct timeval* time) { case button1_pressed: case button1_pressed_move: - getButtonState().left_button = Released; + getButtonState().left_button = State::Released; break; case button2_pressed: case button2_pressed_move: - getButtonState().middle_button = Released; + getButtonState().middle_button = State::Released; break; case button3_pressed: case button3_pressed_move: - getButtonState().right_button = Released; + getButtonState().right_button = State::Released; break; default: @@ -701,12 +708,12 @@ void FMouseX11::setButtonState (const int btn, const struct timeval* time) case button_up: resetMousePressedTime(); - getButtonState().wheel_up = Pressed; + getButtonState().wheel_up = true; break; case button_down: resetMousePressedTime(); - getButtonState().wheel_down = Pressed; + getButtonState().wheel_down = true; break; default: @@ -881,25 +888,25 @@ void FMouseSGR::setPressedButtonState ( const int btn && ! isDblclickTimeout(getMousePressedTime()) ) { resetMousePressedTime(); - getButtonState().left_button = DoubleClick; + getButtonState().left_button = State::DoubleClick; } else { setMousePressedTime (time); // save click time - getButtonState().left_button = Pressed; + getButtonState().left_button = State::Pressed; } break; case button2: case button2_move: resetMousePressedTime(); - getButtonState().middle_button = Pressed; + getButtonState().middle_button = State::Pressed; break; case button3: case button3_move: resetMousePressedTime(); - getButtonState().right_button = Pressed; + getButtonState().right_button = State::Pressed; break; case button_up: @@ -926,17 +933,17 @@ void FMouseSGR::setReleasedButtonState (const int btn) { case button1: case button1_move: - getButtonState().left_button = Released; + getButtonState().left_button = State::Released; break; case button2: case button2_move: - getButtonState().middle_button = Released; + getButtonState().middle_button = State::Released; break; case button3: case button3_move: - getButtonState().right_button = Released; + getButtonState().right_button = State::Released; break; default: @@ -1100,13 +1107,13 @@ void FMouseUrxvt::processEvent (struct timeval* time) void FMouseUrxvt::setKeyState (int btn) { if ( (btn & key_shift) == key_shift ) - getButtonState().shift_button = Pressed; + getButtonState().shift_button = true; if ( (btn & key_meta) == key_meta ) - getButtonState().meta_button = Pressed; + getButtonState().meta_button = true; 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()) ) { resetMousePressedTime(); - getButtonState().left_button = DoubleClick; + getButtonState().left_button = State::DoubleClick; } else { setMousePressedTime (time); // save click time - getButtonState().left_button = Pressed; + getButtonState().left_button = State::Pressed; } break; case button2_pressed: case button2_pressed_move: resetMousePressedTime(); - getButtonState().middle_button = Pressed; + getButtonState().middle_button = State::Pressed; break; case button3_pressed: case button3_pressed_move: resetMousePressedTime(); - getButtonState().right_button = Pressed; + getButtonState().right_button = State::Pressed; break; case all_buttons_released: @@ -1162,17 +1169,17 @@ void FMouseUrxvt::setButtonState (const int btn, const struct timeval* time) { case button1_pressed: case button1_pressed_move: - getButtonState().left_button = Released; + getButtonState().left_button = State::Released; break; case button2_pressed: case button2_pressed_move: - getButtonState().middle_button = Released; + getButtonState().middle_button = State::Released; break; case button3_pressed: case button3_pressed_move: - getButtonState().right_button = Released; + getButtonState().right_button = State::Released; break; default: @@ -1182,12 +1189,12 @@ void FMouseUrxvt::setButtonState (const int btn, const struct timeval* time) case button_up: resetMousePressedTime(); - getButtonState().wheel_up = Pressed; + getButtonState().wheel_up = true; break; case button_down: resetMousePressedTime(); - getButtonState().wheel_down = Pressed; + getButtonState().wheel_down = true; break; default: @@ -1206,12 +1213,12 @@ FMouseControl::FMouseControl() { #ifdef F_HAVE_LIBGPM if ( FTerm::isLinuxTerm() ) - mouse_protocol[FMouse::gpm].reset(FMouse::createMouseObject()); + mouse_protocol[FMouse::MouseType::gpm].reset(FMouse::createMouseObject()); #endif - mouse_protocol[FMouse::x11].reset(FMouse::createMouseObject()); - mouse_protocol[FMouse::sgr].reset(FMouse::createMouseObject()); - mouse_protocol[FMouse::urxvt].reset(FMouse::createMouseObject()); + mouse_protocol[FMouse::MouseType::x11].reset(FMouse::createMouseObject()); + mouse_protocol[FMouse::MouseType::sgr].reset(FMouse::createMouseObject()); + mouse_protocol[FMouse::MouseType::urxvt].reset(FMouse::createMouseObject()); } //---------------------------------------------------------------------- @@ -1234,7 +1241,7 @@ const FPoint& FMouseControl::getPos() //---------------------------------------------------------------------- void FMouseControl::clearEvent() { - FMouse::mouse_type mtype; + FMouse::MouseType mtype; do { @@ -1243,14 +1250,14 @@ void FMouseControl::clearEvent() if ( mouse_protocol[mtype] ) mouse_protocol[mtype]->clearEvent(); } - while ( mtype != FMouse::none ); + while ( mtype != FMouse::MouseType::none ); } //---------------------------------------------------------------------- #ifdef F_HAVE_LIBGPM 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(mouse); if ( gpm_mouse ) @@ -1264,13 +1271,13 @@ void FMouseControl::setStdinNo (int) //---------------------------------------------------------------------- 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) { - 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() ) 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(mouse); if ( gpm_mouse ) @@ -1500,7 +1507,7 @@ void FMouseControl::enable() #ifdef F_HAVE_LIBGPM if ( use_gpm_mouse ) { - auto mouse = mouse_protocol[FMouse::gpm].get(); + auto mouse = mouse_protocol[FMouse::MouseType::gpm].get(); auto gpm_mouse = static_cast(mouse); if ( gpm_mouse ) @@ -1518,7 +1525,7 @@ void FMouseControl::disable() #ifdef F_HAVE_LIBGPM if ( use_gpm_mouse ) { - auto mouse = mouse_protocol[FMouse::gpm].get(); + auto mouse = mouse_protocol[FMouse::MouseType::gpm].get(); auto gpm_mouse = static_cast(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) { auto mouse = mouse_protocol[mt].get(); @@ -1583,7 +1590,7 @@ bool FMouseControl::getGpmKeyPressed (bool pending) if ( mouse_protocol.empty() ) return false; - auto mouse = mouse_protocol[FMouse::gpm].get(); + auto mouse = mouse_protocol[FMouse::MouseType::gpm].get(); auto gpm_mouse = static_cast(mouse); if ( gpm_mouse ) @@ -1605,7 +1612,7 @@ void FMouseControl::drawPointer() if ( mouse_protocol.empty() ) return; - auto mouse = mouse_protocol[FMouse::gpm].get(); + auto mouse = mouse_protocol[FMouse::MouseType::gpm].get(); auto gpm_mouse = static_cast(mouse); if ( gpm_mouse ) @@ -1619,7 +1626,7 @@ void FMouseControl::drawPointer() // private methods of FMouseControl //---------------------------------------------------------------------- -FMouse::mouse_type FMouseControl::getMouseWithData() +FMouse::MouseType FMouseControl::getMouseWithData() { const auto& iter = \ 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 = \ 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; } //---------------------------------------------------------------------- diff --git a/src/fscrollbar.cpp b/src/fscrollbar.cpp index a6b7f2a6..0dd70e52 100644 --- a/src/fscrollbar.cpp +++ b/src/fscrollbar.cpp @@ -261,16 +261,16 @@ void FScrollbar::onMouseDown (FMouseEvent* ev) // Process left mouse button 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); if ( slider_click_pos > 0 ) - scroll_type = FScrollbar::scrollJump; + scroll_type = SType::scrollJump; } - if ( scroll_type == FScrollbar::scrollPageBackward - || scroll_type == FScrollbar::scrollPageForward ) + if ( scroll_type == SType::scrollPageBackward + || scroll_type == SType::scrollPageForward ) { if ( bar_orientation == fc::vertical ) slider_click_stop_pos = mouse_y - 2; @@ -285,8 +285,8 @@ void FScrollbar::onMouseDown (FMouseEvent* ev) else slider_click_stop_pos = -1; - if ( scroll_type >= FScrollbar::scrollStepBackward - && scroll_type <= FScrollbar::scrollPageForward ) + if ( scroll_type >= SType::scrollStepBackward + && scroll_type <= SType::scrollPageForward ) { processScroll(); threshold_reached = false; @@ -303,10 +303,10 @@ void FScrollbar::onMouseUp (FMouseEvent* ev) slider_click_pos = -1; - if ( scroll_type != FScrollbar::noScroll ) + if ( scroll_type != SType::noScroll ) { delOwnTimers(); - scroll_type = FScrollbar::noScroll; + scroll_type = SType::noScroll; } } @@ -327,9 +327,9 @@ void FScrollbar::onMouseMove (FMouseEvent* ev) } // 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{}; @@ -362,7 +362,7 @@ void FScrollbar::onMouseMove (FMouseEvent* ev) { delOwnTimers(); } - else if ( scroll_type != FScrollbar::scrollJump ) + else if ( scroll_type != SType::scrollJump ) { addTimer(repeat_time); } @@ -378,16 +378,16 @@ void FScrollbar::onWheel (FWheelEvent* ev) { const int wheel = ev->getWheel(); - if ( scroll_type != FScrollbar::noScroll ) + if ( scroll_type != SType::noScroll ) { delOwnTimers(); - scroll_type = FScrollbar::noScroll; + scroll_type = SType::noScroll; } if ( wheel == fc::WheelUp ) - scroll_type = FScrollbar::scrollWheelUp; + scroll_type = SType::scrollWheelUp; else if ( wheel == fc::WheelDown ) - scroll_type = FScrollbar::scrollWheelDown; + scroll_type = SType::scrollWheelDown; processScroll(); } @@ -395,7 +395,7 @@ void FScrollbar::onWheel (FWheelEvent* ev) //---------------------------------------------------------------------- void FScrollbar::onTimer (FTimerEvent*) { - if ( scroll_type == FScrollbar::noScroll ) + if ( scroll_type == SType::noScroll ) return; if ( ! threshold_reached ) @@ -406,20 +406,20 @@ void FScrollbar::onTimer (FTimerEvent*) } // Timer stop condition - if ( ( scroll_type == FScrollbar::scrollPageBackward + if ( ( scroll_type == SType::scrollPageBackward && slider_pos == slider_click_stop_pos ) - || ( scroll_type == FScrollbar::scrollPageForward + || ( scroll_type == SType::scrollPageForward && slider_pos == slider_click_stop_pos ) ) { const auto max_slider_pos = int(bar_length - slider_length); - if ( scroll_type == FScrollbar::scrollPageBackward + if ( scroll_type == SType::scrollPageBackward && slider_pos == 0 ) { jumpToClickPos(0); // Scroll to the start processScroll(); } - else if ( scroll_type == FScrollbar::scrollPageForward + else if ( scroll_type == SType::scrollPageForward && slider_pos == max_slider_pos ) { 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 ) { @@ -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 ) { - return FScrollbar::scrollStepBackward; // decrement button + return SType::scrollStepBackward; // decrement button } 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()) ) { - return FScrollbar::scrollPageForward; // after slider + return SType::scrollPageForward; // after slider } 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 ( x == 1 || x == 2 ) { - return FScrollbar::scrollStepBackward; // decrement button + return SType::scrollStepBackward; // decrement button } 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 ) { - return FScrollbar::scrollPageForward; // after slider + return SType::scrollPageForward; // after slider } 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 { if ( x == 1 ) { - return FScrollbar::scrollStepBackward; // decrement button + return SType::scrollStepBackward; // decrement button } 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()) ) { - return FScrollbar::scrollPageForward; // after slider + return SType::scrollPageForward; // after slider } 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); drawBar(); forceTerminalUpdate(); - scroll_type = FScrollbar::scrollJump; + scroll_type = SType::scrollJump; processScroll(); } } @@ -781,9 +781,9 @@ void FScrollbar::jumpToClickPos (int pos) void FScrollbar::avoidScrollOvershoot() { // Avoid overshoot - if ( ( scroll_type == FScrollbar::scrollPageBackward + if ( ( scroll_type == SType::scrollPageBackward && slider_pos < slider_click_stop_pos ) - || ( scroll_type == FScrollbar::scrollPageForward + || ( scroll_type == SType::scrollPageForward && slider_pos > slider_click_stop_pos ) ) { jumpToClickPos (slider_click_stop_pos); diff --git a/src/fscrollview.cpp b/src/fscrollview.cpp index 9c10d532..18d58ee6 100644 --- a/src/fscrollview.cpp +++ b/src/fscrollview.cpp @@ -865,19 +865,19 @@ void FScrollView::setViewportCursor() //---------------------------------------------------------------------- void FScrollView::cb_vbarChange (const FWidget*) { - FScrollbar::sType scrollType = vbar->getScrollType(); + FScrollbar::SType scrollType = vbar->getScrollType(); static constexpr int wheel_distance = 4; int distance{1}; - assert ( scrollType == FScrollbar::noScroll - || scrollType == FScrollbar::scrollJump - || scrollType == FScrollbar::scrollStepBackward - || scrollType == FScrollbar::scrollStepForward - || scrollType == FScrollbar::scrollPageBackward - || scrollType == FScrollbar::scrollPageForward - || scrollType == FScrollbar::scrollWheelUp - || scrollType == FScrollbar::scrollWheelDown ); + assert ( scrollType == FScrollbar::SType::noScroll + || scrollType == FScrollbar::SType::scrollJump + || scrollType == FScrollbar::SType::scrollStepBackward + || scrollType == FScrollbar::SType::scrollStepForward + || scrollType == FScrollbar::SType::scrollPageBackward + || scrollType == FScrollbar::SType::scrollPageForward + || scrollType == FScrollbar::SType::scrollWheelUp + || scrollType == FScrollbar::SType::scrollWheelDown ); - if ( scrollType >= FScrollbar::scrollStepBackward ) + if ( scrollType >= FScrollbar::SType::scrollStepBackward ) { update_scrollbar = true; } @@ -888,32 +888,32 @@ void FScrollView::cb_vbarChange (const FWidget*) switch ( scrollType ) { - case FScrollbar::noScroll: + case FScrollbar::SType::noScroll: break; - case FScrollbar::scrollPageBackward: + case FScrollbar::SType::scrollPageBackward: distance = int(getViewportHeight()); // fall through - case FScrollbar::scrollStepBackward: + case FScrollbar::SType::scrollStepBackward: scrollBy (0, -distance); break; - case FScrollbar::scrollPageForward: + case FScrollbar::SType::scrollPageForward: distance = int(getViewportHeight()); // fall through - case FScrollbar::scrollStepForward: + case FScrollbar::SType::scrollStepForward: scrollBy (0, distance); break; - case FScrollbar::scrollJump: + case FScrollbar::SType::scrollJump: scrollToY (1 + int(vbar->getValue())); break; - case FScrollbar::scrollWheelUp: + case FScrollbar::SType::scrollWheelUp: scrollBy (0, -wheel_distance); break; - case FScrollbar::scrollWheelDown: + case FScrollbar::SType::scrollWheelDown: scrollBy (0, wheel_distance); break; } @@ -924,19 +924,19 @@ void FScrollView::cb_vbarChange (const FWidget*) //---------------------------------------------------------------------- void FScrollView::cb_hbarChange (const FWidget*) { - FScrollbar::sType scrollType = hbar->getScrollType(); + FScrollbar::SType scrollType = hbar->getScrollType(); static constexpr int wheel_distance = 4; int distance{1}; - assert ( scrollType == FScrollbar::noScroll - || scrollType == FScrollbar::scrollJump - || scrollType == FScrollbar::scrollStepBackward - || scrollType == FScrollbar::scrollStepForward - || scrollType == FScrollbar::scrollPageBackward - || scrollType == FScrollbar::scrollPageForward - || scrollType == FScrollbar::scrollWheelUp - || scrollType == FScrollbar::scrollWheelDown ); + assert ( scrollType == FScrollbar::SType::noScroll + || scrollType == FScrollbar::SType::scrollJump + || scrollType == FScrollbar::SType::scrollStepBackward + || scrollType == FScrollbar::SType::scrollStepForward + || scrollType == FScrollbar::SType::scrollPageBackward + || scrollType == FScrollbar::SType::scrollPageForward + || scrollType == FScrollbar::SType::scrollWheelUp + || scrollType == FScrollbar::SType::scrollWheelDown ); - if ( scrollType >= FScrollbar::scrollStepBackward ) + if ( scrollType >= FScrollbar::SType::scrollStepBackward ) { update_scrollbar = true; } @@ -947,32 +947,32 @@ void FScrollView::cb_hbarChange (const FWidget*) switch ( scrollType ) { - case FScrollbar::noScroll: + case FScrollbar::SType::noScroll: break; - case FScrollbar::scrollPageBackward: + case FScrollbar::SType::scrollPageBackward: distance = int(getViewportWidth()); // fall through - case FScrollbar::scrollStepBackward: + case FScrollbar::SType::scrollStepBackward: scrollBy (-distance, 0); break; - case FScrollbar::scrollPageForward: + case FScrollbar::SType::scrollPageForward: distance = int(getViewportWidth()); // fall through - case FScrollbar::scrollStepForward: + case FScrollbar::SType::scrollStepForward: scrollBy (distance, 0); break; - case FScrollbar::scrollJump: + case FScrollbar::SType::scrollJump: scrollToX (1 + int(hbar->getValue())); break; - case FScrollbar::scrollWheelUp: + case FScrollbar::SType::scrollWheelUp: scrollBy (-wheel_distance, 0); break; - case FScrollbar::scrollWheelDown: + case FScrollbar::SType::scrollWheelDown: scrollBy (wheel_distance, 0); break; } diff --git a/src/fterm_functions.cpp b/src/fterm_functions.cpp index 22915191..27d521fd 100644 --- a/src/fterm_functions.cpp +++ b/src/fterm_functions.cpp @@ -460,7 +460,7 @@ std::size_t getColumnWidth (const FString& s, std::size_t pos) } catch (const std::out_of_range& ex) { - std::clog << FLog::Error + std::clog << FLog::LogLevel::Error << "Out of Range error: " << ex.what() << std::endl; } } diff --git a/src/ftermcap.cpp b/src/ftermcap.cpp index 863a354f..5d99d544 100644 --- a/src/ftermcap.cpp +++ b/src/ftermcap.cpp @@ -133,7 +133,7 @@ void FTermcap::termcapError (int status) { const auto& fterm_data = FTerm::getFTermData(); const char* termtype = fterm_data->getTermType(); - std::clog << FLog::Error + std::clog << FLog::LogLevel::Error << "Unknown terminal: \"" << termtype << "\". " << "Check the TERM environment variable. " << "Also make sure that the terminal " diff --git a/src/ftermfreebsd.cpp b/src/ftermfreebsd.cpp index 595cc62c..22ff4e85 100644 --- a/src/ftermfreebsd.cpp +++ b/src/ftermfreebsd.cpp @@ -172,7 +172,7 @@ void FTermFreeBSD::finish() //---------------------------------------------------------------------- void FTermFreeBSD::warnNotInitialized() { - std::clog << FLog::Warn + std::clog << FLog::LogLevel::Warn << "The FTermFreeBSD object has " << "not yet been initialized! " << "Please call the init() method first." diff --git a/src/ftermlinux.cpp b/src/ftermlinux.cpp index e36dc4e0..145c1412 100644 --- a/src/ftermlinux.cpp +++ b/src/ftermlinux.cpp @@ -192,7 +192,7 @@ void FTermLinux::init() } 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(); } } diff --git a/src/ftermopenbsd.cpp b/src/ftermopenbsd.cpp index d10ed9f6..9e4742ff 100644 --- a/src/ftermopenbsd.cpp +++ b/src/ftermopenbsd.cpp @@ -134,7 +134,7 @@ bool FTermOpenBSD::resetBeep() //---------------------------------------------------------------------- void FTermOpenBSD::warnNotInitialized() { - std::clog << FLog::Warn + std::clog << FLog::LogLevel::Warn << "The FTermOpenBSD object has " << "not yet been initialized! " << "Please call the init() method first." diff --git a/src/ftermxterminal.cpp b/src/ftermxterminal.cpp index 3899fcad..45cfc589 100644 --- a/src/ftermxterminal.cpp +++ b/src/ftermxterminal.cpp @@ -295,7 +295,7 @@ void FTermXTerminal::captureFontAndTitle() //---------------------------------------------------------------------- void FTermXTerminal::warnNotInitialized() const { - std::clog << FLog::Warn + std::clog << FLog::LogLevel::Warn << "The FTermXTerminal object has " << "not yet been initialized! " << "Please call the init() method first." diff --git a/src/ftextview.cpp b/src/ftextview.cpp index a7f1c7c2..756d40c6 100644 --- a/src/ftextview.cpp +++ b/src/ftextview.cpp @@ -761,51 +761,51 @@ void FTextView::changeOnResize() const //---------------------------------------------------------------------- void FTextView::cb_vbarChange (const FWidget*) { - const FScrollbar::sType scrollType = vbar->getScrollType(); + const FScrollbar::SType scrollType = vbar->getScrollType(); static constexpr int wheel_distance = 4; int distance{1}; - assert ( scrollType == FScrollbar::noScroll - || scrollType == FScrollbar::scrollJump - || scrollType == FScrollbar::scrollStepBackward - || scrollType == FScrollbar::scrollStepForward - || scrollType == FScrollbar::scrollPageBackward - || scrollType == FScrollbar::scrollPageForward - || scrollType == FScrollbar::scrollWheelUp - || scrollType == FScrollbar::scrollWheelDown ); + assert ( scrollType == FScrollbar::SType::noScroll + || scrollType == FScrollbar::SType::scrollJump + || scrollType == FScrollbar::SType::scrollStepBackward + || scrollType == FScrollbar::SType::scrollStepForward + || scrollType == FScrollbar::SType::scrollPageBackward + || scrollType == FScrollbar::SType::scrollPageForward + || scrollType == FScrollbar::SType::scrollWheelUp + || scrollType == FScrollbar::SType::scrollWheelDown ); - if ( scrollType >= FScrollbar::scrollStepBackward ) + if ( scrollType >= FScrollbar::SType::scrollStepBackward ) update_scrollbar = true; else update_scrollbar = false; switch ( scrollType ) { - case FScrollbar::noScroll: + case FScrollbar::SType::noScroll: break; - case FScrollbar::scrollPageBackward: + case FScrollbar::SType::scrollPageBackward: distance = int(getClientHeight()); // fall through - case FScrollbar::scrollStepBackward: + case FScrollbar::SType::scrollStepBackward: scrollBy (0, -distance); break; - case FScrollbar::scrollPageForward: + case FScrollbar::SType::scrollPageForward: distance = int(getClientHeight()); // fall through - case FScrollbar::scrollStepForward: + case FScrollbar::SType::scrollStepForward: scrollBy (0, distance); break; - case FScrollbar::scrollJump: + case FScrollbar::SType::scrollJump: scrollToY (vbar->getValue()); break; - case FScrollbar::scrollWheelUp: + case FScrollbar::SType::scrollWheelUp: scrollBy (0, -wheel_distance); break; - case FScrollbar::scrollWheelDown: + case FScrollbar::SType::scrollWheelDown: scrollBy (0, wheel_distance); break; } @@ -816,51 +816,51 @@ void FTextView::cb_vbarChange (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; int distance{1}; - assert ( scrollType == FScrollbar::noScroll - || scrollType == FScrollbar::scrollJump - || scrollType == FScrollbar::scrollStepBackward - || scrollType == FScrollbar::scrollStepForward - || scrollType == FScrollbar::scrollPageBackward - || scrollType == FScrollbar::scrollPageForward - || scrollType == FScrollbar::scrollWheelUp - || scrollType == FScrollbar::scrollWheelDown ); + assert ( scrollType == FScrollbar::SType::noScroll + || scrollType == FScrollbar::SType::scrollJump + || scrollType == FScrollbar::SType::scrollStepBackward + || scrollType == FScrollbar::SType::scrollStepForward + || scrollType == FScrollbar::SType::scrollPageBackward + || scrollType == FScrollbar::SType::scrollPageForward + || scrollType == FScrollbar::SType::scrollWheelUp + || scrollType == FScrollbar::SType::scrollWheelDown ); - if ( scrollType >= FScrollbar::scrollStepBackward ) + if ( scrollType >= FScrollbar::SType::scrollStepBackward ) update_scrollbar = true; else update_scrollbar = false; switch ( scrollType ) { - case FScrollbar::noScroll: + case FScrollbar::SType::noScroll: break; - case FScrollbar::scrollPageBackward: + case FScrollbar::SType::scrollPageBackward: distance = int(getClientWidth()); // fall through - case FScrollbar::scrollStepBackward: + case FScrollbar::SType::scrollStepBackward: scrollBy (-distance, 0); break; - case FScrollbar::scrollPageForward: + case FScrollbar::SType::scrollPageForward: distance = int(getClientWidth()); // fall through - case FScrollbar::scrollStepForward: + case FScrollbar::SType::scrollStepForward: scrollBy (distance, 0); break; - case FScrollbar::scrollJump: + case FScrollbar::SType::scrollJump: scrollToX (hbar->getValue()); break; - case FScrollbar::scrollWheelUp: + case FScrollbar::SType::scrollWheelUp: scrollBy (-wheel_distance, 0); break; - case FScrollbar::scrollWheelDown: + case FScrollbar::SType::scrollWheelDown: scrollBy (wheel_distance, 0); break; } diff --git a/src/include/final/flog.h b/src/include/final/flog.h index 61cab79f..b88b8b75 100644 --- a/src/include/final/flog.h +++ b/src/include/final/flog.h @@ -64,12 +64,12 @@ class FLog : public std::stringbuf using IOManip = std::ostream& (*)(std::ostream&); // Enumerations - enum LogLevel + enum class LogLevel { Info, Warn, Error, Debug }; - enum LineEnding + enum class LineEnding { LF, CR, CRLF }; @@ -106,8 +106,8 @@ class FLog : public std::stringbuf private: // Data member - LogLevel level{Info}; - LineEnding end_of_line{CRLF}; + LogLevel level{LogLevel::Info}; + LineEnding end_of_line{LineEnding::CRLF}; std::mutex mut{}; FLogPrint current_log{std::bind(&FLog::info, this, std::placeholders::_1)}; std::ostream stream{this}; diff --git a/src/include/final/flogger.h b/src/include/final/flogger.h index cb722877..a258b232 100644 --- a/src/include/final/flogger.h +++ b/src/include/final/flogger.h @@ -104,7 +104,7 @@ inline FString FLogger::getClassName() const inline void FLogger::info (const std::string& msg) { std::lock_guard lock_guard(getMutex()); - setLevel() = Info; + setLevel() = LogLevel::Info; printLogLine (msg); } @@ -112,7 +112,7 @@ inline void FLogger::info (const std::string& msg) inline void FLogger::warn (const std::string& msg) { std::lock_guard lock_guard(getMutex()); - setLevel() = Warn; + setLevel() = LogLevel::Warn; printLogLine (msg); } @@ -120,7 +120,7 @@ inline void FLogger::warn (const std::string& msg) inline void FLogger::error (const std::string& msg) { std::lock_guard lock_guard(getMutex()); - setLevel() = Error; + setLevel() = LogLevel::Error; printLogLine (msg); } @@ -128,7 +128,7 @@ inline void FLogger::error (const std::string& msg) inline void FLogger::debug (const std::string& msg) { std::lock_guard lock_guard(getMutex()); - setLevel() = Debug; + setLevel() = LogLevel::Debug; printLogLine (msg); } diff --git a/src/include/final/fmessagebox.h b/src/include/final/fmessagebox.h index e199b34e..4ec19543 100644 --- a/src/include/final/fmessagebox.h +++ b/src/include/final/fmessagebox.h @@ -171,7 +171,7 @@ class FMessageBox : public FDialog std::size_t max_line_width{0}; FColor emphasis_color{getColorTheme()->dialog_emphasis_fg}; ButtonType result_code{ButtonType::Reject}; - FButtonsDigit button_digit{ButtonType::Reject}; + FButtonsDigit button_digit{}; std::size_t num_buttons{0}; std::size_t text_num_lines{0}; bool center_text{false}; diff --git a/src/include/final/fmouse.h b/src/include/final/fmouse.h index 1891e13a..48017c13 100644 --- a/src/include/final/fmouse.h +++ b/src/include/final/fmouse.h @@ -122,22 +122,8 @@ class FMouseData void clearButtonState(); 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 - enum states + enum class State : uChar { Undefined = 0, Pressed = 1, @@ -145,6 +131,19 @@ class FMouseData 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 FMouseButton& getButtonState(); const FMouseButton& getButtonState() const; @@ -167,7 +166,7 @@ class FMouse : public FMouseData { public: // Enumeration - enum mouse_type + enum class MouseType { none = 0, gpm = 1, @@ -537,7 +536,7 @@ class FMouseControl // Methods void enable(); void disable(); - virtual void setRawData ( FMouse::mouse_type + virtual void setRawData ( FMouse::MouseType , FKeyboard::keybuffer& ); virtual void processEvent (struct timeval* time); void processQueuedInput(); @@ -548,11 +547,11 @@ class FMouseControl // Using-declaration using FMousePtr = std::unique_ptr; using FMouseDataPtr = std::unique_ptr; - using FMouseProtocol = std::map; + using FMouseProtocol = std::map; // Accessor - FMouse::mouse_type getMouseWithData(); - FMouse::mouse_type getMouseWithEvent(); + FMouse::MouseType getMouseWithData(); + FMouse::MouseType getMouseWithEvent(); void xtermMouse (bool) const; void enableXTermMouse() const; void disableXTermMouse() const; diff --git a/src/include/final/fscrollbar.h b/src/include/final/fscrollbar.h index 6e394fb5..b615ef9a 100644 --- a/src/include/final/fscrollbar.h +++ b/src/include/final/fscrollbar.h @@ -74,7 +74,7 @@ class FScrollbar : public FWidget using FWidget::setGeometry; // Enumeration - enum sType + enum class SType { noScroll = 0, scrollJump = 1, @@ -102,7 +102,7 @@ class FScrollbar : public FWidget // Accessors FString getClassName() const override; int getValue() const; - sType getScrollType() const; + SType getScrollType() const; // Mutators void setMinimum (int); @@ -138,9 +138,9 @@ class FScrollbar : public FWidget void drawHorizontalBar(); void drawHorizontalBackgroundColumn(); void drawButtons(); - sType getClickedScrollType (int, int) const; - sType getVerticalClickedScrollType (int) const; - sType getHorizontalClickedScrollType (int) const; + SType getClickedScrollType (int, int) const; + SType getVerticalClickedScrollType (int) const; + SType getHorizontalClickedScrollType (int) const; int getSliderClickPos (int, int) const; void jumpToClickPos (int, int); void jumpToClickPos (int); @@ -149,7 +149,7 @@ class FScrollbar : public FWidget void changeOnResize(); // Data members - sType scroll_type{FScrollbar::noScroll}; + SType scroll_type{SType::noScroll}; bool threshold_reached{false}; int threshold_time{500}; int repeat_time{80}; @@ -211,7 +211,7 @@ inline int FScrollbar::getValue() const { return val; } //---------------------------------------------------------------------- -inline FScrollbar::sType FScrollbar::getScrollType() const +inline FScrollbar::SType FScrollbar::getScrollType() const { return scroll_type; } } // namespace finalcut diff --git a/src/include/final/ftypes.h b/src/include/final/ftypes.h index 4bbba54d..407e984a 100644 --- a/src/include/final/ftypes.h +++ b/src/include/final/ftypes.h @@ -43,7 +43,7 @@ #define null nullptr #define badAllocOutput(object_name) \ - std::clog << FLog::Error \ + std::clog << FLog::LogLevel::Error \ << __FILE__ << ":" << __LINE__ \ << ": Not enough memory to alloc " \ << (object_name) \ diff --git a/test/flogger-test.cpp b/test/flogger-test.cpp index c3aee10c..33f0e4bd 100644 --- a/test/flogger-test.cpp +++ b/test/flogger-test.cpp @@ -149,11 +149,11 @@ void FLoggerTest::defaultObjectTest() CPPUNIT_ASSERT ( buf.str() == "[INFO] Hello, World!\n\r\n" ); 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" ); 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" ); buf.str(""); // Clear buffer @@ -161,7 +161,7 @@ void FLoggerTest::defaultObjectTest() CPPUNIT_ASSERT ( buf.str() == "[WARNING] Hello, World!\r\n" ); 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" ); buf.str(""); // Clear buffer @@ -169,7 +169,7 @@ void FLoggerTest::defaultObjectTest() CPPUNIT_ASSERT ( buf.str() == "[ERROR] Hello, World!\r\n" ); 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" ); buf.str(""); // Clear buffer @@ -206,17 +206,17 @@ void FLoggerTest::lineEndingTest() CPPUNIT_ASSERT ( buf.str() == "[INFO] Line endings\r\n" ); buf.str(""); // Clear buffer - log.setLineEnding(finalcut::FLog::LF); + log.setLineEnding(finalcut::FLog::LineEnding::LF); log.warn("Line endings"); CPPUNIT_ASSERT ( buf.str() == "[WARNING] Line endings\n" ); buf.str(""); // Clear buffer - log.setLineEnding(finalcut::FLog::CR); + log.setLineEnding(finalcut::FLog::LineEnding::CR); log.error("Line endings"); CPPUNIT_ASSERT ( buf.str() == "[ERROR] Line endings\r" ); buf.str(""); // Clear buffer - log.setLineEnding(finalcut::FLog::CRLF); + log.setLineEnding(finalcut::FLog::LineEnding::CRLF); log.debug("Line endings"); CPPUNIT_ASSERT ( buf.str() == "[DEBUG] Line endings\r\n" ); buf.str(""); // Clear buffer @@ -258,17 +258,17 @@ void FLoggerTest::fileTest() { finalcut::FLogger log{}; std::ofstream file_stream(filename, std::ofstream::out); - log.setLineEnding (finalcut::FLog::LF); + log.setLineEnding (finalcut::FLog::LineEnding::LF); log.setOutputStream(file_stream); log.info("test1"); log.warn("test2"); log.error("test3"); log.debug("test4"); - log << finalcut::FLog::Info << "streaming test1"; - log << finalcut::FLog::Warn << "streaming test2"; - log << finalcut::FLog::Error << "streaming test3"; - log << finalcut::FLog::Debug << "streaming test4" << std::flush; + log << finalcut::FLog::LogLevel::Info << "streaming test1"; + log << finalcut::FLog::LogLevel::Warn << "streaming test2"; + log << finalcut::FLog::LogLevel::Error << "streaming test3"; + log << finalcut::FLog::LogLevel::Debug << "streaming test4" << std::flush; if ( file_stream.is_open() ) file_stream.close(); @@ -308,7 +308,7 @@ void FLoggerTest::fileTest() { finalcut::FLogger log{}; log.setOutputStream(std::cerr); - log.setLineEnding (finalcut::FLog::LF); + log.setLineEnding (finalcut::FLog::LineEnding::LF); log.error("Cannot delete the test.log file"); } } @@ -347,16 +347,16 @@ void FLoggerTest::applicationObjectTest() CPPUNIT_ASSERT ( buf.str() == "[INFO] test5\r\n" ); 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" ); buf.str(""); // Clear buffer // 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" ); 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" ); buf.str(""); // Clear buffer @@ -382,11 +382,11 @@ void FLoggerTest::applicationObjectTest() buf.str(""); // Clear buffer // 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" ); 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" ); buf.str(""); // Clear buffer diff --git a/test/fmouse-test.cpp b/test/fmouse-test.cpp index c6002b75..00b8254a 100644 --- a/test/fmouse-test.cpp +++ b/test/fmouse-test.cpp @@ -1267,7 +1267,7 @@ void FMouseTest::mouseControlTest() finalcut::FKeyboard::keybuffer rawdata1 = \ { 0x1b, '[', 'M', 0x20, 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.hasUnprocessedInput() ); @@ -1292,7 +1292,7 @@ void FMouseTest::mouseControlTest() CPPUNIT_ASSERT ( ! mouse_control.isMoved() ); CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() ); - mouse_control.setRawData (finalcut::FMouse::x11, rawdata1); + mouse_control.setRawData (finalcut::FMouse::MouseType::x11, rawdata1); mouse_control.processEvent (&tv); CPPUNIT_ASSERT ( ! mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! mouse_control.isLeftButtonPressed() ); @@ -1303,7 +1303,7 @@ void FMouseTest::mouseControlTest() finalcut::FKeyboard::keybuffer rawdata2 = \ { 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.hasUnprocessedInput() ); finalcut::FObject::getCurrentTime(&tv); @@ -1325,7 +1325,7 @@ void FMouseTest::mouseControlTest() CPPUNIT_ASSERT ( ! mouse_control.isWheelDown() ); CPPUNIT_ASSERT ( ! mouse_control.isMoved() ); - mouse_control.setRawData (finalcut::FMouse::sgr, rawdata2); + mouse_control.setRawData (finalcut::FMouse::MouseType::sgr, rawdata2); mouse_control.processEvent (&tv); CPPUNIT_ASSERT ( ! mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! mouse_control.isMiddleButtonPressed() ); @@ -1334,7 +1334,7 @@ void FMouseTest::mouseControlTest() // Right mouse button on a urxvt mouse finalcut::FKeyboard::keybuffer rawdata3 = { 0x1b, '[', '3', '4', ';', '3', ';', '3', '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.hasUnprocessedInput() ); finalcut::FObject::getCurrentTime(&tv); @@ -1356,7 +1356,7 @@ void FMouseTest::mouseControlTest() CPPUNIT_ASSERT ( ! mouse_control.isWheelDown() ); CPPUNIT_ASSERT ( ! mouse_control.isMoved() ); - mouse_control.setRawData (finalcut::FMouse::urxvt, rawdata3); + mouse_control.setRawData (finalcut::FMouse::MouseType::urxvt, rawdata3); mouse_control.processEvent (&tv); CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(3, 4) ); CPPUNIT_ASSERT ( ! mouse_control.hasUnprocessedInput() ); @@ -1367,7 +1367,7 @@ void FMouseTest::mouseControlTest() finalcut::FKeyboard::keybuffer rawdata4 = \ { 0x1b, '[', 'M', 0x60, 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.hasUnprocessedInput() ); finalcut::FObject::getCurrentTime(&tv); @@ -1389,7 +1389,7 @@ void FMouseTest::mouseControlTest() CPPUNIT_ASSERT ( ! mouse_control.isWheelDown() ); CPPUNIT_ASSERT ( ! mouse_control.isMoved() ); - mouse_control.setRawData (finalcut::FMouse::x11, rawdata4); + mouse_control.setRawData (finalcut::FMouse::MouseType::x11, rawdata4); mouse_control.processEvent (&tv); CPPUNIT_ASSERT ( ! mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( mouse_control.isWheelDown() ); @@ -1399,7 +1399,7 @@ void FMouseTest::mouseControlTest() { 0x1b, '[', '<', '0', ';', '1', ';', '2', 'M' , 0x1b, '[', '<', '3', '2', ';', '2', ';', '3', '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.hasUnprocessedInput() ); finalcut::FObject::getCurrentTime(&tv); @@ -1421,12 +1421,12 @@ void FMouseTest::mouseControlTest() CPPUNIT_ASSERT ( ! mouse_control.isWheelDown() ); CPPUNIT_ASSERT ( ! mouse_control.isMoved() ); - mouse_control.setRawData (finalcut::FMouse::sgr, rawdata5); + mouse_control.setRawData (finalcut::FMouse::MouseType::sgr, rawdata5); mouse_control.processEvent (&tv); CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(2, 3) ); CPPUNIT_ASSERT ( mouse_control.isMoved() ); - mouse_control.setRawData (finalcut::FMouse::sgr, rawdata5); + mouse_control.setRawData (finalcut::FMouse::MouseType::sgr, rawdata5); mouse_control.processEvent (&tv); CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(3, 4) ); CPPUNIT_ASSERT ( ! mouse_control.isMoved() );