Documentation
¶
Overview ¶
Package style describes terminal text styling — foreground and background colours together with text attributes — as composable values that authors declare directly and reuse to build themes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( Black = named(30) Red = named(31) Green = named(32) Yellow = named(33) Blue = named(34) Magenta = named(35) Cyan = named(36) White = named(37) BrightBlack = named(90) BrightRed = named(91) BrightGreen = named(92) BrightYellow = named(93) BrightBlue = named(94) BrightMagenta = named(95) BrightCyan = named(96) BrightWhite = named(97) )
The sixteen named ANSI colours.
var ErrUnknownAttribute = errors.New("unknown attribute")
ErrUnknownAttribute reports that a text-attribute name could not be resolved.
var ErrUnknownColour = errors.New("unknown colour")
ErrUnknownColour reports that a colour name could not be resolved.
Functions ¶
This section is empty.
Types ¶
type Attribute ¶
type Attribute uint
Attribute is a bitfield of text attributes. The zero value is no attributes, and values combine with bitwise OR.
func AttributeByName ¶
AttributeByName resolves a single named attribute ("bold", "italic"). The second result reports whether the name was recognised.
func (*Attribute) UnmarshalText ¶
UnmarshalText resolves a single named attribute, returning ErrUnknownAttribute for an unrecognised name.
type Colour ¶
type Colour struct {
// contains filtered or unexported fields
}
Colour is a foreground or background colour. Its zero value is unset, meaning it contributes no styling and is overridable by Style.Merge.
A Colour is either one of the sixteen named ANSI colours (see the package preset variables) or a 24-bit value produced by RGB.
func ColourByName ¶
ColourByName resolves one of the sixteen named ANSI colours. The second result reports whether the name was recognised.
func (*Colour) UnmarshalText ¶
UnmarshalText resolves a named colour ("red", "brightred") or a true-colour in "rgb(r,g,b)" form with each component in the range 0-255. It returns ErrUnknownColour for any other input.
type Style ¶
Style is a complete set of terminal styling: foreground colour, background colour, and text attributes. Its zero value applies no styling and renders as an empty string.