Expand description
Runs of different treatment inside one Text.
Not a widget. A paragraph with a bold phrase and a link in it is one piece of text, and splitting it into three widgets to say so would break line wrapping at the seams: the renderer would wrap each piece on its own and the phrase would never share a line with what surrounds it.
So the spans travel beside the string, as a blob of fixed-length records in the same
shape a Canvas carries its commands. Nothing new crosses the boundary to do it.
Markdown is a convenience on this side. TextSpans::from_markdown turns a small,
closed subset into spans, and the Renderer never hears the word.
Structs§
- Text
Span - One run, given in bytes into the string rather than characters.
- Text
Spans - An encoded list of spans, ready to travel.
Constants§
- FLAG_
BOLD - FLAG_
ITALIC - FLAG_
STRIKETHROUGH - FLAG_
UNDERLINE - SPAN_
BACKGROUND_ AT - SPAN_
COLOR_ AT - SPAN_
FLAGS_ AT - SPAN_
HANDLER_ AT - SPAN_
LEN - Bytes of one span record: two ranges’ worth of offsets, a role, flags, the text’s paint, the background’s paint and a handler. Four-byte aligned throughout, which is the protocol’s invariant.
- SPAN_
LENGTH_ AT - SPAN_
ROLE_ AT - SPAN_
START_ AT - Where each field of a span record starts. The Kotlin decoder is generated from these, so the two sides read the same bytes.