From owner-svn-src-head@freebsd.org Sun Aug 19 18:22:02 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 0F49E10735AD; Sun, 19 Aug 2018 18:22:02 +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 B96E283D17; Sun, 19 Aug 2018 18:22:01 +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 823D91FDB; Sun, 19 Aug 2018 18:22:01 +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 w7JIM1rc077281; Sun, 19 Aug 2018 18:22:01 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w7JIM1xi077280; Sun, 19 Aug 2018 18:22:01 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201808191822.w7JIM1xi077280@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 19 Aug 2018 18:22:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r338065 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 338065 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.27 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, 19 Aug 2018 18:22:02 -0000 Author: kevans Date: Sun Aug 19 18:22:01 2018 New Revision: 338065 URL: https://svnweb.freebsd.org/changeset/base/338065 Log: lualoader: Hide most of the internal drawing functions Ideally, all of the functionality to revamp the loader screen has associated APIs that are flexible enough that third-party scripts wouldn't need to override these. Modified: head/stand/lua/drawer.lua Modified: head/stand/lua/drawer.lua ============================================================================== --- head/stand/lua/drawer.lua Sun Aug 19 18:18:19 2018 (r338064) +++ head/stand/lua/drawer.lua Sun Aug 19 18:22:01 2018 (r338065) @@ -90,131 +90,7 @@ local function draw(x, y, logo) end end -fbsd_brand = { -" ______ ____ _____ _____ ", -" | ____| | _ \\ / ____| __ \\ ", -" | |___ _ __ ___ ___ | |_) | (___ | | | |", -" | ___| '__/ _ \\/ _ \\| _ < \\___ \\| | | |", -" | | | | | __/ __/| |_) |____) | |__| |", -" | | | | | | || | | |", -" |_| |_| \\___|\\___||____/|_____/|_____/ " -} -none = {""} - --- Module exports -drawer.default_brand = 'fbsd' - -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. - -- This is designed so that everything, including menu separators, may - -- have their names derived differently. The default action for entry - -- types not specified here is to use entry.name directly. - [core.MENU_SEPARATOR] = function(_, entry) - if entry.name ~= nil then - if type(entry.name) == "function" then - return entry.name() - end - return entry.name - end - return "" - end, - [core.MENU_CAROUSEL_ENTRY] = function(_, entry) - local carid = entry.carousel_id - local caridx = config.getCarouselIndex(carid) - local choices = entry.items - if type(choices) == "function" then - choices = choices() - end - if #choices < caridx then - caridx = 1 - end - return entry.name(caridx, choices[caridx], choices) - end, -} - -drawer.brand_position = {x = 2, y = 1} -drawer.logo_position = {x = 46, y = 4} -drawer.menu_position = {x = 5, y = 10} -drawer.frame_size = {w = 42, h = 13} -drawer.default_shift = {x = 0, y = 0} -drawer.shift = drawer.default_shift - -drawer.branddefs = { - -- Indexed by valid values for loader_brand in loader.conf(5). Valid - -- keys are: graphic (table depicting graphic) - ["fbsd"] = { - graphic = fbsd_brand, - }, - ["none"] = { - graphic = none, - }, -} - -function drawer.addBrand(name, def) - drawer.branddefs[name] = def -end - -function drawer.addLogo(name, def) - drawer.logodefs[name] = def -end - -drawer.logodefs = { - -- Indexed by valid values for loader_logo in loader.conf(5). Valid keys - -- are: requires_color (boolean), graphic (table depicting graphic), and - -- shift (table containing x and y). - ["tribute"] = { - graphic = fbsd_brand, - }, - ["tributebw"] = { - graphic = fbsd_brand, - }, - ["none"] = { - graphic = none, - shift = {x = 17, y = 0}, - }, -} - -drawer.frame_styles = { - -- Indexed by valid values for loader_menu_frame in loader.conf(5). - -- All of the keys appearing below must be set for any menu frame style - -- added to drawer.frame_styles. - ["ascii"] = { - horizontal = "-", - vertical = "|", - top_left = "+", - bottom_left = "+", - top_right = "+", - bottom_right = "+", - }, - ["single"] = { - horizontal = "\xC4", - vertical = "\xB3", - top_left = "\xDA", - bottom_left = "\xC0", - top_right = "\xBF", - bottom_right = "\xD9", - }, - ["double"] = { - horizontal = "\xCD", - vertical = "\xBA", - top_left = "\xC9", - bottom_left = "\xC8", - top_right = "\xBB", - bottom_right = "\xBC", - }, -} - -function drawer.drawscreen(menu_opts) - -- drawlogo() must go first. - -- it determines the positions of other elements - drawer.drawlogo() - drawer.drawbrand() - drawer.drawbox() - return drawer.drawmenu(menu_opts) -end - -function drawer.drawmenu(menudef) +local function drawmenu(menudef) local x = drawer.menu_position.x local y = drawer.menu_position.y @@ -258,7 +134,7 @@ function drawer.drawmenu(menudef) return alias_table end -function drawer.drawbox() +local function drawbox() local x = drawer.menu_position.x - 3 local y = drawer.menu_position.y - 1 local w = drawer.frame_size.w @@ -327,7 +203,7 @@ function drawer.drawbox() printc(menu_header) end -function drawer.drawbrand() +local function drawbrand() local x = tonumber(loader.getenv("loader_brand_x")) or drawer.brand_position.x local y = tonumber(loader.getenv("loader_brand_y")) or @@ -346,7 +222,7 @@ function drawer.drawbrand() draw(x, y, graphic) end -function drawer.drawlogo() +local function drawlogo() local x = tonumber(loader.getenv("loader_logo_x")) or drawer.logo_position.x local y = tonumber(loader.getenv("loader_logo_y")) or @@ -382,6 +258,130 @@ function drawer.drawlogo() end draw(x, y, logodef.graphic) +end + +fbsd_brand = { +" ______ ____ _____ _____ ", +" | ____| | _ \\ / ____| __ \\ ", +" | |___ _ __ ___ ___ | |_) | (___ | | | |", +" | ___| '__/ _ \\/ _ \\| _ < \\___ \\| | | |", +" | | | | | __/ __/| |_) |____) | |__| |", +" | | | | | | || | | |", +" |_| |_| \\___|\\___||____/|_____/|_____/ " +} +none = {""} + +-- Module exports +drawer.default_brand = 'fbsd' + +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. + -- This is designed so that everything, including menu separators, may + -- have their names derived differently. The default action for entry + -- types not specified here is to use entry.name directly. + [core.MENU_SEPARATOR] = function(_, entry) + if entry.name ~= nil then + if type(entry.name) == "function" then + return entry.name() + end + return entry.name + end + return "" + end, + [core.MENU_CAROUSEL_ENTRY] = function(_, entry) + local carid = entry.carousel_id + local caridx = config.getCarouselIndex(carid) + local choices = entry.items + if type(choices) == "function" then + choices = choices() + end + if #choices < caridx then + caridx = 1 + end + return entry.name(caridx, choices[caridx], choices) + end, +} + +drawer.brand_position = {x = 2, y = 1} +drawer.logo_position = {x = 46, y = 4} +drawer.menu_position = {x = 5, y = 10} +drawer.frame_size = {w = 42, h = 13} +drawer.default_shift = {x = 0, y = 0} +drawer.shift = drawer.default_shift + +drawer.branddefs = { + -- Indexed by valid values for loader_brand in loader.conf(5). Valid + -- keys are: graphic (table depicting graphic) + ["fbsd"] = { + graphic = fbsd_brand, + }, + ["none"] = { + graphic = none, + }, +} + +function drawer.addBrand(name, def) + drawer.branddefs[name] = def +end + +function drawer.addLogo(name, def) + drawer.logodefs[name] = def +end + +drawer.logodefs = { + -- Indexed by valid values for loader_logo in loader.conf(5). Valid keys + -- are: requires_color (boolean), graphic (table depicting graphic), and + -- shift (table containing x and y). + ["tribute"] = { + graphic = fbsd_brand, + }, + ["tributebw"] = { + graphic = fbsd_brand, + }, + ["none"] = { + graphic = none, + shift = {x = 17, y = 0}, + }, +} + +drawer.frame_styles = { + -- Indexed by valid values for loader_menu_frame in loader.conf(5). + -- All of the keys appearing below must be set for any menu frame style + -- added to drawer.frame_styles. + ["ascii"] = { + horizontal = "-", + vertical = "|", + top_left = "+", + bottom_left = "+", + top_right = "+", + bottom_right = "+", + }, + ["single"] = { + horizontal = "\xC4", + vertical = "\xB3", + top_left = "\xDA", + bottom_left = "\xC0", + top_right = "\xBF", + bottom_right = "\xD9", + }, + ["double"] = { + horizontal = "\xCD", + vertical = "\xBA", + top_left = "\xC9", + bottom_left = "\xC8", + top_right = "\xBB", + bottom_right = "\xBC", + }, +} + +function drawer.drawscreen(menudef) + -- drawlogo() must go first. + -- it determines the positions of other elements + drawlogo() + drawbrand() + drawbox() + return drawmenu(menudef) end return drawer