31 #ifndef DRAIN_TEXT_STYLE_VT100
32 #define DRAIN_TEXT_STYLE_VT100
38 #include "StringBuilder.h"
39 #include "TextStyle.h"
49 template <
typename ... T>
58 template <
typename ... TT>
59 void write(std::ostream & ostr,
const TT &... args)
const{
61 append(ostr, args...);
67 void startWrite(std::ostream & ostr)
const {
71 void endWrite(std::ostream & ostr)
const {
75 template <
typename ... TT>
76 void append(std::ostream & ostr,
const TT &... args)
const{
81 typedef std::map<drain::TextStyle::Colour,int> color_codemap_t;
82 typedef std::map<drain::TextStyle::Style,int> style_codemap_t;
83 typedef std::map<drain::TextStyle::Line,int> line_codemap_t;
86 const color_codemap_t color_codemap;
89 const style_codemap_t style_codemap;
92 const line_codemap_t line_codemap;
96 const std::map<T,int> & getCodeMap();
104 typedef std::map<E,int> codemap_t;
106 const codemap_t & map = getCodeMap<E>();
108 typename codemap_t::const_iterator it = map.find(enumCode);
109 if (it != map.end()){
114 for (
const auto & entry: map){
115 std::cerr << entry.first <<
'=' << (int)entry.first <<
" VT100=" << entry.second << std::endl;
119 std::cerr << StringBuilder<>(
TypeName<E>::str(),
": no such enumCode: ", enumCode) << std::endl;
121 std::cerr << __FILE__ <<
'/' << __FUNCTION__ <<
": no such enumCode: " << enumCode << std::endl;
122 throw std::runtime_error(
"No such enumCode: ");
133 template <
typename T,
typename ... TT>
135 void _append(std::ostream & ostr,
bool init,
const T & arg,
const TT &... args)
const{
137 _appendControlSuffix(ostr);
143 template <
typename ... TT>
145 void _append(std::ostream & ostr,
bool start,
const Colour & colour,
const TT &... args)
const{
146 _appendControlPrefix(ostr, start);
151 template <
typename ... TT>
153 void _append(std::ostream & ostr,
bool start,
const Line & line,
const TT &... args)
const{
154 _appendControlPrefix(ostr, start);
159 template <
typename ... TT>
161 void _append(std::ostream & ostr,
bool start,
const Style & style,
const TT &... args)
const{
162 _appendControlPrefix(ostr, start);
168 void _append(std::ostream & ostr,
bool init)
const{
170 _appendControlSuffix(ostr);
175 void _appendControlPrefix(std::ostream & ostr,
bool start)
const {
185 void _appendControlSuffix(std::ostream & ostr)
const {
196 const std::map<TextStyle::Colour,int> & TextStyleVT100::getCodeMap();
199 const std::map<TextStyle::Line,int> & TextStyleVT100::getCodeMap();
202 const std::map<TextStyle::Style,int> & TextStyleVT100::getCodeMap();
205 std::ostream & operator<<(std::ostream & ostr,
const TextStyleVT100 &t){
206 ostr << __FILE__ <<
':' << __LINE__ <<
'?';
210 DRAIN_TYPENAME(TextStyleVT100);
Definition: TextStyleVT100.h:45
void _append(std::ostream &ostr, bool init, const T &arg, const TT &... args) const
Definition: TextStyleVT100.h:135
static int getIntCode(const E &enumCode)
Given an enum value, returns the corresponding numeric VT100 code.
Definition: TextStyleVT100.h:102
Utility for scanning text segments.
Definition: TextStyle.h:50
Definition: DataSelector.cpp:1277