]> git.cworth.org Git - apitrace/blobdiff - common/formatter.hpp
Highlight NULL as a literal.
[apitrace] / common / formatter.hpp
index 5e2143e884b5801b9d48a79c091ee652a462777b..43b816eb1ef1fb453817bd850ac5f6aad6e56191 100644 (file)
@@ -88,7 +88,10 @@ protected:
 public:
     virtual Attribute *normal(void) const { return new AnsiAttribute("0m"); }
     virtual Attribute *bold(void) const { return new AnsiAttribute("1m"); }
+    /* Italic is not widely supported, or worse, implemented with a reverse */
+#if 0
     virtual Attribute *italic(void) const { return new AnsiAttribute("3m"); }
+#endif
     virtual Attribute *strike(void) const { return new AnsiAttribute("9m"); }
     virtual Attribute *color(Color c) const { 
         static const char *color_escapes[] = {
@@ -114,31 +117,31 @@ inline std::ostream& operator<<(std::ostream& os, const Attribute *attr) {
 
 
 #ifndef COMMON_LVB_LEADING_BYTE
-##define COMMON_LVB_LEADING_BYTE    0x0100
+#define COMMON_LVB_LEADING_BYTE    0x0100
 #endif
 
 #ifndef COMMON_LVB_TRAILING_BYTE
-##define COMMON_LVB_TRAILING_BYTE   0x0200
+#define COMMON_LVB_TRAILING_BYTE   0x0200
 #endif
 
 #ifndef COMMON_LVB_GRID_HORIZONTAL
-##define COMMON_LVB_GRID_HORIZONTAL 0x0400
+#define COMMON_LVB_GRID_HORIZONTAL 0x0400
 #endif
 
 #ifndef COMMON_LVB_GRID_LVERTICAL
-##define COMMON_LVB_GRID_LVERTICAL  0x0800
+#define COMMON_LVB_GRID_LVERTICAL  0x0800
 #endif
 
 #ifndef COMMON_LVB_GRID_RVERTICAL
-##define COMMON_LVB_GRID_RVERTICAL  0x1000
+#define COMMON_LVB_GRID_RVERTICAL  0x1000
 #endif
 
 #ifndef COMMON_LVB_REVERSE_VIDEO
-##define COMMON_LVB_REVERSE_VIDEO   0x4000
+#define COMMON_LVB_REVERSE_VIDEO   0x4000
 #endif
 
 #ifndef COMMON_LVB_UNDERSCORE
-##define COMMON_LVB_UNDERSCORE      0x8000
+#define COMMON_LVB_UNDERSCORE      0x8000
 #endif
 
 
@@ -192,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;