diff options
Diffstat (limited to 'ShellPkg/Library/UefiShellDebug1CommandsLib/Edit')
-rw-r--r-- | ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c | 22 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c | 160 | ||||
-rw-r--r-- | ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/TextEditStrings.uni | bin | 7356 -> 11484 bytes |
3 files changed, 150 insertions, 32 deletions
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c index 8f7c870bb1..9a2427f4e9 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c @@ -53,7 +53,7 @@ EFI_EDITOR_FILE_BUFFER FileBufferConst = { //
// the whole edit area needs to be refreshed
//
-STATIC BOOLEAN FileBufferNeedRefresh;
+BOOLEAN FileBufferNeedRefresh;
//
// only the current line in edit area needs to be refresh
@@ -627,11 +627,11 @@ FileBufferRefresh ( Link = Link->ForwardLink;
Row++;
- } while (Link != FileBuffer.ListHead && Row <= (MainEditor.ScreenSize.Row - 4));
+ } while (Link != FileBuffer.ListHead && Row <= (MainEditor.ScreenSize.Row - 1));
//
// while not file end and not screen full
//
- while (Row <= (MainEditor.ScreenSize.Row - 4)) {
+ while (Row <= (MainEditor.ScreenSize.Row - 1)) {
EditorClearLine (Row, MainEditor.ScreenSize.Column, MainEditor.ScreenSize.Row);
Row++;
}
@@ -2300,8 +2300,8 @@ FileBufferPageDown ( //
// has next page
//
- if (FileBuffer.NumLines >= FRow + (MainEditor.ScreenSize.Row - 5)) {
- Gap = (MainEditor.ScreenSize.Row - 5);
+ if (FileBuffer.NumLines >= FRow + (MainEditor.ScreenSize.Row - 2)) {
+ Gap = (MainEditor.ScreenSize.Row - 2);
} else {
//
// MOVE CURSOR TO LAST LINE
@@ -2352,8 +2352,8 @@ FileBufferPageUp ( //
// has previous page
//
- if (FRow > (MainEditor.ScreenSize.Row - 5)) {
- Gap = (MainEditor.ScreenSize.Row - 5);
+ if (FRow > (MainEditor.ScreenSize.Row - 2)) {
+ Gap = (MainEditor.ScreenSize.Row - 2);
} else {
//
// the first line of file will displayed on the first line of screen
@@ -2575,7 +2575,7 @@ UnderCurrentScreen ( //
// if is to the under of the screen
//
- if (FileRow > FileBuffer.LowVisibleRange.Row + (MainEditor.ScreenSize.Row - 5) - 1) {
+ if (FileRow > FileBuffer.LowVisibleRange.Row + (MainEditor.ScreenSize.Row - 2) - 1) {
return TRUE;
}
@@ -3207,12 +3207,12 @@ FileBufferAdjustMousePosition ( // check whether new mouse row position is beyond screen
// if not, adjust it
//
- if (CoordinateY >= 2 && CoordinateY <= (MainEditor.ScreenSize.Row - 4)) {
+ if (CoordinateY >= 2 && CoordinateY <= (MainEditor.ScreenSize.Row - 1)) {
FileBuffer.MousePosition.Row = CoordinateY;
} else if (CoordinateY < 2) {
FileBuffer.MousePosition.Row = 2;
- } else if (CoordinateY > (MainEditor.ScreenSize.Row - 4)) {
- FileBuffer.MousePosition.Row = (MainEditor.ScreenSize.Row - 4);
+ } else if (CoordinateY > (MainEditor.ScreenSize.Row - 1)) {
+ FileBuffer.MousePosition.Row = (MainEditor.ScreenSize.Row - 1);
}
}
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c index 1a8f39a229..460433e373 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c @@ -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
@@ -62,6 +88,16 @@ MainCommandSaveFile ( );
/**
+ show help menu.
+
+ @retval EFI_SUCCESS The operation was successful.
+**/
+EFI_STATUS
+MainCommandDisplayHelp (
+ VOID
+ );
+
+/**
exit editor
@retval EFI_SUCCESS The operation was successful.
@@ -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;
}
-EFI_EDITOR_COLOR_ATTRIBUTES OriginalColors;
-INTN OriginalMode;
-
-//
-// the first time editor launch
-//
-BOOLEAN EditorFirst;
-
-//
-// it's time editor should exit
-//
-BOOLEAN EditorExit;
+/**
+ show help menu.
-BOOLEAN EditorMouseAction;
+ @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);
-extern EFI_EDITOR_FILE_BUFFER FileBuffer;
+ // update screen with file buffer's info
+ FileBufferRestorePosition ();
+ FileBufferNeedRefresh = TRUE;
+ FileBufferOnlyLineNeedRefresh = FALSE;
+ FileBufferRefresh ();
-extern BOOLEAN FileBufferMouseNeedRefresh;
+ return EFI_SUCCESS;
+}
-extern EFI_EDITOR_FILE_BUFFER FileBufferBackupVar;
+EFI_EDITOR_COLOR_ATTRIBUTES OriginalColors;
+INTN OriginalMode;
-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
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/TextEditStrings.uni b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/TextEditStrings.uni Binary files differindex 09a0d47b28..a61cae33d3 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/TextEditStrings.uni +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/TextEditStrings.uni |