Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Feb 2018 14:57:42 +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: r329368 - head/stand/lua
Message-ID:  <201802161457.w1GEvgQs038127@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Fri Feb 16 14:57:42 2018
New Revision: 329368
URL: https://svnweb.freebsd.org/changeset/base/329368

Log:
  stand/lua: Create/use some MENU_ constants where applicable

Modified:
  head/stand/lua/core.lua
  head/stand/lua/drawer.lua
  head/stand/lua/menu.lua

Modified: head/stand/lua/core.lua
==============================================================================
--- head/stand/lua/core.lua	Fri Feb 16 14:39:41 2018	(r329367)
+++ head/stand/lua/core.lua	Fri Feb 16 14:57:42 2018	(r329368)
@@ -29,11 +29,17 @@
 local core = {};
 
 -- Commonly appearing constants
-core.KEY_ENTER = 13;
-core.KEY_BACKSPACE = 127;
+core.KEY_ENTER		= 13;
+core.KEY_BACKSPACE	= 127;
 
-core.KEYSTR_ESCAPE = "\027";
+core.KEYSTR_ESCAPE	= "\027";
 
+core.MENU_RETURN	= "return";
+core.MENU_ENTRY		= "entry";
+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;
@@ -119,6 +125,7 @@ function core.kernelList()
 	local k = loader.getenv("kernel");
 	local v = loader.getenv("kernels") or "";
 
+	v = "kernel;kernel.GENERIC"
 	local kernels = {};
 	local i = 0;
 	if k ~= nil then

Modified: head/stand/lua/drawer.lua
==============================================================================
--- head/stand/lua/drawer.lua	Fri Feb 16 14:39:41 2018	(r329367)
+++ head/stand/lua/drawer.lua	Fri Feb 16 14:57:42 2018	(r329368)
@@ -29,6 +29,7 @@
 local drawer = {};
 
 local color = require("color");
+local core = require("core");
 local screen = require("screen");
 
 drawer.brand_position = {x = 2, y = 1};
@@ -166,12 +167,12 @@ function drawer.drawmenu(m)
 	local alias_table = {};
 	local entry_num = 0;
 	for line_num, e in ipairs(m) do
-		if (e.entry_type ~= "separator") then
+		if (e.entry_type ~= core.MENU_SEPARATOR) then
 			entry_num = entry_num + 1;
 			screen.setcursor(x, y + line_num);
 			local name = "";
 
-			if (e.entry_type == "carousel_entry") then
+			if (e.entry_type == core.MENU_CAROUSEL_ENTRY) then
 				local carid = e.carousel_id;
 				local caridx = menu.getCarouselIndex(carid);
 				local choices = e.items();

