Guest User

Untitled

a guest
Jul 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #ifndef __ANSI_COLOR_INCLUDED__
  2. #define __ANSI_COLOR_INCLUDED__
  3.  
  4. #define ANSI_RESET "0"
  5. #define ANSI_BOLD "1"
  6. #define ANSI_BLACK "30"
  7. #define ANSI_RED "31"
  8. #define ANSI_GREEN "32"
  9. #define ANSI_YELLOW "33"
  10. #define ANSI_BLUE "34"
  11. #define ANSI_MAGENTA "35"
  12. #define ANSI_CYAN "36"
  13. #define ANSI_WHITE "37"
  14. #define ANSI_ON_BLACK "40"
  15. #define ANSI_ON_RED "41"
  16. #define ANSI_ON_GREEN "42"
  17. #define ANSI_ON_YELLOW "43"
  18. #define ANSI_ON_BLUE "44"
  19. #define ANSI_ON_MAGENTA "45"
  20. #define ANSI_ON_CYAN "46"
  21. #define ANSI_ON_WHITE "47"
  22.  
  23. #define ANSI_ESC(x) "\x1b[" x "m"
  24. #define ANSI1(x) ANSI_ESC(ANSI_ ## x)
  25. #define ANSI2(x, y) ANSI_ESC(ANSI_ ## x ";" ANSI_ ## y)
  26. #define ANSI3(x, y, z) ANSI_ESC(ANSI_ ## x ";" ANSI_ ## y ";" ANSI_ ## z)
  27. #define ANSI4(x, y, z, t) ANSI_ESC(ANSI_ ## x ";" ANSI_ ## y ";" ANSI_ ## z ";" ANSI_ ## t)
  28. #define ANSI_SELECT_VERSION(_1, _2, _3, _4, VERSION,...) VERSION
  29. #define ANSI(...) ANSI_SELECT_VERSION(__VA_ARGS__, ANSI4, ANSI3, ANSI2, ANSI1)(__VA_ARGS__)
  30.  
  31. /**
  32. * printf("%sERROR%s", ANSI(RED, BOLD), ANSI(RESET));
  33. * printf("%sHLIGHTED%s", ANSI(BLACK, ON_YELLOW), ANSI(RESET));
  34. * ...
  35. */
  36.  
  37. #endif
Add Comment
Please, Sign In to add comment