diff options
author | Benoît Lormeau <blormeau@outlook.com> | 2020-06-29 22:28:18 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-30 18:24:00 +0200 |
commit | 310fbe48e51058c58bb4e76d23ccea964b02fb59 (patch) | |
tree | 3df5633aa3eae34d342c1f29c3bcd7fa6233fd26 /Libraries/LibVT | |
parent | f20becf71b89e1caac65a06d69c57362847c1c94 (diff) | |
download | serenity-310fbe48e51058c58bb4e76d23ccea964b02fb59.zip |
LibVT/Terminal: add a scroll length to the TerminalWidget
The scroll length is the number of lines by which the terminal will go
up/down when scrolling the mouse wheel once.
Diffstat (limited to 'Libraries/LibVT')
-rw-r--r-- | Libraries/LibVT/TerminalWidget.cpp | 13 | ||||
-rw-r--r-- | Libraries/LibVT/TerminalWidget.h | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/Libraries/LibVT/TerminalWidget.cpp b/Libraries/LibVT/TerminalWidget.cpp index 672460664e..8b30db01ca 100644 --- a/Libraries/LibVT/TerminalWidget.cpp +++ b/Libraries/LibVT/TerminalWidget.cpp @@ -105,6 +105,7 @@ TerminalWidget::TerminalWidget(int ptm_fd, bool automatic_size_policy, RefPtr<Co m_scrollbar->on_change = [this](int) { force_repaint(); }; + set_scroll_length(m_config->read_num_entry("Window", "ScrollLength", 1)); dbgprintf("Terminal: Load config file from %s\n", m_config->file_name().characters()); m_cursor_blink_timer->set_interval(m_config->read_num_entry("Text", @@ -672,7 +673,7 @@ void TerminalWidget::mousewheel_event(GUI::MouseEvent& event) { if (!is_scrollable()) return; - m_scrollbar->set_value(m_scrollbar->value() + event.wheel_delta()); + m_scrollbar->set_value(m_scrollbar->value() + event.wheel_delta() * scroll_length()); GUI::Frame::mousewheel_event(event); } @@ -681,6 +682,16 @@ bool TerminalWidget::is_scrollable() const return m_scrollbar->is_scrollable(); } +int TerminalWidget::scroll_length() const +{ + return m_scrollbar->step(); +} + +void TerminalWidget::set_scroll_length(int length) +{ + m_scrollbar->set_step(length); +} + String TerminalWidget::selected_text() const { StringBuilder builder; diff --git a/Libraries/LibVT/TerminalWidget.h b/Libraries/LibVT/TerminalWidget.h index 6be5328079..af6b91d1bf 100644 --- a/Libraries/LibVT/TerminalWidget.h +++ b/Libraries/LibVT/TerminalWidget.h @@ -74,6 +74,8 @@ public: VT::Position normalized_selection_end() const; bool is_scrollable() const; + int scroll_length() const; + void set_scroll_length(int); GUI::Action& copy_action() { return *m_copy_action; } GUI::Action& paste_action() { return *m_paste_action; } |