diff options
author | Joursoir <chat@joursoir.net> | 2021-12-08 21:21:02 +0300 |
---|---|---|
committer | Joursoir <chat@joursoir.net> | 2021-12-08 21:21:02 +0300 |
commit | 168b13a1c52b925a0aebc3f1857562c4bc6e753f (patch) | |
tree | 9f73d6c26ebb2833b74018dd73a06b2cfefd1af1 /Library/UefiShellUfmCommandLib/actions.c | |
parent | bbe0ce6ecd203f86cd10e5f4ed7c8362ec71e8e2 (diff) | |
download | ufm-168b13a1c52b925a0aebc3f1857562c4bc6e753f.tar.gz ufm-168b13a1c52b925a0aebc3f1857562c4bc6e753f.tar.bz2 ufm-168b13a1c52b925a0aebc3f1857562c4bc6e753f.zip |
add execution for files and text editors
Diffstat (limited to 'Library/UefiShellUfmCommandLib/actions.c')
-rw-r--r-- | Library/UefiShellUfmCommandLib/actions.c | 73 |
1 files changed, 73 insertions, 0 deletions
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); |