Documentation
¶
Index ¶
- Variables
- func BgBlack(s string) string
- func BgBlue(s string) string
- func BgBrightBlack(s string) string
- func BgBrightBlue(s string) string
- func BgBrightCyan(s string) string
- func BgBrightGreen(s string) string
- func BgBrightMagenta(s string) string
- func BgBrightRed(s string) string
- func BgBrightWhite(s string) string
- func BgBrightYellow(s string) string
- func BgCyan(s string) string
- func BgDefault(s string) string
- func BgGreen(s string) string
- func BgMagenta(s string) string
- func BgRed(s string) string
- func BgWhite(s string) string
- func BgYellow(s string) string
- func Black(s string) string
- func Blue(s string) string
- func Bold(s string) string
- func BrightBlack(s string) string
- func BrightBlue(s string) string
- func BrightCyan(s string) string
- func BrightGreen(s string) string
- func BrightMagenta(s string) string
- func BrightRed(s string) string
- func BrightWhite(s string) string
- func BrightYellow(s string) string
- func Cyan(s string) string
- func Default(s string) string
- func Dim(s string) string
- func DisableColors()
- func DoubleUnderline(s string) string
- func EnableColors()
- func Encircled(s string) string
- func Error(msg string, v ...any) error
- func FPrint(w io.Writer, msg string, v ...any) (n int, err error)
- func FPrintln(w io.Writer, msg string, v ...any) (n int, err error)
- func Fatal(msg string, v ...any)
- func FatalIf(err error)
- func FatalIfWith(err error, msg string, v ...any)
- func Fraktur(s string) string
- func Framed(s string) string
- func Fscan(r io.Reader, format string, v ...any) (n int, err error)
- func Fscanln(r io.Reader, v ...any) (n int, err error)
- func Green(s string) string
- func Hidden(s string) string
- func Italic(s string) string
- func Magenta(s string) string
- func Overline(s string) string
- func Panic(msg string, v ...any)
- func Print(msg string, v ...any)
- func Println(msg string, v ...any)
- func RapidBlink(s string) string
- func Red(s string) string
- func Reverse(s string) string
- func Scan(format string, v ...any) (n int, err error)
- func Scanln(v ...any) (n int, err error)
- func SlowBlink(s string) string
- func Sprint(msg string, v ...any) string
- func Sprintln(msg string, v ...any) string
- func Sscan(str, format string, v ...any) (n int, err error)
- func Sscanln(str string, v ...any) (n int, err error)
- func StrikeThrough(s string) string
- func Stylize(s string, v ...func(s string) string) string
- func Underline(s string) string
- func White(s string) string
- func Yellow(s string) string
- type ColorMode
- type Style
- func (s *Style) Apply(text string) string
- func (s *Style) WithBold() *Style
- func (s *Style) WithColor(color StyleColor) *Style
- func (s *Style) WithDim() *Style
- func (s *Style) WithDoubleUnderline() *Style
- func (s *Style) WithEncircled() *Style
- func (s *Style) WithFraktur() *Style
- func (s *Style) WithFramed() *Style
- func (s *Style) WithHidden() *Style
- func (s *Style) WithInverse() *Style
- func (s *Style) WithItalic() *Style
- func (s *Style) WithOverline() *Style
- func (s *Style) WithRapidBlink() *Style
- func (s *Style) WithSlowBlink() *Style
- func (s *Style) WithStrikeThrough() *Style
- func (s *Style) WithUnderline() *Style
- type StyleColor
Constants ¶
This section is empty.
Variables ¶
var ( ColorBlack = NewColorAnsi(30) ColorRed = NewColorAnsi(31) ColorGreen = NewColorAnsi(32) ColorYellow = NewColorAnsi(33) ColorBlue = NewColorAnsi(34) ColorMagenta = NewColorAnsi(35) ColorCyan = NewColorAnsi(36) ColorWhite = NewColorAnsi(37) ColorDefault = NewColorAnsi(39) ColorBgBlack = NewColorAnsi(40) ColorBgRed = NewColorAnsi(41) ColorBgGreen = NewColorAnsi(42) ColorBgYellow = NewColorAnsi(43) ColorBgBlue = NewColorAnsi(44) ColorBgMagenta = NewColorAnsi(45) ColorBgCyan = NewColorAnsi(46) ColorBgWhite = NewColorAnsi(47) ColorBgDefault = NewColorAnsi(49) ColorBrightBlack = NewColorAnsi(90) ColorBrightRed = NewColorAnsi(91) ColorBrightGreen = NewColorAnsi(92) ColorBrightYellow = NewColorAnsi(93) ColorBrightBlue = NewColorAnsi(94) ColorBrightMagenta = NewColorAnsi(95) ColorBrightCyan = NewColorAnsi(96) ColorBrightWhite = NewColorAnsi(97) ColorBgBrightBlack = NewColorAnsi(100) ColorBgBrightRed = NewColorAnsi(101) ColorBgBrightGreen = NewColorAnsi(102) ColorBgBrightYellow = NewColorAnsi(103) ColorBgBrightBlue = NewColorAnsi(104) ColorBgBrightMagenta = NewColorAnsi(105) ColorBgBrightCyan = NewColorAnsi(106) ColorBgBrightWhite = NewColorAnsi(107) )
Functions ¶
func BgBrightBlack ¶
func BgBrightBlue ¶
func BgBrightCyan ¶
func BgBrightGreen ¶
func BgBrightMagenta ¶
func BgBrightRed ¶
func BgBrightWhite ¶
func BgBrightYellow ¶
func BrightBlack ¶
func BrightBlue ¶
func BrightCyan ¶
func BrightGreen ¶
func BrightMagenta ¶
func BrightWhite ¶
func BrightYellow ¶
func DisableColors ¶
func DisableColors()
DisableColors disables the use of colors globally in the package.
func DoubleUnderline ¶
func EnableColors ¶
func EnableColors()
EnableColors enables the use of colors globally in the package. By default, colors are enabled.
func FPrintln ¶
FPrintln is an alias to fmt.Fprintf using the given writer with a newline at the end.
func FatalIf ¶ added in v0.3.0
func FatalIf(err error)
Fatal prints a formatted message to stdout and exits the program with status code 1 IF the err is not nil.
func FatalIfWith ¶ added in v0.3.0
Fatal prints a formatted message to stdout and exits the program with status code 1 IF the err is not nil.
func RapidBlink ¶
func StrikeThrough ¶
Types ¶
type Style ¶
type Style struct {
// contains filtered or unexported fields
}
Style represents a combination of text modifiers and colors that can be applied to a string.
func (*Style) WithColor ¶
func (s *Style) WithColor(color StyleColor) *Style
WithColor sets the foreground color of the style. Be careful to use
func (*Style) WithDoubleUnderline ¶
WithDoubleUnderline adds the double underline modifier to the style, which adds two lines under the text. This is rarely supported by terminals.
func (*Style) WithEncircled ¶
WithEncircled adds the encircled modifier to the style, which adds a circle around the text. This is rarely supported by terminals.
func (*Style) WithFraktur ¶
WithFraktur adds the fraktur modifier to the style, which changes the font to a fraktur style. This is rarely supported by terminals.
func (*Style) WithFramed ¶
WithFramed adds the framed modifier to the style, which adds a frame around the text. This is rarely supported by terminals.
func (*Style) WithHidden ¶
WithHidden adds the hidden modifier to the style, which hides the text.
func (*Style) WithInverse ¶
WithInverse adds the inverse modifier to the style, which swaps the foreground and background colors.
func (*Style) WithItalic ¶
WithItalic adds the italic modifier to the style.
func (*Style) WithOverline ¶
WithOverline adds the overline modifier to the style, which adds a line above the text.
func (*Style) WithRapidBlink ¶
WithRapidBlink adds the rapid blink modifier to the style. This is rarely supported by terminals.
func (*Style) WithSlowBlink ¶
WithSlowBlink adds the slow blink modifier to the style. This is rarely supported by terminals.
func (*Style) WithStrikeThrough ¶
WithStrikeThrough adds the strike through modifier to the style, which adds a line through the text.
func (*Style) WithUnderline ¶
WithUnderline adds the underline modifier to the style.
type StyleColor ¶
type StyleColor struct {
// contains filtered or unexported fields
}
StyleColor represents a color that can be used in a Style. It can be an ANSI color, a 256 color or a true color.
func NewColor ¶
func NewColor(r, g, b uint8) StyleColor
NewColor creates a new **FOREGROUND** true color with the given RGB values. Use `NewColorBg` to create a background color.
func NewColor256 ¶
func NewColor256(code uint8) StyleColor
NewColor256 creates a new 256 **FOREGROUND** color with the given code. Use `NewColor256Bg` to create a background color.
func NewColor256Bg ¶
func NewColor256Bg(code uint8) StyleColor
NewColor256Bg creates a new 256 **BACKGROUND** color with the given code. Use `NewColor256` to create a foreground color.
func NewColorAnsi ¶
func NewColorAnsi(code uint8) StyleColor
NewColorAnsi creates a new ANSI color with the given code. All ansi colors are mapped to constants defined in this package, you may use them instead of creating new ones with this function.
Examples: `ColorRed`, `ColorBgBrightBlue`, ...
func NewColorBg ¶
func NewColorBg(r, g, b uint8) StyleColor
NewColorBg creates a new **BACKGROUND** true color with the given RGB values. Use `NewColor` to create a foreground color.
func (*StyleColor) Code ¶
func (c *StyleColor) Code() string
Code returns the ANSI code for the color, depending on its mode.
func (*StyleColor) ToAnsi ¶
func (c *StyleColor) ToAnsi() StyleColor
ToAnsi converts the color to an ANSI color. If the color is already an ANSI color, it returns the same color.