aboutsummaryrefslogtreecommitdiffstats
path: root/Library/UefiShellUfmCommandLib
diff options
context:
space:
mode:
Diffstat (limited to 'Library/UefiShellUfmCommandLib')
-rw-r--r--Library/UefiShellUfmCommandLib/UefiShellUfmCommandLib.c8
-rw-r--r--Library/UefiShellUfmCommandLib/actions.c73
-rw-r--r--Library/UefiShellUfmCommandLib/actions.h3
3 files changed, 80 insertions, 4 deletions
diff --git a/Library/UefiShellUfmCommandLib/UefiShellUfmCommandLib.c b/Library/UefiShellUfmCommandLib/UefiShellUfmCommandLib.c
index fb56e1b..95d4989 100644
--- a/Library/UefiShellUfmCommandLib/UefiShellUfmCommandLib.c
+++ b/Library/UefiShellUfmCommandLib/UefiShellUfmCommandLib.c
@@ -17,12 +17,12 @@ STATIC CONST struct shortcut shortcuts[] = {
{ACTION_ROUTINE, {SCAN_UP, 0x0}, jump_up, L"Up arrow", L"Movement"},
{ACTION_ROUTINE, {SCAN_DOWN, 0x0}, jump_down, L"Down arrow", L"Movement"},
{ACTION_ROUTINE, {SCAN_NULL, CHAR_TAB}, change_panel, L"TAB", L"Movement"},
- {ACTION_ROUTINE, {SCAN_NULL, CHAR_LINEFEED}, do_nothing, L"Enter", L"Movement"},
- {ACTION_ROUTINE, {SCAN_NULL, CHAR_CARRIAGE_RETURN}, do_nothing, L"Enter", L"Movement"},
+ {ACTION_ROUTINE, {SCAN_NULL, CHAR_LINEFEED}, execute, L"Enter", L"Movement"},
+ {ACTION_ROUTINE, {SCAN_NULL, CHAR_CARRIAGE_RETURN}, execute, L"Enter", L"Movement"},
{ACTION_ROUTINE, {SCAN_NULL, L' '}, mark, L"Space", L"Movement"},
{ACTION_CMD, {SCAN_F1, 0x0}, do_nothing, L"1", L"Help"},
- {ACTION_CMD, {SCAN_F2, 0x0}, do_nothing, L"2", L"Edit"},
- {ACTION_CMD, {SCAN_F3, 0x0}, do_nothing, L"3", L"Hex"},
+ {ACTION_CMD, {SCAN_F2, 0x0}, edit, L"2", L"Edit"},
+ {ACTION_CMD, {SCAN_F3, 0x0}, hexedit, L"3", L"Hex"},
{ACTION_CMD, {SCAN_F4, 0x0}, do_nothing, L"4", L"Copy"},
{ACTION_CMD, {SCAN_F5, 0x0}, do_nothing, L"5", L"RenMov"},
{ACTION_CMD, {SCAN_F6, 0x0}, do_nothing, L"6", L"Mkdir"},
diff --git a/Library/UefiShellUfmCommandLib/actions.c b/Library/UefiShellUfmCommandLib/actions.c
index 144e8f8..4bae7cf 100644
--- a/Library/UefiShellUfmCommandLib/actions.c
+++ b/Library/UefiShellUfmCommandLib/actions.c
@@ -18,6 +18,28 @@
#define LEFT_PANEL (fm_ctx.left)
#define RIGHT_PANEL (fm_ctx.right)
+STATIC EFI_STATUS shell_exec2(CONST CHAR16 *farg,
+ CONST CHAR16 *sarg, EFI_STATUS *cmd_status)
+{
+ EFI_STATUS status;
+ CHAR16 *cmd_line = NULL;
+ UINTN size = 0;
+
+ StrnCatGrow(&cmd_line, &size, farg, 0);
+ StrnCatGrow(&cmd_line, &size, sarg, 0);
+ status = ShellExecute(&gImageHandle, cmd_line, FALSE, NULL, cmd_status);
+ SHELL_FREE_NON_NULL(cmd_line);
+ return status;
+}
+
+STATIC VOID redraw()
+{
+ panel_refresh(LEFT_PANEL);
+ panel_refresh(RIGHT_PANEL);
+ menubar_refresh(MENUBAR);
+ cmdbar_refresh(CMDBAR);
+}
+
BOOLEAN jump_up(VOID)
{
panel_move_cursor(PANEL, PANEL->curline - 1);
@@ -38,12 +60,63 @@ BOOLEAN change_panel(VOID)
return TRUE;
}
+BOOLEAN execute(VOID)
+{
+ EFI_SHELL_FILE_INFO *file;
+ EFI_STATUS cmd_status;
+
+ if(!PANEL->cwd)
+ return panel_cd_to(PANEL, PANEL->fsa->full_name[PANEL->curline-1]);
+
+ file = dirl_getn(PANEL->dirs, PANEL->curline);
+ if((file->Info->Attribute & EFI_FILE_DIRECTORY) != 0)
+ return panel_cd_to(PANEL, file->FullName);
+
+ shell_exec2(L"", file->FullName, &cmd_status);
+ redraw();
+ return TRUE;
+}
+
BOOLEAN mark(VOID)
{
panel_mark_file(PANEL, PANEL->curline);
return TRUE;
}
+BOOLEAN edit(VOID)
+{
+ EFI_SHELL_FILE_INFO *file;
+ EFI_STATUS cmd_status;
+
+ if(!PANEL->cwd)
+ return FALSE;
+
+ file = dirl_getn(PANEL->dirs, PANEL->curline);
+ if((file->Info->Attribute & EFI_FILE_DIRECTORY) != 0)
+ return FALSE;
+
+ shell_exec2(L"edit ", file->FullName, &cmd_status);
+ redraw();
+ return TRUE;
+}
+
+BOOLEAN hexedit(VOID)
+{
+ EFI_SHELL_FILE_INFO *file;
+ EFI_STATUS cmd_status;
+
+ if(!PANEL->cwd)
+ return FALSE;
+
+ file = dirl_getn(PANEL->dirs, PANEL->curline);
+ if((file->Info->Attribute & EFI_FILE_DIRECTORY) != 0)
+ return FALSE;
+
+ shell_exec2(L"hexedit ", file->FullName, &cmd_status);
+ redraw();
+ return TRUE;
+}
+
BOOLEAN show_filesystems(VOID)
{
return panel_cd_to(PANEL, NULL);
diff --git a/Library/UefiShellUfmCommandLib/actions.h b/Library/UefiShellUfmCommandLib/actions.h
index 4a6b113..c6a7031 100644
--- a/Library/UefiShellUfmCommandLib/actions.h
+++ b/Library/UefiShellUfmCommandLib/actions.h
@@ -20,7 +20,10 @@ struct shortcut {
BOOLEAN jump_up(VOID);
BOOLEAN jump_down(VOID);
BOOLEAN change_panel(VOID);
+BOOLEAN execute(VOID);
BOOLEAN mark(VOID);
+BOOLEAN edit(VOID);
+BOOLEAN hexedit(VOID);
BOOLEAN show_filesystems(VOID);
BOOLEAN do_nothing(VOID);
BOOLEAN quit(VOID);