Modified: head/stand/lua/menu.lua
==============================================================================
--- head/stand/lua/menu.lua	Fri Feb 16 14:39:41 2018	(r329367)
+++ head/stand/lua/menu.lua	Fri Feb 16 14:57:42 2018	(r329368)
@@ -50,7 +50,7 @@ local welcome;
 menu.boot_options = {
 	-- return to welcome menu
 	{
-		entry_type = "return",
+		entry_type = core.MENU_RETURN,
 		name = function()
 			return "Back to main menu"..color.highlight(" [Backspace]");
 		end
@@ -58,7 +58,7 @@ menu.boot_options = {
 
 	-- load defaults
 	{
-		entry_type = "entry",
+		entry_type = core.MENU_ENTRY,
 		name = function()
 			return "Load System "..color.highlight("D").."efaults";
 		end,
@@ -69,14 +69,14 @@ menu.boot_options = {
 	},
 
 	{
-		entry_type = "separator",
+		entry_type = core.MENU_SEPARATOR,
 		name = function()
 			return "";
 		end
 	},
 
 	{
-		entry_type = "separator",
+		entry_type = core.MENU_SEPARATOR,
 		name = function()
 			return "Boot Options:";
 		end
@@ -84,7 +84,7 @@ menu.boot_options = {
 
 	-- acpi
 	{
-		entry_type = "entry",
+		entry_type = core.MENU_ENTRY,
 		name = function()
 			return OnOff(color.highlight("A").."CPI       :", core.acpi);
 		end,
@@ -95,7 +95,7 @@ menu.boot_options = {
 	},
 	-- safe mode
 	{
-		entry_type = "entry",
+		entry_type = core.MENU_ENTRY,
 		name = function()
 			return OnOff("Safe "..color.highlight("M").."ode  :", core.sm);
 		end,
@@ -106,7 +106,7 @@ menu.boot_options = {
 	},
 	-- single user
 	{
-		entry_type = "entry",
+		entry_type = core.MENU_ENTRY,
 		name = function()
 			return OnOff(color.highlight("S").."ingle user:", core.su);
 		end,
@@ -117,7 +117,7 @@ menu.boot_options = {
 	},
 	-- verbose boot
 	{
-		entry_type = "entry",
+		entry_type = core.MENU_ENTRY,
 		name = function()
 			return OnOff(color.highlight("V").."erbose    :", core.verbose);
 		end,
@@ -131,7 +131,7 @@ menu.boot_options = {
 menu.welcome = {
 	-- boot multi user
 	{
-		entry_type = "entry",
+		entry_type = core.MENU_ENTRY,
 		name = function()
 			return color.highlight("B").."oot Multi user "..color.highlight("[Enter]");
 		end,
@@ -144,7 +144,7 @@ menu.welcome = {
 
 	-- boot single user
 	{
-		entry_type = "entry",
+		entry_type = core.MENU_ENTRY,
 		name = function()
 			return "Boot "..color.highlight("S").."ingle user";
 		end,
@@ -157,7 +157,7 @@ menu.welcome = {
 
 	-- escape to interpreter
 	{
-		entry_type = "return",
+		entry_type = core.MENU_RETURN,
 		name = function()
 			return color.highlight("Esc").."ape to loader prompt";
 		end,
@@ -166,7 +166,7 @@ menu.welcome = {
 
 	-- reboot
 	{
-		entry_type = "entry",
+		entry_type = core.MENU_ENTRY,
 		name = function()
 			return color.highlight("R").."eboot";
 		end,
@@ -178,14 +178,14 @@ menu.welcome = {
 
 
 	{
-		entry_type = "separator",
+		entry_type = core.MENU_SEPARATOR,
 		name = function()
 			return "";
 		end
 	},
 
 	{
-		entry_type = "separator",
+		entry_type = core.MENU_SEPARATOR,
 		name = function()
 			return "Options:";
 		end
@@ -193,7 +193,7 @@ menu.welcome = {
 
 	-- kernel options
 	{
-		entry_type = "carousel_entry",
+		entry_type = core.MENU_CAROUSEL_ENTRY,
 		carousel_id = "kernel",
 		items = core.kernelList,
 		name = function(idx, choice, all_choices)
@@ -218,7 +218,7 @@ menu.welcome = {
 
 	-- boot options
 	{
-		entry_type = "submenu",
+		entry_type = core.MENU_SUBMENU,
 		name = function()
 			return "Boot "..color.highlight("O").."ptions";
 		end,
@@ -284,10 +284,10 @@ function menu.run(m)
 
 		-- if we have an alias do the assigned action:
 		if(sel_entry ~= nil) then
-			if (sel_entry.entry_type == "entry") then
+			if (sel_entry.entry_type == core.MENU_ENTRY) then
 				-- run function
 				sel_entry.func();
-			elseif (sel_entry.entry_type == "carousel_entry") then
+			elseif (sel_entry.entry_type == core.MENU_CAROUSEL_ENTRY) then
 				-- carousel (rotating) functionality
 				local carid = sel_entry.carousel_id;
 				local caridx = menu.getCarouselIndex(carid);
@@ -296,10 +296,10 @@ function menu.run(m)
 				caridx = (caridx % #choices) + 1;
 				menu.setCarouselIndex(carid, caridx);
 				sel_entry.func(choices[caridx]);
-			elseif (sel_entry.entry_type == "submenu") then
+			elseif (sel_entry.entry_type == core.MENU_SUBMENU) then
 				-- recurse
 				cont = menu.run(sel_entry.submenu());
-			elseif (sel_entry.entry_type == "return") then
+			elseif (sel_entry.entry_type == core.MENU_RETURN) then
 				-- break recurse
 				cont = false;
 			end



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