return NULL;
}
+static void menu_display_statusline(struct menu *m)
+{
+ struct bootmenu_entry *entry;
+ struct bootmenu_data *menu;
+
+ if (menu_default_choice(m, (void *)&entry) < 0)
+ return;
+
+ menu = entry->menu;
+
+ printf(ANSI_CURSOR_POSITION, 1, 1);
+ puts(ANSI_CLEAR_LINE);
+ printf(ANSI_CURSOR_POSITION, 2, 1);
+ puts(" *** U-Boot Boot Menu ***");
+ puts(ANSI_CLEAR_LINE_TO_END);
+ printf(ANSI_CURSOR_POSITION, 3, 1);
+ puts(ANSI_CLEAR_LINE);
+
+ /* First 3 lines are bootmenu header + 2 empty lines between entries */
+ printf(ANSI_CURSOR_POSITION, menu->count + 5, 1);
+ puts(ANSI_CLEAR_LINE);
+ printf(ANSI_CURSOR_POSITION, menu->count + 6, 1);
+ puts(" Press UP/DOWN to move, ENTER to select");
+ puts(ANSI_CLEAR_LINE_TO_END);
+ printf(ANSI_CURSOR_POSITION, menu->count + 7, 1);
+ puts(ANSI_CLEAR_LINE);
+}
+
static void bootmenu_show(int delay)
{
int init = 0;
if (!bootmenu)
return;
- menu = menu_create(NULL, bootmenu->delay, 1, bootmenu_print_entry,
- bootmenu_choice_entry, bootmenu);
+ menu = menu_create(NULL, bootmenu->delay, 1, menu_display_statusline,
+ bootmenu_print_entry, bootmenu_choice_entry,
+ bootmenu);
if (!menu) {
bootmenu_destroy(bootmenu);
return;
#endif
}
-void menu_display_statusline(struct menu *m)
-{
- struct bootmenu_entry *entry;
- struct bootmenu_data *menu;
-
- if (menu_default_choice(m, (void *)&entry) < 0)
- return;
-
- menu = entry->menu;
-
- printf(ANSI_CURSOR_POSITION, 1, 1);
- puts(ANSI_CLEAR_LINE);
- printf(ANSI_CURSOR_POSITION, 2, 1);
- puts(" *** U-Boot Boot Menu ***");
- puts(ANSI_CLEAR_LINE_TO_END);
- printf(ANSI_CURSOR_POSITION, 3, 1);
- puts(ANSI_CLEAR_LINE);
-
- /* First 3 lines are bootmenu header + 2 empty lines between entries */
- printf(ANSI_CURSOR_POSITION, menu->count + 5, 1);
- puts(ANSI_CLEAR_LINE);
- printf(ANSI_CURSOR_POSITION, menu->count + 6, 1);
- puts(" Press UP/DOWN to move, ENTER to select");
- puts(ANSI_CLEAR_LINE_TO_END);
- printf(ANSI_CURSOR_POSITION, menu->count + 7, 1);
- puts(ANSI_CLEAR_LINE);
-}
-
#ifdef CONFIG_AUTOBOOT_MENU_SHOW
int menu_show(int bootdelay)
{
int timeout;
char *title;
int prompt;
+ void (*display_statusline)(struct menu *);
void (*item_data_print)(void *);
char *(*item_choice)(void *);
void *item_choice_data;
return NULL;
}
-__weak void menu_display_statusline(struct menu *m)
-{
-}
-
/*
* Display a menu so the user can make a choice of an item. First display its
* title, if any, and then each item in the menu.
puts(m->title);
putc('\n');
}
- menu_display_statusline(m);
+ if (m->display_statusline)
+ m->display_statusline(m);
menu_items_iter(m, menu_item_print, NULL);
}
* timeout. If 1, the user will be prompted for input regardless of the value
* of timeout.
*
+ * display_statusline - If not NULL, will be called to show a statusline when
+ * the menu is displayed.
+ *
* item_data_print - If not NULL, will be called for each item when the menu
* is displayed, with the pointer to the item's data passed as the argument.
* If NULL, each item's key will be printed instead. Since an item's key is
* insufficient memory available to create the menu.
*/
struct menu *menu_create(char *title, int timeout, int prompt,
+ void (*display_statusline)(struct menu *),
void (*item_data_print)(void *),
char *(*item_choice)(void *),
void *item_choice_data)
m->default_item = NULL;
m->prompt = prompt;
m->timeout = timeout;
+ m->display_statusline = display_statusline;
m->item_data_print = item_data_print;
m->item_choice = item_choice;
m->item_choice_data = item_choice_data;
struct menu;
struct menu *menu_create(char *title, int timeout, int prompt,
+ void (*display_statusline)(struct menu *),
void (*item_data_print)(void *),
char *(*item_choice)(void *),
void *item_choice_data);
int menu_get_choice(struct menu *m, void **choice);
int menu_item_add(struct menu *m, char *item_key, void *item_data);
int menu_destroy(struct menu *m);
-void menu_display_statusline(struct menu *m);
int menu_default_choice(struct menu *m, void **choice);
/**