Documentation
¶
Index ¶
- Variables
- func Ansi256ToHex(index int) string
- func BuiltinThemeJSON(name string) ([]byte, bool)
- func BuiltinThemeNames() []string
- func ClearMermaidCache()
- func DefaultThemeName() string
- func DetectTerminalBackground() string
- func HasPendingMermaid(markdown string) bool
- func IsLightTheme(themeName string) bool
- func LangByExtension(ext string) (highlight, vscode string, ok bool)
- func LanguageFromPath(path string) string
- func ListThemeNames() ([]string, error)
- func MermaidASCII(hash uint64) string
- func PrerenderMermaid(markdown string)
- func ResolvedThemeColors(themeName string) (map[string]string, error)
- func SetMermaidASCII(hash uint64, ascii string)
- func SetMermaidRenderHook(fn func())
- func ThemesDir() string
- func ValidSymbolPreset(s string) bool
- func ValidThemeBg(name string) bool
- func ValidThemeColor(name string) bool
- type ColorMode
- type ResolvedColor
- type SpinnerType
- type SymbolPreset
- type Theme
- func (t *Theme) BashModeBorderColor() func(string) string
- func (t *Theme) Bg(bg ThemeBg, text string) string
- func (t *Theme) BgANSI(bg ThemeBg) string
- func (t *Theme) Bold(text string) string
- func (t *Theme) ColorMode() ColorMode
- func (t *Theme) Fg(color ThemeColor, text string) string
- func (t *Theme) FgANSI(color ThemeColor) string
- func (t *Theme) InputCursor() string
- func (t *Theme) Inverse(text string) string
- func (t *Theme) Italic(text string) string
- func (t *Theme) LangIcon(lang string) string
- func (t *Theme) PythonModeBorderColor() func(string) string
- func (t *Theme) SpinnerFrames(kind SpinnerType) []string
- func (t *Theme) Strikethrough(text string) string
- func (t *Theme) StyledSymbol(key string, color ThemeColor) string
- func (t *Theme) Symbol(key string) string
- func (t *Theme) SymbolPreset() SymbolPreset
- func (t *Theme) ThinkingBorderColor(level string) func(string) string
- func (t *Theme) Underline(text string) string
- type ThemeBg
- type ThemeColor
- type ThemeConfig
- type ThemeExport
- type ThemeExportColors
- type ThemeFile
- type ThemeOption
- type ThemeSymbols
Constants ¶
This section is empty.
Variables ¶
var ExtensionLang = map[string][2]string{}/* 162 elements not displayed */
ExtensionLang maps a file extension (without leading dot, typically lowercase) to [highlight grammar id, VS Code language id].
var SymbolMap = UnicodeSymbolMap
SymbolMap is an alias of UnicodeSymbolMap for backward compatibility.
var UnicodeSymbolMap = map[string]string{}/* 141 elements not displayed */
UnicodeSymbolMap is the default Unicode / emoji-heavy symbol table.
Functions ¶
func Ansi256ToHex ¶ added in v0.5.0
Ansi256ToHex converts a 256-color index to #RRGGBB for HTML/CSS.
func BuiltinThemeJSON ¶ added in v0.5.0
BuiltinThemeJSON returns raw JSON bytes for an embedded theme name (e.g. "dark", "alabaster").
func BuiltinThemeNames ¶ added in v0.5.0
func BuiltinThemeNames() []string
BuiltinThemeNames returns sorted embedded theme base names (filename without .json).
func ClearMermaidCache ¶ added in v0.5.0
func ClearMermaidCache()
ClearMermaidCache drops all cached diagrams.
func DefaultThemeName ¶ added in v0.5.0
func DefaultThemeName() string
DefaultThemeName picks "light" or "dark" from DetectTerminalBackground.
func DetectTerminalBackground ¶ added in v0.5.0
func DetectTerminalBackground() string
DetectTerminalBackground returns "dark" or "light" using COLORFGBG when present (simple heuristic).
func HasPendingMermaid ¶ added in v0.5.0
HasPendingMermaid always reports false until a real extractor is wired.
func IsLightTheme ¶ added in v0.5.0
IsLightTheme reports whether userMessageBg resolves to a light background (luminance > 0.5).
func LangByExtension ¶
LangByExtension returns highlight and VS Code language ids for ext (without dot).
func LanguageFromPath ¶ added in v0.5.0
LanguageFromPath returns the highlight grammar id for a file path (from extension), or "" if unknown.
func ListThemeNames ¶ added in v0.5.0
ListThemeNames returns builtin names plus any *.json in ThemesDir (sorted, unique).
func MermaidASCII ¶ added in v0.5.0
MermaidASCII returns cached ASCII for a content hash, or empty string if missing.
func PrerenderMermaid ¶ added in v0.5.0
func PrerenderMermaid(markdown string)
PrerenderMermaid is a no-op placeholder; extend with a Mermaid → ASCII pipeline as needed.
func ResolvedThemeColors ¶ added in v0.5.0
ResolvedThemeColors returns theme colors as #RRGGBB (or fallback for empty / index colors) for CSS.
func SetMermaidASCII ¶ added in v0.5.0
SetMermaidASCII stores prerendered ASCII for a hash (replace prior value).
func SetMermaidRenderHook ¶ added in v0.5.0
func SetMermaidRenderHook(fn func())
SetMermaidRenderHook registers a callback invoked when new diagrams might be available.
func ThemesDir ¶ added in v0.5.0
func ThemesDir() string
ThemesDir returns the directory for user-defined themes (override with FASTTUI_THEMES_DIR).
func ValidSymbolPreset ¶ added in v0.5.0
ValidSymbolPreset reports whether s is a known preset name.
func ValidThemeBg ¶ added in v0.5.0
ValidThemeBg reports whether name is a known background theme token.
func ValidThemeColor ¶ added in v0.5.0
ValidThemeColor reports whether name is a known foreground theme token.
Types ¶
type ColorMode ¶ added in v0.5.0
type ColorMode string
ColorMode selects truecolor vs 256-color ANSI output.
func DetectColorMode ¶ added in v0.5.0
func DetectColorMode() ColorMode
DetectColorMode mirrors the TypeScript terminal heuristic.
type ResolvedColor ¶ added in v0.5.0
ResolvedColor is either a hex/default string or a 256-color index.
type SpinnerType ¶ added in v0.5.0
type SpinnerType string
SpinnerType selects spinner animation sets.
const ( SpinnerStatus SpinnerType = "status" SpinnerActivity SpinnerType = "activity" )
type SymbolPreset ¶ added in v0.5.0
type SymbolPreset string
SymbolPreset selects which glyph set to use for UI symbols.
const ( SymbolPresetUnicode SymbolPreset = "unicode" SymbolPresetNerd SymbolPreset = "nerd" SymbolPresetAscii SymbolPreset = "ascii" )
func AvailableSymbolPresets ¶ added in v0.5.0
func AvailableSymbolPresets() []SymbolPreset
AvailableSymbolPresets lists supported symbol presets.
type Theme ¶ added in v0.5.0
type Theme struct {
// contains filtered or unexported fields
}
Theme holds resolved ANSI sequences and the active symbol table.
func LoadTheme ¶ added in v0.5.0
func LoadTheme(name string, opts ...ThemeOption) (*Theme, error)
LoadTheme is shorthand for LoadThemeFile + NewTheme with options.
func NewTheme ¶ added in v0.5.0
func NewTheme(tf *ThemeFile, opts ...ThemeOption) (*Theme, error)
NewTheme builds a Theme from validated theme data.
func (*Theme) BashModeBorderColor ¶ added in v0.5.0
BashModeBorderColor colors text with the bash-mode border token.
func (*Theme) Bg ¶ added in v0.5.0
Bg paints text with a background theme token and resets only the background color.
func (*Theme) ColorMode ¶ added in v0.5.0
ColorMode returns the color mode used to build this theme.
func (*Theme) Fg ¶ added in v0.5.0
func (t *Theme) Fg(color ThemeColor, text string) string
Fg paints text with a foreground theme token and resets only the foreground color.
func (*Theme) FgANSI ¶ added in v0.5.0
func (t *Theme) FgANSI(color ThemeColor) string
FgANSI returns the raw ANSI sequence for a foreground token.
func (*Theme) InputCursor ¶ added in v0.5.0
InputCursor returns the cursor glyph used in text inputs (matches TS ascii vs unicode rule).
func (*Theme) LangIcon ¶ added in v0.5.0
LangIcon returns the icon string for a language id or file extension token.
func (*Theme) PythonModeBorderColor ¶ added in v0.5.0
PythonModeBorderColor colors text with the python-mode border token.
func (*Theme) SpinnerFrames ¶ added in v0.5.0
func (t *Theme) SpinnerFrames(kind SpinnerType) []string
SpinnerFrames returns spinner animation frames for the given spinner kind.
func (*Theme) Strikethrough ¶ added in v0.5.0
Strikethrough wraps text with ANSI strikethrough.
func (*Theme) StyledSymbol ¶ added in v0.5.0
func (t *Theme) StyledSymbol(key string, color ThemeColor) string
StyledSymbol returns a symbol wrapped in a foreground color.
func (*Theme) Symbol ¶ added in v0.5.0
Symbol returns a glyph for the given logical key (e.g. "status.success").
func (*Theme) SymbolPreset ¶ added in v0.5.0
func (t *Theme) SymbolPreset() SymbolPreset
SymbolPreset returns the active symbol preset.
func (*Theme) ThinkingBorderColor ¶ added in v0.5.0
ThinkingBorderColor returns a function that colors text for a thinking level (off, minimal, low, ...).
type ThemeBg ¶ added in v0.5.0
type ThemeBg string
ThemeBg names background tokens resolved to ANSI background sequences.
type ThemeColor ¶ added in v0.5.0
type ThemeColor string
ThemeColor names foreground / non-background tokens in theme JSON.
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" 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" ColorBashMode ThemeColor = "bashMode" ColorPythonMode ThemeColor = "pythonMode" ColorStatusLineSep ThemeColor = "statusLineSep" ColorStatusLineModel ThemeColor = "statusLineModel" ColorStatusLinePath ThemeColor = "statusLinePath" ColorStatusLineGitClean ThemeColor = "statusLineGitClean" ColorStatusLineGitDirty ThemeColor = "statusLineGitDirty" ColorStatusLineContext ThemeColor = "statusLineContext" ColorStatusLineSpend ThemeColor = "statusLineSpend" ColorStatusLineStaged ThemeColor = "statusLineStaged" ColorStatusLineDirty ThemeColor = "statusLineDirty" ColorStatusLineUntracked ThemeColor = "statusLineUntracked" ColorStatusLineOutput ThemeColor = "statusLineOutput" ColorStatusLineCost ThemeColor = "statusLineCost" ColorStatusLineSubagents ThemeColor = "statusLineSubagents" )
type ThemeConfig ¶ added in v0.5.0
type ThemeConfig struct {
Mode ColorMode
SymbolPreset *SymbolPreset // if non-nil, overrides theme JSON symbols.preset
ColorBlindMode bool
}
ThemeConfig holds optional fields for NewTheme. The zero value means: detect color mode, use symbol preset from theme JSON, and color-blind mode off. Options apply in order; later options override earlier ones.
type ThemeExport ¶ added in v0.5.0
type ThemeExport struct {
PageBg any `json:"pageBg,omitempty"`
CardBg any `json:"cardBg,omitempty"`
InfoBg any `json:"infoBg,omitempty"`
}
ThemeExport holds optional HTML export hints.
type ThemeExportColors ¶ added in v0.5.0
ThemeExportColors holds optional HTML export palette entries.
func ExportColors ¶ added in v0.5.0
func ExportColors(themeName string) (*ThemeExportColors, error)
ExportColors loads explicit export.* colors from theme JSON, resolving vars when needed.
type ThemeFile ¶ added in v0.5.0
type ThemeFile struct {
Schema string `json:"$schema,omitempty"`
Name string `json:"name"`
Vars map[string]any `json:"vars,omitempty"`
Colors map[string]any `json:"colors"`
Export *ThemeExport `json:"export,omitempty"`
Symbols *ThemeSymbols `json:"symbols,omitempty"`
}
ThemeFile is the on-disk JSON shape for a color theme.
func LoadThemeFile ¶ added in v0.5.0
LoadThemeFile loads a theme by name from embedded builtins first, then ThemesDir.
func ParseThemeJSON ¶ added in v0.5.0
ParseThemeJSON validates and decodes theme JSON bytes.
type ThemeOption ¶ added in v0.5.0
type ThemeOption func(*ThemeConfig)
ThemeOption configures NewTheme and LoadTheme via the functional options pattern.
func WithColorBlindMode ¶ added in v0.5.0
func WithColorBlindMode(on bool) ThemeOption
WithColorBlindMode shifts toolDiffAdded (green) toward blue when true.
func WithColorMode ¶ added in v0.5.0
func WithColorMode(m ColorMode) ThemeOption
WithColorMode sets the terminal color mode. An empty ColorMode (or omitting this option) uses DetectColorMode.
func WithSymbolPreset ¶ added in v0.5.0
func WithSymbolPreset(p SymbolPreset) ThemeOption
WithSymbolPreset forces a symbol preset, overriding the theme file's symbols.preset.
type ThemeSymbols ¶ added in v0.5.0
type ThemeSymbols struct {
Preset *SymbolPreset `json:"preset,omitempty"`
Overrides map[string]string `json:"overrides,omitempty"`
}
ThemeSymbols configures embedded symbol overrides in JSON.