Documentation
¶
Overview ¶
Package theme holds the terminal UI's colors, glyphs and styles: the dashboard's theme families, generated from its CSS, plus Terminal, which uses the terminal's own ANSI colors.
Code generated by scripts/tuithemes; DO NOT EDIT.
Index ¶
- Constants
- Variables
- func Fill(base lipgloss.Style, line string, width int) string
- func Monochrome(p colorprofile.Profile) bool
- type Braille
- type Family
- type Glyphs
- type Levels
- type Palette
- type Plot
- type Styles
- func (s Styles) OnRaised() Styles
- func (s Styles) OnSelected() Styles
- func (s Styles) OnSelection(st lipgloss.Style) lipgloss.Style
- func (s Styles) Row(line string, width int) string
- func (s Styles) SelectedRow(line string, width int) string
- func (s Styles) State(d string) lipgloss.Style
- func (s Styles) StateWord(d string) lipgloss.Style
Constants ¶
const CPUFloor = 5.0
CPUFloor is the lowest top of a CPU plot, in percent of a core: the servers list's sparklines and the Metrics chart scale to at least it, so a process idling at 1 percent draws a low line, not a full one.
Variables ¶
var ASCII = Glyphs{ ID: "ascii", Running: "*", Unready: "?", Crashed: "!", Stopped: "-", Done: "+", External: "@", Disabled: "x", Stale: "^", Spinner: []string{"|", "/", "-", "\\"}, Expanded: "v", Collapsed: ">", Logo: "#", Cursor: ">", Caret: "_", Border: asciiBorder, Heavy: asciiHeavy, Rule: "-", Ellipsis: "~", Separator: ", ", Spark: Levels{Blank: ' ', Steps: []rune("_.-=#")}, Chart: Levels{Blank: ' ', Steps: []rune("_.-=#")}, }
var Nerd = Glyphs{ ID: "nerd", Running: "\uf111", Unready: "\U000f0026", Crashed: "\uf071", Stopped: "\uf10c", Done: "\uf058", External: "\U000f059f", Disabled: "\U000f073a", Stale: "\uf021", Spinner: []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}, Expanded: "\uf078", Collapsed: "\uf054", Logo: "\U000f0dd4", Kind: nerdKinds, Task: "\uf0ae", Schedule: "\uf017", Watch: "\uf06e", Worktree: "\ue725", Network: "\U000f0317", Cursor: "▎", Caret: "▏", Border: lipgloss.RoundedBorder(), Heavy: lipgloss.ThickBorder(), Rule: "─", Ellipsis: "…", Separator: " · ", Spark: Braille{}, Chart: Braille{}, }
Nerd needs a Nerd Font (v3 code points).
var TerminalFamily = Family{ ID: "terminal", Label: "Terminal", Dark: terminal(true), Light: terminal(false), }
TerminalFamily uses the terminal's 16 ANSI colors, so the UI matches the user's terminal theme; Bg and Surface are the terminal's own background. Raised and Selected are bright black (8) in dark terminals, white (7) in light ones: black (0) is the background itself in many dark terminals. No text is drawn on Accent: the active tab, the mode pill and an overlay's highlighted row reverse the terminal's own foreground and background (build), the only pair whose contrast the user has chosen.
var Unicode = Glyphs{ ID: "unicode", Running: "●", Unready: "◍", Crashed: "◆", Stopped: "○", Done: "✓", External: "◎", Disabled: "⊘", Stale: "↻", Spinner: []string{"◐", "◓", "◑", "◒"}, Expanded: "▾", Collapsed: "▸", Logo: "⚓", Cursor: "▎", Caret: "▏", Border: lipgloss.RoundedBorder(), Heavy: lipgloss.ThickBorder(), Rule: "─", Ellipsis: "…", Separator: " · ", Spark: Braille{}, Chart: Braille{}, }
Functions ¶
func Fill ¶
Fill fits line to width cells (cut, or padded with spaces) with base's background and attributes under all of it: they are set at the start and again after every reset inside line. Foreground colors inside line win.
func Monochrome ¶
func Monochrome(p colorprofile.Profile) bool
Monochrome reports whether a terminal's color profile shows no colors, so the styles must mark state with attributes (NewMono). Bubble Tea sends the profile as tea.ColorProfileMsg after start, NO_COLOR included.
Types ¶
type Braille ¶
type Braille struct{}
Braille packs 2x4 dots into a cell: two samples per cell, four levels per row of cells. Blank is U+2800.
type Family ¶
type Family struct {
ID string // "terminal", or the dashboard's family id ("rose-pine", "nord", ...)
Label string
Dark Palette
Light Palette
}
Family is a theme in its dark and light variants.
type Glyphs ¶
type Glyphs struct {
ID string // "unicode", "nerd" or "ascii"
Running, Unready, Crashed, Stopped, Done, External, Disabled string
// Stale marks a live server whose config changed since it started (a
// restart applies it), next to its lamp like Disabled.
Stale string
Spinner []string // frames for starting, stopping and pending actions
Expanded, Collapsed string // group arrows
Logo string // the top bar's mark
// Kind is the icon before a server's name by discover.CommandKind
// (supervisor.View.Kind); empty in sets without tool icons.
Kind map[string]string
// Badge icons; empty strings fall back to the badge's word.
Task, Schedule, Watch, Worktree, Network string
// Chrome: everything drawn around and between the content.
Cursor string // marks the selected row, so selection never depends on color
Caret string // the text cursor at the end of an input line
Border lipgloss.Border // panes, overlays
Heavy lipgloss.Border // the focused pane when color cannot mark it (PaneBorder)
Rule string // one cell of a horizontal rule (log markers, chart baselines)
Ellipsis string // the tail of cut text
Separator string // between inline values, e.g. "exit 1 · 2m ago"
Spark Plot // the servers list's CPU sparkline
Chart Plot // the metrics charts
}
Glyphs is one glyph set (design/tui.md "Glyphs"). Every state has its own shape, so state never depends on color alone.
func GlyphSets ¶
func GlyphSets() []Glyphs
GlyphSets lists the sets in the order `--icons` documents them.
func (Glyphs) PaneBorder ¶
PaneBorder is the border of a pane: Heavy for the focused pane when colors are off (mono) or in the ASCII set, whose terminals are often basic, else Border.
type Levels ¶
Levels draws one sample per cell: Steps lists the glyphs from the lowest level to the highest, Blank is a cell with no value. In a chart of several rows the cells under a column's top are Steps' last glyph.
type Palette ¶
type Palette struct {
ID string // the dashboard's theme id, e.g. "rose-pine-dawn"; "terminal-dark" for Terminal
Dark bool
// ANSI is set for the Terminal family, whose colors are the user's
// ANSI palette: their contrast is unknown, so highlights are reverse
// video and the selected row's text is Text (design/tui.md "Themes").
ANSI bool
Bg color.Color // screen
Surface color.Color // panes
Raised color.Color // overlays and search matches
// Selected is the selected row's background: Accent tinted into
// Surface as far as the row's text, labels, ports and states stay
// readable on it.
Selected color.Color
Text color.Color
Text2 color.Color // secondary values
Muted color.Color // labels, unfocused borders, badges
Border color.Color
Accent color.Color // focused border, active tab and mode pill backgrounds, cursor
// AccentText is Accent as text (key hints, the focused title, search
// matches): Accent mixed toward Text until it reads at 4.5:1 on Bg,
// Surface and Raised, Accent itself where it already does.
AccentText color.Color
AccentFg color.Color // text on an Accent, Warn or Crashed background (banners)
Running color.Color
Starting color.Color
Crashed color.Color
External color.Color
Stopped color.Color
Warn color.Color
Info color.Color
Port color.Color // ports and addresses
}
Palette is one theme variant's semantic colors; design/tui.md "Themes" says what each is for.
type Plot ¶
type Plot interface {
// contains filtered or unexported methods
}
Plot is the alphabet a sparkline or chart draws with: Braille or Levels.
type Styles ¶
type Styles struct {
Palette Palette
// Mono is set when the terminal shows no colors (NO_COLOR, or a
// profile without color; see Monochrome): selection, focus, the active
// tab and the mode then show as reverse, bold and underline.
Mono bool
// Screen is the background outside panes, Surface inside them.
Screen, Surface lipgloss.Style
Text, Text2, Muted, Bold lipgloss.Style
Accent, AccentBold lipgloss.Style
Port, Link lipgloss.Style // Link is underlined Port
Warn, Info, Error lipgloss.Style
// State colors a state word; State and StateWord pick one for a
// display state. On the Terminal family's selected row (OnSelected)
// they are Text, the way Port, Warn, Info and Error are there, while
// the glyph styles (State) keep their color.
Running, Starting, Crashed, External, Stopped lipgloss.Style
Pane, PaneFocused lipgloss.Style // rounded borders, Border or Accent colored
Frame, FrameFocused lipgloss.Style // the border characters a pane draws itself, on Surface
Title, TitleFocused lipgloss.Style // pane titles in the top border
Selected lipgloss.Style // the selected row's background, Selected; reverse when Mono
Match lipgloss.Style // a search match
Tab, TabActive lipgloss.Style
// Mode is the footer's mode pill: AccentFg on Accent; reverse and
// bold in the Terminal family and when Mono, like TabActive.
Mode lipgloss.Style
Key, KeyHelp lipgloss.Style // a key hint and its description (Text2)
Overlay lipgloss.Style // dialogs and menus on Raised, Accent border
// OverlaySelected is the highlighted row of a list inside an overlay,
// whose own background is Raised: AccentFg on Accent; reverse and
// bold in the Terminal family and when Mono.
OverlaySelected lipgloss.Style
Banner, BannerError lipgloss.Style // the top bar's warning and error banners
Dim lipgloss.Style // what lies under an overlay
// contains filtered or unexported fields
}
Styles are the lipgloss styles every part of the UI draws with, built from one palette; nothing outside this package picks a color.
Every style drawn inside a pane carries the Surface background, so a named theme paints its own background whatever the terminal's is; in the Terminal family that background is lipgloss.NoColor and the terminal's own shows through.
func (Styles) OnRaised ¶
OnRaised is s for content drawn on Raised, inside an overlay: every style that carried Surface carries Raised instead.
func (Styles) OnSelected ¶
OnSelected is s for the selected row's content: every style that carried Surface carries Selected instead, so the row's segments keep its background (see SelectedRow). In the Terminal family the text styles that carry a meaning (ports, states, warnings) are Text there, since an ANSI color on ANSI 8 or 7 may not read; State's glyph styles keep their color.
func (Styles) OnSelection ¶
OnSelection is st, one of s's styles, moved onto the selected row: on Selected, with its foreground made readable there as OnSelected makes it (a semantic color is Text in the Terminal family). Mono rows are reversed by SelectedRow, so st stays.
func (Styles) Row ¶
Row fits line to width cells on Surface: text and padding alike, and the spaces between styled segments, which a reset would otherwise leave on the terminal's background.
func (Styles) SelectedRow ¶
SelectedRow is Row for the selected row: on Selected, or reversed when Mono. Draw the row's segments with OnSelected styles, whose Muted stays visible on Selected.
func (Styles) State ¶
State returns the style for a display state's glyph (and a graphic such as the CPU sparkline), which keeps its color on every row.