Help us shape the future of Go! Take the 2026 Go Developer Survey

theme

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package theme holds the muted green palette, ported from cdx (GoNotes): warm dark gray-green surfaces with a single green accent.

These hex strings are the one source of truth for every surface dbc paints. The TUI turns them into terminal colors; the HTML export drops them straight into its stylesheet. The package deliberately has no dependencies so both sides can import it.

Index

Constants

View Source
const (
	Bg     = "#1f2420" // deepest surface — editor, results table, export page
	Panel  = "#242a25" // sidebar, log pane, code blocks, zebra rows
	Panel2 = "#2b322c" // status bar, modal fields, table header band
	Sel    = "#3a4a3f" // selected row, hovered row
	Line   = "#38403a" // borders and rules at rest
	Fg     = "#d6ddd6"
	Muted  = "#9db0a2"
	Accent = "#4db380"
	Warn   = "#d9a45b" // not in cdx; dbc needs a busy/stopped tone
	Err    = "#e57373"
)
View Source
const HostSelAlpha = 0.30

HostSelAlpha is how much accent goes into a host-derived selection color — the weight cats uses for its own sel-fill, so a dbc selection and a cats selection in the next pane are the same color.

Variables

This section is empty.

Functions

func Blend

func Blend(fg, bg string, alpha float64) string

Blend mixes fg over bg at the given alpha (0 = bg, 1 = fg) and returns the result as "#rrggbb". Both inputs must parse; anything else returns bg unchanged, so a caller that is already refusing non-hex input gets a defined answer rather than a second error to handle.

It exists because a host palette may not carry every surface dbc needs: a selection color is a blend of the accent over the background, which is how cats derives its own, so dbc can compute the same thing rather than ask for it.

func ParseHex

func ParseHex(s string) (r, g, b uint8, ok bool)

ParseHex reads "#rgb" or "#rrggbb". It reports false for anything else — including the rgba() form a host may use for translucent surfaces, which has no meaning for a terminal cell that is either one color or another.

Types

type Palette

type Palette struct {
	Bg     string // deepest surface — editor, results table
	Panel  string // sidebar, log pane
	Panel2 string // status bar, modal fields, table header band
	Sel    string // selected row, hovered row
	Line   string // borders and rules at rest
	Fg     string
	Muted  string
	Accent string
	Warn   string
	Err    string
}

Palette is the ten surfaces dbc paints, as hex strings. The constants above are one instance of it — the built-in muted green — and Default returns them; anything else is a palette handed in from outside, which today means the colors of the cats host dbc is running inside (see FromHost in host.go).

It is a struct rather than a map because these ten are the whole vocabulary: a missing key would be a compile error rather than a black surface nobody notices until it is on screen.

func ByName

func ByName(name string) (Palette, error)

ByName is the built-in palette a setting names: "dark" (or "", the default) is Default, "light" is Light. Case and surrounding space are ignored. Anything else is an error rather than a quiet dark, so a typo in a flag is reported instead of producing the picture that was not asked for.

Only the two built-ins are nameable. A host palette (FromHost) belongs to the terminal dbc happens to run in, and a plan picture is sent to people who are not sitting in it — see Default's note on the HTML exporter.

func Default

func Default() Palette

Default is the built-in palette: the constants this package has always exported, in the shape the rest of the program can now swap out.

The HTML exporter deliberately keeps reading the CONSTANTS rather than the active palette. An exported report is a document that outlives the session and travels to people who are not sitting in this terminal, so it should look like dbc rather than like whatever theme the author's multiplexer happened to be wearing.

func FromHost

func FromHost(colors map[string]string) (Palette, bool)

FromHost turns a host terminal's theme (cats' config.get / theme_changed colors) into a dbc palette. ok is false when the host's colors cannot make a complete one.

THE MAPPING IS SMALL BECAUSE THE TWO PALETTES ARE RELATED. dbc's ten surfaces were ported from cdx and cats' theme system descends from the same place, so nine of the ten are a rename; only the selection is computed, the way cats computes its own:

host  bg fg muted line accent warn err  panel  panel2   (none)
dbc   Bg Fg Muted Line Accent Warn Err  Panel  Panel2   Sel = accent over bg at HostSelAlpha

HEX ONLY, AND ALL OR NOTHING. A missing or non-hex value (cats emits rgba() for translucent keys) in one of the seven core keys abandons the whole synthesis: a palette half the host's and half dbc's looks like a bug, and the built-in palette is a perfectly good answer.

The mapping was first written for the former tview UI (its catsHostPalette); this is now its only copy.

func Light

func Light() Palette

Light is the palette's daylight variant: the same muted green on paper instead of on slate, for dbc web's light mode (a terminal brings its own background, so the TUI never needs one). The values are the ones the standalone plan page's light toggle uses (explain/assets/plan.css), so a plan opened from a light workbench looks like the workbench it came from.

Jump to

Keyboard shortcuts

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