aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2021-11-30 17:45:29 +0300
committerJoursoir <chat@joursoir.net>2021-11-30 17:45:29 +0300
commit727390c04c56c60fbe4369d76565f5607d468e11 (patch)
tree8af2ede1274f3dcc93804aa653ff13908a54d251 /Library
parenta3bf9b1132d9e495a462df05c9733090a641bbf1 (diff)
downloadufm-727390c04c56c60fbe4369d76565f5607d468e11.tar.gz
ufm-727390c04c56c60fbe4369d76565f5607d468e11.tar.bz2
ufm-727390c04c56c60fbe4369d76565f5607d468e11.zip
panel: make panel_move_cursor()
Diffstat (limited to 'Library')
-rw-r--r--Library/UefiShellUfmCommandLib/panel.c27
-rw-r--r--Library/UefiShellUfmCommandLib/panel.h10
2 files changed, 37 insertions, 0 deletions
diff --git a/Library/UefiShellUfmCommandLib/panel.c b/Library/UefiShellUfmCommandLib/panel.c
index cc33aee..c8d3565 100644
--- a/Library/UefiShellUfmCommandLib/panel.c
+++ b/Library/UefiShellUfmCommandLib/panel.c
@@ -278,3 +278,30 @@ VOID panel_release(struct panel_ctx *p)
FreePool(p);
}
+BOOLEAN panel_move_cursor(struct panel_ctx *p, UINTN line)
+{
+ UINTN oldline = p->curline;
+ UINTN maxlen = (p->cwd) ? p->dirs->len : p->fsa->len;
+
+ if(line < 1 || line > maxlen)
+ return FALSE;
+
+ if(line < p->start_entry || line >= (p->start_entry + p->list_lines) ||
+ p->start_entry == 0)
+ {
+ p->start_entry = line - ((line-1) % p->list_lines);
+
+ if(!p->cwd)
+ display_fs(p, p->start_entry);
+ else
+ display_files(p, p->start_entry);
+ }
+ else
+ UNHIGHLIGHT_LINE_AS_CURRENT(p, oldline);
+
+ p->curline = line;
+ update_file_info(p);
+ HIGHLIGHT_LINE_AS_CURRENT(p, p->curline);
+ return TRUE;
+}
+
diff --git a/Library/UefiShellUfmCommandLib/panel.h b/Library/UefiShellUfmCommandLib/panel.h
index 2706dd6..1d71258 100644
--- a/Library/UefiShellUfmCommandLib/panel.h
+++ b/Library/UefiShellUfmCommandLib/panel.h
@@ -50,4 +50,14 @@ struct panel_ctx *panel_alloc(struct screen *scr, CONST CHAR16 *path,
*/
VOID panel_release(struct panel_ctx *p);
+/*
+ * Moves cursor position to specified line
+ *
+ * p: the panel on which to operate
+ * line: the line coordinate (starts from 1)
+ *
+ * return: FALSE upon failure and TRUE upon successful completion
+*/
+BOOLEAN panel_move_cursor(struct panel_ctx *p, UINTN line);
+
#endif /* UFM_PANEL_H */