-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_term_color.c
214 lines (196 loc) · 5.64 KB
/
test_term_color.c
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#include "print.h"
#include "term_color.h"
int main(void)
{
#define TARGET_STRING "*Color*"
term_color_t regular_colors[] = {
TERM_COLOR_BLACK,
TERM_COLOR_RED,
TERM_COLOR_GREEN,
TERM_COLOR_YELLOW,
TERM_COLOR_BLUE,
TERM_COLOR_PURPLE,
TERM_COLOR_CYAN,
TERM_COLOR_WHITE
};
term_color_t bright_colors[] = {
TERM_BRIGHT_COLOR_BLACK,
TERM_BRIGHT_COLOR_RED,
TERM_BRIGHT_COLOR_GREEN,
TERM_BRIGHT_COLOR_YELLOW,
TERM_BRIGHT_COLOR_BLUE,
TERM_BRIGHT_COLOR_PURPLE,
TERM_BRIGHT_COLOR_CYAN,
TERM_BRIGHT_COLOR_WHITE
};
term_color_t bold_colors[] = {
TERM_BOLD_COLOR_BLACK,
TERM_BOLD_COLOR_RED,
TERM_BOLD_COLOR_GREEN,
TERM_BOLD_COLOR_YELLOW,
TERM_BOLD_COLOR_BLUE,
TERM_BOLD_COLOR_PURPLE,
TERM_BOLD_COLOR_CYAN,
TERM_BOLD_COLOR_WHITE
};
term_color_t bold_bright_colors[] = {
TERM_BOLD_BRIGHT_COLOR_BLACK,
TERM_BOLD_BRIGHT_COLOR_RED,
TERM_BOLD_BRIGHT_COLOR_GREEN,
TERM_BOLD_BRIGHT_COLOR_YELLOW,
TERM_BOLD_BRIGHT_COLOR_BLUE,
TERM_BOLD_BRIGHT_COLOR_PURPLE,
TERM_BOLD_BRIGHT_COLOR_CYAN,
TERM_BOLD_BRIGHT_COLOR_WHITE
};
term_color_t underline_colors[] = {
TERM_UNDERLINE_COLOR_BLACK,
TERM_UNDERLINE_COLOR_RED,
TERM_UNDERLINE_COLOR_GREEN,
TERM_UNDERLINE_COLOR_YELLOW,
TERM_UNDERLINE_COLOR_BLUE,
TERM_UNDERLINE_COLOR_PURPLE,
TERM_UNDERLINE_COLOR_CYAN,
TERM_UNDERLINE_COLOR_WHITE
};
term_color_t background_colors[] = {
TERM_BACKGROUND_COLOR_BLACK,
TERM_BACKGROUND_COLOR_RED,
TERM_BACKGROUND_COLOR_GREEN,
TERM_BACKGROUND_COLOR_YELLOW,
TERM_BACKGROUND_COLOR_BLUE,
TERM_BACKGROUND_COLOR_PURPLE,
TERM_BACKGROUND_COLOR_CYAN,
TERM_BACKGROUND_COLOR_WHITE
};
term_color_t bright_background_colors[] = {
TERM_BRIGHT_BACKGROUND_COLOR_BLACK,
TERM_BRIGHT_BACKGROUND_COLOR_RED,
TERM_BRIGHT_BACKGROUND_COLOR_GREEN,
TERM_BRIGHT_BACKGROUND_COLOR_YELLOW,
TERM_BRIGHT_BACKGROUND_COLOR_BLUE,
TERM_BRIGHT_BACKGROUND_COLOR_PURPLE,
TERM_BRIGHT_BACKGROUND_COLOR_CYAN,
TERM_BRIGHT_BACKGROUND_COLOR_WHITE
};
/* Regular color on regular background color. */
{
size_t i;
for (i = 0;
i < sizeof(background_colors) / sizeof(term_color_t);
i++)
{
{
size_t j;
for (j = 0;
j < sizeof(regular_colors) / sizeof(term_color_t);
j++)
{
PRINT("%s%s%s%s",
regular_colors[j],
background_colors[i],
TARGET_STRING,
TERM_COLOR_RESET);
}
}
PUTS("");
}
}
PUTS("");
/* Bright color on bright background color. */
{
size_t i;
for (i = 0;
i < sizeof(bright_background_colors) / sizeof(term_color_t);
i++)
{
{
size_t j;
for (j = 0;
j < sizeof(bright_colors) / sizeof(term_color_t);
j++)
{
PRINT("%s%s%s%s",
bright_colors[j],
bright_background_colors[i],
TARGET_STRING,
TERM_COLOR_RESET);
}
PUTS("");
}
}
}
PUTS("");
/* Bold color on regular background color. */
{
size_t i;
for (i = 0;
i < sizeof(background_colors) / sizeof(term_color_t);
i++)
{
{
size_t j;
for (j = 0;
j < sizeof(bold_colors) / sizeof(term_color_t);
j++)
{
PRINT("%s%s%s%s",
bold_colors[j],
background_colors[i],
TARGET_STRING,
TERM_COLOR_RESET);
}
PUTS("");
}
}
}
PUTS("");
/* Bold bright color on bright background color. */
{
size_t i;
for (i = 0;
i < sizeof(bright_background_colors) / sizeof(term_color_t);
i++)
{
{
size_t j;
for (j = 0;
j < sizeof(bold_bright_colors) / sizeof(term_color_t);
j++)
{
PRINT("%s%s%s%s",
bold_bright_colors[j],
bright_background_colors[i],
TARGET_STRING,
TERM_COLOR_RESET);
}
PUTS("");
}
}
}
PUTS("");
/* Underline color on regular background color. */
{
size_t i;
for (i = 0;
i < sizeof(background_colors) / sizeof(term_color_t);
i++)
{
{
size_t j;
for (j = 0;
j < sizeof(underline_colors) / sizeof(term_color_t);
j++)
{
PRINT("%s%s%s%s",
underline_colors[j],
background_colors[i],
TARGET_STRING,
TERM_COLOR_RESET);
}
PUTS("");
}
}
}
return 0;
}