Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

colormod

By: JoelSjogren on May 26th, 2014  |  syntax: C++  |  size: 0.56 KB  |  views: 237  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }