libwreport  3.42
term.h
1 #ifndef WREPORT_TERM_H
2 #define WREPORT_TERM_H
3 
11 #include <cstdio>
12 #include <string>
13 
14 namespace wreport::term {
15 
16 struct Terminal
17 {
18  static const unsigned black;
19  static const unsigned red;
20  static const unsigned green;
21  static const unsigned yellow;
22  static const unsigned blue;
23  static const unsigned magenta;
24  static const unsigned cyan;
25  static const unsigned white;
26  static const unsigned bright;
27 
28  FILE* out;
29  bool isatty;
30 
31  struct Restore
32  {
33  Terminal& term;
34 
35  Restore(Terminal& term);
36  ~Restore();
37  };
38 
39  Terminal(FILE* out);
40 
41  Restore set_color(int fg, int bg);
42  Restore set_color_fg(int col);
43  Restore set_color_bg(int col);
44 
45  std::string color(int fg, int bg, const std::string& s);
46  std::string color_fg(int col, const std::string& s);
47  std::string color_bg(int col, const std::string& s);
48 
49  operator FILE*() { return out; }
50 };
51 
52 } // namespace wreport::term
53 
54 #endif
Contrl terminal output.
Definition: term.h:14
Definition: term.h:16