Documentation
¶
Overview ¶
Package theme is the skin: a palette, the text styles drawn from it, and the two frames — a pane and a card — that everything on screen is drawn inside.
The styles are package-level variables rather than a value threaded through every renderer, because a terminal application has exactly one skin and it is chosen once, at startup. Apply swaps the palette; call it before the first frame is drawn.
Index ¶
- Variables
- func Apply(p Palette)
- func Box(title, content string, width, height int, focused bool) string
- func Card(title, tag string, body []string, width int, edge lipgloss.Style) []string
- func EndsAt(left, right string, width int) string
- func Overlay(background, dialog string, width, height int) string
- type Palette
Constants ¶
This section is empty.
Variables ¶
var ( Key lipgloss.Style // a field label in the banner Value lipgloss.Style // a field value Hint lipgloss.Style // a key name Dim lipgloss.Style // chrome, borders, anything secondary Text lipgloss.Style // a table cell Logo lipgloss.Style Title lipgloss.Style // a resource name Count lipgloss.Style // the [n] beside it Header lipgloss.Style // a table's column headings Err lipgloss.Style OK lipgloss.Style Warn lipgloss.Style // Band is the selection: a full-width bar. BandOff marks the selection in a // pane that does not have focus — the row is still the one that would open, // so it is never unmarked, only quieter. Band lipgloss.Style BandOff lipgloss.Style // Chip is the breadcrumb at the bottom of the screen and the action chips a // screen may draw. ChipDanger marks one that changes remote state. Chip lipgloss.Style ChipDanger lipgloss.Style // Alert is a red band for a condition the screen would otherwise hide: // refreshes failing look exactly like nothing happening. The colour is on // the background rather than the text, because this one has to be seen // without being looked at. Alert lipgloss.Style // Selected marks a selected range — dimmer than the caret, so the caret // stays findable inside its own selection. Selected lipgloss.Style )
The active palette and the styles drawn from it.
Functions ¶
func Apply ¶
func Apply(p Palette)
Apply recolours every style from p. Call it before the first render.
func Box ¶
Box draws a bordered pane of a fixed inner size with a centred title set into its top border, as k9s does.
The title arrives already styled; its printable width is measured in cells so the escape sequences do not skew the centring. The border is assembled from parts rather than by splicing into a rendered box, because slicing styled text by rune index corrupts the escapes.
func Card ¶
Card frames a block of text with its title set into the top-left of the border and an optional tag against the top-right — a comment's author on one side, whether it is resolved on the other.
It is the counterpart to Box: a box is a pane, centred and fixed-height; a card is content, left-aligned and as tall as what it holds.
func EndsAt ¶
EndsAt puts left flush and right against the far edge of width.
The right block is dropped rather than wrapped when the two will not fit: it is always the lesser of the two, a hint or a shortcut, and a hint that pushes the facts off the line has cost more than it gave.
func Overlay ¶
Overlay centres a dialog over a background, replacing the lines it covers.
It writes over the background rather than compositing: the background is already-styled text, and slicing escape sequences out of the middle of a row to paste something else in is how a screen ends up with stray colours.
Types ¶
type Palette ¶
type Palette struct {
Key lipgloss.Color // field labels
Value lipgloss.Color // field values
Hint lipgloss.Color // key names in the legend
Muted lipgloss.Color // borders, chrome, anything secondary
Logo lipgloss.Color
Title lipgloss.Color // resource name in a border title
Count lipgloss.Color // the [n] count
Text lipgloss.Color // table cells
SelBg lipgloss.Color // selection band
SelFg lipgloss.Color // text on the band
SelDim lipgloss.Color // a selected range, dimmer than the caret
ChipBg lipgloss.Color // breadcrumb chip
ChipFg lipgloss.Color
Err lipgloss.Color
OK lipgloss.Color
Warn lipgloss.Color
}
Palette is the colour scheme. Every style below is derived from it, so a skin is a Palette and nothing else.