[PATCH 1/5] wineconsole: Add 'ColorTable' support to the registry

Hugh McMaster hugh.mcmaster at outlook.com
Sun Aug 7 22:08:29 CDT 2016


Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
 programs/wineconsole/registry.c        | 46 ++++++++++++++++++++++++++++++----
 programs/wineconsole/winecon_private.h |  1 +
 programs/wineconsole/wineconsole.c     |  1 +
 3 files changed, 43 insertions(+), 5 deletions(-)

diff --git a/programs/wineconsole/registry.c b/programs/wineconsole/registry.c
index c1d04c1..f898a85 100644
--- a/programs/wineconsole/registry.c
+++ b/programs/wineconsole/registry.c
@@ -26,10 +26,12 @@
 #include "winreg.h"
 #include "winecon_private.h"
 
+#include "wine/unicode.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(wineconsole);
 
+static const WCHAR wszColorTable[]        = {'C','o','l','o','r','T','a','b','l','e',0};
 static const WCHAR wszConsole[]           = {'C','o','n','s','o','l','e',0};
 static const WCHAR wszCursorSize[]        = {'C','u','r','s','o','r','S','i','z','e',0};
 static const WCHAR wszCursorVisible[]     = {'C','u','r','s','o','r','V','i','s','i','b','l','e',0};
@@ -77,6 +79,12 @@ static LPWSTR   WINECON_CreateKeyName(LPCWSTR kn)
     return ret;
 }
 
+/* ColorTable */
+static WCHAR color_name[13];
+static const WCHAR color_name_fmt[] = {'%','s','%','0','2','d',0};
+
+#define NUM_COLORS 16
+
 /******************************************************************
  *		WINECON_RegLoadHelper
  *
@@ -84,9 +92,16 @@ static LPWSTR   WINECON_CreateKeyName(LPCWSTR kn)
  */
 static void WINECON_RegLoadHelper(HKEY hConKey, struct config_data* cfg)
 {
-    DWORD 	type;
-    DWORD 	count;
-    DWORD       val;
+    int   i;
+    DWORD type, count, val;
+
+    for (i = 0; i < NUM_COLORS; i++)
+    {
+        sprintfW(color_name, color_name_fmt, wszColorTable, i);
+        count = sizeof(val);
+        if (!RegQueryValueExW(hConKey, color_name, 0, &type, (LPBYTE)&val, &count))
+            cfg->color_map[i] = val;
+    }
 
     count = sizeof(val);
     if (!RegQueryValueExW(hConKey, wszCursorSize, 0, &type, (LPBYTE)&val, &count))
@@ -166,11 +181,24 @@ static void WINECON_RegLoadHelper(HKEY hConKey, struct config_data* cfg)
  */
 void WINECON_RegLoad(const WCHAR* appname, struct config_data* cfg)
 {
-    HKEY        hConKey;
+    static const COLORREF color_map[NUM_COLORS] =
+    {
+        RGB(0x00, 0x00, 0x00), RGB(0x00, 0x00, 0x80), RGB(0x00, 0x80, 0x00), RGB(0x00, 0x80, 0x80),
+        RGB(0x80, 0x00, 0x00), RGB(0x80, 0x00, 0x80), RGB(0x80, 0x80, 0x00), RGB(0xC0, 0xC0, 0xC0),
+        RGB(0x80, 0x80, 0x80), RGB(0x00, 0x00, 0xFF), RGB(0x00, 0xFF, 0x00), RGB(0x00, 0xFF, 0xFF),
+        RGB(0xFF, 0x00, 0x00), RGB(0xFF, 0x00, 0xFF), RGB(0xFF, 0xFF, 0x00), RGB(0xFF, 0xFF, 0xFF),
+    };
+
+    int  i;
+    HKEY hConKey;
 
     WINE_TRACE("loading %s registry settings.\n", appname ? wine_dbgstr_w(appname) : "default");
 
     /* first set default values */
+    for (i = 0; i < NUM_COLORS; i++)
+    {
+        cfg->color_map[i] = color_map[i];
+    }
     cfg->cursor_size = 25;
     cfg->cursor_visible = 1;
     cfg->exit_on_die = 1;
@@ -221,10 +249,18 @@ void WINECON_RegLoad(const WCHAR* appname, struct config_data* cfg)
  */
 static void WINECON_RegSaveHelper(HKEY hConKey, const struct config_data* cfg)
 {
-    DWORD       val;
+    int   i;
+    DWORD val;
 
     WINECON_DumpConfig("save", cfg);
 
+    for (i = 0; i < NUM_COLORS; i++)
+    {
+        sprintfW(color_name, color_name_fmt, wszColorTable, i);
+        val = cfg->color_map[i];
+        RegSetValueExW(hConKey, color_name, 0, REG_DWORD, (LPBYTE)&val, sizeof(val));
+    }
+
     val = cfg->cursor_size;
     RegSetValueExW(hConKey, wszCursorSize, 0, REG_DWORD, (LPBYTE)&val, sizeof(val));
 
diff --git a/programs/wineconsole/winecon_private.h b/programs/wineconsole/winecon_private.h
index 5608f99..2ecaad0 100644
--- a/programs/wineconsole/winecon_private.h
+++ b/programs/wineconsole/winecon_private.h
@@ -27,6 +27,7 @@
 
 /* this is the configuration stored & loaded into the registry */
 struct config_data {
+    DWORD       color_map[16];  /* console ColorTable */
     unsigned	cell_width;	/* width in pixels of a character */
     unsigned	cell_height;	/* height in pixels of a character */
     int		cursor_size;	/* in % of cell height */
diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c
index f9027a4..e5e2823 100644
--- a/programs/wineconsole/wineconsole.c
+++ b/programs/wineconsole/wineconsole.c
@@ -703,6 +703,7 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna
         /* fall through */
     case init_success:
         WINECON_GetServerConfig(data);
+        memcpy(data->curcfg.color_map, cfg.color_map, sizeof(data->curcfg.color_map));
         data->cells = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
                                 data->curcfg.sb_width * data->curcfg.sb_height * sizeof(CHAR_INFO));
         if (!data->cells) WINECON_Fatal("OOM\n");
-- 
2.7.4




More information about the wine-patches mailing list