kernel32: Reset insert key toggle when Insert Mode changes (v2)

Hugh McMaster hugh.mcmaster at outlook.com
Thu Aug 13 00:22:17 CDT 2015


On Windows, switching Insert Mode via the user dialog resets the
insert key toggle (if it is enabled).

In wineconsole, although the console mode changes, the insert
key toggle is still enabled, so ctx.insert gets flipped
back to what it was originally.

The end result is the opposite of what the user wanted.
---
 dlls/kernel32/editline.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/dlls/kernel32/editline.c b/dlls/kernel32/editline.c
index c0234d7..b330869 100644
--- a/dlls/kernel32/editline.c
+++ b/dlls/kernel32/editline.c
@@ -913,7 +913,7 @@ WCHAR* CONSOLE_Readline(HANDLE hConsoleIn, BOOL can_pos_cursor)
     const KeyEntry*	ke;
     unsigned		ofs;
     void		(*func)(struct WCEL_Context* ctx);
-    DWORD               mode, ks;
+    DWORD               mode, input_mode, ks;
     int                 use_emacs;
 
     memset(&ctx, 0, sizeof(ctx));
@@ -928,6 +928,7 @@ WCHAR* CONSOLE_Readline(HANDLE hConsoleIn, BOOL can_pos_cursor)
 	!GetConsoleScreenBufferInfo(ctx.hConOut, &ctx.csbi))
 	return NULL;
     if (!GetConsoleMode(hConsoleIn, &mode)) mode = 0;
+    input_mode = mode;
     ctx.shall_echo = (mode & ENABLE_ECHO_INPUT) ? 1 : 0;
     ctx.insert = (mode & (ENABLE_INSERT_MODE|ENABLE_EXTENDED_FLAGS)) == (ENABLE_INSERT_MODE|ENABLE_EXTENDED_FLAGS) ? 1 : 0;
     if (!GetConsoleMode(ctx.hConOut, &mode)) mode = 0;
@@ -982,6 +983,11 @@ WCHAR* CONSOLE_Readline(HANDLE hConsoleIn, BOOL can_pos_cursor)
 	}
 
         GetConsoleMode(hConsoleIn, &mode);
+        if (input_mode != mode)
+        {
+            input_mode = mode;
+            ctx.insertkey = 0;
+        }
         ctx.insert = (mode & (ENABLE_INSERT_MODE|ENABLE_EXTENDED_FLAGS)) ==
                      (ENABLE_INSERT_MODE|ENABLE_EXTENDED_FLAGS);
         if (ctx.insertkey)
-- 
1.9.1




More information about the wine-patches mailing list