From d55581a1107de1e548b67d29a9ca0fcb7f1a0572 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 3 Mar 2021 01:52:27 +0000 Subject: Fix not being able to colour format output to stderr on Windows. --- win/inspircd_win32wrapper.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'win/inspircd_win32wrapper.cpp') diff --git a/win/inspircd_win32wrapper.cpp b/win/inspircd_win32wrapper.cpp index c6f5d8232..169741ba5 100644 --- a/win/inspircd_win32wrapper.cpp +++ b/win/inspircd_win32wrapper.cpp @@ -55,3 +55,16 @@ DWORD CWin32Exception::GetErrorCode() { return dwErrorCode; } + +WindowsStream::WindowsStream(DWORD handle) + : BackgroundColor(0) + , ForegroundColor(FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN) +{ + this->Handle = GetStdHandle(handle); + CONSOLE_SCREEN_BUFFER_INFO bufinf; + if (GetConsoleScreenBufferInfo(this->Handle, &bufinf)) + { + this->BackgroundColor = bufinf.wAttributes & 0x00F0; + this->ForegroundColor = bufinf.wAttributes & 0x00FF; + } +} -- cgit v1.2.3