aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/old/vlib/term/colors.v
blob: f7662eea31a3db5e2c602f97f44278ddd0cf9206 (plain)
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
// Copyright (c) 2019-2021 Alexander Medvednikov. All rights reserved.
// Use of this source code is governed by an MIT license
// that can be found in the LICENSE file.
module term

pub fn format(msg string, open string, close string) string {
	return '\x1b[' + open + 'm' + msg + '\x1b[' + close + 'm'
}

pub fn format_rgb(r int, g int, b int, msg string, open string, close string) string {
	return '\x1b[' + open + ';2;' + r.str() + ';' + g.str() + ';' + b.str() + 'm' + msg + '\x1b[' +
		close + 'm'
}

pub fn rgb(r int, g int, b int, msg string) string {
	return format_rgb(r, g, b, msg, '38', '39')
}

pub fn bg_rgb(r int, g int, b int, msg string) string {
	return format_rgb(r, g, b, msg, '48', '49')
}

pub fn hex(hex int, msg string) string {
	return format_rgb(hex >> 16, hex >> 8 & 0xFF, hex & 0xFF, msg, '38', '39')
}

pub fn bg_hex(hex int, msg string) string {
	return format_rgb(hex >> 16, hex >> 8 & 0xFF, hex & 0xFF, msg, '48', '49')
}

pub fn bg_black(msg string) string {
	return format(msg, '40', '49')
}

pub fn bright_bg_black(msg string) string {
	return format(msg, '100', '49')
}

pub fn bg_blue(msg string) string {
	return format(msg, '44', '49')
}

pub fn bright_bg_blue(msg string) string {
	return format(msg, '104', '49')
}

pub fn bg_cyan(msg string) string {
	return format(msg, '46', '49')
}

pub fn bright_bg_cyan(msg string) string {
	return format(msg, '106', '49')
}

pub fn bg_green(msg string) string {
	return format(msg, '42', '49')
}

pub fn bright_bg_green(msg string) string {
	return format(msg, '102', '49')
}

pub fn bg_magenta(msg string) string {
	return format(msg, '45', '49')
}

pub fn bright_bg_magenta(msg string) string {
	return format(msg, '105', '49')
}

pub fn bg_red(msg string) string {
	return format(msg, '41', '49')
}

pub fn bright_bg_red(msg string) string {
	return format(msg, '101', '49')
}

pub fn bg_white(msg string) string {
	return format(msg, '47', '49')
}

pub fn bright_bg_white(msg string) string {
	return format(msg, '107', '49')
}

pub fn bg_yellow(msg string) string {
	return format(msg, '43', '49')
}

pub fn bright_bg_yellow(msg string) string {
	return format(msg, '103', '49')
}

pub fn black(msg string) string {
	return format(msg, '30', '39')
}

pub fn bright_black(msg string) string {
	return format(msg, '90', '39')
}

pub fn blue(msg string) string {
	return format(msg, '34', '39')
}

pub fn bright_blue(msg string) string {
	return format(msg, '94', '39')
}

pub fn bold(msg string) string {
	return format(msg, '1', '22')
}

pub fn cyan(msg string) string {
	return format(msg, '36', '39')
}

pub fn bright_cyan(msg string) string {
	return format(msg, '96', '39')
}

pub fn dim(msg string) string {
	return format(msg, '2', '22')
}

pub fn green(msg string) string {
	return format(msg, '32', '39')
}

pub fn bright_green(msg string) string {
	return format(msg, '92', '39')
}

pub fn gray(msg string) string {
	return bright_black(msg)
}

pub fn hidden(msg string) string {
	return format(msg, '8', '28')
}

pub fn italic(msg string) string {
	return format(msg, '3', '23')
}

pub fn inverse(msg string) string {
	return format(msg, '7', '27')
}

pub fn magenta(msg string) string {
	return format(msg, '35', '39')
}

pub fn bright_magenta(msg string) string {
	return format(msg, '95', '39')
}

pub fn reset(msg string) string {
	return format(msg, '0', '0')
}

pub fn red(msg string) string {
	return format(msg, '31', '39')
}

pub fn bright_red(msg string) string {
	return format(msg, '91', '39')
}

pub fn strikethrough(msg string) string {
	return format(msg, '9', '29')
}

pub fn underline(msg string) string {
	return format(msg, '4', '24')
}

pub fn white(msg string) string {
	return format(msg, '37', '39')
}

pub fn bright_white(msg string) string {
	return format(msg, '97', '39')
}

pub fn yellow(msg string) string {
	return format(msg, '33', '39')
}

pub fn bright_yellow(msg string) string {
	return format(msg, '93', '39')
}

// highlight_command highlights the command with an on-brand background
// to make CLI commands immediately recognizable.
pub fn highlight_command(command string) string {
	return bright_white(bg_cyan(' $command '))
}