4 * Created on: Oct 18, 2009
16 * Set the console color.
18 void setConsoleColor(int color) {
19 cout << (char)0x1B << "[" << 0 << ";" << color + 30 << ";" << 0 + 40 << "m";
23 * Set the console color.
25 void appendConsoleColor(string& s, int color) {
26 s.push_back((char)0x1B);
35 * Print color character in the appropriate color to the console.
36 * Console must support color.
38 void printColor(char color) {
44 setConsoleColor(COLOR_BLUE);
49 setConsoleColor(COLOR_GREEN);
54 setConsoleColor(COLOR_YELLOW);
59 setConsoleColor(COLOR_RED);
65 setConsoleColor(COLOR_WHITE);
68 setConsoleColor(COLOR_WHITE);
72 setConsoleColor(COLOR_WHITE);
76 * Print color character in the appropriate color to the console.
77 * Console must support color.
79 void appendColor(string& s, char color) {
85 appendConsoleColor(s, COLOR_BLUE);
90 appendConsoleColor(s, COLOR_GREEN);
95 appendConsoleColor(s, COLOR_YELLOW);
100 appendConsoleColor(s, COLOR_RED);
106 appendConsoleColor(s, COLOR_WHITE);
109 appendConsoleColor(s, COLOR_WHITE);
113 appendConsoleColor(s, COLOR_WHITE);