From 04af422907599825aa89cce0399932835d414103 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Mon, 26 Feb 2018 04:08:54 +0000 Subject: [PATCH] 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. --- stand/lua/color.lua | 23 ++++++++++++----------- stand/lua/config.lua | 29 ++++++++++++++++------------- stand/lua/core.lua | 44 ++++++++++++++++++++++---------------------- stand/lua/drawer.lua | 8 ++++---- stand/lua/menu.lua | 4 ++-- 5 files changed, 56 insertions(+), 52 deletions(-) diff --git a/stand/lua/color.lua b/stand/lua/color.lua index ea8760b67425..e5be3948a8f4 100644 --- a/stand/lua/color.lua +++ b/stand/lua/color.lua @@ -58,30 +58,31 @@ end color.disabled = not color.isEnabled() -function color.escapef(c) +function color.escapef(color_value) if color.disabled then - return c + return color_value end - return "\027[3" .. c .. "m" + return "\027[3" .. color_value .. "m" end -function color.escapeb(c) +function color.escapeb(color_value) if color.disabled then - return c + return color_value end - return "\027[4" .. c .. "m" + return "\027[4" .. color_value .. "m" end -function color.escape(fg, bg, att) +function color.escape(fg_color, bg_color, attribute) if color.disabled then return "" end - if not att then - att = "" + if attribute == nil then + attribute = "" else - att = att .. ";" + attribute = attribute .. ";" end - return "\027[" .. att .. "3" .. fg .. ";4" .. bg .. "m" + return "\027[" .. attribute .. + "3" .. fg_color .. ";4" .. bg_color .. "m" end function color.default() diff --git a/stand/lua/config.lua b/stand/lua/config.lua index a190abd3edd3..4aef782d0b00 100644 --- a/stand/lua/config.lua +++ b/stand/lua/config.lua @@ -228,22 +228,25 @@ function config.restoreEnv() config.env_restore = {} end -function config.setenv(k, v) +function config.setenv(key, value) -- Track the original value for this if we haven't already - if config.env_restore[k] == nil then - config.env_restore[k] = {value = loader.getenv(k)} + if config.env_restore[key] == nil then + config.env_restore[key] = {value = loader.getenv(key)} end - config.env_changed[k] = v + config.env_changed[key] = value - return loader.setenv(k, v) + return loader.setenv(key, value) end -function config.setKey(k, n, v) - if modules[k] == nil then - modules[k] = {} +-- name here is one of 'name', 'type', flags', 'before', 'after', or 'error.' +-- These are set from lines in loader.conf(5): ${key}_${name}="${value}" where +-- ${key} is a module name. +function config.setKey(key, name, value) + if modules[key] == nil then + modules[key] = {} end - modules[k][n] = v + modules[key][name] = value end function config.lsModules() @@ -255,11 +258,11 @@ function config.lsModules() end -function config.isValidComment(c) - if c ~= nil then - local s = c:match("^%s*#.*") +function config.isValidComment(line) + if line ~= nil then + local s = line:match("^%s*#.*") if s == nil then - s = c:match("^%s*$") + s = line:match("^%s*$") end if s == nil then return false diff --git a/stand/lua/core.lua b/stand/lua/core.lua index fc9c322da3a6..c67c49e46276 100644 --- a/stand/lua/core.lua +++ b/stand/lua/core.lua @@ -54,37 +54,37 @@ core.MENU_SEPARATOR = "separator" core.MENU_SUBMENU = "submenu" core.MENU_CAROUSEL_ENTRY = "carousel_entry" -function core.setVerbose(b) - if b == nil then - b = not core.verbose +function core.setVerbose(verbose) + if verbose == nil then + verbose = not core.verbose end - if b then + if verbose then loader.setenv("boot_verbose", "YES") else loader.unsetenv("boot_verbose") end - core.verbose = b + core.verbose = verbose end -function core.setSingleUser(b) - if b == nil then - b = not core.su +function core.setSingleUser(single_user) + if single_user == nil then + single_user = not core.su end - if b then + if single_user then loader.setenv("boot_single", "YES") else loader.unsetenv("boot_single") end - core.su = b + core.su = single_user end -function core.getACPIPresent(checkingSystemDefaults) +function core.getACPIPresent(checking_system_defaults) local c = loader.getenv("hint.acpi.0.rsdp") if c ~= nil then - if checkingSystemDefaults then + if checking_system_defaults then return true end -- Otherwise, respect disabled if it's set @@ -94,12 +94,12 @@ function core.getACPIPresent(checkingSystemDefaults) return false end -function core.setACPI(b) - if b == nil then - b = not core.acpi +function core.setACPI(acpi) + if acpi == nil then + acpi = not core.acpi end - if b then + if acpi then loader.setenv("acpi_load", "YES") loader.setenv("hint.acpi.0.disabled", "0") loader.unsetenv("loader.acpi_disabled_by_user") @@ -108,14 +108,14 @@ function core.setACPI(b) loader.setenv("hint.acpi.0.disabled", "1") loader.setenv("loader.acpi_disabled_by_user", "1") end - core.acpi = b + core.acpi = acpi end -function core.setSafeMode(b) - if b == nil then - b = not core.sm +function core.setSafeMode(safe_mode) + if safe_mode == nil then + safe_mode = not core.sm end - if b then + if safe_mode then loader.setenv("kern.smp.disabled", "1") loader.setenv("hw.ata.ata_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.geom.part.check_integrity") end - core.sm = b + core.sm = safe_mode end function core.kernelList() diff --git a/stand/lua/drawer.lua b/stand/lua/drawer.lua index 0e82e3b80e03..b8c1ec204d9e 100644 --- a/stand/lua/drawer.lua +++ b/stand/lua/drawer.lua @@ -265,14 +265,14 @@ function drawer.drawscreen(menu_opts) return drawer.drawmenu(menu_opts) end -function drawer.drawmenu(m) +function drawer.drawmenu(menudef) local x = drawer.menu_position.x local y = drawer.menu_position.y -- print the menu and build the alias table local alias_table = {} local entry_num = 0 - local menu_entries = m.entries + local menu_entries = menudef.entries local effective_line_num = 0 if type(menu_entries) == "function" then menu_entries = menu_entries() @@ -288,7 +288,7 @@ function drawer.drawmenu(m) entry_num = entry_num + 1 screen.setcursor(x, y + effective_line_num) - print(entry_num .. ". " .. menuEntryName(m, e)) + print(entry_num .. ". " .. menuEntryName(menudef, e)) -- fill the alias table alias_table[tostring(entry_num)] = e @@ -299,7 +299,7 @@ function drawer.drawmenu(m) end else screen.setcursor(x, y + effective_line_num) - print(menuEntryName(m, e)) + print(menuEntryName(menudef, e)) end ::continue:: end diff --git a/stand/lua/menu.lua b/stand/lua/menu.lua index 56537199db8c..fe18d70fdfb0 100644 --- a/stand/lua/menu.lua +++ b/stand/lua/menu.lua @@ -40,8 +40,8 @@ local menu = {} local drawn_menu -local function OnOff(str, b) - if b then +local function OnOff(str, value) + if value then return str .. color.escapef(color.GREEN) .. "On" .. color.escapef(color.WHITE) else