reveal

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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 Phase

type Phase int

Phase is where a block is in its life.

const (
	// Entering: rows are being added from the top.
	Entering Phase = iota
	// Shown: every row is painted and nothing is scheduled.
	Shown
	// Leaving: rows are being removed from the bottom.
	Leaving
	// Gone: nothing is painted and the caller may drop the state.
	Gone
)

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

func New(total int) *State

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

func (s *State) Animating() bool

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

func (s *State) Clip(block string) string

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) Phase

func (s *State) Phase() Phase

Phase reports the current phase.

func (*State) Resize

func (s *State) Resize(total int)

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.

func (*State) Rows

func (s *State) Rows() int

Rows is how many rows from the top of the block to paint this frame.

func (*State) Visible

func (s *State) Visible() bool

Visible reports whether anything is painted.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL