Documentation ¶
Overview ¶
Package colorize adds more color to your console.
Index ¶
- Variables
- type Color
- type Colorable
- func (c *Colorable) AppliedStyle() Style
- func (c *Colorable) Black(s ...interface{}) string
- func (c *Colorable) Blue(s ...interface{}) string
- func (c *Colorable) Cyan(s ...interface{}) string
- func (c *Colorable) DisableColor() *Colorable
- func (c *Colorable) EnableColor() *Colorable
- func (c *Colorable) Fprint(w io.Writer, style Style, s ...interface{}) (n int, err error)
- func (c *Colorable) FprintFunc() func(w io.Writer, style Style, s ...interface{}) (n int, err error)
- func (c *Colorable) Fprintf(w io.Writer, style Style, format string, s ...interface{}) (n int, err error)
- func (c *Colorable) FprintfFunc() ...
- func (c *Colorable) Fprintln(w io.Writer, style Style, s ...interface{}) (n int, err error)
- func (c *Colorable) FprintlnFunc() func(w io.Writer, style Style, s ...interface{}) (n int, err error)
- func (c *Colorable) Gray(s ...interface{}) string
- func (c *Colorable) Green(s ...interface{}) string
- func (c *Colorable) Magenta(s ...interface{}) string
- func (c *Colorable) Orange(s ...interface{}) string
- func (c *Colorable) Print(style Style, s ...interface{}) (n int, err error)
- func (c *Colorable) PrintFunc() func(style Style, s ...interface{}) (n int, err error)
- func (c *Colorable) Printf(style Style, format string, s ...interface{}) (n int, err error)
- func (c *Colorable) PrintfFunc() func(style Style, format string, s ...interface{}) (n int, err error)
- func (c *Colorable) Println(style Style, s ...interface{}) (n int, err error)
- func (c *Colorable) PrintlnFunc() func(style Style, s ...interface{}) (n int, err error)
- func (c *Colorable) Purple(s ...interface{}) string
- func (c *Colorable) Red(s ...interface{}) string
- func (c *Colorable) Reset() *Colorable
- func (c *Colorable) Set(style Style) *Colorable
- func (c *Colorable) Sprint(style Style, s ...interface{}) string
- func (c *Colorable) SprintFunc() func(style Style, s ...interface{}) string
- func (c *Colorable) Sprintf(style Style, format string, s ...interface{}) string
- func (c *Colorable) SprintfFunc() func(style Style, format string, s ...interface{}) string
- func (c *Colorable) Sprintln(style Style, s ...interface{}) string
- func (c *Colorable) SprintlnFunc() func(style Style, s ...interface{}) string
- func (c *Colorable) White(s ...interface{}) string
- func (c *Colorable) Yellow(s ...interface{}) string
- type Comparable
- type FontEffect
- type Formatter
- type Style
Constants ¶
This section is empty.
Variables ¶
var ( // IsColorDisabled is a global option to dictate if the output should be colored or not. // The value is dynamically set, based on the stdout's file descriptor, if it is a terminal or not. // To disable color for specific color sections please use the DisableColor() method individually. IsColorDisabled = os.Getenv("TERM") == "dump" || (!isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd())) )
Functions ¶
This section is empty.
Types ¶
type Color ¶ added in v1.1.0
type Color interface { Comparable Formatter fmt.Stringer Red() byte Green() byte Blue() byte Alpha() byte Hex() string RGB() string }
Color representation interface.
type Colorable ¶
type Colorable struct {
// contains filtered or unexported fields
}
Colorable wrapper for color operations.
func NewColorable ¶
NewColorable allocates and returns a new Colorable. e.g.: colorized := NewColorable(os.Stdout)
func (*Colorable) AppliedStyle ¶ added in v1.1.0
AppliedStyle returns the applied style by Set().
func (*Colorable) DisableColor ¶ added in v1.1.0
DisableColor used to disable colored output, useful with a defined flag e.g. --no-color, so without modifying existing code output is done normally but having the color disabled.
func (*Colorable) EnableColor ¶ added in v1.1.0
EnableColor to re-enable colored output used in conjunction with DisableColor(). Otherwise, it will have no side effect.
func (*Colorable) Fprint ¶ added in v1.1.0
Fprint acts as the standard fmt.Fprint() method, wrapped with the given style.
func (*Colorable) FprintFunc ¶ added in v1.1.0
func (c *Colorable) FprintFunc() func(w io.Writer, style Style, s ...interface{}) (n int, err error)
FprintFunc returns a new callback that prints the passed arguments as Colorable.Fprint().
func (*Colorable) Fprintf ¶ added in v1.1.0
func (c *Colorable) Fprintf(w io.Writer, style Style, format string, s ...interface{}) (n int, err error)
Fprintf acts as the standard fmt.Fprintf() method, wrapped with the given style.
func (*Colorable) FprintfFunc ¶ added in v1.1.0
func (c *Colorable) FprintfFunc() func(w io.Writer, style Style, format string, s ...interface{}) (n int, err error)
FprintfFunc returns a new callback that prints the passed arguments as Colorable.Fprintf().
func (*Colorable) Fprintln ¶ added in v1.1.0
Fprintln acts as the standard fmt.Fprintln() method, wrapped with the given style.
func (*Colorable) FprintlnFunc ¶ added in v1.1.0
func (c *Colorable) FprintlnFunc() func(w io.Writer, style Style, s ...interface{}) (n int, err error)
FprintlnFunc returns a new callback that prints the passed arguments as Colorable.Fprintln().
func (*Colorable) Print ¶ added in v1.1.0
Print acts as the standard fmt.Print() method, wrapped with the given style.
func (*Colorable) PrintFunc ¶ added in v1.1.0
PrintFunc returns a new callback that prints the passed arguments as Colorable.Print().
func (*Colorable) Printf ¶ added in v1.1.0
Printf acts as the standard fmt.Printf() method, wrapped with the given style.
func (*Colorable) PrintfFunc ¶ added in v1.1.0
func (c *Colorable) PrintfFunc() func(style Style, format string, s ...interface{}) (n int, err error)
PrintfFunc returns a new callback that prints the passed arguments as Colorable.Printf().
func (*Colorable) Println ¶ added in v1.1.0
Println acts as the standard fmt.Println() method, wrapped with the given style.
func (*Colorable) PrintlnFunc ¶ added in v1.1.0
PrintlnFunc returns a new callback that prints the passed arguments as Colorable.Println().
func (*Colorable) Sprint ¶ added in v1.1.0
Sprint acts as the standard fmt.Sprint() method, wrapped with the given style.
func (*Colorable) SprintFunc ¶ added in v1.1.0
SprintFunc returns a new callback that prints the passed arguments as Colorable.Sprint().
func (*Colorable) Sprintf ¶ added in v1.1.0
Sprintf acts as the standard fmt.Sprintf() method, wrapped with the given style.
func (*Colorable) SprintfFunc ¶ added in v1.1.0
SprintfFunc returns a new callback that prints the passed arguments as Colorable.Sprintf().
func (*Colorable) Sprintln ¶ added in v1.1.0
Sprintln acts as the standard fmt.Sprintln() method, wrapped with the given style.
func (*Colorable) SprintlnFunc ¶ added in v1.1.0
SprintlnFunc returns a new callback that prints the passed arguments as Colorable.Sprintln().
type Comparable ¶ added in v1.1.1
Comparable representation interface.
type FontEffect ¶
type FontEffect int
FontEffect value.
const ( Normal FontEffect = iota Bold Faint Italic Underline BlinkSlow BlinkRapid ReverseVideo Concealed CrossedOut )
Font effects. Some effects are not supported on all terminals.
type Formatter ¶ added in v1.1.1
type Formatter interface {
// contains filtered or unexported methods
}
Formatter representation interface.
type Style ¶
type Style struct { fmt.Formatter fmt.Stringer Foreground Color Background Color Font []FontEffect }
Style to be applied to the text.
func (Style) Equals ¶ added in v1.1.0
Equals compares style with a given style, and returns true if they are the same.