C++ Utilities
4.15.0
Useful C++ classes and routines such as argument parser, IO and conversion utilities
|
Encapsulates functions for formatted terminal output using ANSI escape codes. More...
Enumerations | |
enum | Color : char { Color::Black = '0', Color::Red, Color::Green, Color::Yellow, Color::Blue, Color::Purple, Color::Cyan, Color::White } |
enum | ColorContext : char { ColorContext::Foreground = '3', ColorContext::Background = '4' } |
enum | TextAttribute : char { TextAttribute::Reset = '0', TextAttribute::Bold = '1', TextAttribute::Dim = '2', TextAttribute::Italic = '3', TextAttribute::Underscore = '4', TextAttribute::Blink = '5', TextAttribute::ReverseVideo = '7', TextAttribute::Concealed = '8', TextAttribute::Strikethrough = '9' } |
enum | Direction : char { Direction::Up = 'A', Direction::Down = 'B', Direction::Forward = 'C', Direction::Backward = 'D' } |
enum | Phrases { Phrases::Error, Phrases::Warning, Phrases::End, Phrases::PlainMessage, Phrases::SuccessMessage, Phrases::SubMessage, Phrases::ErrorMessage, Phrases::WarningMessage, Phrases::EndFlush, Phrases::Info, Phrases::Override } |
The Phrases enum contains standard phrases which can be printed to any std::ostream. More... | |
Functions | |
void | setStyle (std::ostream &stream, TextAttribute displayAttribute=TextAttribute::Reset) |
void | setStyle (std::ostream &stream, Color color, ColorContext context=ColorContext::Foreground, TextAttribute displayAttribute=TextAttribute::Reset) |
void | setStyle (std::ostream &stream, Color foregroundColor, Color backgroundColor, TextAttribute displayAttribute=TextAttribute::Reset) |
void | resetStyle (std::ostream &stream) |
void | setCursor (std::ostream &stream, unsigned int row=0, unsigned int col=0) |
void | moveCursor (std::ostream &stream, unsigned int cells, Direction direction) |
void | saveCursor (std::ostream &stream) |
void | restoreCursor (std::ostream &stream) |
void | eraseDisplay (std::ostream &stream) |
void | eraseLine (std::ostream &stream) |
std::ostream & | operator<< (std::ostream &stream, TextAttribute displayAttribute) |
constexpr auto | color (Color foreground, Color background, TextAttribute displayAttribute=TextAttribute::Reset) |
constexpr auto | color (Color foreground, ColorContext context, TextAttribute displayAttribute=TextAttribute::Reset) |
template<typename TupleType , Traits::EnableIfAny< std::is_same< TupleType, std::tuple< Color, Color, TextAttribute >>, std::is_same< TupleType, std::tuple< Color, ColorContext, TextAttribute >>> * = nullptr> | |
std::ostream & | operator<< (std::ostream &stream, TupleType displayAttribute) |
CPP_UTILITIES_EXPORT std::ostream & | operator<< (std::ostream &stream, Phrases phrase) |
Prints the specified phrase. More... | |
Variables | |
CPP_UTILITIES_EXPORT bool | enabled |
Controls whether the functions inside the EscapeCodes namespace actually make use of escape codes. More... | |
Encapsulates functions for formatted terminal output using ANSI escape codes.
|
strong |
Enumerator | |
---|---|
Black | |
Red | |
Green | |
Yellow | |
Blue | |
Purple | |
Cyan | |
White |
Definition at line 14 of file ansiescapecodes.h.
|
strong |
Enumerator | |
---|---|
Foreground | |
Background |
Definition at line 16 of file ansiescapecodes.h.
|
strong |
Enumerator | |
---|---|
Up | |
Down | |
Forward | |
Backward |
Definition at line 30 of file ansiescapecodes.h.
|
strong |
The Phrases enum contains standard phrases which can be printed to any std::ostream.
Example: std::cerr << Phrases::Error << "Something bad happened." << Phrases::End
Definition at line 135 of file ansiescapecodes.h.
|
strong |
Enumerator | |
---|---|
Reset | |
Bold | |
Dim | |
Italic | |
Underscore | |
Blink | |
ReverseVideo | |
Concealed | |
Strikethrough |
Definition at line 18 of file ansiescapecodes.h.
constexpr auto EscapeCodes::color | ( | Color | foreground, |
Color | background, | ||
TextAttribute | displayAttribute = TextAttribute::Reset |
||
) |
Definition at line 111 of file ansiescapecodes.h.
constexpr auto EscapeCodes::color | ( | Color | foreground, |
ColorContext | context, | ||
TextAttribute | displayAttribute = TextAttribute::Reset |
||
) |
Definition at line 116 of file ansiescapecodes.h.
|
inline |
Definition at line 91 of file ansiescapecodes.h.
|
inline |
Definition at line 98 of file ansiescapecodes.h.
|
inline |
Definition at line 70 of file ansiescapecodes.h.
|
inline |
Definition at line 105 of file ansiescapecodes.h.
|
inline |
Definition at line 124 of file ansiescapecodes.h.
std::ostream & EscapeCodes::operator<< | ( | std::ostream & | stream, |
Phrases | phrase | ||
) |
Prints the specified phrase.
Definition at line 31 of file ansiescapecodes.cpp.
|
inline |
Definition at line 56 of file ansiescapecodes.h.
|
inline |
Definition at line 84 of file ansiescapecodes.h.
|
inline |
Definition at line 77 of file ansiescapecodes.h.
|
inline |
Definition at line 63 of file ansiescapecodes.h.
|
inline |
Definition at line 32 of file ansiescapecodes.h.
|
inline |
Definition at line 39 of file ansiescapecodes.h.
|
inline |
Definition at line 47 of file ansiescapecodes.h.
bool EscapeCodes::enabled |
Controls whether the functions inside the EscapeCodes namespace actually make use of escape codes.
This allows to disable use of escape codes when not appropriate.
The default value can be configured at build time by setting the CMake variable ENABLE_ESCAPE_CODES_BY_DEFAULT. The "default for the default" is true. However, the default is overridden with the value of the environment variable ENABLE_ESCAPE_CODES when instantiating an ApplicationUtilities::NoColorArgument (if ENABLE_ESCAPE_CODES is present).
Definition at line 20 of file ansiescapecodes.cpp.