Phosphor::ProgressMock
Inherits Phosphor::MockWidget < Reference < Object
A determinate or indeterminate progress bar.
Generic and app-agnostic: no knowledge of AppState, Msg, or the
application theme. The Widget wrapper resolves theme → Style values
and sets them in Props before each render.
Determinate mode (props.value set) is driven entirely by Props —
handle_cmd ignores Cmd::Tick in that mode. Indeterminate mode
(props.value is nil) animates a moving block in response to
Cmd::Tick, exactly like SpinnerMock: the widget owns no timer, the
consuming screen mounts a TickPort in on_mount. See
.claude/rules/async.md.
Constants
Light shade — the empty-track glyph.
Full block — the filled/moving-block glyph.
Constructors
Initialises the progress bar with props and an optional state.
Instance methods
Responds to Cmd::Tick.
In indeterminate mode, advances state.block_position by 1, wrapping
at frame.width - block_width (using the most recently rendered
frame's width; a no-op before the first render). In determinate mode,
returns CmdResult::None — progress is driven by Props, not ticks.
Any other command also returns CmdResult::None.
Renders a single-row bar into buf at frame.y, spanning frame.width.
In determinate mode, the leading round(props.value * frame.width)
cells (clamped to 0..frame.width) use props.filled_style and
FILLED_CHAR; the rest use props.empty_style and EMPTY_CHAR. In
indeterminate mode, a max(1, frame.width // 5)-wide block at
state.block_position uses props.filled_style; everything else uses
props.empty_style.
Narrows the inherited state getter to ProgressMock::WidgetState.
Safe: initialize only ever stores a WidgetState into the base
@state ivar.