[U-Boot] [PATCH v4 2/4] New command bootmenu: ANSI terminal boot menu support

Anatolij Gustschin
2013-03-28T15:32:47Z

On Sun, 24 Mar 2013 01:53:08 +0100
Anatolij Gustschin <agust@denx.de> wrote:

> From: Pali Roh?r <pali.rohar@gmail.com>
>
> The "bootmenu" command uses U-Boot menu interfaces and provides
> a simple mechanism for creating menus with several boot items.
> When running this command the menu will be assembled as defined
> by a set of environment variables which contain a title and
> command key-value pairs. The "Up" and "Down" keys are used for
> navigation through the items. Current active menu item is
> highlighted and can be selected using the "Enter" key.
>
> The command interprets and generates various ANSI escape
> sequencies, so for proper menu rendering and item selection
> the used terminal should support them.
>
> Signed-off-by: Pali Roh?r <pali.rohar@gmail.com>
> [agust: various fixes and documentation updates]
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> ---
> Changes in v4:
> - coding style fixes
> - highlight only the menu entry title, not the whole line
> - don't return empty strings in bootmenu_choice_entry()
> to avoid useless searching for menu keys in the menu
> item list. Empty key strings won't be found anyway, so
> for down and up keys just return NULL in this function
> to indicate that no item selection happened yet
> - print error message if invalid bootmenu environment
> variable without title/command separator found
> - if number of menu items is equal to MAX_COUNT, the
> U-Boot console selection entry won't be generated.
> Fix it so that documented and real behaviour match
> - include entry key initialisation fix for proper
> menu behaviour when running in sandbox (without it
> the item selection by up/down keys didn't work
> in sandbox)
> - use puts() instead of printf() where appropriate
> - always use 1 for prompt argument for menu_create()
> so that the bootmenu command works as documented when
> using a negative delay value
> - call bootmenu_destroy() in the case if menu_create()
> fails (avoid memory leaks)
> - don't display the title of selected item before
> running the commands (but do it only if debugging
> is enabled)
> - don't change the argument of menu_display_statusline(),
> use exported menu_default_choice() instead and obtain
> the needed bootmenu data pointer in the custom
> menu_display_statusline() function
> - use lower case in menu header
> - update documentation in readme file for the command
>
> Changes in v3:
> - Do not use hardcoded numbers, added MAX_COUNT and MAX_ENV_SIZE
> - Use unsigned short int for menu number
> - Use enum bootmenu_key for key selection
> - Separate loop code from function bootmenu_choice_entry to bootmenu_loop and bootmenu_autoboot_loop
> - Updated README, added example
> - Use switches, added braces, fix style problems
>
> Changes in v2:
> - Added commit message
> - Removed bootmenu from include/config_cmd_all.h
> - Moved ANSI escape codes from include/common.h to include/ansi.h
> - Fixed style and indentation problems
> - Use mdelay instead udelay
> - Removed autoboot delay message when some key is pressed
>
> common/Makefile | 1 +
> common/cmd_bootmenu.c | 517 +++++++++++++++++++++++++++++++++++++++++++++++++
> doc/README.bootmenu | 115 +++++++++++
> include/ansi.h | 42 ++++
> 4 files changed, 675 insertions(+), 0 deletions(-)
> create mode 100644 common/cmd_bootmenu.c
> create mode 100644 doc/README.bootmenu
> create mode 100644 include/ansi.h

applied to staging/agust at denx.de. Thanks.

Anatolij