- Instances of the other objects of the editor\r
- Main Interfaces\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
HEFI_EDITOR_GLOBAL_EDITOR HMainEditorConst = {\r
&HBufferImage,\r
{\r
- 0,\r
- 0\r
+ {0, 0}\r
},\r
{\r
0,\r
0\r
},\r
+ NULL,\r
FALSE,\r
NULL,\r
0,\r
VOID\r
)\r
{\r
- INTN CurrentLine=0;\r
- CHAR16 * InfoString;\r
- EFI_INPUT_KEY Key;\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 != HexMainMenuHelpInfo[CurrentLine]; CurrentLine++) {\r
InfoString = HiiGetString(gShellDebug1HiiHandle, HexMainMenuHelpInfo[CurrentLine]\r
, NULL);\r
ShellPrintEx (0,CurrentLine+1,L"%E%s%N",InfoString); \r
}\r
- \r
+\r
+ //\r
// scan for ctrl+w\r
- do {\r
- gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
- } while(SCAN_CONTROL_W != Key.UnicodeChar); \r
+ //\r
+ while (TRUE) {\r
+ Status = gBS->WaitForEvent (1, &HMainEditor.TextInputEx->WaitForKeyEx, &EventIndex);\r
+ if (EFI_ERROR (Status) || (EventIndex != 0)) {\r
+ continue;\r
+ }\r
+ Status = HMainEditor.TextInputEx->ReadKeyStrokeEx (HMainEditor.TextInputEx, &KeyData);\r
+ if (EFI_ERROR (Status)) {\r
+ continue;\r
+ }\r
+\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 buffer's info\r
HBufferImageNeedRefresh = TRUE;\r
// the file won't be saved\r
//\r
return EFI_SUCCESS;\r
- break;\r
\r
case L'c':\r
case L'C':\r
)\r
{\r
UINTN Index;\r
- HEFI_EDITOR_LINE *Line;\r
LIST_ENTRY *Link;\r
UINT8 *Buffer;\r
UINTN Count;\r
Link = Link->ForwardLink;\r
}\r
\r
- Line = CR (Link, HEFI_EDITOR_LINE, Link, EFI_EDITOR_LINE_LIST);\r
-\r
Count = HMainEditor.SelectEnd - HMainEditor.SelectStart + 1;\r
Buffer = AllocateZeroPool (Count);\r
if (Buffer == NULL) {\r
NULL, /* Ctrl - A */\r
NULL, /* Ctrl - B */\r
NULL, /* Ctrl - C */\r
- NULL, /* Ctrl - D */\r
+ HMainCommandSelectEnd, /* Ctrl - D */\r
HMainCommandDisplayHelp, /* Ctrl - E */\r
NULL, /* Ctrl - F */\r
- NULL, /* Ctrl - G */\r
+ HMainCommandGoToOffset, /* Ctrl - G */\r
NULL, /* Ctrl - H */\r
- NULL, /* Ctrl - I */\r
+ HMainCommandOpenDisk, /* Ctrl - I */\r
NULL, /* Ctrl - J */\r
NULL, /* Ctrl - K */\r
NULL, /* Ctrl - L */\r
- NULL, /* Ctrl - M */\r
+ HMainCommandOpenMemory, /* Ctrl - M */\r
NULL, /* Ctrl - N */\r
- NULL, /* Ctrl - O */\r
+ HMainCommandOpenFile, /* Ctrl - O */\r
NULL, /* Ctrl - P */\r
- NULL, /* Ctrl - Q */\r
+ HMainCommandExit, /* Ctrl - Q */\r
NULL, /* Ctrl - R */\r
- NULL, /* Ctrl - S */\r
- NULL, /* Ctrl - T */\r
+ HMainCommandSaveBuffer, /* Ctrl - S */\r
+ HMainCommandSelectStart, /* Ctrl - T */\r
NULL, /* Ctrl - U */\r
- NULL, /* Ctrl - V */\r
+ HMainCommandPaste, /* Ctrl - V */\r
NULL, /* Ctrl - W */\r
- NULL, /* Ctrl - X */\r
+ HMainCommandCut, /* Ctrl - X */\r
NULL, /* Ctrl - Y */\r
NULL, /* Ctrl - Z */\r
};\r
&(HMainEditor.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**)&HMainEditor.TextInputEx\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
//\r
// Find mouse in System Table ConsoleInHandle\r
//\r
//\r
// below will call the five components' init function\r
//\r
- Status = MainTitleBarInit (NULL);\r
+ Status = MainTitleBarInit (L"UEFI HEXEDIT");\r
if (EFI_ERROR (Status)) {\r
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_LIBEDITOR_MAINEDITOR_TITLE), gShellDebug1HiiHandle);\r
return EFI_LOAD_ERROR;\r
return EFI_LOAD_ERROR;\r
}\r
\r
- InputBarInit ();\r
+ InputBarInit (HMainEditor.TextInputEx);\r
\r
Status = HBufferImageInit ();\r
if (EFI_ERROR (Status)) {\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
BOOLEAN LengthChange;\r
UINTN Size;\r
UINTN OldSize;\r
}\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
- HBufferImageMouseNeedRefresh = TRUE;\r
-\r
- //\r
- // clear previous status string\r
- //\r
- StatusBarSetRefresh();\r
- if (EFI_SUCCESS == MenuBarDispatchControlHotKey(&Key)) {\r
- Status = EFI_SUCCESS;\r
- } else if (Key.ScanCode == SCAN_NULL) {\r
- Status = HBufferImageHandleInput (&Key);\r
- } else if (((Key.ScanCode >= SCAN_UP) && (Key.ScanCode <= SCAN_PAGE_DOWN))) {\r
- Status = HBufferImageHandleInput (&Key);\r
- } else if (((Key.ScanCode >= SCAN_F1) && Key.ScanCode <= (SCAN_F12))) {\r
- Status = MenuBarDispatchFunctionKey (&Key);\r
- } else {\r
- StatusBarSetStatusString (L"Unknown Command");\r
-\r
- HBufferImageMouseNeedRefresh = FALSE;\r
- }\r
+ Status = gBS->WaitForEvent (1, &HMainEditor.TextInputEx->WaitForKeyEx, &EventIndex);\r
+ if (!EFI_ERROR (Status) && EventIndex == 0) {\r
+ Status = HMainEditor.TextInputEx->ReadKeyStrokeEx (HMainEditor.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
+ HBufferImageMouseNeedRefresh = TRUE;\r
\r
- if (Status != EFI_SUCCESS && Status != EFI_OUT_OF_RESOURCES) {\r
//\r
- // not already has some error status\r
+ // clear previous status string\r
+ //\r
+ StatusBarSetRefresh();\r
+ //\r
+ // NoShiftState: TRUE when no shift key is pressed.\r
+ //\r
+ NoShiftState = ((KeyData.KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) || (KeyData.KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID);\r
//\r
- if (StrCmp (L"", StatusBarGetString()) == 0) {\r
- StatusBarSetStatusString (L"Disk Error. Try Again");\r
+ // dispatch to different components' key handling function\r
+ //\r
+ if (EFI_SUCCESS == MenuBarDispatchControlHotKey(&KeyData)) {\r
+ Status = EFI_SUCCESS;\r
+ } else if (NoShiftState && KeyData.Key.ScanCode == SCAN_NULL) {\r
+ Status = HBufferImageHandleInput (&KeyData.Key);\r
+ } else if (NoShiftState && ((KeyData.Key.ScanCode >= SCAN_UP) && (KeyData.Key.ScanCode <= SCAN_PAGE_DOWN))) {\r
+ Status = HBufferImageHandleInput (&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
+\r
+ HBufferImageMouseNeedRefresh = FALSE;\r
+ }\r
+\r
+ if (Status != EFI_SUCCESS && Status != EFI_OUT_OF_RESOURCES) {\r
+ //\r
+ // not already has some error status\r
+ //\r
+ if (StrCmp (L"", StatusBarGetString()) == 0) {\r
+ StatusBarSetStatusString (L"Disk Error. Try Again");\r
+ }\r
}\r
}\r
- }\r
- //\r
- // decide if has to set length warning\r
- //\r
- if (HBufferImage.BufferType != HBufferImageBackupVar.BufferType) {\r
- LengthChange = FALSE;\r
- } else {\r
//\r
- // still the old buffer\r
+ // decide if has to set length warning\r
//\r
- if (HBufferImage.BufferType != FileTypeFileBuffer) {\r
- Size = HBufferImageGetTotalSize ();\r
+ if (HBufferImage.BufferType != HBufferImageBackupVar.BufferType) {\r
+ LengthChange = FALSE;\r
+ } else {\r
+ //\r
+ // still the old buffer\r
+ //\r
+ if (HBufferImage.BufferType != FileTypeFileBuffer) {\r
+ Size = HBufferImageGetTotalSize ();\r
\r
- switch (HBufferImage.BufferType) {\r
- case FileTypeDiskBuffer:\r
- OldSize = HBufferImage.DiskImage->Size * HBufferImage.DiskImage->BlockSize;\r
- break;\r
+ switch (HBufferImage.BufferType) {\r
+ case FileTypeDiskBuffer:\r
+ OldSize = HBufferImage.DiskImage->Size * HBufferImage.DiskImage->BlockSize;\r
+ break;\r
\r
- case FileTypeMemBuffer:\r
- OldSize = HBufferImage.MemImage->Size;\r
- break;\r
+ case FileTypeMemBuffer:\r
+ OldSize = HBufferImage.MemImage->Size;\r
+ break;\r
\r
- default:\r
- OldSize = 0;\r
- break;\r
- }\r
+ default:\r
+ OldSize = 0;\r
+ break;\r
+ }\r
\r
- if (!LengthChange) {\r
- if (OldSize != Size) {\r
- StatusBarSetStatusString (L"Disk/Mem Buffer Length should not be changed");\r
+ if (!LengthChange) {\r
+ if (OldSize != Size) {\r
+ StatusBarSetStatusString (L"Disk/Mem Buffer Length should not be changed");\r
+ }\r
}\r
- }\r
\r
- if (OldSize != Size) {\r
- LengthChange = TRUE;\r
- } else {\r
- LengthChange = FALSE;\r
+ if (OldSize != Size) {\r
+ LengthChange = TRUE;\r
+ } else {\r
+ LengthChange = FALSE;\r
+ }\r
}\r
}\r
+ //\r
+ // after handling, refresh editor\r
+ //\r
+ HMainEditorRefresh ();\r
}\r
- //\r
- // after handling, refresh editor\r
- //\r
- HMainEditorRefresh ();\r
\r
} while (Status != EFI_OUT_OF_RESOURCES && !HEditorExit);\r
\r
Backup function for MainEditor.\r
**/\r
VOID\r
-EFIAPI\r
HMainEditorBackup (\r
VOID\r
)\r