diff --git a/dlls/kernel/console.c b/dlls/kernel/console.c index 3725e748849..a611d28bec4 100644 --- a/dlls/kernel/console.c +++ b/dlls/kernel/console.c @@ -1053,7 +1053,7 @@ BOOL WINAPI ReadConsoleW(HANDLE hConsoleInput, LPVOID lpBuffer, if (!S_EditString || S_EditString[S_EditStrPos] == 0) { if (S_EditString) HeapFree(GetProcessHeap(), 0, S_EditString); - if (!(S_EditString = CONSOLE_Readline(hConsoleInput, mode & WINE_ENABLE_LINE_INPUT_EMACS))) + if (!(S_EditString = CONSOLE_Readline(hConsoleInput))) return FALSE; S_EditStrPos = 0; } @@ -2242,3 +2242,21 @@ unsigned CONSOLE_GetNumHistoryEntries(void) SERVER_END_REQ; return ret; } + +/****************************************************************** + * CONSOLE_GetEditionMode + * + * + */ +BOOL CONSOLE_GetEditionMode(HANDLE hConIn, int* mode) +{ + unsigned ret = FALSE; + SERVER_START_REQ(get_console_input_info) + { + req->handle = hConIn; + if ((ret = !wine_server_call_err( req ))) + *mode = reply->edition_mode; + } + SERVER_END_REQ; + return ret; +} diff --git a/dlls/kernel/console_private.h b/dlls/kernel/console_private.h index e8da4beebce..f48f4e58e5b 100644 --- a/dlls/kernel/console_private.h +++ b/dlls/kernel/console_private.h @@ -28,8 +28,9 @@ extern int CONSOLE_GetHistory(int idx, WCHAR* buf, int buf_len); extern BOOL CONSOLE_AppendHistory(const WCHAR *p); extern unsigned CONSOLE_GetNumHistoryEntries(void); extern void CONSOLE_FillLineUniform(HANDLE hConsoleOutput, int i, int j, int len, LPCHAR_INFO lpFill); +extern BOOL CONSOLE_GetEditionMode(HANDLE, int*); /* editline.c */ -extern WCHAR* CONSOLE_Readline(HANDLE, int); +extern WCHAR* CONSOLE_Readline(HANDLE); #endif /* __WINE_CONSOLE_PRIVATE_H */ diff --git a/dlls/kernel/editline.c b/dlls/kernel/editline.c index ce6d35169c7..1cb1030a7d8 100644 --- a/dlls/kernel/editline.c +++ b/dlls/kernel/editline.c @@ -785,7 +785,7 @@ KeyMap Win32KeyMap[] = * * ====================================================================*/ -WCHAR* CONSOLE_Readline(HANDLE hConsoleIn, int use_emacs) +WCHAR* CONSOLE_Readline(HANDLE hConsoleIn) { WCEL_Context ctx; INPUT_RECORD ir; @@ -794,10 +794,15 @@ WCHAR* CONSOLE_Readline(HANDLE hConsoleIn, int use_emacs) unsigned ofs; void (*func)(struct WCEL_Context* ctx); DWORD ks; + int use_emacs; memset(&ctx, 0, sizeof(ctx)); ctx.hConIn = hConsoleIn; WCEL_HistoryInit(&ctx); + + if (!CONSOLE_GetEditionMode(hConsoleIn, &use_emacs)) + use_emacs = 0; + if ((ctx.hConOut = CreateFileA("CONOUT$", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0 )) == INVALID_HANDLE_VALUE || !GetConsoleScreenBufferInfo(ctx.hConOut, &ctx.csbi)) diff --git a/include/wincon.h b/include/wincon.h index b94da20d81e..b35bcca70fa 100644 --- a/include/wincon.h +++ b/include/wincon.h @@ -35,8 +35,6 @@ extern "C" { #define ENABLE_ECHO_INPUT 0x04 #define ENABLE_WINDOW_INPUT 0x08 #define ENABLE_MOUSE_INPUT 0x10 -/* Wine only code (extension) */ -#define WINE_ENABLE_LINE_INPUT_EMACS 0x80 #define ENABLE_PROCESSED_OUTPUT 0x01 #define ENABLE_WRAP_AT_EOL_OUTPUT 0x02 diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index f48f4985107..07ef51a37e3 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -1164,6 +1164,7 @@ struct set_console_input_info_request obj_handle_t active_sb; int history_mode; int history_size; + int edition_mode; /* VARARG(title,unicode_str); */ }; struct set_console_input_info_reply @@ -1174,6 +1175,7 @@ struct set_console_input_info_reply #define SET_CONSOLE_INPUT_INFO_TITLE 0x02 #define SET_CONSOLE_INPUT_INFO_HISTORY_MODE 0x04 #define SET_CONSOLE_INPUT_INFO_HISTORY_SIZE 0x08 +#define SET_CONSOLE_INPUT_INFO_EDITION_MODE 0x10 @@ -1188,6 +1190,7 @@ struct get_console_input_info_reply int history_mode; int history_size; int history_index; + int edition_mode; /* VARARG(title,unicode_str); */ }; @@ -3532,6 +3535,6 @@ union generic_reply struct get_next_hook_reply get_next_hook_reply; }; -#define SERVER_PROTOCOL_VERSION 95 +#define SERVER_PROTOCOL_VERSION 96 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */ diff --git a/server/console.c b/server/console.c index aa610fc7ade..e7e4f317018 100644 --- a/server/console.c +++ b/server/console.c @@ -241,6 +241,7 @@ static struct object *create_console_input( struct thread* renderer ) console_input->history = calloc( console_input->history_size, sizeof(WCHAR*) ); console_input->history_index = 0; console_input->history_mode = 0; + console_input->edition_mode = 0; if (!console_input->history || !console_input->evt) { @@ -666,6 +667,10 @@ static int set_console_input_info( const struct set_console_input_info_request * console->history = mem; console->history_size = req->history_size; } + if (req->mask & SET_CONSOLE_INPUT_INFO_EDITION_MODE) + { + console->edition_mode = req->edition_mode; + } release_object( console ); return 1; error: @@ -1363,6 +1368,8 @@ DECL_HANDLER(get_console_input_info) reply->history_mode = console->history_mode; reply->history_size = console->history_size; reply->history_index = console->history_index; + reply->edition_mode = console->edition_mode; + release_object( console ); } diff --git a/server/console.h b/server/console.h index 7ac1ea3cb16..9371d7ad2f7 100644 --- a/server/console.h +++ b/server/console.h @@ -41,6 +41,7 @@ struct console_input int history_size; /* number of entries in history array */ int history_index; /* number of used entries in history array */ int history_mode; /* mode of history (non zero means remove doubled strings */ + int edition_mode; /* index to edition mode flavors */ }; /* console functions */ diff --git a/server/protocol.def b/server/protocol.def index bc53ab645cc..7a17949bf0c 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -864,12 +864,14 @@ struct console_renderer_event obj_handle_t active_sb; /* active screen buffer */ int history_mode; /* whether we duplicate lines in history */ int history_size; /* number of lines in history */ + int edition_mode; /* index to the edition mode flavors */ VARARG(title,unicode_str); /* console title */ @END #define SET_CONSOLE_INPUT_INFO_ACTIVE_SB 0x01 #define SET_CONSOLE_INPUT_INFO_TITLE 0x02 #define SET_CONSOLE_INPUT_INFO_HISTORY_MODE 0x04 #define SET_CONSOLE_INPUT_INFO_HISTORY_SIZE 0x08 +#define SET_CONSOLE_INPUT_INFO_EDITION_MODE 0x10 /* Get info about a console (input only) */ @@ -879,6 +881,7 @@ struct console_renderer_event int history_mode; /* whether we duplicate lines in history */ int history_size; /* number of lines in history */ int history_index; /* number of used lines in history */ + int edition_mode; /* index to the edition mode flavors */ VARARG(title,unicode_str); /* console title */ @END diff --git a/server/trace.c b/server/trace.c index 36ac319bf90..aac9e74505a 100644 --- a/server/trace.c +++ b/server/trace.c @@ -1027,6 +1027,7 @@ static void dump_set_console_input_info_request( const struct set_console_input_ fprintf( stderr, " active_sb=%p,", req->active_sb ); fprintf( stderr, " history_mode=%d,", req->history_mode ); fprintf( stderr, " history_size=%d,", req->history_size ); + fprintf( stderr, " edition_mode=%d,", req->edition_mode ); fprintf( stderr, " title=" ); dump_varargs_unicode_str( cur_size ); } @@ -1041,6 +1042,7 @@ static void dump_get_console_input_info_reply( const struct get_console_input_in fprintf( stderr, " history_mode=%d,", req->history_mode ); fprintf( stderr, " history_size=%d,", req->history_size ); fprintf( stderr, " history_index=%d,", req->history_index ); + fprintf( stderr, " edition_mode=%d,", req->edition_mode ); fprintf( stderr, " title=" ); dump_varargs_unicode_str( cur_size ); }