git: c2ba66d4d01f - main - loader: Fix boot menu on BIOS
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 02 Nov 2024 22:03:02 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=c2ba66d4d01f23303352bfe3cbd50ff5d9a05947 commit c2ba66d4d01f23303352bfe3cbd50ff5d9a05947 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2024-11-02 22:02:44 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2024-11-02 22:02:44 +0000 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 --- stand/lua/core.lua | 9 +++++++++ stand/lua/drawer.lua | 32 +++++++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/stand/lua/core.lua b/stand/lua/core.lua index 72b19462ae5c..3582720f2a81 100644 --- a/stand/lua/core.lua +++ b/stand/lua/core.lua @@ -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 diff --git a/stand/lua/drawer.lua b/stand/lua/drawer.lua index 3a462930b86b..e55702ffee6c 100644 --- a/stand/lua/drawer.lua +++ b/stand/lua/drawer.lua @@ -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.