Documentation ¶
Overview ¶
Most color package seem overkill for my project need.This package simply provide helper to inject ANSI escape code into the string and return string with injected ANSI code. Then you decide where to print the string afterward , if it detect your terminal isn't able to print color , no color will be inject The API can be used in several way. Pick the one that suit your project
Use global default helper function to set either background or foreground color ¶
Red("Hello World") Blue("Hello World") Magenta("Hello World") Green("Hello World") Yellow("Hello World") White("Hello World") Cyan("Hello World") RedBg("Hello World") BlueBg("Hello World") MagentaBg("Hello World") GreenBg("Hello World") YellowBg("Hello World") WhiteBg("Hello World") CyanBg("Hello World")
When multiple style need to be apply , method can be chain ¶
Red("Hello World").BlueBg() Green("Hello World").Bold() Yellow("Hello World").Underline().Bold().Italic()
high intensity also available with {Hi} started ¶
HiYellow(...)
other base method also available ¶
Bold("Hello World") Underline("Hello World") StrikeOut("Hello World") Italic("Hello World") Dim("Hello World") Hidden("Hello World") Inverse("Hello World")
there are timewhen custom color mixed is required. Then you can create color object , derive from color object ,... ¶
You can add style by either using property attributes , which is available below
New(FRed, BoldText).Sprint("hello wolrd")
Or by using method
New().Blue().RedBg().Sprintf("hello world")
Derived from base object
c := New(BoldText , UnderlineText) pass := c.Derive(FGreen) // with green as foreground color fail := c.Derive(FRed) // with red as foreground color pass.Sprintf("ok") fail.Sprintf("fail").DimText()
## Available Properties
- **Base** : BoldText , DimText , ItalicText , UnderlineText , InverseText , HiddenText , StrikeOut - **Foreground Color** : F{Color} - **Background Color** : B{Color} - **HighIntensity Version** : {F|B}{Color}.High() - **Reset Base** : {Base}.Reset()
Index ¶
- Constants
- func Black(format string, msg ...interface{}) colorStr
- func BlackBg(format string, msg ...interface{}) colorStr
- func Blue(format string, msg ...interface{}) colorStr
- func BlueBg(format string, msg ...interface{}) colorStr
- func Bold(format string, msg ...interface{}) colorStr
- func Cyan(format string, msg ...interface{}) colorStr
- func CyanBg(format string, msg ...interface{}) colorStr
- func Dim(format string, msg ...interface{}) colorStr
- func Green(format string, msg ...interface{}) colorStr
- func GreenBg(format string, msg ...interface{}) colorStr
- func HiBlack(format string, msg ...interface{}) colorStr
- func HiBlackBg(format string, msg ...interface{}) colorStr
- func HiBlue(format string, msg ...interface{}) colorStr
- func HiBlueBg(format string, msg ...interface{}) colorStr
- func HiCyan(format string, msg ...interface{}) colorStr
- func HiCyanBg(format string, msg ...interface{}) colorStr
- func HiGreen(format string, msg ...interface{}) colorStr
- func HiGreenBg(format string, msg ...interface{}) colorStr
- func HiMagenta(format string, msg ...interface{}) colorStr
- func HiMagentaBg(format string, msg ...interface{}) colorStr
- func HiRed(format string, msg ...interface{}) colorStr
- func HiRedBg(format string, msg ...interface{}) colorStr
- func HiWhite(format string, msg ...interface{}) colorStr
- func HiWhiteBg(format string, msg ...interface{}) colorStr
- func HiYellow(format string, msg ...interface{}) colorStr
- func HiYellowBg(format string, msg ...interface{}) colorStr
- func Hidden(format string, msg ...interface{}) colorStr
- func Inverse(format string, msg ...interface{}) colorStr
- func Italic(format string, msg ...interface{}) colorStr
- func Magenta(format string, msg ...interface{}) colorStr
- func MagentaBg(format string, msg ...interface{}) colorStr
- func New(properties ...property) *color
- func Red(format string, msg ...interface{}) colorStr
- func RedBg(format string, msg ...interface{}) colorStr
- func StrikeOut(format string, msg ...interface{}) colorStr
- func Underline(format string, msg ...interface{}) colorStr
- func White(format string, msg ...interface{}) colorStr
- func WhiteBg(format string, msg ...interface{}) colorStr
- func Yellow(format string, msg ...interface{}) colorStr
- func YellowBg(format string, msg ...interface{}) colorStr
Constants ¶
const ( // bold. BoldText property // Dim. DimText // italic. ItalicText // underline. UnderlineText // InverseText. InverseText property = iota + 2 // HiddenText. HiddenText // StrikeOutText. StrikeOutText )
Base.
const ( // Black. FBlack property = iota + 30 // Red. FRed // Green. FGreen // Yellow. FYellow // Blue. FBlue // Magenta. FMagenta // Cyan. FCyan // White. FWhite )
FgColor.
const ( // Black. BBlack property = iota + 40 // Red. BRed // Green. BGreen // Yellow. BYellow // Blue. BBlue // Magenta. BMagenta // Cyan. BCyan // White. BWhite )
BgColor.
Variables ¶
This section is empty.
Functions ¶
func BlackBg ¶
func BlackBg(format string, msg ...interface{}) colorStr
Change background color to black.
func BlueBg ¶
func BlueBg(format string, msg ...interface{}) colorStr
Change background color to blue.
func CyanBg ¶
func CyanBg(format string, msg ...interface{}) colorStr
Change background color to cyan.
func GreenBg ¶
func GreenBg(format string, msg ...interface{}) colorStr
Change background color to green.
func HiBlack ¶
func HiBlack(format string, msg ...interface{}) colorStr
Change text color to high-intensity black.
func HiBlackBg ¶
func HiBlackBg(format string, msg ...interface{}) colorStr
Change background color to high-intensity black.
func HiBlue ¶
func HiBlue(format string, msg ...interface{}) colorStr
Change text color to high-intensity blue.
func HiBlueBg ¶
func HiBlueBg(format string, msg ...interface{}) colorStr
Change background color to high-intensity blue.
func HiCyan ¶
func HiCyan(format string, msg ...interface{}) colorStr
Change text color to high-intensity cyan.
func HiCyanBg ¶
func HiCyanBg(format string, msg ...interface{}) colorStr
Change background color to high-intensity cyan.
func HiGreen ¶
func HiGreen(format string, msg ...interface{}) colorStr
Change text color to high-intensity green.
func HiGreenBg ¶
func HiGreenBg(format string, msg ...interface{}) colorStr
Change background color to high-intensity green.
func HiMagenta ¶
func HiMagenta(format string, msg ...interface{}) colorStr
Change text color to high-intensity magenta.
func HiMagentaBg ¶
func HiMagentaBg(format string, msg ...interface{}) colorStr
func HiRed ¶
func HiRed(format string, msg ...interface{}) colorStr
Change text color to high-intensity red.
func HiRedBg ¶
func HiRedBg(format string, msg ...interface{}) colorStr
Change background color to high-intensity red.
func HiWhite ¶
func HiWhite(format string, msg ...interface{}) colorStr
Change text color to high-intensity white.
func HiWhiteBg ¶
func HiWhiteBg(format string, msg ...interface{}) colorStr
Change background color to high-intensity white.
func HiYellow ¶
func HiYellow(format string, msg ...interface{}) colorStr
Change text color to high-intensity yellow.
func HiYellowBg ¶
func HiYellowBg(format string, msg ...interface{}) colorStr
Change background color to high-intensity yellow.
func Magenta ¶
func Magenta(format string, msg ...interface{}) colorStr
Change text color to magenta.
func MagentaBg ¶
func MagentaBg(format string, msg ...interface{}) colorStr
Change background color to magenta.
func New ¶
func New(properties ...property) *color
New color instance , properties can be added now or later.
func StrikeOut ¶
func StrikeOut(format string, msg ...interface{}) colorStr
Apply strikeout text style.
func Underline ¶
func Underline(format string, msg ...interface{}) colorStr
Apply underline text style.
Types ¶
This section is empty.