From owner-svn-src-head@freebsd.org Fri Mar 2 15:28:09 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 75DCEF2CB53; Fri, 2 Mar 2018 15:28:09 +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 2476086560; Fri, 2 Mar 2018 15:28:09 +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 1F4C9193EC; Fri, 2 Mar 2018 15:28:09 +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 w22FS9WB051458; Fri, 2 Mar 2018 15:28:09 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w22FS8CT051457; Fri, 2 Mar 2018 15:28:08 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201803021528.w22FS8CT051457@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Fri, 2 Mar 2018 15:28:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r330281 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 330281 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: Fri, 02 Mar 2018 15:28:09 -0000 Author: kevans Date: Fri Mar 2 15:28:08 2018 New Revision: 330281 URL: https://svnweb.freebsd.org/changeset/base/330281 Log: lualoader: Steamroll the box-drawing - Add drawer.frame_styles to map out the kinds of characters we need for the different loader_menu_frame values - Respect loader_menu_frame, default to double[*] - (imp) Use loader.printc instead of print- print adds a newline to the output, which is not the right thing we want to be doing. - (imp) Draw horizontal frames a little more efficiently- setting the cursor after every line segment is horribly inefficient, especially on serial consoles. Halve the number of characters written at the expense of an additional loop to draw the bottom frame, which is likely more efficient in the long run for some of less ideal scenarios. [*] menu.4th(8) claims that the default here was single, but unset loader_menu_frame yielded double and we didn't have any overrides in the default loader.conf(5), so double it is. Modified: head/stand/lua/drawer.lua Modified: head/stand/lua/drawer.lua ============================================================================== --- head/stand/lua/drawer.lua Fri Mar 2 15:17:42 2018 (r330280) +++ head/stand/lua/drawer.lua Fri Mar 2 15:28:08 2018 (r330281) @@ -256,6 +256,36 @@ drawer.logodefs = { }, } +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 @@ -306,42 +336,52 @@ function drawer.drawmenu(menudef) return alias_table end - function drawer.drawbox() local x = drawer.box_pos_dim.x local y = drawer.box_pos_dim.y local w = drawer.box_pos_dim.w local h = drawer.box_pos_dim.h - local hl = "\xCD" - local vl = "\xBA" + local framestyle = loader.getenv("loader_menu_frame") or "double" + local framespec = drawer.frame_styles[framestyle] + -- If we don't have a framespec for the current frame style, just don't + -- draw a box. + if framespec == nil then + return + end - local tl = "\xC9" - local bl = "\xC8" - local tr = "\xBB" - local br = "\xBC" + local hl = framespec.horizontal + local vl = framespec.vertical - screen.setcursor(x, y); print(tl) - screen.setcursor(x, y+h); print(bl) - screen.setcursor(x+w, y); print(tr) - screen.setcursor(x+w, y+h); print(br) + local tl = framespec.top_left + local bl = framespec.bottom_left + local tr = framespec.top_right + local br = framespec.bottom_right - for i = 1, w-1 do - screen.setcursor(x+i, y) - print(hl) - screen.setcursor(x+i, y+h) - print(hl) + screen.setcursor(x, y); loader.printc(tl) + screen.setcursor(x, y + h); loader.printc(bl) + screen.setcursor(x + w, y); loader.printc(tr) + screen.setcursor(x + w, y + h); loader.printc(br) + + screen.setcursor(x + 1, y) + for _ = 1, w - 1 do + loader.printc(hl) end - for i = 1, h-1 do - screen.setcursor(x, y+i) - print(vl) - screen.setcursor(x+w, y+i) - print(vl) + screen.setcursor(x + 1, y + h) + for _ = 1, w - 1 do + loader.printc(hl) end - screen.setcursor(x+(w/2)-9, y) - print("Welcome to FreeBSD") + for i = 1, h - 1 do + screen.setcursor(x, y + i) + loader.printc(vl) + screen.setcursor(x + w, y + i) + loader.printc(vl) + end + + screen.setcursor(x + (w / 2) - 9, y) + loader.printc("Welcome to FreeBSD") end function drawer.draw(x, y, logo)