term

package
v1.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package term styles terminal text using capabilities supplied by logo.Detect. It does not inspect the environment or detect the terminal itself.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CellWidth added in v1.1.0

func CellWidth(text string) int

CellWidth measures text in terminal cells after removing escapes. Unlike VisibleWidth, which counts runes, it counts a wide character as two and a combining mark as none.

func RuneWidth added in v1.1.0

func RuneWidth(r rune) int

RuneWidth is the terminal cells one code point takes: 0 for a control character or a combining mark, 2 for a wide or fullwidth character or an emoji, 1 for everything else, the box-drawing glyphs among them.

func StripEscapes

func StripEscapes(text string) string

StripEscapes removes terminal escapes, leaving the text as it reads.

func VisibleWidth

func VisibleWidth(text string) int

VisibleWidth counts runes after removing terminal escapes. This matches rune-based wrapping; it does not measure wide glyphs or combining characters in terminal columns.

Types

type Style

type Style struct {
	// contains filtered or unexported fields
}

Style formats text and symbols for a terminal. Its zero value is plain ASCII with a width of 80. Construct a Style with New to use detected capabilities.

func New

func New(caps logo.Caps) Style

New builds a style from capabilities already detected by logo.Detect. As in logo.Render, Color controls escapes; TTY controls the layout width.

func (Style) Accent

func (s Style) Accent(text string) string

Accent colors numbers, defaults and commands cyan.

func (Style) Again

func (s Style) Again() string

Again returns a repeat arrow, or "->" without UTF-8.

func (Style) Arrow added in v1.1.0

func (s Style) Arrow() string

Arrow returns a rightward arrow, or "->" without UTF-8.

func (Style) AtMost added in v1.1.0

func (s Style) AtMost() string

AtMost returns a less-than-or-equal sign, or "<=" without UTF-8.

func (Style) Bad

func (s Style) Bad(text string) string

Bad colors errors red.

func (Style) BandBad added in v1.1.0

func (s Style) BandBad(text string) string

BandBad paints the error band: dark text on a solid red.

func (Style) BandWarn added in v1.1.0

func (s Style) BandWarn(text string) string

BandWarn paints the paused band: dark text on a solid yellow.

func (Style) Blue added in v1.1.0

func (s Style) Blue(text string) string

Blue colors the glm family's agent names.

func (Style) Bold

func (s Style) Bold(text string) string

Bold emphasizes text when color is enabled.

func (Style) BoxBottomLeft added in v1.1.0

func (s Style) BoxBottomLeft() string

BoxBottomLeft returns a rounded box's bottom-left corner, or "+" without UTF-8.

func (Style) BoxBottomRight added in v1.1.0

func (s Style) BoxBottomRight() string

BoxBottomRight returns a rounded box's bottom-right corner, or "+" without UTF-8.

func (Style) BoxSide added in v1.1.0

func (s Style) BoxSide() string

BoxSide returns a box's vertical side, or "|" without UTF-8.

func (Style) BoxTopLeft added in v1.1.0

func (s Style) BoxTopLeft() string

BoxTopLeft returns a rounded box's top-left corner, or "+" without UTF-8.

func (Style) BoxTopRight added in v1.1.0

func (s Style) BoxTopRight() string

BoxTopRight returns a rounded box's top-right corner, or "+" without UTF-8.

func (Style) Bullet added in v1.1.0

func (s Style) Bullet() string

Bullet returns a filled circle, or "*" without UTF-8.

func (Style) Check

func (s Style) Check() string

Check returns a check mark, or "ok" without UTF-8.

func (Style) Colour added in v1.1.0

func (s Style) Colour() bool

Colour reports whether the style paints with colour.

func (Style) Cross added in v1.1.0

func (s Style) Cross() string

Cross returns a failure mark, or "x" without UTF-8.

func (Style) Dash added in v1.1.0

func (s Style) Dash() string

Dash returns a rule cell, or "-" without UTF-8.

func (Style) Dim

func (s Style) Dim(text string) string

Dim colors secondary text grey, without the terminal's faint attribute.

func (Style) Dot added in v1.1.0

func (s Style) Dot() string

Dot returns a separator dot, or "|" without UTF-8.

func (Style) Empty added in v1.1.0

func (s Style) Empty() string

Empty returns an empty progress cell, or "." without UTF-8.

func (Style) Filled added in v1.1.0

func (s Style) Filled() string

Filled returns a filled progress cell, or "#" without UTF-8.

func (Style) Meter added in v1.1.0

func (s Style) Meter() string

Meter returns a slots-meter cell, or "=" without UTF-8.

func (Style) Mint added in v1.1.0

func (s Style) Mint(text string) string

Mint colors the dsh family's agent names.

func (Style) OK

func (s Style) OK(text string) string

OK colors successful results green.

func (Style) OneLine added in v1.1.0

func (s Style) OneLine() string

OneLine returns the brand's one-line form, `▙ brigada`, as logo.String prints it at the style's colour depth, without its trailing newline: only the ▙ is coloured, and plain with no colour. Without UTF-8 the brand has no one-line form and the result is empty.

func (Style) Pointer

func (s Style) Pointer() string

Pointer returns a triangular pointer, or ">" without UTF-8.

func (Style) Question

func (s Style) Question() string

Question returns a question mark.

func (Style) Rule

func (s Style) Rule() string

Rule returns a short rule, or "==" without UTF-8.

func (Style) Teal added in v1.1.0

func (s Style) Teal(text string) string

Teal colors work that is done but not yet landed, apart from Accent at every depth.

func (Style) TintNeeds added in v1.1.0

func (s Style) TintNeeds(text string) string

TintNeeds paints a needs-you row on a dark red, text and background both set, so the row reads on a light theme too. Colours inside the text keep the background. Without 256 colours or true colour it returns text as is.

func (Style) TintRun added in v1.1.0

func (s Style) TintRun(text string) string

TintRun paints a running job's row on a dark blue; see TintNeeds.

func (Style) Up added in v1.1.0

func (s Style) Up() string

Up returns an upward arrow, or "^" without UTF-8.

func (Style) Violet added in v1.1.0

func (s Style) Violet(text string) string

Violet colors the claude family's agent names.

func (Style) Warn

func (s Style) Warn(text string) string

Warn colors warnings yellow.

func (Style) Warning

func (s Style) Warning() string

Warning returns an exclamation mark.

func (Style) Width

func (s Style) Width() int

Width returns the layout width, clamped to 80..100 columns. Unknown widths and output that is not a terminal use 80 columns.

Jump to

Keyboard shortcuts

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