Phosphor::ParagraphMock
Inherits Phosphor::MockWidget < Reference < Object
A word-wrapped block of text.
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. Display only — it owns no
mutable render state and does not handle input.
Scope limitation, documented per .claude/rules/widgets.md's
convention for widgets with a bounded feature set:
- Only ASCII and common Unicode (Latin, CJK) word breaking is supported.
Latin text wraps at whitespace or hyphens; CJK text (cells with
Width.of(char) == 2) wraps at any character boundary. - Right-to-left text is not supported.
- The full Unicode line-breaking algorithm (UAX #14) is not implemented — this is a simple greedy wrapper, not a general-purpose typesetter.
- Hyphenation algorithms (inserting new hyphens to break a word that has none) are not implemented; only hyphens already present in the text are treated as break points.
Constructors
Initialises the paragraph with props and an optional state. No
extra render state is needed beyond the base WidgetState.
Instance methods
The number of rows props.text word-wraps to at width — the same
wrapping #render_content itself performs, so the two always agree.
Word-wraps props.text to frame.width cells and writes each
resulting line into buf, clipped to frame.height rows.
Each line is positioned per props.alignment: Left at frame.x,
Right at frame.x + (frame.width - line_width), Center at
frame.x + (frame.width - line_width) // 2, where line_width is
that line's own cell width (lines are shorter than frame.width
whenever a word wouldn't fit, so alignment has visible effect).