summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChrisTX <chris@rev-crew.info>2012-10-14 02:13:49 +0200
committerChrisTX <chris@rev-crew.info>2012-10-14 02:13:49 +0200
commitebdaf368e137fc933e648ee88a08a4f83e796f87 (patch)
tree72c7969e860704c99fc2fbe8537a248fa71f9e7e /include
parent272208502c426f5bb6abdb13b8986b686afbb904 (diff)
Replace printf(_c) with iostream
Diffstat (limited to 'include')
-rw-r--r--include/consolecolors.h100
-rw-r--r--include/inspircd.h2
2 files changed, 101 insertions, 1 deletions
diff --git a/include/consolecolors.h b/include/consolecolors.h
new file mode 100644
index 000000000..953beb346
--- /dev/null
+++ b/include/consolecolors.h
@@ -0,0 +1,100 @@
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ * This file is part of InspIRCd. InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef CONSOLECOLORS_H
+#define CONSOLECOLORS_H
+
+#include <ostream>
+
+#ifdef _WIN32
+
+#include <windows.h>
+
+extern WORD g_wOriginalColors;
+extern WORD g_wBackgroundColor;
+extern HANDLE g_hStdout;
+
+inline std::ostream& con_green(std::ostream &s)
+{
+ SetConsoleTextAttribute(g_hStdout, FOREGROUND_GREEN|FOREGROUND_INTENSITY|g_wBackgroundColor);
+ return s;
+}
+
+inline std::ostream& con_red(std::ostream &s)
+{
+ SetConsoleTextAttribute(g_hStdout, FOREGROUND_RED|FOREGROUND_INTENSITY|g_wBackgroundColor);
+ return s;
+}
+
+inline std::ostream& con_white(std::ostream &s)
+{
+ SetConsoleTextAttribute(g_hStdout, FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN|g_wBackgroundColor);
+ return s;
+}
+
+inline std::ostream& con_white_bright(std::ostream &s)
+{
+ SetConsoleTextAttribute(g_hStdout, FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_GREEN|FOREGROUND_INTENSITY|g_wBackgroundColor);
+ return s;
+}
+
+inline std::ostream& con_bright(std::ostream &s)
+{
+ SetConsoleTextAttribute(g_hStdout, FOREGROUND_INTENSITY|g_wBackgroundColor);
+ return s;
+}
+
+inline std::ostream& con_reset(std::ostream &s)
+{
+ SetConsoleTextAttribute(g_hStdout, g_wOriginalColors);
+ return s;
+}
+
+#else
+
+inline std::ostream& con_green(std::ostream &s)
+{
+ return s << "\033[1;32m";
+}
+
+inline std::ostream& con_red(std::ostream &s)
+{
+ return s << "\033[1;31m";
+}
+
+inline std::ostream& con_white(std::ostream &s)
+{
+ return s << "\033[0m";
+}
+
+inline std::ostream& con_white_bright(std::ostream &s)
+{
+ return s << "\033[1m";
+}
+
+inline std::ostream& con_bright(std::ostream &s)
+{
+ return s << "\033[1m";
+}
+
+inline std::ostream& con_reset(std::ostream &s)
+{
+ return s << "\033[0m";
+}
+
+#endif
+
+#endif \ No newline at end of file
diff --git a/include/inspircd.h b/include/inspircd.h
index cc627ca57..69c8bf47f 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -34,7 +34,6 @@
#ifndef _WIN32
#define DllExport
#define CoreExport
-#define printf_c printf
#else
#include "inspircd_win32wrapper.h"
/** Windows defines these already */
@@ -71,6 +70,7 @@
#include "inspircd_config.h"
#include "inspircd_version.h"
#include "typedefs.h"
+#include "consolecolors.h"
CoreExport extern InspIRCd* ServerInstance;