lualoader: More argument name expansion, part 2

screen also has some instances, but it also has other cleanup to go with it.
Because of this, I will be committing the screen changes separately.
This commit is contained in:
Kyle Evans 2018-02-26 04:08:54 +00:00
parent 2a11b81090
commit 04af422907
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=330009
5 changed files with 56 additions and 52 deletions

View File

@ -58,30 +58,31 @@ end
color.disabled = not color.isEnabled() color.disabled = not color.isEnabled()
function color.escapef(c) function color.escapef(color_value)
if color.disabled then if color.disabled then
return c return color_value
end end
return "\027[3" .. c .. "m" return "\027[3" .. color_value .. "m"
end end
function color.escapeb(c) function color.escapeb(color_value)
if color.disabled then if color.disabled then
return c return color_value
end end
return "\027[4" .. c .. "m" return "\027[4" .. color_value .. "m"
end end
function color.escape(fg, bg, att) function color.escape(fg_color, bg_color, attribute)
if color.disabled then if color.disabled then
return "" return ""
end end
if not att then if attribute == nil then
att = "" attribute = ""
else else
att = att .. ";" attribute = attribute .. ";"
end end
return "\027[" .. att .. "3" .. fg .. ";4" .. bg .. "m" return "\027[" .. attribute ..
"3" .. fg_color .. ";4" .. bg_color .. "m"
end end
function color.default() function color.default()

View File

@ -228,22 +228,25 @@ function config.restoreEnv()
config.env_restore = {} config.env_restore = {}
end end
function config.setenv(k, v) function config.setenv(key, value)
-- Track the original value for this if we haven't already -- Track the original value for this if we haven't already
if config.env_restore[k] == nil then if config.env_restore[key] == nil then
config.env_restore[k] = {value = loader.getenv(k)} config.env_restore[key] = {value = loader.getenv(key)}
end end
config.env_changed[k] = v config.env_changed[key] = value
return loader.setenv(k, v) return loader.setenv(key, value)
end end
function config.setKey(k, n, v) -- name here is one of 'name', 'type', flags', 'before', 'after', or 'error.'
if modules[k] == nil then -- These are set from lines in loader.conf(5): ${key}_${name}="${value}" where
modules[k] = {} -- ${key} is a module name.
function config.setKey(key, name, value)
if modules[key] == nil then
modules[key] = {}
end end
modules[k][n] = v modules[key][name] = value
end end
function config.lsModules() function config.lsModules()
@ -255,11 +258,11 @@ function config.lsModules()
end end
function config.isValidComment(c) function config.isValidComment(line)
if c ~= nil then if line ~= nil then
local s = c:match("^%s*#.*") local s = line:match("^%s*#.*")
if s == nil then if s == nil then
s = c:match("^%s*$") s = line:match("^%s*$")
end end
if s == nil then if s == nil then
return false return false

View File

