1
0
mirror of https://github.com/20kdc/OC-KittenOS.git synced 2024-11-23 10:58:06 +11:00

Finish flash, replace pass with control (handles all the control things), slight adjustments here & there

This commit is contained in:
20kdc 2018-03-29 17:31:51 +01:00
parent 8e0c74c41b
commit 8fc441299b
9 changed files with 453 additions and 142 deletions

View File

@ -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()

233
code/apps/app-control.lua Normal file
View File

@ -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

View File

@ -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
-- <get><set> <data> <label>
-- 21FEDCBA Nuclear Disk
-- <get><set> <data> <label>
local running = true
local busy = false
local regenCore
local function regenLabeller(set, get, wd)
return wd, 2, nil, neoux.tcwindow(wd, 1, {
neoux.tcfield(1, 1, wd, function (nt)
if nt then
set(nt)
end
return get()
end)
}, function (w)
busy = false
w.reset(regenCore())
end, 0xFFFFFF, 0)
end
function regenCore()
local elems = {}
local l = 1
for v in eeprom.list() do
local lbl = unicode.safeTextFormat(v.getLabel())
table.insert(elems, neoux.tcrawview(1, l, {
v.address:sub(1, 8) .. " " .. lbl
}))
table.insert(elems, neoux.tcbutton(1, l + 1, "get", function (window)
if busy then return end
busy = true
local fd = neoux.fileDialog(true)
if not fd then busy = false return end
fd.write(v.get())
fd.close()
busy = false
neoux.startDialog("Got the data!", nil, true)
end))
table.insert(elems, neoux.tcbutton(6, l + 1, "set", function (window)
if busy then return end
busy = true
local fd = neoux.fileDialog(false)
if not fd then busy = false return end
local eepromCode = fd.read("*a")
fd.close()
local wasOk, report = v.set(eepromCode)
report = (wasOk and tostring(report)) or "Flash successful.\nI recommend relabelling the EEPROM."
busy = false
neoux.startDialog(report, nil, true)
end))
local function dHandler(set, get, wd)
local setter = v[set]
local getter = v[get]
return function (window)
if busy then return end
busy = true
window.reset(regenLabeller(setter, getter, wd))
end
end
table.insert(elems, neoux.tcbutton(12, l + 1, "data", dHandler("setData", "getData", 38)))
table.insert(elems, neoux.tcbutton(19, l + 1, "label", dHandler("setLabel", "getLabel", 18)))
l = l + 2
end
return 25, l - 1, nil, neoux.tcwindow(25, l - 1, elems, function (w)
w.close()
running = false
end, 0xFFFFFF, 0)
end
local window = neoux.create(regenCore())
while running do
event.pull()
end

View File

@ -1,47 +0,0 @@
-- This is released into the public domain.
-- No warranty is provided, implied or otherwise.
-- app-pass: The password setter
local settings = neo.requestAccess("x.neo.sys.manage")
if not settings then error("no management") return end
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 pw = settings.getSetting("password")
neoux.create(20, 2, nil, neoux.tcwindow(20, 2, {
neoux.tcfield(1, 1, 12, function (set)
if not set then
return pw
end
pw = set
end),
neoux.tcbutton(13, 1, "set PW", function (w)
settings.setSetting("password", pw)
w.close()
running = false
end),
neoux.tcbutton(1, 2, "log out", function (w)
w.close()
running = false
local session = neo.requestAccess("x.neo.sys.session")
if not session then return end
session.endSession(true)
end),
neoux.tcbutton(11, 2, "shutdown", function (w)
w.close()
running = false
settings.shutdown(false)
end)
}, function (w)
w.close()
running = false
end, 0xFFFFFF, 0))
while running do
event.pull()
end

View File

