fixed sum stuff

This commit is contained in:
2025-12-23 12:46:47 -08:00
parent 9df738465a
commit aa64d18060
9 changed files with 15514 additions and 20 deletions

View File

@@ -14,7 +14,6 @@ function _G.app.getApps()
local out = {}
for _,f in ipairs(fs.list("/apps-meta")) do
if fs.exists(fs.combine("/apps-meta",f)) then
print(f)
local file = fs.open(fs.combine("/apps-meta",f),"r")
if file then
out[#out+1] = textutils.unserialise(file.readAll())
@@ -24,13 +23,54 @@ function _G.app.getApps()
end
return out
end
function _G.app.launch(id,perms)
function _G.app.closeApp(pid)
if pid == focusedapp then
app.focusapp(-1)
apps[pid] = nil
else
apps[pid] = nil
end
end
function _G.app.getRunningApps()
local pids = {}
for k,_ in pairs(apps) do
pids[#pids+1] = k
end
return pids
end
function _G.app.getTitle(pid)
if not apps[pid] then return false, "Process not found" end
return apps[pid].title
end
function _G.app.getDetail(pid)
if not apps[pid] then return false, "Process not found" end
local registered_apps = app.getApps()
local appid = apps[pid].id
local appdetails = nil
local msg = "Details not found (likely doesn't have a metadata file)"
for _,registered_app in ipairs(registered_apps) do
if registered_app.appid == appid then
appdetails = registered_app
msg = nil
break
end
end
return appdetails, msg
end
function _G.app.launch(id,perms,parentperms)
if parentperms then
for k,v in pairs(perms) do
if v and not parentperms[k] then
return false, "Unable to grant permission: "..k
end
end
end
local w,h = term.getSize()
if not fs.exists(fs.combine("/apps",id)) then return false,"App Not Found" end
local win = windows.create(id,w,h-2,1,2)
local env = containers.getENV(fs.combine("/apps",id), win, perms)
local appobj = {win=win,co=nil,id=id,title=id}
function env.setAppTitle(str) appobj.title=str end
function env.setAppTitle(str) appobj.title=tostring(str) end
appobj.co = coroutine.create(function () containers.start(env) end)
local pid = -1
for k=1,#apps+1 do
@@ -75,7 +115,7 @@ local function render()
term.setCursorPos(1,1)
term.setBackgroundColor(colors.black)
if focusedapp then
term.setBackgroundColor(focusedapp.win.getBackgroundColour())
term.setBackgroundColor(focusedapp.win.getMostCommonBackgroundColor())
end
term.clearLine()
term.write(os.date("%I:%M %p"))
@@ -87,6 +127,7 @@ local function render()
term.setCursorPos(w-right:len()+1,1)
term.write(right)
term.setCursorPos((w/2)-(home_button:len()/2)+1,h)
term.clearLine()
term.write(home_button)
term.setCursorPos(1,h)
if focusedapp then
@@ -119,16 +160,7 @@ local function process()
event[4] = event[4]-1
end
if focusedapp then
if focusedapp.event then
local success, content = coroutine.resume(focusedapp.co,table.unpack(focusedapp.event))
if success then
-- print(focusedapp.title,focusedapp.filter)
focusedapp.event = nil
focusedapp.filter = content
else
app.focusapp(-1)
end
elseif focusedapp.filter == nil or focusedapp.filter == event[1] then
if focusedapp.filter == nil or focusedapp.filter == event[1] then
local success, content = coroutine.resume(focusedapp.co,table.unpack(event))
if success then
focusedapp.filter = content
@@ -138,13 +170,16 @@ local function process()
end
end
for k,v in pairs(apps) do
if v.filter == nil or v.filter == event[1] and v.event == nil and v ~= focusedapp then
v.event = event
if (v.filter == nil or v.filter == event[1]) and v ~= focusedapp and event[1] ~= "mouse_click" and event[1] ~= "mouse_up" and event[1] ~= "mouse_drag" and event[1] ~= "mouse_scroll" then
local success, content = coroutine.resume(v.co,table.unpack(event))
if success then
v.filter = content
end
end
end
end
end
print("launching launcher app..")
launcherapp = app.launch(launcherappid,{http=true,app=true,repo=true,network=true})
launcherapp = app.launch(launcherappid,{http=true,app=true,repo=true,network=true,peripheral=true})
print("launched launcher app")
parallel.waitForAny(process,render,network.run)