9
0
Fork 0
Commit Graph

29 Commits

Author SHA1 Message Date
Sascha Hauer 7e66707c76 input: Add BB_ prefix to KEY_ defines
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>
2014-02-17 08:23:37 +01:00
Sascha Hauer 22350e4e68 menu: Make action callback optional
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>
2013-06-19 22:47:48 +02:00
Sascha Hauer f890ea69be Fix gotoXY argument order
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>
2013-06-19 22:45:14 +02:00
Sascha Hauer 1679063e40 menu: Align entries
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>
2013-06-19 22:42:34 +02:00
Fabio Porcedda 8e418dcc63 menu: fix remove superfluous newline: change puts() -> printf("%s", )
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>
2013-02-26 15:04:23 +01:00
Fabio Porcedda 638f91bd16 fix compiler warnings: use puts() instead of printf()
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>
2013-02-21 14:25:57 +01:00
Sascha Hauer 77322aa896 Treewide: remove address of the Free Software Foundation
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>
2012-09-17 10:57:41 +02:00
Jean-Christophe PLAGNIOL-VILLARD 0e21e17614 menu: add number key support
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>
2012-08-09 08:40:02 +02:00
Sascha Hauer c77dd2a81b Merge branch 'for-next/menu' 2012-07-02 11:02:59 +02:00
Sascha Hauer 13b70bb921 menu: implement KEY_HOME/KEY_END
To go to the first/last menu entry.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-06-30 20:23:26 +02:00
Sascha Hauer 4f02e70d6d menu: store repaint state in variable
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>
2012-06-30 20:23:26 +02:00
Sascha Hauer fa37257ce0 menu: use read_key
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>
2012-06-30 20:23:26 +02:00
Sascha Hauer 01f8ce581b menu: factor out a function to print an entry
To save a few bytes of binary space.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-06-28 12:45:19 +02:00
Jean-Christophe PLAGNIOL-VILLARD 9851c9cc87 menu: fix support for "\n", "\n\r" and "\r"
If "\n\r" or "\r\n" is ignore one.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2012-04-23 19:51:06 +08:00
Jean-Christophe PLAGNIOL-VILLARD 6f9eaaa000 menu: enable the fancy color support only if HUSH is enabled
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>
2012-04-15 18:29:52 +02:00
Jean-Christophe PLAGNIOL-VILLARD 4da4b4df10 menu: add color fancy support
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>
2012-04-10 10:00:07 +02:00
Jean-Christophe PLAGNIOL-VILLARD 6da43a09a9 menu: fix double action when "\n\r" or "\r\n" is received
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-04-10 10:00:07 +02:00
Jean-Christophe PLAGNIOL-VILLARD 1f22d10f15 readkey: add define for Ascii keys
this will simplify the usage of gpio keyboard

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2012-02-16 18:17:32 +08:00
Jean-Christophe PLAGNIOL-VILLARD 78b77a332e menu: fix command support as module
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>
2011-07-05 09:34:13 +02:00
Jean-Christophe PLAGNIOL-VILLARD a47575911d Menu: add box style entry
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>
2010-09-20 08:58:53 +02:00
Jean-Christophe PLAGNIOL-VILLARD 7923392c56 menu: add auto select support
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>
2010-09-20 08:58:52 +02:00
Sascha Hauer 0d35c3c8a0 menu: simplify usage for clients
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>
2010-08-30 21:06:02 +02:00
Sascha Hauer f50d2063cb menu: use an initialized struct list as menu list
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-08-30 20:57:20 +02:00
Sascha Hauer 417e2d45fe menu: use list_for_each_entry where appropriate
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-08-30 20:57:20 +02:00
Sascha Hauer b11b88de64 menu: remove superfluous struct menu_entry member from struct menu
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-08-30 20:57:20 +02:00
Sascha Hauer a75d6dacc3 menu: simplify menu_free with list_for_each_entry_safe
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-08-30 20:57:20 +02:00
Sascha Hauer 86086c5faa menu: initialize entries list in menu_alloc
Otherwise menu_free fails when menu_add failed.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-08-30 20:57:20 +02:00
Jean-Christophe PLAGNIOL-VILLARD 6ce1c664de Menu/cmd: add sub menu entry command support
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>
2010-08-30 20:57:20 +02:00
Jean-Christophe PLAGNIOL-VILLARD b712b26632 Add Menu Framework
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>
2010-08-30 20:57:20 +02:00