diff --git a/README.md b/README.md index 75275c8..aa538d8 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,16 @@ The first commit is after I got the installer working again after the new compre That's what the "SYSTEM HEROES" thing is about. +## Authors + +Most code and data here by 20kdc. + +Exceptions must be noted in this section, on a per-file basis, including submitted patches. + +## About code/README.asc + +It exists because it needs to exist. + ## Known Issues (That Aren't KittenOS NEO's Fault) Touch calibration could be off if the setPrecise support mess didn't work properly. diff --git a/code/apps/sys-everest.lua b/code/apps/sys-everest.lua index 74d78d6..ef45fe4 100644 --- a/code/apps/sys-everest.lua +++ b/code/apps/sys-everest.lua @@ -58,6 +58,7 @@ local lIM = 1 -- Stops the main loop local shuttingDown = false +-- Also used for settings. local savingThrow = neo.requestAccess("x.neo.sys.manage") local function suggestAppsStop() @@ -677,7 +678,14 @@ local function key(ku, ka, kc, down) return end if ka == 13 then - if down and (not waitingShutdownCallback) then neo.executeAsync("app-launcher") end return + if down and (not waitingShutdownCallback) then + local lApp = "app-launcher" + if savingThrow then + lApp = savingThrow.getSetting("sys-everest.launcher") or lApp + end + neo.executeAsync(lApp) + end + return end end if focus then @@ -774,10 +782,17 @@ while not shuttingDown do end for k, v in ipairs(tags) do local surf = table.remove(surfaces, v - (k - 1)) + if os1 == surf then + os1 = nil + end updateRegion(surf[1], surf[2], surf[3], surf[4], surf[5], {}) end checkWSC() - changeFocus(os1) + if os1 then + changeFocus(os1) + else + changeFocus(surfaces[1]) + end end if s[1] == "x.neo.sys.screens" then if s[2] == "available" then diff --git a/code/apps/sys-icecap.lua b/code/apps/sys-icecap.lua index f3fb286..7a6c5ac 100644 --- a/code/apps/sys-icecap.lua +++ b/code/apps/sys-icecap.lua @@ -183,6 +183,7 @@ donkonitDFProvider(function (pkg, pid, sendSig) neo.ensurePath(path, prefixWS) if path:sub(#path, #path) == "/" then error("Expected no / at end") end local fw, closer = require("sys-filewrap").create(fs.primary, path, mode) + if not fw then return nil, closer end local oc = fw.close fw.close = function () oc() diff --git a/code/libs/neoux.lua b/code/libs/neoux.lua index 63d3e11..678808a 100644 --- a/code/libs/neoux.lua +++ b/code/libs/neoux.lua @@ -347,14 +347,12 @@ newNeoux = function (event, neo) selectable = true, key = function (window, update, a, c, d) if d then - if a == 13 then - return true - elseif a == 8 then + if a == 8 then local str = textprop() textprop(unicode.sub(str, 1, unicode.len(str) - 1)) update() return true - elseif a ~= 0 then + elseif a >= 32 then textprop(textprop() .. unicode.char(a)) update() return true diff --git a/repository/apps/app-nbox2018.lua b/repository/apps/app-nbox2018.lua index d428a40..95c3b97 100644 --- a/repository/apps/app-nbox2018.lua +++ b/repository/apps/app-nbox2018.lua @@ -6,7 +6,6 @@ -- program start -local holos = neo.requestAccess("c.hologram") local icecap = neo.requireAccess("x.neo.pub.base", "filedialogs") local window = neo.requireAccess("x.neo.pub.window", "window")(40, 13) local fmttext = require("fmttext") @@ -90,6 +89,12 @@ local programStates = { elseif kc == 68 then -- Tint if selectedBox then tintDigi = 1 programState = "tint" end + elseif ka == 127 or ka == 8 then + -- Delete + if selectedBox then + boxes[state][selectedBox] = nil + selectedBox = nil + end else local cc = unicode.char(ka):upper() if boxes[state][cc] then @@ -243,9 +248,10 @@ local function onRect(x, y, minX, minY, maxX, maxY) end local function getPixel(x, y, p) + -- the reason is obvious for plane1, but less so for plane2 + -- just consider that without this, the top of the screen would be facing you, but X would remain your left/right + y = 17 - y if p == 1 then - -- plane 1 uses inverted Y - y = 17 - y if x == cx and y == cy then return cursorBlink end @@ -451,7 +457,7 @@ local function exportBoxes(shapes, st) v.minX, v.minY, v.minZ, - v.minX, + v.maxX, v.maxY, v.maxZ, texture = v.tex, @@ -569,7 +575,7 @@ while true do if not xyz then cy = math.min(16, cy + 1) else - cz = math.max(1, cz - 1) + cz = math.min(16, cz + 1) end refresh() elseif d == 205 then @@ -579,7 +585,7 @@ while true do if not xyz then cy = math.max(1, cy - 1) else - cz = math.min(16, cz + 1) + cz = math.max(1, cz - 1) end refresh() else diff --git a/repository/apps/app-nprt2018.lua b/repository/apps/app-nprt2018.lua index f534deb..7fc77f0 100644 --- a/repository/apps/app-nprt2018.lua +++ b/repository/apps/app-nprt2018.lua @@ -1 +1,137 @@ -Hello World. +-- This is released into the public domain. +-- No warranty is provided, implied or otherwise. + +-- app-nprt2018.lua : 3D printing application +-- Authors: 20kdc + +local callerPkg, callerPid, sentModel = ... + +local event = require("event")(neo) +local neoux = require("neoux")(event, neo) +local tp = neo.requireAccess("c.printer3d", "") +local running = true + +local window, genCurrent + +local function regen() + window.reset(genCurrent()) +end + +local function runModel(mdl, printers, rep) + if not mdl then return end + for _, v in ipairs(printers) do + v.reset() + v.setLabel(mdl.label or "Block") + v.setTooltip(mdl.tooltip or "A 3D-printed block.") + v.setRedstoneEmitter(mdl.emitRedstore or false) + v.setButtonMode(mdl.buttonMode or false) + for _, vs in ipairs(mdl.shapes) do + v.addShape(vs[1], vs[2], vs[3], vs[4], vs[5], vs[6], vs.texture or "", vs.state or false, vs.tint or 0xFFFFFF) + end + v.commit(rep) + end +end + +local function gaugeProgress(printers) + local avg = 0 + local busy = false + for _, v in ipairs(printers) do + local state, substate = v.status() + if state == "idle" then + avg = avg + 100 + else + busy = true + avg = avg + substate + end + end + if not busy then return end + -- if busy, #printers cannot be 0 + return math.ceil(avg / #printers) +end + +local function engagePS2(printers, rep) + window.close() + local model = sentModel + if not model then + local m = neoux.fileDialog(false) + if m then + model = require("serial").deserialize("return " .. m.read("*a")) + m.close() + end + end + if not model then + genCurrent = genMain + window = neoux.create(genCurrent()) + return + end + local percent = 0 + genCurrent = function () + local str = "Printing... " .. percent .. "%" + local tx = "printing" + return #str, 1, tx, function (w, ev, t) + if ev == "close" then + for _, v in ipairs(printers) do + v.reset() + end + end + if ev == "line" then + if t == 1 then + w.span(1, 1, str, 0xFFFFFF, 0) + end + end + end + end + window = neoux.create(genCurrent()) + runModel(model, printers, rep) + while true do + percent = gaugeProgress(printers) + if not percent then break end + regen() + event.sleepTo(os.uptime() + 1) + end + window.close() + if sentModel then + running = false + else + genCurrent = genMain + window = neoux.create(genCurrent()) + end +end + +function genMain() + local rep = 1 + local elems = { + neoux.tcrawview(1, 1, { + "Repeats: ", + "Choose Printer: " + }), + neoux.tcfield(9, 1, 7, function (tx) + if tx then rep = math.max(0, math.floor(tonumber(tx) or 0)) end + return tostring(rep) + end) + } + local max = 16 + local all = {} + for v in tp.list() do + table.insert(all, v) + local us = unicode.safeTextFormat(v.address) + table.insert(elems, neoux.tcbutton(1, #elems + 1, us, function (w) + engagePS2({v}, rep) + end)) + max = math.max(max, unicode.len(us) + 2) + end + table.insert(elems, neoux.tcbutton(1, #elems + 1, "All", function (w) + engagePS2(all, rep) + end)) + return max, #elems, nil, neoux.tcwindow(max, #elems, elems, function (w) + running = false + w.close() + end, 0xFFFFFF, 0) +end + +genCurrent = genMain + +window = neoux.create(genCurrent()) +while running do + event.pull() +end diff --git a/repository/docs/us-setti b/repository/docs/us-setti index c19973b..c1ae93c 100644 --- a/repository/docs/us-setti +++ b/repository/docs/us-setti @@ -7,6 +7,10 @@ As "*" is used as a part of some of -- System-wide permissions -- +sys-everest.launcher: The launcher + application. If not present, then + app-launcher is used by default. + pub.: Public settings, readable and writable by anything with x.neo.pub.globals access.