From dcd02876ea73f65dc286038f0f70189c4994152f Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 20 Jul 2020 15:38:00 +0200 Subject: [PATCH] server: Introduce IOCTL_CONDRV_SET_INPUT_INFO ioctl. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- include/wine/condrv.h | 11 ++++++++ server/console.c | 62 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/include/wine/condrv.h b/include/wine/condrv.h index fedf3f308ce..f6888443c97 100644 --- a/include/wine/condrv.h +++ b/include/wine/condrv.h @@ -32,6 +32,7 @@ #define IOCTL_CONDRV_WRITE_INPUT CTL_CODE(FILE_DEVICE_CONSOLE, 11, METHOD_BUFFERED, FILE_WRITE_PROPERTIES) #define IOCTL_CONDRV_PEEK CTL_CODE(FILE_DEVICE_CONSOLE, 12, METHOD_BUFFERED, FILE_READ_ACCESS) #define IOCTL_CONDRV_GET_INPUT_INFO CTL_CODE(FILE_DEVICE_CONSOLE, 13, METHOD_BUFFERED, FILE_READ_PROPERTIES) +#define IOCTL_CONDRV_SET_INPUT_INFO CTL_CODE(FILE_DEVICE_CONSOLE, 14, METHOD_BUFFERED, FILE_WRITE_PROPERTIES) #define IOCTL_CONDRV_GET_TITLE CTL_CODE(FILE_DEVICE_CONSOLE, 15, METHOD_BUFFERED, FILE_READ_PROPERTIES) /* console output ioctls */ @@ -64,10 +65,20 @@ typedef struct /* IOCTL_CONDRV_GET_INPUT_INFO result */ struct condrv_input_info { + unsigned int input_cp; /* console input codepage */ + unsigned int output_cp; /* console output codepage */ unsigned int history_mode; /* whether we duplicate lines in history */ unsigned int history_size; /* number of lines in history */ unsigned int edition_mode; /* index to the edition mode flavors */ unsigned int input_count; /* number of available input records */ + condrv_handle_t win; /* renderer window handle */ +}; + +/* IOCTL_CONDRV_SET_INPUT_INFO params */ +struct condrv_input_info_params +{ + unsigned int mask; /* setting mask */ + struct condrv_input_info info; /* input_info */ }; /* IOCTL_CONDRV_GET_OUTPUT_INFO result */ diff --git a/server/console.c b/server/console.c index 3c562cb5075..a348ed5bca9 100644 --- a/server/console.c +++ b/server/console.c @@ -1577,13 +1577,75 @@ static int console_input_ioctl( struct fd *fd, ioctl_code_t code, struct async * set_error( STATUS_INVALID_PARAMETER ); return 0; } + info.input_cp = console->input_cp; + info.output_cp = console->output_cp; info.history_mode = console->history_mode; info.history_size = console->history_size; info.edition_mode = console->edition_mode; info.input_count = console->recnum; + info.win = console->win; return set_reply_data( &info, sizeof(info) ) != NULL; } + case IOCTL_CONDRV_SET_INPUT_INFO: + { + const struct condrv_input_info_params *params = get_req_data(); + if (get_req_data_size() != sizeof(*params)) + { + set_error( STATUS_INVALID_PARAMETER ); + return 0; + } + if (params->mask & SET_CONSOLE_INPUT_INFO_HISTORY_MODE) + { + console->history_mode = params->info.history_mode; + } + if ((params->mask & SET_CONSOLE_INPUT_INFO_HISTORY_SIZE) && + console->history_size != params->info.history_size) + { + struct history_line **mem = NULL; + int i, delta; + + if (params->info.history_size) + { + if (!(mem = mem_alloc( params->info.history_size * sizeof(*mem) ))) return 0; + memset( mem, 0, params->info.history_size * sizeof(*mem) ); + } + + delta = (console->history_index > params->info.history_size) ? + (console->history_index - params->info.history_size) : 0; + + for (i = delta; i < console->history_index; i++) + { + mem[i - delta] = console->history[i]; + console->history[i] = NULL; + } + console->history_index -= delta; + + for (i = 0; i < console->history_size; i++) + free( console->history[i] ); + free( console->history ); + console->history = mem; + console->history_size = params->info.history_size; + } + if (params->mask & SET_CONSOLE_INPUT_INFO_EDITION_MODE) + { + console->edition_mode = params->info.edition_mode; + } + if (params->mask & SET_CONSOLE_INPUT_INFO_INPUT_CODEPAGE) + { + console->input_cp = params->info.input_cp; + } + if (params->mask & SET_CONSOLE_INPUT_INFO_OUTPUT_CODEPAGE) + { + console->output_cp = params->info.output_cp; + } + if (params->mask & SET_CONSOLE_INPUT_INFO_WIN) + { + console->win = params->info.win; + } + return 1; + } + case IOCTL_CONDRV_GET_TITLE: if (!console->title_len) return 1; return set_reply_data( console->title, min( console->title_len, get_reply_max_size() )) != NULL;