aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2024-06-20 16:20:05 -0700
committerMichael Brown <mcb30@ipxe.org>2024-06-20 16:24:38 -0700
commit039019039e89aedf4c5a0d81c351638a1e036335 (patch)
tree8af0293694ba5095d2bb9e6cb318d4e27e9726a2
parentc8e50bb0fd3d9d1629e5c78f92bbf7bc9af84f2c (diff)
downloadipxe-039019039e89aedf4c5a0d81c351638a1e036335.zip
ipxe-039019039e89aedf4c5a0d81c351638a1e036335.tar.gz
ipxe-039019039e89aedf4c5a0d81c351638a1e036335.tar.bz2
[dynui] Allow for multiple flags on a user interface item
Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/core/dynui.c6
-rw-r--r--src/hci/commands/dynui_cmd.c7
-rw-r--r--src/hci/tui/menu_ui.c2
-rw-r--r--src/include/ipxe/dynui.h12
4 files changed, 17 insertions, 10 deletions
diff --git a/src/core/dynui.c b/src/core/dynui.c
index 33218f5..3d139c0 100644
--- a/src/core/dynui.c
+++ b/src/core/dynui.c
@@ -96,13 +96,13 @@ struct dynamic_ui * create_dynui ( const char *name, const char *title ) {
* @v dynui Dynamic user interface
* @v name Name, or NULL
* @v text Text, or NULL
+ * @v flags Flags
* @v shortcut Shortcut key
- * @v is_default Item is the default item
* @ret item User interface item, or NULL on failure
*/
struct dynamic_item * add_dynui_item ( struct dynamic_ui *dynui,
const char *name, const char *text,
- int shortcut, int is_default ) {
+ unsigned int flags, int shortcut ) {
struct dynamic_item *item;
size_t name_len;
size_t text_len;
@@ -132,8 +132,8 @@ struct dynamic_item * add_dynui_item ( struct dynamic_ui *dynui,
strcpy ( text_copy, text );
item->text = text_copy;
item->index = dynui->count++;
+ item->flags = flags;
item->shortcut = shortcut;
- item->is_default = is_default;
/* Add to list of items */
list_add_tail ( &item->list, &dynui->items );
diff --git a/src/hci/commands/dynui_cmd.c b/src/hci/commands/dynui_cmd.c
index dbaa669..557c5db 100644
--- a/src/hci/commands/dynui_cmd.c
+++ b/src/hci/commands/dynui_cmd.c
@@ -148,6 +148,7 @@ static int item_exec ( int argc, char **argv ) {
struct item_options opts;
struct dynamic_ui *dynui;
struct dynamic_item *item;
+ unsigned int flags = 0;
char *name = NULL;
char *text = NULL;
int rc;
@@ -174,8 +175,10 @@ static int item_exec ( int argc, char **argv ) {
goto err_parse_dynui;
/* Add dynamic user interface item */
- item = add_dynui_item ( dynui, name, ( text ? text : "" ),
- opts.key, opts.is_default );
+ if ( opts.is_default )
+ flags |= DYNUI_DEFAULT;
+ item = add_dynui_item ( dynui, name, ( text ? text : "" ), flags,
+ opts.key );
if ( ! item ) {
rc = -ENOMEM;
goto err_add_dynui_item;
diff --git a/src/hci/tui/menu_ui.c b/src/hci/tui/menu_ui.c
index 00cdab8..b7b52ee 100644
--- a/src/hci/tui/menu_ui.c
+++ b/src/hci/tui/menu_ui.c
@@ -267,7 +267,7 @@ int show_menu ( struct dynamic_ui *dynui, unsigned long timeout,
if ( strcmp ( select, item->name ) == 0 )
ui.scroll.current = ui.scroll.count;
} else {
- if ( item->is_default )
+ if ( item->flags & DYNUI_DEFAULT )
ui.scroll.current = ui.scroll.count;
}
}
diff --git a/src/include/ipxe/dynui.h b/src/include/ipxe/dynui.h
index f38d448..5ba0070 100644
--- a/src/include/ipxe/dynui.h
+++ b/src/include/ipxe/dynui.h
@@ -35,17 +35,21 @@ struct dynamic_item {
const char *text;
/** Index */
unsigned int index;
+ /** Flags */
+ unsigned int flags;
/** Shortcut key */
int shortcut;
- /** Is default item */
- int is_default;
};
+/** Dynamic user interface item is default selection */
+#define DYNUI_DEFAULT 0x0001
+
extern struct dynamic_ui * create_dynui ( const char *name, const char *title );
extern struct dynamic_item * add_dynui_item ( struct dynamic_ui *dynui,
const char *name,
- const char *text, int shortcut,
- int is_default );
+ const char *text,
+ unsigned int flags,
+ int shortcut );
extern void destroy_dynui ( struct dynamic_ui *dynui );
extern struct dynamic_ui * find_dynui ( const char *name );
extern struct dynamic_item * dynui_item ( struct dynamic_ui *dynui,