aboutsummaryrefslogtreecommitdiffstats
path: root/src/hci
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2024-06-18 15:17:03 -0700
committerMichael Brown <mcb30@ipxe.org>2024-06-18 15:17:03 -0700
commit76e0933d781474acf52000cba0afaebe32361667 (patch)
tree7dd18decf7175080a9e086a583574571efbd192d /src/hci
parentbf98eae5daeb0b9281562e70fdf3768a629adde8 (diff)
downloadipxe-76e0933d781474acf52000cba0afaebe32361667.tar.gz
[hci] Rename "item" command's first parameter from "label" to "name"
Switch terminology for the "item" command from "item <label> <text>" to "item <name> <text>", in preparation for repurposing the "item" command to cover interactive forms as well as menus. Since this renaming affects only a positional parameter, it does not break compatibility with any existing scripts. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/hci')
-rw-r--r--src/hci/commands/menu_cmd.c12
-rw-r--r--src/hci/tui/menu_ui.c26
2 files changed, 19 insertions, 19 deletions
diff --git a/src/hci/commands/menu_cmd.c b/src/hci/commands/menu_cmd.c
index 76bce8695..8b6d2a9f1 100644
--- a/src/hci/commands/menu_cmd.c
+++ b/src/hci/commands/menu_cmd.c
@@ -135,7 +135,7 @@ static struct option_descriptor item_opts[] = {
/** "item" command descriptor */
static struct command_descriptor item_cmd =
COMMAND_DESC ( struct item_options, item_opts, 0, MAX_ARGUMENTS,
- "[<label> [<text>]]" );
+ "[<name> [<text>]]" );
/**
* The "item" command
@@ -148,7 +148,7 @@ static int item_exec ( int argc, char **argv ) {
struct item_options opts;
struct menu *menu;
struct menu_item *item;
- char *label = NULL;
+ char *name = NULL;
char *text = NULL;
int rc;
@@ -156,9 +156,9 @@ static int item_exec ( int argc, char **argv ) {
if ( ( rc = parse_options ( argc, argv, &item_cmd, &opts ) ) != 0 )
goto err_parse_options;
- /* Parse label, if present */
+ /* Parse name, if present */
if ( ! opts.is_gap )
- label = argv[optind++]; /* May be NULL */
+ name = argv[optind++]; /* May be NULL */
/* Parse text, if present */
if ( optind < argc ) {
@@ -174,7 +174,7 @@ static int item_exec ( int argc, char **argv ) {
goto err_parse_menu;
/* Add menu item */
- item = add_menu_item ( menu, label, ( text ? text : "" ),
+ item = add_menu_item ( menu, name, ( text ? text : "" ),
opts.key, opts.is_default );
if ( ! item ) {
rc = -ENOMEM;
@@ -257,7 +257,7 @@ static int choose_exec ( int argc, char **argv ) {
/* Store setting */
if ( ( rc = storef_setting ( setting.settings, &setting.setting,
- item->label ) ) != 0 ) {
+ item->name ) ) != 0 ) {
printf ( "Could not store \"%s\": %s\n",
setting.setting.name, strerror ( rc ) );
goto err_store;
diff --git a/src/hci/tui/menu_ui.c b/src/hci/tui/menu_ui.c
index f9dd9d100..cac61a7da 100644
--- a/src/hci/tui/menu_ui.c
+++ b/src/hci/tui/menu_ui.c
@@ -99,7 +99,7 @@ static void draw_menu_item ( struct menu_ui *ui, unsigned int index ) {
if ( item ) {
/* Draw separators in a different colour */
- if ( ! item->label )
+ if ( ! item->name )
color_set ( CPAIR_SEPARATOR, NULL );
/* Highlight if this is the selected item */
@@ -225,7 +225,7 @@ static int menu_loop ( struct menu_ui *ui, struct menu_item **selected ) {
continue;
}
ui->scroll.current = i;
- if ( item->label ) {
+ if ( item->name ) {
chosen = 1;
} else {
move = +1;
@@ -239,7 +239,7 @@ static int menu_loop ( struct menu_ui *ui, struct menu_item **selected ) {
while ( move ) {
move = jump_scroll_move ( &ui->scroll, move );
item = menu_item ( ui->menu, ui->scroll.current );
- if ( item->label )
+ if ( item->name )
break;
}
@@ -254,7 +254,7 @@ static int menu_loop ( struct menu_ui *ui, struct menu_item **selected ) {
/* Record selection */
item = menu_item ( ui->menu, ui->scroll.current );
assert ( item != NULL );
- assert ( item->label != NULL );
+ assert ( item->name != NULL );
*selected = item;
} while ( ( rc == 0 ) && ! chosen );
@@ -275,7 +275,7 @@ int show_menu ( struct menu *menu, unsigned long timeout,
struct menu_item *item;
struct menu_ui ui;
char buf[ MENU_COLS + 1 /* NUL */ ];
- int labelled_count = 0;
+ int named_count = 0;
int rc;
/* Initialise UI */
@@ -284,12 +284,12 @@ int show_menu ( struct menu *menu, unsigned long timeout,
ui.scroll.rows = MENU_ROWS;
ui.timeout = timeout;
list_for_each_entry ( item, &menu->items, list ) {
- if ( item->label ) {
- if ( ! labelled_count )
+ if ( item->name ) {
+ if ( ! named_count )
ui.scroll.current = ui.scroll.count;
- labelled_count++;
+ named_count++;
if ( select ) {
- if ( strcmp ( select, item->label ) == 0 )
+ if ( strcmp ( select, item->name ) == 0 )
ui.scroll.current = ui.scroll.count;
} else {
if ( item->is_default )
@@ -298,10 +298,10 @@ int show_menu ( struct menu *menu, unsigned long timeout,
}
ui.scroll.count++;
}
- if ( ! labelled_count ) {
- /* Menus with no labelled items cannot be selected
- * from, and will seriously confuse the navigation
- * logic. Refuse to display any such menus.
+ if ( ! named_count ) {
+ /* Menus with no named items cannot be selected from,
+ * and will seriously confuse the navigation logic.
+ * Refuse to display any such menus.
*/
return -ENOENT;
}