]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
ShellPkg/[hex]edit: Fix mouse freeze issue
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / Edit / MainTextEditor.c
index a197f80a40f6606ec42091236c5b96dd18886afd..98e1331ac453267334d1766b9c621d43952192b6 100644 (file)
@@ -1387,18 +1387,20 @@ MainCommandDisplayHelp (
       continue;\r
     }\r
 \r
-    if ((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) {\r
+    if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) ||\r
+        (KeyData.KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID)) {\r
       //\r
-      // For consoles that don't support shift state reporting,\r
+      // For consoles that don't support/report shift state,\r
       // CTRL+W is translated to L'W' - L'A' + 1.\r
       //\r
       if (KeyData.Key.UnicodeChar == L'W' - L'A' + 1) {\r
         break;\r
       }\r
-    } else if (((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) &&\r
+    } else if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) &&\r
+               ((KeyData.KeyState.KeyShiftState & (EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) != 0) &&\r
                ((KeyData.KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_LEFT_CONTROL_PRESSED | EFI_RIGHT_CONTROL_PRESSED)) == 0)) {\r
       //\r
-      // For consoles that supports shift state reporting,\r
+      // For consoles that supports/reports shift state,\r
       // make sure that only CONTROL shift key is pressed.\r
       //\r
       if ((KeyData.Key.UnicodeChar == 'w') || (KeyData.Key.UnicodeChar == 'W')) {\r
@@ -1497,7 +1499,7 @@ MainEditorInit (
   // Find mouse in System Table ConsoleInHandle\r
   //\r
   Status = gBS->HandleProtocol (\r
-                gST->ConIn,\r
+                gST->ConsoleInHandle,\r
                 &gEfiSimplePointerProtocolGuid,\r
                 (VOID**)&MainEditor.MouseInterface\r
                 );\r
@@ -1838,7 +1840,6 @@ MainEditorKeyInput (
   EFI_KEY_DATA              KeyData;\r
   EFI_STATUS                Status;\r
   EFI_SIMPLE_POINTER_STATE  MouseState;\r
-  UINTN                     EventIndex;\r
   BOOLEAN                   NoShiftState;\r
 \r
   do {\r
@@ -1874,8 +1875,11 @@ MainEditorKeyInput (
       }\r
     }\r
 \r
-    Status = gBS->WaitForEvent (1, &MainEditor.TextInputEx->WaitForKeyEx, &EventIndex);\r
-    if (!EFI_ERROR (Status) && EventIndex == 0) {\r
+    //\r
+    // CheckEvent() returns Success when non-partial key is pressed.\r
+    //\r
+    Status = gBS->CheckEvent (MainEditor.TextInputEx->WaitForKeyEx);\r
+    if (!EFI_ERROR (Status)) {\r
       Status = MainEditor.TextInputEx->ReadKeyStrokeEx (MainEditor.TextInputEx, &KeyData);\r
       if (!EFI_ERROR (Status)) {\r
         //\r
@@ -1915,11 +1919,11 @@ MainEditorKeyInput (
         }\r
 \r
       }\r
-      //\r
-      // after handling, refresh editor\r
-      //\r
-      MainEditorRefresh ();\r
     }\r
+    //\r
+    // after handling, refresh editor\r
+    //\r
+    MainEditorRefresh ();\r
 \r
   } while (Status != EFI_OUT_OF_RESOURCES && !EditorExit);\r
 \r