loader: Fix boot menu on BIOS

Only the gfx-enabled boot loader supports unicode. Otherwise, we have to
use the old cons25 / ibmpc upper code page drawing characters. Check to
see if we have the gfx.term_drawbox function. If we do, we support the
unicode drawing characters. If we don't, then we have an older loader
that doesn't support it *OR* we have the reduced function, text-only
boot loader. In either of those cases, we need to use the old graphics
characters. Abstract all those details into core.hasUnicode function.

PR: 282465
MFC After: 2 day
Sponsored by: Netflix
Differential Revision:	https://reviews.freebsd.org/D47403
This commit is contained in:
Warner Losh 2024-11-02 16:02:44 -06:00
parent 3f313682e0
commit c2ba66d4d0
2 changed files with 36 additions and 5 deletions

View File

@ -543,6 +543,15 @@ function core.nextConsoleChoice()
end
end
-- The graphical-enabled loaders have unicode drawing character support. The
-- text-only ones do not. We check the old and new bindings for term_drawrect as
-- a proxy for unicode support, which will work on older boot loaders as well
-- as be future proof for when we remove the old binding. This also abstracts
-- out the test to one spot in case we start to export this notion more directly.
function core.hasUnicode()
return gfx.term_drawrect ~= nil or loader.term_drawrect ~= nil
end
-- Sanity check the boot loader revision
-- Loaders with version 3.0 have everything that we need without backwards
-- compatible hacks. Warn users that still have old versions to upgrade so

View File

@ -506,23 +506,45 @@ drawer.frame_styles = {
top_right = "+",
bottom_right = "+",
},
["single"] = {
}
if core.hasUnicode() then
-- unicode based framing characters
drawer.frame_styles["single"] = {
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",
},
["double"] = {
}
drawer.frame_styles["double"] = {
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",
},
}
}
else
-- non-unicode cons25-style framing characters
drawer.frame_styles["single"] = {
horizontal = "\xC4",
vertical = "\xB3",
top_left = "\xDA",
bottom_left = "\xC0",
top_right = "\xBF",
bottom_right = "\xD9",
}
drawer.frame_styles["double"] = {
horizontal = "\xCD",
vertical = "\xBA",
top_left = "\xC9",
bottom_left = "\xC8",
top_right = "\xBB",
bottom_right = "\xBC",
}
end
function drawer.drawscreen(menudef)
-- drawlogo() must go first.