]> git.ipfire.org Git - thirdparty/ipxe.git/commit
[dynui] Generalise the concept of a menu to a dynamic user interface
authorMichael Brown <mcb30@ipxe.org>
Thu, 20 Jun 2024 21:24:53 +0000 (14:24 -0700)
committerMichael Brown <mcb30@ipxe.org>
Thu, 20 Jun 2024 21:26:06 +0000 (14:26 -0700)
commit5719cde838b6e86a02831373dae81642653b872f
treee4159ca36ce356a80df7909dfabeaececc6fefdc
parent122777f789a68512593e4aa6da3ace3d0d8664ec
[dynui] Generalise the concept of a menu to a dynamic user interface

We currently have an abstract model of a dynamic menu as a list of
items, each of which has a name, a description, and assorted metadata
such as a shortcut key.  The "menu" and "item" commands construct
representations in this abstract model, and the "choose" command then
presents the items as a single-choice menu, with the selected item's
name used as the output value.

This same abstraction may be used to model a dynamic form as a list of
editable items, each of which has a corresponding setting name, an
optional description label, and assorted metadata such as a shortcut
key.  By defining a "form" command as an alias for the "menu" command,
we could construct and present forms using commands such as:

  #!ipxe
  form                     Login to ${url}
  item          username   Username or email address
  item --secret password   Password
  present

or

  #!ipxe
  form                Configure IPv4 networking for ${netX/ifname}
  item netX/ip        IPv4 address
  item netX/netmask   Subnet mask
  item netX/gateway   Gateway address
  item netX/dns       DNS server address
  present

Reusing the same abstract model for both menus and forms allows us to
minimise the increase in code size, since the implementation of the
"form" and "item" commands is essentially zero-cost.

Rename everything within the abstract data model from "menu" to
"dynamic user interface" to reflect this generalisation.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/config/config.c
src/core/dynui.c [moved from src/core/menu.c with 54% similarity]
src/core/parseopt.c
src/hci/commands/dynui_cmd.c [moved from src/hci/commands/menu_cmd.c with 73% similarity]
src/hci/tui/menu_ui.c
src/include/ipxe/dynui.h [new file with mode: 0644]
src/include/ipxe/errfile.h
src/include/ipxe/menu.h [deleted file]
src/include/ipxe/parseopt.h