87 lines
1.8 KiB
C++
87 lines
1.8 KiB
C++
#include "Tools.hpp"
|
|
|
|
setoutputcolor::setoutputcolor(ConsoleColors _color)
|
|
: color(_color), bold(false){};
|
|
|
|
setoutputcolor::setoutputcolor(bool _bold) : color(clear), bold(_bold){};
|
|
|
|
setoutputcolor::setoutputcolor(ConsoleColors _color, bool _bold)
|
|
: color(_color), bold(_bold){};
|
|
|
|
std::ostream &operator<<(std::ostream &out, setoutputcolor setOutput) {
|
|
out << "\033[";
|
|
if (setOutput.color == clear) {
|
|
out << "0m";
|
|
return out;
|
|
}
|
|
if (setOutput.bold) {
|
|
out << "1";
|
|
}
|
|
else {
|
|
out << "0";
|
|
}
|
|
switch (setOutput.color) {
|
|
case black:
|
|
out << ";30m";
|
|
break;
|
|
case red:
|
|
out << ";31m";
|
|
break;
|
|
case green:
|
|
out << ";32m";
|
|
break;
|
|
case blue:
|
|
out << ";34m";
|
|
break;
|
|
case magenta:
|
|
out << ";35m";
|
|
break;
|
|
case cyan:
|
|
out << ";36m";
|
|
break;
|
|
case lightGray:
|
|
out << ";37m";
|
|
break;
|
|
default:
|
|
out << "m\033[0m";
|
|
}
|
|
return out;
|
|
}
|
|
|
|
std::ostream &operator<<(std::ostream &out, setbgcolor setbg) {
|
|
switch (setbg.color) {
|
|
case black:
|
|
out << "\033[7;30m";
|
|
break;
|
|
case red:
|
|
out << "\033[7;31m";
|
|
break;
|
|
case green:
|
|
out << "\033[7;32m";
|
|
break;
|
|
case blue:
|
|
out << "\033[7;34m";
|
|
break;
|
|
case magenta:
|
|
out << "\033[7;35m";
|
|
break;
|
|
case cyan:
|
|
out << "\033[7;36m";
|
|
break;
|
|
case lightGray:
|
|
out << "\033[7;37m";
|
|
break;
|
|
default:
|
|
// clang-format off
|
|
{;}
|
|
// clang-format on
|
|
}
|
|
return out;
|
|
}
|
|
|
|
setbgcolor::setbgcolor(ConsoleColors _color) : color(_color){};
|
|
|
|
std::ostream &resetOutputColor(std::ostream &out) {
|
|
out << setoutputcolor(clear);
|
|
return out;
|
|
} |