Bayeux  3.4.1
Core Foundation library for SuperNEMO
ansi_colors.h
Go to the documentation of this file.
1 //
4 // Copyright (c) 2017 by François Mauger <mauger@lpccaen.in2p3.fr>
5 //
6 // This file is part of datatools.
7 //
8 // datatools is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 //
13 // datatools is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with datatools. If not, see <http://www.gnu.org/licenses/>.
20 
21 #ifndef DATATOOLS_UI_ANSI_COLORS_H
22 #define DATATOOLS_UI_ANSI_COLORS_H
23 
24 // Standard libraries:
25 #include <string>
26 #include <iostream>
27 
28 namespace datatools {
29 
30  namespace ui {
31 
32  namespace ansi_colors {
33 
34  struct ansi_code
35  {
36  ansi_code(const int code_);
37  friend std::ostream & operator<<(std::ostream & out_, const ansi_code &);
38  int _code_ = 0;
39  };
40 
41  struct color_8bits
42  {
43  static const unsigned int BLACK = 0;
44  static const unsigned int DARK_RED = 1;
45  static const unsigned int DARK_GREEN = 2;
46  static const unsigned int DARK_YELLOW = 3;
47  static const unsigned int DARK_BLUE = 4;
48  static const unsigned int DARK_MAGENTA = 5;
49  static const unsigned int DARK_CYAN = 6;
50  static const unsigned int LIGHT_GRAY = 7;
51  static const unsigned int DARK_GRAY = 8;
52  static const unsigned int RED = 9;
53  static const unsigned int GREEN = 10;
54  static const unsigned int YELLOW = 11;
55  static const unsigned int BLUE = 12;
56  static const unsigned int MAGENTA = 13;
57  static const unsigned int CYAN = 14;
58  static const unsigned int WHITE = 15;
59  static const unsigned int GRAY00 = 232;
60  static const unsigned int GRAY01 = 233;
61  static const unsigned int GRAY02 = 234;
62  static const unsigned int GRAY03 = 235;
63  static const unsigned int GRAY04 = 236;
64  static const unsigned int GRAY05 = 237;
65  static const unsigned int GRAY06 = 238;
66  static const unsigned int GRAY07 = 239;
67  static const unsigned int GRAY08 = 240;
68  static const unsigned int GRAY09 = 241;
69  static const unsigned int GRAY10 = 242;
70  static const unsigned int GRAY11 = 243;
71  static const unsigned int GRAY12 = 244;
72  static const unsigned int GRAY13 = 245;
73  static const unsigned int GRAY14 = 246;
74  static const unsigned int GRAY15 = 247;
75  static const unsigned int GRAY16 = 248;
76  static const unsigned int GRAY17 = 249;
77  static const unsigned int GRAY18 = 250;
78  static const unsigned int GRAY19 = 251;
79  static const unsigned int GRAY20 = 252;
80  static const unsigned int GRAY21 = 253;
81  static const unsigned int GRAY22 = 254;
82  static const unsigned int GRAY23 = 255;
83 
84  enum mode_type {
88  };
89 
90  color_8bits(const mode_type mode_,
91  const unsigned int n_,
92  const unsigned int r_ = 0,
93  const unsigned int g_ = 0,
94  const unsigned int b_ = 0);
95 
96  color_8bits(const unsigned int n_);
97 
98  color_8bits(const unsigned int r_, const unsigned int g_, const unsigned int b_);
99 
100  friend std::ostream & operator<<(std::ostream & out_, const color_8bits & c8_);
101 
102  unsigned int _n_ = 0;
103  unsigned int _r_ = 0;
104  unsigned int _g_ = 0;
105  unsigned int _b_ = 0;
106  };
107 
109 
110  struct reset
111  : public ansi_code
112  {
113  reset() : ansi_code(0) {}
114  };
115 
117  : public ansi_code
118  {
120  };
121 
123  : public ansi_code
124  {
126  };
127 
128  struct italics_on
129  : public ansi_code
130  {
132  };
133 
135  : public ansi_code
136  {
138  };
139 
140  struct blink_slow
141  : public ansi_code
142  {
144  };
145 
146  struct blink_fast
147  : public ansi_code
148  {
150  };
151 
152  struct inverse_on
153  : public ansi_code
154  {
156  };
157 
159  : public ansi_code
160  {
162  };
163 
165  : public ansi_code
166  {
168  };
169 
171  : public ansi_code
172  {
174  };
175 
176  struct italic_off
177  : public ansi_code
178  {
180  };
181 
183  : public ansi_code
184  {
186  };
187 
188  struct blink_off
189  : public ansi_code
190  {
191  blink_off() : ansi_code(25) {}
192  };
193 
194  struct inverse_off
195  : public ansi_code
196  {
198  };
199 
201  : public ansi_code
202  {
204  };
205 
207  : public ansi_code
208  {
210  };
211 
213  : public ansi_code
214  {
216  };
217 
219  : public ansi_code
220  {
222  };
223 
225 
227  : public ansi_code
228  {
230  };
231 
233  : public ansi_code
234  {
236  };
237 
239  : public ansi_code
240  {
242  };
243 
245  : public ansi_code
246  {
248  };
249 
251  : public ansi_code
252  {
254  };
255 
257  : public ansi_code
258  {
260  };
261 
263  : public ansi_code
264  {
266  };
267 
269  : public ansi_code
270  {
272  };
273 
275  : public ansi_code
276  {
278  };
279 
281  : public ansi_code
282  {
284  };
285 
287  : public ansi_code
288  {
290  };
291 
293  : public ansi_code
294  {
296  };
297 
299  : public ansi_code
300  {
302  };
303 
305  : public ansi_code
306  {
308  };
309 
311  : public ansi_code
312  {
314  };
315 
317  : public ansi_code
318  {
320  };
321 
323  : public ansi_code
324  {
326  };
327 
329  : public ansi_code
330  {
332  };
333 
335  : public ansi_code
336  {
338  };
339 
341  : public ansi_code
342  {
344  };
345 
347  : public ansi_code
348  {
350  };
351 
353  : public ansi_code
354  {
356  };
357 
359  : public ansi_code
360  {
362  };
363 
365  : public ansi_code
366  {
368  };
369 
371  : public ansi_code
372  {
374  };
375 
377  : public ansi_code
378  {
380  };
381 
383  : public ansi_code
384  {
386  };
387 
389  : public ansi_code
390  {
392  };
393 
395  : public ansi_code
396  {
398  };
399 
401  : public ansi_code
402  {
404  };
405 
407  : public ansi_code
408  {
410  };
411 
413  : public ansi_code
414  {
416  };
417 
418  struct framed_on
419  : public ansi_code
420  {
421  framed_on() : ansi_code(51) {}
422  };
423 
425  : public ansi_code
426  {
428  };
429 
431  : public ansi_code
432  {
434  };
435 
436  struct framed_off
437  : public ansi_code
438  {
440  };
441 
443  : public ansi_code
444  {
446  };
447 
448  } // namespace ansi_colors
449 
450  } // namespace ui
451 
452 } // namespace datatools
453 
454 #endif // DATATOOLS_UI_UTILS_H
455 
456 // Local Variables: --
457 // mode: c++ --
458 // c-file-style: "gnu" --
459 // tab-width: 2 --
460 // End: --
Definition: ansi_colors.h:424
restore_default()
Definition: ansi_colors.h:313
mode_type
Definition: ansi_colors.h:84
static const unsigned int MAGENTA
Definition: ansi_colors.h:56
Definition: ansi_colors.h:364
foreground_bright_white()
Definition: ansi_colors.h:307
Definition: ansi_colors.h:194
static const unsigned int LIGHT_GRAY
Definition: ansi_colors.h:50
unsigned int _n_
Definition: ansi_colors.h:102
static const unsigned int WHITE
Definition: ansi_colors.h:58
foreground_bright_cyan()
Definition: ansi_colors.h:295
foreground_bright_yellow()
Definition: ansi_colors.h:259
static const unsigned int GRAY11
Definition: ansi_colors.h:70
static const unsigned int GRAY15
Definition: ansi_colors.h:74
italic_off()
Definition: ansi_colors.h:179
encircled_on()
Definition: ansi_colors.h:427
underline_off()
Definition: ansi_colors.h:185
static const unsigned int GRAY08
Definition: ansi_colors.h:67
static const unsigned int DARK_GREEN
Definition: ansi_colors.h:45
background_blue()
Definition: ansi_colors.h:367
color_8bits(const mode_type mode_, const unsigned int n_, const unsigned int r_=0, const unsigned int g_=0, const unsigned int b_=0)
background_bright_blue()
Definition: ansi_colors.h:373
Definition: ansi_colors.h:200
background_black()
Definition: ansi_colors.h:319
concealed_off()
Definition: ansi_colors.h:203
concealed_on()
Definition: ansi_colors.h:161
Definition: ansi_colors.h:328
static const unsigned int GRAY04
Definition: ansi_colors.h:63
Definition: ansi_colors.h:388
background_bright_magenta()
Definition: ansi_colors.h:385
overlined_on()
Definition: ansi_colors.h:433
inverse_on()
Definition: ansi_colors.h:155
inverse_off()
Definition: ansi_colors.h:197
static const unsigned int GRAY12
Definition: ansi_colors.h:71
Definition: ansi_colors.h:286
static const unsigned int GRAY00
Definition: ansi_colors.h:59
static const unsigned int GRAY09
Definition: ansi_colors.h:68
static const unsigned int GRAY22
Definition: ansi_colors.h:81
static const unsigned int GRAY07
Definition: ansi_colors.h:66
Definition: ansi_colors.h:158
static const unsigned int GRAY06
Definition: ansi_colors.h:65
static const unsigned int GRAY18
Definition: ansi_colors.h:77
foreground_cyan()
Definition: ansi_colors.h:289
static const unsigned int GRAY03
Definition: ansi_colors.h:62
static const unsigned int DARK_GRAY
Definition: ansi_colors.h:51
Definition: ansi_colors.h:134
static const unsigned int BLUE
Definition: ansi_colors.h:55
framed_off()
Definition: ansi_colors.h:439
background_bright_black()
Definition: ansi_colors.h:325
Definition: ansi_colors.h:418
framed_on()
Definition: ansi_colors.h:421
Definition: ansi_colors.h:34
unsigned int _b_
Definition: ansi_colors.h:105
foreground_red()
Definition: ansi_colors.h:229
static const unsigned int DARK_BLUE
Definition: ansi_colors.h:47
static const unsigned int GRAY05
Definition: ansi_colors.h:64
Definition: ansi_colors.h:310
static const unsigned int GRAY17
Definition: ansi_colors.h:76
foreground_bright_blue()
Definition: ansi_colors.h:271
static const unsigned int CYAN
Definition: ansi_colors.h:57
background_cyan()
Definition: ansi_colors.h:391
foreground_bright_black()
Definition: ansi_colors.h:221
static const unsigned int RED
Definition: ansi_colors.h:52
background_magenta()
Definition: ansi_colors.h:379
static const unsigned int BLACK
Definition: ansi_colors.h:43
Definition: ansi_colors.h:182
static const unsigned int GRAY02
Definition: ansi_colors.h:61
static const unsigned int GRAY16
Definition: ansi_colors.h:75
static const unsigned int GREEN
Definition: ansi_colors.h:53
friend std::ostream & operator<<(std::ostream &out_, const ansi_code &)
foreground_green()
Definition: ansi_colors.h:241
Definition: ansi_colors.h:262
Definition: ansi_colors.h:41
Definition: ansi_colors.h:176
italics_on()
Definition: ansi_colors.h:131
background_bright_white()
Definition: ansi_colors.h:409
background_red()
Definition: ansi_colors.h:331
Definition: ansi_colors.h:110
foreground_magenta()
Definition: ansi_colors.h:277
Definition: ansi_colors.h:226
static const unsigned int YELLOW
Definition: ansi_colors.h:54
high_intensity_on()
Definition: ansi_colors.h:119
normal_intensity()
Definition: ansi_colors.h:173
static const unsigned int DARK_RED
Definition: ansi_colors.h:44
overlined_off()
Definition: ansi_colors.h:445
static const unsigned int GRAY14
Definition: ansi_colors.h:73
static const unsigned int DARK_YELLOW
Definition: ansi_colors.h:46
background_bright_red()
Definition: ansi_colors.h:337
foreground_white()
Definition: ansi_colors.h:301
static const unsigned int DARK_MAGENTA
Definition: ansi_colors.h:48
The Bayeux/datatools library top-level namespace.
Definition: algo.h:13
static const unsigned int DARK_CYAN
Definition: ansi_colors.h:49
foreground_black()
Definition: ansi_colors.h:215
Definition: ansi_colors.h:442
unsigned int _g_
Definition: ansi_colors.h:104
Definition: ansi_colors.h:152
background_bright_yellow()
Definition: ansi_colors.h:361
strikethrough_on()
Definition: ansi_colors.h:167
Definition: ansi_colors.h:436
static const unsigned int GRAY10
Definition: ansi_colors.h:69
foreground_bright_red()
Definition: ansi_colors.h:235
foreground_bright_magenta()
Definition: ansi_colors.h:283
background_green()
Definition: ansi_colors.h:343
static const unsigned int GRAY21
Definition: ansi_colors.h:80
foreground_yellow()
Definition: ansi_colors.h:253
foreground_bright_black foreground_gray
Definition: ansi_colors.h:224
Definition: ansi_colors.h:128
int _code_
Definition: ansi_colors.h:38
background_bright_cyan()
Definition: ansi_colors.h:397
default_background()
Definition: ansi_colors.h:415
foreground_bright_green()
Definition: ansi_colors.h:247
color_8bits color256
Definition: ansi_colors.h:108
Definition: ansi_colors.h:430
strikethrough_off()
Definition: ansi_colors.h:209
static const unsigned int GRAY23
Definition: ansi_colors.h:82
reset()
Definition: ansi_colors.h:113
background_white()
Definition: ansi_colors.h:403
static const unsigned int GRAY13
Definition: ansi_colors.h:72
static const unsigned int GRAY20
Definition: ansi_colors.h:79
background_bright_green()
Definition: ansi_colors.h:349
unsigned int _r_
Definition: ansi_colors.h:103
low_intensity_on()
Definition: ansi_colors.h:125
underline_on()
Definition: ansi_colors.h:137
background_yellow()
Definition: ansi_colors.h:355
static const unsigned int GRAY01
Definition: ansi_colors.h:60
friend std::ostream & operator<<(std::ostream &out_, const color_8bits &c8_)
foreground_blue()
Definition: ansi_colors.h:265
static const unsigned int GRAY19
Definition: ansi_colors.h:78