Documentation
¶
Overview ¶
Package pager is the pantheon suite's shared scroll state for read-only screens: a Pager owns the scroll offset over a block of text and renders it through porticus.Styles.Page, handling the suite's navigation keys and the mouse wheel. It is the line-scroll analogue of browse.Cursor (which owns item selection) — drop one into any tool that shows a markdown preview, a changelog, or a long answer, and scrolling behaves identically everywhere.
Presentation + interaction only: depends on bubbletea, porticus/keys, and the porticus chrome — never on the data spine.
Index ¶
- type Pager
- func (p *Pager) Handle(msg tea.KeyMsg, km keys.Map, height int) bool
- func (p *Pager) HandleMouse(msg tea.MouseMsg) bool
- func (p *Pager) Scroll() int
- func (p *Pager) SetContent(body string)
- func (p *Pager) Top()
- func (p *Pager) View(s porticus.Styles, t porticus.Theme, label string, width, height int) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pager ¶
type Pager struct {
// contains filtered or unexported fields
}
Pager holds the scroll offset over a body of text. The zero value is an empty, top-of-page pager ready for SetContent. It remembers the last viewport height it was given (by Handle or View) so the mouse wheel — which carries no height — can still clamp to the bottom.
func (*Pager) Handle ¶
Handle applies a navigation key and reports whether the offset moved: j/k step a line, ctrl+d/ctrl+u a half page, g/G jump to top/bottom. height is the page height so the half-page step and the bottom stop match what View renders. Keys it doesn't recognise leave the pager unchanged and return false, so the caller can route them.
func (*Pager) HandleMouse ¶
HandleMouse scrolls one line per wheel notch and reports whether it moved. Other mouse events return false. It clamps against the last height the pager saw (from Handle or View), mirroring browse.Cursor.HandleMouse.
func (*Pager) SetContent ¶
SetContent replaces the text and clamps the offset to the new content, so a shorter body can't leave the page scrolled past its end. Use Top to jump back to the first row explicitly.
func (*Pager) View ¶
View renders the page at the current offset through the standard read-only chrome (the header label over the ══ rule, the windowed body, a scroll hint when it overflows), filled to exactly width×height so the footer stays pinned. It records height so a later wheel event clamps correctly.