svn commit: r329700 - head/stand/lua

Kyle Evans kevans at FreeBSD.org
Wed Feb 21 05:04:59 UTC 2018


Author: kevans
Date: Wed Feb 21 05:04:58 2018
New Revision: 329700
URL: https://svnweb.freebsd.org/changeset/base/329700

Log:
  lualoader: Allow carousel 'items' to be a table as well as a function
  
  We don't have any in-tree users of this, but for a static set of carousel
  options having to define a callback is excessive.

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

Modified: head/stand/lua/drawer.lua
==============================================================================
--- head/stand/lua/drawer.lua	Wed Feb 21 04:48:37 2018	(r329699)
+++ head/stand/lua/drawer.lua	Wed Feb 21 05:04:58 2018	(r329700)
@@ -190,8 +190,10 @@ drawer.menu_name_handlers = {
 	[core.MENU_CAROUSEL_ENTRY] = function(drawing_menu, entry)
 		local carid = entry.carousel_id
 		local caridx = config.getCarouselIndex(carid)
-		local choices = entry.items()
-
+		local choices = entry.items
+		if type(choices) == "function" then
+			choices = choices()
+		end
 		if #choices < caridx then
 			caridx = 1
 		end

Modified: head/stand/lua/menu.lua
==============================================================================
--- head/stand/lua/menu.lua	Wed Feb 21 04:48:37 2018	(r329699)
+++ head/stand/lua/menu.lua	Wed Feb 21 05:04:58 2018	(r329700)
@@ -65,8 +65,10 @@ menu.handlers = {
 		-- carousel (rotating) functionality
 		local carid = entry.carousel_id
 		local caridx = config.getCarouselIndex(carid)
-		local choices = entry.items()
-
+		local choices = entry.items
+		if type(choices) == "function" then
+			choices = choices()
+		end
 		if #choices > 0 then
 			caridx = (caridx % #choices) + 1
 			config.setCarouselIndex(carid, caridx)


More information about the svn-src-all mailing list