12 #ifndef INCLUDE_ASCII_COLOR_H_
13 #define INCLUDE_ASCII_COLOR_H_
19 #include <type_traits>
64 int id() {
return id_; }
86 int r() {
return r_; }
89 int g() {
return g_; }
92 int b() {
return b_; }
139 os <<
"\x1b[" <<
static_cast<int>(val.attr_) <<
"m";
178 Foreground(std::string color) : color_(color) {}
181 static std::string Resolve(
Color color) {
185 std::stringstream os;
186 os <<
"\x1b[" <<
static_cast<int>(color) <<
"m";
190 static std::string Resolve(RGB color) {
191 std::stringstream os;
192 os <<
"\x1b[38;2;" << color.r() <<
";" << color.g() <<
";" << color.b()
197 static std::string Resolve(Color256 color) {
198 std::stringstream os;
199 os <<
"\x1b[38;5;" << color.id() <<
"m";
234 Background(std::string color) : color_(color) {}
237 static std::string Resolve(
Color color) {
241 std::stringstream os;
242 os <<
"\x1b[" << 10 +
static_cast<int>(color) <<
"m";
246 static std::string Resolve(RGB color) {
247 std::stringstream os;
248 os <<
"\x1b[48;2;" << color.r() <<
";" << color.g() <<
";" << color.b()
253 static std::string Resolve(Color256 color) {
254 std::stringstream os;
255 os <<
"\x1b[48;5;" << color.id() <<
"m";
ANSI background color escape sequence generator.
friend std::ostream & operator<<(std::ostream &os, const Background &val)
Output the background color escape sequence to an output stream.
static Background From(T color)
Create a Background color from a color value.
256-color ANSI terminal color wrapper.
Color256(int id)
Construct a Color256 with the given palette ID.
ANSI text decoration (bold, italic, underline, etc.).
static Decoration From(Attribute attr)
Create a Decoration from an Attribute.
friend std::ostream & operator<<(std::ostream &os, const Decoration &val)
Output the decoration escape sequence to an output stream.
ANSI foreground color escape sequence generator.
static Foreground From(T color)
Create a Foreground color from a color value.
friend std::ostream & operator<<(std::ostream &os, const Foreground &val)
Output the foreground color escape sequence to an output stream.
24-bit true-color RGB terminal color.
RGB(int r, int g, int b)
Construct an RGB color from component values.
Color
Standard and bright ANSI terminal colors.