Advertisement
JoelSjogren

colormod

May 26th, 2014
2,459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <ostream>
  2. namespace Color {
  3.     enum Code {
  4.         FG_RED      = 31,
  5.         FG_GREEN    = 32,
  6.         FG_BLUE     = 34,
  7.         FG_DEFAULT  = 39,
  8.         BG_RED      = 41,
  9.         BG_GREEN    = 42,
  10.         BG_BLUE     = 44,
  11.         BG_DEFAULT  = 49
  12.     };
  13.     std::ostream& operator<<(std::ostream& os, Code code) {
  14.         return os << "\033[" << static_cast<int>(code) << "m";
  15.     }
  16. }
  17. #include <iostream>
  18. using namespace std;
  19. int main() {
  20.     cout << "This ->" << Color::FG_RED << "word"
  21.          << Color::FG_DEFAULT << "<- is red." << endl;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement