summaryrefslogtreecommitdiffstats
path: root/common/menu.c
Commit message (Collapse)AuthorAgeFilesLines
* output: use '[0m' to reset colorsMichael Olbrich2017-01-241-1/+1
| | | | | | | | | '[m' is supposed to have the same effect as '[0m'. However, some EFI implementations seem to ignore '[m', so use '[0m' everywhere to avoid rendering issues. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: sanitize menu_add_titleSascha Hauer2017-01-101-7/+5
| | | | | | | | 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-10/+71
| | | | | Signed-off-by: Aleksey Kuleshov <rndfax@yandex.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: add vi like key supportDu Huanpeng2016-04-191-6/+9
| | | | | | | | | | add vi like key support: j: down k: up <Space>: select Signed-off-by: Du Huanpeng <u74147@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/nfs'Sascha Hauer2014-03-071-1/+1
|\ | | | | | | | | Conflicts: defaultenv/defaultenv-2-base/bin/ifup
| * run_command: remove unused flag parameterSascha Hauer2014-03-071-1/+1
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | input: Add BB_ prefix to KEY_ definesSascha Hauer2014-02-171-9/+9
|/ | | | | | | Our KEY_ defines conflict with the standard Linux KEY_ defines, so add a BB_ prefix to them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: Make action callback optionalSascha Hauer2013-06-191-1/+2
| | | | | | | Someone calling menu_show might only be interested in the entry the user selected without having something in the action callback. Make it optional. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Fix gotoXY argument orderSascha Hauer2013-06-191-5/+5
| | | | | | | gotoXY has the argument order (y, x). Change this so that usage of this function feels more natural. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: Align entriesSascha Hauer2013-06-191-1/+1
| | | | | | | | | | | | | More than 9 menu entries in are single menu are not aligned anymore, like this: 8 entry8 9 entry9 10 entry10 Use %2d in the printf format specifier to align more than 9 entries. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: fix remove superfluous newline: change puts() -> printf("%s", )Fabio Porcedda2013-02-261-1/+1
| | | | | | | | | | | | Fix previous commit: 638f91b "fix compiler warnings: use puts() instead of printf()". Because puts() function add a newline, use instead printf("%s", ). Signed-off-by: Fabio Porcedda <fabio.porcedda@gmail.com> Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Cc: Vicente Bergas <vicencb@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fix compiler warnings: use puts() instead of printf()Fabio Porcedda2013-02-211-1/+1
| | | | | | | | | | | | | | | | Use puts() because printf() isn't necessary, to fix the following compiler warnings: /barebox/common/menu.c: In function ‘menu_show’: /barebox/common/menu.c:277:4: warning: format not a string literal and no format arguments [-Wformat-security] /barebox/scripts/omap4_usbboot.c: In function ‘read_asic_id’: /barebox/scripts/omap4_usbboot.c:101:3: warning: format not a string literal and no format arguments [-Wformat-security] Signed-off-by: Fabio Porcedda <fabio.porcedda@gmail.com> Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Cc: Vicente <vicencb@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: add number key supportJean-Christophe PLAGNIOL-VILLARD2012-08-091-0/+17
| | | | | | | | Allow to use the number key to jump to entry. if already on a entry % number_key jump to the next +10 one if exit Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/menu'Sascha Hauer2012-07-021-18/+25
|\
| * menu: implement KEY_HOME/KEY_ENDSascha Hauer2012-06-301-0/+9
| | | | | | | | | | | | To go to the first/last menu entry. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * menu: store repaint state in variableSascha Hauer2012-06-301-5/+12
| | | | | | | | | | | | | | | | Instead of calling print_menu_entry multiple times in each case, store the repaint state in a variable and call it once at the end to save a few bytes of binary space. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * menu: use read_keySascha Hauer2012-06-301-13/+4
| | | | | | | | | | | | | | We have the read_key function which reads a key and parses escape sequences. Use it in the menu instead of reimplementing this manually. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | menu: factor out a function to print an entrySascha Hauer2012-06-281-55/+15
|/ | | | | | To save a few bytes of binary space. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: fix support for "\n", "\n\r" and "\r"Jean-Christophe PLAGNIOL-VILLARD2012-04-231-1/+7
| | | | | | If "\n\r" or "\r\n" is ignore one. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* menu: enable the fancy color support only if HUSH is enabledJean-Christophe PLAGNIOL-VILLARD2012-04-151-6/+15
| | | | | | | So we can use the menu for the xloader too. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: add color fancy supportJean-Christophe PLAGNIOL-VILLARD2012-04-101-5/+45
| | | | | | | | | | | | You can now use AINSI color in the display of the menu or menu_entry. As the length of the string is not any more the same as the display simplify the invertion display managemnent. We just now invert the fontground and backgound on the string itself as done in Kconfig. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: fix double action when "\n\r" or "\r\n" is receivedJean-Christophe PLAGNIOL-VILLARD2012-04-101-2/+1
| | | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* readkey: add define for Ascii keysJean-Christophe PLAGNIOL-VILLARD2012-02-161-3/+3
| | | | | | this will simplify the usage of gpio keyboard Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* menu: fix command support as moduleJean-Christophe PLAGNIOL-VILLARD2011-07-051-1/+16
| | | | | | | add missing EXPORT_SYMBOL for nan static function Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Menu: add box style entryJean-Christophe PLAGNIOL-VILLARD2010-09-201-6/+32
| | | | | | | | | | | | | | | | | | | | | | | 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-1/+53
| | | | | | | | | | | 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: simplify usage for clientsSascha Hauer2010-08-301-8/+100
| | | | | | | | | | | | | | | 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: use an initialized struct list as menu listSascha Hauer2010-08-301-12/+7
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: use list_for_each_entry where appropriateSascha Hauer2010-08-301-16/+5
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: remove superfluous struct menu_entry member from struct menuSascha Hauer2010-08-301-10/+10
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: simplify menu_free with list_for_each_entry_safeSascha Hauer2010-08-301-9/+3
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* menu: initialize entries list in menu_allocSascha Hauer2010-08-301-4/+0
| | | | | | Otherwise menu_free fails when menu_add failed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Menu/cmd: add sub menu entry command supportJean-Christophe PLAGNIOL-VILLARD2010-08-301-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/+315
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>