Expand description
Theme spec resolution and loading.
A theme spec is the value of --theme / settings.json.theme: either a
built-in preset name (dark / light / monochrome) or a path to a pi
theme JSON file (ThemeJson, see rpi_tui::theme_json). File specs expand
~ and load lazily at the point of application so parse errors surface as
warnings plus a fallback to the built-in default, never a startup veto —
the same gentle style as emit_startup_warnings.
--no-themes is enforced upstream (app.rs passes no theme at all), so
custom files cannot bypass it here.
Structs§
- Loaded
Theme - A successfully loaded file theme, ready to apply.
- Theme
Registry - A registry of discovered custom theme files: display name → path.
Enums§
- Theme
Spec - A resolved theme spec: built-in preset or theme file path.
Functions§
- apply_
and_ persist - Apply a theme spec (preset or file path) live and persist it.
- apply_
loaded - Apply a file theme to both the process-wide theme (what components read)
and the session’s theme manager (what
/themeswaps), mirroring the preset path’s dual application. - apply_
spec - Resolve + apply a theme spec at TUI startup.
- apply_
startup_ spec - Resolve a
--theme/settings spec against the discovery registry and apply it. Kept as one helper so the startup call site cannot resolve before the registry is built (the saved value may be a registry name, which only resolves when the registry is in scope). - expand_
home - Expand a leading
~to the user’s home directory.~userforms are left untouched (only the current user’s home is resolvable here). - reconcile_
after_ reload - Reconcile a rebuilt registry after
/reload: if the currently active file theme (tracked as its spec value) is no longer resolvable, fall back to the default preset and return the user-facing notice; otherwise leave the theme alone and returnNone. - resolve_
command_ theme - Resolve a
/theme <name>argument to the specapply_and_persistconsumes. Built-in presets are case-folded; discovered custom themes keep the original case because the registry is case-sensitive and discovery preserves file stems (/theme Oceanmust findOcean.json). ReturnsNonewhen the name matches neither a preset nor the registry. - resolve_
spec - Classify a theme spec string. Anything that is not a built-in preset name
is treated as a file path (the documented
--themesemantics). - resolve_
spec_ in resolve_specwith a discovery registry: an exact registry name resolves to its file, so a theme picked from the selector (persisted by name) loads again on the next startup. Direct paths still win for values that are not registry names.- restart_
theme_ watcher - Swap the theme watcher onto the current active spec.