menu.lua: Give names to menu entries
Make menu customizations easier by naming the entries and using the names to build the table entries. Reviewed by: kevans Approved by: mav (mentor) MFC after: 1 week Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D24527
This commit is contained in:
parent
5e8f32e389
commit
f218cf9280
@ -212,30 +212,50 @@ menu.boot_options = {
|
|||||||
menu.welcome = {
|
menu.welcome = {
|
||||||
entries = function()
|
entries = function()
|
||||||
local menu_entries = menu.welcome.all_entries
|
local menu_entries = menu.welcome.all_entries
|
||||||
-- Swap the first two menu items on single user boot
|
local multi_user = menu_entries.multi_user
|
||||||
|
local single_user = menu_entries.single_user
|
||||||
|
local boot_entry_1, boot_entry_2
|
||||||
if core.isSingleUserBoot() then
|
if core.isSingleUserBoot() then
|
||||||
-- We'll cache the swapped menu, for performance
|
-- Swap the first two menu items on single user boot.
|
||||||
if menu.welcome.swapped_menu ~= nil then
|
-- We'll cache the alternate entries for performance.
|
||||||
return menu.welcome.swapped_menu
|
local alts = menu_entries.alts
|
||||||
|
if alts == nil then
|
||||||
|
single_user = core.deepCopyTable(single_user)
|
||||||
|
multi_user = core.deepCopyTable(multi_user)
|
||||||
|
single_user.name = single_user.alternate_name
|
||||||
|
multi_user.name = multi_user.alternate_name
|
||||||
|
menu_entries.alts = {
|
||||||
|
single_user = single_user,
|
||||||
|
multi_user = multi_user,
|
||||||
|
}
|
||||||
|
else
|
||||||
|
single_user = alts.single_user
|
||||||
|
multi_user = alts.multi_user
|
||||||
end
|
end
|
||||||
-- Shallow copy the table
|
boot_entry_1, boot_entry_2 = single_user, multi_user
|
||||||
menu_entries = core.deepCopyTable(menu_entries)
|
else
|
||||||
|
boot_entry_1, boot_entry_2 = multi_user, single_user
|
||||||
-- Swap the first two menu entries
|
|
||||||
menu_entries[1], menu_entries[2] =
|
|
||||||
menu_entries[2], menu_entries[1]
|
|
||||||
|
|
||||||
-- Then set their names to their alternate names
|
|
||||||
menu_entries[1].name, menu_entries[2].name =
|
|
||||||
menu_entries[1].alternate_name,
|
|
||||||
menu_entries[2].alternate_name
|
|
||||||
menu.welcome.swapped_menu = menu_entries
|
|
||||||
end
|
end
|
||||||
return menu_entries
|
return {
|
||||||
|
boot_entry_1,
|
||||||
|
boot_entry_2,
|
||||||
|
menu_entries.prompt,
|
||||||
|
menu_entries.reboot,
|
||||||
|
{
|
||||||
|
entry_type = core.MENU_SEPARATOR,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
entry_type = core.MENU_SEPARATOR,
|
||||||
|
name = "Options:",
|
||||||
|
},
|
||||||
|
menu_entries.kernel_options,
|
||||||
|
menu_entries.boot_options,
|
||||||
|
menu_entries.boot_envs,
|
||||||
|
menu_entries.chainload,
|
||||||
|
}
|
||||||
end,
|
end,
|
||||||
all_entries = {
|
all_entries = {
|
||||||
-- boot multi user
|
multi_user = {
|
||||||
{
|
|
||||||
entry_type = core.MENU_ENTRY,
|
entry_type = core.MENU_ENTRY,
|
||||||
name = color.highlight("B") .. "oot Multi user " ..
|
name = color.highlight("B") .. "oot Multi user " ..
|
||||||
color.highlight("[Enter]"),
|
color.highlight("[Enter]"),
|
||||||
@ -248,8 +268,7 @@ menu.welcome = {
|
|||||||
end,
|
end,
|
||||||
alias = {"b", "B"},
|
alias = {"b", "B"},
|
||||||
},
|
},
|
||||||
-- boot single user
|
single_user = {
|
||||||
{
|
|
||||||
entry_type = core.MENU_ENTRY,
|
entry_type = core.MENU_ENTRY,
|
||||||
name = "Boot " .. color.highlight("S") .. "ingle user",
|
name = "Boot " .. color.highlight("S") .. "ingle user",
|
||||||
-- Not a standard menu entry function!
|
-- Not a standard menu entry function!
|
||||||
@ -261,8 +280,7 @@ menu.welcome = {
|
|||||||
end,
|
end,
|
||||||
alias = {"s", "S"},
|
alias = {"s", "S"},
|
||||||
},
|
},
|
||||||
-- escape to interpreter
|
prompt = {
|
||||||
{
|
|
||||||
entry_type = core.MENU_RETURN,
|
entry_type = core.MENU_RETURN,
|
||||||
name = color.highlight("Esc") .. "ape to loader prompt",
|
name = color.highlight("Esc") .. "ape to loader prompt",
|
||||||
func = function()
|
func = function()
|
||||||
@ -270,8 +288,7 @@ menu.welcome = {
|
|||||||
end,
|
end,
|
||||||
alias = {core.KEYSTR_ESCAPE},
|
alias = {core.KEYSTR_ESCAPE},
|
||||||
},
|
},
|
||||||
-- reboot
|
reboot = {
|
||||||
{
|
|
||||||
entry_type = core.MENU_ENTRY,
|
entry_type = core.MENU_ENTRY,
|
||||||
name = color.highlight("R") .. "eboot",
|
name = color.highlight("R") .. "eboot",
|
||||||
func = function()
|
func = function()
|
||||||
@ -279,15 +296,7 @@ menu.welcome = {
|
|||||||
end,
|
end,
|
||||||
alias = {"r", "R"},
|
alias = {"r", "R"},
|
||||||
},
|
},
|
||||||
{
|
kernel_options = {
|
||||||
entry_type = core.MENU_SEPARATOR,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
entry_type = core.MENU_SEPARATOR,
|
|
||||||
name = "Options:",
|
|
||||||
},
|
|
||||||
-- kernel options
|
|
||||||
{
|
|
||||||
entry_type = core.MENU_CAROUSEL_ENTRY,
|
entry_type = core.MENU_CAROUSEL_ENTRY,
|
||||||
carousel_id = "kernel",
|
carousel_id = "kernel",
|
||||||
items = core.kernelList,
|
items = core.kernelList,
|
||||||
@ -319,15 +328,13 @@ menu.welcome = {
|
|||||||
end,
|
end,
|
||||||
alias = {"k", "K"},
|
alias = {"k", "K"},
|
||||||
},
|
},
|
||||||
-- boot options
|
boot_options = {
|
||||||
{
|
|
||||||
entry_type = core.MENU_SUBMENU,
|
entry_type = core.MENU_SUBMENU,
|
||||||
name = "Boot " .. color.highlight("O") .. "ptions",
|
name = "Boot " .. color.highlight("O") .. "ptions",
|
||||||
submenu = menu.boot_options,
|
submenu = menu.boot_options,
|
||||||
alias = {"o", "O"},
|
alias = {"o", "O"},
|
||||||
},
|
},
|
||||||
-- boot environments
|
boot_envs = {
|
||||||
{
|
|
||||||
entry_type = core.MENU_SUBMENU,
|
entry_type = core.MENU_SUBMENU,
|
||||||
visible = function()
|
visible = function()
|
||||||
return core.isZFSBoot() and
|
return core.isZFSBoot() and
|
||||||
@ -337,8 +344,7 @@ menu.welcome = {
|
|||||||
submenu = menu.boot_environments,
|
submenu = menu.boot_environments,
|
||||||
alias = {"e", "E"},
|
alias = {"e", "E"},
|
||||||
},
|
},
|
||||||
-- chainload
|
chainload = {
|
||||||
{
|
|
||||||
entry_type = core.MENU_ENTRY,
|
entry_type = core.MENU_ENTRY,
|
||||||
name = function()
|
name = function()
|
||||||
return 'Chain' .. color.highlight("L") ..
|
return 'Chain' .. color.highlight("L") ..
|
||||||
|
Loading…
x
Reference in New Issue
Block a user