Raxol.Terminal.Theme.Manager (Raxol v0.5.0)

View Source

Manages terminal themes with advanced features:

  • Theme loading from files and presets
  • Theme customization and modification
  • Dynamic theme switching
  • Theme persistence and state management

Summary

Functions

Adds a custom style to the current theme.

Gets the current theme metrics.

Gets a style from the current theme or custom styles.

Loads a theme from a file or preset.

Creates a new theme manager with the given options.

Restores a theme state from saved data.

Saves the current theme state for persistence.

Types

color()

@type color() :: %{r: integer(), g: integer(), b: integer(), a: float()}

style()

@type style() :: %{
  foreground: color(),
  background: color(),
  bold: boolean(),
  italic: boolean(),
  underline: boolean()
}

t()

@type t() :: %Raxol.Terminal.Theme.Manager{
  current_theme: theme(),
  custom_styles: %{required(String.t()) => style()},
  metrics: %{
    theme_switches: integer(),
    style_applications: integer(),
    customizations: integer(),
    load_operations: integer()
  },
  themes: %{required(String.t()) => theme()}
}

theme()

@type theme() :: %{
  name: String.t(),
  description: String.t(),
  author: String.t(),
  version: String.t(),
  colors: %{
    background: color(),
    foreground: color(),
    cursor: color(),
    selection: color(),
    black: color(),
    red: color(),
    green: color(),
    yellow: color(),
    blue: color(),
    magenta: color(),
    cyan: color(),
    white: color(),
    bright_black: color(),
    bright_red: color(),
    bright_green: color(),
    bright_yellow: color(),
    bright_blue: color(),
    bright_magenta: color(),
    bright_cyan: color(),
    bright_white: color()
  },
  styles: %{
    normal: style(),
    bold: style(),
    italic: style(),
    underline: style(),
    cursor: style(),
    selection: style()
  }
}

Functions

add_custom_style(manager, name, style)

@spec add_custom_style(t(), String.t(), style()) :: {:ok, t()} | {:error, term()}

Adds a custom style to the current theme.

get_metrics(manager)

@spec get_metrics(t()) :: map()

Gets the current theme metrics.

get_style(manager, style_name)

@spec get_style(t(), String.t()) :: {:ok, style()} | {:error, term()}

Gets a style from the current theme or custom styles.

load_theme(manager, theme_name)

@spec load_theme(t(), String.t()) :: {:ok, t()} | {:error, term()}

Loads a theme from a file or preset.

new(opts \\ [])

@spec new(keyword()) :: t()

Creates a new theme manager with the given options.

restore_theme_state(manager, state)

@spec restore_theme_state(t(), map()) :: {:ok, t()} | {:error, term()}

Restores a theme state from saved data.

save_theme_state(manager)

@spec save_theme_state(t()) :: {:ok, map()} | {:error, term()}

Saves the current theme state for persistence.