color

package
v0.0.0-...-0940f3f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2016 License: BSD-3-Clause Imports: 5 Imported by: 163

Documentation

Overview

The colors package provide a simple way to bring colorful characters to terminal interface.

This example will output the text with a Blue foreground and a Black background

color.Println("@{bK}Example Text")

This one will output the text with a red foreground

color.Println("@rExample Text")

This one will escape the @

color.Println("@@")

Full color syntax code

@{rgbcmykwRGBCMYKW}  foreground/background color
  r/R:  Red
  g/G:  Green
  b/B:  Blue
  c/C:  Cyan
  m/M:  Magenta
  y/Y:  Yellow
  k/K:  Black
  w/W:  White
@{|}  Reset format style
@{!./_} Bold / Dim / Italic / Underline
@{^&} Blink / Fast blink
@{*} High intensity foreground color
@{?} Reverse the foreground and background color
@{-} Hide the text

Note some of the functions are not widely supported, like "Fast blink" and "Italic".

Index

Constants

View Source
const (
	EscapeChar = '@'       // Escape character for color syntax
	ResetCode  = "\033[0m" // Short for reset to default style
)

Variables

This section is empty.

Functions

func Colorize

func Colorize(x string) string

Compile color syntax string like "rG" to escape code.

func Errorf

func Errorf(format string, a ...interface{}) error

Similar to fmt.Errorf, will reset the color at the end.

func Fprint

func Fprint(w io.Writer, a ...interface{}) (int, error)

Similar to fmt.Fprint, will reset the color at the end.

func Fprintf

func Fprintf(w io.Writer, format string, a ...interface{}) (int, error)

Similar to fmt.Fprintf, will reset the color at the end.

func Fprintln

func Fprintln(w io.Writer, a ...interface{}) (int, error)

Similar to fmt.Fprintln, will reset the color at the end.

func Print

func Print(a ...interface{}) (int, error)

Similar to fmt.Print, will reset the color at the end.

func Printf

func Printf(format string, a ...interface{}) (int, error)

Similar to fmt.Printf, will reset the color at the end.

func Println

func Println(a ...interface{}) (int, error)

Similar to fmt.Println, will reset the color at the end.

func Sprint

func Sprint(a ...interface{}) string

Similar to fmt.Sprint, will reset the color at the end.

func Sprintf

func Sprintf(format string, a ...interface{}) string

Similar to fmt.Sprintf, will reset the color at the end.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL