theme

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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:

  1. defaults — the stock look
  2. a named theme (config `theme = mono`, TASKS_THEME env, or NO_COLOR)
  3. 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

View Source
const DefaultBorderGradient = "#5aa2f7 #c678dd @45"

DefaultBorderGradient is a blue→violet diagonal sweep, contrasty enough to read on both light and dark terminals.

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

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

func HasSlot

func HasSlot(slot Slot) bool

HasSlot reports whether slot is a known slot name.

func Names

func Names() []string

Names lists every theme name in sorted order.

func Parse

func Parse(spec string) ([]string, bool)

Parse turns a spec string into SGR codes. It reports ok=false if any token is invalid — the whole spec is rejected so a half-styled slot cannot happen. "none"/"plain" parse to an empty, valid code list.

func Themes

func Themes() map[string]map[Slot]string

Themes returns the full theme table: the two builtins plus the generated color schemes.

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

func SelectedSlot(slot Slot) Slot

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

func Configure(name string, overrides map[string]string) *Theme

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 Default

func Default() *Theme

Default is the stock theme with no overrides.

func (*Theme) CompositeOver

func (t *Theme) CompositeOver(slot Slot, str string) string

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

func (t *Theme) Gradient(slot string) *border.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

func (t *Theme) Paint(slot Slot, str string) string

Paint styles str for slot. Unknown slots and "none" slots pass the string through untouched.

func (*Theme) PaintOver

func (t *Theme) PaintOver(baseSlot, slot Slot, str string) string

PaintOver combines two slots' codes on fresh plain text.

func (*Theme) SGR

func (t *Theme) SGR(slot Slot) string

SGR is the raw opening sequence for a slot (e.g. "\e[7m"), or "" when the slot is unset or "none". Frame uses this to composite the selection background UNDER a row's own field styling instead of repainting the row.

Jump to

Keyboard shortcuts

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