-
Notifications
You must be signed in to change notification settings - Fork 0
/
console.h
executable file
·65 lines (57 loc) · 1.44 KB
/
console.h
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
#ifndef _CONSOLE_COLOR_H_
#define _CONSOLE_COLOR_H_
#include <iostream>
#if defined(WIN32)
#include <windows.h>
#endif
inline std::ostream& blue(std::ostream &s)
{
#if defined(WIN32)
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hStdout, FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_INTENSITY);
#else
s << "\e[0;34m";
#endif
return s;
}
inline std::ostream& red(std::ostream &s)
{
#if defined(WIN32)
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hStdout, FOREGROUND_RED|FOREGROUND_INTENSITY);
#else
s << "\e[0;31m";
#endif
return s;
}
inline std::ostream& green(std::ostream &s)
{
#if defined(WIN32)
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hStdout, FOREGROUND_GREEN|FOREGROUND_INTENSITY);
#else
s << "\e[0;32m";
#endif
return s;
}
inline std::ostream& yellow(std::ostream &s)
{
#if defined(WIN32)
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hStdout, FOREGROUND_GREEN|FOREGROUND_RED|FOREGROUND_INTENSITY);
#else
s << "\e[0;33m";
#endif
return s;
}
inline std::ostream& white(std::ostream &s)
{
#if defined(WIN32)
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hStdout, FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
#else
s << "\e[0;37m";
#endif
return s;
}
#endif