theme

package
v0.85.1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

fs_watch.go (pi: src/modes/interactive/theme — theme file watching).

pig keeps the poll-watcher implementation in codingagent/utils (pi keeps it in src/utils/fs-watch.ts, shared with the footer git watcher); these aliases preserve the theme package's internal call sites.

Package theme (pi: src/modes/interactive/theme/theme.ts) — the Theme class, color utilities, theme loading/registry, the global theme instance, terminal theme detection, HTML export helpers and the TUI theme adapters.

Declared deviations:

  • pi stores the global theme on globalThis (cross module-loader sharing); pig uses package state guarded by a mutex. Package-level functions (Fg/Bg/Bold/...) delegate to Current(), keeping call sites shaped like pi's `theme.fg(...)` proxy.
  • pi's chalk.bold/italic/... are hand-rolled ANSI here (repo-wide precedent: chalk is not ported; test_themes_test.go hand-writes level-3 bytes).
  • The theme file watcher polls the watched theme file (Go has no fs.watch); pi's dir watcher + filename filter collapses to a watched-file mtime poll. The 100ms reload debounce is preserved.
  • Validation is a hand-written equivalent of the TypeBox schema (model-config precedent). Missing-color diagnostics keep pi's formatting; other type-error wording is approximate (no pi test locks it).
  • Syntax highlighting delegates to codingagent/utils (chroma backend; see syntax_highlight.go for the deviation record).
  • Broken built-in theme JSON surfaces as a panic in InitTheme/SetTheme fallback paths, matching pi's synchronous throw out of the catch block (both are fatal at startup).

theme_controller.go (pi: src/modes/interactive/theme/theme-controller.ts).

The controller declares a narrow TUI consumption-face interface (ThemeControllerTUI) instead of pi's full TUI type — repo precedent: ModelResolverRuntime. tui.TUI satisfies it; tests stub it.

pi's async controller methods (applyFromSettings/setThemeSetting) become blocking calls with error returns; the terminal queries are blocking (see theme.go detection deviations).

theme_json.go (pi: theme/theme-json.ts, v0.85.1) — theme JSON validation, kept out of `theme.go` on purpose.

pi moves full validation out of theme.ts so that presentations which only use built-in themes never pay the typebox import (~17 MB of module graph). `interactive-mode` installs this validator; anything that does not simply skips validation, as built-in themes already do. In Go the cost is a hand-written validator instead of typebox, but the seam is kept 1:1 so the consumption shape matches: theme.go's parseThemeJson consults the installed validator and otherwise performs a minimal structural check.

Index

Constants

View Source
const FSWatchRetryDelayMs = utils.FSWatchRetryDelayMs

FSWatchRetryDelayMs is pi's FS_WATCH_RETRY_DELAY_MS.

Variables

View Source
var CloseWatcher = utils.CloseWatcher

CloseWatcher stops a watcher, ignoring nil and close errors (pi: closeWatcher).

View Source
var WatchWithErrorHandler = utils.WatchWithErrorHandler

WatchWithErrorHandler polls path for mtime/size changes and invokes onChange; poll-setup errors invoke onError and return nil.

Functions

func Bg

func Bg(color ThemeBg, text string) string

Bg colors text with the global theme (pi: theme.bg).

func Bold

func Bold(text string) string

Bold styles text with the global theme (pi: theme.bold).

func CurrentName

func CurrentName() string

CurrentName returns the active theme name ("" = unset; pi: currentThemeName module state, exposed for controller consumption).

func Fg

func Fg(color ThemeColor, text string) string

Fg colors text with the global theme (pi: theme.fg).

func GetAvailableThemes

func GetAvailableThemes() []string

func GetDefaultTheme

func GetDefaultTheme() string

GetDefaultTheme returns the env-detected default theme name (pi: getDefaultTheme).

func GetEditorTheme

func GetEditorTheme() tui.EditorTheme

GetEditorTheme builds the editor theme (pi: getEditorTheme).

func GetLanguageFromPath

func GetLanguageFromPath(filePath string) (string, bool)

GetLanguageFromPath maps a file extension to a language identifier (pi: getLanguageFromPath).

func GetMarkdownTheme

func GetMarkdownTheme() tui.MarkdownTheme

GetMarkdownTheme builds the Markdown theme from the global theme (pi: getMarkdownTheme).

func GetResolvedThemeColors

func GetResolvedThemeColors(themeName string) map[string]string

