]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellDebug1CommandsLib/EditInputBar.c
ShellPkg/[hex]edit: use SimpleTextInEx to read console
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / EditInputBar.c
index 26f70d719ab3f0cb79208401c6cfec65d00ec516..6c6fc70bab4aee1ead43a7603ec59b1bf8d7bc44 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implements inputbar interface functions.\r
 \r
 /** @file\r
   Implements inputbar interface functions.\r
 \r
-  Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved. <BR>\r
+  Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved. <BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
 CHAR16  *mPrompt;        // Input bar mPrompt string.\r
 CHAR16  *mReturnString;  // The returned string.\r
 UINTN   StringSize;      // Size of mReturnString space size.\r
 CHAR16  *mPrompt;        // Input bar mPrompt string.\r
 CHAR16  *mReturnString;  // The returned string.\r
 UINTN   StringSize;      // Size of mReturnString space size.\r
+EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *mTextInEx;\r
 \r
 /**\r
   Initialize the input bar.\r
 \r
 /**\r
   Initialize the input bar.\r
+\r
+  @param[in] TextInEx  Pointer to SimpleTextInEx instance in System Table.\r
 **/\r
 VOID\r
 InputBarInit (\r
 **/\r
 VOID\r
 InputBarInit (\r
-  VOID\r
+  IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx\r
   )\r
 {\r
   mPrompt       = NULL;\r
   mReturnString = NULL;\r
   StringSize    = 0;\r
   )\r
 {\r
   mPrompt       = NULL;\r
   mReturnString = NULL;\r
   StringSize    = 0;\r
+  mTextInEx     = TextInEx;\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -125,7 +129,7 @@ InputBarRefresh (
 {\r
   INPUT_BAR_COLOR_UNION   Orig;\r
   INPUT_BAR_COLOR_UNION   New;\r
 {\r
   INPUT_BAR_COLOR_UNION   Orig;\r
   INPUT_BAR_COLOR_UNION   New;\r
-  EFI_INPUT_KEY           Key;\r
+  EFI_KEY_DATA            KeyData;\r
   UINTN                   Size;\r
   EFI_STATUS              Status;\r
   BOOLEAN                 NoDisplay;\r
   UINTN                   Size;\r
   EFI_STATUS              Status;\r
   BOOLEAN                 NoDisplay;\r
@@ -174,15 +178,25 @@ InputBarRefresh (
   // wait for user input\r
   //\r
   for (;;) {\r
   // wait for user input\r
   //\r
   for (;;) {\r
-    gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &EventIndex);\r
-    Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
+    Status = gBS->WaitForEvent (1, &mTextInEx->WaitForKeyEx, &EventIndex);\r
+    if (EFI_ERROR (Status) || (EventIndex != 0)) {\r
+      continue;\r
+    }\r
+    Status = mTextInEx->ReadKeyStrokeEx (mTextInEx, &KeyData);\r
     if (EFI_ERROR (Status)) {\r
       continue;\r
     }\r
     if (EFI_ERROR (Status)) {\r
       continue;\r
     }\r
+    if (((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) != 0) &&\r
+        (KeyData.KeyState.KeyShiftState != EFI_SHIFT_STATE_VALID)) {\r
+      //\r
+      // Shift key pressed.\r
+      //\r
+      continue;\r
+    }\r
     //\r
     // pressed ESC\r
     //\r
     //\r
     // pressed ESC\r
     //\r
-    if (Key.ScanCode == SCAN_ESC) {\r
+    if (KeyData.Key.ScanCode == SCAN_ESC) {\r
       Size    = 0;\r
       Status  = EFI_NOT_READY;\r
       break;\r
       Size    = 0;\r
       Status  = EFI_NOT_READY;\r
       break;\r
@@ -190,9 +204,9 @@ InputBarRefresh (
     //\r
     // return pressed\r
     //\r
     //\r
     // return pressed\r
     //\r
-    if (Key.UnicodeChar == CHAR_LINEFEED || Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {\r
+    if (KeyData.Key.UnicodeChar == CHAR_LINEFEED || KeyData.Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {\r
       break;\r
       break;\r
-    } else if (Key.UnicodeChar == CHAR_BACKSPACE) {\r
+    } else if (KeyData.Key.UnicodeChar == CHAR_BACKSPACE) {\r
       //\r
       // backspace\r
       //\r
       //\r
       // backspace\r
       //\r
@@ -205,11 +219,11 @@ InputBarRefresh (
 \r
         }\r
       }\r
 \r
         }\r
       }\r
-    } else if (Key.UnicodeChar <= 127 && Key.UnicodeChar >= 32) {\r
+    } else if (KeyData.Key.UnicodeChar <= 127 && KeyData.Key.UnicodeChar >= 32) {\r
       //\r
       // VALID ASCII char pressed\r
       //\r
       //\r
       // VALID ASCII char pressed\r
       //\r
-      mReturnString[Size] = Key.UnicodeChar;\r
+      mReturnString[Size] = KeyData.Key.UnicodeChar;\r
 \r
       //\r
       // should be less than specified length\r
 \r
       //\r
       // should be less than specified length\r