color

package module
v0.0.0-...-27789b4 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2015 License: MIT Imports: 7 Imported by: 0

README

Go Color

Build Status

Color your console in Golang.

Install

go install github.com/PierreRambaud/go-color

Examples

// Default usage
color.New("green").Print("This is a green message.")
color.New("red", "underline").Print("This is a red message with an underline.")

// Reuse color
success := color.New("green").Add("bold")
success.Print("Great!")
success.Printf("This is %s", "SPARTA")


// Reusable functions
// Func expects as parameter to be a valid method from
// the Color struct.

error := color.New("red").Func("Print")
error("Error during process..")
error("Can connect..")

info := color.New("yellow").Func("Println")
info("Be careful")
info("Something happened, but nobody cares.")

License

see LICENSE.md for more details

Documentation

Index

Constants

View Source
const Escape = "\x1b"

Variables

View Source
var BgColors = map[string]int{
	"black":   black + 40,
	"red":     red + 40,
	"green":   green + 40,
	"yellow":  yellow + 40,
	"blue":    blue + 40,
	"magenta": magenta + 40,
	"cyan":    cyan + 40,
	"white":   white + 40,
}
View Source
var FgColors = map[string]int{
	"black":   black + 30,
	"red":     red + 30,
	"green":   green + 30,
	"yellow":  yellow + 30,
	"blue":    blue + 30,
	"magenta": magenta + 30,
	"cyan":    cyan + 30,
	"white":   white + 30,
}
View Source
var Style = map[string]int{
	"reset":      0,
	"bold":       1,
	"faint":      2,
	"italic":     3,
	"underline":  4,
	"blinkslow":  5,
	"blinkrapid": 6,
	"reverse":    7,
	"conceal":    8,
	"crossedout": 9,
}

Functions

func ColorCode

func ColorCode(code string) int

func MatchString

func MatchString(regex string, code string) string

Types

type Color

type Color struct {
	// contains filtered or unexported fields
}

Define color object

func New

func New(value ...string) *Color

func (*Color) Add

func (c *Color) Add(value ...string) *Color

func (*Color) Format

func (c *Color) Format() string

func (*Color) Func

func (c *Color) Func(method string) func(args ...interface{})

func (*Color) Print

func (c *Color) Print(attr ...interface{}) (n int, err error)

func (*Color) Printf

func (c *Color) Printf(format string, attr ...interface{}) (n int, err error)

func (*Color) Println

func (c *Color) Println(attr ...interface{}) (n int, err error)

func (*Color) Sequence

func (c *Color) Sequence() string

func (*Color) Set

func (c *Color) Set() *Color

func (*Color) Unset

func (c *Color) Unset() *Color

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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