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

theme

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ThemePresets = sortedPresets()

ThemePresets lists every selectable theme in the interactive t menu, in menu order: Classic first (the default), then the catalog grouped by family, then the terminal-following theme.

Functions

func DefaultIndex

func DefaultIndex() int

ThemePresets lists every selectable theme in the interactive t menu. The DefaultIndex returns the index of the Classic (Default) preset in Presets, which is the initial theme.

func DefaultIndexIn

func DefaultIndexIn(themes []ThemePreset) int

DefaultIndexIn returns the index of the Classic (Default) preset in themes.

func IDAt

func IDAt(themes []ThemePreset, index int) string

IDAt returns the stable id of the preset at index, falling back to the default when out of range.

func IndexOf

func IndexOf(themes []ThemePreset, name string) int

IndexOf resolves a persisted theme id or name to an index, tolerating a missing or stale preference after themes are renamed or removed.

Types

type Palette

type Palette struct {
	// Surfaces and text.
	Bg    string // main background
	Alt   string // panel / secondary background
	Sel   string // cursor row and selection background
	Fg    string // primary text
	Muted string // comments and secondary text; keep >= 3:1 against Bg
	Line  string // borders, tree guides, scrollbar track

	// Hues. Every theme maps its own colors onto these seven slots.
	Red, Orange, Yellow, Green, Cyan, Blue, Purple string

	// Optional overrides. Empty values fall back to the defaults noted.
	Accent   string // chrome highlight (default Blue)
	Keyword  string // default Purple
	Function string // default Blue
	Type     string // default Yellow
	String   string // default Green
	Number   string // default Orange
	Property string // default Cyan
	Operator string // default Cyan
}

Palette is the small set of colors every editor theme defines. A preset is derived from it in one place (build), so every theme maps colors to UI roles, status colors, and syntax tokens the same way. Adding a theme means filling in a Palette, nothing else.

All values are "#rrggbb" hex strings.

type StatusColors

type StatusColors struct {
	Info    lipgloss.Color
	Success lipgloss.Color
	Warning lipgloss.Color
	Error   lipgloss.Color
}

StatusColors keeps operational status separate from syntax and UI accents.

type ThemePreset

type ThemePreset struct {
	// ID is the stable persisted identity; Name remains the display label.
	ID          string
	Name        string
	Family      string
	Variant     string
	Description string
	Dark        bool
	// FollowTerminal marks a palette that intentionally uses the terminal's
	// ANSI colors instead of fixed RGB values.
	FollowTerminal bool

	Border   lipgloss.Color
	Title    lipgloss.Color
	Muted    lipgloss.Color
	CursorBg lipgloss.Color
	CursorFg lipgloss.Color
	Selected lipgloss.Color
	Notice   lipgloss.Color
	ModeFull lipgloss.Color
	ModeSig  lipgloss.Color
	ModeSkip lipgloss.Color
	// Highlight is retained for compatibility with legacy RenderLine callers.
	Highlight highlight.Palette
	// Syntax is the theme-independent semantic palette for cached previews.
	Syntax highlight.SyntaxPalette

	UI     UIColors
	Status StatusColors
}

ThemePreset is an instance-local color palette. Applying a preset rebuilds the model's own styles; it never mutates package-level state.

func LoadUserThemes

func LoadUserThemes(path string) ([]ThemePreset, error)

LoadUserThemes loads and validates custom picker themes from a TOML file. Inheriting themes are resolved against built-ins and earlier definitions.

func Normalize

func Normalize(p ThemePreset) ThemePreset

Normalize fills semantic roles from the compatibility fields and guarantees that every renderer-facing role has a concrete fallback.

type UIColors

type UIColors struct {
	Background   lipgloss.Color
	Surface      lipgloss.Color
	SurfaceAlt   lipgloss.Color
	Text         lipgloss.Color
	TextMuted    lipgloss.Color
	TextSubtle   lipgloss.Color
	Accent       lipgloss.Color
	AccentSoft   lipgloss.Color
	Border       lipgloss.Color
	BorderActive lipgloss.Color
	CursorBg     lipgloss.Color
	CursorFg     lipgloss.Color
	SelectionBg  lipgloss.Color
	SelectionFg  lipgloss.Color
	TreeGuide    lipgloss.Color
	Scrollbar    lipgloss.Color
	ModeFull     lipgloss.Color
	ModeSig      lipgloss.Color
	ModeSkip     lipgloss.Color
}

UIColors describes the semantic roles consumed by TUI renderers. Legacy preset fields remain supported and are normalized into this structure.

Directories

Path Synopsis
Command genweb derives the web theme data and CSS from the internal/theme catalog, so the browser UI never hand-maintains palettes.
Command genweb derives the web theme data and CSS from the internal/theme catalog, so the browser UI never hand-maintains palettes.

Jump to

Keyboard shortcuts

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