]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - common/menu.c
Merge branch 'marex@denx.de' of git://git.denx.de/u-boot-staging
[karo-tx-uboot.git] / common / menu.c
index f0048233633da58649d45c96130e89eb0f76b6ff..aa16c9a199d772f7bd9971e401efdb883bf06895 100644 (file)
@@ -87,10 +87,12 @@ static inline void *menu_item_print(struct menu *m,
                                struct menu_item *item,
                                void *extra)
 {
-       if (!m->item_data_print)
-               printf("%s\n", item->key);
-       else
+       if (!m->item_data_print) {
+               puts(item->key);
+               putc('\n');
+       } else {
                m->item_data_print(item->data);
+       }
 
        return NULL;
 }
@@ -111,14 +113,24 @@ static inline void *menu_item_destroy(struct menu *m,
        return NULL;
 }
 
+void __menu_display_statusline(struct menu *m)
+{
+       return;
+}
+void menu_display_statusline(struct menu *m)
+       __attribute__ ((weak, alias("__menu_display_statusline")));
+
 /*
  * 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.
  */
 static inline void menu_display(struct menu *m)
 {
-       if (m->title)
-               printf("%s:\n", m->title);
+       if (m->title) {
+               puts(m->title);
+               putc('\n');
+       }
+       menu_display_statusline(m);
 
        menu_items_iter(m, menu_item_print, NULL);
 }
@@ -218,15 +230,18 @@ static inline int menu_interactive_choice(struct menu *m, void **choice)
 
                menu_display(m);
 
-               readret = readline_into_buffer("Enter choice: ", cbuf);
+               readret = readline_into_buffer("Enter choice: ", cbuf,
+                               m->timeout);
 
                if (readret >= 0) {
                        choice_item = menu_item_by_key(m, cbuf);
 
-                       if (!choice_item)
+                       if (!choice_item) {
                                printf("%s not found\n", cbuf);
+                               m->timeout = 0;
+                       }
                } else {
-                       printf("^C\n");
+                       puts("^C\n");
                        return -EINTR;
                }
        }