libzypp 17.37.17
colors.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8----------------------------------------------------------------------/
9*
10* This file contains private API, this might break at any time between releases.
11* Strictly for internal use!
12*/
13
14#ifndef ZYPP_TUI_UTILS_COLORS_H_
15#define ZYPP_TUI_UTILS_COLORS_H_
16
17#include <iostream>
18#include <string>
19
20#include "ansi.h"
21
22namespace ztui {
23
27bool do_ttyout();
28
30bool do_colors();
31
33
52
54ansi::Color customColorCtor( ColorContext ctxt_r );
55
56namespace ansi
57{
58 // Enable using ColorContext as ansi::SGRSequence
59 template<>
61 { enum { customColorCtor = true }; };
62}
63
64// ColorString types
65template <ColorContext _ctxt>
66struct CCString : public ColorString
67{
68 CCString() : ColorString( _ctxt ) {}
69 explicit CCString( const std::string & str_r ) : ColorString( _ctxt, str_r ) {}
70 explicit CCString( std::string && str_r ) : ColorString( _ctxt, std::move(str_r) ) {}
71};
72
73template <ColorContext _ctxt>
74inline ansi::ColorStream & operator<<( ansi::ColorStream & cstr_r, const CCString<_ctxt> & cstring_r )
75{ return cstr_r << static_cast<const ColorString &>(cstring_r); }
76
78
82
86
89
90}
91
92#endif /* ZYPP_TUI_UTILS_COLORS_H_ */
Colored stream output if do_colors.
Definition ansi.h:674
Definition Arch.h:364
CCString< ColorContext::LOWLIGHT > LOWLIGHTString
Definition colors.h:88
CCString< ColorContext::NEGATIVE > NEGATIVEString
Definition colors.h:85
CCString< ColorContext::MSG_ERROR > MSG_ERRORString
Definition colors.h:80
CCString< ColorContext::MSG_WARNING > MSG_WARNINGString
Definition colors.h:81
CCString< ColorContext::HIGHLIGHT > HIGHLIGHTString
Definition colors.h:87
CCString< ColorContext::CHANGE > CHANGEString
Definition colors.h:84
CCString< ColorContext::POSITIVE > POSITIVEString
Definition colors.h:83
ansi::Color customColorCtor(ColorContext ctxt_r)
Definition colors.cc:125
ColorContext
Definition colors.h:35
bool do_ttyout()
True unless output is a dumb tty or file.
Definition colors.cc:27
bool do_colors()
If output is done in colors (depends on config)
Definition colors.cc:32
CCString< ColorContext::DEFAULT > DEFAULTString
Definition colors.h:77
CCString< ColorContext::MSG_STATUS > MSG_STATUSString
Definition colors.h:79
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
CCString(const std::string &str_r)
Definition colors.h:69
CCString(std::string &&str_r)
Definition colors.h:70