git: 3fb656f8ef21 - main - loader: Use printc instead of print to fit in 24,80

From: Warner Losh <imp_at_FreeBSD.org>
Date: Tue, 24 Sep 2024 16:56:39 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=3fb656f8ef21332d96de8097521aaa51ddeb649d

commit 3fb656f8ef21332d96de8097521aaa51ddeb649d
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-09-24 16:52:18 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-09-24 16:57:11 +0000

    loader: Use printc instead of print to fit in 24,80
    
    print automatically adds a newline, while printc does not. Use printc in
    preference to print for managing the autoboot message. This means we can
    use line 24 safely on a 24x80 terminal, restoring some functionality
    that was lost in 101afbc6ee2f0.
    
    Note: we still set the default curosor position to 25,1 in screen.lua,
    but real VT100s (and successors) will treat any row larger than the
    pnumber of rows in a cursor motion command to be the last physical row
    (this is so you can move to 9999,9999 and do a cursor location query to
    get the size of the screen). Keeping that as is looks better on a
    typical VGA console.
    
    Fixes: 101afbc6ee2f0
    Sponsored by: Netflix
    Reviewed by: kevans
    Differential Revision:  https://reviews.freebsd.org/D46771
---
 stand/lua/menu.lua | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/stand/lua/menu.lua b/stand/lua/menu.lua
index ed84360d93b0..5820d80532b5 100644
--- a/stand/lua/menu.lua
+++ b/stand/lua/menu.lua
@@ -530,6 +530,7 @@ function menu.run()
 	drawn_menu = nil
 
 	screen.defcursor()
+	-- We explicitly want the newline print adds
 	print("Exiting menu!")
 end
 
@@ -544,7 +545,7 @@ function menu.autoboot(delay)
 		if last == nil or last ~= time then
 			last = time
 			screen.setcursor(x, y)
-			print("Autoboot in " .. time ..
+			printc("Autoboot in " .. time ..
 			    " seconds. [Space] to pause ")
 			screen.defcursor()
 		end
@@ -553,9 +554,12 @@ function menu.autoboot(delay)
 			if ch == core.KEY_ENTER then
 				break
 			else
-				-- erase autoboot msg
+				-- Erase autoboot msg.  While real VT100s
+				-- wouldn't scroll when receiving a char with
+				-- the cursor at (24, 79), bad emulators do.
+				-- Avoid the issue by stopping at 79.
 				screen.setcursor(0, y)
-				print(string.rep(" ", 80))
+				printc(string.rep(" ", 79))
 				screen.defcursor()
 				return ch
 			end