MENUSETS.4TH(7) Standards, Environments, and Macros MENUSETS.4TH(7)

menusets.4thloader dynamic submenu boot module

The file that goes by the name of menusets.4th is a set of commands designed to add submenu functionality to the dynamic menu system provided by menu.4th(7). Submenus are managed through a system of carefully named environment variables. The commands of menusets.4th by themselves are not enough for most uses. Please refer to the examples below for the most common situations, and to menu.4th(7) for additional commands.

Before using any of the commands provided in menusets.4th, it must be included through the command:

include menusets.4th

This line is present in the default /boot/forth/menu-commands.4th file, so it is not needed (and should not be re-issued) in a normal setup.

The commands provided by it are:

Takes a single integer on the stack to identify the menuset environment variables to be activated (see environment variables below).
If $menuset_initial is set, passes the value to menuset-loadsetnum. The value must be a number.
Unsets the environment variables associated with all menusets. Increments starting at 1 and stops at the first unconfigured menuset. A menuset is considered configured if the caption for item 1 is set.

The environment variables that effect its behavior are:

Number to pass to menuset-loadsetnum when menuset-loadinitial is called.
Used to give a name to a menuset.

When a menuset is NOT given a name (the default), menuset N is comprised of the following environment variables:

ansisetN_caption[x]
-> ansi_caption[x]
ansisetN_caption[x][y]
-> ansi_caption[x][y]
-> menu_acpi
-> menu_caption[x]
-> menu_caption[x][y]
-> menu_command[x]
-> “evaluated
-> menu_init[x]
-> menu_keycode[x]
-> menu_options
-> menu_optionstext
-> menu_reboot
toggledsetN_ansi[x]
-> toggled_ansi[x]
toggledsetN_text[x]
-> toggled_text[x]

When you choose to give a menuset a name (by setting $menuset_nameN), menuset N is instead comprised of the following environment variables:

NAMEansi_caption[x]
-> ansi_caption[x]
NAMEansi_caption[x][y]
-> ansi_caption[x][y]
NAMEmenu_acpi
-> menu_acpi
NAMEmenu_caption[x]
-> menu_caption[x]
NAMEmenu_caption[x][y]
-> menu_caption[x][y]
NAMEmenu_command[x]
-> menu_command[x]
NAMEmenu_init
-> “evaluated
NAMEmenu_init[x]
-> menu_init[x]
NAMEmenu_keycode[x]
-> menu_keycode[x]
NAMEmenu_options
-> menu_options
NAMEmenu_optionstext
-> menu_optionstext
NAMEmenu_reboot
-> menu_reboot
NAMEtoggled_ansi[x]
-> toggled_ansi[x]
NAMEtoggled_text[x]
-> toggled_text[x]

where “NAME” is the value of $menuset_nameN. In the case of $NAMEmenu_init ($menusetN_init when $menuset_nameN is unset), the value is evaluated as an FICL statement. This can be used to dynamically adjust the menuset variables right before the menu is activated.

In addition, menusets.4th provides the following FICL words:

Given a single integer on the stack, sets a global variable menuset_use_name to a boolean based on whether $menuset_nameN is set (true) or not (false). Also sets $affix temporary variable (prefix or infix depending on menuset_use_name). Automatically called by menuset-loadsetnum and menusets-unset.
Used indirectly to shorten syntax and mitigate dictionary size. Requires the following temporary environment variables:

type
should be set to one of: menu toggled ansi
var
should be set to one of: caption command keycode text ...
affix
either a prefix (menuset_use_name is true) or infix (menuset_use_name is false)

If the global menuset_use_name is true, the variable ${type}_${var} is made to equal the value of the variable ${affix}${type}_${var} (note: in this case menuset-checksetnum has set $affix to $menuset_nameN). Otherwise (when menuset_use_name is false), the variable ${type}_${var} is made to equal the value of the variable ${type}set${affix}_${var} (note: in this case menuset-checksetnum has set $affix to N).

