From 5a2beb745f87a113bbb1db775d0450f65ceb2124 Mon Sep 17 00:00:00 2001 From: jcarsey Date: Wed, 20 Jul 2011 20:10:45 +0000 Subject: ShellPkg: Added the Ctrl based hot key and changed text editor's UI. * Add Ctrl-E hotkey for help * Add Ctrl based hotkey alternatives to function hotkeys * Don't show hotkey help on the main screen * Change the file buffer's row count for display to adjust the new screen format * Change the edit status bar location, the new edit status bar is in the last line * Change the location of the edit bar, the new edit input bar is in the last line Signed-off-by: kidzyoung reviewed-by: jcarsey reviewed-by: jljusten reviewed-by: jiang git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12036 6f19259b-4bc3-4df7-8a09-765794883524 --- .../HexEdit/BufferImage.c | 18 ++-- .../HexEdit/HexeditStrings.uni | Bin 8516 -> 12686 bytes .../HexEdit/MainHexEditor.c | 108 ++++++++++++++++++++- 3 files changed, 112 insertions(+), 14 deletions(-) (limited to 'ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit') diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c index 57c4a9c739..46926320a6 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/BufferImage.c @@ -832,7 +832,7 @@ HBufferImageRefresh ( // FStartRow = HBufferImage.LowVisibleRow; StartRow = 2; - EndRow = (HMainEditor.ScreenSize.Row - 4); + EndRow = (HMainEditor.ScreenSize.Row - 1); } // // no line @@ -1404,7 +1404,7 @@ HUnderCurrentScreen ( IN UINTN FileRow ) { - if (FileRow > HBufferImage.LowVisibleRow + (HMainEditor.ScreenSize.Row - 5) - 1) { + if (FileRow > HBufferImage.LowVisibleRow + (HMainEditor.ScreenSize.Row - 2) - 1) { return TRUE; } @@ -1712,8 +1712,8 @@ HBufferImagePageDown ( // // has next page // - if (HBufferImage.NumLines >= FRow + (HMainEditor.ScreenSize.Row - 5)) { - Gap = (HMainEditor.ScreenSize.Row - 5); + if (HBufferImage.NumLines >= FRow + (HMainEditor.ScreenSize.Row - 2)) { + Gap = (HMainEditor.ScreenSize.Row - 2); } else { // // MOVE CURSOR TO LAST LINE @@ -1764,8 +1764,8 @@ HBufferImagePageUp ( // // has previous page // - if (FRow > (HMainEditor.ScreenSize.Row - 5)) { - Gap = (HMainEditor.ScreenSize.Row - 5); + if (FRow > (HMainEditor.ScreenSize.Row - 2)) { + Gap = (HMainEditor.ScreenSize.Row - 2); } else { // // the first line of file will displayed on the first line of screen @@ -2392,12 +2392,12 @@ HBufferImageAdjustMousePosition ( // check whether new mouse row position is beyond screen // if not, adjust it // - if (TempY >= 2 && TempY <= (HMainEditor.ScreenSize.Row - 4)) { + if (TempY >= 2 && TempY <= (HMainEditor.ScreenSize.Row - 1)) { HBufferImage.MousePosition.Row = TempY; } else if (TempY < 2) { HBufferImage.MousePosition.Row = 2; - } else if (TempY > (HMainEditor.ScreenSize.Row - 4)) { - HBufferImage.MousePosition.Row = (HMainEditor.ScreenSize.Row - 4); + } else if (TempY > (HMainEditor.ScreenSize.Row - 1)) { + HBufferImage.MousePosition.Row = (HMainEditor.ScreenSize.Row - 1); } } diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexeditStrings.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexeditStrings.uni index 3389444f62..777258977d 100644 Binary files a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexeditStrings.uni and b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/HexeditStrings.uni differ diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c index 83b31992d2..357f8fa977 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/HexEdit/MainHexEditor.c @@ -65,6 +65,71 @@ HEFI_EDITOR_GLOBAL_EDITOR HMainEditorConst = { 1 }; +/** + Help info that will be displayed. +**/ +EFI_STRING_ID HexMainMenuHelpInfo[] = { + STRING_TOKEN(STR_HEXEDIT_HELP_TITLE), + STRING_TOKEN(STR_HEXEDIT_HELP_BLANK), + STRING_TOKEN(STR_HEXEDIT_HELP_LIST_TITLE), + STRING_TOKEN(STR_HEXEDIT_HELP_DIV), + STRING_TOKEN(STR_HEXEDIT_HELP_GO_TO_OFFSET), + STRING_TOKEN(STR_HEXEDIT_HELP_SAVE_BUFFER), + STRING_TOKEN(STR_HEXEDIT_HELP_EXIT), + STRING_TOKEN(STR_HEXEDIT_HELP_SELECT_START), + STRING_TOKEN(STR_HEXEDIT_HELP_SELECT_END), + STRING_TOKEN(STR_HEXEDIT_HELP_CUT), + STRING_TOKEN(STR_HEXEDIT_HELP_PASTE), + STRING_TOKEN(STR_HEXEDIT_HELP_OPEN_FILE), + STRING_TOKEN(STR_HEXEDIT_HELP_OPEN_DISK), + STRING_TOKEN(STR_HEXEDIT_HELP_OPEN_MEMORY), + STRING_TOKEN(STR_HEXEDIT_HELP_BLANK), + STRING_TOKEN(STR_HEXEDIT_HELP_EXIT_HELP), + STRING_TOKEN(STR_HEXEDIT_HELP_BLANK), + STRING_TOKEN(STR_HEXEDIT_HELP_BLANK), + STRING_TOKEN(STR_HEXEDIT_HELP_BLANK), + STRING_TOKEN(STR_HEXEDIT_HELP_BLANK), + STRING_TOKEN(STR_HEXEDIT_HELP_BLANK), + STRING_TOKEN(STR_HEXEDIT_HELP_BLANK), + STRING_TOKEN(STR_HEXEDIT_HELP_DIV), + 0 +}; + + +/** + show help menu. + + @retval EFI_SUCCESS The operation was successful. +**/ +EFI_STATUS +HMainCommandDisplayHelp ( + VOID + ) +{ + INTN CurrentLine=0; + CHAR16 * InfoString; + EFI_INPUT_KEY Key; + + // print helpInfo + for (CurrentLine = 0; 0 != HexMainMenuHelpInfo[CurrentLine]; CurrentLine++) { + InfoString = HiiGetString(gShellDebug1HiiHandle, HexMainMenuHelpInfo[CurrentLine] +, NULL); + ShellPrintEx (0,CurrentLine+1,L"%E%s%N",InfoString); + } + + // scan for ctrl+w + do { + gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); + } while(SCAN_CONTROL_W != Key.UnicodeChar); + + // update screen with buffer's info + HBufferImageNeedRefresh = TRUE; + HBufferImageOnlyLineNeedRefresh = FALSE; + HBufferImageRefresh (); + + return EFI_SUCCESS; +} + /** Move cursor to specified lines. @@ -1439,6 +1504,36 @@ HMainCommandOpenMemory ( } +MENU_ITEM_FUNCTION HexMainControlBasedMenuFunctions[] = { + NULL, + NULL, /* Ctrl - A */ + NULL, /* Ctrl - B */ + NULL, /* Ctrl - C */ + NULL, /* Ctrl - D */ + HMainCommandDisplayHelp, /* Ctrl - E */ + NULL, /* Ctrl - F */ + NULL, /* Ctrl - G */ + NULL, /* Ctrl - H */ + NULL, /* Ctrl - I */ + NULL, /* Ctrl - J */ + NULL, /* Ctrl - K */ + NULL, /* Ctrl - L */ + NULL, /* Ctrl - M */ + NULL, /* Ctrl - N */ + NULL, /* Ctrl - O */ + NULL, /* Ctrl - P */ + NULL, /* Ctrl - Q */ + NULL, /* Ctrl - R */ + NULL, /* Ctrl - S */ + NULL, /* Ctrl - T */ + NULL, /* Ctrl - U */ + NULL, /* Ctrl - V */ + NULL, /* Ctrl - W */ + NULL, /* Ctrl - X */ + NULL, /* Ctrl - Y */ + NULL, /* Ctrl - Z */ +}; + CONST EDITOR_MENU_ITEM HexEditorMenuItems[] = { { STRING_TOKEN(STR_HEXEDIT_LIBMENUBAR_GO_TO_OFFSET), @@ -1598,6 +1693,11 @@ HMainEditorInit ( return EFI_LOAD_ERROR; } + Status = ControlHotKeyInit (HexMainControlBasedMenuFunctions); + if (EFI_ERROR (Status)) { + ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_LIBEDITOR_MAINEDITOR_MAINMENU), gShellDebug1HiiHandle); + return EFI_LOAD_ERROR; + } Status = MenuBarInit (HexEditorMenuItems); if (EFI_ERROR (Status)) { ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_HEXEDIT_LIBEDITOR_MAINEDITOR_MAINMENU), gShellDebug1HiiHandle); @@ -1777,9 +1877,6 @@ HMainEditorRefresh ( } if (HEditorFirst) { - MenuBarRefresh ( - HMainEditor.ScreenSize.Row, - HMainEditor.ScreenSize.Column); HBufferImageRefresh (); } @@ -2138,8 +2235,9 @@ HMainEditorKeyInput ( // clear previous status string // StatusBarSetRefresh(); - - if (Key.ScanCode == SCAN_NULL) { + if (EFI_SUCCESS == MenuBarDispatchControlHotKey(&Key)) { + Status = EFI_SUCCESS; + } else if (Key.ScanCode == SCAN_NULL) { Status = HBufferImageHandleInput (&Key); } else if (((Key.ScanCode >= SCAN_UP) && (Key.ScanCode <= SCAN_PAGE_DOWN))) { Status = HBufferImageHandleInput (&Key); -- cgit v1.2.3