]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/consolecolors.h
Switch <stdint.h> test to use a test file too.
[user/henk/code/inspircd.git] / include / consolecolors.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  * This file is part of InspIRCd.  InspIRCd is free software: you can
5  * redistribute it and/or modify it under the terms of the GNU General Public
6  * License as published by the Free Software Foundation, version 2.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
11  * details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15  */
16
17 #ifndef CONSOLECOLORS_H
18 #define CONSOLECOLORS_H
19
20 #include <ostream>
21
22 #ifdef _WIN32
23
24 #include <windows.h>
25
26 extern WORD g_wOriginalColors;
27 extern WORD g_wBackgroundColor;
28 extern HANDLE g_hStdout;
29
30 inline std::ostream& con_green(std::ostream &s)
31 {
32     SetConsoleTextAttribute(g_hStdout, FOREGROUND_GREEN|FOREGROUND_INTENSITY|g_wBackgroundColor);
33     return s;
34 }
35
36 inline std::ostream& con_red(std::ostream &s)
37 {
38     SetConsoleTextAttribute(g_hStdout, FOREGROUND_RED|FOREGROUND_INTENSITY|g_wBackgroundColor);
39     return s;
40 }
41
42 inline std::ostream& con_white(std::ostream &s)
43 {
44     SetConsoleTextAttribute(g_hStdout, FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN|g_wBackgroundColor);
45     return s;
46 }
47
48 inline std::ostream& con_white_bright(std::ostream &s)
49 {
50     SetConsoleTextAttribute(g_hStdout, FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_INTENSITY|g_wBackgroundColor);
51     return s;
52 }
53
54 inline std::ostream& con_bright(std::ostream &s)
55 {
56     SetConsoleTextAttribute(g_hStdout, FOREGROUND_INTENSITY|g_wBackgroundColor);
57     return s;
58 }
59
60 inline std::ostream& con_reset(std::ostream &s)
61 {
62     SetConsoleTextAttribute(g_hStdout, g_wOriginalColors);
63     return s;
64 }
65
66 #else
67
68 inline std::ostream& con_green(std::ostream &s)
69 {
70     return s << "\033[1;32m";
71 }
72
73 inline std::ostream& con_red(std::ostream &s)
74 {
75     return s << "\033[1;31m";
76 }
77
78 inline std::ostream& con_white(std::ostream &s)
79 {
80     return s << "\033[0m";
81 }
82
83 inline std::ostream& con_white_bright(std::ostream &s)
84 {
85     return s << "\033[1m";
86 }
87
88 inline std::ostream& con_bright(std::ostream &s)
89 {
90     return s << "\033[1m";
91 }
92
93 inline std::ostream& con_reset(std::ostream &s)
94 {
95     return s << "\033[0m";
96 }
97
98 #endif
99
100 #endif