Documentation
¶
Overview ¶
Package reveal is the row-count state machine behind design frame 1h — the only motion sidecar allows outside the intro.
The spec in one sentence: a block of N rows arrives one whole row per frame, ~90ms apart, revealed top-down and retracted bottom-up, with no subpixel travel and no fades. Because both directions only ever change *how many rows from the top are painted*, the whole thing is one integer, and a caller renders its block and keeps the first Rows() lines.
Nothing here draws, and nothing here knows what the rows contain: the toast stack is the first caller, and any future motion is meant to be the second.
Index ¶
Constants ¶
const Step = 67 * time.Millisecond
Step is one animation frame. Design 1h says ~90ms; polish round 2 speeds reveal and retract by ~25% because at 90ms a five-row block took most of half a second to arrive. The status flash moves at the same cadence, so the two motions in the system still run at one speed rather than two that nearly agree (the flash takes an extra fade step to keep its fade the same length in wall-clock time).
Variables ¶
This section is empty.
Functions ¶
func Animated ¶
func Animated() bool
Animated reports whether this terminal gets motion at all. A dumb or absent TERM cannot be trusted with per-frame repaints, and SIDECAR_NO_ANIMATION is the explicit opt-out for a slow link where 90ms frames cost more than the motion is worth. Both the status flash and the toast reveal ask here — one answer, resolved once, because an environment lookup per frame is the kind of per-frame syscall the latency rules exist to prevent.
func SetAnimatedForTests ¶
func SetAnimatedForTests(v bool) func()
SetAnimatedForTests pins Animated to v and returns a func restoring the environment-derived answer.
Types ¶
type State ¶
type State struct {
// contains filtered or unexported fields
}
State is one block's reveal. The zero value is a gone, empty block; use New.
func New ¶
New starts a block of total rows entering. On a terminal that cannot be trusted with per-frame repaints the block is simply shown at full height, which is the spec'd degraded mode and needs no ticks at all.
func (*State) Advance ¶
func (s *State) Advance()
Advance moves the block one frame. It is a no-op once the block has settled, so a stale tick costs nothing.
func (*State) Animating ¶
Animating reports whether the block still owes frames. A host schedules its tick while any of its blocks says yes and stops when none do — motion must not keep a frame timer alive for a screen that has settled.
func (*State) Clip ¶
Clip returns the first Rows() lines of an already-rendered block. Retracting bottom-up is exactly "keep fewer lines from the top", which is why the border never has to be redrawn from scratch mid-motion.
func (*State) Leave ¶
func (s *State) Leave()
Leave starts the retraction. It is idempotent, and a block that never got its motion (degraded terminal) leaves the same way it arrived: at once.
func (*State) Resize ¶
Resize updates the block's full height, which changes between frames: a countdown row disappears, a body wraps differently, a collapsed stack gains a peek line. A block already shown grows and shrinks with it immediately; a block still entering keeps its progress and simply has a new target.