Documentation
¶
Overview ¶
Package termchrome owns the shared, opinionated TUI chrome widgets that sibling terminal apps (passage, ssherpa, …) render through: rounded box geometry (Edge/Top/Bottom/Divider/Line), the canonical key-hint Footer, the aligned KVRow, plus the locale-aware GlyphSet (spinner + progress Bar) and the countdown UrgencyRole.
It renders STRINGS ONLY over a termtheme.Theme. It depends on termtheme alone — no Bubble Tea, no os/net — so a box, footer, or countdown on a non-list screen never drags a navigation/runtime dependency in. List windowing lives in termnav; the per-app overflow policy (Strip vs Sanitize) stays in each app and is injected via the Truncator seam, never baked in here.
Index ¶
- Constants
- func Bottom(theme termtheme.Theme, width int) string
- func Divider(theme termtheme.Theme, width int) string
- func Edge(theme termtheme.Theme, left, right, label string, width int, tr Truncator) string
- func Footer(hints []KeyHint, width int) string
- func KVRow(theme termtheme.Theme, label, value string, gutter int) string
- func Line(theme termtheme.Theme, content string, width int, tr Truncator) string
- func Top(theme termtheme.Theme, label string, width int, tr Truncator) string
- func UrgencyRole(remaining, total int) termtheme.Role
- type GlyphSet
- type KeyHint
- type Truncator
Constants ¶
FooterSep is the one canonical key-hint separator. Screens historically drifted between " / " and " / "; this is the single source of truth.
Variables ¶
This section is empty.
Functions ¶
func Edge ¶
Edge draws a top/divider/bottom border row. The fill dashes are always border-styled — the canonical choice that resolves the historical divergence between a styled picker border and a default-colored overlay border. The label is styled by the caller and truncated by tr; an empty label yields a plain rule.
func Footer ¶
Footer renders key hints in the canonical grammar ("key label / key label"). When the hints exceed width it drops trailing ones and appends a "+N" marker (progressive disclosure) rather than letting the shell silently truncate with "~". width <= 0 means no overflow handling.
func KVRow ¶
KVRow renders an aligned "label value" row: the label is muted and padded to gutter cells so values line up in a column, the value is foreground-styled. One gutter, one grammar — replacing the per-screen 7/8/9/13/14 drift.
func Line ¶
Line wraps content as a box body row ("│ … │"), truncating with tr and padding to the inner width.
func UrgencyRole ¶
UrgencyRole ramps a countdown's color from success through warning to danger as it drains: danger in roughly the last sixth, warning in the last half, success otherwise. For a 30s TOTP that lands danger at <=5s and warning at <=15s, matching the at-a-glance "is this code about to expire" read.
Types ¶
type GlyphSet ¶
type GlyphSet struct {
Name string
ASCII bool
Spinner []string // animation frames, cycled per tick
BarFull string // filled progress-bar cell
BarEmpty string // empty progress-bar cell
}
GlyphSet is the set of decorative runes the UI animates with — spinner frames and progress-bar cells. It exists so motion never renders as mojibake on a terminal without UTF-8: every field has an ASCII fallback, chosen by locale, independently of color (a monochrome UTF-8 xterm still gets the pretty glyphs; a C/POSIX-locale terminal gets ASCII even in full color).
func ASCIIGlyphs ¶
func ASCIIGlyphs() GlyphSet
ASCIIGlyphs is the 7-bit fallback for terminals without UTF-8. Every rune is <= 0x7e so it is safe on legacy codepages.
func DefaultGlyphs ¶
func DefaultGlyphs() GlyphSet
DefaultGlyphs is used when a caller does not resolve a set from the environment. Most terminals are UTF-8, so the rich set is the default; the resolved set from ResolveGlyphs should be preferred where the env is known.
func ResolveGlyphs ¶
ResolveGlyphs picks a glyph set from the environment: Unicode when the active locale advertises UTF-8, ASCII otherwise. Glyph choice is deliberately decoupled from NoColor — capability, not color, decides. A nil env reads the current process environment (via termtheme.EnvMap).
func UnicodeGlyphs ¶
func UnicodeGlyphs() GlyphSet
UnicodeGlyphs is the default rich set: a braille spinner and block bar cells.