-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdisplay-menu.h
66 lines (54 loc) · 1.21 KB
/
display-menu.h
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
#include <menu.h>
/*
* Menu data structures
*/
// selection --> items must be filled
// value --> no items but config->min and config-> max are set
// bits --> config->min and config-> max are 0
typedef enum {
selection, onoff, value, bits
} menu_style_t;
//
// the menu itself - one window on the screen
//
typedef struct menu_t {
const char *title;
const char *descr;
struct menu_t *back;
const struct menuconfig_t *config;
const struct menuitem_t *items;
int size;
MENU *cmenu;
WINDOW *cwindow;
} menu_t;
//
// configuration menu - executing a function with selected item as parameter
//
typedef int (*getfunc_t)(const void *, const void *);
typedef void (*setfunc_t)(const void *, const void *, int);
typedef struct menuconfig_t {
menu_style_t style;
getfunc_t getfunc;
setfunc_t setfunc;
int reg;
int mask;
int min;
int max;
int def;
} menuconfig_t;
//
// execute a function (void or integer) for a selected item
//
typedef void (*vfunc_t)(void);
typedef void (*ifunc_t)(int);
typedef struct menuitem_t {
int index;
char *name;
char *descr;
menu_t *submenu;
vfunc_t vfunc;
ifunc_t ifunc;
} menuitem_t;
void menu_create(menu_t *, menu_t *);
void menu_open(menu_t *);
void menu_handle(int);