From owner-svn-src-all@freebsd.org Tue Feb 20 14:36:29 2018 Return-Path: Delivered-To: svn-src-all@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 45D66F06E14; Tue, 20 Feb 2018 14:36:29 +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 EB90879AC4; Tue, 20 Feb 2018 14:36:28 +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 E1D412A1A; Tue, 20 Feb 2018 14:36:28 +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 w1KEaSoH067846; Tue, 20 Feb 2018 14:36:28 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1KEaSXn067843; Tue, 20 Feb 2018 14:36:28 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201802201436.w1KEaSXn067843@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Tue, 20 Feb 2018 14:36:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329640 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 329640 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Feb 2018 14:36:29 -0000 Author: kevans Date: Tue Feb 20 14:36:28 2018 New Revision: 329640 URL: https://svnweb.freebsd.org/changeset/base/329640 Log: stand/lua: Consistently declare local functions at module scope Declare these adjacent to the local definitions at the top of the module, and make sure they're actually declared local to pollute global namespace a little bit less. Modified: head/stand/lua/drawer.lua head/stand/lua/menu.lua head/stand/lua/screen.lua Modified: head/stand/lua/drawer.lua ============================================================================== --- head/stand/lua/drawer.lua Tue Feb 20 10:52:07 2018 (r329639) +++ head/stand/lua/drawer.lua Tue Feb 20 14:36:28 2018 (r329640) @@ -41,6 +41,24 @@ local orb; local none; local none_shifted = false; +local menu_entry_name = function(drawing_menu, entry) + local name_handler = drawer.menu_name_handlers[entry.entry_type]; + + if (name_handler ~= nil) then + return name_handler(drawing_menu, entry); + end + return entry.name(); +end + +local shift_brand_text = function(shift) + drawer.brand_position.x = drawer.brand_position.x + shift.x; + drawer.brand_position.y = drawer.brand_position.y + shift.y; + drawer.menu_position.x = drawer.menu_position.x + shift.x; + drawer.menu_position.y = drawer.menu_position.y + shift.y; + drawer.box_pos_dim.x = drawer.box_pos_dim.x + shift.x; + drawer.box_pos_dim.y = drawer.box_pos_dim.y + shift.y; +end + drawer.menu_name_handlers = { -- Menu name handlers should take the menu being drawn and entry being -- drawn as parameters, and return the name of the item. @@ -228,15 +246,6 @@ function drawer.drawscreen(menu_opts) return drawer.drawmenu(menu_opts); end -function menu_entry_name(drawing_menu, entry) - local name_handler = drawer.menu_name_handlers[entry.entry_type]; - - if (name_handler ~= nil) then - return name_handler(drawing_menu, entry); - end - return entry.name(); -end - function drawer.drawmenu(m) x = drawer.menu_position.x; y = drawer.menu_position.y; @@ -332,15 +341,6 @@ function drawer.drawbrand() graphic = fbsd_logo; end drawer.draw(x, y, graphic); -end - -function shift_brand_text(shift) - drawer.brand_position.x = drawer.brand_position.x + shift.x; - drawer.brand_position.y = drawer.brand_position.y + shift.y; - drawer.menu_position.x = drawer.menu_position.x + shift.x; - drawer.menu_position.y = drawer.menu_position.y + shift.y; - drawer.box_pos_dim.x = drawer.box_pos_dim.x + shift.x; - drawer.box_pos_dim.y = drawer.box_pos_dim.y + shift.y; end function drawer.drawlogo() Modified: head/stand/lua/menu.lua ============================================================================== --- head/stand/lua/menu.lua Tue Feb 20 10:52:07 2018 (r329639) +++ head/stand/lua/menu.lua Tue Feb 20 14:36:28 2018 (r329640) @@ -36,12 +36,22 @@ local drawer = require("drawer"); local menu = {}; -local OnOff; local skip; local run; local autoboot; local carousel_choices = {}; +local OnOff = function(str, b) + if (b) then + return str .. color.escapef(color.GREEN) .. "On" .. + color.escapef(color.WHITE); + else + return str .. color.escapef(color.RED) .. "off" .. + color.escapef(color.WHITE); + end +end + + menu.handlers = { -- Menu handlers take the current menu and selected entry as parameters, -- and should return a boolean indicating whether execution should @@ -459,16 +469,6 @@ function menu.autoboot() until time <= 0; core.boot(); -end - -function OnOff(str, b) - if (b) then - return str .. color.escapef(color.GREEN) .. "On" .. - color.escapef(color.WHITE); - else - return str .. color.escapef(color.RED) .. "off" .. - color.escapef(color.WHITE); - end end return menu; Modified: head/stand/lua/screen.lua ============================================================================== --- head/stand/lua/screen.lua Tue Feb 20 10:52:07 2018 (r329639) +++ head/stand/lua/screen.lua Tue Feb 20 14:36:28 2018 (r329640) @@ -32,7 +32,7 @@ local core = require("core"); local screen = {}; -- XXX TODO: This should be fixed in the interpreter to not print decimals -function intstring(num) +local intstring = function(num) local str = tostring(num); local decimal = str:find("%.");