style

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package style is bumper's plain-output color palette — the terminal counterpart of the web app's <Terminal> components. It wraps lipgloss so that color is applied only when the destination is a real terminal: piping, redirecting, a non-TTY writer, or NO_COLOR all degrade to plain text automatically (lipgloss/ termenv detects this from the writer), and truecolor downsamples to 16-color on terminals that lack it. Severity is always conveyed by the word, never by color alone, so the output stays legible with color off.

Only semantic tokens are colored (severity, the ●/○ section glyphs, the accent prompt, sources, success/fix) — never body text — so it reads correctly on both light and dark terminal backgrounds. The deterministic engine never imports this.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PadRight

func PadRight(s string, n int) string

PadRight pads s with spaces to width n (n excludes any color codes since callers pad before coloring). Long strings are returned as-is plus two spaces of gap.

func Trunc

func Trunc(s string, n int) string

Trunc shortens s to n runes with an ellipsis, so titles never wrap the line.

Types

type Glyphs

type Glyphs struct {
	Dot, Ring, Check, Warn, Cross, Pause, Bullet, Mid string
}

Glyphs is a small terminal glyph set with a plain-ASCII fallback.

type Palette

type Palette struct {

	// Glyphs is the Unicode/ASCII glyph set chosen for the current locale.
	Glyphs Glyphs
	// contains filtered or unexported fields
}

Palette holds the styles for one writer. Build it per destination with New.

func New

func New(w io.Writer) *Palette

New builds a palette bound to w. If w is a terminal it colors; otherwise (pipe, file, bytes.Buffer in tests) lipgloss yields plain text. Colors match the web app's --term-* tokens.

func (*Palette) Accent

func (p *Palette) Accent(s string) string

func (*Palette) Dim

func (p *Palette) Dim(s string) string

func (*Palette) Faint

func (p *Palette) Faint(s string) string

func (*Palette) OK

func (p *Palette) OK(s string) string

func (*Palette) Sev

func (p *Palette) Sev(sev string) string

Sev colors the severity word itself.

func (*Palette) Severity

func (p *Palette) Severity(sev, text string) string

Severity colors text with sev's color (pass already-padded text to keep columns aligned — the color wraps the whole cell, so width is preserved).

func (*Palette) Strong

func (p *Palette) Strong(s string) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL