Skip to main content

Module theme

Module theme 

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

BuiltinTheme
A builtin theme with its name, pack, and embedded JSON content.
DiagnosticColors
LSP diagnostic colors (errors, warnings, etc.)
EditorColors
Editor area colors
SearchColors
Search result highlighting colors
SyntaxColors
Syntax highlighting colors
Theme
Comprehensive theme structure with all UI colors
ThemeFile
Serializable theme definition (matches JSON structure)
ThemeInfo
Information about an available theme.
ThemeLoader
Loads themes and creates a ThemeRegistry.
ThemeRegistry
A registry holding all loaded themes.
UiColors
UI element colors (tabs, menus, status bar, etc.)

Enums§

ColorDef
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.