theme

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package theme defines memcode's color themes: a registry of named palettes (semantic color roles for TUI styles, diff RGBs, and chroma syntax-highlight style names) plus the active-theme accessor used by the renderer. Themes are registered at init time in themes.go; "aurora" is the default. A "random" meta-theme re-resolves to a different concrete theme on each launch.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chosen

func Chosen() string

Chosen returns the literal theme name last passed to Set — e.g. "random" — so the front-end persists the user's choice rather than the concrete theme it resolved to.

func ChromaStyle

func ChromaStyle() *chroma.Style

ChromaStyle resolves the active theme's ChromaName to a *chroma.Style, caching the result so repeated calls are cheap (map lookup + RLock).

func Names

func Names() []string

Names returns the sorted list of all registered theme names.

func Register

func Register(t Theme)

Register adds a theme to the registry. Call from an init() function.

func Set

func Set(name string) bool

Set switches the active theme to the named theme. Returns true if the name was found and the theme was changed; returns false for unknown names (no mutation).

Types

type DiffColors

type DiffColors struct {
	AddBg         [3]int // RGB for added-line background
	DelBg         [3]int // RGB for deleted-line background
	AddGutter     [3]int // RGB for added-line gutter foreground
	DelGutter     [3]int // RGB for deleted-line gutter foreground
	ContextGutter string // hex for context-line gutter foreground
}

DiffColors holds the RGB/ANSI values used for diff rendering backgrounds and gutters. These are raw numeric values (not hex strings) because diff.go builds ANSI escape sequences directly from the RGB components.

type Palette

type Palette struct {
	Brand        string // primary brand (purple in aurora)
	Info         string // primary info (blue)
	Secondary    string // secondary info (cyan)
	Success      string // positive/success (green)
	Warning      string // caution (amber)
	WarningAlt   string // caution variant — darker amber
	Danger       string // error/forbidden (red)
	DangerStrong string // error emphasis — lighter red
	Accent       string // accent highlight (magenta)
	Emphasis     string // high-emphasis text (near-white)
	Muted        string // secondary text (gray)
	Dim          string // gutter/divider (dark gray)
	ToolGlyph    string // tool glyph color — hex or "" for terminal default
}

Palette holds the 13 semantic color roles used by the TUI's lipgloss styles. Each field is a hex color string (e.g. "#A78BFA") except ToolGlyph, which may be empty to indicate "use the terminal default".

type Theme

type Theme struct {
	Name       string // stable slug — the persisted key (e.g. "tokyonight")
	Palette    Palette
	Diff       DiffColors
	ChromaName string // chroma style name — must resolve via styles.Get
}

Theme is a complete color theme: a name, palette (TUI styles), diff colors, and a chroma style name for syntax highlighting.

func Active

func Active() Theme

Active returns the current theme.

Jump to

Keyboard shortcuts

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