mirror of
https://github.com/Maks1mS/bubbles.git
synced 2025-01-11 22:41:03 +03:00
Tidy up the key case switch in viewport
This commit is contained in:
parent
b130d96434
commit
88469a499e
@ -7,6 +7,10 @@ import (
|
|||||||
tea "github.com/charmbracelet/bubbletea"
|
tea "github.com/charmbracelet/bubbletea"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
spacebar = " "
|
||||||
|
)
|
||||||
|
|
||||||
// MODEL
|
// MODEL
|
||||||
|
|
||||||
type Model struct {
|
type Model struct {
|
||||||
@ -292,20 +296,14 @@ func Update(msg tea.Msg, m Model) (Model, tea.Cmd) {
|
|||||||
case tea.KeyMsg:
|
case tea.KeyMsg:
|
||||||
switch msg.String() {
|
switch msg.String() {
|
||||||
// Down one page
|
// Down one page
|
||||||
case "pgdown":
|
case "pgdown", spacebar, "f":
|
||||||
fallthrough
|
|
||||||
case " ": // spacebar
|
|
||||||
fallthrough
|
|
||||||
case "f":
|
|
||||||
lines := m.ViewDown()
|
lines := m.ViewDown()
|
||||||
if m.HighPerformanceRendering {
|
if m.HighPerformanceRendering {
|
||||||
cmd = ViewDown(m, lines)
|
cmd = ViewDown(m, lines)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Up one page
|
// Up one page
|
||||||
case "pgup":
|
case "pgup", "b":
|
||||||
fallthrough
|
|
||||||
case "b":
|
|
||||||
lines := m.ViewUp()
|
lines := m.ViewUp()
|
||||||
if m.HighPerformanceRendering {
|
if m.HighPerformanceRendering {
|
||||||
cmd = ViewUp(m, lines)
|
cmd = ViewUp(m, lines)
|
||||||
@ -326,18 +324,14 @@ func Update(msg tea.Msg, m Model) (Model, tea.Cmd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Down one line
|
// Down one line
|
||||||
case "down":
|
case "down", "j":
|
||||||
fallthrough
|
|
||||||
case "j":
|
|
||||||
lines := m.LineDown(1)
|
lines := m.LineDown(1)
|
||||||
if m.HighPerformanceRendering {
|
if m.HighPerformanceRendering {
|
||||||
cmd = ViewDown(m, lines)
|
cmd = ViewDown(m, lines)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Up one line
|
// Up one line
|
||||||
case "up":
|
case "up", "k":
|
||||||
fallthrough
|
|
||||||
case "k":
|
|
||||||
lines := m.LineUp(1)
|
lines := m.LineUp(1)
|
||||||
if m.HighPerformanceRendering {
|
if m.HighPerformanceRendering {
|
||||||
cmd = ViewUp(m, lines)
|
cmd = ViewUp(m, lines)
|
||||||
|
Loading…
Reference in New Issue
Block a user