MCPcopy
hub / github.com/charmbracelet/glow / updatePagination

Method updatePagination

ui/stash.go:255–275  ·  view source on GitHub ↗

Update pagination according to the amount of markdowns for the current state.

()

Source from the content-addressed store, hash-verified

253// Update pagination according to the amount of markdowns for the current
254// state.
255func (m *stashModel) updatePagination() {
256 _, helpHeight := m.helpView()
257
258 availableHeight := m.common.height -
259 stashViewTopPadding -
260 helpHeight -
261 stashViewBottomPadding
262
263 m.paginator().PerPage = max(1, availableHeight/stashViewItemHeight)
264
265 if pages := len(m.getVisibleMarkdowns()); pages < 1 {
266 m.paginator().SetTotalPages(1)
267 } else {
268 m.paginator().SetTotalPages(pages)
269 }
270
271 // Make sure the page stays in bounds
272 if m.paginator().Page >= m.paginator().TotalPages-1 {
273 m.paginator().Page = max(0, m.paginator().TotalPages-1)
274 }
275}
276
277// MarkdownIndex returns the index of the currently selected markdown item.
278func (m stashModel) markdownIndex() int {

Callers 5

setSizeMethod · 0.95
resetFilteringMethod · 0.95
addMarkdownsMethod · 0.95
handleFilteringMethod · 0.95

Calls 3

helpViewMethod · 0.95
paginatorMethod · 0.95
getVisibleMarkdownsMethod · 0.95

Tested by

no test coverage detected