v0.2.0 - Added startup apps and an event handler process (unfinished)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
local loadfile = ...
|
||||
local filesystem = loadfile("/halyde/lib/filesystem.lua")(loadfile)
|
||||
|
||||
_G._OSVERSION = "Halyde 0.1.0"
|
||||
_G._OSVERSION = "Halyde 0.2.0"
|
||||
|
||||
function _G.import(module, ...)
|
||||
local args = table.pack(...)
|
||||
@@ -21,7 +21,7 @@ function _G.import(module, ...)
|
||||
tmpdata = handle:read(math.huge or math.maxinteger)
|
||||
data = data .. (tmpdata or "")
|
||||
until not tmpdata
|
||||
assert(load(data, "="..modulepath))(table.unpack(args))
|
||||
return(assert(load(data, "="..modulepath))(table.unpack(args)))
|
||||
end
|
||||
|
||||
--local handle = assert(filesystem.open("/bazinga.txt", "w"))
|
||||
|
||||
+21
-3
@@ -1,12 +1,15 @@
|
||||
_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)
|
||||
coroutine.yield()
|
||||
end
|
||||
|
||||
function handleError(errormsg)
|
||||
@@ -14,7 +17,19 @@ function handleError(errormsg)
|
||||
assert(false, errormsg)
|
||||
end
|
||||
|
||||
_G.cormgr.loadCoroutine("/halyde/core/loader.lua")
|
||||
local handle = filesystem.open("/halyde/config/startupapps.txt", "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
|
||||
_G.cormgr.loadCoroutine(line)
|
||||
end
|
||||
end
|
||||
_G.cormgr.loadCoroutine("/halyde/core/shell.lua")
|
||||
|
||||
while true do
|
||||
for i = 1, #_G.cormgr.corList do
|
||||
@@ -25,6 +40,9 @@ while true do
|
||||
handleError(errormsg)
|
||||
end
|
||||
end
|
||||
computer.pullSignal(1)
|
||||
computer.pullSignal(0)
|
||||
end
|
||||
if #_G.cormgr.corList == 0 then
|
||||
computer.shutdown()
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,17 @@
|
||||
_G.evmgr = {}
|
||||
_G.evmgr.eventQueue = {}
|
||||
local maxEventQueueLength = 10 -- increase if events start getting dropped
|
||||
|
||||
while true do
|
||||
local args
|
||||
repeat
|
||||
args = computer.pullSignal(0)
|
||||
if args then
|
||||
table.insert(evmgr.eventQueue, table.pack(computer.uptime(), args))
|
||||
while #evmgr.eventQueue > maxEventQueueLength do
|
||||
table.remove(evmgr.eventQueue, 1)
|
||||
end
|
||||
end
|
||||
until not args
|
||||
coroutine.yield()
|
||||
end
|
||||
@@ -1,8 +0,0 @@
|
||||
import("termlib")
|
||||
|
||||
print("wait...")
|
||||
print("IT WORKS???")
|
||||
print("abab")
|
||||
print("abc\ndef")
|
||||
print("abc\tdef")
|
||||
print("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
|
||||
@@ -0,0 +1,6 @@
|
||||
import("termlib")
|
||||
|
||||
print("\n │\n │ ".._OSVERSION..'\n │ Welcome! Type "help" to get started.\n │')
|
||||
while true do
|
||||
coroutine.yield()
|
||||
end
|
||||
Reference in New Issue
Block a user