theme

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package theme provides theme file parsing and serialization for revdiff color palettes. Theme files use INI format with comment-based metadata (# name: ..., # description: ...).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BundledNames

func BundledNames() []string

BundledNames returns the sorted list of bundled theme names.

func ColorKeys

func ColorKeys() []string

ColorKeys returns the ordered list of recognized color key names.

func Dump

func Dump(t Theme, w io.Writer) error

Dump writes a theme file to w from the given Theme. Colors are written in the canonical order defined by ColorKeys().

func InitBundled

func InitBundled(themesDir string) error

InitBundled writes bundled theme files to the given directory, creating it if needed. Always overwrites files matching bundled theme names; does not touch user-added files.

func List

func List(themesDir string) ([]string, error)

List returns sorted names of theme files in the given directory. Returns an empty list if the directory does not exist.

Types

type Theme

type Theme struct {
	Name        string
	Description string
	ChromaStyle string
	Colors      map[string]string // keys include the "color-" prefix, matching ini-name tags exactly (e.g. "color-accent")
}

Theme represents a color theme with metadata and color key-value pairs.

func Load

func Load(name, themesDir string) (Theme, error)

Load reads a theme file by name from the given themes directory. The file is expected at <themesDir>/<name>. Name must be a plain filename without path separators or directory traversal components.

func Parse

func Parse(r io.Reader) (Theme, error)

Parse reads a theme file from r and returns the parsed Theme. Theme files use INI-style key=value pairs and comment metadata lines:

# name: theme-name
# description: one-line description
chroma-style = dracula
color-accent = #bd93f9

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL