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§

SPAN_LEN
Bytes of one span record: two ranges’ worth of offsets, a role, flags, a paint and a handler. Four-byte aligned throughout, which is the protocol’s invariant.