diff options
author | Kyle Evans <kevans@FreeBSD.org> | 2018-02-21 04:48:37 +0000 |
---|---|---|
committer | Kyle Evans <kevans@FreeBSD.org> | 2018-02-21 04:48:37 +0000 |
commit | a51f9f0c480fc3d10f5938c91ea0a1dd82c10fb1 (patch) | |
tree | d356907517f108e6052d0baaeada5b88f1ca27f5 /stand/lua/drawer.lua | |
parent | 9a28f948ee29bfea13c8f128383acc06b2819aeb (diff) | |
download | src-a51f9f0c480fc3d10f5938c91ea0a1dd82c10fb1.tar.gz src-a51f9f0c480fc3d10f5938c91ea0a1dd82c10fb1.zip |
lualoader: Simplify menu definitions a little further
Allow "name" entries to be simple strings, instead of just functions. We
know whether we support colors or not by the time any of this is setup, so
all menu names that are basically static with colors sprinkled in are good
candidates for simplification.
Also simplify "func" in many cases where it's just invoking another function
with no arguments. The downside to this simplification is that the functions
called can no longer be trivially replaced by a local module. The upside is
that it removes another layer of indirection that we likely don't need.
These can be re-evaluated later if a compelling argument is raised, on a
case-by-case basis, for replacement.
Notes
Notes:
svn path=/head/; revision=329699
Diffstat (limited to 'stand/lua/drawer.lua')
-rw-r--r-- | stand/lua/drawer.lua | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/stand/lua/drawer.lua b/stand/lua/drawer.lua index 9c94c9b023d2..cc75e59648a4 100644 --- a/stand/lua/drawer.lua +++ b/stand/lua/drawer.lua @@ -48,7 +48,10 @@ local menu_entry_name = function(drawing_menu, entry) if name_handler ~= nil then return name_handler(drawing_menu, entry) end - return entry.name() + if type(entry.name) == "function" then + return entry.name() + end + return entry.name end local shift_brand_text = function(shift) @@ -174,10 +177,13 @@ drawer.menu_name_handlers = { -- drawn as parameters, and return the name of the item. -- This is designed so that everything, including menu separators, may -- have their names derived differently. The default action for entry - -- types not specified here is to call and use entry.name(). + -- types not specified here is to use entry.name directly. [core.MENU_SEPARATOR] = function(drawing_menu, entry) if entry.name ~= nil then - return entry.name() + if type(entry.name) == "function" then + return entry.name() + end + return entry.name end return "" end, |