Skip to main content

Module themes

Module themes 

Source
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§

LoadedTheme
A successfully loaded file theme, ready to apply.
ThemeRegistry
A registry of discovered custom theme files: display name → path.

Enums§

ThemeSpec
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 /theme swaps), 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. ~user forms 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 return None.
resolve_command_theme
Resolve a /theme <name> argument to the spec apply_and_persist consumes. 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 Ocean must find Ocean.json). Returns None when 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 --theme semantics).
resolve_spec_in
resolve_spec with 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.