@ -62,6 +62,15 @@ local lIM = 1
local shuttingDown = false
local savingThrow = neo.requestAccess("x.neo.sys.manage")
local function suggestAppsStop()
for k, v in ipairs(surfaces) do
for i = 1, 4 do
v[6]("close")
end
end
end
local function dying()
local primary = (monitors[1] or {})[2] or ""
for _, v in ipairs(monitors) do
@ -77,6 +86,7 @@ local function dying()
pcall(v[6], "line", 1)
pcall(v[6], "line", 2)
end
surfaces = {}
end
if savingThrow then
savingThrow.registerForShutdownEvent()
@ -185,7 +195,7 @@ local function updateRegion(monitorId, x, y, w, h, surfaceSpanCache)
end
local function updateStatus()
statusLine = "Λ-¶: menu (launch 'pass' to logout)"
statusLine = "Λ-¶: menu (launch 'control' to logout)"
if surfaces[1] then
if #monitors > 1 then
-- 123456789X123456789X123456789X123456789X123456789X
@ -254,8 +264,8 @@ local function moveSurface(surface, m, x, y, w, h, force)
if ox == x and oy == y and not force then
return
end
-- note: this doesn't always work due to WC support
if renderingAllowed() then
-- note: this doesn't always work due to WC support, and due to resize-to-repaint
if renderingAllowed() and not force then
local cb, b = monitors[m][1]()
if b then
monitorResetBF(b)
@ -384,6 +394,7 @@ everestProvider(function (pkg, pid, sendSig)
local lid = 0
return function (w, h, title)
if neo.dead then error("everest died") end
if shuttingDown or waitingShutdownCallback then error("system shutting down") end
w = math.floor(math.max(w, 8))
h = math.floor(math.max(h, 1)) + 1
if type(title) ~= "string" then
@ -516,6 +527,7 @@ everestSessionProvider(function (pkg, pid, sendSig)
endSession = function (gotoBristol)
shuttingDown = true
if gotoBristol then
suggestAppsStop()
dying()
end
end
@ -699,9 +711,7 @@ while not shuttingDown do
if s[1] == "x.neo.sys.manage" then
if s[2] == "shutdown" then
waitingShutdownCallback = s[4]
for k, v in ipairs(surfaces) do
v[6]("close")
end
suggestAppsStop()
checkWSC()
end
end

View File

@ -335,17 +335,20 @@ glacierDCProvider(function (pkg, pid, sendSig)
tbl[k] = {v.address, false, getMonitorSettings(v.address)}
end
for k, v in pairs(monitorClaims) do
table.insert(tbl, {k, true, getMonitorSettings(v.address)})
table.insert(tbl, {k, true, getMonitorSettings(k)})
end
return tbl
end,
changeMonitorSetup = function (ma, w, h, d)
changeMonitorSetup = function (ma, w, h, d, t)
neo.ensureType(ma, "string")
neo.ensureType(w, "number")
neo.ensureType(h, "number")
neo.ensureType(d, "number")
neo.ensureType(t, "string")
w = math.floor(w)
h = math.floor(h)
d = math.floor(d)
if t ~= "yes" then t = "no" end
if w < 1 then error("Invalid width") end
if h < 1 then error("Invalid height") end
if d < 1 then error("Invalid depth") end
@ -353,9 +356,11 @@ glacierDCProvider(function (pkg, pid, sendSig)
settings["scr.w." .. ma] = w
settings["scr.h." .. ma] = h
settings["scr.d." .. ma] = d
settings["scr.t." .. ma] = t
sRattle("scr.w." .. ma, w)
sRattle("scr.h." .. ma, h)
sRattle("scr.d." .. ma, d)
sRattle("scr.t." .. ma, t)
pcall(saveSettings)
end,
forceRescan = rescanDevs,

View File

@ -86,7 +86,8 @@ return {
"libs"
},
files = {
"libs/sys-secpolicy.lua"
"libs/sys-secpolicy.lua",
"libs/sys-criticals.lua"
}
},
["neo-coreapps"] = {
@ -100,7 +101,7 @@ return {
},
files = {
"apps/app-textedit.lua",
"apps/app-pass.lua",
"apps/app-control.lua",
"apps/app-taskmgr.lua"
}
},

View File

@ -9,6 +9,7 @@
-- drag(window, update, x, y, button)
-- drop(window, update, x, y, button)
-- scroll(window, update, x, y, button)
-- clipboard(window, update, contents)
-- get(window, x, y, bg, fg, selected) -> r,g,b (REQUIRED)
-- REMINDER:
-- 03
@ -82,7 +83,89 @@ end
local function packRGB(r, g, b)
return (r * 65536) + (g * 256) + b
end
-- span is a NeoUX-like span function (x, y, str, bg, fg)
-- x, y are character-cell start coordinates for this.
-- w is character-cell count.
-- colour is nil to disable colour,
-- otherwise the colour-change threshold (best 0)
-- get is a function r,g,b = get(xo, yo)
-- NOTE: xo/yo are 0-based!
local function calcLine(x, y, w, span, get, colour)
local str = ""
local bgR = 0
local bgG = 0
local bgB = 0
local fgR = 255
local fgG = 255
local fgB = 255
local bg = 0
local fg = 0xFFFFFF
local ca = 0
for p = 1, w do
local i = 0x2800
local xb = (p - 1) * 2
local dot0R, dot0G, dot0B = get(xb + 0, 0)
local dot1R, dot1G, dot1B = get(xb + 0, 1)
local dot2R, dot2G, dot2B = get(xb + 0, 2)
local dot3R, dot3G, dot3B = get(xb + 1, 0)
local dot4R, dot4G, dot4B = get(xb + 1, 1)
local dot5R, dot5G, dot5B = get(xb + 1, 2)
local dot6R, dot6G, dot6B = get(xb + 0, 3)
local dot7R, dot7G, dot7B = get(xb + 1, 3)
if colour then
local obgR, obgG, obgB = colourize(nil,
{dot0R, dot0G, dot0B},
{dot1R, dot1G, dot1B},
{dot2R, dot2G, dot2B},
{dot3R, dot3G, dot3B},
{dot4R, dot4G, dot4B},
{dot5R, dot5G, dot5B},
{dot6R, dot6G, dot6B},
{dot7R, dot7G, dot7B}
)
local ofgR, ofgG, ofgB = colourize({obgR, obgG, obgB},
{dot0R, dot0G, dot0B},
{dot1R, dot1G, dot1B},
{dot2R, dot2G, dot2B},
{dot3R, dot3G, dot3B},
{dot4R, dot4G, dot4B},
{dot5R, dot5G, dot5B},
{dot6R, dot6G, dot6B},
{dot7R, dot7G, dot7B}
)
if ((dotDist(obgR, obgG, obgB, bgR, bgG, bgB) > colour) and
(dotDist(obgR, obgG, obgB, fgR, fgG, fgB) > colour)) or
((dotDist(ofgR, ofgG, ofgB, bgR, bgG, bgB) > colour) and
(dotDist(ofgR, ofgG, ofgB, fgR, fgG, fgB) > colour)) then
if ca ~= 0 then
span(x, y, str, bg, fg)
str = ""
end
x = x + ca
ca = 0
bg = packRGB(obgR, obgG, obgB)
fg = packRGB(ofgR, ofgG, ofgB)
bgR, bgG, bgB = obgR, obgG, obgB
fgR, fgG, fgB = ofgR, ofgG, ofgB
end
end
i = i + dotGet(1, dot0R, dot0G, dot0B, bgR, bgG, bgB, fgR, fgG, fgB, true, colour)
i = i + dotGet(2, dot1R, dot1G, dot1B, bgR, bgG, bgB, fgR, fgG, fgB, false, colour)
i = i + dotGet(4, dot2R, dot2G, dot2B, bgR, bgG, bgB, fgR, fgG, fgB, true, colour)
i = i + dotGet(8, dot3R, dot3G, dot3B, bgR, bgG, bgB, fgR, fgG, fgB, false, colour)
i = i + dotGet(16, dot4R, dot4G, dot4B, bgR, bgG, bgB, fgR, fgG, fgB, true, colour)
i = i + dotGet(32, dot5R, dot5G, dot5B, bgR, bgG, bgB, fgR, fgG, fgB, false, colour)
i = i + dotGet(64, dot6R, dot6G, dot6B, bgR, bgG, bgB, fgR, fgG, fgB, false, colour)
i = i + dotGet(128, dot7R, dot7G, dot7B, bgR, bgG, bgB, fgR, fgG, fgB, true, colour)
str = str .. unicode.char(i)
ca = ca + 1
end
if str ~= "" then
span(x, y, str, bg, fg)
end
end
heldRef = neo.wrapMeta({
calcLine = calcLine,
new = function (x, y, w, h, cbs, colour)
local control
control = {
@ -92,83 +175,16 @@ heldRef = neo.wrapMeta({
h = h,
selectable = cbs.selectable,
key = cbs.key,
clipboard = cbs.clipboard,
touch = cbs.touch and cTransform(cbs.touch),
drag = cbs.drag and cTransform(cbs.drag),
drop = cbs.drop and cTransform(cbs.drop),
scroll = cbs.scroll and cTransform(cbs.scroll),
line = function (window, x, y, iy, bg, fg, selected)
local colour = (window.getDepth() > 1) and colour
local str = ""
local bgR = 0
local bgG = 0
local bgB = 0
local fgR = 255
local fgG = 255
local fgB = 255
bg = 0
fg = 0xFFFFFF
local ca = 0
for p = 1, control.w do
local i = 0x2800
local xb = (p * 2) - 1
local yb = (iy * 4) - 3
local dot0R, dot0G, dot0B = cbs.get(window, xb, yb, bg, fg, selected, colour)
local dot1R, dot1G, dot1B = cbs.get(window, xb, yb + 1, bg, fg, selected, colour)
local dot2R, dot2G, dot2B = cbs.get(window, xb, yb + 2, bg, fg, selected, colour)
local dot3R, dot3G, dot3B = cbs.get(window, xb + 1, yb, bg, fg, selected, colour)
local dot4R, dot4G, dot4B = cbs.get(window, xb + 1, yb + 1, bg, fg, selected, colour)
local dot5R, dot5G, dot5B = cbs.get(window, xb + 1, yb + 2, bg, fg, selected, colour)
local dot6R, dot6G, dot6B = cbs.get(window, xb, yb + 3, bg, fg, selected, colour)
local dot7R, dot7G, dot7B = cbs.get(window, xb + 1, yb + 3, bg, fg, selected, colour)
if colour then
local obgR, obgG, obgB = colourize(nil,
{dot0R, dot0G, dot0B},
{dot1R, dot1G, dot1B},
{dot2R, dot2G, dot2B},
{dot3R, dot3G, dot3B},
{dot4R, dot4G, dot4B},
{dot5R, dot5G, dot5B},
{dot6R, dot6G, dot6B},
{dot7R, dot7G, dot7B}
)
local ofgR, ofgG, ofgB = colourize({obgR, obgG, obgB},
{dot0R, dot0G, dot0B},
{dot1R, dot1G, dot1B},
{dot2R, dot2G, dot2B},
{dot3R, dot3G, dot3B},
{dot4R, dot4G, dot4B},
{dot5R, dot5G, dot5B},
{dot6R, dot6G, dot6B},
{dot7R, dot7G, dot7B}
)
if ((dotDist(obgR, obgG, obgB, bgR, bgG, bgB) > colour) and
(dotDist(obgR, obgG, obgB, fgR, fgG, fgB) > colour)) or
((dotDist(ofgR, ofgG, ofgB, bgR, bgG, bgB) > colour) and
(dotDist(ofgR, ofgG, ofgB, fgR, fgG, fgB) > colour)) then
if ca ~= 0 then
window.span(x, y, str, bg, fg)
str = ""
end
x = x + ca
ca = 0
bg = packRGB(obgR, obgG, obgB)
fg = packRGB(ofgR, ofgG, ofgB)
bgR, bgG, bgB = obgR, obgG, obgB
fgR, fgG, fgB = ofgR, ofgG, ofgB
end
end
i = i + dotGet(1, dot0R, dot0G, dot0B, bgR, bgG, bgB, fgR, fgG, fgB, true, colour)
i = i + dotGet(2, dot1R, dot1G, dot1B, bgR, bgG, bgB, fgR, fgG, fgB, false, colour)
i = i + dotGet(4, dot2R, dot2G, dot2B, bgR, bgG, bgB, fgR, fgG, fgB, true, colour)
i = i + dotGet(8, dot3R, dot3G, dot3B, bgR, bgG, bgB, fgR, fgG, fgB, false, colour)
i = i + dotGet(16, dot4R, dot4G, dot4B, bgR, bgG, bgB, fgR, fgG, fgB, true, colour)
i = i + dotGet(32, dot5R, dot5G, dot5B, bgR, bgG, bgB, fgR, fgG, fgB, false, colour)
i = i + dotGet(64, dot6R, dot6G, dot6B, bgR, bgG, bgB, fgR, fgG, fgB, false, colour)
i = i + dotGet(128, dot7R, dot7G, dot7B, bgR, bgG, bgB, fgR, fgG, fgB, true, colour)
str = str .. unicode.char(i)
ca = ca + 1
end
window.span(x, y, str, bg, fg)
local colour = ((window.getDepth() <= 1) or nil) and colour
calcLine(x, y, control.w, window.span, function (xb, yb)
return cbs.get(window, xb + 1, yb + (iy * 4) - 3, bg, fg, selected, colour)
end, colour)
end,
}
return control

View File

@ -12,6 +12,7 @@
-- drag(window, update, x, y, xI, yI, button)
-- drop(window, update, x, y, xI, yI, button)
-- scroll(window, update, x, y, xI, yI, amount)
-- clipboard(window, update, contents)
-- Global forces reference. Otherwise, nasty duplication happens.
newNeoux = function (event, neo)
@ -102,9 +103,10 @@ newNeoux = function (event, neo)
local k = #windows + 1
table.insert(windows, windowCore)
pushWindowToEverest(k)
window.reset = function (w, h, cb)
-- API convenience: args compatible with .create
window.reset = function (nw, nh, _, cb)
callback = cb
if mw or nh then
if nw or nh then
windowCore[2] = nw
windowCore[3] = nh
end
@ -210,11 +212,7 @@ newNeoux = function (event, neo)
return {neoux.pad(text, w)}
end
-- UI FRAMEWORK --
neoux.tcwindow = function (w, h, controls, closing, bg, fg)
local selIndex = #controls
if #controls == 0 then
selIndex = 1
end
neoux.tcwindow = function (w, h, controls, closing, bg, fg, selIndex)
local function rotateSelIndex()
local original = selIndex
while true do
@ -232,7 +230,13 @@ newNeoux = function (event, neo)
end
end
end
rotateSelIndex()
if not selIndex then
selIndex = #controls
if #controls == 0 then
selIndex = 1
end
rotateSelIndex()
end
local function moveIndex(vertical, negative)
if not controls[selIndex] then return end
local currentMA, currentOA = controls[selIndex].y, controls[selIndex].x
@ -374,6 +378,12 @@ newNeoux = function (event, neo)
controls[selIndex].key(window, function () doZone(window, controls[selIndex]) end, a, b, c)
end
end
elseif ev == "clipboard" then
if controls[selIndex] then
if controls[selIndex].clipboard then
controls[selIndex].clipboard(window, function () doZone(window, controls[selIndex]) end, a)
end
end
elseif ev == "line" then
doLine(window, a)
elseif ev == "close" then