Documentation ¶
Overview ¶
Package aurora implements ANSI-colors
Example (Printf) ¶
fmt.Printf("%d %s", Blue(100), BgBlue("cats"))
Output: �[34m100�[0m �[44mcats�[0m
Index ¶
- Constants
- Variables
- func HyperlinkEscape(s string) string
- func HyperlinkTarget(arg interface{}) (target string)
- func HyperlinkUnescape(s string) (raw string, err error)
- func IsValidHyperlinkParam(param string) (valid bool)
- func IsValidHyperlinkTarget(target string) (valid bool)
- func Sprintf(format interface{}, args ...interface{}) string
- type Aurora
- func (a *Aurora) BgBlack(arg interface{}) Value
- func (a *Aurora) BgBlue(arg interface{}) Value
- func (a *Aurora) BgBrightBlack(arg interface{}) Value
- func (a *Aurora) BgBrightBlue(arg interface{}) Value
- func (a *Aurora) BgBrightCyan(arg interface{}) Value
- func (a *Aurora) BgBrightGreen(arg interface{}) Value
- func (a *Aurora) BgBrightMagenta(arg interface{}) Value
- func (a *Aurora) BgBrightRed(arg interface{}) Value
- func (a *Aurora) BgBrightWhite(arg interface{}) Value
- func (a *Aurora) BgBrightYellow(arg interface{}) Value
- func (a *Aurora) BgCyan(arg interface{}) Value
- func (a *Aurora) BgGray(n GrayIndex, arg interface{}) Value
- func (a *Aurora) BgGreen(arg interface{}) Value
- func (a *Aurora) BgIndex(n ColorIndex, arg interface{}) Value
- func (a *Aurora) BgMagenta(arg interface{}) Value
- func (a *Aurora) BgRed(arg interface{}) Value
- func (a *Aurora) BgWhite(arg interface{}) Value
- func (a *Aurora) BgYellow(arg interface{}) Value
- func (a *Aurora) Black(arg interface{}) Value
- func (a *Aurora) Blink(arg interface{}) Value
- func (a *Aurora) Blue(arg interface{}) Value
- func (a *Aurora) Bold(arg interface{}) Value
- func (a *Aurora) BrightBlack(arg interface{}) Value
- func (a *Aurora) BrightBlue(arg interface{}) Value
- func (a *Aurora) BrightCyan(arg interface{}) Value
- func (a *Aurora) BrightGreen(arg interface{}) Value
- func (a *Aurora) BrightMagenta(arg interface{}) Value
- func (a *Aurora) BrightRed(arg interface{}) Value
- func (a *Aurora) BrightWhite(arg interface{}) Value
- func (a *Aurora) BrightYellow(arg interface{}) Value
- func (a *Aurora) Clear(arg interface{}) Value
- func (a *Aurora) Colorize(arg interface{}, color Color) Value
- func (a *Aurora) Conceal(arg interface{}) Value
- func (a *Aurora) Config() Config
- func (a *Aurora) CrossedOut(arg interface{}) Value
- func (a *Aurora) Cyan(arg interface{}) Value
- func (a *Aurora) DoublyUnderline(arg interface{}) Value
- func (a *Aurora) Encircled(arg interface{}) Value
- func (a *Aurora) Faint(arg interface{}) Value
- func (a *Aurora) Fraktur(arg interface{}) Value
- func (a *Aurora) Framed(arg interface{}) Value
- func (a *Aurora) Gray(n GrayIndex, arg interface{}) Value
- func (a *Aurora) Green(arg interface{}) Value
- func (a *Aurora) Hidden(arg interface{}) Value
- func (a *Aurora) Hyperlink(arg interface{}, target string, params ...HyperlinkParam) Value
- func (a *Aurora) HyperlinkParams(arg interface{}) (params []HyperlinkParam)
- func (a *Aurora) HyperlinkTarget(arg interface{}) (target string)
- func (a *Aurora) Index(n ColorIndex, arg interface{}) Value
- func (a *Aurora) Inverse(arg interface{}) Value
- func (a *Aurora) Italic(arg interface{}) Value
- func (a *Aurora) Magenta(arg interface{}) Value
- func (a *Aurora) Overlined(arg interface{}) Value
- func (a *Aurora) RapidBlink(arg interface{}) Value
- func (a *Aurora) Red(arg interface{}) Value
- func (a *Aurora) Reset(arg interface{}) Value
- func (a *Aurora) Reverse(arg interface{}) Value
- func (a *Aurora) SlowBlink(arg interface{}) Value
- func (a *Aurora) Sprintf(format interface{}, args ...interface{}) string
- func (a *Aurora) StrikeThrough(arg interface{}) Value
- func (a *Aurora) Underline(arg interface{}) Value
- func (a *Aurora) White(arg interface{}) Value
- func (a *Aurora) Yellow(arg interface{}) Value
- type Color
- func (c Color) BgBlack() Color
- func (c Color) BgBlue() Color
- func (c Color) BgBrightBlack() Color
- func (c Color) BgBrightBlue() Color
- func (c Color) BgBrightCyan() Color
- func (c Color) BgBrightGreen() Color
- func (c Color) BgBrightMagenta() Color
- func (c Color) BgBrightRed() Color
- func (c Color) BgBrightWhite() Color
- func (c Color) BgBrightYellow() Color
- func (c Color) BgCyan() Color
- func (c Color) BgGray(n GrayIndex) Color
- func (c Color) BgGreen() Color
- func (c Color) BgIndex(n ColorIndex) Color
- func (c Color) BgMagenta() Color
- func (c Color) BgRed() Color
- func (c Color) BgWhite() Color
- func (c Color) BgYellow() Color
- func (c Color) Black() Color
- func (c Color) Blink() Color
- func (c Color) Blue() Color
- func (c Color) Bold() Color
- func (c Color) BrightBlack() Color
- func (c Color) BrightBlue() Color
- func (c Color) BrightCyan() Color
- func (c Color) BrightGreen() Color
- func (c Color) BrightMagenta() Color
- func (c Color) BrightRed() Color
- func (c Color) BrightWhite() Color
- func (c Color) BrightYellow() Color
- func (c Color) Conceal() Color
- func (c Color) CrossedOut() Color
- func (c Color) Cyan() Color
- func (c Color) DoublyUnderline() Color
- func (c Color) Encircled() Color
- func (c Color) Faint() Color
- func (c Color) Fraktur() Color
- func (c Color) Framed() Color
- func (c Color) Gray(n GrayIndex) Color
- func (c Color) Green() Color
- func (c Color) Hidden() Color
- func (c Color) Index(ci ColorIndex) Color
- func (c Color) Inverse() Color
- func (c Color) Italic() Color
- func (c Color) Magenta() Color
- func (c Color) Nos(zero bool) string
- func (c Color) Overlined() Color
- func (c Color) RapidBlink() Color
- func (c Color) Red() Color
- func (c Color) Reset() Color
- func (c Color) Reverse() Color
- func (c Color) SlowBlink() Color
- func (c Color) StrikeThrough() Color
- func (c Color) Underline() Color
- func (c Color) White() Color
- func (c Color) Yellow() Color
- type ColorIndex
- type Colored
- type Config
- type GrayIndex
- type HyperlinkParam
- type Option
- type Value
- func BgBlack(arg interface{}) Value
- func BgBlue(arg interface{}) Value
- func BgBrightBlack(arg interface{}) Value
- func BgBrightBlue(arg interface{}) Value
- func BgBrightCyan(arg interface{}) Value
- func BgBrightGreen(arg interface{}) Value
- func BgBrightMagenta(arg interface{}) Value
- func BgBrightRed(arg interface{}) Value
- func BgBrightWhite(arg interface{}) Value
- func BgBrightYellow(arg interface{}) Value
- func BgCyan(arg interface{}) Value
- func BgGray(n GrayIndex, arg interface{}) Value
- func BgGreen(arg interface{}) Value
- func BgIndex(n ColorIndex, arg interface{}) Value
- func BgMagenta(arg interface{}) Value
- func BgRed(arg interface{}) Value
- func BgWhite(arg interface{}) Value
- func BgYellow(arg interface{}) Value
- func Black(arg interface{}) Value
- func Blink(arg interface{}) Value
- func Blue(arg interface{}) Value
- func Bold(arg interface{}) Value
- func BrightBlack(arg interface{}) Value
- func BrightBlue(arg interface{}) Value
- func BrightCyan(arg interface{}) Value
- func BrightGreen(arg interface{}) Value
- func BrightMagenta(arg interface{}) Value
- func BrightRed(arg interface{}) Value
- func BrightWhite(arg interface{}) Value
- func BrightYellow(arg interface{}) Value
- func Clear(arg interface{}) Value
- func Colorize(arg interface{}, color Color) Value
- func Conceal(arg interface{}) Value
- func CrossedOut(arg interface{}) Value
- func Cyan(arg interface{}) Value
- func DoublyUnderline(arg interface{}) Value
- func Encircled(arg interface{}) Value
- func Faint(arg interface{}) Value
- func Fraktur(arg interface{}) Value
- func Framed(arg interface{}) Value
- func Gray(n GrayIndex, arg interface{}) Value
- func Green(arg interface{}) Value
- func Hidden(arg interface{}) Value
- func Hyperlink(arg interface{}, target string, params ...HyperlinkParam) Value
- func Index(n ColorIndex, arg interface{}) Value
- func Inverse(arg interface{}) Value
- func Italic(arg interface{}) Value
- func Magenta(arg interface{}) Value
- func Overlined(arg interface{}) Value
- func RapidBlink(arg interface{}) Value
- func Red(arg interface{}) Value
- func Reset(arg interface{}) Value
- func Reverse(arg interface{}) Value
- func SlowBlink(arg interface{}) Value
- func StrikeThrough(arg interface{}) Value
- func Underline(arg interface{}) Value
- func White(arg interface{}) Value
- func Yellow(arg interface{}) Value
- func (v Value) BgBlack() Value
- func (v Value) BgBlue() Value
- func (v Value) BgBrightBlack() Value
- func (v Value) BgBrightBlue() Value
- func (v Value) BgBrightCyan() Value
- func (v Value) BgBrightGreen() Value
- func (v Value) BgBrightMagenta() Value
- func (v Value) BgBrightRed() Value
- func (v Value) BgBrightWhite() Value
- func (v Value) BgBrightYellow() Value
- func (v Value) BgCyan() Value
- func (v Value) BgGray(n GrayIndex) Value
- func (v Value) BgGreen() Value
- func (v Value) BgIndex(n ColorIndex) Value
- func (v Value) BgMagenta() Value
- func (v Value) BgRed() Value
- func (v Value) BgWhite() Value
- func (v Value) BgYellow() Value
- func (v Value) Black() Value
- func (v Value) Blink() Value
- func (v Value) Blue() Value
- func (v Value) Bold() Value
- func (v Value) BrightBlack() Value
- func (v Value) BrightBlue() Value
- func (v Value) BrightCyan() Value
- func (v Value) BrightGreen() Value
- func (v Value) BrightMagenta() Value
- func (v Value) BrightRed() Value
- func (v Value) BrightWhite() Value
- func (v Value) BrightYellow() Value
- func (v Value) Clear() Value
- func (v Value) Color() Color
- func (v Value) Colorize(color Color) Value
- func (v Value) Conceal() Value
- func (v Value) CrossedOut() Value
- func (v Value) Cyan() Value
- func (v Value) DoublyUnderline() Value
- func (v Value) Encircled() Value
- func (v Value) Faint() Value
- func (v Value) Format(s fmt.State, verb rune)
- func (v Value) Fraktur() Value
- func (v Value) Framed() Value
- func (v Value) Gray(n GrayIndex) Value
- func (v Value) Green() Value
- func (v Value) Hidden() Value
- func (v Value) Hyperlink(target string, params ...HyperlinkParam) Value
- func (v Value) HyperlinkParams() (params []HyperlinkParam)
- func (v Value) HyperlinkTarget() (target string)
- func (v Value) Index(n ColorIndex) Value
- func (v Value) Inverse() Value
- func (v Value) Italic() Value
- func (v Value) Magenta() Value
- func (v Value) Overlined() Value
- func (v Value) RapidBlink() Value
- func (v Value) Red() Value
- func (v Value) Reset() Value
- func (v Value) Reverse() Value
- func (v Value) SlowBlink() Value
- func (v Value) StrikeThrough() Value
- func (v Value) String() string
- func (v Value) Underline() Value
- func (v Value) Value() interface{}
- func (v Value) White() Value
- func (v Value) Yellow() Value
Examples ¶
Constants ¶
const (
HyperlinkIDKey = "id" // hyperlink id parameter key
)
Hyperlinks related constants
Variables ¶
var DefaultColorizer = New(WithColors(true), WithHyperlinks(true))
DefaultColorizer is global colorizer that used for package root color methods.
Functions ¶
func HyperlinkEscape ¶
HyperlinkEscape escapes all symbols of given string out of [32; 126] range using URL-encoding. Used to escape a hyperlink target.
func HyperlinkTarget ¶
func HyperlinkTarget(arg interface{}) (target string)
HyperlinkTarget of the argument if it's a Value.
func HyperlinkUnescape ¶
HyperlinkUnescape reverts a string escaped by the HyperlinkEscape.
func IsValidHyperlinkParam ¶
IsValidHyperlinkParam returns true for given string, if the string is valid hyperlink target (see IsValidHyperlinkTarget) and doesn't contains ':', ';' and '='.
func IsValidHyperlinkTarget ¶
IsValidHyperlinkTarget returns true if the target contains symbols only in 32-126 ASCII range. All symbols outside this range should be URL-escaped.
func Sprintf ¶
func Sprintf(format interface{}, args ...interface{}) string
Sprintf allows to use Value as format. For example
var v = Sprintf(Red("total: +3.5f points"), Blue(3.14))
In this case "total:" and "points" will be red, but 3.14 will be blue. But, in another example
var v = Sprintf(Red("total: +3.5f points"), 3.14)
full string will be red. And no way to clear 3.14 to default format and color.
It applies own configurations to all given Values.
Example ¶
fmt.Print( Sprintf( Blue("we've got %d cats, but want %d"), // <- blue format Cyan(5), Bold(Magenta(25)), ), )
Output: �[34mwe've got �[0;36m5�[0;34m cats, but want �[0;1;35m25�[0;34m�[0m
Types ¶
type Aurora ¶
type Aurora struct {
// contains filtered or unexported fields
}
func New ¶
New returns new colorizer by given Options.
Example (Colors) ¶
var a = New() fmt.Println(a.Red("Red"))
Output: �[31mRed�[0m
Example (No_colors) ¶
var a = New(WithColors(false), WithHyperlinks(false)) fmt.Println(a.Red("Not red"))
Output: Not red
func (*Aurora) BgBrightBlue ¶
BgBrightBlue background color (104).
func (*Aurora) BgBrightCyan ¶
BgBrightCyan background color (106).
func (*Aurora) BgBrightGreen ¶
BgBrightGreen background color (102).
func (*Aurora) BgBrightMagenta ¶
BgBrightMagenta background color (105).
func (*Aurora) BgBrightRed ¶
BgBrightRed background color (101).
func (*Aurora) BgBrightWhite ¶
BgBrightWhite background color (107).
func (*Aurora) BgBrightYellow ¶
BgBrightYellow background color (103).
func (*Aurora) BgIndex ¶
func (a *Aurora) BgIndex(n ColorIndex, arg interface{}) Value
Other background colors.
BgIndex of 8-bit pre-defined background color from 0 to 255 (48;5;n).
0- 7: standard colors (as in ESC [ 40–47 m) 8- 15: high intensity colors (as in ESC [100–107 m) 16-231: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5) 232-255: grayscale from black to white in 24 steps
func (*Aurora) BrightBlue ¶
BrightBlue foreground color (94).
func (*Aurora) BrightCyan ¶
BrightCyan foreground color (96).
func (*Aurora) BrightGreen ¶
BrightGreen foreground color (92).
func (*Aurora) BrightMagenta ¶
BrightMagenta foreground color (95).
func (*Aurora) BrightWhite ¶
BrightWhite foreground color (97).
func (*Aurora) BrightYellow ¶
BrightYellow foreground color (93).
func (*Aurora) Clear ¶
Clear wraps given argument returning Value without formats and colors. But preserving links.
func (*Aurora) Colorize ¶
Special color functions.
Colorize removes existing colors and formats of the argument and applies given.
func (*Aurora) CrossedOut ¶
CrossedOut, characters legible, but marked for deletion (9).
func (*Aurora) DoublyUnderline ¶
DoublyUnderline or Bold off, double-underline per ECMA-48 (21).
func (*Aurora) Hyperlink ¶
func (a *Aurora) Hyperlink(arg interface{}, target string, params ...HyperlinkParam) Value
Hyperlinks feature
Hyperlink with given target and parameters. If hyperlinks feature is disabled, then the 'arg' argument dropped and the 'target' used instead inheriting all colors and format from the 'arg' (if it's a Colored).
See https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda for details about the hyperlinks feature.
The Hyperlink doesn't escape the target and the params. They should be checked and escaped before.
See also HyperlinkID function.
For a simple example
au.Hyperlink("Example", "http://example.com")
and an example with ID
au.Hyperlink("Example", "http://example.com", aurora.HyperlinkID("10"))
func (*Aurora) HyperlinkParams ¶
func (a *Aurora) HyperlinkParams(arg interface{}) (params []HyperlinkParam)
HyperlinkParams of the argument if it's a Value.
func (*Aurora) HyperlinkTarget ¶
HyperlinkTarget of the argument if it's a Value.
func (*Aurora) Index ¶
func (a *Aurora) Index(n ColorIndex, arg interface{}) Value
Other colors.
Index of pre-defined 8-bit foreground color from 0 to 255 (38;5;n).
0- 7: standard colors (as in ESC [ 30–37 m) 8- 15: high intensity colors (as in ESC [ 90–97 m) 16-231: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5) 232-255: grayscale from black to white in 24 steps
func (*Aurora) RapidBlink ¶
RapidBlink, blinking 150+ per minute, not widely supported (6).
func (*Aurora) Reset ¶
Reset wraps given argument returning Value without formats, colors and links.
func (*Aurora) Sprintf ¶
Sprintf allows to use Value as format. For example
var v = Sprintf(Red("total: +3.5f points"), Blue(3.14))
In this case "total:" and "points" will be red, but 3.14 will be blue. But, in another example
var v = Sprintf(Red("total: +3.5f points"), 3.14)
full string will be red. And no way to clear 3.14 to default format and color.
It applies own configurations to all given Values.
func (*Aurora) StrikeThrough ¶
StrikeThrough is alias for the CrossedOut.
type Color ¶
type Color uint
A Color type is a color. It can contain one background color, one foreground color and a format, including ideogram related formats.
const ( BoldFm Color = 1 << iota // 1 FaintFm // 2 ItalicFm // 3 UnderlineFm // 4 SlowBlinkFm // 5 RapidBlinkFm // 6 ReverseFm // 7 ConcealFm // 8 CrossedOutFm // 9 FrakturFm // 20 DoublyUnderlineFm // 21 or bold off for some systems FramedFm // 51 EncircledFm // 52 OverlinedFm // 53 InverseFm = ReverseFm // alias to ReverseFm BlinkFm = SlowBlinkFm // alias to SlowBlinkFm HiddenFm = ConcealFm // alias to ConcealFm StrikeThroughFm = CrossedOutFm // alias to CrossedOutFm )
Special formats
const ( BlackFg Color = (iota << shiftFg) | flagFg // 30, 90 RedFg // 31, 91 GreenFg // 32, 92 YellowFg // 33, 93 BlueFg // 34, 94 MagentaFg // 35, 95 CyanFg // 36, 96 WhiteFg // 37, 97 BrightFg Color = ((1 << 3) << shiftFg) | flagFg // -> 90 )
Foreground colors and related formats
const ( BlackBg Color = (iota << shiftBg) | flagBg // 40, 100 RedBg // 41, 101 GreenBg // 42, 102 YellowBg // 43, 103 BlueBg // 44, 104 MagentaBg // 45, 105 CyanBg // 46, 106 WhiteBg // 47, 107 BrightBg Color = ((1 << 3) << shiftBg) | flagBg // -> 100 )
Background colors and related formats
func (Color) BgBrightGreen ¶
BgBrightGreen background color (102)
func (Color) BgBrightMagenta ¶
BgBrightMagenta background color (105)
func (Color) BgBrightWhite ¶
BgBrightWhite background color (107)
func (Color) BgBrightYellow ¶
BgBrightYellow background color (103)
func (Color) BgIndex ¶
func (c Color) BgIndex(n ColorIndex) Color
Other
BgIndex of 8-bit pre-defined background color from 0 to 255 (48;5;n).
0- 7: standard colors (as in ESC [ 40–47 m) 8- 15: high intensity colors (as in ESC [100–107 m) 16-231: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5) 232-255: grayscale from black to white in 24 steps
func (Color) BrightMagenta ¶
BrightMagenta foreground color (95)
func (Color) CrossedOut ¶
CrossedOut, characters legible, but marked for deletion (9).
func (Color) DoublyUnderline ¶
DoublyUnderline or Bold off, double-underline per ECMA-48 (21).
func (Color) Index ¶
func (c Color) Index(ci ColorIndex) Color
Other
Index of pre-defined 8-bit foreground color from 0 to 255 (38;5;n).
0- 7: standard colors (as in ESC [ 30–37 m) 8- 15: high intensity colors (as in ESC [ 90–97 m) 16-231: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5) 232-255: grayscale from black to white in 24 steps
func (Color) Nos ¶
Nos returns string like 1;7;31;45. It may be an empty string for empty color. If the zero is true, then the string is prepended with 0;
func (Color) RapidBlink ¶
RapidBlink, blinking 150+ per minute, not widely supported (6).
func (Color) StrikeThrough ¶
StrikeThrough is alias for the CrossedOut.
type ColorIndex ¶
type ColorIndex uint8
ColorIndex is index of pre-defined 8-bit foreground or background colors from 0 to 255 (38;5;n).
0- 7: standard colors (as in ESC [ 30–37 m) 8- 15: high intensity colors (as in ESC [ 90–97 m) 16-231: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5) 232-255: grayscale from black to white in 24 steps
type Colored ¶
type Colored interface {
Color() Color // color of the value
}
The Colored interface represents a value with a Color.
type Config ¶
type Config struct { // Colors feature. Enable colors if true. Colors bool `json:"colors" yaml:"colors" toml:"colors" mapstructure:"colors"` // Hyperlinks feature. Enable hyperlinks if true. Hyperlinks bool `json:"hyperlinks" yaml:"hyperlinks" toml:"hyperlinks" mapstructure:"hyperlinks"` }
Config represents configurations of a colorizer.
func (*Config) AddFlags ¶
AddFlags to given *flag.FlagSet. The prefix used as prefix for flags. It may be used to parse commandline flags. For example
var conf Config conf.AddFlags(flag.CommandLine, "colors.") flag.Parse()
for a main package, and use with flags commandline flags,
go run main.go -colors.colors -colors.hyperlinks
to enable or disable features. A colorizer can be created, for example,
var colorizer = New(conf.Options()...)
type HyperlinkParam ¶
The HyperlinkParam represents a hyperlink parameter.
func HyperlinkID ¶
func HyperlinkID(id string) HyperlinkParam
HyperlinkID returns list of HyperlinkParams that contains only id parameter with given value of the id parameter.
func HyperlinkParams ¶
func HyperlinkParams(arg interface{}) (params []HyperlinkParam)
HyperlinkParams of the argument if it's a Value.
func (HyperlinkParam) String ¶
func (hp HyperlinkParam) String() string
String represents the HyperlinkParam as string, e.g. in key=value form.
type Option ¶
type Option func(*Config)
An Option function.
func WithColors ¶
WithColors is an Option that used to enable or disable colors.
func WithHyperlinks ¶
WithHyperlinks is an Option that used to enable or disable links.
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
A Value represents any printable value with or without colors, formats and a link.
func BgBrightMagenta ¶
func BgBrightMagenta(arg interface{}) Value
BgBrightMagenta background color (105)
func BgBrightYellow ¶
func BgBrightYellow(arg interface{}) Value
BgBrightYellow background color (103)
func BgIndex ¶
func BgIndex(n ColorIndex, arg interface{}) Value
BgIndex of 8-bit pre-defined background color from 0 to 255 (48;5;n).
0- 7: standard colors (as in ESC [ 40–47 m) 8- 15: high intensity colors (as in ESC [100–107 m) 16-231: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5) 232-255: grayscale from black to white in 24 steps
func Bold ¶
func Bold(arg interface{}) Value
Bold or increased intensity (1).
Example ¶
fmt.Println("value:", Bold(Green(99)))
Output: value: �[1;32m99�[0m
func Clear ¶
func Clear(arg interface{}) Value
Clear wraps given argument returning Value without formats and colors. But preserving links.
func Colorize ¶
Colorize wraps given value into Value with given colors. For example
var s = Colorize("some", BlueFg|GreenBg|BoldFm)
returns a Value with blue foreground, green background and bold. Unlike functions like Red/BgBlue/Bold etc. This function clears all previous colors and formats. Thus
var s = Colorize(Red("some"), BgBlue)
clears red color from value.
func Conceal ¶
func Conceal(arg interface{}) Value
Conceal hides text, preserving an ability to select the text and copy it. It is not widely supported (8).
func CrossedOut ¶
func CrossedOut(arg interface{}) Value
CrossedOut makes characters legible, but marked for deletion (9).
func DoublyUnderline ¶
func DoublyUnderline(arg interface{}) Value
DoublyUnderline or Bold off, double-underline per ECMA-48 (21).
func Faint ¶
func Faint(arg interface{}) Value
Faint decreases intensity (2). The Faint rejects the Bold.
func Hyperlink ¶
func Hyperlink(arg interface{}, target string, params ...HyperlinkParam) Value
Hyperlink with given target and parameters. If hyperlinks feature is disabled, then the 'arg' argument dropped and the 'target' used instead inheriting all colors and format from the 'arg' (if it's a Colored).
See https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda for details about the hyperlinks feature.
The Hyperlink doesn't escape the target and the params. They should be checked and escaped before.
See also HyperlinkID function.
For a simple example
au.Hyperlink("Example", "http://example.com")
and an example with ID
au.Hyperlink("Example", "http://example.com", aurora.HyperlinkID("10"))
Example ¶
fmt.Println(Hyperlink(Red("Example"), "http://example.com/"))
Output: �]8;;http://example.com/�\�[31mExample�[0m�]8;;�\
func Index ¶
func Index(n ColorIndex, arg interface{}) Value
Index of pre-defined 8-bit foreground color from 0 to 255 (38;5;n).
0- 7: standard colors (as in ESC [ 30–37 m) 8- 15: high intensity colors (as in ESC [ 90–97 m) 16-231: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5) 232-255: grayscale from black to white in 24 steps
func Italic ¶
func Italic(arg interface{}) Value
Italic is not widely supported, sometimes treated as inverse (3).
func RapidBlink ¶
func RapidBlink(arg interface{}) Value
RapidBlink makes text blink 150+ per minute. It is not widely supported (6).
func Red ¶
func Red(arg interface{}) Value
Red foreground color (31)
Example ¶
fmt.Println("value exceeds min-threshold:", Red(3.14))
Output: value exceeds min-threshold: �[31m3.14�[0m
func Reset ¶
func Reset(arg interface{}) Value
Reset wraps given argument returning Value without formats, colors and links.
func Reverse ¶
func Reverse(arg interface{}) Value
Reverse video, swap foreground and background colors (7).
func SlowBlink ¶
func SlowBlink(arg interface{}) Value
SlowBlink makes text blink less than 150 per minute (5).
func StrikeThrough ¶
func StrikeThrough(arg interface{}) Value
StrikeThrough is alias for the CrossedOut.
func (Value) BgBrightBlue ¶
BgBrightBlue background color (104).
func (Value) BgBrightCyan ¶
BgBrightCyan background color (106).
func (Value) BgBrightGreen ¶
BgBrightGreen background color (102).
func (Value) BgBrightMagenta ¶
BgBrightMagenta background color (105).
func (Value) BgBrightWhite ¶
BgBrightWhite background color (107).
func (Value) BgBrightYellow ¶
BgBrightYellow background color (103).
func (Value) BgIndex ¶
func (v Value) BgIndex(n ColorIndex) Value
Other background colors.
BgIndex of 8-bit pre-defined background color from 0 to 255 (48;5;n).
0- 7: standard colors (as in ESC [ 40–47 m) 8- 15: high intensity colors (as in ESC [100–107 m) 16-231: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5) 232-255: grayscale from black to white in 24 steps
func (Value) BrightMagenta ¶
BrightMagenta foreground color (95).
func (Value) Colorize ¶
Special colorization method.
Colorize removes existing colors and formats of the argument and applies given.
func (Value) CrossedOut ¶
CrossedOut, characters legible, but marked for deletion (9).
func (Value) DoublyUnderline ¶
DoublyUnderline or Bold off, double-underline per ECMA-48 (21). It depends.
func (Value) Hyperlink ¶
func (v Value) Hyperlink(target string, params ...HyperlinkParam) Value
Hyperlinks feature
Hyperlink with given target and parameters. If hyperlinks feature is disabled, then the 'arg' argument dropped and the 'target' used instead, inheriting all colors and format from the 'arg' (if it's a Colored).
See https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda for details about the hyperlinks feature.
The Hyperlink doesn't escape the target and the parameters. They should be checked and escaped before. See HyperlinkEscape function.
See also HyperlinkID function.
For a simple example
val.Hyperlink("http://example.com")
and an example with ID
val.Hyperlink("http://example.com", aurora.HyperlinkID("10"))
Successive calls replace previously set target and parameters.
func (Value) HyperlinkParams ¶
func (v Value) HyperlinkParams() (params []HyperlinkParam)
HyperlinkParams if any.
func (Value) HyperlinkTarget ¶
HyperlinkTarget if any.
func (Value) Index ¶
func (v Value) Index(n ColorIndex) Value
Other colors.
Index of pre-defined 8-bit foreground color from 0 to 255 (38;5;n).
0- 7: standard colors (as in ESC [ 30–37 m) 8- 15: high intensity colors (as in ESC [ 90–97 m) 16-231: 6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5) 232-255: grayscale from black to white in 24 steps
func (Value) RapidBlink ¶
RapidBlink, blinking 150+ per minute, not widely supported (6).
func (Value) StrikeThrough ¶
StrikeThrough is alias for the CrossedOut.