@ -54,37 +54,37 @@ core.MENU_SEPARATOR = "separator"
core.MENU_SUBMENU = "submenu" core.MENU_SUBMENU = "submenu"
core.MENU_CAROUSEL_ENTRY = "carousel_entry" core.MENU_CAROUSEL_ENTRY = "carousel_entry"
function core.setVerbose(b) function core.setVerbose(verbose)
if b == nil then if verbose == nil then
b = not core.verbose verbose = not core.verbose
end end
if b then if verbose then
loader.setenv("boot_verbose", "YES") loader.setenv("boot_verbose", "YES")
else else
loader.unsetenv("boot_verbose") loader.unsetenv("boot_verbose")
end end
core.verbose = b core.verbose = verbose
end end
function core.setSingleUser(b) function core.setSingleUser(single_user)
if b == nil then if single_user == nil then
b = not core.su single_user = not core.su
end end
if b then if single_user then
loader.setenv("boot_single", "YES") loader.setenv("boot_single", "YES")
else else
loader.unsetenv("boot_single") loader.unsetenv("boot_single")
end end
core.su = b core.su = single_user
end end
function core.getACPIPresent(checkingSystemDefaults) function core.getACPIPresent(checking_system_defaults)
local c = loader.getenv("hint.acpi.0.rsdp") local c = loader.getenv("hint.acpi.0.rsdp")
if c ~= nil then if c ~= nil then
if checkingSystemDefaults then if checking_system_defaults then
return true return true
end end
-- Otherwise, respect disabled if it's set -- Otherwise, respect disabled if it's set
@ -94,12 +94,12 @@ function core.getACPIPresent(checkingSystemDefaults)
return false return false
end end
function core.setACPI(b) function core.setACPI(acpi)
if b == nil then if acpi == nil then
b = not core.acpi acpi = not core.acpi
end end
if b then if acpi then
loader.setenv("acpi_load", "YES") loader.setenv("acpi_load", "YES")
loader.setenv("hint.acpi.0.disabled", "0") loader.setenv("hint.acpi.0.disabled", "0")
loader.unsetenv("loader.acpi_disabled_by_user") loader.unsetenv("loader.acpi_disabled_by_user")
@ -108,14 +108,14 @@ function core.setACPI(b)
loader.setenv("hint.acpi.0.disabled", "1") loader.setenv("hint.acpi.0.disabled", "1")
loader.setenv("loader.acpi_disabled_by_user", "1") loader.setenv("loader.acpi_disabled_by_user", "1")
end end
core.acpi = b core.acpi = acpi
end end
function core.setSafeMode(b) function core.setSafeMode(safe_mode)
if b == nil then if safe_mode == nil then
b = not core.sm safe_mode = not core.sm
end end
if b then if safe_mode then
loader.setenv("kern.smp.disabled", "1") loader.setenv("kern.smp.disabled", "1")
loader.setenv("hw.ata.ata_dma", "0") loader.setenv("hw.ata.ata_dma", "0")
loader.setenv("hw.ata.atapi_dma", "0") loader.setenv("hw.ata.atapi_dma", "0")
@ -132,7 +132,7 @@ function core.setSafeMode(b)
loader.unsetenv("kern.eventtimer.periodic") loader.unsetenv("kern.eventtimer.periodic")
loader.unsetenv("kern.geom.part.check_integrity") loader.unsetenv("kern.geom.part.check_integrity")
end end
core.sm = b core.sm = safe_mode
end end
function core.kernelList() function core.kernelList()

View File

@ -265,14 +265,14 @@ function drawer.drawscreen(menu_opts)
return drawer.drawmenu(menu_opts) return drawer.drawmenu(menu_opts)
end end
function drawer.drawmenu(m) function drawer.drawmenu(menudef)
local x = drawer.menu_position.x local x = drawer.menu_position.x
local y = drawer.menu_position.y local y = drawer.menu_position.y
-- print the menu and build the alias table -- print the menu and build the alias table
local alias_table = {} local alias_table = {}
local entry_num = 0 local entry_num = 0
local menu_entries = m.entries local menu_entries = menudef.entries
local effective_line_num = 0 local effective_line_num = 0
if type(menu_entries) == "function" then if type(menu_entries) == "function" then
menu_entries = menu_entries() menu_entries = menu_entries()
@ -288,7 +288,7 @@ function drawer.drawmenu(m)
entry_num = entry_num + 1 entry_num = entry_num + 1
screen.setcursor(x, y + effective_line_num) screen.setcursor(x, y + effective_line_num)
print(entry_num .. ". " .. menuEntryName(m, e)) print(entry_num .. ". " .. menuEntryName(menudef, e))
-- fill the alias table -- fill the alias table
alias_table[tostring(entry_num)] = e alias_table[tostring(entry_num)] = e
@ -299,7 +299,7 @@ function drawer.drawmenu(m)
end end
else else
screen.setcursor(x, y + effective_line_num) screen.setcursor(x, y + effective_line_num)
print(menuEntryName(m, e)) print(menuEntryName(menudef, e))
end end
::continue:: ::continue::
end end

View File

@ -40,8 +40,8 @@ local menu = {}
local drawn_menu local drawn_menu
local function OnOff(str, b) local function OnOff(str, value)
if b then if value then
return str .. color.escapef(color.GREEN) .. "On" .. return str .. color.escapef(color.GREEN) .. "On" ..
color.escapef(color.WHITE) color.escapef(color.WHITE)
else else