Expand description
Role-based theme system. Segments declare semantic roles; themes map
roles to colors; the render path emits ANSI SGR around each segment
based on the terminal’s detected capability. Full contract in
docs/specs/theming.md.
Built-ins compiled in: default (Palette16, terminal-default
anchor), minimal (decoration-only), the four Catppuccin flavors,
plus Dracula, Nord, Gruvbox, Tokyo Night, and Rose Pine. User
themes load from ~/.config/linesmith/themes/*.toml via
user::ThemeRegistry.
Re-exports§
pub use style_syntax::parse_style;pub use style_syntax::StyleParseError;pub use user::RegisteredTheme;pub use user::ThemeRegistry;pub use user::ThemeSource;
Modules§
- style_
syntax - Style-string parser per
docs/specs/theming.md§Style syntax. Accepts whitespace-separated tokens in any order: - user
- User-authored theme TOML loading. Parses files from
~/.config/linesmith/themes/*.tomlperdocs/specs/theming.md§Theme file format and merges them with the compiled-in themes into aThemeRegistry. The registry is the single source of truth the driver consults fortheme = "..."resolution.
Structs§
- Style
- Text decorations a segment may layer over its theme color.
roleis the role the segment wants;fgis an explicit color override that wins overrole.hyperlinkcarries an OSC 8 URL thatcrate::layout::runs_to_ansiwraps around the run’s text when the terminal advertises hyperlink support.bglives in the spec but isn’t wired through. - Styled
Run - Text + style emitted by the layout engine. The flat run sequence is
what
crate::layout::render_to_runsreturns: one run per segment plus one run per non-empty inter-segment separator. Consumers map runs to their target surface — ANSI SGR for terminal stdout, ratatuiSpanfor the TUI preview pane — without re-parsing escape sequences. - Theme
- Named color palette keyed by
Role.colors[role as usize]is eitherSome(color)when the theme defines it orNonesoTheme::colorfalls back viaRole::fallback. Fields stay crate-private so callers can’t mint themes with arbitrary names or bypass the fallback contract; user-authored themes will go through a validated constructor when TOML loading lands.
Enums§
- Ansi
Color - Standard 16-color ANSI palette. Stored as the foreground base (30..=37 for normal, 90..=97 for bright); we add offsets at emit time.
- Capability
- Terminal color capability detected from the environment. Truecolor
is preferred when available;
Nonestrips all color and keeps only decorations. - Color
- Concrete color value a theme resolves a role to.
- Role
- Semantic color slot a segment targets. Themes map every role to a concrete color; segments never reference hex values directly. Variants are ordered to match the 16-slot role array themes store.
Functions§
- built_
in - Look up a built-in theme by name. Unknown names return
Noneso callers can warn and fall back todefault. - builtin_
names - Names of all compiled-in themes, in registration order.
- default_
theme - The default theme when config names none (or names an unknown one). Guaranteed to exist.
- sgr_
open - Emit the ANSI SGR prefix for
styleundercap. Returns an empty string when the style is plain or the capability isNonewith no decorations. - sgr_
reset - SGR reset. Emitted after every styled span so color and decorations don’t leak across segment boundaries.