Module: wine Branch: master Commit: 1602eff3b8c5f4d3550ee8628d48ff6632c7e343 URL: http://source.winehq.org/git/wine.git/?a=commit;h=1602eff3b8c5f4d3550ee8628d...
Author: Hugh McMaster hugh.mcmaster@outlook.com Date: Mon Aug 8 03:08:29 2016 +0000
wineconsole: Add 'ColorTable' support to the registry.
Signed-off-by: Hugh McMaster hugh.mcmaster@outlook.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
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..f5fa433 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}; @@ -47,6 +49,10 @@ static const WCHAR wszScreenBufferSize[] = {'S','c','r','e','e','n','B','u','f' static const WCHAR wszScreenColors[] = {'S','c','r','e','e','n','C','o','l','o','r','s',0}; static const WCHAR wszWindowSize[] = {'W','i','n','d','o','w','S','i','z','e',0};
+static const WCHAR color_name_fmt[] = {'%','s','%','0','2','d',0}; + +#define NUM_COLORS 16 + void WINECON_DumpConfig(const char* pfx, const struct config_data* cfg) { WINE_TRACE("%s cell=(%u,%u) cursor=(%d,%d) attr=%02x font=%s/%u hist=%u/%d flags=%c%c%c msk=%08x sb=(%u,%u) win=(%u,%u)x(%u,%u) edit=%u registry=%s\n", @@ -84,9 +90,17 @@ 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; + WCHAR color_name[13]; + + 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 +180,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 +248,19 @@ 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; + WCHAR color_name[13];
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..7236879 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 color table */ 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");