Documentation
¶
Overview ¶
Package render is the human-facing visual system for refresh: a small design language (palette, status tokens, primitives) plus an in-place live-region printer. It is line-oriented CLI output — NOT a TUI (no alternate screen, no input loop). Color is always additive: every status also carries a glyph and a label, so output stays legible with --no-color, when piped, or on a non-UTF-8 terminal.
Machine formats (-o json/yaml/plain) do not go through this package; they stay in runner.EncodeStdout. render only styles the human `table`/detail surfaces, reusing the ANSI-width math in internal/ui.
Index ¶
- Variables
- type Color
- type ColorLevel
- type LiveRegion
- type Palette
- type Status
- type Table
- type Theme
- func (t *Theme) Bar(done, total, width int, c Color) string
- func (t *Theme) Bold(c Color, s string) string
- func (t *Theme) Branch(last bool) string
- func (t *Theme) Callout(title string, body []string, width int) []string
- func (t *Theme) Glyph(s Status) string
- func (t *Theme) KV(pairs [][2]string) []string
- func (t *Theme) NewLiveRegion(w io.Writer) *LiveRegion
- func (t *Theme) NewTable(cols ...ui.Column) *Table
- func (t *Theme) Paint(c Color, s string) string
- func (t *Theme) Section(title string) string
- func (t *Theme) Token(s Status, label string) string
- func (t *Theme) Tokenf(s Status, label string) string
Constants ¶
This section is empty.
Variables ¶
var Mocha = Palette{ Text: Color{205, 214, 244}, Subtext: Color{166, 173, 200}, Dim: Color{108, 112, 134}, White: Color{235, 239, 252}, Rule: Color{69, 71, 90}, Green: Color{166, 227, 161}, Yellow: Color{249, 226, 175}, Red: Color{243, 139, 168}, Teal: Color{148, 226, 213}, Blue: Color{137, 180, 250}, Mauve: Color{203, 166, 247}, Peach: Color{250, 179, 135}, Sky: Color{137, 220, 235}, }
Mocha is the default palette (Catppuccin Mocha) — a real, widely-used terminal theme that downgrades cleanly to 256-color.
Functions ¶
This section is empty.
Types ¶
type ColorLevel ¶
type ColorLevel int
ColorLevel is the terminal's color capability.
const ( ColorNone ColorLevel = iota // no ANSI color (NO_COLOR, piped, dumb term) Color256 // 256-color palette ColorTrue // 24-bit truecolor )
func DetectLevel ¶
func DetectLevel(w io.Writer) ColorLevel
DetectLevel reports the color capability for w. Honors NO_COLOR, fatih/color's global (set by --no-color), TTY-ness, COLORTERM and TERM.
type LiveRegion ¶
type LiveRegion struct {
// contains filtered or unexported fields
}
LiveRegion repaints a multi-line block in place on a TTY (cursor-up + clear-to-end), and degrades to appended snapshots when output isn't a terminal (or color is off) — so logs and pipes never get escape codes or a flicker of half-frames. It is line-oriented: it never uses the alternate screen buffer, so scrollback is preserved and it stays a CLI, not a TUI.
The frame model is a pure func() []string; this type only paints it, which keeps the rendering testable without a pseudo-terminal.
func (*LiveRegion) Draw ¶
func (lr *LiveRegion) Draw(frame []string)
Draw paints one frame. On a TTY it overwrites the previous frame in place; off a TTY it appends the frame (callers throttle the cadence so logs stay sane).
type Palette ¶
type Palette struct {
Text, Subtext, Dim, White, Rule Color
Green, Yellow, Red, Teal, Blue, Mauve, Peach, Sky Color
}
Palette is the named color set the design system draws from.
type Status ¶
type Status int
Status is a semantic state with a fixed glyph + color, so meaning is carried by the glyph (not color alone).
func StatusFromString ¶
StatusFromString maps a free-form AWS/Kubernetes status to a Status using the single classification table in internal/ui (so the vocabulary never drifts).
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table builds an aligned, optionally-colored table that returns its lines (header + rows). Column sizing/alignment reuse the ANSI-width helpers in internal/ui, so colored and glyph cells line up exactly.
type Theme ¶
type Theme struct {
Level ColorLevel
Unicode bool
Pal Palette
}
Theme renders strings at a given color level and Unicode capability. It is safe to copy; it holds no state.
func New ¶
func New(level ColorLevel, unicode bool) *Theme
New builds a Theme with an explicit level/unicode (used in tests for determinism).
func (*Theme) Bar ¶
Bar renders a block-glyph progress bar of the given width filled to done/total in color c.
func (*Theme) Branch ¶
Branch returns the tree connector for a list item ("├─" / "└─" for the last).
func (*Theme) Callout ¶
Callout renders a titled block bounded by top/bottom rules (no side borders, so it is trivially alignment-safe). width is the rule length.
func (*Theme) KV ¶
KV renders aligned key/value detail rows: the keys are dim and padded to a common width, the values are passed through (may already be colored).
func (*Theme) NewLiveRegion ¶
func (t *Theme) NewLiveRegion(w io.Writer) *LiveRegion
NewLiveRegion returns a LiveRegion for w. It repaints in place only when w is a terminal and the theme has color enabled.
func (*Theme) Paint ¶
Paint wraps s in the foreground color for the active level (no-op at ColorNone). Bold is the same with the bold attribute.