-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
color.go
77 lines (69 loc) · 1.32 KB
/
color.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package utils
import (
"fmt"
)
// ANSIColorEscape escape string for ANSI color
const ANSIColorEscape = "\x1b"
// Base attributes
const (
ANSIColorReset int = iota
ANSIColorBold
ANSIColorFaint
ANSIColorItalic
ANSIColorUnderline
ANSIColorBlinkSlow
ANSIColorBlinkRapid
ANSIColorReverseVideo
ANSIColorConcealed
ANSIColorCrossedOut
)
// Foreground text colors
const (
ANSIColorFgBlack int = iota + 30
ANSIColorFgRed
ANSIColorFgGreen
ANSIColorFgYellow
ANSIColorFgBlue
ANSIColorFgMagenta
ANSIColorFgCyan
ANSIColorFgWhite
)
// Foreground Hi-Intensity text colors
const (
ANSIColorFgHiBlack int = iota + 90
ANSIColorFgHiRed
ANSIColorFgHiGreen
ANSIColorFgHiYellow
ANSIColorFgHiBlue
ANSIColorFgHiMagenta
ANSIColorFgHiCyan
ANSIColorFgHiWhite
)
// Background text colors
const (
ANSIColorBgBlack int = iota + 40
ANSIColorBgRed
ANSIColorBgGreen
ANSIColorBgYellow
ANSIColorBgBlue
ANSIColorBgMagenta
ANSIColorBgCyan
ANSIColorBgWhite
)
// Background Hi-Intensity text colors
const (
ANSIColorBgHiBlack int = iota + 100
ANSIColorBgHiRed
ANSIColorBgHiGreen
ANSIColorBgHiYellow
ANSIColorBgHiBlue
ANSIColorBgHiMagenta
ANSIColorBgHiCyan
ANSIColorBgHiWhite
)
// Color wrap with ANSI color
//
// inspired by github.com/fatih/color
func Color(color int, s string) string {
return fmt.Sprintf("\033[1;%dm%s\033[0m", color, s)
}