mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-16 01:43:21 +00:00
feat(viewport): horizontal scroll with mouse wheel (#761)
Add support for the events of a horizontal mouse wheel and when holding shift while using the regular mouse wheel now scrolls the screen left and right.
This commit is contained in:
+20
-6
@@ -466,16 +466,30 @@ func (m Model) updateAsModel(msg tea.Msg) (Model, tea.Cmd) {
|
|||||||
}
|
}
|
||||||
switch msg.Button { //nolint:exhaustive
|
switch msg.Button { //nolint:exhaustive
|
||||||
case tea.MouseButtonWheelUp:
|
case tea.MouseButtonWheelUp:
|
||||||
lines := m.ScrollUp(m.MouseWheelDelta)
|
if msg.Shift {
|
||||||
if m.HighPerformanceRendering {
|
// Note that not every terminal emulator sends the shift event for mouse actions by default (looking at you Konsole)
|
||||||
cmd = ViewUp(m, lines)
|
m.ScrollLeft(m.horizontalStep)
|
||||||
|
} else {
|
||||||
|
lines := m.ScrollUp(m.MouseWheelDelta)
|
||||||
|
if m.HighPerformanceRendering {
|
||||||
|
cmd = ViewUp(m, lines)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case tea.MouseButtonWheelDown:
|
case tea.MouseButtonWheelDown:
|
||||||
lines := m.ScrollDown(m.MouseWheelDelta)
|
if msg.Shift {
|
||||||
if m.HighPerformanceRendering {
|
m.ScrollRight(m.horizontalStep)
|
||||||
cmd = ViewDown(m, lines)
|
} else {
|
||||||
|
lines := m.ScrollDown(m.MouseWheelDelta)
|
||||||
|
if m.HighPerformanceRendering {
|
||||||
|
cmd = ViewDown(m, lines)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// Note that not every terminal emulator sends the horizontal wheel events by default (looking at you Konsole)
|
||||||
|
case tea.MouseButtonWheelLeft:
|
||||||
|
m.ScrollLeft(m.horizontalStep)
|
||||||
|
case tea.MouseButtonWheelRight:
|
||||||
|
m.ScrollRight(m.horizontalStep)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user