Created
December 5, 2018 00:30
-
-
Save izanbf1803/9c0934623c775af5c36cda6996c2bda7 to your computer and use it in GitHub Desktop.
Console output color
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ostream> | |
namespace Color { | |
enum Code { | |
FG_RED = 31, | |
FG_GREEN = 32, | |
FG_BLUE = 34, | |
FG_DEFAULT = 39, | |
BG_RED = 41, | |
BG_GREEN = 42, | |
BG_BLUE = 44, | |
BG_DEFAULT = 49 | |
}; | |
class Modifier { | |
Code code; | |
public: | |
Modifier(Code pCode) : code(pCode) {} | |
friend std::ostream& | |
operator<<(std::ostream& os, const Modifier& mod) { | |
return os << "\033[" << mod.code << "m"; | |
} | |
}; | |
} | |
static const Color::Modifier C_FG_RED(Color::FG_RED); | |
static const Color::Modifier C_FG_GREEN(Color::FG_GREEN); | |
static const Color::Modifier C_FG_BLUE(Color::FG_BLUE); | |
static const Color::Modifier C_FG_DEFAULT(Color::FG_DEFAULT); | |
static const Color::Modifier C_BG_RED(Color::BG_RED); | |
static const Color::Modifier C_BG_GREEN(Color::BG_GREEN); | |
static const Color::Modifier C_BG_DEFAULT(Color::BG_DEFAULT); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment