Skip to main content

Module spans

Module spans 

Source
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§

TextSpan
One run, given in bytes into the string rather than characters.
TextSpans
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.