1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:57:43 +00:00

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.
This commit is contained in:
Benoît Lormeau 2020-06-29 22:28:18 +02:00 committed by Andreas Kling
parent f20becf71b
commit 310fbe48e5
3 changed files with 29 additions and 2 deletions

View file

@ -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;