From owner-svn-src-head@freebsd.org Mon Feb 26 03:46:18 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 3DF89F25982; Mon, 26 Feb 2018 03:46:18 +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 E48C07FD6C; Mon, 26 Feb 2018 03:46:17 +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 DF88B16303; Mon, 26 Feb 2018 03:46:17 +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 w1Q3kH1t037822; Mon, 26 Feb 2018 03:46:17 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1Q3kHN5037821; Mon, 26 Feb 2018 03:46:17 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802260346.w1Q3kHN5037821@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 26 Feb 2018 03:46:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r330008 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 330008 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: Mon, 26 Feb 2018 03:46:18 -0000 Author: kevans Date: Mon Feb 26 03:46:17 2018 New Revision: 330008 URL: https://svnweb.freebsd.org/changeset/base/330008 Log: 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. Modified: head/stand/lua/menu.lua Modified: head/stand/lua/menu.lua ============================================================================== --- head/stand/lua/menu.lua Mon Feb 26 03:16:57 2018 (r330007) +++ head/stand/lua/menu.lua Mon Feb 26 03:46:17 2018 (r330008) @@ -347,21 +347,21 @@ menu.default = menu.welcome -- the local alias_table in menu.process. menu.current_alias_table = {} -function menu.draw(m) +function menu.draw(menudef) -- Clear the screen, reset the cursor, then draw screen.clear() screen.defcursor() - menu.current_alias_table = drawer.drawscreen(m) - drawn_menu = m + menu.current_alias_table = drawer.drawscreen(menudef) + drawn_menu = menudef end -- '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) +function menu.process(menudef, keypress) + assert(menudef ~= nil) - if drawn_menu ~= m then - menu.draw(m) + if drawn_menu ~= menudef then + menu.draw(menudef) end while true do @@ -370,7 +370,7 @@ function menu.process(m, keypress) -- Special key behaviors if (key == core.KEY_BACKSPACE or key == core.KEY_DELETE) and - m ~= menu.default then + menudef ~= menu.default then break elseif key == core.KEY_ENTER then core.boot() @@ -389,19 +389,17 @@ function menu.process(m, keypress) -- if we have an alias do the assigned action: if sel_entry ~= nil then - -- Get menu handler 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 - -- return value means to continue. - if handler(m, sel_entry) == false then - return - end + assert(handler ~= nil) + -- The handler's return value indicates if we + -- need to exit this menu. An omitted or true + -- return value means to continue. + if handler(menudef, sel_entry) == false then + return end -- If we got an alias key the screen is out of date... -- redraw it. - menu.draw(m) + menu.draw(menudef) end end end