Skip to content

Instantly share code, notes, and snippets.

@izanbf1803
Created December 5, 2018 00:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save izanbf1803/9c0934623c775af5c36cda6996c2bda7 to your computer and use it in GitHub Desktop.
Save izanbf1803/9c0934623c775af5c36cda6996c2bda7 to your computer and use it in GitHub Desktop.
Console output color
#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