Expand description
Syntax highlighting as runs (docs/texteditor.md §9): a tokenizer is a pure function from text
to Vec<TextRun>, and TextEditor::highlight re-runs it on
every edit and pushes the runs back as an attributes patch, so the caret and the undo stack
stay where they are. Nothing here touches a toolkit; the same runs restyle all eight arms,
and a test asserts them on the headless one.
The grammars are small on purpose: an API client’s bodies (JSON, XML, GraphQL), Day’s own
samples (Rust), and the template tags Yaak-style clients write inside any of them
(${[ name ]}). A full grammar engine is a dependency this crate does not want; a new
language is a function below.
Structs§
- Palette
- The colors a highlighter paints with. Every one is readable on a light and on a dark surface, which matters because the editor’s background is the platform’s and changes with the theme while the runs do not.
Enums§
- Language
- What a text is written in.
Functions§
- highlight
- Tokenize
textinto runs covering every byte: claimed tokens in their colors, the gaps between them in the palette’s base style. Byte offsets throughout, which is what the document indexes by, and why a multi-byte character in a comment cannot shift the styling of what follows it. - highlight_
with_ templates highlight, then every${[ … ]}template tag painted over whatever token it sits in.- highlighter
- A closure for
TextEditor::highlight:languagetokens, template tags on top whentemplatesis set. - template_
tags - Paint every
${[ … ]}tag intextoverruns, splitting the runs it overlaps. The tag is what a Yaak-style client renders a variable or a function call as; an unclosed${[is left as it was typed.