From 902ff12d22bf12dae93d444451db145330bce75e Mon Sep 17 00:00:00 2001 From: 20kdc Date: Thu, 29 Mar 2018 21:35:04 +0100 Subject: [PATCH] Fix the launcher for high amounts of applications --- code/apps/app-launcher.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/code/apps/app-launcher.lua b/code/apps/app-launcher.lua index e2801f0..89bf809 100644 --- a/code/apps/app-launcher.lua +++ b/code/apps/app-launcher.lua @@ -11,14 +11,17 @@ local running = true local buttons = {} local xlen = 0 +local xlb = 1 +local yp = 1 local appNames = neo.listApps() for k, v in ipairs(appNames) do if v:sub(1, 4) == "app-" then - local vl = unicode.len(v) + local vs = unicode.safeTextFormat(v) + local vl = unicode.len(vs) + xlb + 1 if xlen < vl then xlen = vl end - table.insert(buttons, neoux.tcbutton(1, #buttons + 1, v, function (w) + table.insert(buttons, neoux.tcbutton(xlb, yp, vs, function (w) -- Button pressed. local pid, err = neo.executeAsync(v) if not pid then @@ -28,10 +31,15 @@ for k, v in ipairs(appNames) do running = false end end)) + yp = yp + 1 + if yp == 16 then + yp = 1 + xlb = xlen + 1 + end end end -neoux.create(xlen + 2, #buttons, nil, neoux.tcwindow(xlen + 2, #buttons, buttons, function (w) +neoux.create(xlen, math.min(15, #buttons), nil, neoux.tcwindow(xlen, math.min(15, #buttons), buttons, function (w) w.close() running = false end, 0xFFFFFF, 0))