style

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package style holds the terminal's colors and aligned tables. Colors are off unless asked for.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Width

func Width(s string) int

Width is the printed width of s, ignoring ANSI sequences.

Types

type Align

type Align int

Align says how a column's cells are placed.

const (
	Left Align = iota
	Right
	Center
)

type Style

type Style struct{ On bool }

Style wraps text in ANSI colors when On.

func (Style) Bold

func (s Style) Bold(t string) string

func (Style) Code added in v0.1.2

func (s Style) Code(code, t string) string

Code wraps text in the given SGR codes ("1;36").

func (Style) Cyan

func (s Style) Cyan(t string) string

func (Style) Dim

func (s Style) Dim(t string) string

func (Style) Green

func (s Style) Green(t string) string

func (Style) Magenta

func (s Style) Magenta(t string) string

func (Style) Red

func (s Style) Red(t string) string

func (Style) Reverse added in v0.1.2

func (s Style) Reverse(t string) string

Reverse swaps the text and background colors: a selected tab.

func (Style) Series

func (s Style) Series(i int, t string) string

Series colors text with the i-th series color.

func (Style) Table

func (s Style) Table(rows [][]string, aligns []Align, header bool) []string

Table lays rows out in aligned columns separated by two spaces. With header, the first row is bold and underlined by a rule. Lines carry no trailing spaces.

func (Style) Yellow

func (s Style) Yellow(t string) string

Jump to

Keyboard shortcuts

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