Expand description
Theme module with separated pure types and I/O operations.
This module is split into:
types: Pure data types (WASM-compatible, no filesystem access)loader: ThemeLoader creates ThemeRegistry from embedded + user themes (runtime only)
§Example
ⓘ
use crate::view::theme::{Theme, ThemeLoader, ThemeRegistry};
use std::path::PathBuf;
// Load all themes once at startup (requires themes directory path)
let themes_dir = PathBuf::from("/home/user/.config/fresh/themes");
let loader = ThemeLoader::new(themes_dir);
let registry = loader.load_all();
// Or load embedded themes only (no user themes)
let loader = ThemeLoader::embedded_only();
let registry = loader.load_all();
// Get theme by name (no I/O, just lookup)
let dark = registry.get("dark").unwrap();
// List all available themes
let themes = registry.list();Structs§
- Builtin
Theme - A builtin theme with its name, pack, and embedded JSON content.
- Diagnostic
Colors - LSP diagnostic colors (errors, warnings, etc.)
- Editor
Colors - Editor area colors
- Search
Colors - Search result highlighting colors
- Syntax
Colors - Syntax highlighting colors
- Theme
- Comprehensive theme structure with all UI colors
- Theme
File - Serializable theme definition (matches JSON structure)
- Theme
Info - Information about an available theme.
- Theme
Loader - Loads themes and creates a ThemeRegistry.
- Theme
Registry - A registry holding all loaded themes.
- UiColors
- UI element colors (tabs, menus, status bar, etc.)
Enums§
- Color
Def - Serializable color representation
Constants§
- BUILTIN_
THEMES - All builtin themes embedded at compile time.
- THEME_
DARK - THEME_
DRACULA - THEME_
HIGH_ CONTRAST - THEME_
LIGHT - THEME_
NORD - THEME_
NOSTALGIA - THEME_
SOLARIZED_ DARK
Functions§
- brighten_
color - Brighten a color by adding an amount to each RGB component. Clamps values to 255.
- color_
to_ rgb - Convert a ratatui Color to RGB values. Returns None for Reset or Indexed colors.
- get_
builtin_ themes - Returns a map of built-in theme names to their JSON content.
- get_
theme_ schema - Returns the raw JSON Schema for ThemeFile, generated by schemars. The schema uses standard JSON Schema format with $ref for type references. Plugins are responsible for parsing and resolving $ref references.
- named_
color_ from_ str - Convert a named color string (e.g. “Yellow”, “Red”) to a ratatui Color. Returns None if the string is not a recognized named color.
- normalize_
theme_ name - Normalize a theme name for consistent lookup and storage.