2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2019 linuxdaemon <linuxdaemon.irc@gmail.com>
5 * Copyright (C) 2013, 2019 Sadie Powell <sadie@witchery.services>
6 * Copyright (C) 2012 ChrisTX <xpipe@hotmail.de>
8 * This file is part of InspIRCd. InspIRCd is free software: you can
9 * redistribute it and/or modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation, version 2.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29 # define isatty(x) _isatty((x))
30 # define fileno(x) _fileno((x))
37 inline bool CanUseColors()
39 #ifdef INSPIRCD_DISABLE_COLORS
42 return isatty(fileno(stdout));
51 extern WORD g_wOriginalColors;
52 extern WORD g_wBackgroundColor;
53 extern HANDLE g_hStdout;
55 inline std::ostream& con_green(std::ostream& stream)
58 SetConsoleTextAttribute(g_hStdout, FOREGROUND_GREEN|FOREGROUND_INTENSITY|g_wBackgroundColor);
62 inline std::ostream& con_red(std::ostream& stream)
65 SetConsoleTextAttribute(g_hStdout, FOREGROUND_RED|FOREGROUND_INTENSITY|g_wBackgroundColor);
69 inline std::ostream& con_white(std::ostream& stream)
72 SetConsoleTextAttribute(g_hStdout, FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN|g_wBackgroundColor);
76 inline std::ostream& con_white_bright(std::ostream& stream)
79 SetConsoleTextAttribute(g_hStdout, FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_INTENSITY|g_wBackgroundColor);
83 inline std::ostream& con_bright(std::ostream& stream)
86 SetConsoleTextAttribute(g_hStdout, FOREGROUND_INTENSITY|g_wBackgroundColor);
90 inline std::ostream& con_reset(std::ostream& stream)
93 SetConsoleTextAttribute(g_hStdout, g_wOriginalColors);
99 inline std::ostream& con_green(std::ostream& stream)
103 return stream << "\033[1;32m";
106 inline std::ostream& con_red(std::ostream& stream)
110 return stream << "\033[1;31m";
113 inline std::ostream& con_white(std::ostream& stream)
117 return stream << "\033[0m";
120 inline std::ostream& con_white_bright(std::ostream& stream)
124 return stream << "\033[1m";
127 inline std::ostream& con_bright(std::ostream& stream)
131 return stream << "\033[1m";
134 inline std::ostream& con_reset(std::ostream& stream)
138 return stream << "\033[0m";