Hugh McMaster : server: Get and set the console color table.
Alexandre Julliard
julliard at winehq.org
Thu Aug 11 09:37:48 CDT 2016
Module: wine
Branch: master
Commit: 2d7c73d802f7a8c09cf8896609c1c8c66acb1bb5
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2d7c73d802f7a8c09cf8896609c1c8c66acb1bb5
Author: Hugh McMaster <hugh.mcmaster at outlook.com>
Date: Wed Aug 10 10:01:34 2016 +0000
server: Get and set the console color table.
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
include/wine/server_protocol.h | 5 ++++-
programs/wineconsole/wineconsole.c | 23 ++++++++++++++++++++++-
server/console.c | 9 +++++++++
server/protocol.def | 3 +++
server/trace.c | 20 ++++++++++++++------
5 files changed, 52 insertions(+), 8 deletions(-)
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index b221570..5a6e277 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -1947,6 +1947,7 @@ struct set_console_output_info_request
short int max_height;
short int font_width;
short int font_height;
+ /* VARARG(colors,uints); */
char __pad_50[6];
};
struct set_console_output_info_reply
@@ -1960,6 +1961,7 @@ struct set_console_output_info_reply
#define SET_CONSOLE_OUTPUT_INFO_DISPLAY_WINDOW 0x10
#define SET_CONSOLE_OUTPUT_INFO_MAX_SIZE 0x20
#define SET_CONSOLE_OUTPUT_INFO_FONT 0x40
+#define SET_CONSOLE_OUTPUT_INFO_COLORTABLE 0x80
@@ -1986,6 +1988,7 @@ struct get_console_output_info_reply
short int max_height;
short int font_width;
short int font_height;
+ /* VARARG(colors,uints); */
char __pad_38[2];
};
@@ -6245,6 +6248,6 @@ union generic_reply
struct terminate_job_reply terminate_job_reply;
};
-#define SERVER_PROTOCOL_VERSION 507
+#define SERVER_PROTOCOL_VERSION 508
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c
index e5e2823..b9da7b6 100644
--- a/programs/wineconsole/wineconsole.c
+++ b/programs/wineconsole/wineconsole.c
@@ -212,6 +212,27 @@ static BOOL WINECON_SetEditionMode(HANDLE hConIn, int edition_mode)
}
/******************************************************************
+ * WINECON_SetColors
+ *
+ *
+ */
+static void WINECON_SetColors(struct inner_data *data, const struct config_data* cfg)
+{
+ size_t color_map_size = sizeof(data->curcfg.color_map);
+
+ memcpy(data->curcfg.color_map, cfg->color_map, color_map_size);
+
+ SERVER_START_REQ( set_console_output_info )
+ {
+ req->handle = wine_server_obj_handle( data->hConOut );
+ req->mask = SET_CONSOLE_OUTPUT_INFO_COLORTABLE;
+ wine_server_add_data( req, cfg->color_map, color_map_size );
+ wine_server_call( req );
+ }
+ SERVER_END_REQ;
+}
+
+/******************************************************************
* WINECON_GrabChanges
*
* A change occurs, try to figure out which
@@ -449,6 +470,7 @@ void WINECON_SetConfig(struct inner_data* data, const struct config_data* cf
FillConsoleOutputAttribute(data->hConOut, cfg->def_attr, screen_size, top_left, &written);
SetConsoleTextAttribute(data->hConOut, cfg->def_attr);
}
+ WINECON_SetColors(data, cfg);
/* now let's look at the window / sb size changes...
* since the server checks that sb is always bigger than window,
* we have to take care of doing the operations in the right order
@@ -703,7 +725,6 @@ 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");
diff --git a/server/console.c b/server/console.c
index 93f785a..ab764dc 100644
--- a/server/console.c
+++ b/server/console.c
@@ -147,6 +147,7 @@ struct screen_buffer
int max_height;
char_info_t *data; /* the data for each cell - a width x height matrix */
unsigned short attr; /* default attribute for screen buffer */
+ unsigned int color_map[16]; /* color table */
rectangle_t win; /* current visible window on the screen buffer *
* as seen in wineconsole */
struct font_info font; /* console font information */
@@ -426,6 +427,7 @@ static struct screen_buffer *create_console_output( struct console_input *consol
screen_buffer->data = NULL;
screen_buffer->font.width = 0;
screen_buffer->font.height = 0;
+ memset( screen_buffer->color_map, 0, sizeof(screen_buffer->color_map) );
list_add_head( &screen_buffer_list, &screen_buffer->entry );
if (fd == -1)
@@ -1032,6 +1034,11 @@ static int set_console_output_info( struct screen_buffer *screen_buffer,
screen_buffer->font.width = req->font_width;
screen_buffer->font.height = req->font_height;
}
+ if (req->mask & SET_CONSOLE_OUTPUT_INFO_COLORTABLE)
+ {
+ memcpy( screen_buffer->color_map, get_req_data(),
+ min( sizeof(screen_buffer->color_map), get_req_data_size() ));
+ }
return 1;
}
@@ -1690,6 +1697,8 @@ DECL_HANDLER(get_console_output_info)
reply->max_height = screen_buffer->max_height;
reply->font_width = screen_buffer->font.width;
reply->font_height = screen_buffer->font.height;
+ set_reply_data( screen_buffer->color_map,
+ min( sizeof(screen_buffer->color_map), get_reply_max_size() ));
release_object( screen_buffer );
}
}
diff --git a/server/protocol.def b/server/protocol.def
index 5917212..c11b679 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -1537,6 +1537,7 @@ struct console_renderer_event
short int max_height;
short int font_width; /* font size (width x height) */
short int font_height;
+ VARARG(colors,uints); /* color table */
@END
#define SET_CONSOLE_OUTPUT_INFO_CURSOR_GEOM 0x01
#define SET_CONSOLE_OUTPUT_INFO_CURSOR_POS 0x02
@@ -1545,6 +1546,7 @@ struct console_renderer_event
#define SET_CONSOLE_OUTPUT_INFO_DISPLAY_WINDOW 0x10
#define SET_CONSOLE_OUTPUT_INFO_MAX_SIZE 0x20
#define SET_CONSOLE_OUTPUT_INFO_FONT 0x40
+#define SET_CONSOLE_OUTPUT_INFO_COLORTABLE 0x80
/* Get info about a console (output only) */
@@ -1566,6 +1568,7 @@ struct console_renderer_event
short int max_height;
short int font_width; /* font size (width x height) */
short int font_height;
+ VARARG(colors,uints); /* color table */
@END
/* Add input records to a console input queue */
diff --git a/server/trace.c b/server/trace.c
index 9e64b4c..d17564f 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -58,9 +58,9 @@ static inline void remove_data( data_size_t size )
cur_size -= size;
}
-static void dump_uints( const int *ptr, int len )
+static void dump_uints( const char *prefix, const unsigned int *ptr, int len )
{
- fputc( '{', stderr );
+ fprintf( stderr, "%s{", prefix );
while (len > 0)
{
fprintf( stderr, "%08x", *ptr++ );
@@ -407,6 +407,14 @@ static void dump_varargs_ints( const char *prefix, data_size_t size )
remove_data( size );
}
+static void dump_varargs_uints( const char *prefix, data_size_t size )
+{
+ const unsigned int *data = cur_data;
+
+ dump_uints( prefix, data, size / sizeof(*data) );
+ remove_data( size );
+}
+
static void dump_varargs_uints64( const char *prefix, data_size_t size )
{
const unsigned __int64 *data = cur_data;
@@ -574,10 +582,8 @@ static void dump_varargs_context( const char *prefix, data_size_t size )
}
}
if (ctx.flags & SERVER_CTX_EXTENDED_REGISTERS)
- {
- fprintf( stderr, ",extended=" );
- dump_uints( (const int *)ctx.ext.i386_regs, sizeof(ctx.ext.i386_regs) / sizeof(int) );
- }
+ dump_uints( ",extended=", (const unsigned int *)ctx.ext.i386_regs,
+ sizeof(ctx.ext.i386_regs) / sizeof(int) );
break;
case CPU_x86_64:
if (ctx.flags & SERVER_CTX_CONTROL)
@@ -2035,6 +2041,7 @@ static void dump_set_console_output_info_request( const struct set_console_outpu
fprintf( stderr, ", max_height=%d", req->max_height );
fprintf( stderr, ", font_width=%d", req->font_width );
fprintf( stderr, ", font_height=%d", req->font_height );
+ dump_varargs_uints( ", colors=", cur_size );
}
static void dump_get_console_output_info_request( const struct get_console_output_info_request *req )
@@ -2059,6 +2066,7 @@ static void dump_get_console_output_info_reply( const struct get_console_output_
fprintf( stderr, ", max_height=%d", req->max_height );
fprintf( stderr, ", font_width=%d", req->font_width );
fprintf( stderr, ", font_height=%d", req->font_height );
+ dump_varargs_uints( ", colors=", cur_size );
}
static void dump_write_console_input_request( const struct write_console_input_request *req )
More information about the wine-cvs
mailing list