Documentation ¶
Index ¶
- Variables
- func Bg(hex string) string
- func ColorToAnsiIndex(c uint8) uint8
- func Colorize(st Style, message string) string
- func ExpandStyle(style string) string
- func Fg(hex string) string
- func GetColorPatterns() map[*regexp.Regexp]FieldStyle
- func HexToColor256(hex string) uint8
- func HexToRgb(hex string) (r, g, b uint8)
- func HexToUint8(hexbyte string) uint8
- func RgbToColor256(red, green, blue uint8) uint8
- type ColorizedWriter
- type FieldSpec
- type FieldStyle
- type Style
Constants ¶
This section is empty.
Variables ¶
var ( // ColorPrefix contains the ANSI control code prefix ColorPrefix = "\u001b[" // ColorSuffix contains the ANSI control code suffix ColorSuffix = "m" // Reset contains the ANSI control code to reset the format Reset = ColorPrefix + "0" + ColorSuffix // Bold contains the ANSI control code to enable bold text Bold = "1" // Bold effect applies to text only (not background) // Underline contains the ANSI control code to enable underlined text Underline = "4" // Underline text // Reverse contains the ANSI control code to enable reverse text Reverse = "7" // Use reverse text (swap foreground and background) )
var ( // ColorPatterns contains the coloring rules ColorPatterns map[*regexp.Regexp]FieldStyle )
Functions ¶
func ColorToAnsiIndex ¶
ColorToAnsiIndex converts a uint8 color value (0-255) into an ANSI color value (0-5)
func ExpandStyle ¶
ExpandStyle expands a style string into an ANSI control code
func GetColorPatterns ¶
func GetColorPatterns() map[*regexp.Regexp]FieldStyle
GetColorPatterns loads the map used by the colorizer
func HexToColor256 ¶
HexToColor256 converts input "hex" into an ANSI color code (xterm-256) hex may be a set of 3 or 6 hexadecimal digits for RGB values
func HexToRgb ¶
HexToRgb converts a 3 or 6 digit hexadecimal string, representing RGB values, into separate R,G,B values
func HexToUint8 ¶
HexToUint8 converts a hexadecimal string to a uint8
func RgbToColor256 ¶
RgbToColor256 converts the red, green, blue tuple into an ANSI color code (xterm-256)
Types ¶
type ColorizedWriter ¶
type ColorizedWriter struct {
// contains filtered or unexported fields
}
ColorizedWriter provides an io.Writer which colorizes output
func NewColorizedWriter ¶
func NewColorizedWriter(w io.Writer) ColorizedWriter
NewColorizedWriter returns a new io.Writer which implements coloring
type FieldStyle ¶
FieldStyle contains the styles for a particular output field