diff options
author | Aleksey Kuleshov <rndfax@yandex.ru> | 2016-08-18 17:05:03 +0300 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2016-09-05 08:26:47 +0200 |
commit | bf2abf90501858a97bf1e05024d963800312a5c4 (patch) | |
tree | b60fe9ed29b48a16e3cfd65992aca9832d8a6491 /commands | |
parent | d0b8f4e0752fbe5e44fd9b2e6143ce80c0f5d4eb (diff) | |
download | barebox-bf2abf90501858a97bf1e05024d963800312a5c4.tar.gz barebox-bf2abf90501858a97bf1e05024d963800312a5c4.tar.xz |
rework menu so that it can support multiline titles
Signed-off-by: Aleksey Kuleshov <rndfax@yandex.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r-- | commands/menu.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/commands/menu.c b/commands/menu.c index e1079fd51e..72db26e5d1 100644 --- a/commands/menu.c +++ b/commands/menu.c @@ -22,6 +22,7 @@ #include <menu.h> #include <getopt.h> #include <errno.h> +#include <libbb.h> #include <linux/err.h> typedef enum { @@ -146,9 +147,7 @@ static int do_menu_add(struct cmd_menu *cm) if (!m->name) goto free; - m->display = strdup(cm->description); - if (!m->display) - goto free; + menu_add_title(m, strdup(cm->description)); ret = menu_add(m); @@ -271,7 +270,23 @@ static int do_menu_list(struct cmd_menu *cm) } list_for_each_entry(m, &menus->list, list) { - printf("%s: %s\n", m->name, m->display? m->display : m->name); + printf("%s: ", m->name); + if (m->display_lines) { + static char outstr[256]; + int i; + + printf("\n"); + for (i = 0; i < m->display_lines; i++) + /* Conform to menu rendering logic */ + if (IS_ENABLED(CONFIG_SHELL_HUSH)) { + process_escape_sequence(m->display[i], outstr, 256); + printf("\t%s\n", outstr); + } else { + printf("\t%s\n", m->display[i]); + } + } else { + printf("%s\n", m->name); + } if (is_entry(cm)) print_entries(m); } |