1#ifndef INCLUDE_ASCII_COLOR_H_
2#define INCLUDE_ASCII_COLOR_H_
40 int id() {
return id_; }
49 int r() {
return r_; }
50 int g() {
return g_; }
51 int b() {
return b_; }
85 os <<
"\x1b[" <<
static_cast<int>(val.attr_) <<
"m";
106 Foreground(std::string color) : color_(color) {}
109 static std::string Resolve(
Color color) {
113 std::stringstream os;
114 os <<
"\x1b[" <<
static_cast<int>(color) <<
"m";
118 static std::string Resolve(RGB color) {
119 std::stringstream os;
120 os <<
"\x1b[38;2;" << color.r() <<
";" << color.g() <<
";" << color.b()
125 static std::string Resolve(Color256 color) {
126 std::stringstream os;
127 os <<
"\x1b[38;5;" << color.id() <<
"m";
144 Background(std::string color) : color_(color) {}
147 static std::string Resolve(
Color color) {
151 std::stringstream os;
152 os <<
"\x1b[" << 10 +
static_cast<int>(color) <<
"m";
156 static std::string Resolve(RGB color) {
157 std::stringstream os;
158 os <<
"\x1b[48;2;" << color.r() <<
";" << color.g() <<
";" << color.b()
163 static std::string Resolve(Color256 color) {
164 std::stringstream os;
165 os <<
"\x1b[48;5;" << color.id() <<
"m";
static Background From(T color)
Definition color.h:134
friend std::ostream & operator<<(std::ostream &os, const Background &val)
Definition color.h:138
int id()
Definition color.h:40
Color256(int id)
Definition color.h:39
static Decoration From(Attribute attr)
Definition color.h:83
Attribute
Definition color.h:61
@ REVERSED
Definition color.h:69
@ RAPIDBLINK
Definition color.h:68
@ CONCEAL
Definition color.h:70
@ RESET
Definition color.h:62
@ CROSSED
Definition color.h:71
@ SLOWBLINK
Definition color.h:67
@ NO_ITALIC
Definition color.h:75
@ ITALIC
Definition color.h:65
@ NO_DIM
Definition color.h:74
@ NO_CONCEAL
Definition color.h:79
@ BOLD
Definition color.h:63
@ NO_CROSSED
Definition color.h:80
@ NO_BOLD
Definition color.h:73
@ UNDERLINE
Definition color.h:66
@ NO_REVERSED
Definition color.h:78
@ NO_UNDERLINE
Definition color.h:76
@ NO_BLINK
Definition color.h:77
@ DIM
Definition color.h:64
friend std::ostream & operator<<(std::ostream &os, const Decoration &val)
Definition color.h:84
static Foreground From(T color)
Definition color.h:96
friend std::ostream & operator<<(std::ostream &os, const Foreground &val)
Definition color.h:100
int r()
Definition color.h:49
RGB(int r, int g, int b)
Definition color.h:48
int g()
Definition color.h:50
int b()
Definition color.h:51
for detailed info, refered to https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797.
Definition ascii.h:17
Color
Definition color.h:15