style

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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].

View Source
var SymbolMap = UnicodeSymbolMap

SymbolMap is an alias of UnicodeSymbolMap for backward compatibility.

View Source
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

func Ansi256ToHex(index int) string

Ansi256ToHex converts a 256-color index to #RRGGBB for HTML/CSS.

func BuiltinThemeJSON added in v0.5.0

func BuiltinThemeJSON(name string) ([]byte, bool)

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

func HasPendingMermaid(markdown string) bool

HasPendingMermaid always reports false until a real extractor is wired.

func IsLightTheme added in v0.5.0

func IsLightTheme(themeName string) bool

IsLightTheme reports whether userMessageBg resolves to a light background (luminance > 0.5).

func LangByExtension

func LangByExtension(ext string) (highlight, vscode string, ok bool)

LangByExtension returns highlight and VS Code language ids for ext (without dot).

func LanguageFromPath added in v0.5.0

func LanguageFromPath(path string) string

LanguageFromPath returns the highlight grammar id for a file path (from extension), or "" if unknown.

func ListThemeNames added in v0.5.0

func ListThemeNames() ([]string, error)

ListThemeNames returns builtin names plus any *.json in ThemesDir (sorted, unique).

func MermaidASCII added in v0.5.0

func MermaidASCII(hash uint64) string

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

func ResolvedThemeColors(themeName string) (map[string]string, error)

ResolvedThemeColors returns theme colors as #RRGGBB (or fallback for empty / index colors) for CSS.

func SetMermaidASCII added in v0.5.0

func SetMermaidASCII(hash uint64, ascii string)

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

func ValidSymbolPreset(s string) bool

ValidSymbolPreset reports whether s is a known preset name.

func ValidThemeBg added in v0.5.0

func ValidThemeBg(name string) bool

ValidThemeBg reports whether name is a known background theme token.

func ValidThemeColor added in v0.5.0

func ValidThemeColor(name string) bool

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.

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

func DetectColorMode added in v0.5.0

func DetectColorMode() ColorMode

DetectColorMode mirrors the TypeScript terminal heuristic.

type ResolvedColor added in v0.5.0

type ResolvedColor struct {
	Hex   string
	Index int
	IsIdx bool
}

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

func (t *Theme) BashModeBorderColor() func(string) string

BashModeBorderColor colors text with the bash-mode border token.

func (*Theme) Bg added in v0.5.0

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

Bg paints text with a background theme token and resets only the background color.

func (*Theme) BgANSI added in v0.5.0

func (t *Theme) BgANSI(bg ThemeBg) string

BgANSI returns the raw ANSI sequence for a background token.

func (*Theme) Bold added in v0.5.0

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

Bold wraps text with ANSI bold (resets with 22).

func (*Theme) ColorMode added in v0.5.0

func (t *Theme) ColorMode() ColorMode

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

func (t *Theme) InputCursor() string

InputCursor returns the cursor glyph used in text inputs (matches TS ascii vs unicode rule).

func (*Theme) Inverse added in v0.5.0

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

Inverse wraps text with ANSI reverse video.

func (*Theme) Italic added in v0.5.0

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

Italic wraps text with ANSI italic (resets with 23).

func (*Theme) LangIcon added in v0.5.0

func (t *Theme) LangIcon(lang string) string

LangIcon returns the icon string for a language id or file extension token.

func (*Theme) PythonModeBorderColor added in v0.5.0

func (t *Theme) PythonModeBorderColor() func(string) string

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

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

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

func (t *Theme) Symbol(key string) string

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

func (t *Theme) ThinkingBorderColor(level string) func(string) string

ThinkingBorderColor returns a function that colors text for a thinking level (off, minimal, low, ...).

func (*Theme) Underline added in v0.5.0

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

Underline wraps text with ANSI underline.

type ThemeBg added in v0.5.0

type ThemeBg string

ThemeBg names background tokens resolved to ANSI background sequences.

const (
	BgSelected      ThemeBg = "selectedBg"
	BgUserMessage   ThemeBg = "userMessageBg"
	BgCustomMessage ThemeBg = "customMessageBg"
	BgToolPending   ThemeBg = "toolPendingBg"
	BgToolSuccess   ThemeBg = "toolSuccessBg"
	BgToolError     ThemeBg = "toolErrorBg"
	BgStatusLine    ThemeBg = "statusLineBg"
)

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

type ThemeExportColors struct {
	PageBg *string
	CardBg *string
	InfoBg *string
}

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

func LoadThemeFile(name string) (*ThemeFile, error)

LoadThemeFile loads a theme by name from embedded builtins first, then ThemesDir.

func ParseThemeJSON added in v0.5.0

func ParseThemeJSON(data []byte) (*ThemeFile, error)

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.

Jump to

Keyboard shortcuts

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