[PATCH] cmd: Enable InsertMode if registry value and data are valid

Hugh McMaster hugh.mcmaster at outlook.com
Wed Apr 8 01:08:09 CDT 2015


---
 programs/cmd/wcmdmain.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index bc9b216..903e147 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -2337,9 +2337,12 @@ int wmain (int argc, WCHAR *argvW[])
   static const WCHAR offW[] = {'O','F','F','\0'};
   static const WCHAR promptW[] = {'P','R','O','M','P','T','\0'};
   static const WCHAR defaultpromptW[] = {'$','P','$','G','\0'};
+  static const WCHAR consoleW[] = {'C','o','n','s','o','l','e','\0'};
   CMD_LIST *toExecute = NULL;         /* Commands left to be executed */
   OSVERSIONINFOW osv;
   char osver[50];
+  HKEY hcu_console;
+  DWORD mode = ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT;
 
   srand(time(NULL));
 
@@ -2593,8 +2596,17 @@ int wmain (int argc, WCHAR *argvW[])
       return errorlevel;
   }
 
-  SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), ENABLE_LINE_INPUT |
-                 ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT);
+  if (RegOpenKeyExW(HKEY_CURRENT_USER, consoleW, 0, KEY_READ, &hcu_console) == ERROR_SUCCESS) {
+      static const WCHAR insertmodeW[] = {'I','n','s','e','r','t','M','o','d','e','\0'};
+      DWORD value, size = sizeof(DWORD);
+
+      if (RegQueryValueExW(hcu_console, insertmodeW, NULL, NULL, (BYTE *)&value, &size) == ERROR_SUCCESS) {
+          if (value)
+              mode |= (ENABLE_INSERT_MODE | ENABLE_EXTENDED_FLAGS);
+      }
+      RegCloseKey(hcu_console);
+  }
+  SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), mode);
   SetConsoleTitleW(WCMD_LoadMessage(WCMD_CONSTITLE));
 
   /* Note: cmd.exe /c dir does not get a new color, /k dir does */
-- 
1.9.1




More information about the wine-patches mailing list