REDRUM.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <[email protected]>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_REDRUM_H
  9. #define IGL_REDRUM_H
  10. // Q: These should probably be inside the igl namespace. What's the correct
  11. // way to do that?
  12. // A: I guess the right way is to not use a macro but a proper function with
  13. // streams as input and output.
  14. // ANSI color codes for formatting iostream style output
  15. #ifdef IGL_REDRUM_NOOP
  16. // Bold Red, etc.
  17. #define NORUM(X) X
  18. #define REDRUM(X) X
  19. #define GREENRUM(X) X
  20. #define YELLOWRUM(X) X
  21. #define BLUERUM(X) X
  22. #define MAGENTARUM(X) X
  23. #define CYANRUM(X) X
  24. // Regular Red, etc.
  25. #define REDGIN(X) X
  26. #define GREENGIN(X) X
  27. #define YELLOWGIN(X) X
  28. #define BLUEGIN(X) X
  29. #define MAGENTAGIN(X) X
  30. #define CYANGIN(X) X
  31. #else
  32. /// Bold red colored text
  33. /// @param[in] X text to color
  34. /// @returns colored text as "stream"
  35. /// #### Example:
  36. ///
  37. /// \code{cpp}
  38. /// std::cout<<REDRUM("File "<<filename<<" not found.")<<std::endl;
  39. /// \endcode
  40. #define REDRUM(X) "\e[1m\e[31m"<<X<<"\e[m"
  41. // Bold Red, etc.
  42. #define NORUM(X) ""<<X<<""
  43. #define GREENRUM(X) "\e[1m\e[32m"<<X<<"\e[m"
  44. #define YELLOWRUM(X) "\e[1m\e[33m"<<X<<"\e[m"
  45. #define BLUERUM(X) "\e[1m\e[34m"<<X<<"\e[m"
  46. #define MAGENTARUM(X) "\e[1m\e[35m"<<X<<"\e[m"
  47. #define CYANRUM(X) "\e[1m\e[36m"<<X<<"\e[m"
  48. // Regular Red, etc.
  49. #define REDGIN(X) "\e[31m"<<X<<"\e[m"
  50. #define GREENGIN(X) "\e[32m"<<X<<"\e[m"
  51. #define YELLOWGIN(X) "\e[33m"<<X<<"\e[m"
  52. #define BLUEGIN(X) "\e[34m"<<X<<"\e[m"
  53. #define MAGENTAGIN(X) "\e[35m"<<X<<"\e[m"
  54. #define CYANGIN(X) "\e[36m"<<X<<"\e[m"
  55. #endif
  56. #endif