-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcolors.go
62 lines (55 loc) · 1.19 KB
/
colors.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
package prompt
import escapes "github.com/snugfox/ansi-escapes"
type color uint8
const (
colorBlack color = iota
colorRed
colorGreen
colorYellow
colorBlue
colorMagenta
colorCyan
colorWhite
)
func (c color) toTextEscapes() string {
switch c {
case colorBlack:
return escapes.TextColorBlack
case colorRed:
return escapes.TextColorRed
case colorGreen:
return escapes.TextColorGreen
case colorYellow:
return escapes.TextColorYellow
case colorBlue:
return escapes.TextColorBlue
case colorMagenta:
return escapes.TextColorMagenta
case colorCyan:
return escapes.TextColorCyan
case colorWhite:
return escapes.TextColorWhite
}
panic("invalid color")
}
func (c color) toBackgroundEscapes() string {
switch c {
case colorBlack:
return escapes.BackgroundColorBlack
case colorRed:
return escapes.BackgroundColorRed
case colorGreen:
return escapes.BackgroundColorGreen
case colorYellow:
return escapes.BackgroundColorYellow
case colorBlue:
return escapes.BackgroundColorBlue
case colorMagenta:
return escapes.BackgroundColorMagenta
case colorCyan:
return escapes.BackgroundColorCyan
case colorWhite:
return escapes.BackgroundColorWhite
}
panic("invalid color")
}