5 typedef void (*menu_finish_callback)(struct menu_s *menu);
9 char *name; /* Menu name */
10 int num_options; /* Number of options in this menu */
11 int flags; /* Various flags - see below */
12 int option_align; /* Aligns options to a field width of this much characters if != 0 */
14 struct menu_option_s **options; /* Pointer to this menu's options */
15 menu_finish_callback callback; /* Called when the menu closes */
19 * type: Type of the option (see below)
20 * name: Name to display for this option
21 * help: Optional help string
22 * id : optional id number
23 * sys : pointer for system-specific data, init to NULL and don't touch
26 #define OPTION_PREAMBLE \
36 * There are a number of different layouts for menu options depending
37 * on their types. Currently there are the following possibilities:
40 * This entry links to a new menu.
43 * A simple on/off toggle entry. Booleans can be either yes/no, 0/1 or on/off.
44 * Optionally, this entry can enable/disable a set of other options. An example would
45 * be to enable/disable on-board USB, and if enabled give access to further options like
46 * irq settings, base address etc.
49 * A single line/limited number of characters text entry box. Text can be restricted
50 * to a certain charset (digits/hex digits/all/custom). Result is also available as an
54 * One-of-many type of selection entry. User may choose on of a set of strings, which
55 * maps to a specific value for the variable.
58 * Selecting this calls an entry-specific routine. This can be used for saving contents etc.
61 * Display and behaviour of this entry is defined by a set of callbacks.
64 #define MENU_SUBMENU_TYPE 0
65 typedef struct menu_submenu_s
69 menu_t * submenu; /* Pointer to the submenu */
72 #define MENU_BOOLEAN_TYPE 1
73 typedef struct menu_boolean_s
77 char *variable; /* Name of the variable to getenv()/setenv() */
78 int subtype; /* Subtype (on/off, 0/1, yes/no, enable/disable), see below */
79 int mutex; /* Bit mask of options to enable/disable. Bit 0 is the option
80 immediately following this one, bit 1 is the next one etc.
81 bit 7 = 0 means to disable when this option is off,
82 bit 7 = 1 means to disable when this option is on.
83 An option is disabled when the type field's upper bit is set */
86 /* BOOLEAN Menu flags */
87 #define MENU_BOOLEAN_ONOFF 0x01
88 #define MENU_BOOLEAN_01 0x02
89 #define MENU_BOOLEAN_YESNO 0x03
90 #define MENU_BOOLEAN_ENDIS 0x04
91 #define MENU_BOOLEAN_TYPE_MASK 0x07
94 #define MENU_TEXT_TYPE 2
95 typedef struct menu_text_s
99 char *variable; /* Name of the variable to getenv()/setenv() */
100 int maxchars; /* Max number of characters */
101 char *charset; /* Optional charset to use */
102 int flags; /* Flags - see below */
105 /* TEXT entry menu flags */
106 #define MENU_TEXT_NUMERIC 0x01
107 #define MENU_TEXT_HEXADECIMAL 0x02
108 #define MENU_TEXT_FREE 0x03
109 #define MENU_TEXT_TYPE_MASK 0x07
112 #define MENU_SELECTION_TYPE 3
113 typedef struct menu_select_option_s
115 char *map_from; /* Map this variable contents ... */
116 char *map_to; /* ... to this menu text and vice versa */
117 } menu_select_option_t;
119 typedef struct menu_select_s
123 int num_options; /* Number of mappings */
124 menu_select_option_t **options;
125 /* Option list array */
129 #define MENU_ROUTINE_TYPE 4
130 typedef void (*menu_routine_callback)(struct menu_routine_s *);
132 typedef struct menu_routine_s
135 menu_routine_callback callback;
136 /* routine to be called */
137 void *user_data; /* User data, don't care for system */
141 #define MENU_CUSTOM_TYPE 5
142 typedef void (*menu_custom_draw)(struct menu_custom_s *);
143 typedef void (*menu_custom_key)(struct menu_custom_s *, int);
145 typedef struct menu_custom_s
148 menu_custom_draw drawfunc;
149 menu_custom_key keyfunc;
154 * The menu option superstructure
156 typedef struct menu_option_s
160 menu_submenu_t m_sub_menu;
161 menu_boolean_t m_boolean;
163 menu_select_t m_select;
164 menu_routine_t m_routine;
168 /* Init the menu system. Returns <0 on error */
169 int menu_init(menu_t *root);
171 /* Execute a single menu. Returns <0 on error */
172 int menu_do(menu_t *menu);