beamtea_viewport (beamtea v0.1.2)
View SourceA bubble: a scrollable viewport over a block of text, mirroring the viewport package in charmbracelet/bubbles.
Give it content and a height; it shows a window into that content that the user can scroll with the arrows, PageUp/PageDown, Home/End (and j/k).
V0 = beamtea_viewport:new(#{height => 10}),
V1 = beamtea_viewport:set_content(BigText, V0),
{V2, _} = beamtea_viewport:update({key, down}, V1),
beamtea_viewport:view(V2).
Summary
Functions
Scroll down by N lines (clamped).
Scroll up by N lines (clamped).
Options: height (visible rows, default 20), width (optional).
How far through the content we are scrolled, as 0.0–1.0.
Replace the content (split into lines on \n).
Scroll in response to a key.
The visible window of lines.
Types
Functions
-spec line_down(non_neg_integer(), model()) -> model().
Scroll down by N lines (clamped).
-spec line_up(non_neg_integer(), model()) -> model().
Scroll up by N lines (clamped).
-spec new() -> model().
Equivalent to new(#{}).
Options: height (visible rows, default 20), width (optional).
-spec offset(model()) -> non_neg_integer().
How far through the content we are scrolled, as 0.0–1.0.
Replace the content (split into lines on \n).
-spec total_lines(model()) -> non_neg_integer().
-spec update(term(), model()) -> {model(), beamtea:cmd()}.
Scroll in response to a key.
The visible window of lines.