1 #ifndef RestCore_TRestStringOutput
2 #define RestCore_TRestStringOutput
15 #include "TRestTools.h"
19 #include <sys/ioctl.h>
27 #define COLORCODE_TYPE std::string
28 constexpr
const char*
const COLOR_RESET =
"\033[0m";
29 constexpr
const char*
const COLOR_BLACK =
"\033[30m";
30 constexpr
const char*
const COLOR_RED =
"\033[31m";
31 constexpr
const char*
const COLOR_GREEN =
"\033[32m";
32 constexpr
const char*
const COLOR_YELLOW =
"\033[33m";
33 constexpr
const char*
const COLOR_BLUE =
"\033[34m";
34 constexpr
const char*
const COLOR_MAGENTA =
"\033[35m";
35 constexpr
const char*
const COLOR_CYAN =
"\033[36m";
36 constexpr
const char*
const COLOR_WHITE =
"\033[37m";
37 constexpr
const char*
const COLOR_BOLDBLACK =
"\033[1m\033[30m";
38 constexpr
const char*
const COLOR_BOLDRED =
"\033[1m\033[31m";
39 constexpr
const char*
const COLOR_BOLDGREEN =
"\033[1m\033[32m";
40 constexpr
const char*
const COLOR_BOLDYELLOW =
"\033[1m\033[33m";
41 constexpr
const char*
const COLOR_BOLDBLUE =
"\033[1m\033[34m";
42 constexpr
const char*
const COLOR_BOLDMAGENTA =
"\033[1m\033[35m";
43 constexpr
const char*
const COLOR_BOLDCYAN =
"\033[1m\033[36m";
44 constexpr
const char*
const COLOR_BOLDWHITE =
"\033[1m\033[37m";
45 constexpr
const char*
const COLOR_BACKGROUNDBLACK =
"\033[1m\033[40m";
46 constexpr
const char*
const COLOR_BACKGROUNDRED =
"\033[1m\033[41m";
47 constexpr
const char*
const COLOR_BACKGROUNDGREEN =
"\033[1m\033[42m";
48 constexpr
const char*
const COLOR_BACKGROUNDYELLOW =
"\033[1m\033[43m";
49 constexpr
const char*
const COLOR_BACKGROUNDBLUE =
"\033[1m\033[44m";
50 constexpr
const char*
const COLOR_BACKGROUNDMAGENTA =
"\033[1m\033[45m";
51 constexpr
const char*
const COLOR_BACKGROUNDCYAN =
"\033[1m\033[46m";
52 constexpr
const char*
const COLOR_BACKGROUNDWHITE =
"\033[1m\033[47m";
55 #define COLORCODE_TYPE int
56 EXTERN_DEF
int COLOR_RESET;
58 constexpr
int COLOR_BLACK = 0;
59 constexpr
int COLOR_RED = 4;
60 constexpr
int COLOR_GREEN = 2;
61 constexpr
int COLOR_YELLOW = 14;
62 constexpr
int COLOR_BLUE = 1;
63 constexpr
int COLOR_MAGENTA = 5;
64 constexpr
int COLOR_CYAN = 9;
65 constexpr
int COLOR_WHITE = 7;
68 constexpr
int COLOR_BOLDBLACK = COLOR_BLACK;
69 constexpr
int COLOR_BOLDRED = COLOR_RED;
70 constexpr
int COLOR_BOLDGREEN = COLOR_GREEN;
71 constexpr
int COLOR_BOLDYELLOW = COLOR_YELLOW;
72 constexpr
int COLOR_BOLDBLUE = COLOR_BLUE;
73 constexpr
int COLOR_BOLDMAGENTA = COLOR_MAGENTA;
74 constexpr
int COLOR_BOLDCYAN = COLOR_CYAN;
75 constexpr
int COLOR_BOLDWHITE = COLOR_WHITE;
94 static int GetWidth();
96 static int GetHeight();
102 static int ReadKey();
104 static std::string ReadLine();
106 static void WriteLine(std::string content);
108 static void CursorUp(
int n);
110 static void CursorDown(
int n);
112 static void CursorRight(
int n);
114 static void CursorLeft(
int n);
116 static void CursorToXY(
int x,
int y);
118 static void ClearScreen();
120 static void ClearCurrentLine();
122 static void ClearLinesAfterCursor();
136 friend std::ostream& operator<<(std::ostream& a, endl_t& et) {
return (a << std::endl); }
166 COLORCODE_TYPE color;
167 std::string formatstring;
172 std::stringstream buf;
179 std::string GetBuffer() {
return buf.str(); }
180 bool isError() {
return iserror; }
181 std::string FormattingPrintString(std::string input);
184 void setcolor(COLORCODE_TYPE colordef) { color = colordef; }
185 void setheader(std::string headerdef) {
186 formatstring = headerdef;
189 void resetcolor() { color = COLOR_RESET; }
190 void resetheader() { formatstring =
""; }
191 void setborder(std::string b) {
195 void resetborder() { formatstring =
""; }
196 void setlength(
int n);
198 void resetorientation() { orientation = REST_Display_Orientation::kMiddle; }
205 COLORCODE_TYPE color = COLOR_RESET, std::string formatter =
"",
209 REST_Verbose_Level v, COLORCODE_TYPE _color = COLOR_RESET, std::string formatter =
"",
211 bool _iserror =
false)
236 "[== ==]", TRestStringOutput::REST_Display_Orientation::kMiddle);
238 "-- Error : ", TRestStringOutput::REST_Display_Orientation::kLeft,
true);
239 static TRestStringOutput RESTWarning(TRestStringOutput::REST_Verbose_Level::REST_Warning, COLOR_BOLDYELLOW,
240 "-- Warning : ", TRestStringOutput::REST_Display_Orientation::kLeft,
243 "", TRestStringOutput::REST_Display_Orientation::kMiddle);
245 "|| ||", TRestStringOutput::REST_Display_Orientation::kMiddle);
247 "-- Info : ", TRestStringOutput::REST_Display_Orientation::kLeft);
249 "-- Success : ", TRestStringOutput::REST_Display_Orientation::kLeft);
251 "-- Debug : ", TRestStringOutput::REST_Display_Orientation::kLeft);
253 "-- Extreme : ", TRestStringOutput::REST_Display_Orientation::kLeft);
259 EXTERN_DEF
bool REST_Display_CompatibilityMode;
REST_Display_Orientation
Enumerate of TRestStringOutput display orientation.
REST_Verbose_Level
Enumerate of verbose level, containing five levels.
@ REST_Essential
+show some essential information, as well as warnings
@ REST_Extreme
show everything
@ REST_Info
+show most of the information for each steps
@ REST_Debug
+show the defined debug messages
@ REST_Silent
show minimum information of the software, as well as error messages