Expand description
Lightweight, dependency-free syntax highlighting for inline previews.
The preview already caps what it reads (see crate::preview), so
highlighting is a single linear pass over a small buffer. The scanner is
deliberately simple — an approximation, not a full parser — and runs once
when a document is loaded, caching the resulting spans with it. Rebuilds
only replay the cached spans, so there is no per-frame cost.
Colors come from a process-wide Palette set at startup from the active
theme (see crate::theme); the tree turns each TokenClass into a
GtkTextTag.
Structs§
- Palette
- The colors used for each token class. Values are GTK color strings
(
#rrggbb), so they can be handed straight to aGtkTextTag. - Span
- A highlighted range of the preview text, in character offsets (
endis exclusive). Spans never overlap.
Enums§
- Language
- The language a preview is highlighted as.
- Token
Class - A semantic token category. Each maps to one color in
Palette.
Functions§
- highlight
- Highlight
textaslanguage. Character offsets in the returned spans index the same text; the text itself is never altered. - language_
for - Pick the highlighting language from a file’s extension.
- palette
- The active syntax palette.
- set_
palette - Install the process-wide syntax palette. Only the first call wins.