Help us shape the future of Go! Take the 2026 Go Developer Survey

theme

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package theme loads TUI color themes: embedded built-ins plus user theme files. A theme is a set of color roles; the TUI decides what each role colors.

Index

Constants

This section is empty.

Variables

View Source
var BuiltinOrder = []string{
	"dark", "light", "high-contrast", "mono",
	"tokyo-night", "tokyo-night-storm", "tokyo-night-day",
	"catppuccin-mocha", "catppuccin-latte", "dracula", "nord", "gruvbox-dark",
	"solarized-dark", "solarized-light",
}

BuiltinOrder is the order built-ins are listed and cycled in.

Functions

func Contrast

func Contrast(a, b string) (float64, bool)

Contrast returns the WCAG contrast ratio of two #rrggbb colors. ok is false unless both are hex (ANSI colors depend on the terminal's palette).

Types

type Palette

type Palette struct {
	ID     string `toml:"-"`
	Source string `toml:"-"` // "built-in" or the file it was loaded from

	Name       string `toml:"name"`
	Background string `toml:"background"`
	Foreground string `toml:"foreground"`
	Muted      string `toml:"muted"`
	Border     string `toml:"border"`
	Accent     string `toml:"accent"`
	OnAccent   string `toml:"on_accent"`
	Heading    string `toml:"heading"`
	Selection  string `toml:"selection"`
	Success    string `toml:"success"`
	Warning    string `toml:"warning"`
	Error      string `toml:"error"`
	Attention  string `toml:"attention"`
	Special    string `toml:"special"`
	Info       string `toml:"info"`
}

Palette is one theme. Every role is optional: empty means the terminal's own color (or plain/bold/reverse for structure).

func (Palette) ReadabilityProblems

func (p Palette) ReadabilityProblems() []string

ReadabilityProblems applies the readability rule. Themes without a background use the terminal's, so they can't be checked.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry holds the available themes in display order.

func Load

func Load(userDir string) (*Registry, error)

Load returns the built-ins plus every *.toml file in userDir (which may be empty or missing). A user file named like a built-in replaces it in place; other user themes follow the built-ins, sorted by id. Any invalid file is an error naming it.

func (*Registry) Get

func (r *Registry) Get(id string) (Palette, bool)

func (*Registry) IDs

func (r *Registry) IDs() []string

Jump to

Keyboard shortcuts

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