-
Notifications
You must be signed in to change notification settings - Fork 151
Open
Description
Hi ! this is not an issue. I get inspired by your library. I need to store style and fg color in a variable for a postponed usage. Here is the idea:
rang::color mycolor = std::pair(rang::red, rang::italic);
std::cout << mycolor << "hello" << std::endl;
So why not adding in your lib something like:
struct color
{
color(rang::style style,
rang::fg fg,
rang::bg bg = rang::bg::reset)
: m_style(style), m_fg(fg), m_bg(bg)
{
}
rang::style m_style;
rang::fg m_fg;
rang::bg m_bg;
};
inline std::ostream& setColor(std::ostream &os, rang::color const c)
{
return os << "\033["
<< static_cast<int>(c.m_fg) << ';'
<< static_cast<int>(c.m_bg) << ';'
<< static_cast<int>(c.m_style) << "m";
}
A simple test code could be:
#define ERROR_COLOR rang::color(rang::style::bold, rang::fg::red)
rang::color c = ERROR_COLOR;
std::cout << c << "hello" << std::endl;
I dunno what could be the best: std::pair
(ugly and long syntax but can be used with constexpr) or struct
(drawback: make copy). personally I would prefer something like red | italic
(but can achieve easily). Other solution ?
(Maybe your lib already can do this, in this case ignore my comment)
patlecat, melMass, arivii, 0xkarambit and def-funagauniyal, DenisSamilton and 0xkarambit
Metadata
Metadata
Assignees
Labels
No labels