Documentation ¶
Index ¶
- Constants
- Variables
- func Colorize(str string, styles ...Style) string
- type Box
- type Crayon
- func (c *Crayon) Append(styles ...Style) *Crayon
- func (c *Crayon) Apply() *Crayon
- func (c *Crayon) Fmt() string
- func (c *Crayon) Monochrome(m bool)
- func (c *Crayon) Prepend(s Style) *Crayon
- func (c *Crayon) Print(a ...interface{}) (int, error)
- func (c *Crayon) Printf(base string, a ...interface{}) (int, error)
- func (c *Crayon) Println(a ...interface{}) (int, error)
- func (c *Crayon) Reset() *Crayon
- func (c *Crayon) Sprint(a ...interface{}) string
- func (c *Crayon) Sprintf(base string, a ...interface{}) string
- func (c *Crayon) Sprintln(a ...interface{}) string
- func (c *Crayon) Styles() []Style
- func (c *Crayon) Unfmt() string
- type Style
Constants ¶
View Source
const ( FgBrightBlack = iota + 90 FgBrightRed FgBrightGreen FgBrightYellow FgBrightBlue FgBrightMagenta FgBrightCyan FgWhite )
Bright Foreground Colors
Variables ¶
View Source
var ( // ErrRemoveBase is when you try to remove the base crayon ErrRemoveBase = errors.New("Cannot remove base crayon") // ErrNilCrayon occurs when you attempt to store a nil crayon ErrNilCrayon = errors.New("Crayon cannot be a nil reference") )
View Source
var ( // Writer is a where crayons will draw too Writer = ansicolor.NewAnsiColorWriter(os.Stdout) // Monochrome checkts if it is tty Monochrome = !isatty.IsTerminal(os.Stdout.Fd()) )
Functions ¶
Types ¶
type Box ¶
Box is collection of crayons.
func NewBox ¶
NewBox creates a box of crayons and applys a default setting. If Base is nil, it will default to white text on a black background.
type Crayon ¶
type Crayon struct {
// contains filtered or unexported fields
}
Crayon is the structure for a crayon. It contains unexported fields
func New ¶
New returns a pointer to an instance of a crayon. You can add several styles and it will add them all.
func (*Crayon) Apply ¶
Apply is the manual way of enabling the style for your string but will remain in effect unless you call Reset.
func (*Crayon) Monochrome ¶
Monochrome lets you set an individual crayon
type Style ¶
type Style int
Style is alias type for int
const ( Clear Style = iota Bold Faint Italic Underline BlinkSlow BlinkRapid ReverseVideo Concealed CrossedOut )
Core Styles
const ( FgBlack Style = iota + 30 FgRed FgGreen FgYellow FgBlue FgMagenta FgCyan FgBrightGrey DefaultFg )
Foreground Colors
Click to show internal directories.
Click to hide internal directories.