13#include <zypp-tui/Application> 
   21  { return ::getenv(
"NO_COLOR"); }
 
 
 
   39  constexpr auto detectAnsiEscapes = [](){
 
   40    if ( ::isatty(STDOUT_FILENO) )
 
   42      char *term = ::getenv(
"TERM");
 
   43      if ( term && ::strcmp( term, 
"dumb" ) )
 
   49  static bool mayUse = detectAnsiEscapes();
 
 
   60    const EscapeSequence 
clearLN ( 
"\033[2K\r", 
"\n" );
 
   61    const EscapeSequence 
cursorUP       ( 
"\033[1A" );
 
   70    static const std::map<std::string, ansi::Color> _def =  {
 
   89    if ( colorName.empty() )    
 
  103      name_r.erase( 0, 6 );
 
  107    auto && it = _def.find( name_r );
 
  108    if ( it == _def.end() )
 
  110      ERR << 
"Unknown color name '" << name_r << 
"'" << std::endl;
 
  115      ret = ( it->second < ret );
 
 
static Application & instance()
ansi::Color color_osdebug
ansi::Color color_promptOption
ansi::Color color_msgWarning
ansi::Color color_highlight
ansi::Color color_negative
ansi::Color color_positive
ansi::Color color_lowlight
ansi::Color color_msgStatus
ansi::Color color_msgError
Various ways to define ansi SGR sequences.
Color()
Default ctor: terminal default color.
static Color fromString(const std::string &colorName)
static Color nocolor()
Leave everything unchanged.
const EscapeSequence cursorUP
Cursor up 1 line.
const EscapeSequence clearLN
Clear entire line.
const EscapeSequence cursorDOWN
Cursor down 1 line.
const EscapeSequence cursorRIGHT
Cursor right 1 char.
const EscapeSequence cursorLEFT
Cursor left 1 char.
bool mayUseANSIEscapes()
Simple check whether stdout is a (not dumb) tty.
ansi::Color customColorCtor(ColorContext ctxt_r)
bool do_ttyout()
True unless output is a dumb tty or file.
bool hasANSIColor()
Simple check whether stdout can handle colors.
bool do_colors()
If output is done in colors (depends on config)
Namespace intended to collect all environment variables we use.
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
std::string toLower(const std::string &s)
Return lowercase version of s.