From owner-svn-src-stable-11@freebsd.org Sun May 3 03:56:18 2020 Return-Path: Delivered-To: svn-src-stable-11@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AAE942D26E4; Sun, 3 May 2020 03:56:18 +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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49FBxG3X3Kz4BBF; Sun, 3 May 2020 03:56:18 +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 693394F28; Sun, 3 May 2020 03:56:18 +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 0433uIk6037331; Sun, 3 May 2020 03:56:18 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0433uIX6037330; Sun, 3 May 2020 03:56:18 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202005030356.0433uIX6037330@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 3 May 2020 03:56:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r360598 - stable/11/stand/lua X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/stand/lua X-SVN-Commit-Revision: 360598 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 May 2020 03:56:18 -0000 Author: kevans Date: Sun May 3 03:56:17 2020 New Revision: 360598 URL: https://svnweb.freebsd.org/changeset/base/360598 Log: MFC r360199: menu.lua: Give names to menu entries Make menu customizations easier by naming the entries and using the names to build the table entries. Modified: stable/11/stand/lua/menu.lua Directory Properties: stable/11/ (props changed) Modified: stable/11/stand/lua/menu.lua ============================================================================== --- stable/11/stand/lua/menu.lua Sun May 3 03:54:49 2020 (r360597) +++ stable/11/stand/lua/menu.lua Sun May 3 03:56:17 2020 (r360598) @@ -212,30 +212,50 @@ menu.boot_options = { menu.welcome = { entries = function() 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 - -- We'll cache the swapped menu, for performance - if menu.welcome.swapped_menu ~= nil then - return menu.welcome.swapped_menu + -- Swap the first two menu items on single user boot. + -- We'll cache the alternate entries for performance. + 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 - -- Shallow copy the table - menu_entries = core.deepCopyTable(menu_entries) - - -- 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 + boot_entry_1, boot_entry_2 = single_user, multi_user + else + boot_entry_1, boot_entry_2 = multi_user, single_user 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, all_entries = { - -- boot multi user - { + multi_user = { entry_type = core.MENU_ENTRY, name = color.highlight("B") .. "oot Multi user " .. color.highlight("[Enter]"), @@ -248,8 +268,7 @@ menu.welcome = { end, alias = {"b", "B"}, }, - -- boot single user - { + single_user = { entry_type = core.MENU_ENTRY, name = "Boot " .. color.highlight("S") .. "ingle user", -- Not a standard menu entry function! @@ -261,8 +280,7 @@ menu.welcome = { end, alias = {"s", "S"}, }, - -- escape to interpreter - { + prompt = { entry_type = core.MENU_RETURN, name = color.highlight("Esc") .. "ape to loader prompt", func = function() @@ -270,8 +288,7 @@ menu.welcome = { end, alias = {core.KEYSTR_ESCAPE}, }, - -- reboot - { + reboot = { entry_type = core.MENU_ENTRY, name = color.highlight("R") .. "eboot", func = function() @@ -279,15 +296,7 @@ menu.welcome = { end, alias = {"r", "R"}, }, - { - entry_type = core.MENU_SEPARATOR, - }, - { - entry_type = core.MENU_SEPARATOR, - name = "Options:", - }, - -- kernel options - { + kernel_options = { entry_type = core.MENU_CAROUSEL_ENTRY, carousel_id = "kernel", items = core.kernelList, @@ -319,15 +328,13 @@ menu.welcome = { end, alias = {"k", "K"}, }, - -- boot options - { + boot_options = { entry_type = core.MENU_SUBMENU, name = "Boot " .. color.highlight("O") .. "ptions", submenu = menu.boot_options, alias = {"o", "O"}, }, - -- boot environments - { + boot_envs = { entry_type = core.MENU_SUBMENU, visible = function() return core.isZFSBoot() and @@ -337,8 +344,7 @@ menu.welcome = { submenu = menu.boot_environments, alias = {"e", "E"}, }, - -- chainload - { + chainload = { entry_type = core.MENU_ENTRY, name = function() return 'Chain' .. color.highlight("L") ..