Documentation
¶
Overview ¶
Package theme holds the colors the packages of this module paint with.
A Style is a set of SGR parameters ("1;38;5;141"); a Theme assigns one to each role text plays on screen — a title, a muted note, the selected row, an error. Packages read their colors from the active theme, so a tool that wants its own palette calls Use once at start-up. Whether anything is painted at all is decided by term.Colored, not by the theme.
Index ¶
Constants ¶
const Reset = "\x1b[0m"
Reset ends every SGR attribute.
Variables ¶
var Default = Theme{ Title: Bold, Subject: Bold, Header: Join(Bold, Fg256(252)), Border: Fg256(240), Muted: Fg256(244), Qualifier: Fg256(250), Value: Fg256(141), Detail: Fg256(117), Selected: Join(Bold, Fg256(141)), SelectedQualifier: Fg256(146), Action: Fg256(73), SelectedAction: Join(Bold, Fg256(79)), Accent: Fg256(214), Flag: Fg256(203), Info: Fg256(117), Success: Fg256(114), Warning: Fg256(221), Error: Fg256(203), }
Default is the theme the packages use unless Use installs another. It sticks to the 256-color palette, which every common terminal supports, and to mid-luminance tones that read on dark and light backgrounds.
var Plain = Theme{}
Plain paints nothing. Installing it keeps escape sequences out of output even where term.Colored would allow them.
Functions ¶
Types ¶
type Style ¶
type Style string
Style is a set of SGR parameters, such as "1" (bold) or "38;5;141" (a 256-color foreground). The zero Style paints nothing.
const ( Bold Style = "1" Dim Style = "2" Italic Style = "3" Underline Style = "4" Reverse Style = "7" )
Common attributes.
func (Style) Paint ¶
Paint wraps text in s and a reset. It returns text unchanged when s is empty or text is empty, so it is safe to call unconditionally.
func (Style) PaintIf ¶
PaintIf paints text only when on is true, usually the result of term.Colored for the writer the text goes to.
func (Style) PaintLines ¶
PaintLines paints every line of text on its own, so a terminal that redraws a single line keeps its color and a newline never carries a color into the next line.
type Theme ¶
type Theme struct {
// Title is a heading, or the question a prompt asks.
Title Style
// Subject is the thing a title is about, drawn inside it.
Subject Style
// Header is a table's header row.
Header Style
// Border is a table's rules and frame.
Border Style
// Muted recedes text: notes, key hints, detail lines, disabled rows.
Muted Style
// Qualifier is secondary text beside a value, quieter than the value but
// louder than Muted.
Qualifier Style
// Value is an answer or a typed value.
Value Style
// Detail is the full value of a shortened item, shown beside a title.
Detail Style
// Selected is the row or item under the cursor.
Selected Style
// SelectedQualifier is Qualifier on the selected row.
SelectedQualifier Style
// Action is what choosing a row does.
Action Style
// SelectedAction is Action on the selected row.
SelectedAction Style
// Accent marks something worth noticing, such as a marker column.
Accent Style
// Flag marks something worth stopping at.
Flag Style
// Info, Success, Warning and Error color messages by severity.
Info Style
Success Style
Warning Style
Error Style
}
Theme assigns a style to each role text plays on screen.