From owner-svn-src-head@freebsd.org Sun Feb 25 04:44:46 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7C7D3F03D28; Sun, 25 Feb 2018 04:44:46 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2E824692AB; Sun, 25 Feb 2018 04:44:46 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 297882FE2C; Sun, 25 Feb 2018 04:44:46 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1P4ikqZ037926; Sun, 25 Feb 2018 04:44:46 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1P4ikVh037925; Sun, 25 Feb 2018 04:44:46 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802250444.w1P4ikVh037925@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 25 Feb 2018 04:44:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329947 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 329947 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Feb 2018 04:44:46 -0000 Author: kevans Date: Sun Feb 25 04:44:45 2018 New Revision: 329947 URL: https://svnweb.freebsd.org/changeset/base/329947 Log: lualoader: Pull menu redrawing specifics out of menu.process In general, every menu redraw is going to require a screen clear and cursor reset. Each redraw also has the potential to invalidate the alias table, so we move the alias table being used out into a module variable. This allows third party consumers to also inspect or update the alias table if they need to. While here, stop searching the alias table once we've found a match. Modified: head/stand/lua/menu.lua Modified: head/stand/lua/menu.lua ============================================================================== --- head/stand/lua/menu.lua Sun Feb 25 04:11:08 2018 (r329946) +++ head/stand/lua/menu.lua Sun Feb 25 04:44:45 2018 (r329947) @@ -341,14 +341,24 @@ menu.welcome = { } menu.default = menu.welcome +-- current_alias_table will be used to keep our alias table consistent across +-- screen redraws, instead of relying on whatever triggered the redraw to update +-- the local alias_table in menu.process. +menu.current_alias_table = {} -function menu.process(m) - assert(m ~= nil) +function menu.redraw(m) -- redraw screen screen.clear() screen.defcursor() - local alias_table = drawer.drawscreen(m) + menu.current_alias_table = drawer.drawscreen(m) +end +function menu.process(m) + assert(m ~= nil) + + -- Trigger a redraw if we've not been drawn + menu.redraw(m) + -- autoboot processing likely belongs better in menu.run, but we want -- to draw the menu once before we do any autoboot prompting. We also -- collect the alias table from the drawer, which generates the table @@ -375,9 +385,10 @@ function menu.process(m) key = string.char(key) -- check to see if key is an alias local sel_entry = nil - for k, v in pairs(alias_table) do + for k, v in pairs(menu.current_alias_table) do if key == k then sel_entry = v + break end end @@ -387,16 +398,15 @@ function menu.process(m) local handler = menu.handlers[sel_entry.entry_type] if handler ~= nil then -- 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. if handler(m, sel_entry) == false then return end end - -- if we got an alias key the screen is out of date: - screen.clear() - screen.defcursor() - alias_table = drawer.drawscreen(m) + -- If we got an alias key the screen is out of date... + -- redraw it. + menu.redraw(m) end end end