Expand description
Styled text: the document model label().runs(…) renders and day-piece-texteditor edits,
with the Markdown / HTML / RTF codecs over it (docs/texteditor.md).
Styled text: the document label().runs(…) renders and day-piece-texteditor edits
(docs/texteditor.md).
StyledText is plain text plus two range vectors over it: TextRuns for character
attributes and ParagraphRuns for paragraph ones. Text and ranges travel together by
construction, because a range only means something against a particular string.
Everything an editor’s toolbar needs is a pure function here rather than a round trip into the
toolkit: StyledText::style_of answers “what is the selection’s style” (with a mixed state
where the runs disagree), StyledText::apply changes it, and StyledText::reflow moves
the ranges over an edit the native editor already made. That is what lets the same logic run
on nine backends and be tested on the headless one.
Structs§
- Paragraph
Run - One styled paragraph.
- Paragraph
Style - A
ParagraphRun’s attributes with no range attached. - RunStyle
- A
TextRun’s attributes with no range attached: what a toolbar toggles, what an editor applies to a selection, and what it styles the next typed character with. - Styled
Text - A styled document: plain text, the character runs over it, and the paragraph attributes over the same offsets.
Enums§
- List
Style - A paragraph’s list decoration, if it is a list item.
- Paragraph
Align - How a paragraph’s lines sit in the width they are given.
- Underline
- A line under a run.
Functions§
- coalesce_
runs - Merge adjacent runs whose styles came out equal, and drop runs that say nothing beyond
base. - paragraph_
bounds - The
\n-delimited paragraphs oftext, as byte ranges INCLUDING the terminator. - paragraphs_
are_ valid - Whether these paragraph runs are well formed for
text:runs_are_valid’s rules, applied to the second range vector.