From 62f902044aa17214484e9e994b134f6a88ad405b Mon Sep 17 00:00:00 2001 From: Ale32bit Date: Thu, 17 Nov 2016 16:00:03 +0100 Subject: [PATCH] Update appList.lua --- src/apps/appList.lua | 69 ++++++++++++++------------------------------ 1 file changed, 22 insertions(+), 47 deletions(-) diff --git a/src/apps/appList.lua b/src/apps/appList.lua index 025a4dc..2378a15 100644 --- a/src/apps/appList.lua +++ b/src/apps/appList.lua @@ -1,52 +1,27 @@ local spkList = "/.sPhone/config/spklist" local dir = "/.sPhone/apps/spk/" +local apps = {} +local ind = {} if not fs.exists(spkList) then config.list("/.sPhone/config/spklist") end - - local apps = {} - - for k,v in pairs(config.list(spkList)) do - table.insert(apps,{ - id = k, - name = v, - }) - end - - for k,v in ipairs(apps) do - local hid = config.read(dir..v.id.."/.spk","hidden") - if hid then - table.remove(apps,k) - end - end - - local function drawHome() - term.setBackgroundColor(sPhone.theme["backgroundColor"]) - term.clear() - term.setTextColor(sPhone.theme["text"]) - sPhone.header("Apps","X") - term.setBackgroundColor(sPhone.theme["backgroundColor"]) - term.setTextColor(sPhone.theme["text"]) - - term.setCursorPos(1,3) - for k, v in pairs(apps) do - print(v.name) - end - end - - drawHome() - - local w, h = term.getSize() - - while true do - drawHome() - local _,_,x,y = os.pullEvent("mouse_click") - if x == w and y == 1 then - break - elseif y >= 2 then - if apps[y-2] then - sPhone.launch(apps[y-2].id) - return - end - end - end +for k,v in pairs(config.list(spkList)) do + table.insert(apps,{ + id = k, + name = v, + }) +end +for k,v in ipairs(apps) do + local hid = config.read(dir..v.id.."/.spk","hidden") + if hid then + table.remove(apps,k) + end +end +for k,v in ipairs(apps) do + ind[ v.id ] = v.name +end +sPhone.launch(sPhone.list(nil,{ + list = ind, + pairs = true, + title = " Apps" +}))