From 0fd072ddcc14bb0bb74faa49ee2cd90c065853a7 Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Tue, 27 Oct 2020 16:30:01 -0400 Subject: [PATCH] Make Paginator more idomatic Bubble Tea (per v0.12.x) --- paginator/paginator.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/paginator/paginator.go b/paginator/paginator.go index 67ed2c9..1ed7b85 100644 --- a/paginator/paginator.go +++ b/paginator/paginator.go @@ -115,7 +115,7 @@ func NewModel() Model { } // Update is the Tea update function which binds keystrokes to pagination. -func Update(msg tea.Msg, m Model) (Model, tea.Cmd) { +func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) { switch msg := msg.(type) { case tea.KeyMsg: if m.UsePgUpPgDownKeys { @@ -164,16 +164,16 @@ func Update(msg tea.Msg, m Model) (Model, tea.Cmd) { } // View renders the pagination to a string. -func View(m Model) string { +func (m Model) View() string { switch m.Type { case Dots: - return dotsView(m) + return m.dotsView() default: - return arabicView(m) + return m.arabicView() } } -func dotsView(m Model) string { +func (m Model) dotsView() string { var s string for i := 0; i < m.TotalPages; i++ { if i == m.Page { @@ -185,7 +185,7 @@ func dotsView(m Model) string { return s } -func arabicView(m Model) string { +func (m Model) arabicView() string { return fmt.Sprintf(m.ArabicFormat, m.Page+1, m.TotalPages) }