cmStdIoTerminal.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file LICENSE.rst or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include "cmConfigure.h" // IWYU pragma: keep
  5. #include <cstddef>
  6. #include <cstdint>
  7. #include <cm/string_view>
  8. #include <cmext/enum_set>
  9. namespace cm {
  10. namespace StdIo {
  11. class OStream;
  12. /**
  13. * Represent a text attribute.
  14. */
  15. enum class TermAttr : std::uint8_t
  16. {
  17. Normal,
  18. ForegroundBold,
  19. ForegroundBlack,
  20. ForegroundBlue,
  21. ForegroundCyan,
  22. ForegroundGreen,
  23. ForegroundMagenta,
  24. ForegroundRed,
  25. ForegroundWhite,
  26. ForegroundYellow,
  27. BackgroundBold,
  28. BackgroundBlack,
  29. BackgroundBlue,
  30. BackgroundCyan,
  31. BackgroundGreen,
  32. BackgroundMagenta,
  33. BackgroundRed,
  34. BackgroundWhite,
  35. BackgroundYellow,
  36. };
  37. static constexpr std::size_t kTermAttrCount = 19;
  38. /**
  39. * Represent a set of text attributes.
  40. */
  41. using TermAttrSet = cm::enum_set<TermAttr, kTermAttrCount>;
  42. /**
  43. * Print text to an output stream using a given set of color attributes.
  44. */
  45. void Print(OStream& os, TermAttrSet const& attrs, cm::string_view text);
  46. }
  47. }