xtd.console - Reference Guide  0.0.1
Modern c++17 library to manage terminal on Windows, macOS and Linux.
console_color.hpp
Go to the documentation of this file.
1 #pragma once
4 #include <string>
5 #include <sstream>
6 
8 namespace xtd {
12  enum class console_color {
14  black,
16  dark_blue,
18  dark_green,
20  dark_cyan,
22  dark_red,
28  gray,
30  dark_gray,
32  blue,
34  green,
36  cyan,
38  red,
40  magenta,
42  yellow,
44  white
45  };
46 }
47 
49 template<typename Char>
50 std::basic_ostream<Char>& operator<<(std::basic_ostream<Char>& os, xtd::console_color c) {
51  switch (c) {
52  case xtd::console_color::black: os << std::basic_string<Char> {'b', 'l', 'a', 'c', 'k'}; break;
53  case xtd::console_color::dark_blue: os << std::basic_string<Char> {'d', 'a', 'r', 'k', '_', 'b', 'l', 'u', 'e'}; break;
54  case xtd::console_color::dark_green: os << std::basic_string<Char> {'d', 'a', 'r', 'k', '_', 'g', 'r', 'e', 'e', 'n'}; break;
55  case xtd::console_color::dark_cyan: os << std::basic_string<Char> {'d', 'a', 'r', 'k', '_', 'c', 'y', 'a', 'n'}; break;
56  case xtd::console_color::dark_red: os << std::basic_string<Char> {'d', 'a', 'r', 'k', '_', 'r', 'e', 'd'}; break;
57  case xtd::console_color::dark_magenta: os << std::basic_string<Char> {'d', 'a', 'r', 'k', '_', 'm', 'a', 'g', 'e', 'n', 't', 'a'}; break;
58  case xtd::console_color::dark_yellow: os << std::basic_string<Char> {'d', 'a', 'r', 'k', '_', 'y', 'e', 'l', 'l', 'o', 'w'}; break;
59  case xtd::console_color::gray: os << std::basic_string<Char> {'g', 'r', 'a', 'y'}; break;
60  case xtd::console_color::dark_gray: os << std::basic_string<Char> {'d', 'a', 'r', 'k', '_', 'g', 'r', 'a', 'y'}; break;
61  case xtd::console_color::blue: os << std::basic_string<Char> {'b', 'l', 'u', 'e'}; break;
62  case xtd::console_color::green: os << std::basic_string<Char> {'g', 'r', 'e', 'e', 'n'}; break;
63  case xtd::console_color::cyan: os << std::basic_string<Char> {'c', 'y', 'a', 'n'}; break;
64  case xtd::console_color::red: os << std::basic_string<Char> {'r', 'e', 'd'}; break;
65  case xtd::console_color::magenta: os << std::basic_string<Char> {'m', 'a', 'g', 'e', 'n', 't', 'a'}; break;
66  case xtd::console_color::yellow: os << std::basic_string<Char> {'y', 'e', 'l', 'l', 'o', 'w'}; break;
67  case xtd::console_color::white: os << std::basic_string<Char> {'w', 'h', 'i', 't', 'e'}; break;
68  default: os << static_cast<int>(c); break;
69  }
70  return os;
71 }
The color black.
The color dark gray.
The color blue.
console_color
Specifies constants that define foreground and background colors for the console. ...
Definition: console_color.hpp:12
The color dark cyan (dark blue-green).
The color dark red.
The color dark magenta (dark purplish-red).
The color dark green.
The color green.
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: background_color.hpp:7
The color yellow.
The color white.
The color dark yellow (ochre).
The color dark blue.
The color cyan (blue-green).
The color gray.
The color magenta (purplish red).