aboutsummaryrefslogtreecommitdiffstats
path: root/Library/UefiShellUfmCommandLib
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2021-11-30 17:34:17 +0300
committerJoursoir <chat@joursoir.net>2021-11-30 17:36:25 +0300
commita40e13b2de56e6c518230a337f5e62d53e74201f (patch)
treec4fc6faf57c7d6cef2cb9f44cc2682d4d5cdccca /Library/UefiShellUfmCommandLib
parentd6a10b886f4cb64e1291a6ca87ffaa238c07a449 (diff)
downloadufm-a40e13b2de56e6c518230a337f5e62d53e74201f.tar.gz
ufm-a40e13b2de56e6c518230a337f5e62d53e74201f.tar.bz2
ufm-a40e13b2de56e6c518230a337f5e62d53e74201f.zip
panel: add support for displaying files
Diffstat (limited to 'Library/UefiShellUfmCommandLib')
-rw-r--r--Library/UefiShellUfmCommandLib/panel.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/Library/UefiShellUfmCommandLib/panel.c b/Library/UefiShellUfmCommandLib/panel.c
index b02bddb..df1be44 100644
--- a/Library/UefiShellUfmCommandLib/panel.c
+++ b/Library/UefiShellUfmCommandLib/panel.c
@@ -13,6 +13,7 @@
#define SIZE_COLS 7
#define MODIFYTIME_COLS 12
+#define MONTH_LENGTH 3
#define HIGHLIGHT_LINE_AS_CURRENT(panel, line) \
highlight_line(panel, line, -1, EFI_CYAN)
@@ -23,6 +24,27 @@
#define UNHIGHLIGHT_LINE_AS_MARK(panel, line) \
highlight_line(panel, line, EFI_LIGHTGRAY, -1)
+STATIC CONST CHAR16 *get_month_string(UINT8 month)
+{
+ switch(month) {
+ case 1: return L"jan";
+ case 2: return L"feb";
+ case 3: return L"mar";
+ case 4: return L"apr";
+ case 5: return L"may";
+ case 6: return L"jun";
+ case 7: return L"jul";
+ case 8: return L"aug";
+ case 9: return L"sep";
+ case 10: return L"oct";
+ case 11: return L"nov";
+ case 12: return L"dec";
+ default: break;
+ }
+
+ return L"xxx";
+}
+
STATIC VOID display_fs(struct panel_ctx *p, UINTN start_index)
{
UINTN line, i;
@@ -41,6 +63,59 @@ STATIC VOID display_fs(struct panel_ctx *p, UINTN start_index)
}
}
+STATIC VOID display_files(struct panel_ctx *p, UINTN start_index)
+{
+ UINTN i;
+ EFI_SHELL_FILE_INFO *list_head, *node;
+ EFI_TIME cur_time, *mod_time;
+ BOOLEAN directory;
+
+ gRT->GetTime(&cur_time, NULL);
+ list_head = p->dirs->list_head;
+
+ node = dirl_getn(p->dirs, start_index);
+ for(i = 0; i <= p->list_lines; i++)
+ {
+ if(IsNull(&list_head->Link, &node->Link) ||
+ ((start_index + i) > p->dirs->len)) {
+ clear_list_line(p, i);
+ continue;
+ }
+
+ mod_time = &(node->Info->ModificationTime);
+ directory = FALSE;
+ if((node->Info->Attribute & EFI_FILE_DIRECTORY) != 0)
+ directory = TRUE;
+
+ // mvwprintf doesn't support "-*.*s" :(
+
+ // column "name"
+ mvwprintf(p->wlist, 0, i, L"%c%-*s", directory ? L'/' : L' ',
+ p->name_cols - 1, node->FileName);
+
+ // column "size"
+ if(directory)
+ mvwprintf(p->wlist, p->name_cols, i, L"%c%*.*s%c", BOXDRAW_VERTICAL,
+ SIZE_COLS, SIZE_COLS, L"<dir>");
+ else
+ mvwprintf(p->wlist, p->name_cols, i, L"%c%*d%c", BOXDRAW_VERTICAL,
+ SIZE_COLS, node->Info->FileSize);
+
+ // column "modify time"
+ mvwprintf(p->wlist, p->wlist->width - MODIFYTIME_COLS - 1, i,
+ L"%c%*s %02u ", BOXDRAW_VERTICAL, MONTH_LENGTH,
+ get_month_string(mod_time->Month), mod_time->Day);
+ if(cur_time.Year == mod_time->Year)
+ mvwprintf(p->wlist, p->wlist->width - MODIFYTIME_COLS + 7, i,
+ L"%02u:%02u", mod_time->Hour, mod_time->Minute);
+ else
+ mvwprintf(p->wlist, p->wlist->width - MODIFYTIME_COLS + 7, i,
+ L"%5u", mod_time->Year);
+
+ node = (EFI_SHELL_FILE_INFO *)GetNextNode(&list_head->Link, &node->Link);
+ }
+}
+
STATIC VOID highlight_line(struct panel_ctx *p, UINTN line, INT32 fg, INT32 bg)
{
CHAR16 *str;