Both the global variable menuset_use_name and the environment variable $affix are automatically handled by menuset-checksetnum above (which is automatically called by menuset-loadsetnum).

Used indirectly to shorten syntax and mitigate dictionary size. Like menuset-loadvar except it unsets the menuset variable. If global menuset_use_name is true ($affix is $menuset_nameN), variable ${affix}${type}_${var} is unset. Otherwise, $affix is N and variable ${type}set${affix}_${var} is unset.
Sets $type to “menu” and calls menuset-loadvar.
Sets $type to “menu” and calls menuset-unloadvar.
Like menuset-loadvar except it takes an additional temporary variable $x. If the global menuset_use_name is true (making $affix equal $menuset_nameN), sets variable ${type}_${var}[${x}] to variable ${affix}${type}_${var}[${x}]. Otherwise ($affix being N), sets the same variable to instead ${type}set{affix}_${var}[${x}].
Like menuset-loadxvar except it unsets the menuset variable. If global menuset_use_name is true, unsets ${affix}${type}_${var}[${x}]. Otherwise, unsets ${type}set${affix}_${var}[${x}].
Sets $type to “ansi” and calls menuset-loadxvar
Sets $type to “ansi” and calls menuset-unloadxvar
Sets $type to “ansi” and calls menuset-loadxvar
Sets $type to “ansi” and calls menuset-unloadxvar
Sets $type to “toggled” and calls menuset-loadxvar
Sets $type to “toggled” and calls menuset-unloadxvar
Like menuset-loadxvar except it takes an additional temporary variable $y. If the global menuset_use_name is true ($affix is $menuset_nameN), sets variable ${type}_${var}[${x}][${y}] to ${affix}${type}_${var}[${x}][${y}]. Otherwise ($affix is N) sets the same variable to instead ${type}set${affix}_${var}[${x}][${y}].
Like menuset-loadxyvar except it unsets the menuset variable. If the global menuset_use_name is true, unsets ${affix}${type}_${var}[${x}][${y}]. Otherwise, unsets ${type}set${affix}_${var}[${x}][${y}].
Sets $type to “ansi” and calls menuset-loadxyvar.
Sets $type to “ansi” and calls menuset-unloadxyvar.
Sets $type to “menu” and calls menuset-loadxyvar.
Sets $type to “menu” and calls menuset-unloadxyvar.
Takes a single integer on the stack and replaces it with a string (in c-addr/u format) whose value is “menuset_nameN”. For example, if given 1 returns “menuset_name1”.
Unsets all the various temporary variables, currently type, var, x, y, and affix.

For all values of “x” above, use any number between 1 through 9. Sorry, double-digits are not currently supported. For all values of “N” above, use any number between 1 and 65535.

/boot/loader
The loader(7).
/boot/forth/menu.4th
Dynamic menu module.
/boot/forth/menu-commands.4th
Contains the goto_menu command.
/boot/forth/menusets.4th
menusets.4th itself.
/boot/loader.rc
loader(7) bootstrapping script.

A simple boot menu with a submenu:

include /boot/forth/menu.4th
include /boot/forth/menu-commands.4th
menu-init
set menuset1_caption[1]="Boot"
set menuset1_command[1]="boot"
set menuset1_caption[2]="Submenu..."
set menuset1_command[2]="2 goto_menu"
set menuset2_caption[1]="Back"
set menuset2_command[1]="1 goto_menu"
set menuset_initial=2
menuset-loadinitial
menu-display

The same boot menu with named menusets:

include /boot/forth/menu.4th
include /boot/forth/menu-commands.4th
menu-init
set menuset_name1=main
set mainmenu_caption[1]="Boot"
set mainmenu_command[1]="boot"
set mainmenu_caption[2]="Submenu..."
set mainmenu_command[2]="2 goto_menu"
set menuset_name2=sub
set submenu_caption[1]="Back"
set submenu_command[1]="1 goto_menu"

loader.conf(5), beastie.4th(7), loader(7), loader.4th(7), menu.4th(7)

July 20, 2018 OmniOS