-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconsole.cpp
102 lines (85 loc) · 1.74 KB
/
console.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include "console.h"
void Console::info(const char* message)
{
println(message, ConsoleColor::green);
reset();
}
void Console::error(const char* message)
{
println(message, ConsoleColor::red);
reset();
}
void Console::debug(const char* message)
{
#ifdef DEBUG
println(message, ConsoleColor::yellow);
reset();
#endif
}
void Console::print(const char* message)
{
print(message, ConsoleColor::normal);
}
void Console::print(const char* message, color_t color)
{
std::cout << color << message;
reset();
}
void Console::println(const char* message)
{
println(message, ConsoleColor::normal);
}
void Console::println(const char* message, color_t color)
{
std::cout << color << message << std::endl;
reset();
}
void Console::reset()
{
std::cout << ConsoleColor::normal;
}
std::ostream& ConsoleColor::normal(std::ostream& stream)
{
stream << "\033[00m";
return stream;
}
std::ostream& ConsoleColor::grey(std::ostream& stream)
{
stream << "\033[30m";
return stream;
}
std::ostream& ConsoleColor::red(std::ostream& stream)
{
stream << "\033[31m";
return stream;
}
std::ostream& ConsoleColor::green(std::ostream& stream)
{
stream << "\033[32m";
return stream;
}
std::ostream& ConsoleColor::yellow(std::ostream& stream)
{
stream << "\033[33m";
return stream;
}
std::ostream& ConsoleColor::blue(std::ostream& stream)
{
stream << "\033[34m";
return stream;
}
std::ostream& ConsoleColor::magenta(std::ostream& stream)
{
stream << "\033[35m";
return stream;
}
std::ostream& ConsoleColor::cyan(std::ostream& stream)
{
stream << "\033[36m";
return stream;
}
std::ostream& ConsoleColor::white(std::ostream& stream)
{
stream << "\037[37m";
return stream;
}