pub struct Run {
pub text: String,
pub role: String,
pub bold: bool,
pub italic: bool,
pub underline: bool,
pub strike: bool,
pub sup: bool,
pub sub: bool,
pub src: u32,
pub sel: bool,
}Expand description
One maximal span of same-styled glyphs on a visual row — the unit the Swift renderer turns into a single styled attributed-string run.
Fields§
§text: StringThe run’s text, glyphs concatenated in column order.
role: StringThe glyph’s semantic role as a renderer class id: body, h1…h6,
code, link, mark, list, quote, rule.
bold: bool§italic: bool§underline: bool§strike: bool§sup: boolRaised off the baseline and drawn smaller — a footnote reference’s [1],
or an author’s ^x^. Mutually exclusive with sub; core’s
Baseline is one value, and these are its two non-default cases flattened
to the flag shape the rest of this record is spelled in.
sub: boolLowered off the baseline and drawn smaller — an author’s ~x~.
src: u32The byte offset in the source this run’s first glyph came from.
What a run means, as opposed to how it looks: a link role says a span
is drawn as a link but not where it points, and the only way back to that
is the source. A frontend drawing part of the document somewhere the caret
isn’t — a footnote’s text in a popover — pairs this with
LeafDoc::link_destination_at or LeafDoc::footnote_at to make those
runs followable.
The alternative was for a frontend to count its way along the row’s text
and ask LeafDoc::offset_for_pos, which means converting between three
units that only agree on ASCII: this is a byte offset, the run’s text is
characters, and a row’s column is a display cell (a wide CJK glyph is
two). Handing the offset over is exact, O(1), and needs none of that.
0 for the runs of the source view, whose rows are split from raw text
rather than laid out from glyphs.
sel: boolWhether this run lies inside the active selection — so the renderer can paint a selection background without re-deriving it from offsets.