/** @file\r
Implements editor interface functions.\r
\r
- Copyright (c) 2005 - 2016, 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
{\r
INT32 CurrentLine;\r
CHAR16 *InfoString;\r
- EFI_INPUT_KEY Key;\r
+ EFI_KEY_DATA KeyData;\r
+ EFI_STATUS Status;\r
+ UINTN EventIndex;\r
\r
//\r
// print helpInfo \r
InfoString = HiiGetString(gShellDebug1HiiHandle, MainMenuHelpInfo[CurrentLine], NULL);\r
ShellPrintEx (0, CurrentLine+1, L"%E%s%N", InfoString); \r
}\r
- \r
+\r
//\r
// scan for ctrl+w\r
//\r
- do {\r
- gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\r
- } while(SCAN_CONTROL_W != Key.UnicodeChar); \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
+ 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
0\r
},\r
NULL,\r
+ NULL,\r
FALSE,\r
NULL\r
};\r
&(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
return EFI_LOAD_ERROR;\r
}\r
\r
- InputBarInit ();\r
+ InputBarInit (MainEditor.TextInputEx);\r
\r
Status = FileBufferInit ();\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
\r
do {\r
\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
- FileBufferMouseNeedRefresh = TRUE;\r
- //\r
- // clear previous status string\r
- //\r
- StatusBarSetRefresh();\r
-\r
- //\r
- // dispatch to different components' key handling function\r
- //\r
- if (EFI_NOT_FOUND != MenuBarDispatchControlHotKey(&Key)) {\r
- Status = EFI_SUCCESS;\r
- } else 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
- // not already has some error status\r
+ // clear previous status string\r
//\r
- if (StatusBarGetString() != NULL && StrCmp (L"", StatusBarGetString()) == 0) {\r
- StatusBarSetStatusString (L"Disk Error. Try Again");\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
+ // 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
/** @file\r
Declares editor types.\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
} EFI_EDITOR_FILE_BUFFER;\r
\r
typedef struct {\r
- EFI_EDITOR_FILE_BUFFER *FileBuffer;\r
-\r
- EFI_EDITOR_COLOR_UNION ColorAttributes;\r
- EFI_EDITOR_POSITION ScreenSize; // row number and column number\r
- EFI_EDITOR_LINE *CutLine; // clip board\r
- BOOLEAN MouseSupported;\r
- EFI_SIMPLE_POINTER_PROTOCOL *MouseInterface;\r
- INT32 MouseAccumulatorX;\r
- INT32 MouseAccumulatorY;\r
+ EFI_EDITOR_FILE_BUFFER *FileBuffer;\r
+\r
+ EFI_EDITOR_COLOR_UNION ColorAttributes;\r
+ EFI_EDITOR_POSITION ScreenSize; // row number and column number\r
+ EFI_EDITOR_LINE *CutLine; // clip board\r
+ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInputEx;\r
+ BOOLEAN MouseSupported;\r
+ EFI_SIMPLE_POINTER_PROTOCOL *MouseInterface;\r
+ INT32 MouseAccumulatorX;\r
+ INT32 MouseAccumulatorY;\r
\r
} EFI_EDITOR_GLOBAL_EDITOR;\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
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
+ @param[in] TextInEx Pointer to SimpleTextInEx instance in System Table.\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
+ mTextInEx = TextInEx;\r
}\r
\r
/**\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
// 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 (((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
- if (Key.ScanCode == SCAN_ESC) {\r
+ if (KeyData.Key.ScanCode == SCAN_ESC) {\r
Size = 0;\r
Status = EFI_NOT_READY;\r
break;\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
- } else if (Key.UnicodeChar == CHAR_BACKSPACE) {\r
+ } else if (KeyData.Key.UnicodeChar == CHAR_BACKSPACE) {\r
//\r
// backspace\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
- mReturnString[Size] = Key.UnicodeChar;\r
+ mReturnString[Size] = KeyData.Key.UnicodeChar;\r
\r
//\r
// should be less than specified length\r
/** @file\r
Declares imputbar 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
\r
/**\r
Initialize the input bar.\r
+\r
+ @param[in] TextInEx Pointer to SimpleTextInEx instance in System Table.\r
**/\r
VOID\r
InputBarInit (\r
- VOID\r
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInEx\r
);\r
\r
/**\r
/** @file\r
implements menubar 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
/**\r
Function to dispatch the correct function based on a control-based key (ctrl+o...)\r
\r
- @param[in] Key The pressed key.\r
+ @param[in] KeyData The pressed key.\r
\r
@retval EFI_NOT_FOUND The key was not a valid control-based key \r
(an error was sent to the status bar).\r
**/\r
EFI_STATUS\r
MenuBarDispatchControlHotKey (\r
- IN CONST EFI_INPUT_KEY *Key\r
+ IN CONST EFI_KEY_DATA *KeyData\r
)\r
{\r
- \r
- if ((SCAN_CONTROL_Z < Key->UnicodeChar)\r
- ||(NULL == ControlBasedMenuFunctions[Key->UnicodeChar]))\r
+ UINT16 ControlIndex;\r
+\r
+ //\r
+ // Set to invalid value first.\r
+ //\r
+ ControlIndex = MAX_UINT16;\r
+\r
+ if ((KeyData->KeyState.KeyShiftState & EFI_SHIFT_STATE_VALID) == 0) {\r
+ //\r
+ // For those console devices that cannot report the CONTROL state,\r
+ // Ctrl+A is translated to 1 (UnicodeChar).\r
+ //\r
+ ControlIndex = KeyData->Key.UnicodeChar;\r
+ } else if (((KeyData->KeyState.KeyShiftState & (EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)) != 0) &&\r
+ ((KeyData->KeyState.KeyShiftState & ~(EFI_SHIFT_STATE_VALID | EFI_RIGHT_CONTROL_PRESSED | EFI_LEFT_CONTROL_PRESSED)) == 0)) {\r
+ //\r
+ // For those console devices that can report the CONTROL state,\r
+ // make sure only CONTROL is pressed.\r
+ //\r
+ if ((KeyData->Key.UnicodeChar >= L'A') && (KeyData->Key.UnicodeChar <= L'Z')) {\r
+ ControlIndex = KeyData->Key.UnicodeChar - L'A' + 1;\r
+ } else if ((KeyData->Key.UnicodeChar >= L'a') && (KeyData->Key.UnicodeChar <= L'z')) {\r
+ ControlIndex = KeyData->Key.UnicodeChar - L'a' + 1;\r
+ }\r
+ }\r
+ if ((SCAN_CONTROL_Z < ControlIndex)\r
+ ||(NULL == ControlBasedMenuFunctions[ControlIndex]))\r
{\r
return EFI_NOT_FOUND;\r
}\r
\r
- ControlBasedMenuFunctions[Key->UnicodeChar]();\r
+ ControlBasedMenuFunctions[ControlIndex]();\r
return EFI_SUCCESS;\r
}\r
\r
/** @file\r
Declares menubar 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
/**\r
Function to dispatch the correct function based on a control-based key (ctrl+o...)\r
\r
- @param[in] Key The pressed key.\r
+ @param[in] KeyData The pressed key.\r
\r
@retval EFI_NOT_FOUND The key was not a valid control-based key \r
(an error was sent to the status bar).\r
**/\r
EFI_STATUS\r
MenuBarDispatchControlHotKey (\r
- IN CONST EFI_INPUT_KEY *Key\r
+ IN CONST EFI_KEY_DATA *KeyData\r
);\r
\r
#endif\r
/** @file\r
data types that are used by editor\r
\r
- Copyright (c) 2005 - 2017, 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_BUFFER_IMAGE;\r
\r
typedef struct {\r
- HEFI_EDITOR_BUFFER_IMAGE *BufferImage;\r
-\r
- HEFI_EDITOR_COLOR_UNION ColorAttributes;\r
- HEFI_EDITOR_POSITION ScreenSize; // row number and column number\r
- BOOLEAN MouseSupported;\r
- EFI_SIMPLE_POINTER_PROTOCOL *MouseInterface;\r
- INT32 MouseAccumulatorX;\r
- INT32 MouseAccumulatorY;\r
-\r
- UINTN SelectStart; // starting from 1\r
- UINTN SelectEnd; // starting from 1\r
+ HEFI_EDITOR_BUFFER_IMAGE *BufferImage;\r
+\r
+ HEFI_EDITOR_COLOR_UNION ColorAttributes;\r
+ HEFI_EDITOR_POSITION ScreenSize; // row number and column number\r
+ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInputEx;\r
+ BOOLEAN MouseSupported;\r
+ EFI_SIMPLE_POINTER_PROTOCOL *MouseInterface;\r
+ INT32 MouseAccumulatorX;\r
+ INT32 MouseAccumulatorY;\r
+\r
+ UINTN SelectStart; // starting from 1\r
+ UINTN SelectEnd; // starting from 1\r
} HEFI_EDITOR_GLOBAL_EDITOR;\r
\r
#endif\r
- Instances of the other objects of the editor\r
- Main Interfaces\r
\r
- Copyright (c) 2005 - 2012, 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
0,\r
0\r
},\r
+ NULL,\r
FALSE,\r
NULL,\r
0,\r
VOID\r
)\r
{\r
- INT32 CurrentLine;\r
- CHAR16 * InfoString;\r
- EFI_INPUT_KEY Key;\r
-\r
- CurrentLine = 0;\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
&(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
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
- if (StrCmp (L"", StatusBarGetString()) == 0) {\r
- StatusBarSetStatusString (L"Disk Error. Try Again");\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
+ // 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