2 * InspIRCd -- Internet Relay Chat Daemon
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.
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
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/>.
25 # define isatty(x) _isatty((x))
26 # define fileno(x) _fileno((x))
33 inline bool CanUseColors()
35 #ifdef INSPIRCD_DISABLE_COLORS
38 return isatty(fileno(stdout));
47 extern WORD g_wOriginalColors;
48 extern WORD g_wBackgroundColor;
49 extern HANDLE g_hStdout;
51 inline std::ostream& con_green(std::ostream& stream)
54 SetConsoleTextAttribute(g_hStdout, FOREGROUND_GREEN|FOREGROUND_INTENSITY|g_wBackgroundColor);
58 inline std::ostream& con_red(std::ostream& stream)
61 SetConsoleTextAttribute(g_hStdout, FOREGROUND_RED|FOREGROUND_INTENSITY|g_wBackgroundColor);
65 inline std::ostream& con_white(std::ostream& stream)
68 SetConsoleTextAttribute(g_hStdout, FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN|g_wBackgroundColor);
72 inline std::ostream& con_white_bright(std::ostream& stream)
75 SetConsoleTextAttribute(g_hStdout, FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_INTENSITY|g_wBackgroundColor);
79 inline std::ostream& con_bright(std::ostream& stream)
82 SetConsoleTextAttribute(g_hStdout, FOREGROUND_INTENSITY|g_wBackgroundColor);
86 inline std::ostream& con_reset(std::ostream& stream)
89 SetConsoleTextAttribute(g_hStdout, g_wOriginalColors);
95 inline std::ostream& con_green(std::ostream& stream)
99 return stream << "\033[1;32m";
102 inline std::ostream& con_red(std::ostream& stream)
106 return stream << "\033[1;31m";
109 inline std::ostream& con_white(std::ostream& stream)
113 return stream << "\033[0m";
116 inline std::ostream& con_white_bright(std::ostream& stream)
120 return stream << "\033[1m";
123 inline std::ostream& con_bright(std::ostream& stream)
127 return stream << "\033[1m";
130 inline std::ostream& con_reset(std::ostream& stream)
134 return stream << "\033[0m";