mirror of
https://github.com/Maks1mS/bubbles.git
synced 2025-03-13 12:33:43 +03:00
Remove redundant viewport commands
This commit is contained in:
parent
2f909886c1
commit
dbb1d93970
@ -218,9 +218,9 @@ func Sync(m Model) tea.Cmd {
|
||||
)
|
||||
}
|
||||
|
||||
// ViewDown is a high performance command that moves the viewport up by one
|
||||
// viewport height. Use Model.ViewDown to get the lines that should be
|
||||
// rendered. For example:
|
||||
// ViewDown is a high performance command that moves the viewport up by a given
|
||||
// numer of lines. Use Model.ViewDown to get the lines that should be rendered.
|
||||
// For example:
|
||||
//
|
||||
// lines := model.ViewDown(1)
|
||||
// cmd := ViewDown(m, lines)
|
||||
@ -232,8 +232,8 @@ func ViewDown(m Model, lines []string) tea.Cmd {
|
||||
return tea.ScrollDown(lines, m.YPosition, m.YPosition+m.Height)
|
||||
}
|
||||
|
||||
// ViewUp is a high performance command the moves the viewport down by one
|
||||
// viewport height. Use Model.ViewDown to get the lines that should be
|
||||
// ViewUp is a high performance command the moves the viewport down by a given
|
||||
// number of lines height. Use Model.ViewDown to get the lines that should be
|
||||
// rendered.
|
||||
func ViewUp(m Model, lines []string) tea.Cmd {
|
||||
if len(lines) == 0 {
|
||||
@ -242,46 +242,6 @@ func ViewUp(m Model, lines []string) tea.Cmd {
|
||||
return tea.ScrollUp(lines, m.YPosition, m.YPosition+m.Height)
|
||||
}
|
||||
|
||||
// HalfViewDown is a high performance command the moves the viewport down by
|
||||
// half of the height of the viewport. Use Model.HalfViewDown to get the lines
|
||||
// that should be rendered.
|
||||
func HalfViewDown(m Model, lines []string) tea.Cmd {
|
||||
if len(lines) == 0 {
|
||||
return nil
|
||||
}
|
||||
return tea.ScrollDown(lines, m.YPosition, m.YPosition+m.Height)
|
||||
}
|
||||
|
||||
// HalfViewUp is a high performance command the moves the viewport up by
|
||||
// half of the height of the viewport. Use Model.HalfViewUp to get the lines
|
||||
// that should be rendered.
|
||||
func HalfViewUp(m Model, lines []string) tea.Cmd {
|
||||
if len(lines) == 0 {
|
||||
return nil
|
||||
}
|
||||
return tea.ScrollUp(lines, m.YPosition, m.YPosition+m.Height)
|
||||
}
|
||||
|
||||
// LineDown is a high performance command the moves the viewport down by
|
||||
// a given number of lines. Use Model.LineDown to get the lines that should be
|
||||
// rendered.
|
||||
func LineDown(m Model, lines []string) tea.Cmd {
|
||||
if len(lines) == 0 {
|
||||
return nil
|
||||
}
|
||||
return tea.ScrollDown(lines, m.YPosition, m.YPosition+m.Height)
|
||||
}
|
||||
|
||||
// LineDown is a high performance command the moves the viewport up by a given
|
||||
// number of lines. Use Model.LineDown to get the lines that should be
|
||||
// rendered.
|
||||
func LineUp(m Model, lines []string) tea.Cmd {
|
||||
if len(lines) == 0 {
|
||||
return nil
|
||||
}
|
||||
return tea.ScrollUp(lines, m.YPosition, m.YPosition+m.Height)
|
||||
}
|
||||
|
||||
// UPDATE
|
||||
|
||||
// Update runs the update loop with default keybindings similar to popular
|
||||
@ -318,14 +278,14 @@ func Update(msg tea.Msg, m Model) (Model, tea.Cmd) {
|
||||
case "d":
|
||||
lines := m.HalfViewDown()
|
||||
if m.HighPerformanceRendering {
|
||||
cmd = HalfViewDown(m, lines)
|
||||
cmd = ViewDown(m, lines)
|
||||
}
|
||||
|
||||
// Up half page
|
||||
case "u":
|
||||
lines := m.HalfViewUp()
|
||||
if m.HighPerformanceRendering {
|
||||
cmd = HalfViewUp(m, lines)
|
||||
cmd = ViewUp(m, lines)
|
||||
}
|
||||
|
||||
// Down one line
|
||||
@ -334,7 +294,7 @@ func Update(msg tea.Msg, m Model) (Model, tea.Cmd) {
|
||||
case "j":
|
||||
lines := m.LineDown(1)
|
||||
if m.HighPerformanceRendering {
|
||||
cmd = LineDown(m, lines)
|
||||
cmd = ViewDown(m, lines)
|
||||
}
|
||||
|
||||
// Up one line
|
||||
@ -343,7 +303,7 @@ func Update(msg tea.Msg, m Model) (Model, tea.Cmd) {
|
||||
case "k":
|
||||
lines := m.LineUp(1)
|
||||
if m.HighPerformanceRendering {
|
||||
cmd = LineUp(m, lines)
|
||||
cmd = ViewUp(m, lines)
|
||||
}
|
||||
}
|
||||
|
||||
@ -353,13 +313,13 @@ func Update(msg tea.Msg, m Model) (Model, tea.Cmd) {
|
||||
case tea.MouseWheelUp:
|
||||
lines := m.LineUp(3)
|
||||
if m.HighPerformanceRendering {
|
||||
cmd = LineUp(m, lines)
|
||||
cmd = ViewUp(m, lines)
|
||||
}
|
||||
|
||||
case tea.MouseWheelDown:
|
||||
lines := m.LineDown(3)
|
||||
if m.HighPerformanceRendering {
|
||||
cmd = LineDown(m, lines)
|
||||
cmd = ViewDown(m, lines)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user