15#if !defined(R__ALPHA) && !defined(R__SOLARIS) && !defined(R__ACC) && !defined(R__FBSD)
19 Int_t Cout::fgLineLength = 100;
20 Cout* Cout::fgInstance = NULL;
21 Hal::EInfo Cout::fgVerboseMode = Hal::EInfo::kInfo;
28 Int_t wide = (fgLineLength - 2 - no) / no;
31 for (Int_t i = 0; i < no; i++) {
32 capt = va_arg(ap,
char*);
36 act_wide = wide - line.Length();
37 for (Int_t j = 0; j < act_wide - 1; j++) {
41 if (i < no - 1) line = line +
"|";
50 auto strings = Hal::Std::GetVector(list);
58 Int_t no = list.size();
59 Int_t wide = (fgLineLength - 2 - no) / no;
62 for (
unsigned int i = 0; i < list.size(); i++) {
66 act_wide = wide - line.Length();
67 for (Int_t j = 0; j < act_wide - 1; j++) {
71 if (i < (
unsigned int) (no - 1)) line = line +
"|";
77 void Cout::InStars(TString text, Color_t color) {
78 TString Header =
"******";
79 Header = Header + text;
80 Int_t dlugosc = Header.Length();
81 Int_t spacji = (fgLineLength - dlugosc);
82 for (Int_t i = 0; i < spacji; i++) {
83 Header = Header +
"*";
85 if ((Int_t) color == -1) {
86 std::cout << Header << std::endl;
92 void Cout::Text(TString text, TString option, Color_t color) {
93 if (text.Length() <= fgLineLength - 4) {
95 Int_t dlugosc = text.Length();
96 Int_t spacji = (fgLineLength - 2 - dlugosc) / 2;
97 for (Int_t i = 0; i < spacji; i++) {
100 for (Int_t i = 0; i < spacji; i++) {
103 if (dlugosc % 2 == 1) {
111 }
else if (option ==
"L") {
112 Int_t dlugosc = text.Length();
114 for (Int_t i = 0; i < fgLineLength - 3 - dlugosc; i++) {
120 Int_t dlugosc = text.Length();
122 for (Int_t i = 0; i < fgLineLength - 3 - dlugosc; i++) {
128 if ((Int_t) color == -1)
129 std::cout << text << std::endl;
134 Int_t zz = (Int_t) text.Length() / (fgLineLength - 4);
135 for (Int_t i = 0; i < zz; i++) {
136 Int_t beg = i * (fgLineLength - 4);
137 Int_t end = (fgLineLength - 4);
138 TString temp = TString(text(beg, end));
139 Text(temp, option, color);
141 if (zz * (fgLineLength - 4) < text.Length()) {
142 Int_t beg = zz * (fgLineLength - 4);
143 Int_t end = text.Length() - zz * (fgLineLength - 4);
144 TString temp = TString(text(beg, end));
145 Text(temp, option, color);
152 for (Int_t i = 0; i < fgLineLength; i++) {
153 starline = starline +
"*";
155 if ((Int_t) color == -1) {
156 std::cout << starline << std::endl;
162 void Cout::PrintError(TString error) {
163 InStars(
"ERROR", kRed);
164 if (error.Length() < (fgLineLength - 4)) {
165 Text(error,
"L", kRed);
167 Int_t zz = (Int_t) error.Length() / ((fgLineLength - 4));
168 for (Int_t i = 0; i < zz; i++) {
169 Int_t beg = i * (fgLineLength - 4);
170 Int_t end = (fgLineLength - 4);
171 TString temp = TString(error(beg, end));
172 Text(temp,
"L", kRed);
174 if (zz * (fgLineLength - 4) < error.Length()) {
175 Int_t beg = zz * (fgLineLength - 4);
176 Int_t end = error.Length() - zz * (fgLineLength - 4);
177 TString temp = TString(error(beg, end));
178 Text(temp,
"L", kRed);
185 void Cout::PrintWarning(TString warning) {
186 InStars(
"WARNING", kOrange);
187 if (warning.Length() < fgLineLength - 10) {
188 Text(warning,
"L", kOrange);
190 Int_t zz = (Int_t) warning.Length() / ((fgLineLength - 4));
191 for (Int_t i = 0; i < zz; i++) {
192 Int_t beg = i * (fgLineLength - 4);
193 Int_t end = (fgLineLength - 4);
194 TString temp = TString(warning(beg, end));
195 Text(temp,
"L", kOrange);
197 if (zz * (fgLineLength - 4) < warning.Length()) {
198 Int_t beg = zz * (fgLineLength - 4);
199 Int_t end = warning.Length() - zz * (fgLineLength - 4);
200 TString temp = TString(warning(beg, end));
201 Text(temp,
"L", kOrange);
210 TString empline(
' ', fgLineLength - 2);
211 empline =
"*" + empline;
212 if ((Int_t) color == -1) {
213 std::cout << empline << std::endl;
215 std::cout <<
GetColor(color) << empline << std::endl;
221 double ratio = actual / total;
224 std::cout <<
GetColor(kViolet) << Form(
"%4d%% ", (
int) (ratio * 100)) << Form(
"\n\033[F\033[J") <<
GetDisableColor()
233 double ratio = actual / total;
234 int c = ratio * (fgLineLength - 7);
237 printf(
"%3d%% [", (
int) (ratio * 100));
239 for (
int x = 0; x < c; x++)
241 for (
int x = c; x < fgLineLength - 7; x++)
245 printf(
"]\n\033[F\033[J");
251 Cout::Text(Hal::Std::RoundToString(i),
"L", kViolet);
257 Cout::Text(Form(
"%s %i", filename.Data(), i),
"L", kViolet);
304 TString Cout::MergeStrings(Int_t no, ...) {
309 for (Int_t i = 0; i < no; i++) {
310 capt = va_arg(ap,
char*);
311 begin = begin + capt;
323 Int_t wide = (fgLineLength - shift - 1 - 2 - no) / no;
326 line = Cout::GetShift(shift);
327 for (Int_t i = 0; i < no; i++) {
328 capt = va_arg(ap,
char*);
332 act_wide = wide - sl;
333 for (Int_t j = 0; j < act_wide - 1; j++) {
337 if (i < no - 1) line = line +
"|";
338 begin = begin + line;
345 void Cout::InStars(Int_t shift, TString text, Color_t color) {
346 text = Cout::GetShift(shift) + text;
347 Cout::InStars(text, color);
351 text = GetShift(shift) + text;
356 text = text + GetShift(shift);
357 InStars(text, color);
360 TString Cout::GetShift(Int_t i) {
362 for (
int j = 0; j < i; j++) {
371 if (status < fgVerboseMode) {
return; }
373 case Hal::EInfo::kDebugInfo:
FailSucced(text,
"DEBUG ", kCyan);
break;
374 case Hal::EInfo::kInfo:
FailSucced(text,
"INFO ", kCyan);
break;
375 case Hal::EInfo::kLowWarning:
FailSucced(text,
"WARNING ", kOrange);
break;
376 case Hal::EInfo::kWarning: PrintWarning(text);
break;
377 case Hal::EInfo::kError:
FailSucced(text,
"ERROR ", kRed);
break;
378 case Hal::EInfo::kCriticalError: PrintError(text);
break;
383 Int_t total = value.Length() + flag.Length();
384 Int_t nr_spaces = (fgLineLength - 4) - total - 2;
385 if (nr_spaces < 0) nr_spaces = 0;
386 TString spaces(
' ', nr_spaces);
387 spaces = value + spaces;
394 PrintWarning(
"Instance of HalCout exist");
401 if (fgInstance == NULL) { fgInstance =
new Cout(); }
408 auto Colored = [](TString str, Color_t col) {
417 if (flag < fgVerboseMode)
return;
418 auto vec = Hal::Std::ExplodeString(file,
'/');
419 TString filename = vec[vec.size() - 1];
420 TString dDot =
"../";
421 if (vec.size() > 2) { filename = dDot + vec[vec.size() - 2] +
"/" + filename; }
422 TString helpText =
"";
423 Color_t helpCol = kWhite;
425 case Hal::EInfo::kDebugInfo: {
429 case Hal::EInfo::kInfo: {
433 case Hal::EInfo::kLowWarning: {
434 helpText =
"LOW WARN";
437 case Hal::EInfo::kWarning: {
438 helpText =
"WARNING ";
441 case Hal::EInfo::kError: {
445 case Hal::EInfo::kCriticalError: {
446 helpText =
"CRIT ERR";
453 TString open = colEn +
"[" + colDis;
454 TString close = colEn +
"]" + colDis;
456 while (filename.Length() < 78) {
457 filename = filename +
" ";
461 TString fileinfo = Form(
"[%8i][%s]", line, filename.Data());
462 fileinfo.ReplaceAll(
"[", open);
463 fileinfo.ReplaceAll(
"]", close);
464 std::cout << fileinfo << std::endl;
465 std::cout << Colored(helpText, helpCol) << text << std::endl;
static void Text(TString text, TString option="L", Color_t color=-1)
static void PrintLineFileInfo(TString file, Int_t line, TString text, Hal::EInfo flag=Hal::EInfo::kDebugInfo)
static void PrintInfo(TString text, Hal::EInfo status)
static void Stars(Color_t color=-1)
static TString GetColor(Color_t Color)
static void Empty(Color_t color=-1)
static TString GetDisableColor()
static void DebugInfo(Int_t i)
static void Database(Int_t no...)
static void ShiftDatabase(Int_t shift, Int_t no...)
static void FailSucced(TString value, TString flag, Color_t color)
static void ShiftInStars(Int_t shift, TString text, Color_t color=-1)
static void SetVerboseMode(Hal::EInfo verbose)
static void Percent(Double_t actual, Double_t total)
static void ProgressBar(Double_t acutal, Double_t total)
static void ShiftText(Int_t shift, TString text, TString option, Color_t color=-1)