Hermes
console_colors.h
Go to the documentation of this file.
1 
32 #ifndef HERMES_LOG_CONSOLE_COLORS_H
33 #define HERMES_LOG_CONSOLE_COLORS_H
34 
35 #include <hermes/common/defs.h>
36 #include <string>
37 #include <iostream>
38 
39 namespace hermes {
40 
44 public:
45  // SET
46  static char bold[5];
47  static char dim[5];
48  static char underlined[5];
49  static char blink[5];
50  static char inverted[5];
51  static char hidden[5];
52  // RESET
53  static char reset[5];
54  static char reset_bold[6];
55  static char reset_dim[6];
56  static char reset_underlined[6];
57  static char reset_blink[6];
58  static char reset_inverted[6];
59  static char reset_hidden[6];
60  // 8/16 Colors
61  static char default_color[6];
62  static char black[6];
63  static char red[6];
64  static char green[6];
65  static char yellow[6];
66  static char blue[6];
67  static char magenta[6];
68  static char cyan[6];
69  static char light_gray[6];
70  static char dark_gray[6];
71  static char light_red[6];
72  static char light_green[6];
73  static char light_yellow[6];
74  static char light_blue[6];
75  static char light_magenta[6];
76  static char light_cyan[6];
77  static char white[6];
78  static char background_default_color[6];
79  static char background_black[6];
80  static char background_red[6];
81  static char background_green[6];
82  static char background_yellow[6];
83  static char background_blue[6];
84  static char background_magenta[6];
85  static char background_cyan[6];
86  static char background_light_gray[6];
87  static char background_dark_gray[7];
88  static char background_light_red[7];
89  static char background_light_green[7];
90  static char background_light_yellow[7];
91  static char background_light_blue[7];
92  static char background_light_magenta[7];
93  static char background_light_cyan[7];
94  static char background_white[7];
95 
99  inline static std::string color(u8 color_number) {
100  return std::string("\e[38;5;") + std::to_string(color_number) + "m";
101  }
105  inline static std::string background_color(u8 color_number) {
106  return std::string("\e[48;5;") + std::to_string(color_number) + "m";
107  }
112  inline static std::string combine(const std::string &a, const std::string &b) {
113  return "\e[" + a.substr(2, a.size() - 3) + ";" + b.substr(2, b.size() - 3) + "m";
114  }
115 };
116 
117 }
118 
119 #endif //HERMES_LOG_CONSOLE_COLORS_H
120 
Set of 256-terminal color codes.
Definition: console_colors.h:43
static char white[6]
"\e[97m"
Definition: console_colors.h:77
static char light_gray[6]
"\e[37m"
Definition: console_colors.h:69
static char background_black[6]
"\e[40m"
Definition: console_colors.h:79
static char light_magenta[6]
"\e[95m"
Definition: console_colors.h:75
static char reset_blink[6]
"\e[25m"
Definition: console_colors.h:57
static char reset_hidden[6]
"\e[28m"
Definition: console_colors.h:59
static char blink[5]
"\e[5m"
Definition: console_colors.h:49
static std::string combine(const std::string &a, const std::string &b)
Combine two color codes.
Definition: console_colors.h:112
static char reset_underlined[6]
"\e[24m"
Definition: console_colors.h:56
static char bold[5]
"\e[1m"
Definition: console_colors.h:46
static std::string color(u8 color_number)
Get 88/256 color code.
Definition: console_colors.h:99
static std::string background_color(u8 color_number)
Get 88/256 background color code.
Definition: console_colors.h:105
static char reset_inverted[6]
"\e[27m"
Definition: console_colors.h:58
static char reset[5]
"\e[0m"
Definition: console_colors.h:53
static char background_default_color[6]
"\e[49m"
Definition: console_colors.h:78
static char dim[5]
"\e[2m"
Definition: console_colors.h:47
static char background_light_blue[7]
"\e[104m"
Definition: console_colors.h:91
static char green[6]
"\e[32m"
Definition: console_colors.h:64
static char reset_bold[6]
"\e[21m"
Definition: console_colors.h:54
static char magenta[6]
"\e[35m"
Definition: console_colors.h:67
static char blue[6]
"\e[34m"
Definition: console_colors.h:66
static char red[6]
"\e[31m"
Definition: console_colors.h:63
static char light_red[6]
"\e[91m"
Definition: console_colors.h:71
static char background_green[6]
"\e[42m"
Definition: console_colors.h:81
static char background_light_cyan[7]
"\e[106m"
Definition: console_colors.h:93
static char background_light_green[7]
"\e[102m"
Definition: console_colors.h:89
static char background_yellow[6]
"\e[43m"
Definition: console_colors.h:82
static char background_red[6]
"\e[41m"
Definition: console_colors.h:80
static char black[6]
"\e[30m"
Definition: console_colors.h:62
static char light_cyan[6]
"\e[96m"
Definition: console_colors.h:76
static char underlined[5]
"\e[4m"
Definition: console_colors.h:48
static char light_blue[6]
"\e[94m"
Definition: console_colors.h:74
static char inverted[5]
"\e[7m"
Definition: console_colors.h:50
static char background_cyan[6]
"\e[46m"
Definition: console_colors.h:85
static char background_white[7]
"\e[107m"
Definition: console_colors.h:94
static char hidden[5]
"\e[8m"
Definition: console_colors.h:51
static char background_dark_gray[7]
"\e[100m"
Definition: console_colors.h:87
static char background_light_yellow[7]
"\e[103m"
Definition: console_colors.h:90
static char light_green[6]
"\e[92m"
Definition: console_colors.h:72
static char background_light_magenta[7]
"\e[105m"
Definition: console_colors.h:92
static char reset_dim[6]
"\e[22m"
Definition: console_colors.h:55
static char cyan[6]
"\e[36m"
Definition: console_colors.h:68
static char background_light_red[7]
"\e[101m"
Definition: console_colors.h:88
static char background_blue[6]
"\e[44m"
Definition: console_colors.h:83
static char default_color[6]
"\e[39m"
Definition: console_colors.h:61
static char background_light_gray[6]
"\e[47m"
Definition: console_colors.h:86
static char yellow[6]
"\e[33m"
Definition: console_colors.h:65
static char light_yellow[6]
"\e[93m"
Definition: console_colors.h:73
static char dark_gray[6]
"\e[90m"
Definition: console_colors.h:70
static char background_magenta[6]
"\e[45m"
Definition: console_colors.h:84
Data type definitions.
uint8_t u8
8 bit size unsigned integer type
Definition: defs.h:86