diff --git a/stand/lua/drawer.lua b/stand/lua/drawer.lua index ed1bb60332b8..5d56d9ef0b45 100644 --- a/stand/lua/drawer.lua +++ b/stand/lua/drawer.lua @@ -41,6 +41,24 @@ local orb; local none; local none_shifted = false; +local menu_entry_name = function(drawing_menu, entry) + local name_handler = drawer.menu_name_handlers[entry.entry_type]; + + if (name_handler ~= nil) then + return name_handler(drawing_menu, entry); + end + return entry.name(); +end + +local shift_brand_text = function(shift) + drawer.brand_position.x = drawer.brand_position.x + shift.x; + drawer.brand_position.y = drawer.brand_position.y + shift.y; + drawer.menu_position.x = drawer.menu_position.x + shift.x; + drawer.menu_position.y = drawer.menu_position.y + shift.y; + drawer.box_pos_dim.x = drawer.box_pos_dim.x + shift.x; + drawer.box_pos_dim.y = drawer.box_pos_dim.y + shift.y; +end + drawer.menu_name_handlers = { -- Menu name handlers should take the menu being drawn and entry being -- drawn as parameters, and return the name of the item. @@ -228,15 +246,6 @@ function drawer.drawscreen(menu_opts) return drawer.drawmenu(menu_opts); end -function menu_entry_name(drawing_menu, entry) - local name_handler = drawer.menu_name_handlers[entry.entry_type]; - - if (name_handler ~= nil) then - return name_handler(drawing_menu, entry); - end - return entry.name(); -end - function drawer.drawmenu(m) x = drawer.menu_position.x; y = drawer.menu_position.y; @@ -334,15 +343,6 @@ function drawer.drawbrand() drawer.draw(x, y, graphic); end -function shift_brand_text(shift) - drawer.brand_position.x = drawer.brand_position.x + shift.x; - drawer.brand_position.y = drawer.brand_position.y + shift.y; - drawer.menu_position.x = drawer.menu_position.x + shift.x; - drawer.menu_position.y = drawer.menu_position.y + shift.y; - drawer.box_pos_dim.x = drawer.box_pos_dim.x + shift.x; - drawer.box_pos_dim.y = drawer.box_pos_dim.y + shift.y; -end - function drawer.drawlogo() local x = tonumber(loader.getenv("loader_logo_x")) or drawer.logo_position.x; diff --git a/stand/lua/menu.lua b/stand/lua/menu.lua index d7fe5d037cb5..cb318ffe166b 100644 --- a/stand/lua/menu.lua +++ b/stand/lua/menu.lua @@ -36,12 +36,22 @@ local drawer = require("drawer"); local menu = {}; -local OnOff; local skip; local run; local autoboot; local carousel_choices = {}; +local OnOff = function(str, b) + if (b) then + return str .. color.escapef(color.GREEN) .. "On" .. + color.escapef(color.WHITE); + else + return str .. color.escapef(color.RED) .. "off" .. + color.escapef(color.WHITE); + end +end + + menu.handlers = { -- Menu handlers take the current menu and selected entry as parameters, -- and should return a boolean indicating whether execution should @@ -461,14 +471,4 @@ function menu.autoboot() end -function OnOff(str, b) - if (b) then - return str .. color.escapef(color.GREEN) .. "On" .. - color.escapef(color.WHITE); - else - return str .. color.escapef(color.RED) .. "off" .. - color.escapef(color.WHITE); - end -end - return menu; diff --git a/stand/lua/screen.lua b/stand/lua/screen.lua index 2428781ac4c4..d8939a0bdc63 100644 --- a/stand/lua/screen.lua +++ b/stand/lua/screen.lua @@ -32,7 +32,7 @@ local core = require("core"); local screen = {}; -- XXX TODO: This should be fixed in the interpreter to not print decimals -function intstring(num) +local intstring = function(num) local str = tostring(num); local decimal = str:find("%.");