Documentation
¶
Overview ¶
Package color provides ANSI color formatting for terminal output. It supports short color codes like [?GN] (green), [?RD] (red), [?BOLD], etc. Coloring can be globally disabled by setting color.ColorEnabled = false.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ColorEnabled = true
ColorEnabled globally enables or disables ANSI color output. When false, all color codes are stripped from the output.
var Colors = map[string]string{
"BOLD": bold, "BD": bold,
"UNDERLINE": underline, "UE": underline,
"RESET": reset, "RT": reset,
"BLACK": black, "BK": black,
"RED": red, "RD": red,
"GREEN": green, "GN": green,
"YELLOW": yellow, "YW": yellow,
"BLUE": blue, "BE": blue,
"MAGENTA": magenta, "MA": magenta,
"CYAN": cyan, "CN": cyan,
"BBLACK": brightBlack, "BBK": brightBlack,
"BRED": brightRed, "BRD": brightRed,
"BGREEN": brightGreen, "BGN": brightGreen,
"BYELLOW": brightYellow, "BYW": brightYellow,
"BBLUE": brightBlue, "BBE": brightBlue,
"BMAGENTA": brightMagenta, "BMA": brightMagenta,
"BCYAN": brightCyan, "BCN": brightCyan,
}
Colors maps short color codes (uppercase) to ANSI escape sequences. Supported codes: BOLD/BD, UNDERLINE/UE, RESET/RT, basic colors (BLACK/BK, RED/RD, GREEN/GN, YELLOW/YW, BLUE/BE, MAGENTA/MA, CYAN/CN), and their bright variants (BBLACK/BBK, BRED/BRD, BGREEN/BGN, BYELLOW/BYW, BBLUE/BBE, BMAGENTA/BMA, BCYAN/BCN).
Functions ¶
func ConvertColored ¶
ConvertColored applies color formatting to each string in the slice using Set and returns a new slice with the colored strings.
func PrintColored ¶
func PrintColored(format string, args ...interface{})
PrintColored formats the string using fmt.Sprintf, replaces color codes, and writes the result to stdout without a trailing newline.
func PrintlnColored ¶
func PrintlnColored(format string, args ...interface{})
PrintlnColored formats the string using fmt.Sprintf, replaces color codes, and writes the result to stdout followed by a newline.
Types ¶
This section is empty.