term

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 3 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 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) Bad

func (s Style) Bad(text string) string

Bad colors errors red.

func (Style) Bold

func (s Style) Bold(text string) string

Bold emphasizes text when color is enabled.

func (Style) Check

func (s Style) Check() string

Check returns a check mark, or "ok" 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) OK

func (s Style) OK(text string) string

OK colors successful results green.

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) 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