Documentation
¶
Overview ¶
Package theme is the single styling surface for the whisper TUI. It owns the palette (the signature 'whisper' theme plus nord/gruvbox), the Lip Gloss style set every view renders through, and the colour policy.
Robustness Principle: conservative in what we EMIT - colour is a courtesy, never a requirement. NO_COLOR (https://no-color.org) always wins; with colour off every status that relied on it also carries a glyph (●/✓/✗/BLOCK), so meaning never depends on colour alone (accessibility). Liberal in what we ACCEPT - an unknown theme name falls back to the signature default, never an error.
Index ¶
- Variables
- func ColorDisabled(noColorFlag bool) bool
- func LightBackground() bool
- type Name
- type Palette
- type Theme
- func (t *Theme) BorderColor() lipgloss.TerminalColor
- func (t *Theme) Decision(decision string) (lipgloss.Style, string)
- func (t *Theme) DimColor() lipgloss.TerminalColor
- func (t *Theme) FlowHi() lipgloss.TerminalColor
- func (t *Theme) FlowLo() lipgloss.TerminalColor
- func (t *Theme) FlowMid() lipgloss.TerminalColor
- func (t *Theme) KindStyle(kind string) lipgloss.Style
- func (t *Theme) LoadHi() lipgloss.TerminalColor
- func (t *Theme) LoadLo() lipgloss.TerminalColor
- func (t *Theme) LoadMid() lipgloss.TerminalColor
Constants ¶
This section is empty.
Variables ¶
var Names = []Name{Whisper, Nord, Gruvbox}
Names lists the selectable themes in cycle order (Ctrl-T).
Functions ¶
func ColorDisabled ¶
ColorDisabled reports the colour policy: NO_COLOR (https://no-color.org) or an explicit --no-color always win; otherwise colour is allowed (the caller additionally gates on a real TTY before entering the TUI at all).
func LightBackground ¶
func LightBackground() bool
LightBackground reports whether a light terminal background was detected. We honour COLORFGBG (the de-facto standard many terminals export) and otherwise assume dark - the safe default for an infra tool. Liberal-in: a malformed COLORFGBG is ignored.
Types ¶
type Palette ¶
type Palette struct {
Bg string // window background
Surface string // panel fill
Text string // primary text
Dim string // muted meta
Border string // panel border (unfocused)
BorderHi string // panel border (focused)
Selection string // selected-row background
Accent string // brand accent (the whisper mark, active tab)
// Semantic colours, paired with glyphs elsewhere so colour is never load-bearing.
DNS string // dns events / ALLOW (green)
Conn string // conn events / /128 addresses (cyan-blue)
Alloc string // allocate/release (amber)
Error string // errors / BLOCK / sinkhole / refused (red)
Warn string // warnings (amber-ish)
}
Palette is the raw colour set a theme provides. Hexes are kept verbatim so the TUI matches the web dashboard (the dev-guide reference palette is the Whisper theme).
type Theme ¶
type Theme struct {
Name Name
Pal Palette
NoColor bool // NO_COLOR / --no-color in effect: every Style is plain
Light bool // a light terminal background was detected (affects nothing today;
// Reusable styles.
App lipgloss.Style
Panel lipgloss.Style // unfocused bordered panel
PanelHi lipgloss.Style // focused bordered panel
BorderFg lipgloss.Style // border glyphs rendered as text (unfocused colour)
BorderHiFg lipgloss.Style // border glyphs rendered as text (focused colour)
Title lipgloss.Style // panel title text
Header lipgloss.Style // the top header bar
TabActive lipgloss.Style
TabIdle lipgloss.Style
StatusBar lipgloss.Style
Help lipgloss.Style // footer keybinding hints
Key lipgloss.Style // a key glyph in the help bar
Dim lipgloss.Style
Text lipgloss.Style
Accent lipgloss.Style
Selected lipgloss.Style
DNS lipgloss.Style
Conn lipgloss.Style
Alloc lipgloss.Style
Error lipgloss.Style
Warn lipgloss.Style
OK lipgloss.Style
Addr lipgloss.Style // a /128 address (monospace-cyan)
ModalBox lipgloss.Style // a centred modal frame
ModalTitle lipgloss.Style
Hero lipgloss.Style // big centred first-run text
}
Theme is a resolved style set the whole TUI renders through. Build one with New and thread it into every view; it is immutable (cycle by building a fresh one).
func New ¶
New resolves a Theme by name. An empty/unknown name falls back to the signature 'whisper' theme (liberal-in). noColor forces a plain, colourless style set; the caller passes the result of ColorDisabled (NO_COLOR / --no-color / non-TTY).
func (*Theme) BorderColor ¶
func (t *Theme) BorderColor() lipgloss.TerminalColor
BorderColor is the panel-border colour as a TerminalColor (used as the gauge "empty" track). Exposed so views can request it without reaching for the unexported helper.
func (*Theme) Decision ¶
Decision returns the style + a leading glyph for a dns `decision` token. The glyph means the colour is never the only signal (accessibility / NO_COLOR).
func (*Theme) DimColor ¶
func (t *Theme) DimColor() lipgloss.TerminalColor
DimColor is the muted meta colour as a TerminalColor (for gradient call sites).
func (*Theme) FlowHi ¶
func (t *Theme) FlowHi() lipgloss.TerminalColor
func (*Theme) FlowLo ¶
func (t *Theme) FlowLo() lipgloss.TerminalColor
FlowLo/FlowMid/FlowHi are the traffic-height gradient stops (green→cyan→amber).
func (*Theme) FlowMid ¶
func (t *Theme) FlowMid() lipgloss.TerminalColor
func (*Theme) KindStyle ¶
KindStyle returns the colour for an event kind (dns/conn/alloc), defaulting to text.
func (*Theme) LoadHi ¶
func (t *Theme) LoadHi() lipgloss.TerminalColor
func (*Theme) LoadLo ¶
func (t *Theme) LoadLo() lipgloss.TerminalColor
LoadLo/LoadMid/LoadHi are the danger gradient stops (green→amber→red).
func (*Theme) LoadMid ¶
func (t *Theme) LoadMid() lipgloss.TerminalColor