From owner-svn-src-head@freebsd.org Sun Feb 25 05:00:55 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 7E562F04596; Sun, 25 Feb 2018 05:00:55 +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 2DE9569B9A; Sun, 25 Feb 2018 05:00:55 +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 0FA9718D; Sun, 25 Feb 2018 05:00:55 +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 w1P50sEi043316; Sun, 25 Feb 2018 05:00:54 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1P50sZ7043315; Sun, 25 Feb 2018 05:00:54 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802250500.w1P50sZ7043315@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 05:00:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329948 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 329948 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 05:00:55 -0000 Author: kevans Date: Sun Feb 25 05:00:54 2018 New Revision: 329948 URL: https://svnweb.freebsd.org/changeset/base/329948 Log: lualoader: Pull autoboot handling out into menu.run() There's no reason for autoboot handling to be mixed in with menu processing. It is a distinct process that should only be done once when entering the menu system. menu.process has been modified to take an initial keypress to process and to only draw the screen initially if it's been invalidated. The keypress is kind of a kludge, although it could be argued to be a potentially useful kludge if there are other processes that may need to feed a keypress into the menu system. Modified: head/stand/lua/menu.lua Modified: head/stand/lua/menu.lua ============================================================================== --- head/stand/lua/menu.lua Sun Feb 25 04:44:45 2018 (r329947) +++ head/stand/lua/menu.lua Sun Feb 25 05:00:54 2018 (r329948) @@ -38,6 +38,8 @@ local drawer = require("drawer") local menu = {} +local screen_invalid = true + local function OnOff(str, b) if b then return str .. color.escapef(color.GREEN) .. "On" .. @@ -80,7 +82,7 @@ menu.handlers = { end end, [core.MENU_SUBMENU] = function(_, entry) - -- recurse + screen_invalid = true menu.process(entry.submenu) end, [core.MENU_RETURN] = function(_, entry) @@ -351,27 +353,23 @@ function menu.redraw(m) screen.clear() screen.defcursor() menu.current_alias_table = drawer.drawscreen(m) + screen_invalid = false end -function menu.process(m) +-- 'keypress' allows the caller to indicate that a key has been pressed that we +-- should process as our initial input. +function menu.process(m, keypress) 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 - -- based on all of the 'alias' entries along with effective line numbers - -- that each entry is drawn at. This makes it cleaner to handle here, - -- for the time being. - local autoboot_key; - if m == menu.default then - autoboot_key = menu.autoboot() + -- 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) end + while true do - local key = autoboot_key or io.getchar() - autoboot_key = nil + local key = keypress or io.getchar() + keypress = nil -- Special key behaviors if (key == core.KEY_BACKSPACE or key == core.KEY_DELETE) and @@ -417,7 +415,10 @@ function menu.run() return end - menu.process(menu.default) + menu.redraw(menu.default) + local autoboot_key = menu.autoboot() + + menu.process(menu.default, autoboot_key) screen.defcursor() print("Exiting menu!")