Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Feb 2018 04:31:09 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r329355 - head/stand/lua
Message-ID:  <201802160431.w1G4V9iu022398@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Fri Feb 16 04:31:09 2018
New Revision: 329355
URL: https://svnweb.freebsd.org/changeset/base/329355

Log:
  stand/lua: Move kernel selection into main menu
  
  This matches the corresponding 4th behavior.

Modified:
  head/stand/lua/menu.lua

Modified: head/stand/lua/menu.lua
==============================================================================
--- head/stand/lua/menu.lua	Fri Feb 16 04:30:57 2018	(r329354)
+++ head/stand/lua/menu.lua	Fri Feb 16 04:31:09 2018	(r329355)
@@ -39,26 +39,14 @@ local OnOff;
 local skip;
 local run;
 local autoboot;
+local current_kernel_index = 1;
 
 --loader menu tree:
 --rooted at menu.welcome
 --submenu declarations:
-local kernel_options;
 local boot_options;
 local welcome;
 
-menu.kernel_options = {
-	-- this table is dynamically appended to when accessed
-	-- return to welcome menu
-	{
-		entry_type = "return",
-		name = function()
-			return "Back to main menu"..color.highlight(" [Backspace]");
-		end,
-		alias = {"\08"}
-	}
-};
-
 menu.boot_options = {
 	-- return to welcome menu
 	{
@@ -206,35 +194,34 @@ menu.welcome = {
 
 	-- kernel options
 	{
-		entry_type = "submenu",
+		entry_type = "entry",
 		name = function()
 			local kernels = core.kernelList();
 			if #kernels == 0 then
-				return "Kernels (not available)";
+				return "Kernel: ";
 			end
-			return color.highlight("K").."ernels";
+
+			local kernel_name = color.escapef(color.GREEN) ..
+			    kernels[current_kernel_index] .. color.default();
+			if (current_kernel_index == 1) then
+				kernel_name = "default/" .. kernel_name;
+			end
+			return color.highlight("K").."ernel: " .. kernel_name ..
+			    " (" .. current_kernel_index ..
+			    " of " .. #kernels .. ")";
 		end,
-		submenu = function()
+		func = function()
 
 			-- dynamically build the kernel menu:
 			local kernels = core.kernelList();
-			if #kernels == 0 then
+			-- Don't do anything if we don't have multiple kernels
+			if #kernels <= 1 then
 				return nil;
 			end
-			for k, v in ipairs(kernels) do
-				menu.kernel_options[#menu.kernel_options + 1] = {
-					entry_type = "entry",
-					name = function()
-						return v;
-					end,
-					func = function()
-						config.reload(v);
-					end,
-					alias = {} -- automatically enumerated
-				}
-			end
-
-			return menu.kernel_options;
+			current_kernel_index = (current_kernel_index % #kernels)
+			    + 1;
+			local current_kernel = kernels[current_kernel_index];
+			config.reload(current_kernel)
 		end,
 		alias = {"k", "K"}
 	},



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802160431.w1G4V9iu022398>