diff --git a/repository/apps/app-slaunch.lua b/repository/apps/app-slaunch.lua new file mode 100644 index 0000000..5776f23 --- /dev/null +++ b/repository/apps/app-slaunch.lua @@ -0,0 +1,69 @@ +-- This is released into the public domain. +-- No warranty is provided, implied or otherwise. + +-- app-slaunch: searching launcher +local event = require("event")(neo) +local neoux, err = require("neoux") +if not neoux then error(err) end +neoux = neoux(event, neo) + +local running = true + +local buttons = {} +local appNames = neo.listApps() +local searchTerm = "" + +function searchApps(str) + local rt = {} + for k,v in ipairs(appNames) do + if v:sub(1, 4) == "app-" then + if v:find(str) then + rt[#rt+1] = v + neo.emergency(v) + end + end + end + return rt +end + +function genWindow(apps) + local wwidth, wheight, wcontents = 1, 1, {} + for k,v in pairs(apps) do + appname = v:sub(5) + if appname:len()+2 > wwidth then + wwidth = appname:len()+2 + end + table.insert(wcontents, neoux.tcbutton(1, wheight+1, appname, function(w) + local pid, err = neo.executeAsync(v) + if not pid then + neoux.startDialog(tostring(err), "launchErr") + else + w.close() + running = false + end + end)) + wheight = wheight + 1 + end + wwidth = math.max(wwidth, 11) + table.insert(wcontents,1,neoux.tcfield(1,1,wwidth,function(nv) + if not nv then return searchTerm end + searchTerm = nv + local sapps = searchApps(searchTerm) + local fwwidth, fwheight, fwcontents = genWindow(sapps) + window.reset(fwwidth, fwheight, nil, neoux.tcwindow(fwwidth, fwheight, fwcontents, function(w) + w.close() + running = false + end, 0xFFFFFF, 0)) + end)) + return wwidth, wheight, wcontents +end + +wwidth, wheight, wcontents = genWindow(searchApps(searchTerm)) +window = neoux.create(wwidth, wheight, nil, neoux.tcwindow(wwidth, wheight, wcontents, function (w) + w.close() + running = false +end, 0xFFFFFF, 0)) + +while running do + event.pull() +end diff --git a/repository/data/app-claw/local.lua b/repository/data/app-claw/local.lua index e460268..c2b8846 100644 --- a/repository/data/app-claw/local.lua +++ b/repository/data/app-claw/local.lua @@ -35,6 +35,19 @@ return { "apps/app-launchbar.lua" }, }, + ["app-slaunch"] = { + desc = "Searching launcher", + v = 0, + deps = { + "neo" + }, + dirs = { + "apps" + }, + files = { + "apps/app-slaunch.lua" + }, + }, ["neo-docs"] = { desc = "KittenOS NEO system documentation", v = 2,