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
This commit is contained in:
jcarsey
2011-07-20 20:10:45 +00:00
parent f7c8bd9f9d
commit 5a2beb745f
10 changed files with 363 additions and 61 deletions

View File

@ -15,6 +15,32 @@
#include "TextEditor.h"
#include "EditStatusBar.h"
#include "EditInputBar.h"
#include "EditMenuBar.h"
//
// the first time editor launch
//
BOOLEAN EditorFirst;
//
// it's time editor should exit
//
BOOLEAN EditorExit;
BOOLEAN EditorMouseAction;
extern EFI_EDITOR_FILE_BUFFER FileBuffer;
extern BOOLEAN FileBufferNeedRefresh;
extern BOOLEAN FileBufferOnlyLineNeedRefresh;
extern BOOLEAN FileBufferMouseNeedRefresh;
extern EFI_EDITOR_FILE_BUFFER FileBufferBackupVar;
EFI_EDITOR_GLOBAL_EDITOR MainEditor;
/**
Load a file from disk to editor
@ -61,6 +87,16 @@ MainCommandSaveFile (
VOID
);
/**
show help menu.
@retval EFI_SUCCESS The operation was successful.
**/
EFI_STATUS
MainCommandDisplayHelp (
VOID
);
/**
exit editor
@ -121,6 +157,66 @@ MainCommandPasteLine (
VOID
);
/**
Help info that will be displayed.
**/
EFI_STRING_ID MainMenuHelpInfo[] = {
STRING_TOKEN(STR_EDIT_HELP_TITLE),
STRING_TOKEN(STR_EDIT_HELP_BLANK),
STRING_TOKEN(STR_EDIT_HELP_LIST_TITLE),
STRING_TOKEN(STR_EDIT_HELP_DIV),
STRING_TOKEN(STR_EDIT_HELP_GO_TO_LINE),
STRING_TOKEN(STR_EDIT_HELP_SAVE_FILE),
STRING_TOKEN(STR_EDIT_HELP_EXIT),
STRING_TOKEN(STR_EDIT_HELP_SEARCH),
STRING_TOKEN(STR_EDIT_HELP_SEARCH_REPLACE),
STRING_TOKEN(STR_EDIT_HELP_CUT_LINE),
STRING_TOKEN(STR_EDIT_HELP_PASTE_LINE),
STRING_TOKEN(STR_EDIT_HELP_OPEN_FILE),
STRING_TOKEN(STR_EDIT_HELP_FILE_TYPE),
STRING_TOKEN(STR_EDIT_HELP_BLANK),
STRING_TOKEN(STR_EDIT_HELP_EXIT_HELP),
STRING_TOKEN(STR_EDIT_HELP_BLANK),
STRING_TOKEN(STR_EDIT_HELP_BLANK),
STRING_TOKEN(STR_EDIT_HELP_BLANK),
STRING_TOKEN(STR_EDIT_HELP_BLANK),
STRING_TOKEN(STR_EDIT_HELP_BLANK),
STRING_TOKEN(STR_EDIT_HELP_BLANK),
STRING_TOKEN(STR_EDIT_HELP_BLANK),
STRING_TOKEN(STR_EDIT_HELP_DIV),
0
};
MENU_ITEM_FUNCTION MainControlBasedMenuFunctions[] = {
NULL,
NULL, /* Ctrl - A */
NULL, /* Ctrl - B */
NULL, /* Ctrl - C */
NULL, /* Ctrl - D */
MainCommandDisplayHelp, /* Ctrl - E */
MainCommandSearch, /* Ctrl - F */
MainCommandGotoLine, /* Ctrl - G */
NULL, /* Ctrl - H */
NULL, /* Ctrl - I */
NULL, /* Ctrl - J */
MainCommandCutLine, /* Ctrl - K */
NULL, /* Ctrl - L */
NULL, /* Ctrl - M */
NULL, /* Ctrl - N */
MainCommandOpenFile, /* Ctrl - O */
NULL, /* Ctrl - P */
MainCommandExit, /* Ctrl - Q */
MainCommandSearchReplace, /* Ctrl - R */
MainCommandSaveFile, /* Ctrl - S */
MainCommandSwitchFileType, /* Ctrl - T */
MainCommandPasteLine, /* Ctrl - U */
NULL, /* Ctrl - V */
NULL, /* Ctrl - W */
NULL, /* Ctrl - X */
NULL, /* Ctrl - Y */
NULL, /* Ctrl - Z */
};
EDITOR_MENU_ITEM MainMenuItems[] = {
{
STRING_TOKEN(STR_EDIT_LIBMENUBAR_GO_TO_LINE),
@ -169,6 +265,11 @@ EDITOR_MENU_ITEM MainMenuItems[] = {
STRING_TOKEN(STR_EDIT_LIBMENUBAR_F9),
MainCommandSwitchFileType
},
{
STRING_TOKEN(STR_EDIT_LIBMENUBAR_FILE_TYPE),
STRING_TOKEN(STR_EDIT_LIBMENUBAR_F11),
MainCommandSwitchFileType
},
{
0,
@ -1248,28 +1349,43 @@ MainCommandSaveFile (
return Status;
}
/**
show help menu.
@retval EFI_SUCCESS The operation was successful.
**/
EFI_STATUS
MainCommandDisplayHelp (
VOID
)
{
INTN CurrentLine=0;
CHAR16 * InfoString;
EFI_INPUT_KEY Key;
// print helpInfo
for (CurrentLine = 0; 0 != MainMenuHelpInfo[CurrentLine]; CurrentLine++) {
InfoString = HiiGetString(gShellDebug1HiiHandle, MainMenuHelpInfo[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 file buffer's info
FileBufferRestorePosition ();
FileBufferNeedRefresh = TRUE;
FileBufferOnlyLineNeedRefresh = FALSE;
FileBufferRefresh ();
return EFI_SUCCESS;
}
EFI_EDITOR_COLOR_ATTRIBUTES OriginalColors;
INTN OriginalMode;
//
// the first time editor launch
//
BOOLEAN EditorFirst;
//
// it's time editor should exit
//
BOOLEAN EditorExit;
BOOLEAN EditorMouseAction;
extern EFI_EDITOR_FILE_BUFFER FileBuffer;
extern BOOLEAN FileBufferMouseNeedRefresh;
extern EFI_EDITOR_FILE_BUFFER FileBufferBackupVar;
EFI_EDITOR_GLOBAL_EDITOR MainEditor;
//
// basic initialization for MainEditor
@ -1387,6 +1503,7 @@ MainEditorInit (
return EFI_LOAD_ERROR;
}
Status = ControlHotKeyInit (MainControlBasedMenuFunctions);
Status = MenuBarInit (MainMenuItems);
if (EFI_ERROR (Status)) {
ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN(STR_EDIT_LIBEDITOR_MAINMENU), gShellDebug1HiiHandle);
@ -1508,7 +1625,6 @@ MainEditorRefresh (
}
if (EditorFirst) {
MenuBarRefresh (MainEditor.ScreenSize.Row, MainEditor.ScreenSize.Column);
FileBufferRestorePosition ();
}
@ -1730,15 +1846,17 @@ MainEditorKeyInput (
//
// dispatch to different components' key handling function
//
if ((Key.ScanCode == SCAN_NULL) || ((Key.ScanCode >= SCAN_UP) && (Key.ScanCode <= SCAN_PAGE_DOWN))) {
if (EFI_NOT_FOUND != MenuBarDispatchControlHotKey(&Key)) {
Status = EFI_SUCCESS;
} else if ((Key.ScanCode == SCAN_NULL) || ((Key.ScanCode >= SCAN_UP) && (Key.ScanCode <= SCAN_PAGE_DOWN))) {
Status = FileBufferHandleInput (&Key);
} else if ((Key.ScanCode >= SCAN_F1) && (Key.ScanCode <= SCAN_F12)) {
Status = MenuBarDispatchFunctionKey (&Key);
} else {
StatusBarSetStatusString (L"Unknown Command");
FileBufferMouseNeedRefresh = FALSE;
FileBufferMouseNeedRefresh = FALSE;
}
if (Status != EFI_SUCCESS && Status != EFI_OUT_OF_RESOURCES) {
//
// not already has some error status