theme

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package theme provides the color theme system for grut. Themes define all colors used throughout the TUI and are loaded from embedded TOML files (built-in) or user-supplied files on disk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuiltinNames

func BuiltinNames() []string

BuiltinNames returns the list of themes that ship with the binary.

func ListThemes

func ListThemes() []string

ListThemes returns the names of all available themes (built-in and custom). Custom themes in the theme directory are included and may shadow built-in names.

func ThemeDir

func ThemeDir() string

ThemeDir returns the path to the user's custom theme directory.

Types

type Colors

type Colors struct {
	// Base
	Background string
	Foreground string
	Cursor     string
	// ANSI normal palette
	NormalBlack   string
	NormalRed     string
	NormalGreen   string
	NormalYellow  string
	NormalBlue    string
	NormalMagenta string
	NormalCyan    string
	NormalWhite   string
	// ANSI bright palette
	BrightBlack   string
	BrightRed     string
	BrightGreen   string
	BrightYellow  string
	BrightBlue    string
	BrightMagenta string
	BrightCyan    string
	BrightWhite   string
	// UI — borders
	BorderFocused   string
	BorderUnfocused string
	// UI — status bar
	StatusBarBg string
	StatusBarFg string
	// UI — tabs
	TabActiveBg   string
	TabActiveFg   string
	TabInactiveBg string
	TabInactiveFg string
	// UI — titles
	TitleBg        string
	TitleFocusedBg string
	// UI — selection / cursor
	SelectionBg string
	SelectionFg string
	CursorLine  string
	// Syntax highlighting
	SyntaxKeyword  string
	SyntaxString   string
	SyntaxNumber   string
	SyntaxComment  string
	SyntaxFunction string
	SyntaxType     string
	SyntaxOperator string
	// Diff
	DiffAdded   string
	DiffRemoved string
	DiffContext string
	DiffHeader  string
	DiffHunk    string
	// Git status
	GitStaged    string
	GitUnstaged  string
	GitUntracked string
	GitConflict  string
	GitBranch    string
	GitTag       string
	// Notifications
	NotifyInfo    string
	NotifyWarn    string
	NotifyError   string
	NotifySuccess string
	// File types (for tree icons)
	FileDirectory  string
	FileDefault    string
	FileExecutable string
	FileSymlink    string
}

Colors defines every color slot used throughout the TUI. Values are CSS-style hex strings (#RRGGBB). Fields are populated by the TOML loader from the nested theme file format; the struct itself is kept flat so that panel code can access any colour without navigating nested types.

func (Colors) ANSIPalette

func (c Colors) ANSIPalette() [16]string

ANSIPalette returns the 16-color ANSI palette from this theme. Indices 0–7 are the normal colors (black through white), indices 8–15 are the bright variants.

func (Colors) Color

func (Colors) Color(hex string) color.Color

Color returns a lipgloss.Color (which implements image/color.Color) for the given hex string.

type Styles

type Styles struct {
	// BorderFocused is the style for a focused panel border.
	BorderFocused lipgloss.Style
	// BorderUnfocused is the style for an unfocused panel border.
	BorderUnfocused lipgloss.Style
	// StatusBar is the base style for the bottom status bar.
	StatusBar lipgloss.Style
	// Title is the style for panel titles (unfocused).
	Title lipgloss.Style
	// TitleFocused is the style for panel titles when focused.
	TitleFocused lipgloss.Style
	// Brand is the style for the application brand text in the status bar.
	Brand lipgloss.Style
	// Tab styles
	TabActive   lipgloss.Style
	TabInactive lipgloss.Style
	// Git status styles
	GitStaged    lipgloss.Style
	GitUnstaged  lipgloss.Style
	GitUntracked lipgloss.Style
	GitConflict  lipgloss.Style
	GitBranch    lipgloss.Style
	GitTag       lipgloss.Style
	// Notification styles
	NotifyInfo    lipgloss.Style
	NotifyWarn    lipgloss.Style
	NotifyError   lipgloss.Style
	NotifySuccess lipgloss.Style
	// Diff styles
	DiffAdded   lipgloss.Style
	DiffRemoved lipgloss.Style
	DiffContext lipgloss.Style
	DiffHeader  lipgloss.Style
	DiffHunk    lipgloss.Style
	// Syntax styles
	SyntaxKeyword  lipgloss.Style
	SyntaxString   lipgloss.Style
	SyntaxNumber   lipgloss.Style
	SyntaxComment  lipgloss.Style
	SyntaxFunction lipgloss.Style
	SyntaxType     lipgloss.Style
	SyntaxOperator lipgloss.Style
	// Selection styles
	Selection  lipgloss.Style
	CursorLine lipgloss.Style
}

Styles holds pre-built lipgloss styles derived from the theme Colors. Panels use these directly instead of rebuilding styles on every render.

type Theme

type Theme struct {
	Styles  Styles
	Colors  Colors
	Name    string
	Variant string
}

Theme holds the resolved color palette and pre-built lipgloss styles for the entire application. It is loaded once at startup and shared across all panels.

func Load

func Load(name string) (*Theme, error)

Load resolves a theme by name or file path and returns the fully initialised Theme with pre-built Styles.

Resolution order for plain names (no path separators):

  1. Custom theme directory (~/.config/grut/themes/{name}.toml)
  2. Built-in embedded themes

If the name looks like a file path it is read directly from disk. On any failure for a custom path, Load falls back to the "default" theme and logs a warning.

func LoadFromFile

func LoadFromFile(path string) (*Theme, error)

LoadFromFile loads a theme from a specific file path on disk. Unlike Load, it does not fall back to defaults on error.

Jump to

Keyboard shortcuts

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