[PATCH 3/5] server: Get and set the console ColorTable
Hugh McMaster
hugh.mcmaster at outlook.com
Sun Aug 7 22:08:51 CDT 2016
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
programs/wineconsole/wineconsole.c | 22 +++++++++++++++++++++-
server/console.c | 38 ++++++++++++++++++++++++++++++++++++++
server/protocol.def | 16 ++++++++++++++++
server/trace.c | 15 +++++++++++++++
4 files changed, 90 insertions(+), 1 deletion(-)
diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c
index e5e2823..b550403 100644
--- a/programs/wineconsole/wineconsole.c
+++ b/programs/wineconsole/wineconsole.c
@@ -212,6 +212,26 @@ static BOOL WINECON_SetEditionMode(HANDLE hConIn, int edition_mode)
}
/******************************************************************
+ * WINECON_SetColorTable
+ *
+ *
+ */
+static void WINECON_SetColorTable(struct inner_data *data, const DWORD *color_map)
+{
+ size_t data_size = sizeof(data->curcfg.color_map);
+
+ memcpy(data->curcfg.color_map, color_map, data_size);
+
+ SERVER_START_REQ( set_console_colortable )
+ {
+ req->handle = wine_server_obj_handle( data->hConOut );
+ wine_server_add_data( req, color_map, data_size );
+ wine_server_call( req );
+ }
+ SERVER_END_REQ;
+}
+
+/******************************************************************
* WINECON_GrabChanges
*
* A change occurs, try to figure out which
@@ -703,7 +723,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));
+ WINECON_SetColorTable(data, cfg.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..413db75 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]; /* console ColorTable */
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)
@@ -1694,6 +1696,42 @@ DECL_HANDLER(get_console_output_info)
}
}
+/* Fill the console ColorTable */
+DECL_HANDLER(set_console_colortable)
+{
+ struct screen_buffer *screen_buffer;
+
+ if ((screen_buffer = (struct screen_buffer *)get_handle_obj(current->process, req->handle,
+ FILE_READ_PROPERTIES, &screen_buffer_ops)))
+ {
+ data_size_t req_size = get_req_data_size();
+ data_size_t color_map_size = sizeof(screen_buffer->color_map);
+
+ if (req_size > color_map_size)
+ req_size = color_map_size;
+ memcpy(screen_buffer->color_map, get_req_data(), req_size);
+ release_object( screen_buffer );
+ }
+}
+
+/* Fetch the console ColorTable */
+DECL_HANDLER(get_console_colortable)
+{
+ struct screen_buffer *screen_buffer;
+
+ if ((screen_buffer = (struct screen_buffer *)get_handle_obj(current->process, req->handle,
+ FILE_READ_PROPERTIES, &screen_buffer_ops)))
+ {
+ data_size_t color_map_size = sizeof(screen_buffer->color_map);
+ data_size_t reply_max_size = get_reply_max_size();
+
+ if (color_map_size > reply_max_size)
+ color_map_size = reply_max_size;
+ set_reply_data( screen_buffer->color_map, color_map_size );
+ release_object( screen_buffer );
+ }
+}
+
/* read data (chars & attrs) from a screen buffer */
DECL_HANDLER(read_console_output)
{
diff --git a/server/protocol.def b/server/protocol.def
index 5917212..3a96a92 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -1568,6 +1568,22 @@ struct console_renderer_event
short int font_height;
@END
+
+/* Fill the console ColorTable */
+ at REQ(set_console_colortable)
+ obj_handle_t handle; /* handle to the console */
+ VARARG(color,unsigned_int); /* ColorTable */
+ at END
+
+
+/* Fetch the console ColorTable */
+ at REQ(get_console_colortable)
+ obj_handle_t handle; /* handle to the console */
+ at REPLY
+ VARARG(color,unsigned_int); /* ColorTable */
+ at END
+
+
/* Add input records to a console input queue */
@REQ(write_console_input)
obj_handle_t handle; /* handle to the console input */
diff --git a/server/trace.c b/server/trace.c
index 9e64b4c..936d89c 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -817,6 +817,21 @@ static void dump_varargs_startup_info( const char *prefix, data_size_t size )
remove_data( size );
}
+static void dump_varargs_unsigned_int( const char *prefix, data_size_t size )
+{
+ const unsigned int *data = cur_data;
+ data_size_t len = size / sizeof(*data);
+
+ fprintf( stderr,"%s{", prefix );
+ while (len > 0)
+ {
+ fprintf( stderr, "%08x", *data++ );
+ if (--len) fputc( ',', stderr );
+ }
+ fputc( '}', stderr );
+ remove_data( size );
+}
+
static void dump_varargs_input_records( const char *prefix, data_size_t size )
{
const INPUT_RECORD *rec = cur_data;
--
2.7.4
More information about the wine-patches
mailing list