From 27f21c0223f9d7a8e0bfc592513013c099cc2f04 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Sat, 7 Apr 2012 10:13:37 +0100 Subject: [PATCH] Use ANSI escape codes when inside WINE. --- common/formatter.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/common/formatter.hpp b/common/formatter.hpp index 10661e3..43b816e 100644 --- a/common/formatter.hpp +++ b/common/formatter.hpp @@ -195,6 +195,18 @@ public: inline Formatter *defaultFormatter(bool color = true) { if (color) { #ifdef _WIN32 + // http://wiki.winehq.org/DeveloperFaq#detect-wine + static HMODULE hNtDll = NULL; + static bool bWine = false; + if (!hNtDll) { + hNtDll = LoadLibraryA("ntdll"); + if (hNtDll) { + bWine = GetProcAddress(hNtDll, "wine_get_version") != NULL; + } + } + if (bWine) { + return new AnsiFormatter; + } return new WindowsFormatter; #else return new AnsiFormatter; -- 2.43.0