1 #ifndef IOUTILITIES_ANSIESCAPECODES 2 #define IOUTILITIES_ANSIESCAPECODES 5 #include "../misc/traits.h" 35 stream << '\e' << '[' << static_cast<char>(displayAttribute) <<
'm';
43 stream << '\e' << '[' << static_cast<char>(displayAttribute) <<
';' << static_cast<char>(context) << static_cast<char>(
color) <<
'm';
51 << static_cast<char>(foregroundColor) <<
';' << static_cast<char>(
ColorContext::Background) << static_cast<char>(backgroundColor)
63 inline void setCursor(std::ostream &stream,
unsigned int row = 0,
unsigned int col = 0)
66 stream <<
'\e' <<
'[' << row <<
';' << col <<
'H';
73 stream << '\e' << '[' << cells << static_cast<char>(direction);
113 return std::make_tuple(foreground, background, displayAttribute);
118 return std::make_tuple(foreground, context, displayAttribute);
121 template <
typename TupleType,
123 std::is_same<TupleType, std::tuple<Color, ColorContext, TextAttribute>>> * =
nullptr>
124 inline std::ostream &
operator<<(std::ostream &stream, TupleType displayAttribute)
126 setStyle(stream, std::get<0>(displayAttribute), std::get<1>(displayAttribute), std::get<2>(displayAttribute));
154 #endif // IOUTILITIES_ANSIESCAPECODES constexpr auto color(Color foreground, Color background, TextAttribute displayAttribute=TextAttribute::Reset)
Encapsulates functions for formatted terminal output using ANSI escape codes.
#define CPP_UTILITIES_EXPORT
Phrases
The Phrases enum contains standard phrases which can be printed to any std::ostream.
void setStyle(std::ostream &stream, TextAttribute displayAttribute=TextAttribute::Reset)
void moveCursor(std::ostream &stream, unsigned int cells, Direction direction)
void restoreCursor(std::ostream &stream)
void eraseDisplay(std::ostream &stream)
CPP_UTILITIES_EXPORT bool enabled
Controls whether the functions inside the EscapeCodes namespace actually make use of escape codes.
void resetStyle(std::ostream &stream)
void eraseLine(std::ostream &stream)
typename std::enable_if< Any< Condition... >::value, Detail::Enabler >::type EnableIfAny
Shortcut for std::enable_if to apply Traits::Any and omit ::value and ::type.
void saveCursor(std::ostream &stream)
void setCursor(std::ostream &stream, unsigned int row=0, unsigned int col=0)
std::ostream & operator<<(std::ostream &stream, TextAttribute displayAttribute)