GetResolvedThemeColors returns the resolved theme colors as CSS-compatible hex strings (pi: getResolvedThemeColors). Panics when the theme cannot be loaded, matching pi's unguarded loadThemeJson.

func GetSelectListTheme

func GetSelectListTheme() tui.SelectListTheme

GetSelectListTheme builds the select-list theme (pi: getSelectListTheme).

func GetSettingsListTheme

func GetSettingsListTheme() tui.SettingsListTheme

GetSettingsListTheme builds the settings-list theme (pi: getSettingsListTheme).

func HighlightCode

func HighlightCode(code string, lang string) []string

HighlightCode highlights code with syntax coloring based on language (pi: highlightCode).

func InitTheme

func InitTheme(themeName string, enableWatcher bool)

InitTheme loads and installs the named theme ("" = env-detected default), falling back to dark silently (pi: initTheme). enableWatcher starts the custom-theme file watcher.

func Inverse

func Inverse(text string) string

Inverse styles text with the global theme (pi: theme.inverse).

func IsLightTheme

func IsLightTheme(themeName string) bool

IsLightTheme reports whether the named theme is light (pi: isLightTheme).

func Italic

func Italic(text string) string

Italic styles text with the global theme (pi: theme.italic).

func OnThemeChange

func OnThemeChange(callback func())

OnThemeChange registers the change callback (pi: onThemeChange).

func ResolveThemeSetting

func ResolveThemeSetting(themeSetting string, terminalTheme TerminalTheme) (string, bool)

ResolveThemeSetting resolves a theme setting against the detected terminal appearance (pi: resolveThemeSetting).

func SetGlobalTheme

func SetGlobalTheme(t *Theme)

