Documentation ¶
Index ¶
- Variables
- func BGColorLookUp(val uint8) []byte
- func BgByte(in byte, r, g, b uint8) []byte
- func BgBytes(in []byte, r, g, b uint8) []byte
- func BgHex(in, hex string) string
- func BgShift(in, from string, h, l, s float64) string
- func BgString(in string, r, g, b uint8) string
- func Bytes(in []byte, fr, fg, fb, br, bg, bb uint8) []byte
- func Exec(cmd string, dir string) (out chan string, err error)
- func FGColorLookUp(val uint8) []byte
- func FgByte(in byte, r, g, b uint8) []byte
- func FgBytes(in []byte, r, g, b uint8) []byte
- func FgHex(in, hex string) string
- func FgShift(in, from string, h, l, s float64) string
- func FgString(in string, r, g, b uint8) string
- func GetColor(r, g, b uint8, foreground bool) []byte
- func HSLtoRGB(h, s, l float64) (r, g, b uint8)
- func Hex(hex string) []byte
- func HexToRGB(hex string) (r, g, b uint8)
- func Interpret(r io.ByteReader, w io.Writer) error
- func InterpretStr(s string) string
- func Printf(w io.Writer, format string, v ...interface{})
- func Println(format string, v ...interface{})
- func RGBtoHSL(r, g, b uint8) (h, s, l float64)
- func RandomHSL() (h, s, l float64)
- func RandomHex() string
- func RandomRGB() (r, g, b uint8)
- func Sprintf(format string, v ...interface{}) string
- func String(in string, fr, fg, fb, br, bg, bb uint8) string
- func Stylize(in []byte, format ...[]byte) (res []byte)
- type Fmt
- type InterpretingWriter
Constants ¶
This section is empty.
Variables ¶
var ( //Reset = []byte("\x1b[0m") ResetFG = []byte("\033[0;00m") Bold = []byte("\x1b[1m") Dim = []byte("\x1b[2m") Italic = []byte("\x1b[3m") Underline = []byte("\x1b[4m") Blink = []byte("\x1b[5m") Reverse = []byte("\x1b[7m") Hidden = []byte("\x1b[8m") )
var ( // ColorOut is a io.Writer that writes to os.Stdout // while substituting the the color escapes in it's input. // // See Interpret for a description of color escapes. ColorOut io.Writer = NewInterpretingWriter(os.Stdout) // ColorErr is a io.Writer that writes to os.Stderr // while substituting the the color escapes in it's input. // // See Interpret for a description of color escapes. ColorErr io.Writer = NewInterpretingWriter(os.Stderr) )
var ( Before = before After = after )
var ( Fc = fgcolors Bc = bgcolors Rgb = &rgbControl{} Reset = reset )
var MaxEscapeCodeLen uint = 15
MaxEscapeCodeLen is the maximum number of bytes that the contents of an escape code may be. If the escape code is longer than this, it is output verbatim without being replaced. If MaxEscapeCodeLen is set to 0 escape codes may be any length (checking is not performed)
This is used to avoid a possible denial of service.
Functions ¶
func BGColorLookUp ¶
func BgByte ¶
BgByte colorizes the background of the input with the terminal color that matches the closest the RGB color.
func BgBytes ¶
BgBytes colorizes the background of the input with the terminal color that matches the closest the RGB color.
func BgString ¶
BgString colorizes the background of the input with the terminal color that matches the closest the RGB color.
This is simply a helper for Bytes.
func Bytes ¶
Bytes colorizes the input with the terminal color that matches the closest the RGB color.
func FGColorLookUp ¶
func FgByte ¶
Byte colorizes the input with the terminal color that matches the closest the RGB color.
func FgBytes ¶
Bytes colorizes the foreground with the terminal color that matches the closest the RGB color.
func FgString ¶
FgString colorizes the foreground of the input with the terminal color that matches the closest the RGB color.
This is simply a helper for Bytes.
func Interpret ¶
func Interpret(r io.ByteReader, w io.Writer) error
Interpret reads data from r and writes it to w, while substituting the color escapes in the input.
Color escapes are directives having one of forms on the following lines:
{#RRGGBB} {#RRGGBB,#RRGGBB} {,#RRGGBB} {}
The first form sets the terminal foreground color to the color RR,GG,BB where RR is the red component, GG green and BB blue. Each component is in hex.
The second form sets the foreground and background colors, while the third sets only the background.
The fourth form resets the terminal colors to defaults.
To output a literal { character, use two braces: {{.
func InterpretStr ¶
ColorizeTemplate substitutes the color escapes in the string s and returns the resulting string.
See Interpret for a description of color escapes.
Types ¶
type InterpretingWriter ¶
type InterpretingWriter struct {
// contains filtered or unexported fields
}
ColorTemplateWriter writes to an underlying io.Writer while substituting the color escapes in the input.
See Interpret for a description of color escapes.
func NewInterpretingWriter ¶
func NewInterpretingWriter(w io.Writer) InterpretingWriter
NewColorTemplateWriter creates a ColorTemplateWriter that writes to w while substituting the color escapes in the input.
See Interpret for a description of color escapes.