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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>