From 8fc441299bdb2b505662d65e95920574440eb60d Mon Sep 17 00:00:00 2001 From: 20kdc Date: Thu, 29 Mar 2018 17:31:51 +0100 Subject: [PATCH] Finish flash, replace pass with control (handles all the control things), slight adjustments here & there --- code/apps/app-claw.lua | 17 ++- code/apps/app-control.lua | 233 +++++++++++++++++++++++++++++++++++ code/apps/app-flash.lua | 76 ++++++++++++ code/apps/app-pass.lua | 47 ------- code/apps/sys-everest.lua | 22 +++- code/apps/sys-glacier.lua | 9 +- code/data/app-claw/local.lua | 5 +- code/libs/braille.lua | 160 +++++++++++++----------- code/libs/neoux.lua | 26 ++-- 9 files changed, 453 insertions(+), 142 deletions(-) create mode 100644 code/apps/app-control.lua delete mode 100644 code/apps/app-pass.lua diff --git a/code/apps/app-claw.lua b/code/apps/app-claw.lua index 2b28875..f92cc82 100644 --- a/code/apps/app-claw.lua +++ b/code/apps/app-claw.lua @@ -114,10 +114,13 @@ local windows = 1 local primarySearchTx = "" local primaryPage = 1 local primaryList = {} +local primaryNextMinus = false + -- package local packageLock = nil local packageId = "FIXME" + local function describe(pkg) local weHave = claw.getInfo(pkg, "local") local theyHave = claw.getInfo(pkg, "local") @@ -135,13 +138,14 @@ local function describe(pkg) end local function primaryWindowRegenCore() - return neoux.tcwindow(25, 12, genCurrent(), function (w) + local gen, gens = genCurrent() + return 25, 12, "claw", neoux.tcwindow(25, 12, gen, function (w) w.close() windows = windows - 1 - end, 0xFF8F00, 0) + end, 0xFF8F00, 0, gens) end local function primaryWindowRegen() - primaryWindow.reset(25, 12, primaryWindowRegenCore()) + primaryWindow.reset(primaryWindowRegenCore()) end -- Use all non-primary filesystems @@ -174,6 +178,8 @@ primaryList = claw.getList() -- Sections function genPrimary() + local minus = (primaryNextMinus and 3) or nil + primaryNextMinus = false local pgs = 10 local pages = math.ceil(#primaryList / pgs) local elems = { @@ -186,6 +192,7 @@ function genPrimary() neoux.tcrawview(4, 1, {neoux.pad(primaryPage .. " / " .. pages, 19, true, true)}), neoux.tcbutton(1, 1, "-", function (w) if primaryPage > 1 then + primaryNextMinus = true primaryPage = primaryPage - 1 primaryWindowRegen() end @@ -221,7 +228,7 @@ function genPrimary() primaryList = n primaryWindowRegen() end)) - return elems + return elems, minus end -- @@ -325,7 +332,7 @@ end -- genCurrent = genPrimary -primaryWindow = neoux.create(25, 12, "claw", primaryWindowRegenCore()) +primaryWindow = neoux.create(primaryWindowRegenCore()) while windows > 0 do event.pull() diff --git a/code/apps/app-control.lua b/code/apps/app-control.lua new file mode 100644 index 0000000..1b283e9 --- /dev/null +++ b/code/apps/app-control.lua @@ -0,0 +1,233 @@ +-- This is released into the public domain. +-- No warranty is provided, implied or otherwise. + +-- app-control: Settings changer +local settings = neo.requireAccess("x.neo.sys.manage", "management") +local globals = neo.requireAccess("x.neo.pub.globals", "gbm") + +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 mainGen +local currentGen +local window + +local function returner() + currentGen = mainGen + window.reset(currentGen()) +end + +local function scrGen() + local tx = {} + local elems = { + } + local y = 1 + for k, v in ipairs(globals.getKnownMonitors()) do + table.insert(tx, v[1]:sub(1, 16) .. "..." ) + table.insert(tx, "") + table.insert(elems, neoux.tcbutton(21, y, "max", function (w) + globals.changeMonitorSetup(v[1], 320, 200, 32, v[6]) + globals.forceRescan() + end)) + local cw, ch = v[3], v[4] + table.insert(elems, neoux.tcfield(1, y + 1, 5, function (tx) + if tx then cw = math.max(0, math.floor(tonumber(tx) or 0)) end + return tostring(cw) + end)) + table.insert(elems, neoux.tcfield(6, y + 1, 5, function (tx) + if tx then ch = math.max(0, math.floor(tonumber(tx) or 0)) end + return tostring(ch) + end)) + table.insert(elems, neoux.tcbutton(12, y + 1, "set", function (w) + globals.changeMonitorSetup(v[1], math.max(cw, 1), math.max(ch, 1), v[5], v[6]) + globals.forceRescan() + end)) + local nx = 8 + if v[5] == 8 then + nx = 4 + elseif v[5] == 4 then + nx = 1 + end + table.insert(elems, neoux.tcbutton(18, y + 1, v[5] .. "b", function (w) + globals.changeMonitorSetup(v[1], v[3], v[4], nx, v[6]) + globals.forceRescan() + end)) + local tm = "ti" + local to = "yes" + if v[6] == "yes" then + tm = "TI" + to = "no" + end + table.insert(elems, neoux.tcbutton(22, y + 1, tm, function (w) + globals.changeMonitorSetup(v[1], v[3], v[4], v[5], to) + globals.forceRescan() + end)) + y = y + 2 + end + table.insert(elems, neoux.tcrawview(1, 1, tx)) + return 25, #tx, nil, neoux.tcwindow(25, #tx, elems, returner, 0xFFFFFF, 0) +end +local function logGen() + local computer = neo.requireAccess("k.computer", "user management") + local tx = { + "Password:", + " (Keep blank to disable.)", + "MC Usernames Allowed:" + } + local users = table.pack(computer.users()) + for k, v in ipairs(users) do + tx[k + 3] = " " .. v + end + local workingName = "" + return 25, #tx + 1, nil, neoux.tcwindow(25, #tx + 1, { + neoux.tcrawview(1, 1, tx), + neoux.tcfield(11, 1, 15, function (str) + if str then + settings.setSetting("password", str) + end + return settings.getSetting("password") + end), + neoux.tcfield(1, #tx + 1, 19, function (str) + workingName = str or workingName + return workingName + end), + neoux.tcbutton(20, #tx + 1, "+", function (w) + local ok, err = computer.addUser(workingName) + if not ok then + neoux.startDialog(err) + end + w.reset(logGen()) + end), + neoux.tcbutton(23, #tx + 1, "-", function (w) + computer.removeUser(workingName) + w.reset(logGen()) + end), + }, returner, 0xFFFFFF, 0) +end + +local advPage = 1 +local advPlusH = false + +local function advAsker(info, def, r, parent) + return function () + return 25, 2, nil, neoux.tcwindow(25, 2, { + neoux.tcrawview(1, 1, { + unicode.safeTextFormat(info) + }), + neoux.tcfield(1, 2, 25, function (tx) + def = tx or def + return def + end) + }, function (w) + r(def) + currentGen = parent + w.reset(parent()) + end, 0xFFFFFF, 0) + end +end + +local function advGen() + local set = settings.listSettings() + table.sort(set) + + -- things get complicated here... + local pages = math.max(1, math.ceil(#set / 7)) + advPage = math.max(1, math.min(advPage, pages)) + local elems = { + neoux.tcbutton(23, 1, "+", function (w) + advPage = advPage + 1 + w.reset(advGen()) + end), + neoux.tcrawview(4, 1, {neoux.pad(advPage .. " / " .. pages, 14, true, true)}), + neoux.tcbutton(1, 1, "-", function (w) + advPage = advPage - 1 + advPlusH = true + w.reset(advGen()) + end), + neoux.tcbutton(18, 1, "add", function (w) + currentGen = advAsker("setting ID", "my.setting", function (r) + settings.setSetting(r, "") + end, currentGen) + w.reset(advGen()) + end), + } + local ofs = (advPage - 1) * 7 + for i = 1, 7 do + local s = set[i + ofs] + if s then + local tx = s .. "=" .. (settings.getSetting(s) or "") + table.insert(elems, neoux.tcbutton(1, i + 1, unicode.sub(unicode.safeTextFormat(tx), 1, 20), function (w) + currentGen = advAsker(s .. ":", settings.getSetting(s) or "", function (r) + settings.setSetting(s, r) + end, currentGen) + w.reset(currentGen()) + end)) + table.insert(elems, neoux.tcbutton(23, i + 1, "-", function (w) + settings.delSetting(s) + end)) + end + end + local ph + if advPlusH then + advPlusH = false + ph = 3 + end + return 25, 8, nil, neoux.tcwindow(25, 8, elems, returner, 0xFFFFFF, 0, ph) +end + +function mainGen() + return 25, 8, nil, neoux.tcwindow(25, 8, { + neoux.tcbutton(1, 1, "Screens", function (window) + currentGen = scrGen + window.reset(currentGen()) + end), + neoux.tcrawview(2, 2, { + "Size, depth, touchmode." + }), + neoux.tcbutton(1, 3, "Login & Access", function (window) + currentGen = logGen + window.reset(currentGen()) + end), + neoux.tcrawview(2, 4, { + "Allowed users, password." + }), + neoux.tcbutton(1, 5, "Advanced Settings", function (window) + advPage = 1 + currentGen = advGen + window.reset(currentGen()) + end), + neoux.tcrawview(2, 6, { + "The raw settings data." + }), + neoux.tchdivider(1, 7, 25), + neoux.tcbutton(1, 8, "Relog", function (window) + neo.requireAccess("x.neo.sys.session", "Everest session").endSession(true) + end), + neoux.tcbutton(8, 8, "Reboot", function (window) + settings.shutdown(true) + end), + neoux.tcbutton(16, 8, "Shutdown", function (window) + settings.shutdown(false) + end), + }, function () + window.close() + running = false + end, 0xFFFFFF, 0) +end + +currentGen = mainGen + +window = neoux.create(currentGen()) + +while running do + local src, id, k, v = event.pull() + if src == "x.neo.sys.manage" then + if id == "set_setting" then + window.reset(currentGen()) + end + end +end diff --git a/code/apps/app-flash.lua b/code/apps/app-flash.lua index e1ff865..8e48edb 100644 --- a/code/apps/app-flash.lua +++ b/code/apps/app-flash.lua @@ -4,10 +4,86 @@ local event = require("event")(neo) local neoux = require("neoux")(event, neo) +local eeprom = neo.requireAccess("c.eeprom") + +-- note: fun coincidence makes this exactly the right size -- 1234567890123456789012345 -- ABCDEF12 Lua BIOS --