From 4a4fb4f8d6a36bb28c10137ff6d3074b5a81442b Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Mon, 19 Feb 2018 01:59:41 +0000 Subject: [PATCH] stand/lua: Allow menu items to be conditionally (in)visible This will be used to conditionally show/hide the boot environment menu. --- stand/lua/drawer.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/stand/lua/drawer.lua b/stand/lua/drawer.lua index 541b774bc82e..1759abe661f9 100644 --- a/stand/lua/drawer.lua +++ b/stand/lua/drawer.lua @@ -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