Skip to content

Commit

Permalink
Terminal: Allow scrolling through terminal history with the mouse wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Aug 20, 2019
1 parent dc3c6be commit c106ec4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Applications/Terminal/TerminalWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,19 @@ void TerminalWidget::mouseup_event(GMouseEvent& event)
GClipboard::the().set_data(selected_text());
}

void TerminalWidget::mousewheel_event(GMouseEvent& event)
{
if (!is_scrollable())
return;
m_scrollbar->set_value(m_scrollbar->value() + event.wheel_delta());
GFrame::mousewheel_event(event);
}

bool TerminalWidget::is_scrollable() const
{
return m_scrollbar->is_scrollable();
}

String TerminalWidget::selected_text() const
{
StringBuilder builder;
Expand Down
3 changes: 3 additions & 0 deletions Applications/Terminal/TerminalWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class TerminalWidget final : public GFrame
VT::Position normalized_selection_start() const;
VT::Position normalized_selection_end() const;

bool is_scrollable() const;

private:
// ^GWidget
virtual void event(CEvent&) override;
Expand All @@ -48,6 +50,7 @@ class TerminalWidget final : public GFrame
virtual void mousedown_event(GMouseEvent&) override;
virtual void mousemove_event(GMouseEvent&) override;
virtual void mouseup_event(GMouseEvent&) override;
virtual void mousewheel_event(GMouseEvent&) override;

// ^TerminalClient
virtual void beep() override;
Expand Down

0 comments on commit c106ec4

Please sign in to comment.