Documentation ¶
Index ¶
- Constants
- func Colorize(str string, foreground Color, background BackgroundColor) string
- func ColorizeBackground(str string, background BackgroundColor) string
- func ColorizeForeground(str string, foreground Color) string
- func DisableTerminalDetection()
- func EnableTerminalDetection()
- type BackgroundColor
- type Color
Constants ¶
const ( // Default foreground color Default = Color(iota) // Black for system foreground color SystemBlack // Red for system foreground color SystemRed // Green for system foreground color SystemGreen // Yellow for system foreground color SystemYellow // Blue for system foreground color SystemBlue // Magenta for system foreground color SystemMagenta // Cyan for system foreground color SystemCyan // White for system foreground color SystemWhite // BrightBlack for system foreground color SystemBrightBlack // BrightRed for system foreground color SystemBrightRed // BrightGreen for system foreground color SystemBrightGreen // BrightYellow for system foreground color SystemBrightYellow // BrightBlue for system foreground color SystemBrightBlue // BrightMagenta for system foreground color SystemBrightMagenta // BrightCyan for system foreground color SystemBrightCyan // BrightWhite for system foreground color SystemBrightWhite // Red: HTML Hex Color Code #FF0000, Ansi 8-bit Color Index 196 Red // Orange: HTML Hex Color Code #FF8700, Ansi 8-bit Color Index 208 Orange // Yellow: HTML Hex Color Code #FFFF00, Ansi 8-bit Color Index 226 Yellow // Chartreuse: HTML Hex Color Code #87FF00, Ansi 8-bit Color Index 118 Chartreuse // Green: HTML Hex Color Code #00FF00, Ansi 8-bit Color Index 46 Green // SpringGreen: HTML Hex Color Code #00FF87, Ansi 8-bit Color Index 48 SpringGreen // Cyan: HTML Hex Color Code #00FFFF, Ansi 8-bit Color Index 51 Cyan // Azure: HTML Hex Color Code #0087FF, Ansi 8-bit Color Index 33 Azure // Blue: HTML Hex Color Code #0000FF, Ansi 8-bit Color Index 21 Blue // Violet: HTML Hex Color Code #8700FF, Ansi 8-bit Color Index 93 Violet // Magenta: HTML Hex Color Code #FF00FF, Ansi 8-bit Color Index 201 Magenta // Rose: HTML Hex Color Code #FF0087, Ansi 8-bit Color Index 198 Rose // White: HTML Hex Color Code #FFFFFF, Ansi 8-bit Color Index 231 White // Silver: HTML Hex Color Code #BCBCBC, Ansi 8-bit Color Index 250 Silver // Grey: HTML Hex Color Code #808080, Ansi 8-bit Color Index 244 Grey // Black: HTML Hex Color Code #000000, Ansi 8-bit Color Index 16 Black )
Foreground color name
const ( // Default background color DefaultBackground = BackgroundColor(iota) // Black for system background color SystemBlackBackground // Red for system background color SystemRedBackground // Green for system background color SystemGreenBackground // Yellow for system background color SystemYellowBackground // Blue for system background color SystemBlueBackground // Magenta for system background color SystemMagentaBackground // Cyan for system background color SystemCyanBackground // White for system background color SystemWhiteBackground // BrightBlack for system background color SystemBrightBlackBackground // BrightRed for system background color SystemBrightRedBackground // BrightGreen for system background color SystemBrightGreenBackground // BrightYellow for system background color SystemBrightYellowBackground // BrightBlue for system background color SystemBrightBlueBackground // BrightMagenta for system background color SystemBrightMagentaBackground // BrightCyan for system background color SystemBrightCyanBackground // BrightWhite for system background color SystemBrightWhiteBackground // Red for background color: HTML Hex Color Code #FF0000, Ansi 8-bit Color Index 196 RedBackground // Orange for background color: HTML Hex Color Code #FF8700, Ansi 8-bit Color Index 208 OrangeBackground // Yellow for background color: HTML Hex Color Code #FFFF00, Ansi 8-bit Color Index 226 YellowBackground // Chartreuse for background color: HTML Hex Color Code #87FF00, Ansi 8-bit Color Index 118 ChartreuseBackground // Green for background color: HTML Hex Color Code #00FF00, Ansi 8-bit Color Index 46 GreenBackground // SpringGreen for background color: HTML Hex Color Code #00FF87, Ansi 8-bit Color Index 48 SpringGreenBackground // Cyan for background color: HTML Hex Color Code #00FFFF, Ansi 8-bit Color Index 51 CyanBackground // Azure for background color: HTML Hex Color Code #0087FF, Ansi 8-bit Color Index 33 AzureBackground // Blue for background color: HTML Hex Color Code #0000FF, Ansi 8-bit Color Index 21 BlueBackground // Violet for background color: HTML Hex Color Code #8700FF, Ansi 8-bit Color Index 93 VioletBackground // Magenta for background color: HTML Hex Color Code #FF00FF, Ansi 8-bit Color Index 201 MagentaBackground // Rose for background color: HTML Hex Color Code #FF0087, Ansi 8-bit Color Index 198 RoseBackground // White for background color: HTML Hex Color Code #FFFFFF, Ansi 8-bit Color Index 231 WhiteBackground // Silver for background color: HTML Hex Color Code #BCBCBC, Ansi 8-bit Color Index 250 SilverBackground // Grey for background color: HTML Hex Color Code #808080, Ansi 8-bit Color Index 244 GreyBackground // Black for background color: HTML Hex Color Code #000000, Ansi 8-bit Color Index 16 BlackBackground )
Background color name
const Version = "0.4.1"
Variables ¶
This section is empty.
Functions ¶
func Colorize ¶ added in v0.3.0
func Colorize(str string, foreground Color, background BackgroundColor) string
Colorize returns the string with foreground and background colors.
func ColorizeBackground ¶ added in v0.3.0
func ColorizeBackground(str string, background BackgroundColor) string
ColorizeBackground returns the string with the background color.
func ColorizeForeground ¶ added in v0.3.0
ColorizeForeground returns the string with the foreground color.
func DisableTerminalDetection ¶
func DisableTerminalDetection()
DisableTerminalDetection disables terminal detection. Even if the terminal is not detected, colorization is not suppressed. By default, the terminal detection is enabled.
func EnableTerminalDetection ¶
func EnableTerminalDetection()
EnableTerminalDetection enables terminal detection. If no terminal is detected, colorization is suppressed. By default, the terminal detection is enabled.
Types ¶
type BackgroundColor ¶ added in v0.2.0
type BackgroundColor int
BackgroundColor is a background color for output.
func NewBackgroundColor ¶ added in v0.2.0
func NewBackgroundColor(name string) (BackgroundColor, error)
NewBackgroundColor creates a BackgroundColor.
func (BackgroundColor) Colorize ¶ added in v0.2.0
func (c BackgroundColor) Colorize(str string) string
Colorize returns the string with the background color.
func (BackgroundColor) String ¶ added in v0.2.0
func (c BackgroundColor) String() string
String returns the name of the color.