阶段性的成果。
This commit is contained in:
42
大作业/Tools.cpp
Normal file
42
大作业/Tools.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "Tools.hpp"
|
||||
setoutputcolor::setoutputcolor() : color(clear), bold(false) {};
|
||||
|
||||
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 red:
|
||||
out << ";31m";
|
||||
break;
|
||||
case green:
|
||||
out << ";32m";
|
||||
break;
|
||||
case blue:
|
||||
out << ";34m";
|
||||
break;
|
||||
default:
|
||||
out << ";0m";
|
||||
break;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream &resetOutputColor(std::ostream &out) {
|
||||
out << setoutputcolor();
|
||||
return out;
|
||||
}
|
||||
Reference in New Issue
Block a user