|
@@ -36,6 +36,7 @@ struct menu {
|
|
int timeout;
|
|
int timeout;
|
|
char *title;
|
|
char *title;
|
|
int prompt;
|
|
int prompt;
|
|
|
|
+ void (*display_statusline)(struct menu *);
|
|
void (*item_data_print)(void *);
|
|
void (*item_data_print)(void *);
|
|
char *(*item_choice)(void *);
|
|
char *(*item_choice)(void *);
|
|
void *item_choice_data;
|
|
void *item_choice_data;
|
|
@@ -106,10 +107,6 @@ static inline void *menu_item_destroy(struct menu *m,
|
|
return NULL;
|
|
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
|
|
* 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.
|
|
* title, if any, and then each item in the menu.
|
|
@@ -120,7 +117,8 @@ static inline void menu_display(struct menu *m)
|
|
puts(m->title);
|
|
puts(m->title);
|
|
putc('\n');
|
|
putc('\n');
|
|
}
|
|
}
|
|
- menu_display_statusline(m);
|
|
|
|
|
|
+ if (m->display_statusline)
|
|
|
|
+ m->display_statusline(m);
|
|
|
|
|
|
menu_items_iter(m, menu_item_print, NULL);
|
|
menu_items_iter(m, menu_item_print, NULL);
|
|
}
|
|
}
|
|
@@ -344,6 +342,9 @@ int menu_item_add(struct menu *m, char *item_key, void *item_data)
|
|
* timeout. If 1, the user will be prompted for input regardless of the value
|
|
* timeout. If 1, the user will be prompted for input regardless of the value
|
|
* of timeout.
|
|
* 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
|
|
* 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.
|
|
* 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
|
|
* If NULL, each item's key will be printed instead. Since an item's key is
|
|
@@ -360,6 +361,7 @@ int menu_item_add(struct menu *m, char *item_key, void *item_data)
|
|
* insufficient memory available to create the menu.
|
|
* insufficient memory available to create the menu.
|
|
*/
|
|
*/
|
|
struct menu *menu_create(char *title, int timeout, int prompt,
|
|
struct menu *menu_create(char *title, int timeout, int prompt,
|
|
|
|
+ void (*display_statusline)(struct menu *),
|
|
void (*item_data_print)(void *),
|
|
void (*item_data_print)(void *),
|
|
char *(*item_choice)(void *),
|
|
char *(*item_choice)(void *),
|
|
void *item_choice_data)
|
|
void *item_choice_data)
|
|
@@ -374,6 +376,7 @@ struct menu *menu_create(char *title, int timeout, int prompt,
|
|
m->default_item = NULL;
|
|
m->default_item = NULL;
|
|
m->prompt = prompt;
|
|
m->prompt = prompt;
|
|
m->timeout = timeout;
|
|
m->timeout = timeout;
|
|
|
|
+ m->display_statusline = display_statusline;
|
|
m->item_data_print = item_data_print;
|
|
m->item_data_print = item_data_print;
|
|
m->item_choice = item_choice;
|
|
m->item_choice = item_choice;
|
|
m->item_choice_data = item_choice_data;
|
|
m->item_choice_data = item_choice_data;
|