1#ifndef IOUTILITIES_ANSIESCAPECODES
2#define IOUTILITIES_ANSIESCAPECODES
12namespace EscapeCodes {
37 stream << '\033' << '[' << static_cast<char>(displayAttribute) <<
'm';
45 stream << '\033' << '[' << static_cast<char>(displayAttribute) <<
';' <<
static_cast<char>(context) <<
static_cast<char>(
color) <<
'm';
53 <<
static_cast<char>(foregroundColor) <<
';' <<
static_cast<char>(
ColorContext::Background) <<
static_cast<char>(backgroundColor)
65inline void setCursor(std::ostream &stream,
unsigned int row = 0,
unsigned int col = 0)
68 stream <<
'\033' <<
'[' << row <<
';' << col <<
'H';
75 stream << '\033' << '[' << cells << static_cast<char>(direction);
115 return std::make_tuple(foreground, background, displayAttribute);
120 return std::make_tuple(foreground, context, displayAttribute);
123template <
typename TupleType,
125 std::is_same<TupleType, std::tuple<Color, ColorContext, TextAttribute>>> * =
nullptr>
126inline std::ostream &
operator<<(std::ostream &stream, TupleType displayAttribute)
128 setStyle(stream, std::get<0>(displayAttribute), std::get<1>(displayAttribute), std::get<2>(displayAttribute));
#define CPP_UTILITIES_EXPORT
Marks the symbol to be exported by the c++utilities library.
void moveCursor(std::ostream &stream, unsigned int cells, Direction direction)
constexpr auto color(Color foreground, Color background, TextAttribute displayAttribute=TextAttribute::Reset)
void setCursor(std::ostream &stream, unsigned int row=0, unsigned int col=0)
CPP_UTILITIES_EXPORT std::string_view phraseString(Phrases phrase)
Returns a string for the specified phrase without formatting.
void eraseLine(std::ostream &stream)
void eraseDisplay(std::ostream &stream)
void saveCursor(std::ostream &stream)
std::ostream & operator<<(std::ostream &stream, TextAttribute displayAttribute)
CPP_UTILITIES_EXPORT bool enabled
Controls whether the functions inside the EscapeCodes namespace actually make use of escape codes.
void setStyle(std::ostream &stream, TextAttribute displayAttribute=TextAttribute::Reset)
void restoreCursor(std::ostream &stream)
CPP_UTILITIES_EXPORT std::string_view formattedPhraseString(Phrases phrase)
Returns a string for the specified phrase which is formatted using ANSI escape codes.
Phrases
The Phrases enum contains standard phrases which can be printed to any std::ostream and obtained as s...
void resetStyle(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.
Contains all utilities provides by the c++utilities library.