30# define WIN32_LEAN_AND_MEAN
64enum class BackgroundColor {
87inline std::string get_textcolor_code( TextColor textcolor ) {
90 case TextColor::black:
return "30";
91 case TextColor::dark_blue:
return "34";
92 case TextColor::dark_green:
return "32";
93 case TextColor::light_blue:
return "36";
94 case TextColor::dark_red:
return "31";
95 case TextColor::magenta:
return "35";
96 case TextColor::orange:
return "33";
97 case TextColor::light_gray:
return "37";
98 case TextColor::gray:
return "90";
99 case TextColor::blue:
return "94";
100 case TextColor::green:
return "92";
101 case TextColor::cyan:
return "96";
102 case TextColor::red:
return "91";
103 case TextColor::pink:
return "95";
104 case TextColor::yellow:
return "93";
105 case TextColor::white:
return "97";
106 default:
return "37";
110inline std::string get_backgroundcolor_code( BackgroundColor backgroundcolor) {
111 switch( backgroundcolor )
113 case BackgroundColor::black:
return "40";
114 case BackgroundColor::dark_blue:
return "44";
115 case BackgroundColor::dark_green:
return "42";
116 case BackgroundColor::light_blue:
return "46";
117 case BackgroundColor::dark_red:
return "41";
118 case BackgroundColor::magenta:
return "45";
119 case BackgroundColor::orange:
return "43";
120 case BackgroundColor::light_gray:
return "47";
121 case BackgroundColor::gray:
return "100";
122 case BackgroundColor::blue:
return "104";
123 case BackgroundColor::green:
return "102";
124 case BackgroundColor::cyan:
return "106";
125 case BackgroundColor::red:
return "101";
126 case BackgroundColor::pink:
return "105";
127 case BackgroundColor::yellow:
return "103";
128 case BackgroundColor::white:
return "107";
129 default:
return "40";
135inline std::ostream& operator<<( std::ostream& stream, TextColor color ) {
137 ::SetConsoleTextAttribute( ::GetStdHandle(STD_OUTPUT_HANDLE),
static_cast<const int>(color) );
138#elif defined(__linux__)
139 stream <<
"\033["+get_textcolor_code(color)+
"m";
144inline std::ostream& operator<<( std::ostream& stream, BackgroundColor color ) {
146 ::SetConsoleTextAttribute( ::GetStdHandle(STD_OUTPUT_HANDLE),
static_cast<const int>(color) << 4 );
147#elif defined(__linux__)
148 stream <<
"\033["+get_backgroundcolor_code(color)+
"m";
153inline std::ostream& rendl( std::ostream& stream ) {
154 stream << TextColor::reset << std::endl;
Namespace of common utility classes and methods.
Definition Helpers.h:43