#344 renderer integration with new assertion handling

This commit is contained in:
Mikayla Fischler
2023-09-30 13:31:41 -04:00
parent 560d48084a
commit d38a2dea7c
10 changed files with 116 additions and 50 deletions

View File

@@ -5,18 +5,23 @@
local main_view = require("pocket.ui.main")
local style = require("pocket.ui.style")
local core = require("graphics.core")
local flasher = require("graphics.flasher")
local DisplayBox = require("graphics.elements.displaybox")
---@class pocket_renderer
local renderer = {}
local ui = {
display = nil
}
-- start the pocket GUI
function renderer.start_ui()
-- try to start the pocket GUI
---@return boolean success, any error_msg
function renderer.try_start_ui()
local status, msg = true, nil
if ui.display == nil then
-- reset screen
term.setTextColor(colors.white)
@@ -30,12 +35,22 @@ function renderer.start_ui()
end
-- init front panel view
ui.display = DisplayBox{window=term.current(),fg_bg=style.root}
main_view(ui.display)
status, msg = pcall(function ()
ui.display = DisplayBox{window=term.current(),fg_bg=style.root}
main_view(ui.display)
end)
-- start flasher callback task
flasher.run()
if status then
-- start flasher callback task
flasher.run()
else
-- report fail and close ui
msg = core.extract_assert_msg(msg)
renderer.close_ui()
end
end
return status, msg
end
-- close out the UI