svn commit: r329987 - head/stand/lua
Kyle Evans
kevans at FreeBSD.org
Sun Feb 25 17:02:52 UTC 2018
Author: kevans
Date: Sun Feb 25 17:02:50 2018
New Revision: 329987
URL: https://svnweb.freebsd.org/changeset/base/329987
Log:
lualoader: Track the menu currently drawn, instead of validity
This cleans up the odd approach to menu drawing. Instead of tracking
validity, we track the menu that was drawn on the screen. Whenever we draw a
menu, we'll set this to that menu.
Anything that invalidates the screen should go ahead and trigger an explicit
redraw, rather than finding a wy to set screen_invalid.
The currently drawn menu is then reset in menu.run as we exit the menu
system, so that dropping to the loader prompt or leaving menu.run() will
just behave as expected without doing redundant work every time we leave a
menu.
Modified:
head/stand/lua/menu.lua
Modified: head/stand/lua/menu.lua
==============================================================================
--- head/stand/lua/menu.lua Sun Feb 25 16:29:02 2018 (r329986)
+++ head/stand/lua/menu.lua Sun Feb 25 17:02:50 2018 (r329987)
@@ -38,7 +38,7 @@ local drawer = require("drawer")
local menu = {}
-local screen_invalid = true
+local drawn_menu
local function OnOff(str, b)
if b then
@@ -82,7 +82,6 @@ menu.handlers = {
end
end,
[core.MENU_SUBMENU] = function(_, entry)
- screen_invalid = true
menu.process(entry.submenu)
end,
[core.MENU_RETURN] = function(_, entry)
@@ -348,12 +347,12 @@ menu.default = menu.welcome
-- the local alias_table in menu.process.
menu.current_alias_table = {}
-function menu.redraw(m)
- -- redraw screen
+function menu.draw(m)
+ -- Clear the screen, reset the cursor, then draw
screen.clear()
screen.defcursor()
menu.current_alias_table = drawer.drawscreen(m)
- screen_invalid = false
+ drawn_menu = m
end
-- 'keypress' allows the caller to indicate that a key has been pressed that we
@@ -361,10 +360,8 @@ end
function menu.process(m, keypress)
assert(m ~= nil)
- -- Trigger a redraw if we've been invalidated. Otherwise, we assume
- -- that this menu has already been drawn.
- if screen_invalid then
- menu.redraw(m)
+ if drawn_menu ~= m then
+ menu.draw(m)
end
while true do
@@ -404,13 +401,9 @@ function menu.process(m, keypress)
end
-- If we got an alias key the screen is out of date...
-- redraw it.
- menu.redraw(m)
+ menu.draw(m)
end
end
- -- Invalidate the screen upon exit so that it gets redrawn upon
- -- processing a new menu, assuming it won't be redrawn after leaving
- -- this menu
- screen_invalid = false
end
function menu.run()
@@ -419,10 +412,11 @@ function menu.run()
return
end
- menu.redraw(menu.default)
+ menu.draw(menu.default)
local autoboot_key = menu.autoboot()
menu.process(menu.default, autoboot_key)
+ drawn_menu = nil
screen.defcursor()
print("Exiting menu!")
More information about the svn-src-all
mailing list