1 #ifndef IOUTILITIES_ANSIESCAPECODES
2 #define IOUTILITIES_ANSIESCAPECODES
5 #include "../misc/traits.h"
12 namespace EscapeCodes {
16 enum class Color : char { Black =
'0', Red, Green, Yellow, Blue, Purple, Cyan,
White };
37 stream << '\e' << '[' << static_cast<char>(displayAttribute) <<
'm';
45 stream << '\e' << '[' << static_cast<char>(displayAttribute) <<
';' <<
static_cast<char>(context) <<
static_cast<char>(
color) <<
'm';
52 stream << '\e' << '[' << static_cast<char>(displayAttribute) <<
';' <<
static_cast<char>(ColorContext::Foreground)
53 <<
static_cast<char>(foregroundColor) <<
';' <<
static_cast<char>(
ColorContext::Background) <<
static_cast<char>(backgroundColor)
61 stream << '\e' << '[' << static_cast<char>(TextAttribute::Reset) <<
'm';
65 inline void setCursor(std::ostream &stream,
unsigned int row = 0,
unsigned int col = 0)
68 stream <<
'\e' <<
'[' << row <<
';' << col <<
'H';
75 stream << '\e' << '[' << cells << static_cast<char>(direction);
115 return std::make_tuple(foreground, background, displayAttribute);
120 return std::make_tuple(foreground, context, displayAttribute);
123 template <
typename TupleType,
125 std::is_same<TupleType, std::tuple<Color, ColorContext, TextAttribute>>> * =
nullptr>
126 inline std::ostream &
operator<<(std::ostream &stream, TupleType displayAttribute)
128 setStyle(stream, std::get<0>(displayAttribute), std::get<1>(displayAttribute), std::get<2>(displayAttribute));
161 #endif // IOUTILITIES_ANSIESCAPECODES