Export pagination helpers

This commit is contained in:
Christian Rocha 2020-04-09 19:32:56 -04:00
parent 363c2522f2
commit fc64be59d6
No known key found for this signature in database
GPG Key ID: D6CC7A16E5878018

View File

@ -63,13 +63,13 @@ func (m *Model) GetSliceBounds(length int) (start int, end int) {
return start, end return start, end
} }
func (m *Model) prevPage() { func (m *Model) PrevPage() {
if m.Page > 0 { if m.Page > 0 {
m.Page-- m.Page--
} }
} }
func (m *Model) nextPage() { func (m *Model) NextPage() {
if m.Page < m.TotalPages-1 { if m.Page < m.TotalPages-1 {
m.Page++ m.Page++
} }
@ -99,33 +99,33 @@ func Update(msg tea.Msg, m Model) (Model, tea.Cmd) {
if m.UseLeftRightKeys { if m.UseLeftRightKeys {
switch msg.String() { switch msg.String() {
case "left": case "left":
m.prevPage() m.PrevPage()
case "right": case "right":
m.nextPage() m.NextPage()
} }
} }
if m.UseUpDownKeys { if m.UseUpDownKeys {
switch msg.String() { switch msg.String() {
case "up": case "up":
m.prevPage() m.PrevPage()
case "down": case "down":
m.nextPage() m.NextPage()
} }
} }
if m.UseHLKeys { if m.UseHLKeys {
switch msg.String() { switch msg.String() {
case "h": case "h":
m.prevPage() m.PrevPage()
case "l": case "l":
m.nextPage() m.NextPage()
} }
} }
if m.UseJKKeys { if m.UseJKKeys {
switch msg.String() { switch msg.String() {
case "j": case "j":
m.prevPage() m.PrevPage()
case "k": case "k":
m.nextPage() m.NextPage()
} }
} }
} }