Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Nov 2024 00:50:35 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 0d2b7892cd3a - releng/14.2 - loader: Fix boot menu on BIOS
Message-ID:  <202411070050.4A70oZs1010409@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch releng/14.2 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=0d2b7892cd3aa4666dee7211a76a3a4d99c4c18b

commit 0d2b7892cd3aa4666dee7211a76a3a4d99c4c18b
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-11-02 22:02:44 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-11-06 23:13:14 +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
    
    (cherry picked from commit c2ba66d4d01f23303352bfe3cbd50ff5d9a05947)
    (cherry picked from commit f2103edaf5229271f3f6769844c0c747d8352228)
    
    Approved-by: re (cperciva)
---
 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 a009b78164df..612bd2f5317f 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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202411070050.4A70oZs1010409>