SetGlobalTheme installs a theme instance (pi: setGlobalTheme — private, exported for SetThemeInstance's cross-package consumers and tests).

func SetRegisteredThemes

func SetRegisteredThemes(themes []*Theme)

SetRegisteredThemes replaces the extension/theme-loader registered themes (pi: setRegisteredThemes).

func SetThemeInstance

func SetThemeInstance(themeInstance *Theme)

SetThemeInstance installs a direct theme instance (pi: setThemeInstance).

func SetThemeJsonValidator

func SetThemeJsonValidator(validator ThemeJsonValidator)

SetThemeJsonValidator installs full theme validation (pi: setThemeJsonValidator). Without it, documents are accepted as-is, which is what built-in themes already do.

func Strikethrough

func Strikethrough(text string) string

Strikethrough styles text with the global theme (pi: theme.strikethrough).

func Underline

func Underline(text string) string

Underline styles text with the global theme (pi: theme.underline).

Types

type AutoThemePair

type AutoThemePair struct {
	LightTheme string
	DarkTheme  string
}

AutoThemePair is parseAutoThemeSetting's resolved pair.

func ParseAutoThemeSetting

func ParseAutoThemeSetting(themeSetting string) *AutoThemePair

ParseAutoThemeSetting parses "<light>/<dark>" theme settings (pi: parseAutoThemeSetting). Returns nil for unset/invalid settings.

type ColorMode

type ColorMode string

ColorMode is the ANSI encoding mode (pi: ColorMode).

const (
	ColorModeTruecolor ColorMode = "truecolor"
	ColorMode256       ColorMode = "256color"
)

type ColorValue

type ColorValue = any

ColorValue is a theme color value: a hex string ("#ff0000"), a variable reference ("primary"), an empty string (terminal default), or a 256-color index (pi: ColorValue = string | int).

type InteractiveThemeController

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

InteractiveThemeController manages the global theme for the interactive session (pi: class InteractiveThemeController).

func NewInteractiveThemeController

func NewInteractiveThemeController(ui ThemeControllerTUI, options InteractiveThemeControllerOptions) *InteractiveThemeController

NewInteractiveThemeController builds the controller (pi: constructor).

func (*InteractiveThemeController) ApplyFromSettings

func (c *InteractiveThemeController) ApplyFromSettings() error

ApplyFromSettings resolves the theme from the current setting and applies it (pi: applyFromSettings).

func (*InteractiveThemeController) DisableAutoSync

func (c *InteractiveThemeController) DisableAutoSync()

DisableAutoSync turns off light/dark auto sync (pi: disableAutoSync).

func (*InteractiveThemeController) Dispose

func (c *InteractiveThemeController) Dispose()

Dispose stops terminal appearance updates and drops the color-scheme listener subscription (pi: dispose, v0.85.1).

func (*InteractiveThemeController) GetTerminalTheme

func (c *InteractiveThemeController) GetTerminalTheme() TerminalTheme

GetTerminalTheme returns the detected terminal appearance (pi: getTerminalTheme).

func (*InteractiveThemeController) GetThemeSelection

func (c *InteractiveThemeController) GetThemeSelection() (string, bool)

GetThemeSelection returns the effective theme setting (pi: getThemeSelection; second return false = undefined).

func (*InteractiveThemeController) Preview

func (c *InteractiveThemeController) Preview(themeSettingOrName string)

Preview applies a theme without persisting the selection (pi: preview).

func (*InteractiveThemeController) RebindTui

func (c *InteractiveThemeController) RebindTui()

RebindTui re-subscribes the color-scheme listener after a TUI swap (pi: rebindTui).

func (*InteractiveThemeController) SetThemeInstance

func (c *InteractiveThemeController) SetThemeInstance(themeInstance *Theme) ThemeResult

SetThemeInstance installs a direct theme instance (pi: setThemeInstance).

func (*InteractiveThemeController) SetThemeName

func (c *InteractiveThemeController) SetThemeName(themeName string, showError bool) ThemeResult

SetThemeName selects a theme explicitly (pi: setThemeName).

func (*InteractiveThemeController) SetThemeSetting

func (c *InteractiveThemeController) SetThemeSetting(themeSetting string) error

SetThemeSetting persists and applies a theme setting (pi: setThemeSetting).

type InteractiveThemeControllerOptions

type InteractiveThemeControllerOptions struct {
	GetSettingsManager  func() ThemeSettingsManager
	ShowError           func(message string)
	OnChanged           func()
	InitialThemeSetting string
}

InteractiveThemeControllerOptions carries the constructor's callbacks (pi: options object; initialThemeSetting "" = undefined).

type PollWatcher

type PollWatcher = utils.PollWatcher

PollWatcher is pi's FSWatcher (pig: mtime/size polling watcher).

type RegisteredThemeEntry

type RegisteredThemeEntry struct {
	Name       string
	Theme      *Theme
	SourcePath string
}

RegisteredThemeEntry is one registeredThemes snapshot item.

type SetThemeResult

type SetThemeResult struct {
	Success bool
	Error   string
}

SetThemeResult is pi's { success: boolean; error?: string }.

func SetTheme

func SetTheme(name string, enableWatcher bool) SetThemeResult

SetTheme switches the global theme by name (pi: setTheme).

type TerminalAutoThemeDetectionOptions

type TerminalAutoThemeDetectionOptions struct {
	Ui        TerminalAutoThemeDetector
	TimeoutMs int
	Env       map[string]string
}

TerminalAutoThemeDetectionOptions carries the auto detector, timeout and env (pi: same-named interface).

type TerminalAutoThemeDetector

type TerminalAutoThemeDetector interface {
	TerminalBackgroundThemeDetector
	QueryTerminalColorScheme(timeoutMs int) (*TerminalTheme, error)
}

TerminalAutoThemeDetector is pi's TerminalAutoThemeDetector (queryTerminalColorScheme is an optional member → capability interface).

func TuiThemeDetector

func TuiThemeDetector(ui ThemeControllerTUI) TerminalAutoThemeDetector

TuiThemeDetector adapts any tui.TUI to the theme detection interfaces (pig addition for the startup-ui/interactive-mode callers; pi passes the TUI directly).

type TerminalBackgroundThemeDetectionOptions

type TerminalBackgroundThemeDetectionOptions struct {
	Ui        TerminalBackgroundThemeDetector
	TimeoutMs int
	Env       map[string]string
}

TerminalBackgroundThemeDetectionOptions carries the detector, timeout and env (pi: same-named interface).

type TerminalBackgroundThemeDetector

type TerminalBackgroundThemeDetector interface {
	QueryTerminalBackgroundColor(timeoutMs int) (*tui.RgbColor, error)
}

TerminalBackgroundThemeDetector is pi's TerminalBackgroundThemeDetector. The blocking query replaces pi's promise; a nil color with nil error is pi's `undefined` result, an error is pi's rejection.

type TerminalTheme

type TerminalTheme string

TerminalTheme is "dark" | "light" (pi: TerminalTheme).

const (
	TerminalThemeDark  TerminalTheme = "dark"
	TerminalThemeLight TerminalTheme = "light"
)

func DetectTerminalThemeForAuto

func DetectTerminalThemeForAuto(options TerminalAutoThemeDetectionOptions) TerminalTheme

DetectTerminalThemeForAuto prefers the terminal's color-scheme report and falls back to background detection (pi: detectTerminalThemeForAuto). Declared deviation: pi starts both queries concurrently; pig's blocking detector interface serializes them (color-scheme first, background as fallback).

func GetThemeForRgbColor

func GetThemeForRgbColor(rgbColor tui.RgbColor) TerminalTheme

GetThemeForRgbColor classifies a background color by luminance (pi: getThemeForRgbColor).

type TerminalThemeDetection

type TerminalThemeDetection struct {
	Theme      TerminalTheme
	Source     string // "terminal background" | "COLORFGBG" | "fallback"
	Detail     string
	Confidence string // "high" | "low"
}

TerminalThemeDetection is pi's TerminalThemeDetection.

func DetectTerminalBackgroundFromEnv

func DetectTerminalBackgroundFromEnv(options *TerminalThemeDetectionOptions) TerminalThemeDetection

DetectTerminalBackgroundFromEnv detects the terminal appearance from environment hints (pi: detectTerminalBackgroundFromEnv).

func DetectTerminalBackgroundTheme

func DetectTerminalBackgroundTheme(options TerminalBackgroundThemeDetectionOptions) TerminalThemeDetection

DetectTerminalBackgroundTheme queries the terminal background and falls back to environment hints (pi: detectTerminalBackgroundTheme).

type TerminalThemeDetectionOptions

type TerminalThemeDetectionOptions struct {
	Env map[string]string
}

TerminalThemeDetectionOptions carries the env override (pi: { env? }; nil = process environment).

type Theme

type Theme struct {

	// SourceInfo is assigned by the resource loader (pi: sourceInfo?).
	SourceInfo *utils.SourceInfo
	// contains filtered or unexported fields
}

Theme is the resolved theme (pi: class Theme).

func Current

func Current() *Theme

Current returns the active global theme. It panics when the theme has not been initialized, matching pi's proxy throw.

func GetThemeByName

func GetThemeByName(name string) *Theme

GetThemeByName loads a theme by name, returning nil when it cannot be loaded (pi: getThemeByName).

func LoadThemeFromPath

func LoadThemeFromPath(themePath string, mode ColorMode) (*Theme, error)

LoadThemeFromPath loads and validates a theme file (pi: loadThemeFromPath). mode "" = auto-detect from terminal capabilities.

func NewTheme

func NewTheme(fgColors map[string]ColorValue, bgColors map[string]ColorValue, mode ColorMode, options *ThemeOptions) (*Theme, error)

NewTheme builds a theme from resolved color values (pi: constructor). fgColors/bgColors values are string (hex/""/var-resolved) or int (256-color index).

func (*Theme) Bg

func (t *Theme) Bg(color ThemeBg, text string) string

Bg wraps text in the token's background color, resetting only the background (pi: bg).

func (*Theme) Bold

func (t *Theme) Bold(text string) string

Bold mirrors chalk.bold.

func (*Theme) Fg

func (t *Theme) Fg(color ThemeColor, text string) string

Fg wraps text in the token's foreground color, resetting only the foreground (pi: fg).

func (*Theme) GetBashModeBorderColor

func (t *Theme) GetBashModeBorderColor() func(string) string

GetBashModeBorderColor returns the bash-mode border colorizer (pi: getBashModeBorderColor).

func (*Theme) GetBgAnsi

func (t *Theme) GetBgAnsi(color ThemeBg) string

GetBgAnsi returns the raw ANSI prefix for a background token (pi: getBgAnsi).

func (*Theme) GetColorMode

func (t *Theme) GetColorMode() ColorMode

GetColorMode returns the ANSI mode (pi: getColorMode).

func (*Theme) GetFgAnsi

func (t *Theme) GetFgAnsi(color ThemeColor) string

GetFgAnsi returns the raw ANSI prefix for a foreground token (pi: getFgAnsi).

func (*Theme) GetName

func (t *Theme) GetName() string

GetName returns the theme name ("" = unnamed, pi: name?).

func (*Theme) GetSourcePath

func (t *Theme) GetSourcePath() string

GetSourcePath returns the source path ("" = none, pi: sourcePath?).

func (*Theme) GetThinkingBorderColor

func (t *Theme) GetThinkingBorderColor(level agent.ThinkingLevel) func(string) string

GetThinkingBorderColor maps thinking levels to dedicated theme colors (pi: getThinkingBorderColor).

func (*Theme) Inverse

func (t *Theme) Inverse(text string) string

Inverse mirrors chalk.inverse.

func (*Theme) Italic

func (t *Theme) Italic(text string) string

Italic mirrors chalk.italic.

func (*Theme) Strikethrough

func (t *Theme) Strikethrough(text string) string

Strikethrough mirrors chalk.strikethrough.

func (*Theme) Underline

func (t *Theme) Underline(text string) string

Underline mirrors chalk.underline.

type ThemeBg

type ThemeBg = string

ThemeBg names a background color token (pi: ThemeBg union). Alias for the same reason as ThemeColor.

const (
	BgSelectedBg      ThemeBg = "selectedBg"
	BgSearchMatchBg   ThemeBg = "searchMatchBg"
	BgUserMessageBg   ThemeBg = "userMessageBg"
	BgCustomMessageBg ThemeBg = "customMessageBg"
	BgToolPendingBg   ThemeBg = "toolPendingBg"
	BgToolSuccessBg   ThemeBg = "toolSuccessBg"
	BgToolErrorBg     ThemeBg = "toolErrorBg"
)

type ThemeColor

type ThemeColor = string

ThemeColor names a foreground color token (pi: ThemeColor union). Declared deviation: a string alias (not a named type) so that *Theme structurally satisfies core.UITheme — package core cannot import this package (theme → core for SourceInfo), so renderer signatures in core accept the structural interface.

const (
	ColorAccent             ThemeColor = "accent"
	ColorBorder             ThemeColor = "border"
	ColorBorderAccent       ThemeColor = "borderAccent"
	ColorBorderMuted        ThemeColor = "borderMuted"
	ColorSuccess            ThemeColor = "success"
	ColorError              ThemeColor = "error"
	ColorWarning            ThemeColor = "warning"
	ColorMuted              ThemeColor = "muted"
	ColorDim                ThemeColor = "dim"
	ColorText               ThemeColor = "text"
	ColorThinkingText       ThemeColor = "thinkingText"
	ColorSearchMatchText    ThemeColor = "searchMatchText"
	ColorUserMessageText    ThemeColor = "userMessageText"
	ColorCustomMessageText  ThemeColor = "customMessageText"
	ColorCustomMessageLabel ThemeColor = "customMessageLabel"
	ColorToolTitle          ThemeColor = "toolTitle"
	ColorToolOutput         ThemeColor = "toolOutput"
	ColorMdHeading          ThemeColor = "mdHeading"
	ColorMdLink             ThemeColor = "mdLink"
	ColorMdLinkUrl          ThemeColor = "mdLinkUrl"
	ColorMdCode             ThemeColor = "mdCode"
	ColorMdCodeBlock        ThemeColor = "mdCodeBlock"
	ColorMdCodeBlockBorder  ThemeColor = "mdCodeBlockBorder"
	ColorMdQuote            ThemeColor = "mdQuote"
	ColorMdQuoteBorder      ThemeColor = "mdQuoteBorder"
	ColorMdHr               ThemeColor = "mdHr"
	ColorMdListBullet       ThemeColor = "mdListBullet"
	ColorToolDiffAdded      ThemeColor = "toolDiffAdded"
	ColorToolDiffRemoved    ThemeColor = "toolDiffRemoved"
	ColorToolDiffContext    ThemeColor = "toolDiffContext"
	ColorSyntaxComment      ThemeColor = "syntaxComment"
	ColorSyntaxKeyword      ThemeColor = "syntaxKeyword"
	ColorSyntaxFunction     ThemeColor = "syntaxFunction"
	ColorSyntaxVariable     ThemeColor = "syntaxVariable"
	ColorSyntaxString       ThemeColor = "syntaxString"
	ColorSyntaxNumber       ThemeColor = "syntaxNumber"
	ColorSyntaxType         ThemeColor = "syntaxType"
	ColorSyntaxOperator     ThemeColor = "syntaxOperator"
	ColorSyntaxPunctuation  ThemeColor = "syntaxPunctuation"
	ColorThinkingOff        ThemeColor = "thinkingOff"
	ColorThinkingMinimal    ThemeColor = "thinkingMinimal"
	ColorThinkingLow        ThemeColor = "thinkingLow"
	ColorThinkingMedium     ThemeColor = "thinkingMedium"
	ColorThinkingHigh       ThemeColor = "thinkingHigh"
	ColorThinkingXhigh      ThemeColor = "thinkingXhigh"
	ColorThinkingMax        ThemeColor = "thinkingMax"
	ColorBashMode           ThemeColor = "bashMode"
	// Scrollbar colors are foreground tokens as of v0.85.1 (pi: moved
	// scrollbarThumb from ThemeBg to ThemeColor and added scrollbarTrack; both
	// optional, falling back to muted/text).
	ColorScrollbarTrack ThemeColor = "scrollbarTrack"
	ColorScrollbarThumb ThemeColor = "scrollbarThumb"
	// ImagePlaceholder is a pig-only optional token (pi has no equivalent):
	// colors the [Image N] clipboard-paste placeholder in the editor
	// (docs/feat/CLIPBOARD-IMAGE-PLACEHOLDER.md). Optional, falling back to
	// accent for themes that do not define it.
	ColorImagePlaceholder ThemeColor = "imagePlaceholder"
)

type ThemeControllerTUI

type ThemeControllerTUI interface {
	Invalidate()
	RequestRender(force bool)
	SetTerminalColorSchemeNotifications(enabled bool)
	OnTerminalColorSchemeChange(listener func(scheme tui.TerminalColorScheme)) func()
	QueryTerminalBackgroundColor(timeoutMs int) *tui.RgbColor
	QueryTerminalColorScheme(timeoutMs int) *tui.TerminalColorScheme
}

ThemeControllerTUI is the TUI surface consumed by the controller (pi: TUI used via invalidate/requestRender/setTerminalColorSchemeNotifications/ onTerminalColorSchemeChange/queryTerminalColorScheme; queryTerminalBackgroundColor reaches the detector through DetectTerminalBackgroundTheme).

type ThemeExportColors

type ThemeExportColors struct {
	PageBg string
	CardBg string
	InfoBg string
}

ThemeExportColors is pi's { pageBg?, cardBg?, infoBg? } ("" = unset).

func GetThemeExportColors

func GetThemeExportColors(themeName string) ThemeExportColors

GetThemeExportColors reads the explicit export colors from a theme's export section, resolving variable references (pi: getThemeExportColors). Unset colors are "" (pi: undefined); load failures yield the zero struct (pi: {}).

type ThemeExportJson

type ThemeExportJson struct {
	PageBg ColorValue `json:"pageBg,omitempty"`
	CardBg ColorValue `json:"cardBg,omitempty"`
	InfoBg ColorValue `json:"infoBg,omitempty"`
}

ThemeExportJson is the optional export section (pi: export).

type ThemeInfo

type ThemeInfo struct {
	Name string
	Path string // "" = none (pi: path?: string)
}

ThemeInfo is pi's ThemeInfo.

func GetAvailableThemesWithPaths

func GetAvailableThemesWithPaths() []ThemeInfo

type ThemeJson

type ThemeJson struct {
	Schema string                `json:"$schema,omitempty"`
	Name   string                `json:"name"`
	Vars   map[string]ColorValue `json:"vars,omitempty"`
	Colors map[string]ColorValue `json:"colors"`
	Export *ThemeExportJson      `json:"export,omitempty"`
}

ThemeJson mirrors the theme JSON schema (pi: ThemeJsonSchema/ThemeJson).

func ValidateThemeJson

func ValidateThemeJson(label string, parsed any) (*ThemeJson, error)

ValidateThemeJson hand-validates the theme schema (pi: validateThemeJson in theme-json.ts; pig hand-writes the TypeBox shape). Missing required colors keep pi's diagnostic formatting; the theme name may not contain "/".

type ThemeJsonValidator

type ThemeJsonValidator = func(label string, json any) (*ThemeJson, error)

ThemeJsonValidator validates one theme document (pi: ThemeJsonValidator).

type ThemeOptions

type ThemeOptions struct {
	Name       string
	SourcePath string
	SourceInfo *utils.SourceInfo
}

ThemeOptions carries the constructor's optional fields (pi: options object; "" = undefined).

type ThemeResult

type ThemeResult struct {
	Success bool
	Error   string
}

ThemeResult is pi's ThemeResult = { success: boolean; error?: string }.

type ThemeSettingsManager

type ThemeSettingsManager interface {
	// GetThemeSetting is pi's settingsManager.getThemeSetting().
	GetThemeSetting() (string, bool)
	// SetTheme is pi's settingsManager.setTheme().
	SetTheme(theme string)
	// Flush is pi's settingsManager.flush().
	Flush()
}

ThemeSettingsManager is the SettingsManager surface the controller consumes (pi: SettingsManager). Declared deviation: package theme cannot import core (core → core/tools → theme would cycle); *core.SettingsManager satisfies this interface structurally.

Jump to

Keyboard shortcuts

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