From owner-svn-src-all@freebsd.org Wed Feb 21 04:48:38 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 86870F02D1A; Wed, 21 Feb 2018 04:48:38 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3273B85288; Wed, 21 Feb 2018 04:48:38 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2C47013CE9; Wed, 21 Feb 2018 04:48:38 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1L4mb6n005950; Wed, 21 Feb 2018 04:48:37 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1L4mbKd005948; Wed, 21 Feb 2018 04:48:37 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802210448.w1L4mbKd005948@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 21 Feb 2018 04:48:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329699 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 329699 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Feb 2018 04:48:38 -0000 Author: kevans Date: Wed Feb 21 04:48:37 2018 New Revision: 329699 URL: https://svnweb.freebsd.org/changeset/base/329699 Log: lualoader: Simplify menu definitions a little further Allow "name" entries to be simple strings, instead of just functions. We know whether we support colors or not by the time any of this is setup, so all menu names that are basically static with colors sprinkled in are good candidates for simplification. Also simplify "func" in many cases where it's just invoking another function with no arguments. The downside to this simplification is that the functions called can no longer be trivially replaced by a local module. The upside is that it removes another layer of indirection that we likely don't need. These can be re-evaluated later if a compelling argument is raised, on a case-by-case basis, for replacement. Modified: head/stand/lua/drawer.lua head/stand/lua/menu.lua Modified: head/stand/lua/drawer.lua ============================================================================== --- head/stand/lua/drawer.lua Wed Feb 21 04:23:13 2018 (r329698) +++ head/stand/lua/drawer.lua Wed Feb 21 04:48:37 2018 (r329699) @@ -48,7 +48,10 @@ local menu_entry_name = function(drawing_menu, entry) if name_handler ~= nil then return name_handler(drawing_menu, entry) end - return entry.name() + if type(entry.name) == "function" then + return entry.name() + end + return entry.name end local shift_brand_text = function(shift) @@ -174,10 +177,13 @@ drawer.menu_name_handlers = { -- drawn as parameters, and return the name of the item. -- This is designed so that everything, including menu separators, may -- have their names derived differently. The default action for entry - -- types not specified here is to call and use entry.name(). + -- types not specified here is to use entry.name directly. [core.MENU_SEPARATOR] = function(drawing_menu, entry) if entry.name ~= nil then - return entry.name() + if type(entry.name) == "function" then + return entry.name() + end + return entry.name end return "" end, Modified: head/stand/lua/menu.lua ============================================================================== --- head/stand/lua/menu.lua Wed Feb 21 04:23:13 2018 (r329698) +++ head/stand/lua/menu.lua Wed Feb 21 04:48:37 2018 (r329699) @@ -92,36 +92,24 @@ menu.boot_options = { -- return to welcome menu { entry_type = core.MENU_RETURN, - name = function() - return "Back to main menu" .. - color.highlight(" [Backspace]") - end + name = "Back to main menu" .. + color.highlight(" [Backspace]"), }, - -- load defaults { entry_type = core.MENU_ENTRY, - name = function() - return "Load System " .. color.highlight("D") .. - "efaults" - end, - func = function() - core.setDefaults() - end, + name = "Load System " .. color.highlight("D") .. + "efaults", + func = core.setDefaults, alias = {"d", "D"} }, - { entry_type = core.MENU_SEPARATOR, }, - { entry_type = core.MENU_SEPARATOR, - name = function() - return "Boot Options:" - end + name = "Boot Options:", }, - -- acpi { entry_type = core.MENU_ENTRY, @@ -130,9 +118,7 @@ menu.boot_options = { return OnOff(color.highlight("A") .. "CPI :", core.acpi) end, - func = function() - core.setACPI() - end, + func = core.setACPI, alias = {"a", "A"} }, -- safe mode @@ -142,9 +128,7 @@ menu.boot_options = { return OnOff("Safe " .. color.highlight("M") .. "ode :", core.sm) end, - func = function() - core.setSafeMode() - end, + func = core.setSafeMode, alias = {"m", "M"} }, -- single user @@ -154,9 +138,7 @@ menu.boot_options = { return OnOff(color.highlight("S") .. "ingle user:", core.su) end, - func = function() - core.setSingleUser() - end, + func = core.setSingleUser, alias = {"s", "S"} }, -- verbose boot @@ -166,9 +148,7 @@ menu.boot_options = { return OnOff(color.highlight("V") .. "erbose :", core.verbose) end, - func = function() - core.setVerbose() - end, + func = core.setVerbose, alias = {"v", "V"} }, }, @@ -202,79 +182,55 @@ menu.welcome = { -- boot multi user { entry_type = core.MENU_ENTRY, - name = function() - return color.highlight("B") .. - "oot Multi user " .. - color.highlight("[Enter]") - end, + name = color.highlight("B") .. "oot Multi user " .. + color.highlight("[Enter]"), -- Not a standard menu entry function! - alternate_name = function() - return color.highlight("B") .. - "oot Multi user" - end, + alternate_name = color.highlight("B") .. + "oot Multi user", func = function() core.setSingleUser(false) core.boot() end, alias = {"b", "B"} }, - -- boot single user { entry_type = core.MENU_ENTRY, - name = function() - return "Boot " .. color.highlight("S") .. - "ingle user" - end, + name = "Boot " .. color.highlight("S") .. "ingle user", -- Not a standard menu entry function! - alternate_name = function() - return "Boot " .. color.highlight("S") .. - "ingle user " .. color.highlight("[Enter]") - end, + alternate_name = "Boot " .. color.highlight("S") .. + "ingle user " .. color.highlight("[Enter]"), func = function() core.setSingleUser(true) core.boot() end, alias = {"s", "S"} }, - -- escape to interpreter { entry_type = core.MENU_RETURN, - name = function() - return color.highlight("Esc") .. - "ape to loader prompt" - end, + name = color.highlight("Esc") .. "ape to loader prompt", func = function() loader.setenv("autoboot_delay", "NO") end, alias = {core.KEYSTR_ESCAPE} }, - -- reboot { entry_type = core.MENU_ENTRY, - name = function() - return color.highlight("R") .. "eboot" - end, + name = color.highlight("R") .. "eboot", func = function() loader.perform("reboot") end, alias = {"r", "R"} }, - - { entry_type = core.MENU_SEPARATOR, }, - { entry_type = core.MENU_SEPARATOR, - name = function() - return "Options:" - end + name = "Options:", }, - -- kernel options { entry_type = core.MENU_CAROUSEL_ENTRY, @@ -305,14 +261,10 @@ menu.welcome = { end, alias = {"k", "K"} }, - -- boot options { entry_type = core.MENU_SUBMENU, - name = function() - return "Boot " .. color.highlight("O") .. - "ptions" - end, + name = "Boot " .. color.highlight("O") .. "ptions", submenu = menu.boot_options, alias = {"o", "O"} },