mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-27 16:39:08 +00:00
lualoader: A little more general menu cleanup
Instead of a single-letter parameter ('m'), use something a little more descriptive and meaningful: 'menudef' ("menu definition") -- these functions expect to be passed a menudef, so call it what it is. While here, throw an assertion in that we have a handler for the selected menu item. This is more of a debugging aide so that it's more obvious when one is testing a menudef that they've added an entry item that we don't handle. This is an improvement over the past behavior of ignoring the unknown menu entry.
This commit is contained in:
parent
fcd13be6e2
commit
2a11b81090
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=330008
@ -347,21 +347,21 @@ menu.default = menu.welcome
|
|||||||
-- the local alias_table in menu.process.
|
-- the local alias_table in menu.process.
|
||||||
menu.current_alias_table = {}
|
menu.current_alias_table = {}
|
||||||
|
|
||||||
function menu.draw(m)
|
function menu.draw(menudef)
|
||||||
-- Clear the screen, reset the cursor, then draw
|
-- Clear the screen, reset the cursor, then draw
|
||||||
screen.clear()
|
screen.clear()
|
||||||
screen.defcursor()
|
screen.defcursor()
|
||||||
menu.current_alias_table = drawer.drawscreen(m)
|
menu.current_alias_table = drawer.drawscreen(menudef)
|
||||||
drawn_menu = m
|
drawn_menu = menudef
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 'keypress' allows the caller to indicate that a key has been pressed that we
|
-- 'keypress' allows the caller to indicate that a key has been pressed that we
|
||||||
-- should process as our initial input.
|
-- should process as our initial input.
|
||||||
function menu.process(m, keypress)
|
function menu.process(menudef, keypress)
|
||||||
assert(m ~= nil)
|
assert(menudef ~= nil)
|
||||||
|
|
||||||
if drawn_menu ~= m then
|
if drawn_menu ~= menudef then
|
||||||
menu.draw(m)
|
menu.draw(menudef)
|
||||||
end
|
end
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
@ -370,7 +370,7 @@ function menu.process(m, keypress)
|
|||||||
|
|
||||||
-- Special key behaviors
|
-- Special key behaviors
|
||||||
if (key == core.KEY_BACKSPACE or key == core.KEY_DELETE) and
|
if (key == core.KEY_BACKSPACE or key == core.KEY_DELETE) and
|
||||||
m ~= menu.default then
|
menudef ~= menu.default then
|
||||||
break
|
break
|
||||||
elseif key == core.KEY_ENTER then
|
elseif key == core.KEY_ENTER then
|
||||||
core.boot()
|
core.boot()
|
||||||
@ -389,19 +389,17 @@ function menu.process(m, keypress)
|
|||||||
|
|
||||||
-- if we have an alias do the assigned action:
|
-- if we have an alias do the assigned action:
|
||||||
if sel_entry ~= nil then
|
if sel_entry ~= nil then
|
||||||
-- Get menu handler
|
|
||||||
local handler = menu.handlers[sel_entry.entry_type]
|
local handler = menu.handlers[sel_entry.entry_type]
|
||||||
if handler ~= nil then
|
assert(handler ~= nil)
|
||||||
-- The handler's return value indicates if we
|
-- The handler's return value indicates if we
|
||||||
-- need to exit this menu. An omitted or true
|
-- need to exit this menu. An omitted or true
|
||||||
-- return value means to continue.
|
-- return value means to continue.
|
||||||
if handler(m, sel_entry) == false then
|
if handler(menudef, sel_entry) == false then
|
||||||
return
|
return
|
||||||
end
|
|
||||||
end
|
end
|
||||||
-- If we got an alias key the screen is out of date...
|
-- If we got an alias key the screen is out of date...
|
||||||
-- redraw it.
|
-- redraw it.
|
||||||
menu.draw(m)
|
menu.draw(menudef)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user