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
- func ActiveName(name string) string
- func ColorKeys() []string
- func Dump(t Theme, w io.Writer) error
- func Gallery() (map[string]Theme, error)
- func GalleryNames() ([]string, error)
- func InitAll(themesDir string) error
- func InitBundled(themesDir string) error
- func InitNames(themesDir string, names []string) error
- func Install(args []string, themesDir string, validateChroma func(string) bool, ...) error
- func List(themesDir string) ([]string, error)
- func OptionalColorKeys() map[string]bool
- func PrintList(themesDir string, w io.Writer) error
- type Theme
- type ThemeInfo
Constants ¶
const DefaultThemeName = "revdiff"
DefaultThemeName is the name of the built-in default theme.
Variables ¶
This section is empty.
Functions ¶
func ActiveName ¶ added in v0.15.0
ActiveName returns the theme name, defaulting to the built-in default when empty.
func ColorKeys ¶
func ColorKeys() []string
ColorKeys returns the ordered list of recognized color key names.
func Dump ¶
Dump writes a theme file to w from the given Theme. Colors are written in the canonical order defined by ColorKeys().
func Gallery ¶ added in v0.15.0
Gallery returns all themes from the embedded gallery, keyed by filename. Results are cached after the first call since the embedded FS is immutable. Each call returns a deep copy so callers can mutate the result safely.
func GalleryNames ¶ added in v0.15.0
GalleryNames returns sorted names of all themes in the embedded gallery.
func InitAll ¶ added in v0.15.0
InitAll writes all gallery themes to the given directory, creating it if needed. Always overwrites files matching gallery theme names; does not touch user-added files.
func InitBundled ¶
InitBundled writes bundled theme files (marked bundled: true in gallery) to the given directory, creating it if needed. Always overwrites files matching bundled theme names; does not touch user-added files.
func InitNames ¶ added in v0.15.0
InitNames writes specific named themes from the gallery to the given directory. Returns an error if any name is not found in the gallery.
func Install ¶ added in v0.15.0
func Install(args []string, themesDir string, validateChroma func(string) bool, stdout io.Writer) error
Install installs themes from gallery names or local file paths. Validates all gallery names upfront before performing any installs to prevent partial state.
func List ¶
List returns sorted names of theme files in the given directory. Returns an empty list if the directory does not exist.
func OptionalColorKeys ¶
OptionalColorKeys returns the set of color keys that may be omitted from theme files. these correspond to CLI flags with no default value (terminal background is used instead).
Types ¶
type Theme ¶
type Theme struct {
Name string
Description string
Author string
Bundled bool
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 GalleryTheme ¶ added in v0.15.0
GalleryTheme returns a single theme from the embedded gallery by name.
func Load ¶
Load reads a theme by name. It first checks the local themes directory for a user-customized copy, then falls back to the embedded gallery. Name must be a plain filename without path separators or directory traversal components.
type ThemeInfo ¶ added in v0.15.0
type ThemeInfo struct {
Name string
InGallery bool // true if name exists in the embedded gallery
Bundled bool // true if gallery entry has bundled: true
Local bool // true if installed locally but not in gallery
}
ThemeInfo holds classification metadata for a theme in an ordered listing.
func ListOrdered ¶ added in v0.15.0
ListOrdered merges gallery and locally installed themes into a classified, deterministic list. Order: default theme first, then local-only (sorted), then bundled gallery (sorted), then other gallery (sorted).