Documentation
¶
Overview ¶
Package theme provides the Catppuccin palettes used to color the interactive prompt.
It is opt-in: a project selects a flavor via the `prompt.theme` key in .posh.yaml, and without it posh keeps its previous, unthemed colors.
Index ¶
Constants ¶
const DefaultFlavor = FlavorMocha
DefaultFlavor is used when nothing selects a flavor and auto-detection does not produce an answer.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Capability ¶
type Capability int
Capability is how much color the terminal can render.
const ( CapabilityNone Capability = iota Capability16 Capability256 CapabilityTrueColor )
func DetectCapability ¶
func DetectCapability() Capability
DetectCapability reports what the current terminal supports.
This exists because neither pterm nor gookit degrades on its own: gookit's RenderCode only checks whether color is enabled at all, and otherwise emits whatever escape it was handed. A truecolor sequence therefore reaches a 256-color terminal verbatim and renders as garbage. Every color this package emits is chosen against this value instead.
func (Capability) String ¶
func (c Capability) String() string
type Flavor ¶
type Flavor string
Flavor is one of the four Catppuccin palettes.
func ParseFlavor ¶
ParseFlavor resolves a flavor name case-insensitively.
type Option ¶
func WithCapability ¶
func WithCapability(v Capability) Option
WithCapability pins the color tier instead of detecting it. Intended for tests: production code should let New detect the terminal.
func WithFlavor ¶
type Role ¶
type Role int
Role is a semantic slot in a palette rather than a Catppuccin color name.
Call sites ask for meaning ("this is an error") instead of a color, so swapping the palette — in particular flipping between a dark and a light flavor — needs no call-site edits. It also keeps the palette data unexported: naming Mauve in a public API would promise a distinction the 16-color prompt tier cannot keep, since Mocha's Mauve and Lavender collapse to the same ANSI slot.
type Theme ¶
type Theme struct {
// contains filtered or unexported fields
}
Theme is a resolved palette: a flavor plus the terminal capability its colors have been projected onto.
func Resolve ¶
Resolve builds the theme for a configured flavor name.
An empty name means no theme was configured and returns nil, which callers treat as "keep the previous, unthemed behavior" rather than as an error. An unrecognized name is an error: it is a typo in something the user wrote, and silently rendering a different theme would hide it.
func (*Theme) Capability ¶
func (t *Theme) Capability() Capability
func (*Theme) Hex ¶
Hex returns the role's exact Catppuccin value.
The prompt cannot render it — see Prompt — but it is the palette's source of truth and is exposed for commands that print their own colors.
func (*Theme) Prompt ¶
Prompt returns the role as one of go-prompt's 16 ANSI colors.
The prompt is capped at 16 colors, so this is an approximation. It is hand-mapped rather than derived: gookit's nearest-basic conversion collapses almost every Mocha role onto white, which would erase both the roles and the dark/light distinction in precisely the tier that cannot afford to lose them.