Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Feb 2018 01:59:41 +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: r329547 - head/stand/lua
Message-ID:  <201802190159.w1J1xfaN030091@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Mon Feb 19 01:59:41 2018
New Revision: 329547
URL: https://svnweb.freebsd.org/changeset/base/329547

Log:
  stand/lua: Allow menu items to be conditionally (in)visible
  
  This will be used to conditionally show/hide the boot environment menu.

Modified:
  head/stand/lua/drawer.lua

Modified: head/stand/lua/drawer.lua
==============================================================================
--- head/stand/lua/drawer.lua	Mon Feb 19 01:49:19 2018	(r329546)
+++ head/stand/lua/drawer.lua	Mon Feb 19 01:59:41 2018	(r329547)
@@ -167,6 +167,11 @@ function drawer.drawmenu(m)
 	local alias_table = {};
 	local entry_num = 0;
 	for line_num, e in ipairs(m) do
+		-- Allow menu items to be conditionally visible by specifying
+		-- a visible function.
+		if (e.visible ~= nil) and (not e.visible()) then
+			goto continue
+		end
 		if (e.entry_type ~= core.MENU_SEPARATOR) then
 			entry_num = entry_num + 1;
 			screen.setcursor(x, y + line_num);
@@ -197,6 +202,7 @@ function drawer.drawmenu(m)
 			screen.setcursor(x, y + line_num);
 			print(e.name());
 		end
+		::continue::
 	end
 	return alias_table;
 end



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