Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Feb 2018 05:04:58 +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: r329700 - head/stand/lua
Message-ID:  <201802210504.w1L54wa8015716@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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)



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