added a keybind to the crash screen that reboots when the user presses enter/return
wow lazyvim likes reformatting everything
This commit is contained in:
@@ -2,43 +2,43 @@ local gpu = component.proxy(component.list("gpu")())
|
|||||||
local resX, resY = gpu.getResolution()
|
local resX, resY = gpu.getResolution()
|
||||||
|
|
||||||
local function loadfile(file)
|
local function loadfile(file)
|
||||||
checkArg(1, file, "string")
|
checkArg(1, file, "string")
|
||||||
local handle = component.invoke(computer.getBootAddress(), "open", file, "r")
|
local handle = component.invoke(computer.getBootAddress(), "open", file, "r")
|
||||||
local data = ""
|
local data = ""
|
||||||
repeat
|
repeat
|
||||||
local tmpdata = component.invoke(computer.getBootAddress(), "read", handle, math.huge or math.maxinteger)
|
local tmpdata = component.invoke(computer.getBootAddress(), "read", handle, math.huge or math.maxinteger)
|
||||||
data = data .. (tmpdata or "")
|
data = data .. (tmpdata or "")
|
||||||
until not tmpdata
|
until not tmpdata
|
||||||
component.invoke(computer.getBootAddress(), "close", handle)
|
component.invoke(computer.getBootAddress(), "close", handle)
|
||||||
return assert(load(data, "=" .. file))
|
return assert(load(data, "=" .. file))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function handleError(errorMessage)
|
local function handleError(errorMessage)
|
||||||
return (errorMessage .. "\n \n" .. debug.traceback())
|
return (errorMessage .. "\n \n" .. debug.traceback())
|
||||||
end
|
end
|
||||||
|
|
||||||
function loadBoot()
|
function loadBoot()
|
||||||
local foundArchitecture = false
|
local foundArchitecture = false
|
||||||
for _, arch in pairs(computer.getArchitectures()) do
|
for _, arch in pairs(computer.getArchitectures()) do
|
||||||
if arch == "Lua 5.3" then
|
if arch == "Lua 5.3" then
|
||||||
foundArchitecture = true
|
foundArchitecture = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if foundArchitecture then
|
if foundArchitecture then
|
||||||
local _, errorMesage = computer.setArchitecture("Lua 5.3")
|
local _, errorMesage = computer.setArchitecture("Lua 5.3")
|
||||||
if errorMessage then
|
if errorMessage then
|
||||||
error(errorMessage)
|
error(errorMessage)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
gpu.set(1, 1, "Required architecture (Lua 5.3) is not supported.")
|
gpu.set(1, 1, "Required architecture (Lua 5.3) is not supported.")
|
||||||
gpu.set(1, 2, "Halting.")
|
gpu.set(1, 2, "Halting.")
|
||||||
while true do
|
while true do
|
||||||
computer.pullSignal()
|
computer.pullSignal()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
loadfile("/halyde/kernel/boot.lua")(loadfile)
|
loadfile("/halyde/kernel/boot.lua")(loadfile)
|
||||||
end
|
end
|
||||||
|
|
||||||
gpu.setBackground(0x000000)
|
gpu.setBackground(0x000000)
|
||||||
@@ -52,138 +52,143 @@ local unicode = unicode
|
|||||||
local result, reason = xpcall(loadBoot, handleError)
|
local result, reason = xpcall(loadBoot, handleError)
|
||||||
local lines = {}
|
local lines = {}
|
||||||
if not result then
|
if not result then
|
||||||
local log
|
resX, resY = gpu.getResolution() -- doing it again because boot.lua changes the resolution
|
||||||
local logSuccess, logError = false, nil
|
local log
|
||||||
if _G.require then
|
local logSuccess, logError = false, nil
|
||||||
logSuccess, logError = pcall(function()
|
if _G.require then
|
||||||
log = _G.require("log")
|
logSuccess, logError = pcall(function()
|
||||||
log.kernel.error("Halyde has crashed!\n" .. tostring(reason or "unknown error"))
|
log = _G.require("log")
|
||||||
end)
|
log.kernel.error("Halyde has crashed!\n" .. tostring(reason or "unknown error"))
|
||||||
end
|
end)
|
||||||
reason = "A fatal error has occurred.\nHalyde cannot continue.\n \n"
|
end
|
||||||
.. tostring(reason or "unknown error"):gsub("\t", " ")
|
reason = "A fatal error has occurred.\nHalyde cannot continue.\n \n"
|
||||||
if not log then
|
.. tostring(reason or "unknown error"):gsub("\t", " ")
|
||||||
reason = "WARNING: This error has occured early enough in the boot process that no log entry could be made.\n\n"
|
if not log then
|
||||||
.. reason
|
reason = "WARNING: This error has occured early enough in the boot process that no log entry could be made.\n\n"
|
||||||
elseif not logSuccess then
|
.. reason
|
||||||
if type(logError) == "nil" then
|
elseif not logSuccess then
|
||||||
logError = ""
|
if type(logError) == "nil" then
|
||||||
else
|
logError = ""
|
||||||
logError = "\n │ " .. tostring(logError)
|
else
|
||||||
end
|
logError = "\n │ " .. tostring(logError)
|
||||||
reason = "WARNING: An error has occured when making a log entry for this crash." .. logError .. "\n\n" .. reason
|
end
|
||||||
end
|
reason = "WARNING: An error has occured when making a log entry for this crash." .. logError .. "\n\n" .. reason
|
||||||
local bgColor
|
end
|
||||||
if gpu.getDepth() == 1 then
|
local bgColor
|
||||||
bgColor = 0x000000
|
if gpu.getDepth() == 1 then
|
||||||
else
|
bgColor = 0x000000
|
||||||
bgColor = 0x000080
|
else
|
||||||
end
|
bgColor = 0x000080
|
||||||
gpu.setBackground(bgColor)
|
end
|
||||||
gpu.fill(1, 1, resX, resY, " ")
|
gpu.setBackground(bgColor)
|
||||||
for line in string.gmatch(reason, "([^\n]*)\n?") do
|
gpu.fill(1, 1, resX, resY, " ")
|
||||||
table.insert(lines, line)
|
for line in string.gmatch(reason, "([^\n]*)\n?") do
|
||||||
end
|
table.insert(lines, line)
|
||||||
local function render()
|
end
|
||||||
gpu.setForeground(0xFFFFFF)
|
local function render()
|
||||||
for i = 1, #lines do
|
gpu.setForeground(0xFFFFFF)
|
||||||
gpu.set(2, i + 1, lines[i])
|
for i = 1, #lines do
|
||||||
end
|
gpu.set(2, i + 1, lines[i])
|
||||||
gpu.fill(1, resY - 1, resX, 1, "─")
|
end
|
||||||
gpu.fill(1, resY, resX, 1, " ")
|
gpu.fill(1, resY - 1, resX, 1, "─")
|
||||||
gpu.setForeground(bgColor)
|
gpu.fill(1, resY, resX, 1, " ")
|
||||||
gpu.setBackground(0xFFFFFF)
|
gpu.setForeground(bgColor)
|
||||||
gpu.set(2, resY, "🠅 🠄 🠇 🠆")
|
gpu.setBackground(0xFFFFFF)
|
||||||
gpu.setForeground(0xFFFFFF)
|
gpu.set(2, resY, "🠅 🠄 🠇 🠆 ⏎")
|
||||||
gpu.setBackground(bgColor)
|
gpu.setForeground(0xFFFFFF)
|
||||||
gpu.set(4, resY, " / ")
|
gpu.setBackground(bgColor)
|
||||||
gpu.set(9, resY, " / ")
|
gpu.set(4, resY, " / ")
|
||||||
gpu.set(14, resY, " / ")
|
gpu.set(9, resY, " / ")
|
||||||
gpu.set(19, resY, " Scroll" .. string.rep(" ", resX - 21))
|
gpu.set(14, resY, " / ")
|
||||||
end
|
gpu.set(19, resY, " Scroll ")
|
||||||
local function cropset(x, y, txt)
|
gpu.set(29, resY, " Reboot")
|
||||||
gpu.set(math.max(x, 1), y, unicode.sub(txt, math.max(2 - x, 1)))
|
end
|
||||||
end
|
local function cropset(x, y, txt)
|
||||||
local scrollX = 0
|
gpu.set(math.max(x, 1), y, unicode.sub(txt, math.max(2 - x, 1)))
|
||||||
local scrollY = 0
|
end
|
||||||
local function scrollDown()
|
local scrollX = 0
|
||||||
if scrollY >= #lines - resY + 2 then
|
local scrollY = 0
|
||||||
return
|
local function scrollDown()
|
||||||
end
|
if scrollY >= #lines - resY + 2 then
|
||||||
gpu.copy(1, 2, resX, resY - 3, 0, -1)
|
return
|
||||||
gpu.fill(1, resY - 2, resX, 1, " ")
|
end
|
||||||
local line = lines[scrollY + resY - 2]
|
gpu.copy(1, 2, resX, resY - 3, 0, -1)
|
||||||
if type(line) == "string" then
|
gpu.fill(1, resY - 2, resX, 1, " ")
|
||||||
cropset(2 - scrollX, resY - 2, line)
|
local line = lines[scrollY + resY - 2]
|
||||||
end
|
if type(line) == "string" then
|
||||||
scrollY = scrollY + 1
|
cropset(2 - scrollX, resY - 2, line)
|
||||||
end
|
end
|
||||||
local function scrollUp()
|
scrollY = scrollY + 1
|
||||||
if scrollY <= 0 then
|
end
|
||||||
return
|
local function scrollUp()
|
||||||
end
|
if scrollY <= 0 then
|
||||||
gpu.copy(1, 1, resX, resY - 3, 0, 1)
|
return
|
||||||
gpu.fill(1, 1, resX, 1, " ")
|
end
|
||||||
local line = lines[scrollY - 1]
|
gpu.copy(1, 1, resX, resY - 3, 0, 1)
|
||||||
if type(line) == "string" then
|
gpu.fill(1, 1, resX, 1, " ")
|
||||||
cropset(2 - scrollX, 1, line)
|
local line = lines[scrollY - 1]
|
||||||
end
|
if type(line) == "string" then
|
||||||
scrollY = scrollY - 1
|
cropset(2 - scrollX, 1, line)
|
||||||
end
|
end
|
||||||
local width = 0
|
scrollY = scrollY - 1
|
||||||
for i = 1, #lines do
|
end
|
||||||
width = math.max(width, unicode.len(lines[i]))
|
local width = 0
|
||||||
end
|
for i = 1, #lines do
|
||||||
local function rerender()
|
width = math.max(width, unicode.len(lines[i]))
|
||||||
for i = 1, #lines do
|
end
|
||||||
local y = i - scrollY + 1
|
local function rerender()
|
||||||
if y > 0 and y <= resY - 2 then
|
for i = 1, #lines do
|
||||||
gpu.fill(1, y, resX, 1, " ")
|
local y = i - scrollY + 1
|
||||||
cropset(2 - scrollX, y, lines[i])
|
if y > 0 and y <= resY - 2 then
|
||||||
end
|
gpu.fill(1, y, resX, 1, " ")
|
||||||
end
|
cropset(2 - scrollX, y, lines[i])
|
||||||
end
|
end
|
||||||
local function scrollRight()
|
end
|
||||||
if scrollX >= width - resX + 2 then
|
end
|
||||||
return
|
local function scrollRight()
|
||||||
end
|
if scrollX >= width - resX + 2 then
|
||||||
scrollX = scrollX + 1
|
return
|
||||||
rerender()
|
end
|
||||||
end
|
scrollX = scrollX + 1
|
||||||
local function scrollLeft()
|
rerender()
|
||||||
if scrollX <= 0 then
|
end
|
||||||
return
|
local function scrollLeft()
|
||||||
end
|
if scrollX <= 0 then
|
||||||
scrollX = scrollX - 1
|
return
|
||||||
rerender()
|
end
|
||||||
end
|
scrollX = scrollX - 1
|
||||||
render()
|
rerender()
|
||||||
beep(440, 0.2)
|
end
|
||||||
beep(465, 0.2)
|
render()
|
||||||
beep(440, 0.2)
|
beep(440, 0.2)
|
||||||
beep(370, 0.5)
|
beep(465, 0.2)
|
||||||
while true do
|
beep(440, 0.2)
|
||||||
local ev = { pullSignal() }
|
beep(370, 0.5)
|
||||||
if ev[1] == "key_down" then
|
while true do
|
||||||
if ev[4] == 200 then
|
local ev = { pullSignal() }
|
||||||
scrollUp()
|
if ev[1] == "key_down" then
|
||||||
end
|
if ev[4] == 200 then
|
||||||
if ev[4] == 208 then
|
scrollUp()
|
||||||
scrollDown()
|
end
|
||||||
end
|
if ev[4] == 208 then
|
||||||
if ev[4] == 203 then
|
scrollDown()
|
||||||
scrollLeft()
|
end
|
||||||
end
|
if ev[4] == 203 then
|
||||||
if ev[4] == 205 then
|
scrollLeft()
|
||||||
scrollRight()
|
end
|
||||||
end
|
if ev[4] == 205 then
|
||||||
end
|
scrollRight()
|
||||||
if ev[1] == "scroll" then
|
end
|
||||||
if ev[5] > 0 then
|
if ev[4] == 28 then
|
||||||
scrollUp()
|
computer.shutdown(true)
|
||||||
else
|
end
|
||||||
scrollDown()
|
end
|
||||||
end
|
if ev[1] == "scroll" then
|
||||||
end
|
if ev[5] > 0 then
|
||||||
end
|
scrollUp()
|
||||||
|
else
|
||||||
|
scrollDown()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user