color

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2015 License: MIT Imports: 2 Imported by: 0

README

Color

Style terminal text.

Installation

go get github.com/labstack/gommon/color

Usage

labstack/gommon/color

Colored text
fmt.Println(color.Black("black"))
fmt.Println(color.Red("red"))
fmt.Println(color.Green("green"))
fmt.Println(color.Yellow("yellow"))
fmt.Println(color.Blue("blue"))
fmt.Println(color.Magenta("magenta"))
fmt.Println(color.Cyan("cyan"))
fmt.Println(color.White("white"))
fmt.Println(color.Grey("grey"))

Colored Text

Colored background
fmt.Println(color.BlackBg("black background", color.Wht))
fmt.Println(color.RedBg("red background"))
fmt.Println(color.GreenBg("green background"))
fmt.Println(color.YellowBg("yellow background"))
fmt.Println(color.BlueBg("blue background"))
fmt.Println(color.MagentaBg("magenta background"))
fmt.Println(color.CyanBg("cyan background"))
fmt.Println(color.WhiteBg("white background"))

Colored Background

Emphasis
fmt.Println(color.Bold("bold"))
fmt.Println(color.Dim("dim"))
fmt.Println(color.Italic("italic"))
fmt.Println(color.Underline("underline"))
fmt.Println(color.Inverse("inverse"))
fmt.Println(color.Hidden("hidden"))
fmt.Println(color.Strikeout("strikeout"))

Emphasis

Mix and match
fmt.Println(color.Green("bold green with white background", color.B, color.WhtBg))
fmt.Println(color.Red("underline red", color.U))
fmt.Println(color.Yellow("dim yellow", color.D))
fmt.Println(color.Cyan("inverse cyan", color.In))
fmt.Println(color.Blue("bold underline dim blue", color.B, color.U, color.D))

Mix and match

Documentation

Index

Constants

View Source
const (
	// Blk Black text style
	Blk = "30"
	// Rd red text style
	Rd = "31"
	// Grn green text style
	Grn = "32"
	// Yel yellow text style
	Yel = "33"
	// Blu blue text style
	Blu = "34"
	// Mgn magenta text style
	Mgn = "35"
	// Cyn cyan text style
	Cyn = "36"
	// Wht white text style
	Wht = "37"
	// Gry grey text style
	Gry = "90"

	// BlkBg black background style
	BlkBg = "40"
	// RdBg red background style
	RdBg = "41"
	// GrnBg green background style
	GrnBg = "42"
	// YelBg yellow background style
	YelBg = "43"
	// BluBg blue background style
	BluBg = "44"
	// MgnBg magenta background style
	MgnBg = "45"
	// CynBg cyan background style
	CynBg = "46"
	// WhtBg white background style
	WhtBg = "47"

	// R reset emphasis style
	R = "0"
	// B bold emphasis style
	B = "1"
	// D dim emphasis style
	D = "2"
	// I italic emphasis style
	I = "3"
	// U underline emphasis style
	U = "4"
	// In inverse emphasis style
	In = "7"
	// Hd hidden emphasis style
	Hd = "8"
	// So strikeout emphasis style
	So = "9"
)

Color styles

Variables

View Source
var (
	// Text color
	Black   = outer(Blk)
	Red     = outer(Rd)
	Green   = outer(Grn)
	Yellow  = outer(Yel)
	Blue    = outer(Blu)
	Magenta = outer(Mgn)
	Cyan    = outer(Cyn)
	White   = outer(Wht)
	Grey    = outer(Gry)

	// Background color
	BlackBg   = outer(BlkBg)
	RedBg     = outer(RdBg)
	GreenBg   = outer(GrnBg)
	YellowBg  = outer(YelBg)
	BlueBg    = outer(BluBg)
	MagentaBg = outer(MgnBg)
	CyanBg    = outer(CynBg)
	WhiteBg   = outer(WhtBg)

	// Emphasis
	Reset     = outer(R)
	Bold      = outer(B)
	Dim       = outer(D)
	Italic    = outer(I)
	Underline = outer(U)
	Inverse   = outer(In)
	Hidden    = outer(Hd)
	Strikeout = outer(So)
)

Color functions

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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