-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstants.go
More file actions
135 lines (120 loc) · 3.98 KB
/
Copy pathconstants.go
File metadata and controls
135 lines (120 loc) · 3.98 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package termtools
import "errors"
const (
// The following constants hold ANSI escape sequences setting color and style of output
Esc string = "\x1b"
//Basic 8 colors
Black string = Esc + "[30m"
Red = Esc + "[31m"
Green = Esc + "[32m"
Yellow = Esc + "[33m"
Blue = Esc + "[34m"
Magenta = Esc + "[35m"
Cyan = Esc + "[36m"
White = Esc + "[37m"
//Additional 8 bright colors
BrightBlack string = Esc + "[30;1m"
BrightRed = Esc + "[31;1m"
BrightGreen = Esc + "[32;1m"
BrightYellow = Esc + "[33;1m"
BrightBlue = Esc + "[34;1m"
BrightMagenta = Esc + "[35;1m"
BrightCyan = Esc + "[36;1m"
BrightWhite = Esc + "[37;1m"
//Basic 8 background colors
BBlack string = Esc + "[40m"
BRed = Esc + "[41m"
BGreen = Esc + "[42m"
BYellow = Esc + "[43m"
BBlue = Esc + "[44m"
BMagenta = Esc + "[45m"
BCyan = Esc + "[46m"
BWhite = Esc + "[47m"
//Additional 8 bright background colors
BBrightBlack string = Esc + "[40;1m"
BBrightRed = Esc + "[41;1m"
BBrightGreen = Esc + "[42;1m"
BBrightYellow = Esc + "[43;1m"
BBrightBlue = Esc + "[44;1m"
BBrightMagenta = Esc + "[45;1m"
BBrightCyan = Esc + "[46;1m"
BBrightWhite = Esc + "[47;1m"
// Color format string to use with 256 color codes. Needs int in range [0;255].
ColorIDTemplate string = Esc + "[38;5;%vm"
BackgroundIDTemplate = Esc + "[48;5;%vm"
//Styles. Can be used separately or together with color and background codes.
Bold string = Esc + "[1m"
Underline = Esc + "[4m"
Blinking = Esc + "[5m"
Reversed = Esc + "[7m"
// Reset escape sequence
Reset string = Esc + "[0m"
// Cursor maniputation
CursorSave string = Esc + "[s"
CursorRestore = Esc + "[u"
CursorHome = Esc + "[H"
CursorGotoTemplate = Esc + "[%v;%vH"
CursorMoveUpTemplate = Esc + "[%vA"
CursorMoveDownTemplate = Esc + "[%vB"
CursorMoveRightTemplate = Esc + "[%vC"
CursorMoveLeftTemplate = Esc + "[%vD"
CursorMoveToNextRowTemplate = Esc + "[E"
CursorMoveToRowTemplate = Esc + "[%vH"
// Clear screen codes
Clear string = Esc + "[2J"
ClearUp = Esc + "[1J"
ClearDown = Esc + "[0J"
// Clear line codes
ClearL string = Esc + "[2K"
ClearLLeft = Esc + "[1K"
ClearLRight = Esc + "[0K"
// FormFeed
FormFeed string = "\x0c"
)
var (
ErrUnknownColor = errors.New("error: unknown color name or color id out of range [0;255]")
ErrUnknownTermSize = errors.New("error: could not find out terminal size")
)
// these maps are used internally to get escapes for named colors
// and styles
var (
colorMap = map[string]string{
"black": Black,
"red": Red,
"green": Green,
"yellow": Yellow,
"blue": Blue,
"magenta": Magenta,
"cyan": Cyan,
"white": White,
"brightblack": BrightBlack,
"brightred": BrightRed,
"brightgreen": BrightGreen,
"brightyellow": BrightYellow,
"brightblue": BrightBlue,
"brightmagenta": BrightMagenta,
"brightcyan": BrightCyan,
"brightwhite": BrightWhite}
backgroundMap = map[string]string{
"black": BBlack,
"red": BRed,
"green": BGreen,
"yellow": BYellow,
"blue": BBlue,
"magenta": BMagenta,
"cyan": BCyan,
"white": BWhite,
"brightblack": BBrightBlack,
"brightred": BBrightRed,
"brightgreen": BBrightGreen,
"brightyellow": BBrightYellow,
"brightblue": BBrightBlue,
"brightmagenta": BBrightMagenta,
"brightcyan": BBrightCyan,
"brightwhite": BBrightWhite}
modeMap = map[string]string{
"bold": Bold,
"underline": Underline,
"blinking": Blinking,
"reversed": Reversed}
)