theme

package
v1.23.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package theme loads the UI color scheme from a small YAML config file, the same way plugins and saved hosts are persisted next to the d9c binary. It ships a set of named palettes (Tokyo Night, Dracula, Nord, …) and lets the user pick one and/or override individual base colors, then hands the result to the styles package via styles.Apply.

Example d9c-config.yaml:

theme: dracula            # built-in palette name (optional; default tokyonight)
colors:                   # optional per-color overrides (hex #rrggbb or ANSI 0-255)
  primary: "#ff79c6"
  danger: "#ff5555"

Index

Constants

View Source
const DefaultName = "tokyonight"

DefaultName is the built-in palette used when the config file is absent or does not name a theme.

Variables

This section is empty.

Functions

func ByName

func ByName(name string) (styles.Palette, bool)

ByName returns the built-in palette with the given name (case-insensitive), reporting whether it exists. It is the entry point for switching themes at runtime without a config file.

func DefaultPath

func DefaultPath() string

DefaultPath returns the config file location next to the running binary, falling back to the current directory if the executable path is unavailable.

func Load

func Load(path string) (styles.Palette, error)

Load reads the config file at path and resolves it to a palette: the named built-in theme (default tokyonight) with any per-color overrides applied. A missing file yields the default palette (not an error); malformed YAML, an unknown theme name, an unknown color key, or an invalid color value is an error.

func NameOf

func NameOf(p styles.Palette) string

NameOf returns the built-in theme name whose palette equals p, or "" if p does not match any built-in (e.g. a config with custom color overrides).

func Names

func Names() []string

Names returns the built-in theme names in sorted order (for docs/help).

func Resolve

func Resolve(cfg Config) (styles.Palette, error)

Resolve turns a parsed Config into a concrete palette, validating the theme name and every color override.

Types

type Config

type Config struct {
	Theme  string            `yaml:"theme"`
	Colors map[string]string `yaml:"colors"`
}

Config is the on-disk config-file format read by this package. The same file also carries a "keys:" section read independently by the keymap package, so the two concerns stay decoupled (yaml ignores fields it doesn't know).

Jump to

Keyboard shortcuts

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