/** @file\r
Implements editor 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
/**\r
Save current file to disk, you can save to current file name or\r
save to another file name.\r
- \r
+\r
@retval EFI_SUCCESS The file was saved correctly.\r
@retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
@retval EFI_LOAD_ERROR A file access error occured.\r
/**\r
Save current file to disk, you can save to current file name or\r
save to another file name.\r
- \r
+\r
@retval EFI_SUCCESS The file was saved correctly.\r
@retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
@retval EFI_LOAD_ERROR A file access error occured.\r
CHAR16 *FileName;\r
BOOLEAN OldFile;\r
CHAR16 *Str;\r
- SHELL_FILE_HANDLE FileHandle; \r
+ SHELL_FILE_HANDLE FileHandle;\r
EFI_FILE_INFO *Info;\r
\r
//\r
StatusBarSetStatusString (L"Open Failed");\r
FreePool (FileName);\r
return EFI_SUCCESS;\r
- } \r
+ }\r
\r
Info = ShellGetFileInfo(FileHandle);\r
if (Info == NULL) {\r
StatusBarSetStatusString (L"Access Denied");\r
FreePool (FileName);\r
return (EFI_SUCCESS);\r
- } \r
- \r
+ }\r
+\r
if (Info->Attribute & EFI_FILE_READ_ONLY) {\r
StatusBarSetStatusString (L"Access Denied - Read Only");\r
FreePool (Info);\r
{\r
INT32 CurrentLine;\r
CHAR16 *InfoString;\r
- EFI_INPUT_KEY Key;\r
- \r
+ EFI_KEY_DATA KeyData;\r
+ EFI_STATUS Status;\r
+ UINTN EventIndex;\r
+\r
//\r
- // print helpInfo \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
+ 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
+ (KeyData.KeyState.KeyShiftState == EFI_SHIFT_STATE_VALID)) {\r
+ //\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_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/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
+ 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
+ FileBufferRefresh ();\r
\r
return EFI_SUCCESS;\r
}\r
0\r
},\r
NULL,\r
+ NULL,\r
FALSE,\r
NULL\r
};\r
@retval EFI_LOAD_ERROR A load error occured.\r
**/\r
EFI_STATUS\r
-EFIAPI\r
MainEditorInit (\r
VOID\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
Status = gBS->HandleProtocol (\r
- gST->ConIn,\r
+ gST->ConsoleInHandle,\r
&gEfiSimplePointerProtocolGuid,\r
(VOID**)&MainEditor.MouseInterface\r
);\r
return EFI_LOAD_ERROR;\r
}\r
\r
- InputBarInit ();\r
+ InputBarInit (MainEditor.TextInputEx);\r
\r
Status = FileBufferInit ();\r
if (EFI_ERROR (Status)) {\r
@retval EFI_LOAD_ERROR A load error occured.\r
**/\r
EFI_STATUS\r
-EFIAPI\r
MainEditorCleanup (\r
VOID\r
)\r
Refresh the main editor component.\r
**/\r
VOID\r
-EFIAPI\r
MainEditorRefresh (\r
VOID\r
)\r
//\r
// call the components refresh function\r
//\r
- if (EditorFirst \r
- || StrCmp (FileBufferBackupVar.FileName, FileBuffer.FileName) != 0 \r
- || FileBufferBackupVar.FileType != FileBuffer.FileType \r
- || FileBufferBackupVar.FileModified != FileBuffer.FileModified \r
+ if (EditorFirst\r
+ || StrCmp (FileBufferBackupVar.FileName, FileBuffer.FileName) != 0\r
+ || FileBufferBackupVar.FileType != FileBuffer.FileType\r
+ || FileBufferBackupVar.FileModified != FileBuffer.FileModified\r
|| FileBufferBackupVar.ReadOnly != FileBuffer.ReadOnly) {\r
\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
+ || FileBufferBackupVar.FilePosition.Row != FileBuffer.FilePosition.Row\r
+ || FileBufferBackupVar.FilePosition.Column != FileBuffer.FilePosition.Column\r
|| FileBufferBackupVar.ModeInsert != FileBuffer.ModeInsert\r
|| StatusBarGetRefresh()) {\r
\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
FileBufferRestorePosition ();\r
}\r
\r
+ FileBufferRefresh ();\r
+\r
//\r
// EditorFirst is now set to FALSE\r
//\r
@return The X location of the mouse.\r
**/\r
INT32\r
-EFIAPI\r
GetTextX (\r
IN INT32 GuidX\r
)\r
@return The Y location of the mouse.\r
**/\r
INT32\r
-EFIAPI\r
GetTextY (\r
IN INT32 GuidY\r
)\r
@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
@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
+ BOOLEAN NoShiftState;\r
\r
do {\r
\r
}\r
}\r
\r
- Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);\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
- //\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 = 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
- // not already has some error status\r
+ // NoShiftState: TRUE when no shift key is pressed.\r
//\r
- if (StatusBarGetString() != NULL && StrCmp (L"", StatusBarGetString()) == 0) {\r
- StatusBarSetStatusString (L"Disk Error. Try Again");\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
\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
@retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
**/\r
EFI_STATUS\r
-EFIAPI\r
MainEditorSetCutLine (\r
EFI_EDITOR_LINE *Line\r
)\r
@retval EFI_SUCCESS The operation was successful.\r
**/\r
EFI_STATUS\r
-EFIAPI\r
MainEditorBackup (\r
VOID\r
)\r
{\r
FileBufferBackup ();\r
- \r
+\r
return EFI_SUCCESS;\r
}\r