aboutsummaryrefslogtreecommitdiffstats
path: root/Library/UefiShellUfmCommandLib/panel.h
blob: 9006416b36c105c0cb0de92333a41146991a0780 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#ifndef UFM_PANEL_H
#define UFM_PANEL_H

#include <Uefi.h>

struct screen;
struct window;
struct dir_list;
struct fs_array;

struct panel_ctx {
	struct window *wbg; // static window
	struct window *wcwd, *wlist, *wfname, *wmarked; // dynamic windows
	UINTN name_cols;

	CHAR16 *cwd; // current work directory
	// if cwd == NULL then we are showing filesystems now

	UINTN curline; // current line
	struct dir_list *dirs; // directory contents
	struct fs_array *fsa; // aviable file systems

	UINTN list_lines; // number of lines in the files list
	UINTN start_entry; // file index at the beginning of the files list
	UINTN marked; // count of marked files
};

/*
 * Creates a panel with given parameters. Filled with files from the
 * specified path
 *
 * scr: the information of the screen
 * path: the pointer to path string
 * cols: the number of columns
 * lines: the number of lines
 * x: the column coordinate (starts from 0) of upper left corner of the window
 * y: the line coordinate (starts from 0) of upper left corner of the window
 *
 * return: A pointer to the allocated structure or NULL if allocation fails
*/
struct panel_ctx *panel_alloc(struct screen *scr, CONST CHAR16 *path,
		INT32 cols, INT32 lines, INT32 x, INT32 y);

/*
 * Deletes the panel, frees the structure
 *
 * p: the panel on which to operate
 *
 * return: VOID
*/
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);

/*
 * Changes the working directory
 *
 * p: the panel on which to operate
 * path: the pointer to path string
 *
 * return: FALSE upon failure and TRUE upon successful completion
*/
BOOLEAN panel_cd_to(struct panel_ctx *p, CONST CHAR16 *path);

/*
 * Changes the active state
 *
 * p: the panel on which to operate
 * active: TRUE if the panel should be activated. FALSE if the
 *         panel should be disabled
 *
 * return: VOID
*/
VOID panel_set_active(struct panel_ctx *p, BOOLEAN active);

/*
 * Marks the file as selected. Supports work only with files.
 *
 * 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_mark_file(struct panel_ctx *p, UINTN line);

/*
 * Gets character from the input device.
 *
 * p: the panel on which to operate
 *
 * return: A pointer to a buffer that is filled in with the keystroke
 *         information for the key that was pressed.
*/
EFI_INPUT_KEY panel_getch(struct panel_ctx *p);

#endif /* UFM_PANEL_H */