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
- Variables
- func Bg(color ThemeBg, text string) string
- func Bold(text string) string
- func CurrentName() string
- func Fg(color ThemeColor, text string) string
- func GetAvailableThemes() []string
- func GetDefaultTheme() string
- func GetEditorTheme() tui.EditorTheme
- func GetLanguageFromPath(filePath string) (string, bool)
- func GetMarkdownTheme() tui.MarkdownTheme
- func GetResolvedThemeColors(themeName string) map[string]string
- func GetSelectListTheme() tui.SelectListTheme
- func GetSettingsListTheme() tui.SettingsListTheme
- func HighlightCode(code string, lang string) []string
- func InitTheme(themeName string, enableWatcher bool)
- func Inverse(text string) string
- func IsLightTheme(themeName string) bool
- func Italic(text string) string
- func OnThemeChange(callback func())
- func ResolveThemeSetting(themeSetting string, terminalTheme TerminalTheme) (string, bool)
- func SetGlobalTheme(t *Theme)
- func SetRegisteredThemes(themes []*Theme)
- func SetThemeInstance(themeInstance *Theme)
- func SetThemeJsonValidator(validator ThemeJsonValidator)
- func Strikethrough(text string) string
- func Underline(text string) string
- type AutoThemePair
- type ColorMode
- type ColorValue
- type InteractiveThemeController
- func (c *InteractiveThemeController) ApplyFromSettings() error
- func (c *InteractiveThemeController) DisableAutoSync()
- func (c *InteractiveThemeController) Dispose()
- func (c *InteractiveThemeController) GetTerminalTheme() TerminalTheme
- func (c *InteractiveThemeController) GetThemeSelection() (string, bool)
- func (c *InteractiveThemeController) Preview(themeSettingOrName string)
- func (c *InteractiveThemeController) RebindTui()
- func (c *InteractiveThemeController) SetThemeInstance(themeInstance *Theme) ThemeResult
- func (c *InteractiveThemeController) SetThemeName(themeName string, showError bool) ThemeResult
- func (c *InteractiveThemeController) SetThemeSetting(themeSetting string) error
- type InteractiveThemeControllerOptions
- type PollWatcher
- type RegisteredThemeEntry
- type SetThemeResult
- type TerminalAutoThemeDetectionOptions
- type TerminalAutoThemeDetector
- type TerminalBackgroundThemeDetectionOptions
- type TerminalBackgroundThemeDetector
- type TerminalTheme
- type TerminalThemeDetection
- type TerminalThemeDetectionOptions
- type Theme
- func (t *Theme) Bg(color ThemeBg, text string) string
- func (t *Theme) Bold(text string) string
- func (t *Theme) Fg(color ThemeColor, text string) string
- func (t *Theme) GetBashModeBorderColor() func(string) string
- func (t *Theme) GetBgAnsi(color ThemeBg) string
- func (t *Theme) GetColorMode() ColorMode
- func (t *Theme) GetFgAnsi(color ThemeColor) string
- func (t *Theme) GetName() string
- func (t *Theme) GetSourcePath() string
- func (t *Theme) GetThinkingBorderColor(level agent.ThinkingLevel) func(string) string
- func (t *Theme) Inverse(text string) string
- func (t *Theme) Italic(text string) string
- func (t *Theme) Strikethrough(text string) string
- func (t *Theme) Underline(text string) string
- type ThemeBg
- type ThemeColor
- type ThemeControllerTUI
- type ThemeExportColors
- type ThemeExportJson
- type ThemeInfo
- type ThemeJson
- type ThemeJsonValidator
- type ThemeOptions
- type ThemeResult
- type ThemeSettingsManager
Constants ¶
const FSWatchRetryDelayMs = utils.FSWatchRetryDelayMs
FSWatchRetryDelayMs is pi's FS_WATCH_RETRY_DELAY_MS.
Variables ¶
var CloseWatcher = utils.CloseWatcher
CloseWatcher stops a watcher, ignoring nil and close errors (pi: closeWatcher).
var WatchWithErrorHandler = utils.WatchWithErrorHandler
WatchWithErrorHandler polls path for mtime/size changes and invokes onChange; poll-setup errors invoke onError and return nil.
Functions ¶
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 ¶
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 ¶
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 ¶
HighlightCode highlights code with syntax coloring based on language (pi: highlightCode).
func InitTheme ¶
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 IsLightTheme ¶
IsLightTheme reports whether the named theme is light (pi: isLightTheme).
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 ¶
Strikethrough styles text with the global theme (pi: theme.strikethrough).
Types ¶
type AutoThemePair ¶
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 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 ¶
RegisteredThemeEntry is one registeredThemes snapshot item.
type SetThemeResult ¶
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 ¶
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 ¶
GetThemeByName loads a theme by name, returning nil when it cannot be loaded (pi: getThemeByName).
func LoadThemeFromPath ¶
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 ¶
Bg wraps text in the token's background color, resetting only the background (pi: bg).
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 ¶
GetBashModeBorderColor returns the bash-mode border colorizer (pi: getBashModeBorderColor).
func (*Theme) GetBgAnsi ¶
GetBgAnsi returns the raw ANSI prefix for a background token (pi: getBgAnsi).
func (*Theme) GetColorMode ¶
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) GetSourcePath ¶
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) Strikethrough ¶
Strikethrough mirrors chalk.strikethrough.
type ThemeBg ¶
type ThemeBg = string
ThemeBg names a background color token (pi: ThemeBg union). Alias for the same reason as ThemeColor.
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.