libzypp  17.35.15
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 
22 namespace ztui {
23 
27 bool do_ttyout();
28 
30 bool do_colors();
31 
33 
34 enum class ColorContext
35 {
36  DEFAULT,
37 
38  RESULT,
39  MSG_STATUS,
40  MSG_ERROR,
42  PROMPT,
44  POSITIVE,
45  CHANGE,
46  NEGATIVE,
47  HIGHLIGHT,
48  LOWLIGHT,
49 
50  OSDEBUG
51 };
52 
54 ansi::Color customColorCtor( ColorContext ctxt_r );
55 
56 namespace ansi
57 {
58  // Enable using ColorContext as ansi::SGRSequence
59  template<>
61  { enum { customColorCtor = true }; };
62 }
63 
64 // ColorString types
65 template <ColorContext _ctxt>
66 struct 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 
73 template <ColorContext _ctxt>
74 inline 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 string if do_colors.
Definition: ansi.h:496
ansi::Color customColorCtor(ColorContext ctxt_r)
Definition: colors.cc:125
bool do_colors()
If output is done in colors (depends on config)
Definition: colors.cc:32
CCString(std::string &&str_r)
Definition: colors.h:70
Definition: Arch.h:363
ColorContext
Definition: colors.h:34
bool do_ttyout()
True unless output is a dumb tty or file.
Definition: colors.cc:27
Colored stream output if do_colors.
Definition: ansi.h:673
CCString(const std::string &str_r)
Definition: colors.h:69