Files
Halyde/halyde/core/cormgr.lua
T
Ponali e9cf9789b7 0.5.0 - ANSI color escape code support
I got asked to do the ANSI escape codes for color because Wahlolly couldn't find a way to get them to work. This involved making some kind of TTY, and let me be clear, i didn't know it would be so tedious to develop one. This implementation has support for dark and bright colors by using a color palette. There isn't 8-bit and 24-bit color yet, nor is there a shell parser, so please wait a bit more when it gets implemented.
2025-04-19 16:09:27 +02:00

62 lines
1.4 KiB
Lua

_G.cormgr = {}
_G.cormgr.corList = {}
--local ocelot = component.proxy(component.list("ocelot")())
local filesystem = import("filesystem")
function _G.cormgr.loadCoroutine(path)
local cor = coroutine.create(function()
import(path)
end)
table.insert(_G.cormgr.corList, cor)
end
function handleError(errormsg)
if errormsg == nil then
error("unknown error")
else
error(tostring(errormsg).."\n \n"..debug.traceback())
end
end
local function runCoroutines()
for i = 1, #_G.cormgr.corList do
local result, errorMessage = coroutine.resume(_G.cormgr.corList[i])
if not result then
handleError(errorMessage)
end
if coroutine.status(_G.cormgr.corList[i]) == "dead" then
table.remove(_G.cormgr.corList, i)
break
end
--computer.pullSignal(0)
--coroutine.yield()
end
end
local handle = filesystem.open("/halyde/config/startupapps.cfg", "r")
local data = ""
local tmpdata
repeat
tmpdata = handle:read(math.huge or math.maxinteger)
data = data .. (tmpdata or "")
until not tmpdata
for line in data:gmatch("([^\n]*)\n?") do
if line ~= "" then
--[[ if _G.print then
print(line)
end ]]
_G.cormgr.loadCoroutine(line)
runCoroutines()
end
end
-- _G.cormgr.loadCoroutine("/halyde/core/shell.lua")
while true do
runCoroutines()
if #_G.cormgr.corList == 0 then
computer.shutdown()
end
end