Documentation ¶
Overview ¶
Package color handles ANSI colors and colorization.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Color ¶
type Color struct {
// contains filtered or unexported fields
}
Color stores a color definition: RGB composition and kind.
func NewHexBGColor ¶
NewHexBGColor parses background hex color. Invalid provided values return KindUnknown color kind.
func NewHexFGColor ¶
NewHexFGColor parses foreground hex color. Invalid provided values return KindUnknown color kind.
func NewRGBBGColor ¶
NewRGBBGColor creates a new background color from its RGB components.
func NewRGBFGColor ¶
NewRGBFGColor creates a new foreground color from its RGB components.
type Colorizer ¶
Colorizer defines how to colorize something with style.
func NewColorizer ¶
NewColorizer returns a new colorizer based on the provided shell.
type Config ¶
Config stores color configuration.
func (*Config) SetDefaultColor ¶
SetDefaultColor sets default to unsetted values.
type NoopColorizer ¶
type NoopColorizer struct{}
NoopColorizer implements Colorizer without doing anything.
type Style ¶
type Style [2]Color
Style stores a foreground and background color.
func NewStyle ¶
NewStyle creates a new Style based on both foreground and background color. Color are applied to the style only if they have the right kind.
func (Style) ANSISprintf ¶
ANSISprintf works the same as fmt.Sprintf but surround output with the ansi escape sequences the Style + reset, to apply colors.