catch_console_colour.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Created by Phil on 25/2/2012.
  3. * Copyright 2012 Two Blue Cubes Ltd. All rights reserved.
  4. *
  5. * Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. */
  8. #ifndef TWOBLUECUBES_CATCH_CONSOLE_COLOUR_HPP_INCLUDED
  9. #define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_HPP_INCLUDED
  10. #include "catch_common.h"
  11. namespace Catch {
  12. struct Colour {
  13. enum Code {
  14. None = 0,
  15. White,
  16. Red,
  17. Green,
  18. Blue,
  19. Cyan,
  20. Yellow,
  21. Grey,
  22. Bright = 0x10,
  23. BrightRed = Bright | Red,
  24. BrightGreen = Bright | Green,
  25. LightGrey = Bright | Grey,
  26. BrightWhite = Bright | White,
  27. BrightYellow = Bright | Yellow,
  28. // By intention
  29. FileName = LightGrey,
  30. Warning = BrightYellow,
  31. ResultError = BrightRed,
  32. ResultSuccess = BrightGreen,
  33. ResultExpectedFailure = Warning,
  34. Error = BrightRed,
  35. Success = Green,
  36. OriginalExpression = Cyan,
  37. ReconstructedExpression = BrightYellow,
  38. SecondaryText = LightGrey,
  39. Headers = White
  40. };
  41. // Use constructed object for RAII guard
  42. Colour( Code _colourCode );
  43. Colour( Colour&& other ) noexcept;
  44. Colour& operator=( Colour&& other ) noexcept;
  45. ~Colour();
  46. // Use static method for one-shot changes
  47. static void use( Code _colourCode );
  48. private:
  49. bool m_moved = false;
  50. };
  51. std::ostream& operator << ( std::ostream& os, Colour const& );
  52. } // end namespace Catch
  53. #endif // TWOBLUECUBES_CATCH_CONSOLE_COLOUR_HPP_INCLUDED