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 ¶
- func CellWidth(text string) int
- func RuneWidth(r rune) int
- func StripEscapes(text string) string
- func VisibleWidth(text string) int
- type Style
- func (s Style) Accent(text string) string
- func (s Style) Again() string
- func (s Style) Arrow() string
- func (s Style) AtMost() string
- func (s Style) Bad(text string) string
- func (s Style) BandBad(text string) string
- func (s Style) BandWarn(text string) string
- func (s Style) Blue(text string) string
- func (s Style) Bold(text string) string
- func (s Style) BoxBottomLeft() string
- func (s Style) BoxBottomRight() string
- func (s Style) BoxSide() string
- func (s Style) BoxTopLeft() string
- func (s Style) BoxTopRight() string
- func (s Style) Bullet() string
- func (s Style) Check() string
- func (s Style) Colour() bool
- func (s Style) Cross() string
- func (s Style) Dash() string
- func (s Style) Dim(text string) string
- func (s Style) Dot() string
- func (s Style) Empty() string
- func (s Style) Filled() string
- func (s Style) Meter() string
- func (s Style) Mint(text string) string
- func (s Style) OK(text string) string
- func (s Style) OneLine() string
- func (s Style) Pointer() string
- func (s Style) Question() string
- func (s Style) Rule() string
- func (s Style) Spinner(frame int) string
- func (s Style) Teal(text string) string
- func (s Style) Times() string
- func (s Style) TintNeeds(text string) string
- func (s Style) TintRun(text string) string
- func (s Style) Up() string
- func (s Style) Violet(text string) string
- func (s Style) Warn(text string) string
- func (s Style) Warning() string
- func (s Style) Width() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CellWidth ¶ added in v1.1.0
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
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 ¶
StripEscapes removes terminal escapes, leaving the text as it reads.
func VisibleWidth ¶
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 ¶
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) AtMost ¶ added in v1.1.0
AtMost returns a less-than-or-equal sign, or "<=" without UTF-8.
func (Style) BandWarn ¶ added in v1.1.0
BandWarn paints the paused band: dark text on a solid yellow.
func (Style) BoxBottomLeft ¶ added in v1.1.0
BoxBottomLeft returns a rounded box's bottom-left corner, or "+" without UTF-8.
func (Style) BoxBottomRight ¶ added in v1.1.0
BoxBottomRight returns a rounded box's bottom-right corner, or "+" without UTF-8.
func (Style) BoxTopLeft ¶ added in v1.1.0
BoxTopLeft returns a rounded box's top-left corner, or "+" without UTF-8.
func (Style) BoxTopRight ¶ added in v1.1.0
BoxTopRight returns a rounded box's top-right corner, or "+" without UTF-8.
func (Style) OneLine ¶ added in v1.1.0
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) Spinner ¶ added in v1.2.0
Spinner returns one of ten braille spinner frames, one cell wide; frame is taken modulo ten, a negative one included. With no colour or no UTF-8 it returns Pointer, so the mark never moves where it cannot be painted.
func (Style) Teal ¶ added in v1.1.0
Teal colors work that is done but not yet landed, apart from Accent at every depth.
func (Style) TintNeeds ¶ added in v1.1.0
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
TintRun paints a running job's row on a dark blue; see TintNeeds.