summaryrefslogtreecommitdiffstats
path: root/commands/menu.c
Commit message (Collapse)AuthorAgeFilesLines
* menu: sanitize menu_add_titleSascha Hauer2017-01-101-1/+1
| | | | | | | | passing a string to menu_add_title() which then gets free by this function is just plain ugly. Pass it a const char * which gets duplicated in menu_add_title() when necessary. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* rework menu so that it can support multiline titlesAleksey Kuleshov2016-09-051-4/+19
| | | | | Signed-off-by: Aleksey Kuleshov <rndfax@yandex.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: menu: check return pointer properlyLucas Stach2016-07-071-1/+1
| | | | | | | | The called functions return error codes encoded in the pointer, so the NULL check will never be true. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* stdio: replace fprintf(stderr,...) with eprintfSascha Hauer2016-04-151-2/+2
| | | | | | | We have a shortcut for fprintf(stderr, so use it. This is done to be able to remove fprintf in the next step. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: harmonize in-barebox documentationHolger Schurig2014-05-141-29/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch does probably too much, but it's hard (and very cumbersome/time consuming) to break it out. What is does is this: * each command has one short description, e.g. "list MUX configuration" * made sure the short descriptions start lowercase * each command has one usage. That string contains just the options, e.g. "[-npn]". It's not part of the long help text. * that is, it doesn't say "[OPTIONS]" anymore, every usable option is listed by character in this (short) option string (the long description is in the long help text, as before) * help texts have been reworked, to make them - sometimes smaller - sometimes describe the options better - more often present themselves in a nicer format * all long help texts are now created with BUSYBOX_CMD_HELP_ macros, no more 'static const __maybe_unused char cmd_foobar_help[]' * made sure the long help texts starts uppercase * because cmdtp->name and cmdtp->opts together provide the new usage, all "Usage: foobar" texts have been removed from the long help texts * BUSYBOX_CMD_HELP_TEXT() provides the trailing newline by itself, this is nicer in the source code * BUSYBOX_CMD_HELP_OPT() provides the trailing newline by itself * made sure no line gets longer than 77 characters * delibertely renamed cmdtp->usage, so that we can get compile-time errors (e.g. in out-of-tree modules that use register_command() * the 'help' command can now always emit the usage, even without compiled long help texts * 'help -v' gives a list of commands with their short description, this is similar like the old "help" command before my patchset * 'help -a' gives out help of all commands Signed-off-by: Holger Schurig <holgerschurig@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: group 'help' outputHolger Schurig2014-05-141-0/+1
| | | | | | | | | | | | | | | | | | | The old output of "help" was just producing a long list, that usually scrolled of the screen (even on a X11 terminal). This list is more compact, and also sorted by groups. The old output format (plus grouping) is now available with 'help -v'. Example: Information commands: ?, devinfo, help, iomem, meminfo, version Boot commands: boot, bootm, go, loadb, loads, loadx, loady, saves, uimage ... Signed-off-by: Holger Schurig <holgerschurig@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Treewide: remove address of the Free Software FoundationSascha Hauer2012-09-171-4/+0
| | | | | | | The FSF address has changed in the past. Instead of updating it each time the address changes, just drop it completely treewide. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: fix non command management supportJean-Christophe PLAGNIOL-VILLARD2012-04-251-8/+9
| | | | | | the auto select is always available Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* commands: remove struct command pointer from commandsSascha Hauer2012-02-271-1/+1
| | | | | | This is unused in all commands and thus can be removed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Cosmetic fixes, including format attributes for printf() and friends.Krzysztof Halasa2010-12-211-1/+1
| | | | | Signed-off-by: Krzysztof HaƂasa <khc@pm.waw.pl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Menu: add box style entryJean-Christophe PLAGNIOL-VILLARD2010-09-201-7/+23
| | | | | | | | | | | | | | | | | | | | | | | this will allow you to create a box style entry via C API by specifying the type as struct menu_entry me = { .display "test", .type = MENU_ENTRY_BOX, .box_state = 1, .action = action_to_run, } and via shell menu -e -a -m <menu> -c <command> [-R] [-b 0|1] -d <description> menu -e -a -m <menu> -u submenu -d [-b 0|1] <description> -b with 0 for not selected and 1 for selected and -c for the command to run when changing state Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: add auto select supportJean-Christophe PLAGNIOL-VILLARD2010-09-201-3/+21
| | | | | | | | | | | this will allow to automaticaly run an entry if the user do no choice this is usefull for boot menu as example with menu -s -m boot -A 3 -d "Auto Boot in" Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: shell fix do_menu_selectJean-Christophe PLAGNIOL-VILLARD2010-09-201-1/+1
| | | | | | | invert the error report Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: simplify usage for clientsSascha Hauer2010-08-301-41/+7
| | | | | | | | | | | | | | | Clients now only have to call menu_add_submenu or menu_add_command_entry instead of allocating many strings. This also fixes some problems in the menu code. The priv field in struct menu_entry was a pointer to struct menu or a pointer to an allocated string. It was never freed, only had to be freed when it was an allocated string. The reference to a submenu is now kept as a string and not to the menu itself. The code checked the existence of the submenu when creating it, but crashed when the submenu was removed and referenced afterwards. Now the code hapily allows references to nonexistant menus but complains during runtime when the menu is not there. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: do not go to free if there's nothing to freeSascha Hauer2010-08-301-2/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: use an initialized struct list as menu listSascha Hauer2010-08-301-0/+3
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: use list_for_each_entry where appropriateSascha Hauer2010-08-301-7/+2
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: remove superfluous struct menu_entry member from struct menuSascha Hauer2010-08-301-1/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: Use strdup instead of malloc/strncpySascha Hauer2010-08-301-26/+5
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Menu/cmd: add sub menu entry command supportJean-Christophe PLAGNIOL-VILLARD2010-08-301-9/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | this will simplify the creation of navigation link as this menu -a -m boot -d "Boot Menu" menu -a -m network -d "Network settings" menu -e -a -m network -u boot -d "Back" menu -e -a -m boot -u network -d "Network settings ->" menu -e -a -m boot -c reset -R -d "Reset" menu -e -a -m boot -c clear -d "Exit" menu -s -m boot in C struct menu m_boot = { .name = "boot", .display = "Boot Menu", }; struct menu m_network = { .name = "network", .display = "Network settings", }; struct menu_entry e_to_network = { .display = "Network settings ->", .action = menu_action_show, .priv = &m_network, }; struct menu_entry e_to_boot = { .display = "Back", .action = menu_action_show, .priv = &m_boot, }; struct menu_entry e_reset = { .display = "Reset", .action = menu_action_run, .priv = "reset", }; struct menu_entry e_exit = { .display = "Exit", .action = menu_action_run, .non_re_ent = 1, .priv = "clear", }; void menu_test(void) { menu_add(&m_boot); menu_add(&m_network); menu_add_entry(&m_boot, &e_to_network); menu_add_entry(&m_boot, &e_reset); menu_add_entry(&m_boot, &e_exit); menu_add_entry(&m_network, &e_to_boot); menu_show(&m_boot); } Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Add Menu FrameworkJean-Christophe PLAGNIOL-VILLARD2010-08-301-0/+481
Introduce a menu framework that allow us to create list menu to simplify barebox and make it more user-frendly This kind of menu is very usefull when you do not have a keyboard or a serial console attached to your board to allow you to interract with barebox For the develloper part, The framework introduce two API 1) C that allow you to create menu, submenu, entry and complex menu action 2) Command that allow you as the C API to create menu, submenu, entry and complex menu action but this time the actions will be store in a function and then be evaluated and excecuted at runtime. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>