2018-02-12 15:32:00 +00:00
|
|
|
--
|
2018-02-23 02:51:35 +00:00
|
|
|
-- SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
|
|
|
--
|
2018-02-12 15:32:00 +00:00
|
|
|
-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org>
|
2018-02-20 05:11:17 +00:00
|
|
|
-- Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
|
2018-02-12 15:32:00 +00:00
|
|
|
-- All rights reserved.
|
|
|
|
--
|
|
|
|
-- Redistribution and use in source and binary forms, with or without
|
|
|
|
-- modification, are permitted provided that the following conditions
|
|
|
|
-- are met:
|
|
|
|
-- 1. Redistributions of source code must retain the above copyright
|
|
|
|
-- notice, this list of conditions and the following disclaimer.
|
|
|
|
-- 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
-- notice, this list of conditions and the following disclaimer in the
|
|
|
|
-- documentation and/or other materials provided with the distribution.
|
|
|
|
--
|
|
|
|
-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
-- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
-- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
-- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
-- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
-- SUCH DAMAGE.
|
|
|
|
--
|
|
|
|
-- $FreeBSD$
|
|
|
|
--
|
|
|
|
|
2018-02-21 01:10:03 +00:00
|
|
|
local color = require("color")
|
|
|
|
local config = require("config")
|
|
|
|
local core = require("core")
|
|
|
|
local screen = require("screen")
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-02-21 01:10:03 +00:00
|
|
|
local drawer = {}
|
2018-02-19 17:54:22 +00:00
|
|
|
|
2018-04-01 01:07:15 +00:00
|
|
|
local fbsd_brand
|
2018-02-21 01:10:03 +00:00
|
|
|
local none
|
2018-02-20 04:23:43 +00:00
|
|
|
|
2018-08-19 18:37:33 +00:00
|
|
|
local menu_name_handlers
|
|
|
|
local branddefs
|
|
|
|
local logodefs
|
|
|
|
local brand_position
|
|
|
|
local logo_position
|
|
|
|
local menu_position
|
|
|
|
local frame_size
|
|
|
|
local default_shift
|
|
|
|
local shift
|
|
|
|
|
2018-02-24 20:21:21 +00:00
|
|
|
local function menuEntryName(drawing_menu, entry)
|
2018-08-19 18:37:33 +00:00
|
|
|
local name_handler = menu_name_handlers[entry.entry_type]
|
2018-02-20 14:36:28 +00:00
|
|
|
|
2018-02-21 01:35:19 +00:00
|
|
|
if name_handler ~= nil then
|
2018-02-21 01:10:03 +00:00
|
|
|
return name_handler(drawing_menu, entry)
|
2018-02-20 14:36:28 +00:00
|
|
|
end
|
2018-02-21 04:48:37 +00:00
|
|
|
if type(entry.name) == "function" then
|
|
|
|
return entry.name()
|
|
|
|
end
|
|
|
|
return entry.name
|
2018-02-20 14:36:28 +00:00
|
|
|
end
|
|
|
|
|
2020-10-04 22:41:43 +00:00
|
|
|
local function processFile(gfxname)
|
|
|
|
if gfxname == nil then
|
|
|
|
return false, "Missing filename"
|
|
|
|
end
|
|
|
|
|
|
|
|
local ret = try_include('gfx-' .. gfxname)
|
|
|
|
if ret == nil then
|
|
|
|
return false, "Failed to include gfx-" .. gfxname
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Legacy format
|
|
|
|
if type(ret) ~= "table" then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
for gfxtype, def in pairs(ret) do
|
|
|
|
if gfxtype == "brand" then
|
|
|
|
drawer.addBrand(gfxname, def)
|
|
|
|
elseif gfxtype == "logo" then
|
|
|
|
drawer.addLogo(gfxname, def)
|
|
|
|
else
|
|
|
|
return false, "Unknown graphics type '" .. gfxtype ..
|
|
|
|
"'"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2018-06-11 01:32:18 +00:00
|
|
|
local function getBranddef(brand)
|
|
|
|
if brand == nil then
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
-- Look it up
|
2018-08-19 18:37:33 +00:00
|
|
|
local branddef = branddefs[brand]
|
2018-06-11 01:32:18 +00:00
|
|
|
|
|
|
|
-- Try to pull it in
|
|
|
|
if branddef == nil then
|
2020-10-04 22:41:43 +00:00
|
|
|
local res, err = processFile(brand)
|
|
|
|
if not res then
|
|
|
|
-- This fallback should go away after FreeBSD 13.
|
|
|
|
try_include('brand-' .. brand)
|
|
|
|
-- If the fallback also failed, print whatever error
|
|
|
|
-- we encountered in the original processing.
|
|
|
|
if branddefs[brand] == nil then
|
|
|
|
print(err)
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-19 18:37:33 +00:00
|
|
|
branddef = branddefs[brand]
|
2018-06-11 01:32:18 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return branddef
|
|
|
|
end
|
|
|
|
|
2018-04-01 01:07:15 +00:00
|
|
|
local function getLogodef(logo)
|
2018-04-01 01:21:00 +00:00
|
|
|
if logo == nil then
|
|
|
|
return nil
|
|
|
|
end
|
2018-04-01 01:07:15 +00:00
|
|
|
-- Look it up
|
2018-08-19 18:37:33 +00:00
|
|
|
local logodef = logodefs[logo]
|
2018-04-01 01:07:15 +00:00
|
|
|
|
|
|
|
-- Try to pull it in
|
|
|
|
if logodef == nil then
|
2020-10-04 22:41:43 +00:00
|
|
|
local res, err = processFile(logo)
|
|
|
|
if not res then
|
|
|
|
-- This fallback should go away after FreeBSD 13.
|
|
|
|
try_include('logo-' .. logo)
|
|
|
|
-- If the fallback also failed, print whatever error
|
|
|
|
-- we encountered in the original processing.
|
|
|
|
if logodefs[logo] == nil then
|
|
|
|
print(err)
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-19 18:37:33 +00:00
|
|
|
logodef = logodefs[logo]
|
2018-04-01 01:07:15 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return logodef
|
|
|
|
end
|
|
|
|
|
2018-08-19 18:12:11 +00:00
|
|
|
local function draw(x, y, logo)
|
|
|
|
for i = 1, #logo do
|
|
|
|
screen.setcursor(x, y + i - 1)
|
|
|
|
printc(logo[i])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-19 18:22:01 +00:00
|
|
|
local function drawmenu(menudef)
|
2018-08-19 18:37:33 +00:00
|
|
|
local x = menu_position.x
|
|
|
|
local y = menu_position.y
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-08-19 18:37:33 +00:00
|
|
|
x = x + shift.x
|
|
|
|
y = y + shift.y
|
2018-03-03 18:25:50 +00:00
|
|
|
|
2018-02-12 15:32:00 +00:00
|
|
|
-- print the menu and build the alias table
|
2018-02-21 01:10:03 +00:00
|
|
|
local alias_table = {}
|
|
|
|
local entry_num = 0
|
2018-02-26 04:08:54 +00:00
|
|
|
local menu_entries = menudef.entries
|
2018-02-23 04:12:19 +00:00
|
|
|
local effective_line_num = 0
|
2018-02-21 01:35:19 +00:00
|
|
|
if type(menu_entries) == "function" then
|
2018-02-21 01:10:03 +00:00
|
|
|
menu_entries = menu_entries()
|
2018-02-19 16:35:46 +00:00
|
|
|
end
|
2018-02-24 03:48:52 +00:00
|
|
|
for _, e in ipairs(menu_entries) do
|
2018-02-19 01:59:41 +00:00
|
|
|
-- Allow menu items to be conditionally visible by specifying
|
|
|
|
-- a visible function.
|
2018-02-21 01:35:19 +00:00
|
|
|
if e.visible ~= nil and not e.visible() then
|
2018-02-21 01:10:03 +00:00
|
|
|
goto continue
|
2018-02-19 01:59:41 +00:00
|
|
|
end
|
2018-02-23 04:12:19 +00:00
|
|
|
effective_line_num = effective_line_num + 1
|
2018-02-21 01:35:19 +00:00
|
|
|
if e.entry_type ~= core.MENU_SEPARATOR then
|
2018-02-21 01:10:03 +00:00
|
|
|
entry_num = entry_num + 1
|
2018-02-23 04:12:19 +00:00
|
|
|
screen.setcursor(x, y + effective_line_num)
|
2018-02-16 14:39:41 +00:00
|
|
|
|
2018-03-21 18:02:56 +00:00
|
|
|
printc(entry_num .. ". " .. menuEntryName(menudef, e))
|
2018-02-12 15:32:00 +00:00
|
|
|
|
|
|
|
-- fill the alias table
|
2018-02-21 01:10:03 +00:00
|
|
|
alias_table[tostring(entry_num)] = e
|
2018-02-21 01:35:19 +00:00
|
|
|
if e.alias ~= nil then
|
2018-02-22 04:15:02 +00:00
|
|
|
for _, a in ipairs(e.alias) do
|
2018-02-21 01:10:03 +00:00
|
|
|
alias_table[a] = e
|
2018-02-16 04:44:47 +00:00
|
|
|
end
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
|
|
|
else
|
2018-02-23 04:12:19 +00:00
|
|
|
screen.setcursor(x, y + effective_line_num)
|
2018-03-21 18:02:56 +00:00
|
|
|
printc(menuEntryName(menudef, e))
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
2018-02-19 01:59:41 +00:00
|
|
|
::continue::
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
2018-02-21 01:10:03 +00:00
|
|
|
return alias_table
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
|
|
|
|
2019-09-10 21:30:38 +00:00
|
|
|
local function defaultframe()
|
|
|
|
if core.isSerialConsole() then
|
|
|
|
return "ascii"
|
|
|
|
end
|
|
|
|
return "double"
|
|
|
|
end
|
|
|
|
|
2020-12-21 05:31:16 +00:00
|
|
|
local function drawframe()
|
2018-08-19 18:37:33 +00:00
|
|
|
local x = menu_position.x - 3
|
|
|
|
local y = menu_position.y - 1
|
|
|
|
local w = frame_size.w
|
|
|
|
local h = frame_size.h
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2019-09-10 21:30:38 +00:00
|
|
|
local framestyle = loader.getenv("loader_menu_frame") or defaultframe()
|
2018-03-02 15:28:08 +00:00
|
|
|
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
|
2020-12-21 05:31:16 +00:00
|
|
|
return false
|
2018-03-02 15:28:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
local hl = framespec.horizontal
|
|
|
|
local vl = framespec.vertical
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-03-02 15:28:08 +00:00
|
|
|
local tl = framespec.top_left
|
|
|
|
local bl = framespec.bottom_left
|
|
|
|
local tr = framespec.top_right
|
|
|
|
local br = framespec.bottom_right
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-08-19 18:37:33 +00:00
|
|
|
x = x + shift.x
|
|
|
|
y = y + shift.y
|
2018-03-03 18:25:50 +00:00
|
|
|
|
2020-12-21 05:31:16 +00:00
|
|
|
if core.isFramebufferConsole() and loader.term_drawrect ~= nil then
|
|
|
|
loader.term_drawrect(x, y, x + w, y + h)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2018-03-02 16:06:20 +00:00
|
|
|
screen.setcursor(x, y); printc(tl)
|
|
|
|
screen.setcursor(x, y + h); printc(bl)
|
|
|
|
screen.setcursor(x + w, y); printc(tr)
|
|
|
|
screen.setcursor(x + w, y + h); printc(br)
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-03-02 15:28:08 +00:00
|
|
|
screen.setcursor(x + 1, y)
|
|
|
|
for _ = 1, w - 1 do
|
2018-03-02 16:06:20 +00:00
|
|
|
printc(hl)
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
|
|
|
|
2018-03-02 15:28:08 +00:00
|
|
|
screen.setcursor(x + 1, y + h)
|
|
|
|
for _ = 1, w - 1 do
|
2018-03-02 16:06:20 +00:00
|
|
|
printc(hl)
|
2018-03-02 15:28:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
for i = 1, h - 1 do
|
|
|
|
screen.setcursor(x, y + i)
|
2018-03-02 16:06:20 +00:00
|
|
|
printc(vl)
|
2018-03-02 15:28:08 +00:00
|
|
|
screen.setcursor(x + w, y + i)
|
2018-03-02 16:06:20 +00:00
|
|
|
printc(vl)
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
2020-12-21 05:31:16 +00:00
|
|
|
return true
|
|
|
|
end
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2020-12-21 05:31:16 +00:00
|
|
|
local function drawbox()
|
|
|
|
local x = menu_position.x - 3
|
|
|
|
local y = menu_position.y - 1
|
|
|
|
local w = frame_size.w
|
2018-03-03 17:25:49 +00:00
|
|
|
local menu_header = loader.getenv("loader_menu_title") or
|
|
|
|
"Welcome to FreeBSD"
|
2018-03-03 17:38:25 +00:00
|
|
|
local menu_header_align = loader.getenv("loader_menu_title_align")
|
2018-03-03 17:25:49 +00:00
|
|
|
local menu_header_x
|
|
|
|
|
2020-12-21 05:31:16 +00:00
|
|
|
x = x + shift.x
|
|
|
|
y = y + shift.y
|
|
|
|
|
|
|
|
if drawframe(x, y, w) == false then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2018-03-03 17:38:25 +00:00
|
|
|
if menu_header_align ~= nil then
|
|
|
|
menu_header_align = menu_header_align:lower()
|
|
|
|
if menu_header_align == "left" then
|
|
|
|
-- Just inside the left border on top
|
|
|
|
menu_header_x = x + 1
|
|
|
|
elseif menu_header_align == "right" then
|
|
|
|
-- Just inside the right border on top
|
|
|
|
menu_header_x = x + w - #menu_header
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if menu_header_x == nil then
|
2021-01-15 14:15:40 +00:00
|
|
|
menu_header_x = x + (w // 2) - (#menu_header // 2)
|
2018-03-03 17:38:25 +00:00
|
|
|
end
|
2021-03-23 05:04:48 +00:00
|
|
|
screen.setcursor(menu_header_x - 1, y)
|
2021-04-21 11:42:10 +00:00
|
|
|
if menu_header ~= "" then
|
|
|
|
printc(" " .. menu_header .. " ")
|
|
|
|
end
|
|
|
|
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
|
|
|
|
2018-08-19 18:22:01 +00:00
|
|
|
local function drawbrand()
|
2018-02-17 05:52:25 +00:00
|
|
|
local x = tonumber(loader.getenv("loader_brand_x")) or
|
2018-08-19 18:37:33 +00:00
|
|
|
brand_position.x
|
2018-02-17 05:52:25 +00:00
|
|
|
local y = tonumber(loader.getenv("loader_brand_y")) or
|
2018-08-19 18:37:33 +00:00
|
|
|
brand_position.y
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-06-11 01:32:18 +00:00
|
|
|
local branddef = getBranddef(loader.getenv("loader_brand"))
|
|
|
|
|
|
|
|
if branddef == nil then
|
|
|
|
branddef = getBranddef(drawer.default_brand)
|
|
|
|
end
|
|
|
|
|
|
|
|
local graphic = branddef.graphic
|
2018-03-03 18:25:50 +00:00
|
|
|
|
2018-08-19 18:37:33 +00:00
|
|
|
x = x + shift.x
|
|
|
|
y = y + shift.y
|
2020-12-21 05:31:16 +00:00
|
|
|
if core.isFramebufferConsole() and
|
|
|
|
loader.term_putimage ~= nil and
|
|
|
|
branddef.image ~= nil then
|
2021-02-08 18:49:09 +00:00
|
|
|
if loader.term_putimage(branddef.image, 1, 1, 0, 7, 0)
|
2020-12-21 05:31:16 +00:00
|
|
|
then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
2018-08-19 18:12:11 +00:00
|
|
|
draw(x, y, graphic)
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
|
|
|
|
2018-08-19 18:22:01 +00:00
|
|
|
local function drawlogo()
|
2018-02-17 05:52:25 +00:00
|
|
|
local x = tonumber(loader.getenv("loader_logo_x")) or
|
2018-08-19 18:37:33 +00:00
|
|
|
logo_position.x
|
2018-02-17 05:52:25 +00:00
|
|
|
local y = tonumber(loader.getenv("loader_logo_y")) or
|
2018-08-19 18:37:33 +00:00
|
|
|
logo_position.y
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-02-21 01:10:03 +00:00
|
|
|
local logo = loader.getenv("loader_logo")
|
|
|
|
local colored = color.isEnabled()
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-04-01 01:07:15 +00:00
|
|
|
local logodef = getLogodef(logo)
|
2018-02-20 04:56:03 +00:00
|
|
|
|
2018-03-03 18:25:50 +00:00
|
|
|
if logodef == nil or logodef.graphic == nil or
|
2018-02-21 01:35:19 +00:00
|
|
|
(not colored and logodef.requires_color) then
|
2018-02-20 04:56:03 +00:00
|
|
|
-- Choose a sensible default
|
2018-02-21 01:35:19 +00:00
|
|
|
if colored then
|
2018-08-19 18:43:10 +00:00
|
|
|
logodef = getLogodef(drawer.default_color_logodef)
|
2018-02-12 15:32:00 +00:00
|
|
|
else
|
2018-08-19 18:43:10 +00:00
|
|
|
logodef = getLogodef(drawer.default_bw_logodef)
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
2020-06-01 23:26:37 +00:00
|
|
|
|
|
|
|
-- Something has gone terribly wrong.
|
|
|
|
if logodef == nil then
|
|
|
|
logodef = getLogodef(drawer.default_fallback_logodef)
|
|
|
|
end
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
2018-03-03 18:25:50 +00:00
|
|
|
|
|
|
|
if logodef ~= nil and logodef.graphic == none then
|
2018-08-19 18:37:33 +00:00
|
|
|
shift = logodef.shift
|
2018-03-03 18:25:50 +00:00
|
|
|
else
|
2018-08-19 18:37:33 +00:00
|
|
|
shift = default_shift
|
2018-03-03 18:25:50 +00:00
|
|
|
end
|
|
|
|
|
2018-08-19 18:37:33 +00:00
|
|
|
x = x + shift.x
|
|
|
|
y = y + shift.y
|
2018-03-03 18:25:50 +00:00
|
|
|
|
2018-03-04 03:23:19 +00:00
|
|
|
if logodef ~= nil and logodef.shift ~= nil then
|
2018-02-21 01:10:03 +00:00
|
|
|
x = x + logodef.shift.x
|
|
|
|
y = y + logodef.shift.y
|
2018-02-20 04:56:03 +00:00
|
|
|
end
|
2018-03-03 18:25:50 +00:00
|
|
|
|
2020-12-21 05:31:16 +00:00
|
|
|
if core.isFramebufferConsole() and
|
|
|
|
loader.term_putimage ~= nil and
|
|
|
|
logodef.image ~= nil then
|
|
|
|
local y1 = 15
|
|
|
|
|
|
|
|
if logodef.image_rl ~= nil then
|
|
|
|
y1 = logodef.image_rl
|
|
|
|
end
|
|
|
|
if loader.term_putimage(logodef.image, x, y, 0, y + y1, 0)
|
|
|
|
then
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
end
|
2018-08-19 18:12:11 +00:00
|
|
|
draw(x, y, logodef.graphic)
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
|
|
|
|
2020-12-21 05:31:16 +00:00
|
|
|
local function drawitem(func)
|
|
|
|
local console = loader.getenv("console")
|
|
|
|
local c
|
|
|
|
|
|
|
|
for c in string.gmatch(console, "%w+") do
|
|
|
|
loader.setenv("console", c)
|
|
|
|
func()
|
|
|
|
end
|
|
|
|
loader.setenv("console", console)
|
|
|
|
end
|
|
|
|
|
2018-08-19 18:22:01 +00:00
|
|
|
fbsd_brand = {
|
|
|
|
" ______ ____ _____ _____ ",
|
|
|
|
" | ____| | _ \\ / ____| __ \\ ",
|
|
|
|
" | |___ _ __ ___ ___ | |_) | (___ | | | |",
|
|
|
|
" | ___| '__/ _ \\/ _ \\| _ < \\___ \\| | | |",
|
|
|
|
" | | | | | __/ __/| |_) |____) | |__| |",
|
|
|
|
" | | | | | | || | | |",
|
|
|
|
" |_| |_| \\___|\\___||____/|_____/|_____/ "
|
|
|
|
}
|
|
|
|
none = {""}
|
|
|
|
|
2018-08-19 18:37:33 +00:00
|
|
|
menu_name_handlers = {
|
2018-08-19 18:22:01 +00:00
|
|
|
-- 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,
|
|
|
|
}
|
|
|
|
|
2018-08-19 18:37:33 +00:00
|
|
|
branddefs = {
|
2018-08-19 18:22:01 +00:00
|
|
|
-- Indexed by valid values for loader_brand in loader.conf(5). Valid
|
|
|
|
-- keys are: graphic (table depicting graphic)
|
|
|
|
["fbsd"] = {
|
|
|
|
graphic = fbsd_brand,
|
2020-12-21 05:31:16 +00:00
|
|
|
image = "/boot/images/freebsd-brand-rev.png",
|
2018-08-19 18:22:01 +00:00
|
|
|
},
|
|
|
|
["none"] = {
|
|
|
|
graphic = none,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2018-08-19 18:37:33 +00:00
|
|
|
logodefs = {
|
2018-08-19 18:22:01 +00:00
|
|
|
-- 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},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2018-08-19 18:37:33 +00:00
|
|
|
brand_position = {x = 2, y = 1}
|
|
|
|
logo_position = {x = 46, y = 4}
|
|
|
|
menu_position = {x = 5, y = 10}
|
|
|
|
frame_size = {w = 42, h = 13}
|
|
|
|
default_shift = {x = 0, y = 0}
|
|
|
|
shift = default_shift
|
|
|
|
|
|
|
|
-- Module exports
|
|
|
|
drawer.default_brand = 'fbsd'
|
2018-08-19 18:43:10 +00:00
|
|
|
drawer.default_color_logodef = 'orb'
|
|
|
|
drawer.default_bw_logodef = 'orbbw'
|
2020-06-01 23:26:37 +00:00
|
|
|
-- For when things go terribly wrong; this def should be present here in the
|
|
|
|
-- drawer module in case it's a filesystem issue.
|
|
|
|
drawer.default_fallback_logodef = 'none'
|
2018-08-19 18:37:33 +00:00
|
|
|
|
2020-10-04 22:41:43 +00:00
|
|
|
-- These should go away after FreeBSD 13; only available for backwards
|
|
|
|
-- compatibility with old logo- files.
|
2018-08-19 18:37:33 +00:00
|
|
|
function drawer.addBrand(name, def)
|
|
|
|
branddefs[name] = def
|
|
|
|
end
|
|
|
|
|
|
|
|
function drawer.addLogo(name, def)
|
|
|
|
logodefs[name] = def
|
|
|
|
end
|
|
|
|
|
2018-08-19 18:22:01 +00:00
|
|
|
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"] = {
|
2019-09-05 22:15:50 +00:00
|
|
|
horizontal = "\xE2\x94\x80",
|
|
|
|
vertical = "\xE2\x94\x82",
|
|
|
|
top_left = "\xE2\x94\x8C",
|
|
|
|
bottom_left = "\xE2\x94\x94",
|
|
|
|
top_right = "\xE2\x94\x90",
|
|
|
|
bottom_right = "\xE2\x94\x98",
|
2018-08-19 18:22:01 +00:00
|
|
|
},
|
|
|
|
["double"] = {
|
2019-09-05 22:15:50 +00:00
|
|
|
horizontal = "\xE2\x95\x90",
|
|
|
|
vertical = "\xE2\x95\x91",
|
|
|
|
top_left = "\xE2\x95\x94",
|
|
|
|
bottom_left = "\xE2\x95\x9A",
|
|
|
|
top_right = "\xE2\x95\x97",
|
|
|
|
bottom_right = "\xE2\x95\x9D",
|
2018-08-19 18:22:01 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
function drawer.drawscreen(menudef)
|
|
|
|
-- drawlogo() must go first.
|
|
|
|
-- it determines the positions of other elements
|
2020-12-21 05:31:16 +00:00
|
|
|
drawitem(drawlogo)
|
|
|
|
drawitem(drawbrand)
|
|
|
|
drawitem(drawbox)
|
2018-08-19 18:22:01 +00:00
|
|
|
return drawmenu(menudef)
|
|
|
|
end
|
|
|
|
|
2018-02-21 01:10:03 +00:00
|
|
|
return drawer
|