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 Red() uint8 Green() uint8 Blue() uint8 }
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 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 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 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 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 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 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 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 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 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 of the 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.