[dynui] Allow for multiple flags on a user interface item

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2024-06-20 16:20:05 -07:00
parent c8e50bb0fd
commit 039019039e
4 changed files with 17 additions and 10 deletions

View File

@@ -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;

View File

@@ -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;
}
}