1#ifndef RestCore_TRestStringOutput
2#define RestCore_TRestStringOutput
15#include "TRestTools.h"
27#define COLORCODE_TYPE std::string
28constexpr const char*
const COLOR_RESET =
"\033[0m";
29constexpr const char*
const COLOR_BLACK =
"\033[30m";
30constexpr const char*
const COLOR_RED =
"\033[31m";
31constexpr const char*
const COLOR_GREEN =
"\033[32m";
32constexpr const char*
const COLOR_YELLOW =
"\033[33m";
33constexpr const char*
const COLOR_BLUE =
"\033[34m";
34constexpr const char*
const COLOR_MAGENTA =
"\033[35m";
35constexpr const char*
const COLOR_CYAN =
"\033[36m";
36constexpr const char*
const COLOR_WHITE =
"\033[37m";
37constexpr const char*
const COLOR_BOLDBLACK =
"\033[1m\033[30m";
38constexpr const char*
const COLOR_BOLDRED =
"\033[1m\033[31m";
39constexpr const char*
const COLOR_BOLDGREEN =
"\033[1m\033[32m";
40constexpr const char*
const COLOR_BOLDYELLOW =
"\033[1m\033[33m";
41constexpr const char*
const COLOR_BOLDBLUE =
"\033[1m\033[34m";
42constexpr const char*
const COLOR_BOLDMAGENTA =
"\033[1m\033[35m";
43constexpr const char*
const COLOR_BOLDCYAN =
"\033[1m\033[36m";
44constexpr const char*
const COLOR_BOLDWHITE =
"\033[1m\033[37m";
45constexpr const char*
const COLOR_BACKGROUNDBLACK =
"\033[1m\033[40m";
46constexpr const char*
const COLOR_BACKGROUNDRED =
"\033[1m\033[41m";
47constexpr const char*
const COLOR_BACKGROUNDGREEN =
"\033[1m\033[42m";
48constexpr const char*
const COLOR_BACKGROUNDYELLOW =
"\033[1m\033[43m";
49constexpr const char*
const COLOR_BACKGROUNDBLUE =
"\033[1m\033[44m";
50constexpr const char*
const COLOR_BACKGROUNDMAGENTA =
"\033[1m\033[45m";
51constexpr const char*
const COLOR_BACKGROUNDCYAN =
"\033[1m\033[46m";
52constexpr const char*
const COLOR_BACKGROUNDWHITE =
"\033[1m\033[47m";
55#define COLORCODE_TYPE int
56EXTERN_DEF
int COLOR_RESET;
58constexpr int COLOR_BLACK = 0;
59constexpr int COLOR_RED = 4;
60constexpr int COLOR_GREEN = 2;
61constexpr int COLOR_YELLOW = 14;
62constexpr int COLOR_BLUE = 1;
63constexpr int COLOR_MAGENTA = 5;
64constexpr int COLOR_CYAN = 9;
65constexpr int COLOR_WHITE = 7;
68constexpr int COLOR_BOLDBLACK = COLOR_BLACK;
69constexpr int COLOR_BOLDRED = COLOR_RED;
70constexpr int COLOR_BOLDGREEN = COLOR_GREEN;
71constexpr int COLOR_BOLDYELLOW = COLOR_YELLOW;
72constexpr int COLOR_BOLDBLUE = COLOR_BLUE;
73constexpr int COLOR_BOLDMAGENTA = COLOR_MAGENTA;
74constexpr int COLOR_BOLDCYAN = COLOR_CYAN;
75constexpr 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); }
155 REST_Warning = REST_Essential,
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);
239static 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);
259EXTERN_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