Author: kevans
Date: Fri Mar  2 16:06:20 2018
New Revision: 330283
URL: https://svnweb.freebsd.org/changeset/base/330283

Log:
  lualoader: Use global printc instead of loader.printc
  
  r330282 registered loader.printc as printc, so use it instead. This makes
  sense for a couple reasons, the major point being that it reads a little bit
  easier and pairs nicely with the global 'print'.
  
  Similar cases can not really be made for other loader.* functions as most of
  them are either highly specific to our use-case or usually available in
  other modules, such as `os`. printc does not have a standard implementation
  in the Lua world(*), so we have a little more leeway with it, and it's kind
  of a special case of the globally available 'print'.
  
  (*) I've been in the Lua world for all of two weeks, so this could be wrong.

Modified:
  head/stand/lua/drawer.lua
  head/stand/lua/password.lua
  head/stand/lua/screen.lua

Modified: head/stand/lua/drawer.lua
==============================================================================
--- head/stand/lua/drawer.lua   Fri Mar  2 15:46:22 2018        (r330282)
+++ head/stand/lua/drawer.lua   Fri Mar  2 16:06:20 2018        (r330283)
@@ -358,30 +358,30 @@ function drawer.drawbox()
        local tr = framespec.top_right
        local br = framespec.bottom_right
 
-       screen.setcursor(x, y); loader.printc(tl)
-       screen.setcursor(x, y + h); loader.printc(bl)
-       screen.setcursor(x + w, y); loader.printc(tr)
-       screen.setcursor(x + w, y + h); loader.printc(br)
+       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)
 
        screen.setcursor(x + 1, y)
        for _ = 1, w - 1 do
-               loader.printc(hl)
+               printc(hl)
        end
 
        screen.setcursor(x + 1, y + h)
        for _ = 1, w - 1 do
-               loader.printc(hl)
+               printc(hl)
        end
 
        for i = 1, h - 1 do
                screen.setcursor(x, y + i)
-               loader.printc(vl)
+               printc(vl)
                screen.setcursor(x + w, y + i)
-               loader.printc(vl)
+               printc(vl)
        end
 
        screen.setcursor(x + (w / 2) - 9, y)
-       loader.printc("Welcome to FreeBSD")
+       printc("Welcome to FreeBSD")
 end
 
 function drawer.draw(x, y, logo)

Modified: head/stand/lua/password.lua
==============================================================================
--- head/stand/lua/password.lua Fri Mar  2 15:46:22 2018        (r330282)
+++ head/stand/lua/password.lua Fri Mar  2 16:06:20 2018        (r330283)
@@ -45,14 +45,14 @@ function password.read(prompt_length)
        local twiddle_pos = 1
 
        local function draw_twiddle()
-               loader.printc("  " .. twiddle_chars[twiddle_pos])
+               printc("  " .. twiddle_chars[twiddle_pos])
                -- Reset cursor to just after the password prompt
                screen.setcursor(prompt_length + 2, screen.default_y)
                twiddle_pos = (twiddle_pos % #twiddle_chars) + 1
        end
 
        -- Space between the prompt and any on-screen feedback
-       loader.printc(" ")
+       printc(" ")
        while true do
                local ch = io.getchar()
                if ch == core.KEY_ENTER then
@@ -61,7 +61,7 @@ function password.read(prompt_length)
                if ch == core.KEY_BACKSPACE or ch == core.KEY_DELETE then
                        if #str > 0 then
                                if show_password_mask then
-                                       loader.printc("\008 \008")
+                                       printc("\008 \008")
                                else
                                        draw_twiddle()
                                end
@@ -69,7 +69,7 @@ function password.read(prompt_length)
                        end
                else
                        if show_password_mask then
-                               loader.printc("*")
+                               printc("*")
                        else
                                draw_twiddle()
                        end
@@ -87,23 +87,23 @@ function password.check()
                local attempts = 1
 
                local function clear_incorrect_text_prompt()
-                       loader.printc("\n")
-                       loader.printc(string.rep(" ", #INCORRECT_PASSWORD))
+                       printc("\n")
+                       printc(string.rep(" ", #INCORRECT_PASSWORD))
                end
 
                while true do
                        screen.defcursor()
-                       loader.printc(prompt)
+                       printc(prompt)
                        local read_pwd = password.read(#prompt)
                        if pwd == nil or pwd == read_pwd then
                                -- Clear the prompt + twiddle
-                               loader.printc(string.rep(" ", #prompt + 5))
+                               printc(string.rep(" ", #prompt + 5))
                                if attempts > 1 then
                                        clear_incorrect_text_prompt()
                                end
                                return read_pwd
                        end
-                       loader.printc("\n" .. INCORRECT_PASSWORD)
+                       printc("\n" .. INCORRECT_PASSWORD)
                        attempts = attempts + 1
                        loader.delay(3*1000*1000)
                end

Modified: head/stand/lua/screen.lua
==============================================================================
--- head/stand/lua/screen.lua   Fri Mar  2 15:46:22 2018        (r330282)
+++ head/stand/lua/screen.lua   Fri Mar  2 16:06:20 2018        (r330283)
@@ -41,7 +41,7 @@ function screen.clear()
        if core.isSerialBoot() then
                return
        end
-       loader.printc(core.KEYSTR_CSI .. "H" .. core.KEYSTR_CSI .. "J")
+       printc(core.KEYSTR_CSI .. "H" .. core.KEYSTR_CSI .. "J")
 end
 
 function screen.setcursor(x, y)
@@ -49,25 +49,25 @@ function screen.setcursor(x, y)
                return
        end
 
-       loader.printc(core.KEYSTR_CSI .. y .. ";" .. x .. "H")
+       printc(core.KEYSTR_CSI .. y .. ";" .. x .. "H")
 end
 
 function screen.setforeground(color_value)
        if color.disabled then
                return color_value
        end
-       loader.printc(color.escapef(color_value))
+       printc(color.escapef(color_value))
 end
 
 function screen.setbackground(color_value)
        if color.disabled then
                return color_value
        end
-       loader.printc(color.escapeb(color_value))
+       printc(color.escapeb(color_value))
 end
 
 function screen.defcolor()
-       loader.printc(color.default())
+       printc(color.default())
 end
 
 function screen.defcursor()
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to