Documentation
¶
Overview ¶
package paginator provides a Bubble Tea package for calulating pagination and rendering pagination info. Note that this package does not render actual pages: it's purely for handling keystrokes related to pagination, and rendering pagination status.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Model ¶
type Model struct { Type Type Page int PerPage int TotalPages int ActiveDot string InactiveDot string ArabicFormat string UsePgUpPgDownKeys bool UseLeftRightKeys bool UseUpDownKeys bool UseHLKeys bool UseJKKeys bool }
Model is the Tea model for this user interface.
func (*Model) GetSliceBounds ¶
GetSliceBounds is a helper function for paginating slices. Pass the length of the slice you're rendering and you'll receive the start and end bounds corresponding the to pagination. For example:
bunchOfStuff := []stuff{...} start, end := model.GetSliceBounds(len(bunchOfStuff)) sliceToRender := bunchOfStuff[start:end]
func (Model) ItemsOnPage ¶
ItemsOnPage is a helper function for returning the numer of items on the current page given the total numer of items passed as an argument.
func (*Model) NextPage ¶
func (m *Model) NextPage()
NextPage is a helper function for navigating one page forward. It will not page beyond the last page (i.e. totalPages - 1).
func (Model) OnLastPage ¶
LastPage returns whether or not we're on the last page.
func (*Model) PrevPage ¶
func (m *Model) PrevPage()
PrevPage is a number function for navigating one page backward. It will not page beyond the first page (i.e. page 0).
func (*Model) SetTotalPages ¶
SetTotalPages is a helper function for calculatng the total number of pages from a given number of items. It's use is optional since this pager can be used for other things beyond navigating sets. Note that it both returns the number of total pages and alters the model.