theme

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package theme is the lipgloss-free, JSON-driven colour theme for the v2 TUI. It loads the same theme JSON schema as pkg/tui/theme (the v1 system) but resolves each colour to its dark hex and emits truecolor ANSI directly — no lipgloss, stdlib only — so it compiles under both x/ansi lines (root v1 at 0.10.x and the v2 module at 0.11.x) and adds nothing to either dependency graph.

Import it aliased, since the package dir is "v2":

"github.com/zarldev/zarlmono/zkit/tui/theme"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadError

func LoadError() error

LoadError reports any failure encountered loading the embedded themes at init time, nil on a clean load. The TUI surfaces it once at startup so a corrupt embedded theme leaves a diagnostic rather than a silent palette fallback.

Types

type Color

type Color string

Color is a hex colour ("#rrggbb" or "#rgb"). The empty value renders nothing (no escape), so unset slots degrade to the terminal default.

func (Color) BG

func (c Color) BG() string

BG returns the truecolor SGR background sequence, or "" if unset/invalid.

func (Color) FG

func (c Color) FG() string

FG returns the truecolor SGR foreground sequence, or "" if unset/invalid.

func (Color) On

func (c Color) On(s string) string

On wraps s in this foreground colour and a reset. No-op when unset.

type Theme

type Theme struct {
	Name string

	// Surfaces.
	Bg, Fg, Subtle, Muted Color
	// Semantic accents.
	Primary, Secondary            Color
	Success, Warning, Error, Info Color
	// Conversation roles.
	User, Assistant, Tool, System Color
	// Structure.
	Border, BorderFocus            Color
	Highlight, Selection, PlanMode Color
}

Theme is a resolved (dark-variant) colour set. Slots mirror the v1 theme so the JSON is interchangeable.

func Builtins

func Builtins() []Theme

Builtins returns every embedded theme.

func ByName

func ByName(name string) (Theme, bool)

ByName returns the builtin theme with the given name.

func DarkDefault

func DarkDefault() Theme

DarkDefault returns the builtin theme marked default:dark (or the first builtin as a fallback).

func Decode

func Decode(data []byte) (Theme, error)

Decode parses a theme JSON (the v1-compatible schema), resolving each colour to its dark variant.

func LoadBuiltins

func LoadBuiltins() ([]Theme, error)

LoadBuiltins reads and decodes every embedded theme, returning them in directory order. Unlike the package-level accessors it surfaces failures: the returned error aggregates (via errors.Join) every per-file read or decode failure so a corrupt embedded theme is diagnosable instead of silently dropped. The themes that DID decode are still returned alongside any error, so a caller can use the good subset and log the rest.

func LoadDir

func LoadDir(dir string) ([]Theme, []error)

LoadDir loads every *.json in dir (best-effort). A missing dir yields no themes and no error, matching the v1 convention.

func LoadFile

func LoadFile(path string) (Theme, error)

LoadFile decodes a theme from a JSON file.

Jump to

Keyboard shortcuts

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