9
0
Fork 0
Commit Graph

12 Commits

Author SHA1 Message Date
Sascha Hauer ca8edb3b65 add menutree command
Creating menus from the shell using the regular 'menu' command is rather
complicated. This adds a 'menutree' command which creates a menu from
a directory structure. In the directory structure each directory corresponds
to a single menu entry. The directory contains the following files:

title -  A file containing the title of the entry as shown in the menu
box -    If present, the entry is a 'bool' entry. The file contains a variable
         name from which the current state of the bool is taken from and saved
         to.
action - if present this file contains a shell script which is executed when
         when the entry is selected.

If neither 'box' or 'action' are present this entry is considered a submenu
containing more entries.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-03-28 09:37:09 +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
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 b108afa01a menu: fix menu alloc init
The auto_select is supposed to be set to -1.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2012-04-23 19:51:06 +08: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 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 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 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