Commit 1602eff3 authored by Hugh McMaster's avatar Hugh McMaster Committed by Alexandre Julliard

wineconsole: Add 'ColorTable' support to the registry.

parent 84b3218e
......@@ -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));
......
......@@ -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 */
......
......@@ -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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment