Documentation
¶
Overview ¶
Package theme is the semantic color layer. Rendering code never names a color — it paints a *slot* (SlotAccent, SlotSelection, SlotLink, …) and the theme resolves the slot to SGR codes. Slots come from three layers, later wins:
- defaults — the stock look
- a named theme (config `theme = mono`, TASKS_THEME env, or NO_COLOR)
- per-slot overrides from the config file (`color.accent = magenta`)
A slot spec is space-separated tokens: attributes (bold, dim, italic, underline, reverse), a named color (red, bright-red, gray, …), a 256-color index (0–255), or a hex color (#rrggbb). Prefix a color with `on-` for the background (on-blue, on-#1e2030). `none` means unstyled. An invalid spec is dropped and the slot falls back to its theme value, so a typo degrades the look rather than crashing the TUI.
Go port of Ruby's lib/tui/theme.rb. Unlike Ruby, a Theme is a value rather than process-global module state: callers hold the *Theme they configured.
Which theme NAME is in force (including the NO_COLOR convention, which selects "mono" when nothing explicit is set) is resolved by the configuration layer, exactly as Ruby resolves it in lib/tasks/config.rb. This package consumes the resolved name.
Index ¶
Constants ¶
const DefaultBorderGradient = "#5aa2f7 #c678dd @45"
DefaultBorderGradient is a blue→violet diagonal sweep, contrasty enough to read on both light and dark terminals.
const SlotBorderGradient = "border_gradient"
SlotBorderGradient is not an SGR slot (it is per-cell truecolor, not one code list), so it lives outside Defaults. A theme supplies its own via this key; "none" (or any unparseable value) disables it and the border falls back to the solid "border" slot.
Variables ¶
var Defaults = map[Slot]string{
"tab_active": "bold reverse",
"tab_inactive": "dim",
"tab_agenda": "cyan",
"tab_next": "green",
"tab_quadrants": "yellow",
"tab_inbox": "magenta",
"tab_projects": "blue",
"tab_approvals": "yellow",
"tab_agenda_active": "bold reverse cyan",
"tab_next_active": "bold reverse green",
"tab_quadrants_active": "bold reverse yellow",
"tab_inbox_active": "bold reverse magenta",
"tab_projects_active": "bold reverse blue",
"tab_approvals_active": "bold reverse yellow",
"selection": "bold 253 on-236",
"accent": "cyan",
"prompt": "bold cyan",
"section": "bold",
"approval_section": "bold yellow",
"inbox_section": "bold magenta",
"modal_title": "bold",
"panel_title": "bold",
"border": "none",
"context": "bold cyan",
"context_selected": "bold cyan",
"context_filter_active": "bold green",
"project": "magenta",
"project_selected": "bold magenta",
"title": "none",
"title_selected": "bold",
"priority": "bold",
"priority_selected": "bold",
"priority_a": "bold red",
"priority_b": "bold green",
"priority_c": "bold yellow",
"muted": "dim",
"muted_selected": "dim",
"outline_thread": "gray",
"outline_container": "bold",
"note": "dim",
"description": "dim",
"link": "underline cyan",
"detail_label": "bold",
"link_system": "cyan",
"error": "red",
"warning": "yellow",
"form_group": "bold",
"form_group_label": "bold black on-cyan",
"form_label": "bold",
"form_value": "none",
"form_focus": "bold cyan",
"form_cursor": "reverse",
"form_error": "bold red",
"form_unsaved": "bold yellow",
"form_hint": "dim",
"form_disabled": "dim",
"form_choice_cursor": "bold cyan",
"form_choice_selected": "bold",
"due_overdue": "red",
"due_soon": "yellow",
"due_week": "cyan",
"due_far": "gray",
"due_overdue_selected": "bold red",
"due_soon_selected": "bold yellow",
"due_week_selected": "bold cyan",
"due_far_selected": "gray",
"state_next": "cyan",
"state_waiting": "yellow",
"state_done": "gray",
}
Defaults is the stock look, keyed by slot.
Functions ¶
Types ¶
type Slot ¶
type Slot = string
Slot names a semantic style. Values match the Ruby symbol names exactly, so a config file's `color.<slot>` key maps across unchanged.
func SelectedSlot ¶
SelectedSlot returns "<slot>_selected" when that variant exists, else slot.
type Theme ¶
type Theme struct {
// contains filtered or unexported fields
}
Theme is a resolved slot table.
func Configure ¶
Configure installs a theme: a named theme plus per-slot overrides. Unknown theme names, unknown slots, and invalid specs all fall back rather than fail — the config file must never be able to break the TUI.
func (*Theme) CompositeOver ¶
CompositeOver lays slot's style OVER a line that already carries its own field SGRs (each closed with a reset). A "none"/unset slot is a passthrough. Closes with one trailing reset.
func (*Theme) Gradient ¶
Gradient returns the parsed border gradient for slot, or nil when the theme disables it. The border package decides whether the terminal can render it.
func (*Theme) Paint ¶
Paint styles str for slot. Unknown slots and "none" slots pass the string through untouched.