Add `sink.text.details`, a testing textual sink which prints details
[babeltrace.git] / src / plugins / text / details / colors.h
1 #ifndef BABELTRACE_PLUGINS_TEXT_DETAILS_COLORS_H
2 #define BABELTRACE_PLUGINS_TEXT_DETAILS_COLORS_H
3
4 /*
5 * Copyright 2019 Philippe Proulx <pproulx@efficios.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 */
25
26 #include "common/common.h"
27
28 #include "write.h"
29
30 static inline
31 const char *color_reset(struct details_write_ctx *ctx)
32 {
33 const char *code = "";
34
35 if (ctx->details_comp->cfg.with_color) {
36 code = BT_COMMON_COLOR_RESET;
37 }
38
39 return code;
40 }
41
42 static inline
43 const char *color_bold(struct details_write_ctx *ctx)
44 {
45 const char *code = "";
46
47 if (ctx->details_comp->cfg.with_color) {
48 code = BT_COMMON_COLOR_BOLD;
49 }
50
51 return code;
52 }
53
54 static inline
55 const char *color_fg_default(struct details_write_ctx *ctx)
56 {
57 const char *code = "";
58
59 if (ctx->details_comp->cfg.with_color) {
60 code = BT_COMMON_COLOR_FG_DEFAULT;
61 }
62
63 return code;
64 }
65
66 static inline
67 const char *color_fg_red(struct details_write_ctx *ctx)
68 {
69 const char *code = "";
70
71 if (ctx->details_comp->cfg.with_color) {
72 code = BT_COMMON_COLOR_FG_RED;
73 }
74
75 return code;
76 }
77
78 static inline
79 const char *color_fg_green(struct details_write_ctx *ctx)
80 {
81 const char *code = "";
82
83 if (ctx->details_comp->cfg.with_color) {
84 code = BT_COMMON_COLOR_FG_GREEN;
85 }
86
87 return code;
88 }
89
90 static inline
91 const char *color_fg_yellow(struct details_write_ctx *ctx)
92 {
93 const char *code = "";
94
95 if (ctx->details_comp->cfg.with_color) {
96 code = BT_COMMON_COLOR_FG_YELLOW;
97 }
98
99 return code;
100 }
101
102 static inline
103 const char *color_fg_blue(struct details_write_ctx *ctx)
104 {
105 const char *code = "";
106
107 if (ctx->details_comp->cfg.with_color) {
108 code = BT_COMMON_COLOR_FG_BLUE;
109 }
110
111 return code;
112 }
113
114 static inline
115 const char *color_fg_magenta(struct details_write_ctx *ctx)
116 {
117 const char *code = "";
118
119 if (ctx->details_comp->cfg.with_color) {
120 code = BT_COMMON_COLOR_FG_MAGENTA;
121 }
122
123 return code;
124 }
125
126 static inline
127 const char *color_fg_cyan(struct details_write_ctx *ctx)
128 {
129 const char *code = "";
130
131 if (ctx->details_comp->cfg.with_color) {
132 code = BT_COMMON_COLOR_FG_CYAN;
133 }
134
135 return code;
136 }
137
138 static inline
139 const char *color_fg_light_gray(struct details_write_ctx *ctx)
140 {
141 const char *code = "";
142
143 if (ctx->details_comp->cfg.with_color) {
144 code = BT_COMMON_COLOR_FG_LIGHT_GRAY;
145 }
146
147 return code;
148 }
149
150 static inline
151 const char *color_bg_default(struct details_write_ctx *ctx)
152 {
153 const char *code = "";
154
155 if (ctx->details_comp->cfg.with_color) {
156 code = BT_COMMON_COLOR_BG_DEFAULT;
157 }
158
159 return code;
160 }
161
162 static inline
163 const char *color_bg_red(struct details_write_ctx *ctx)
164 {
165 const char *code = "";
166
167 if (ctx->details_comp->cfg.with_color) {
168 code = BT_COMMON_COLOR_BG_RED;
169 }
170
171 return code;
172 }
173
174 static inline
175 const char *color_bg_green(struct details_write_ctx *ctx)
176 {
177 const char *code = "";
178
179 if (ctx->details_comp->cfg.with_color) {
180 code = BT_COMMON_COLOR_BG_GREEN;
181 }
182
183 return code;
184 }
185
186 static inline
187 const char *color_bg_yellow(struct details_write_ctx *ctx)
188 {
189 const char *code = "";
190
191 if (ctx->details_comp->cfg.with_color) {
192 code = BT_COMMON_COLOR_BG_YELLOW;
193 }
194
195 return code;
196 }
197
198 static inline
199 const char *color_bg_blue(struct details_write_ctx *ctx)
200 {
201 const char *code = "";
202
203 if (ctx->details_comp->cfg.with_color) {
204 code = BT_COMMON_COLOR_BG_BLUE;
205 }
206
207 return code;
208 }
209
210 static inline
211 const char *color_bg_magenta(struct details_write_ctx *ctx)
212 {
213 const char *code = "";
214
215 if (ctx->details_comp->cfg.with_color) {
216 code = BT_COMMON_COLOR_BG_MAGENTA;
217 }
218
219 return code;
220 }
221
222 static inline
223 const char *color_bg_cyan(struct details_write_ctx *ctx)
224 {
225 const char *code = "";
226
227 if (ctx->details_comp->cfg.with_color) {
228 code = BT_COMMON_COLOR_BG_CYAN;
229 }
230
231 return code;
232 }
233
234 static inline
235 const char *color_bg_light_gray(struct details_write_ctx *ctx)
236 {
237 const char *code = "";
238
239 if (ctx->details_comp->cfg.with_color) {
240 code = BT_COMMON_COLOR_BG_LIGHT_GRAY;
241 }
242
243 return code;
244 }
245
246 #endif /* BABELTRACE_PLUGINS_TEXT_DETAILS_COLORS_H */
This page took 0.035294 seconds and 4 git commands to generate.