]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
ShellPkg/[hex]edit: use SimpleTextInEx to read console
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / Edit / MainTextEditor.c
index 713332ea0d837e2b2258467718a74dea960d5ab1..a197f80a40f6606ec42091236c5b96dd18886afd 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Implements editor interface functions.\r
 \r
-  Copyright (c) 2005 - 2011, 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
 #include "TextEditor.h"\r
 #include "EditStatusBar.h"\r
 #include "EditInputBar.h"\r
+#include "EditMenuBar.h"\r
+\r
+//\r
+// the first time editor launch\r
+//\r
+BOOLEAN                       EditorFirst;\r
+\r
+//\r
+// it's time editor should exit\r
+//\r
+BOOLEAN                       EditorExit;\r
+\r
+BOOLEAN                       EditorMouseAction;\r
+\r
+extern EFI_EDITOR_FILE_BUFFER FileBuffer;\r
+\r
+extern BOOLEAN                FileBufferNeedRefresh;\r
+\r
+extern BOOLEAN                FileBufferOnlyLineNeedRefresh;\r
+\r
+extern BOOLEAN                FileBufferMouseNeedRefresh;\r
+\r
+extern EFI_EDITOR_FILE_BUFFER FileBufferBackupVar;\r
+\r
+EFI_EDITOR_GLOBAL_EDITOR      MainEditor;\r
+\r
 \r
 /**\r
   Load a file from disk to editor\r
@@ -24,7 +50,6 @@
   @retval EFI_OUT_OF_RESOURCES    A memory allocation failed.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainCommandOpenFile (\r
   VOID\r
   );\r
@@ -35,7 +60,6 @@ MainCommandOpenFile (
   @retval EFI_SUCCESS           The switch was ok or a warning was presented.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainCommandSwitchFileType (\r
   VOID\r
   );\r
@@ -46,7 +70,6 @@ MainCommandSwitchFileType (
   @retval EFI_SUCCESS             The operation was successful.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainCommandGotoLine (\r
   VOID\r
   );\r
@@ -60,11 +83,20 @@ MainCommandGotoLine (
   @retval EFI_LOAD_ERROR          A file access error occured.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainCommandSaveFile (\r
   VOID\r
   );\r
 \r
+/**\r
+  Show help information for the editor.\r
+\r
+  @retval EFI_SUCCESS             The operation was successful.\r
+**/\r
+EFI_STATUS\r
+MainCommandDisplayHelp (\r
+  VOID\r
+  );\r
+\r
 /**\r
   exit editor\r
 \r
@@ -73,7 +105,6 @@ MainCommandSaveFile (
   @retval EFI_LOAD_ERROR          A load error occured.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainCommandExit (\r
   VOID\r
   );\r
@@ -86,7 +117,6 @@ MainCommandExit (
   @retval EFI_LOAD_ERROR          A load error occured.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainCommandSearch (\r
   VOID\r
   );\r
@@ -99,7 +129,6 @@ MainCommandSearch (
   @retval EFI_LOAD_ERROR          A load error occured.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainCommandSearchReplace (\r
   VOID\r
   );\r
@@ -112,7 +141,6 @@ MainCommandSearchReplace (
   @retval EFI_LOAD_ERROR          A load error occured.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainCommandCutLine (\r
   VOID\r
   );\r
@@ -125,11 +153,70 @@ MainCommandCutLine (
   @retval EFI_LOAD_ERROR          A load error occured.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainCommandPasteLine (\r
   VOID\r
   );\r
 \r
+/**\r
+  Help info that will be displayed.\r
+**/\r
+EFI_STRING_ID  MainMenuHelpInfo[] = {\r
+  STRING_TOKEN(STR_EDIT_HELP_TITLE),\r
+  STRING_TOKEN(STR_EDIT_HELP_BLANK),\r
+  STRING_TOKEN(STR_EDIT_HELP_LIST_TITLE),\r
+  STRING_TOKEN(STR_EDIT_HELP_DIV),\r
+  STRING_TOKEN(STR_EDIT_HELP_GO_TO_LINE),\r
+  STRING_TOKEN(STR_EDIT_HELP_SAVE_FILE),\r
+  STRING_TOKEN(STR_EDIT_HELP_EXIT),\r
+  STRING_TOKEN(STR_EDIT_HELP_SEARCH),\r
+  STRING_TOKEN(STR_EDIT_HELP_SEARCH_REPLACE),\r
+  STRING_TOKEN(STR_EDIT_HELP_CUT_LINE),\r
+  STRING_TOKEN(STR_EDIT_HELP_PASTE_LINE),\r
+  STRING_TOKEN(STR_EDIT_HELP_OPEN_FILE),\r
+  STRING_TOKEN(STR_EDIT_HELP_FILE_TYPE),\r
+  STRING_TOKEN(STR_EDIT_HELP_BLANK),\r
+  STRING_TOKEN(STR_EDIT_HELP_EXIT_HELP),\r
+  STRING_TOKEN(STR_EDIT_HELP_BLANK),\r
+  STRING_TOKEN(STR_EDIT_HELP_BLANK),\r
+  STRING_TOKEN(STR_EDIT_HELP_BLANK),\r
+  STRING_TOKEN(STR_EDIT_HELP_BLANK),\r
+  STRING_TOKEN(STR_EDIT_HELP_BLANK),\r
+  STRING_TOKEN(STR_EDIT_HELP_BLANK),\r
+  STRING_TOKEN(STR_EDIT_HELP_BLANK),\r
+  STRING_TOKEN(STR_EDIT_HELP_DIV),\r
+0\r
+};\r
+\r
+MENU_ITEM_FUNCTION MainControlBasedMenuFunctions[] = {\r
+  NULL,\r
+  NULL,                      /* Ctrl - A */\r
+  NULL,                      /* Ctrl - B */\r
+  NULL,                      /* Ctrl - C */\r
+  NULL,                      /* Ctrl - D */\r
+  MainCommandDisplayHelp,    /* Ctrl - E */\r
+  MainCommandSearch,         /* Ctrl - F */\r
+  MainCommandGotoLine,       /* Ctrl - G */\r
+  NULL,                      /* Ctrl - H */\r
+  NULL,                      /* Ctrl - I */\r
+  NULL,                      /* Ctrl - J */\r
+  MainCommandCutLine,        /* Ctrl - K */\r
+  NULL,                      /* Ctrl - L */\r
+  NULL,                      /* Ctrl - M */\r
+  NULL,                      /* Ctrl - N */\r
+  MainCommandOpenFile,       /* Ctrl - O */\r
+  NULL,                      /* Ctrl - P */\r
+  MainCommandExit,           /* Ctrl - Q */\r
+  MainCommandSearchReplace,  /* Ctrl - R */\r
+  MainCommandSaveFile,       /* Ctrl - S */\r
+  MainCommandSwitchFileType, /* Ctrl - T */\r
+  MainCommandPasteLine,      /* Ctrl - U */\r
+  NULL,                      /* Ctrl - V */\r
+  NULL,                      /* Ctrl - W */\r
+  NULL,                      /* Ctrl - X */\r
+  NULL,                      /* Ctrl - Y */\r
+  NULL,                      /* Ctrl - Z */\r
+};\r
+\r
 EDITOR_MENU_ITEM  MainMenuItems[] = {\r
   {\r
     STRING_TOKEN(STR_EDIT_LIBMENUBAR_GO_TO_LINE),\r
@@ -178,6 +265,11 @@ EDITOR_MENU_ITEM  MainMenuItems[] = {
     STRING_TOKEN(STR_EDIT_LIBMENUBAR_F9),\r
     MainCommandSwitchFileType\r
   },\r
+  {\r
+    STRING_TOKEN(STR_EDIT_LIBMENUBAR_FILE_TYPE),\r
+    STRING_TOKEN(STR_EDIT_LIBMENUBAR_F11),\r
+    MainCommandSwitchFileType\r
+  },\r
 \r
   {\r
     0,\r
@@ -195,7 +287,6 @@ EDITOR_MENU_ITEM  MainMenuItems[] = {
   @retval EFI_OUT_OF_RESOURCES    A memory allocation failed.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainCommandOpenFile (\r
   VOID\r
   )\r
@@ -350,7 +441,6 @@ MainCommandOpenFile (
   @retval EFI_SUCCESS           The switch was ok or a warning was presented.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainCommandSwitchFileType (\r
   VOID\r
   )\r
@@ -384,7 +474,6 @@ MainCommandSwitchFileType (
   @retval EFI_LOAD_ERROR          A load error occured.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainCommandCutLine (\r
   VOID\r
   )\r
@@ -400,6 +489,7 @@ MainCommandCutLine (
   //     IF cursor is not on valid line, an Status String will be prompted :\r
   //        "Nothing to Cut".\r
   //\r
+  Line = NULL;\r
   Status = FileBufferCutLine (&Line);\r
   if (Status == EFI_NOT_FOUND) {\r
     return EFI_SUCCESS;\r
@@ -422,7 +512,6 @@ MainCommandCutLine (
   @retval EFI_LOAD_ERROR          A load error occured.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainCommandPasteLine (\r
   VOID\r
   )\r
@@ -455,7 +544,6 @@ MainCommandPasteLine (
   @retval EFI_LOAD_ERROR          A load error occured.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainCommandSearch (\r
   VOID\r
   )\r
@@ -597,7 +685,6 @@ MainCommandSearch (
   @retval EFI_LOAD_ERROR          A load error occured.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainCommandSearchReplace (\r
   VOID\r
   )\r
@@ -901,7 +988,6 @@ MainCommandSearchReplace (
   @retval EFI_LOAD_ERROR          A load error occured.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainCommandExit (\r
   VOID\r
   )\r
@@ -983,7 +1069,6 @@ MainCommandExit (
   @retval EFI_SUCCESS             The operation was successful.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainCommandGotoLine (\r
   VOID\r
   )\r
@@ -1057,7 +1142,6 @@ MainCommandGotoLine (
   @retval EFI_LOAD_ERROR          A file access error occured.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainCommandSaveFile (\r
   VOID\r
   )\r
@@ -1266,28 +1350,76 @@ MainCommandSaveFile (
   return Status;\r
 }\r
 \r
-EFI_EDITOR_COLOR_ATTRIBUTES   OriginalColors;\r
-INTN                          OriginalMode;\r
-\r
-//\r
-// the first time editor launch\r
-//\r
-BOOLEAN                       EditorFirst;\r
+/**\r
+  Show help information for the editor.\r
 \r
-//\r
-// it's time editor should exit\r
-//\r
-BOOLEAN                       EditorExit;\r
+  @retval EFI_SUCCESS             The operation was successful.\r
+**/\r
+EFI_STATUS\r
+MainCommandDisplayHelp (\r
+  VOID\r
+  )\r
+{\r
+  INT32           CurrentLine;\r
+  CHAR16          *InfoString;\r
+  EFI_KEY_DATA    KeyData;\r
+  EFI_STATUS      Status;\r
+  UINTN           EventIndex;\r
+  \r
+  //\r
+  // print helpInfo      \r
+  //\r
+  for (CurrentLine = 0; 0 != MainMenuHelpInfo[CurrentLine]; CurrentLine++) {\r
+    InfoString = HiiGetString(gShellDebug1HiiHandle, MainMenuHelpInfo[CurrentLine], NULL);\r
+    ShellPrintEx (0, CurrentLine+1, L"%E%s%N", InfoString);        \r
+  }\r
 \r
-BOOLEAN                       EditorMouseAction;\r
+  //\r
+  // scan for ctrl+w\r
+  //\r
+  while (TRUE) {\r
+    Status = gBS->WaitForEvent (1, &MainEditor.TextInputEx->WaitForKeyEx, &EventIndex);\r
+    if (EFI_ERROR (Status) || (EventIndex != 0)) {\r
+      continue;\r
+    }\r
+    Status = MainEditor.TextInputEx->ReadKeyStrokeEx (MainEditor.TextInputEx, &KeyData);\r
+    if (EFI_ERROR (Status)) {\r
+      continue;\r
+    }\r
 \r
-extern EFI_EDITOR_FILE_BUFFER FileBuffer;\r
+    if ((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) {\r
+      //\r
+      // For consoles that don't support shift state reporting,\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
+               ((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
+      // make sure that only CONTROL shift key is pressed.\r
+      //\r
+      if ((KeyData.Key.UnicodeChar == 'w') || (KeyData.Key.UnicodeChar == 'W')) {\r
+        break;\r
+      }\r
+    }\r
+  }\r
+  //\r
+  // update screen with file buffer's info\r
+  //\r
+  FileBufferRestorePosition ();\r
+  FileBufferNeedRefresh = TRUE;\r
+  FileBufferOnlyLineNeedRefresh = FALSE;\r
+  FileBufferRefresh ();  \r
 \r
-extern BOOLEAN                FileBufferMouseNeedRefresh;\r
+  return EFI_SUCCESS;\r
+}\r
 \r
-extern EFI_EDITOR_FILE_BUFFER FileBufferBackupVar;\r
+EFI_EDITOR_COLOR_ATTRIBUTES   OriginalColors;\r
+INTN                          OriginalMode;\r
 \r
-EFI_EDITOR_GLOBAL_EDITOR      MainEditor;\r
 \r
 //\r
 // basic initialization for MainEditor\r
@@ -1295,14 +1427,14 @@ EFI_EDITOR_GLOBAL_EDITOR      MainEditor;
 EFI_EDITOR_GLOBAL_EDITOR      MainEditorConst = {\r
   &FileBuffer,\r
   {\r
-    0,\r
-    0\r
+    {0, 0}\r
   },\r
   {\r
     0,\r
     0\r
   },\r
   NULL,\r
+  NULL,\r
   FALSE,\r
   NULL\r
 };\r
@@ -1314,7 +1446,6 @@ EFI_EDITOR_GLOBAL_EDITOR      MainEditorConst = {
   @retval EFI_LOAD_ERROR          A load error occured.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainEditorInit (\r
   VOID\r
   )\r
@@ -1349,6 +1480,19 @@ MainEditorInit (
         &(MainEditor.ScreenSize.Row)\r
         );\r
 \r
+  //\r
+  // Find TextInEx in System Table ConsoleInHandle\r
+  // Per UEFI Spec, TextInEx is required for a console capable platform.\r
+  //\r
+  Status = gBS->HandleProtocol (\r
+              gST->ConsoleInHandle,\r
+              &gEfiSimpleTextInputExProtocolGuid,\r
+              (VOID**)&MainEditor.TextInputEx\r
+              );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
   //\r
   // Find mouse in System Table ConsoleInHandle\r
   //\r
@@ -1399,12 +1543,13 @@ MainEditorInit (
   //\r
   // below will call the five components' init function\r
   //\r
-  Status = MainTitleBarInit (L"UEFI EDIT 2.0");\r
+  Status = MainTitleBarInit (L"UEFI EDIT");\r
   if (EFI_ERROR (Status)) {\r
     ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_LIBEDITOR_TITLEBAR), gShellDebug1HiiHandle);\r
     return EFI_LOAD_ERROR;\r
   }\r
 \r
+  Status = ControlHotKeyInit (MainControlBasedMenuFunctions);\r
   Status = MenuBarInit (MainMenuItems);\r
   if (EFI_ERROR (Status)) {\r
     ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_LIBEDITOR_MAINMENU), gShellDebug1HiiHandle);\r
@@ -1417,7 +1562,7 @@ MainEditorInit (
     return EFI_LOAD_ERROR;\r
   }\r
 \r
-  InputBarInit ();\r
+  InputBarInit (MainEditor.TextInputEx);\r
 \r
   Status = FileBufferInit ();\r
   if (EFI_ERROR (Status)) {\r
@@ -1447,7 +1592,6 @@ MainEditorInit (
   @retval EFI_LOAD_ERROR          A load error occured.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainEditorCleanup (\r
   VOID\r
   )\r
@@ -1491,7 +1635,6 @@ MainEditorCleanup (
   Refresh the main editor component.\r
 **/\r
 VOID\r
-EFIAPI\r
 MainEditorRefresh (\r
   VOID\r
   )\r
@@ -1512,8 +1655,8 @@ MainEditorRefresh (
 \r
     MainTitleBarRefresh (MainEditor.FileBuffer->FileName, MainEditor.FileBuffer->FileType, MainEditor.FileBuffer->ReadOnly, MainEditor.FileBuffer->FileModified, MainEditor.ScreenSize.Column, MainEditor.ScreenSize.Row, 0, 0);\r
     FileBufferRestorePosition ();\r
-    FileBufferRefresh ();\r
   }\r
+\r
   if (EditorFirst\r
     || FileBufferBackupVar.FilePosition.Row != FileBuffer.FilePosition.Row \r
     || FileBufferBackupVar.FilePosition.Column != FileBuffer.FilePosition.Column \r
@@ -1522,14 +1665,14 @@ MainEditorRefresh (
 \r
     StatusBarRefresh (EditorFirst, MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column, MainEditor.FileBuffer->FilePosition.Row, MainEditor.FileBuffer->FilePosition.Column, MainEditor.FileBuffer->ModeInsert);\r
     FileBufferRestorePosition ();\r
-    FileBufferRefresh ();\r
   }\r
 \r
   if (EditorFirst) {\r
-    MenuBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);\r
     FileBufferRestorePosition ();\r
   }\r
 \r
+  FileBufferRefresh ();\r
+\r
   //\r
   // EditorFirst is now set to FALSE\r
   //\r
@@ -1544,7 +1687,6 @@ MainEditorRefresh (
   @return The X location of the mouse.\r
 **/\r
 INT32\r
-EFIAPI\r
 GetTextX (\r
   IN INT32 GuidX\r
   )\r
@@ -1566,7 +1708,6 @@ GetTextX (
   @return The Y location of the mouse.\r
 **/\r
 INT32\r
-EFIAPI\r
 GetTextY (\r
   IN INT32 GuidY\r
   )\r
@@ -1590,7 +1731,6 @@ GetTextY (
   @retval EFI_NOT_FOUND     There was no mouse support found.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainEditorHandleMouseInput (\r
   IN EFI_SIMPLE_POINTER_STATE       MouseState\r
   )\r
@@ -1691,14 +1831,15 @@ MainEditorHandleMouseInput (
   @retval EFI_OUT_OF_RESOURCES    A memory allocation failed.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainEditorKeyInput (\r
   VOID\r
   )\r
 {\r
-  EFI_INPUT_KEY             Key;\r
+  EFI_KEY_DATA              KeyData;\r
   EFI_STATUS                Status;\r
   EFI_SIMPLE_POINTER_STATE  MouseState;\r
+  UINTN                     EventIndex;\r
+  BOOLEAN                   NoShiftState;\r
 \r
   do {\r
 \r
@@ -1733,44 +1874,52 @@ MainEditorKeyInput (
       }\r
     }\r
 \r
-    Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
-    if (!EFI_ERROR (Status)) {\r
-      //\r
-      // dispatch to different components' key handling function\r
-      // so not everywhere has to set this variable\r
-      //\r
-      FileBufferMouseNeedRefresh = TRUE;\r
-      //\r
-      // clear previous status string\r
-      //\r
-      StatusBarSetRefresh();\r
-\r
-      //\r
-      // dispatch to different components' key handling function\r
-      //\r
-      if ((Key.ScanCode == SCAN_NULL) || ((Key.ScanCode >= SCAN_UP) && (Key.ScanCode <= SCAN_PAGE_DOWN))) {\r
-        Status = FileBufferHandleInput (&Key);\r
-      } else if ((Key.ScanCode >= SCAN_F1) && (Key.ScanCode <= SCAN_F12)) {\r
-        Status = MenuBarDispatchFunctionKey (&Key);\r
-      } else {\r
-        StatusBarSetStatusString (L"Unknown Command");\r
-        FileBufferMouseNeedRefresh = FALSE;\r
-      }\r
-\r
-      if (Status != EFI_SUCCESS && Status != EFI_OUT_OF_RESOURCES) {\r
+    Status = gBS->WaitForEvent (1, &MainEditor.TextInputEx->WaitForKeyEx, &EventIndex);\r
+    if (!EFI_ERROR (Status) && EventIndex == 0) {\r
+      Status = MainEditor.TextInputEx->ReadKeyStrokeEx (MainEditor.TextInputEx, &KeyData);\r
+      if (!EFI_ERROR (Status)) {\r
+        //\r
+        // dispatch to different components' key handling function\r
+        // so not everywhere has to set this variable\r
+        //\r
+        FileBufferMouseNeedRefresh = TRUE;\r
+        //\r
+        // clear previous status string\r
+        //\r
+        StatusBarSetRefresh();\r
+        //\r
+        // NoShiftState: TRUE when no shift key is pressed.\r
         //\r
-        // not already has some error status\r
+        NoShiftState = ((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) || (KeyData.KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID);\r
         //\r
-        if (StatusBarGetString() != NULL && StrCmp (L"", StatusBarGetString()) == 0) {\r
-          StatusBarSetStatusString (L"Disk Error. Try Again");\r
+        // dispatch to different components' key handling function\r
+        //\r
+        if (EFI_NOT_FOUND != MenuBarDispatchControlHotKey(&KeyData)) {\r
+          Status = EFI_SUCCESS;\r
+        } else if (NoShiftState && ((KeyData.Key.ScanCode == SCAN_NULL) || ((KeyData.Key.ScanCode >= SCAN_UP) && (KeyData.Key.ScanCode <= SCAN_PAGE_DOWN)))) {\r
+          Status = FileBufferHandleInput (&KeyData.Key);\r
+        } else if (NoShiftState && (KeyData.Key.ScanCode >= SCAN_F1) && (KeyData.Key.ScanCode <= SCAN_F12)) {\r
+          Status = MenuBarDispatchFunctionKey (&KeyData.Key);\r
+        } else {\r
+          StatusBarSetStatusString (L"Unknown Command");\r
+          FileBufferMouseNeedRefresh = FALSE;  \r
+        }\r
+        \r
+        if (Status != EFI_SUCCESS && Status != EFI_OUT_OF_RESOURCES) {\r
+          //\r
+          // not already has some error status\r
+          //\r
+          if (StatusBarGetString() != NULL && StrCmp (L"", StatusBarGetString()) == 0) {\r
+            StatusBarSetStatusString (L"Disk Error. Try Again");\r
+          }\r
         }\r
-      }\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
@@ -1786,7 +1935,6 @@ MainEditorKeyInput (
   @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainEditorSetCutLine (\r
   EFI_EDITOR_LINE *Line\r
   )\r
@@ -1818,7 +1966,6 @@ MainEditorSetCutLine (
   @retval EFI_SUCCESS The operation was successful.\r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
 MainEditorBackup (\r
   VOID\r
   )\r