C++ Utilities  4.17.0
Useful C++ classes and routines such as argument parser, IO and conversion utilities
Namespaces | Enumerations | Functions | Variables
ansiescapecodes.h File Reference
#include "../global.h"
#include "../misc/traits.h"
#include <ostream>
#include <tuple>
Include dependency graph for ansiescapecodes.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 EscapeCodes
 Encapsulates functions for formatted terminal output using ANSI escape codes.
 

Enumerations

enum  EscapeCodes::Color : char {
  EscapeCodes::Color::Black = '0', EscapeCodes::Color::Red, EscapeCodes::Color::Green, EscapeCodes::Color::Yellow,
  EscapeCodes::Color::Blue, EscapeCodes::Color::Purple, EscapeCodes::Color::Cyan, EscapeCodes::Color::White
}
 
enum  EscapeCodes::ColorContext : char { EscapeCodes::ColorContext::Foreground = '3', EscapeCodes::ColorContext::Background = '4' }
 
enum  EscapeCodes::TextAttribute : char {
  EscapeCodes::TextAttribute::Reset = '0', EscapeCodes::TextAttribute::Bold = '1', EscapeCodes::TextAttribute::Dim = '2', EscapeCodes::TextAttribute::Italic = '3',
  EscapeCodes::TextAttribute::Underscore = '4', EscapeCodes::TextAttribute::Blink = '5', EscapeCodes::TextAttribute::ReverseVideo = '7', EscapeCodes::TextAttribute::Concealed = '8',
  EscapeCodes::TextAttribute::Strikethrough = '9'
}
 
enum  EscapeCodes::Direction : char { EscapeCodes::Direction::Up = 'A', EscapeCodes::Direction::Down = 'B', EscapeCodes::Direction::Forward = 'C', EscapeCodes::Direction::Backward = 'D' }
 
enum  EscapeCodes::Phrases {
  EscapeCodes::Phrases::Error, EscapeCodes::Phrases::Warning, EscapeCodes::Phrases::End, EscapeCodes::Phrases::PlainMessage,
  EscapeCodes::Phrases::SuccessMessage, EscapeCodes::Phrases::SubMessage, EscapeCodes::Phrases::ErrorMessage, EscapeCodes::Phrases::WarningMessage,
  EscapeCodes::Phrases::EndFlush, EscapeCodes::Phrases::Info, EscapeCodes::Phrases::Override, EscapeCodes::Phrases::SubError,
  EscapeCodes::Phrases::SubWarning
}
 The Phrases enum contains standard phrases which can be printed to any std::ostream. More...
 

Functions

void EscapeCodes::setStyle (std::ostream &stream, TextAttribute displayAttribute=TextAttribute::Reset)
 
void EscapeCodes::setStyle (std::ostream &stream, Color color, ColorContext context=ColorContext::Foreground, TextAttribute displayAttribute=TextAttribute::Reset)
 
void EscapeCodes::setStyle (std::ostream &stream, Color foregroundColor, Color backgroundColor, TextAttribute displayAttribute=TextAttribute::Reset)
 
void EscapeCodes::resetStyle (std::ostream &stream)
 
void EscapeCodes::setCursor (std::ostream &stream, unsigned int row=0, unsigned int col=0)
 
void EscapeCodes::moveCursor (std::ostream &stream, unsigned int cells, Direction direction)
 
void EscapeCodes::saveCursor (std::ostream &stream)
 
void EscapeCodes::restoreCursor (std::ostream &stream)
 
void EscapeCodes::eraseDisplay (std::ostream &stream)
 
void EscapeCodes::eraseLine (std::ostream &stream)
 
std::ostream & EscapeCodes::operator<< (std::ostream &stream, TextAttribute displayAttribute)
 
constexpr auto EscapeCodes::color (Color foreground, Color background, TextAttribute displayAttribute=TextAttribute::Reset)
 
constexpr auto EscapeCodes::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 & EscapeCodes::operator<< (std::ostream &stream, TupleType displayAttribute)
 
CPP_UTILITIES_EXPORT std::ostream & EscapeCodes::operator<< (std::ostream &stream, Phrases phrase)
 Prints the specified phrase. More...
 

Variables

CPP_UTILITIES_EXPORT bool EscapeCodes::enabled
 Controls whether the functions inside the EscapeCodes namespace actually make use of escape codes. More...