ivstdcolorout.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #ifndef IVSTDCOLOROUT_H
  2. #define IVSTDCOLOROUT_H
  3. //#define RESET "\033[0m"
  4. //#define BLACK "\033[30m" /* Black */
  5. //#define RED "\033[31m" /* Red */
  6. //#define GREEN "\033[32m" /* Green */
  7. //#define YELLOW "\033[33m" /* Yellow */
  8. //#define BLUE "\033[34m" /* Blue */
  9. //#define MAGENTA "\033[35m" /* Magenta */
  10. //#define CYAN "\033[36m" /* Cyan */
  11. //#define WHITE "\033[37m" /* White */
  12. //#define BOLDBLACK "\033[1m\033[30m" /* Bold Black */
  13. //#define BOLDRED "\033[1m\033[31m" /* Bold Red */
  14. //#define BOLDGREEN "\033[1m\033[32m" /* Bold Green */
  15. //#define BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */
  16. //#define BOLDBLUE "\033[1m\033[34m" /* Bold Blue */
  17. //#define BOLDMAGENTA "\033[1m\033[35m" /* Bold Magenta */
  18. //#define BOLDCYAN "\033[1m\033[36m" /* Bold Cyan */
  19. //#define BOLDWHITE "\033[1m\033[37m" /* Bold White */
  20. namespace iv {
  21. enum STDCOLOR
  22. {
  23. STDCOLOR_DEFUALT = 1,
  24. STDCOLOR_BLACK = 2,
  25. STDCOLOR_RED = 3,
  26. STDCOLOR_GREEN = 4,
  27. STDCOLOR_YELLOW = 5,
  28. STDCOLOR_BLUE = 6,
  29. STDCOLOR_MAGENTA = 7,
  30. STDCOLOR_CYAN = 8,
  31. STDCOLOR_WHITE = 9,
  32. STDCOLOR_BOLDBLACK = 10,
  33. STDCOLOR_BOLDRED = 11,
  34. STDCOLOR_BOLDGREEN = 12,
  35. STDCOLOR_BOLDYELLOW = 13,
  36. STDCOLOR_BOLDBLUE = 14,
  37. STDCOLOR_BOLDMAGENTA = 15,
  38. STDCOLOR_BOLDCYAN = 16,
  39. STDCOLOR_BOLDWHITE = 17
  40. };
  41. }
  42. #include <iostream>
  43. inline void ivstdcolorout(std::string str,iv::STDCOLOR color = iv::STDCOLOR::STDCOLOR_DEFUALT)
  44. {
  45. if(color == iv::STDCOLOR::STDCOLOR_DEFUALT)
  46. {
  47. std::cout<<str<<std::endl;
  48. return;
  49. }
  50. switch (color) {
  51. case iv::STDCOLOR::STDCOLOR_DEFUALT:
  52. std::cout<<str<<std::endl;
  53. break;
  54. case iv::STDCOLOR::STDCOLOR_BLACK:
  55. std::cout<<"\033[30m"<<str<<"\033[0m"<<std::endl;
  56. break;
  57. case iv::STDCOLOR::STDCOLOR_RED:
  58. std::cout<<"\033[31m"<<str<<"\033[0m"<<std::endl;
  59. break;
  60. case iv::STDCOLOR::STDCOLOR_GREEN:
  61. std::cout<<"\033[32m"<<str<<"\033[0m"<<std::endl;
  62. break;
  63. case iv::STDCOLOR::STDCOLOR_YELLOW:
  64. std::cout<<"\033[33m"<<str<<"\033[0m"<<std::endl;
  65. break;
  66. case iv::STDCOLOR::STDCOLOR_BLUE:
  67. std::cout<<"\033[34m"<<str<<"\033[0m"<<std::endl;
  68. break;
  69. case iv::STDCOLOR::STDCOLOR_MAGENTA:
  70. std::cout<<"\033[35m"<<str<<"\033[0m"<<std::endl;
  71. break;
  72. case iv::STDCOLOR::STDCOLOR_CYAN:
  73. std::cout<<"\033[36m"<<str<<"\033[0m"<<std::endl;
  74. break;
  75. case iv::STDCOLOR::STDCOLOR_WHITE:
  76. std::cout<<"\033[37m"<<str<<"\033[0m"<<std::endl;
  77. break;
  78. case iv::STDCOLOR::STDCOLOR_BOLDBLACK:
  79. std::cout<<"\033[1m\033[30m"<<str<<"\033[0m"<<std::endl;
  80. break;
  81. case iv::STDCOLOR::STDCOLOR_BOLDRED:
  82. std::cout<<"\033[1m\033[31m"<<str<<"\033[0m"<<std::endl;
  83. break;
  84. case iv::STDCOLOR::STDCOLOR_BOLDGREEN:
  85. std::cout<<"\033[1m\033[32m"<<str<<"\033[0m"<<std::endl;
  86. break;
  87. case iv::STDCOLOR::STDCOLOR_BOLDYELLOW:
  88. std::cout<<"\033[1m\033[33m"<<str<<"\033[0m"<<std::endl;
  89. break;
  90. case iv::STDCOLOR::STDCOLOR_BOLDBLUE:
  91. std::cout<<"\033[1m\033[34m"<<str<<"\033[0m"<<std::endl;
  92. break;
  93. case iv::STDCOLOR::STDCOLOR_BOLDMAGENTA:
  94. std::cout<<"\033[1m\033[35m"<<str<<"\033[0m"<<std::endl;
  95. break;
  96. case iv::STDCOLOR::STDCOLOR_BOLDCYAN:
  97. std::cout<<"\033[1m\033[36m"<<str<<"\033[0m"<<std::endl;
  98. break;
  99. case iv::STDCOLOR::STDCOLOR_BOLDWHITE:
  100. std::cout<<"\033[1m\033[37m"<<str<<"\033[0m"<<std::endl;
  101. break;
  102. default:
  103. std::cout<<str<<std::endl;
  104. break;
  105. }
  106. }
  107. #endif // IVSTDCOLOROUT_H