From c9196e5407adbfec28c0f76ff51933dbdf3ee186 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Tue, 23 Jun 2020 12:00:17 -0400 Subject: [PATCH] Add basic mouse wheel support to viewport --- viewport/viewport.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/viewport/viewport.go b/viewport/viewport.go index 84a6352..1dcf6e3 100644 --- a/viewport/viewport.go +++ b/viewport/viewport.go @@ -344,6 +344,22 @@ func Update(msg tea.Msg, m Model) (Model, tea.Cmd) { cmd = LineUp(m, lines) } } + + case tea.MouseMsg: + switch msg.Button { + + case tea.MouseWheelUp: + lines := m.ViewUp() + if m.HighPerformanceRendering { + cmd = ViewUp(m, lines) + } + + case tea.MouseWheelDown: + lines := m.ViewDown() + if m.HighPerformanceRendering { + cmd = ViewDown(m, lines) + } + } } return m, cmd