mirror of
https://github.com/20kdc/OC-KittenOS.git
synced 2024-11-23 10:58:06 +11:00
Fix a bug that's apparently been around since multimonitor-support, and optimize some stuff
Also, store an old installer copy for reference
This commit is contained in:
parent
87932ab26c
commit
d8c4378ec1
@ -13,7 +13,7 @@ end
|
||||
local lines = {
|
||||
"Neolithic: Text Editor",
|
||||
"Keymap " .. unicode.getKeymap() .. ", to correct, type",
|
||||
"\"A Cruel Jump's Kinesis: DVSQuest\"",
|
||||
" the alphabet in capitals.",
|
||||
"Then, restart the text editor.",
|
||||
"^" .. mappingFinal[1] .. ", ^" .. mappingFinal[2] .. ", ^" .. mappingFinal[3] .. ": Load, Save, New",
|
||||
"^" .. mappingFinal[4] .. ", ^" .. mappingFinal[5] .. ", ^" .. mappingFinal[6] .. ": Copy, Paste, Delete Line",
|
||||
@ -54,6 +54,8 @@ local sW, sH = 37, #lines + 2
|
||||
local window = neo.requestAccess("x.neo.pub.window")(sW, sH)
|
||||
local flush
|
||||
|
||||
local screenCache = {}
|
||||
|
||||
local function splitCur()
|
||||
local s = lines[cursorY]
|
||||
local st = unicode.sub(s, 1, cursorX - 1)
|
||||
@ -143,11 +145,9 @@ local function getline(y)
|
||||
|
||||
-- rX is difficult!
|
||||
local rX = 1
|
||||
local Xthold = math.floor(sW / 2)
|
||||
local Xthold = math.max(1, math.floor(sW / 2) - 1)
|
||||
local _, cursorXP = unicode.safeTextFormat(lines[cursorY], cursorX)
|
||||
if cursorXP > Xthold then
|
||||
rX = rX + (cursorXP - Xthold)
|
||||
end
|
||||
rX = (math.max(0, math.floor(cursorXP / Xthold) - 1) * Xthold) + 1
|
||||
local line = lines[rY]
|
||||
if not line then
|
||||
return ("¬"):rep(sW)
|
||||
@ -378,9 +378,14 @@ local function ev_clipboard(t)
|
||||
end
|
||||
|
||||
flush = function ()
|
||||
local newCache = {}
|
||||
for i = 1, sH do
|
||||
window.span(1, i, getline(i), 0xFFFFFF, 0)
|
||||
newCache[i] = getline(i)
|
||||
if newCache[i] ~= screenCache[i] then
|
||||
window.span(1, i, newCache[i], 0xFFFFFF, 0)
|
||||
end
|
||||
end
|
||||
screenCache = newCache
|
||||
end
|
||||
local flash
|
||||
flash = function ()
|
||||
@ -388,7 +393,9 @@ flash = function ()
|
||||
-- reverse:
|
||||
--local rY = (y + cursorY) - math.ceil(sH / 2)
|
||||
local csY = math.ceil(sH / 2)
|
||||
window.span(1, csY, getline(csY), 0xFFFFFF, 0)
|
||||
local l = getline(csY)
|
||||
screenCache[csY] = l
|
||||
window.span(1, csY, l, 0xFFFFFF, 0)
|
||||
event.runAt(os.uptime() + 0.5, flash)
|
||||
end
|
||||
event.runAt(os.uptime() + 0.5, flash)
|
||||
|
@ -39,6 +39,8 @@ local screens = neo.requireAccess("x.neo.sys.screens", "access to screens")
|
||||
neo.requestAccess("s.h.clipboard")
|
||||
neo.requestAccess("s.h.touch")
|
||||
neo.requestAccess("s.h.drag")
|
||||
neo.requestAccess("s.h.drop")
|
||||
neo.requestAccess("s.h.scroll")
|
||||
neo.requestAccess("s.h.key_up")
|
||||
neo.requestAccess("s.h.key_down")
|
||||
|
||||
@ -99,6 +101,11 @@ local function surfaceAt(monitor, x, y)
|
||||
end
|
||||
end
|
||||
|
||||
-- Always use the first sometime before the second
|
||||
local function monitorResetBF(m)
|
||||
m[5] = -1
|
||||
m[6] = -1
|
||||
end
|
||||
local function monitorGPUColours(m, cb, bg, fg)
|
||||
local nbg = m[5]
|
||||
local nfg = m[6]
|
||||
@ -134,6 +141,7 @@ local function updateRegion(monitorId, x, y, w, h, surfaceSpanCache)
|
||||
local m = monitors[monitorId]
|
||||
local mg = m[1]()
|
||||
if not mg then return end
|
||||
monitorResetBF(m)
|
||||
-- The input region is the one that makes SENSE.
|
||||
-- Considering WC handling, that's not an option.
|
||||
-- WCHAX: start
|
||||
@ -208,8 +216,6 @@ local function reconcileAll()
|
||||
if mon then
|
||||
v[3], v[4] = mon.getResolution()
|
||||
end
|
||||
v[5] = -1
|
||||
v[6] = -1
|
||||
updateRegion(k, 1, 1, v[3], v[4], {})
|
||||
end
|
||||
updateStatus()
|
||||
@ -237,6 +243,11 @@ local function moveSurface(surface, m, x, y, w, h)
|
||||
cb.copy(ox, oy, w, h, x - ox, y - oy)
|
||||
end
|
||||
end
|
||||
--because OC's widechar support sucks, comment out this perf. opt.
|
||||
--if surfaces[1] == surface then
|
||||
-- updateRegion(om, ox, oy, ow, oh, cache)
|
||||
-- return
|
||||
--end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -260,6 +271,7 @@ local function handleSpan(target, x, y, text, bg, fg)
|
||||
local m = monitors[target[1]]
|
||||
local cb = m[1]()
|
||||
if not cb then return end
|
||||
monitorResetBF(m)
|
||||
-- It is assumed basic type checks were handled earlier.
|
||||
if y < 1 then return end
|
||||
if y > target[5] then return end
|
||||
@ -280,22 +292,8 @@ local function handleSpan(target, x, y, text, bg, fg)
|
||||
local buildingSegmentE = nil
|
||||
local function submitSegment()
|
||||
if buildingSegment then
|
||||
base = unicode.sub(text, buildingSegment, buildingSegmentE - 1)
|
||||
local ext = unicode.sub(text, buildingSegmentE, buildingSegmentE)
|
||||
if unicode.charWidth(ext) == 1 then
|
||||
base = base .. ext
|
||||
else
|
||||
-- While the GPU may or may not be able to display "half a character",
|
||||
-- getting it to do so reliably is another matter.
|
||||
-- In my experience it always leads to drawing errors much worse than if the code was left alone.
|
||||
-- If your language uses wide chars and you are affected by a window's positioning...
|
||||
-- ... may I ask how, exactly, you intend me to fix it?
|
||||
-- My current theory is that for cases where the segment is >= 2 chars (so we have scratchpad),
|
||||
-- the GPU might be tricked via a copy.
|
||||
-- Then the rest of the draw can proceed as normal,
|
||||
-- with the offending char removed.
|
||||
base = base .. " "
|
||||
end
|
||||
base = unicode.sub(text, buildingSegment, buildingSegmentE)
|
||||
-- rely on undoSafeTextFormat for this transform now
|
||||
monitorGPUColours(m, cb, bg, fg)
|
||||
cb.set(buildingSegmentWX, buildingSegmentWY, unicode.undoSafeTextFormat(base))
|
||||
buildingSegment = nil
|
||||
@ -388,9 +386,7 @@ everestProvider(function (pkg, pid, sendSig)
|
||||
specialDragHandler = function (x, y)
|
||||
local ofsX, ofsY = math.floor(x) - math.floor(a), math.floor(y) - math.floor(b)
|
||||
if (ofsX == 0) and (ofsY == 0) then return end
|
||||
local pX, pY = ofsSurface(surf, ofsX, ofsY)
|
||||
--a = a + pX
|
||||
--b = b + pY
|
||||
ofsSurface(surf, ofsX, ofsY)
|
||||
end
|
||||
return
|
||||
end
|
||||
@ -403,11 +399,7 @@ everestProvider(function (pkg, pid, sendSig)
|
||||
end
|
||||
b = b - 1
|
||||
end
|
||||
if ev == "scroll" then
|
||||
b = b - 1
|
||||
end
|
||||
if ev == "drop" then
|
||||
specialDragHandler = nil
|
||||
if ev == "scroll" or ev == "drop" then
|
||||
b = b - 1
|
||||
end
|
||||
if ev == "line" then
|
||||
|
@ -76,6 +76,8 @@ end
|
||||
local monitorPool = {}
|
||||
-- [screenAddr] = {gpu, claimedLoseCallback}
|
||||
local monitorClaims = {}
|
||||
-- [gpuAddr] = monitorAddr
|
||||
local currentGPUBinding = {}
|
||||
|
||||
local function announceFreeMonitor(address, except)
|
||||
for k, v in pairs(targsRD) do
|
||||
@ -89,7 +91,7 @@ local function getGPU(monitor)
|
||||
local bestG
|
||||
local bestD = 0
|
||||
for v in gpus.list() do
|
||||
v.bind(monitor.address)
|
||||
v.bind(monitor.address, false)
|
||||
local d = v.maxDepth()
|
||||
if d > bestD then
|
||||
bestG = v
|
||||
@ -121,6 +123,7 @@ local function getMonitorSettings(a)
|
||||
return w, h, d
|
||||
end
|
||||
local function setupMonitor(gpu, monitor)
|
||||
gpu.bind(monitor.address, false)
|
||||
local maxW, maxH = gpu.maxResolution()
|
||||
local maxD = gpu.maxDepth()
|
||||
local w, h, d = getMonitorSettings(monitor.address)
|
||||
@ -227,6 +230,7 @@ donkonitRDProvider(function (pkg, pid, sendSig)
|
||||
if gpu then
|
||||
setupMonitor(gpu, v)
|
||||
gpu = gpu.address
|
||||
currentGPUBinding[gpu] = address
|
||||
local disclaimer = function (wasDevLoss)
|
||||
-- we lost it
|
||||
monitorClaims[address] = nil
|
||||
@ -244,12 +248,14 @@ donkonitRDProvider(function (pkg, pid, sendSig)
|
||||
return function ()
|
||||
for v in gpus.list() do
|
||||
if v.address == gpu then
|
||||
local _, v2 = v.bind(address)
|
||||
if not v2 then
|
||||
return v
|
||||
else
|
||||
return
|
||||
if currentGPUBinding[gpu] ~= address then
|
||||
local _, v2 = v.bind(address, false)
|
||||
if v2 then
|
||||
return
|
||||
end
|
||||
end
|
||||
currentGPUBinding[gpu] = address
|
||||
return v
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -270,6 +276,7 @@ end)
|
||||
loadSettings()
|
||||
local function rescanDevs()
|
||||
monitorPool = {}
|
||||
currentGPUBinding = {}
|
||||
local hasGPU = gpus.list()()
|
||||
for k, v in pairs(monitorClaims) do
|
||||
v[2](true)
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
local callerPkg, callerPid, callerScr = ...
|
||||
|
||||
local gpu, screen = nil, nil
|
||||
local gpuG, screen = nil, nil
|
||||
local shutdownEmergency = neo.requestAccess("k.computer").shutdown
|
||||
neo.requestAccess("s.h.key_down")
|
||||
|
||||
@ -30,14 +30,19 @@ local function shutdown(reboot)
|
||||
end
|
||||
end
|
||||
|
||||
local function basicDraw()
|
||||
local function rstfbDraw(gpu)
|
||||
gpu.setBackground(0xFFFFFF)
|
||||
gpu.setForeground(0x000000)
|
||||
end
|
||||
|
||||
local function basicDraw(gpu)
|
||||
scrW, scrH = gpu.getResolution()
|
||||
gpu.fill(1, 1, scrW, scrH, " ")
|
||||
gpu.set(2, 2, "KittenOS NEO")
|
||||
end
|
||||
|
||||
local function advDraw()
|
||||
basicDraw()
|
||||
local function advDraw(gpu)
|
||||
basicDraw(gpu)
|
||||
local usage = math.floor((os.totalMemory() - os.freeMemory()) / 1024)
|
||||
gpu.set(2, 3, "RAM Usage: " .. usage .. "K / " .. math.floor(os.totalMemory() / 1024) .. "K")
|
||||
for i = 1, #warnings do
|
||||
@ -49,9 +54,9 @@ end
|
||||
local performDisclaim = nil
|
||||
|
||||
local function retrieveNssMonitor(nss)
|
||||
gpu = nil
|
||||
gpuG = nil
|
||||
local subpool = {}
|
||||
while not gpu do
|
||||
while not gpuG do
|
||||
if performDisclaim then
|
||||
performDisclaim()
|
||||
end
|
||||
@ -94,19 +99,20 @@ local function retrieveNssMonitor(nss)
|
||||
end
|
||||
|
||||
if not subpool[1] then error("Unable to claim any monitor.") end
|
||||
gpu = subpool[1][1]() -- BAD
|
||||
gpuG = subpool[1][1]
|
||||
screen = subpool[1][2]
|
||||
end
|
||||
-- done with search
|
||||
local gpu = gpuG()
|
||||
scrW, scrH = gpu.getResolution()
|
||||
gpu.setBackground(0xFFFFFF)
|
||||
gpu.setForeground(0x000000)
|
||||
rstfbDraw(gpu)
|
||||
gpu.fill(1, 1, scrW, scrH, " ")
|
||||
performDisclaim = function ()
|
||||
for _, v in ipairs(subpool) do
|
||||
nss.disclaim(v[2])
|
||||
end
|
||||
end
|
||||
return gpu
|
||||
end
|
||||
|
||||
local function sleep(t)
|
||||
@ -120,10 +126,8 @@ local function sleep(t)
|
||||
-- This implies we have and can use nss, but check anyway
|
||||
local nss = neo.requestAccess("x.neo.sys.screens")
|
||||
if nss then
|
||||
retrieveNssMonitor(nss)
|
||||
gpu.setBackground(0xFFFFFF)
|
||||
gpu.setForeground(0x000000)
|
||||
basicDraw()
|
||||
local gpu = retrieveNssMonitor(nss)
|
||||
basicDraw(gpu)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -146,7 +150,9 @@ local function finalPrompt()
|
||||
warnings[2] = "ENTER to select..."
|
||||
-- The actual main prompt loop
|
||||
while waiting do
|
||||
advDraw()
|
||||
local gpu = gpuG()
|
||||
rstfbDraw(gpu)
|
||||
advDraw(gpu)
|
||||
local entry = ""
|
||||
local entry2 = ""
|
||||
local active = true
|
||||
@ -164,7 +170,9 @@ local function finalPrompt()
|
||||
if entry == password then
|
||||
waiting = false
|
||||
else
|
||||
advDraw()
|
||||
local gpu = gpuG()
|
||||
rstfbDraw(gpu)
|
||||
advDraw(gpu)
|
||||
sleep(1)
|
||||
end
|
||||
active = false
|
||||
@ -185,7 +193,9 @@ local function finalPrompt()
|
||||
return shButton
|
||||
end, function (key)
|
||||
if key == 13 then
|
||||
basicDraw()
|
||||
local gpu = gpuG()
|
||||
rstfbDraw(gpu)
|
||||
basicDraw(gpu)
|
||||
gpu.set(2, 4, "Shutting down...")
|
||||
shutdown(false)
|
||||
end
|
||||
@ -194,7 +204,9 @@ local function finalPrompt()
|
||||
return rbButton
|
||||
end, function (key)
|
||||
if key == 13 then
|
||||
basicDraw()
|
||||
local gpu = gpuG()
|
||||
rstfbDraw(gpu)
|
||||
basicDraw(gpu)
|
||||
gpu.set(2, 4, "Rebooting...")
|
||||
shutdown(true)
|
||||
end
|
||||
@ -203,17 +215,22 @@ local function finalPrompt()
|
||||
return smButton
|
||||
end, function (key)
|
||||
if key == 13 then
|
||||
basicDraw()
|
||||
local gpu = gpuG()
|
||||
rstfbDraw(gpu)
|
||||
basicDraw(gpu)
|
||||
gpu.set(2, 4, "Login to activate Safe Mode.")
|
||||
sleep(1)
|
||||
gpu = gpuG()
|
||||
safeModeActive = true
|
||||
advDraw()
|
||||
rstfbDraw(gpu)
|
||||
advDraw(gpu)
|
||||
end
|
||||
end, 4 + unicode.len(shButton) + unicode.len(rbButton), scrH - 1, unicode.len(smButton)},
|
||||
pw,
|
||||
}
|
||||
local control = #controls
|
||||
while active do
|
||||
local gpu = gpuG()
|
||||
for k, v in ipairs(controls) do
|
||||
if k == control then
|
||||
gpu.setBackground(0x000000)
|
||||
@ -225,9 +242,6 @@ local function finalPrompt()
|
||||
gpu.fill(v[3], v[4], v[5], 1, " ")
|
||||
gpu.set(v[3], v[4], v[1]())
|
||||
end
|
||||
-- Reset to normal
|
||||
gpu.setBackground(0xFFFFFF)
|
||||
gpu.setForeground(0x000000)
|
||||
-- event handling...
|
||||
local sig = {coroutine.yield()}
|
||||
if sig[1] == "x.neo.sys.screens" then
|
||||
@ -245,10 +259,14 @@ local function finalPrompt()
|
||||
end
|
||||
end
|
||||
end
|
||||
advDraw()
|
||||
local gpu = gpuG()
|
||||
rstfbDraw(gpu)
|
||||
advDraw(gpu)
|
||||
return safeModeActive
|
||||
end
|
||||
local function postPrompt()
|
||||
local gpu = gpuG()
|
||||
rstfbDraw(gpu)
|
||||
-- Begin to finish login, or fail
|
||||
local everests = neo.requestAccess("x.neo.sys.session")
|
||||
if everests then
|
||||
@ -258,7 +276,7 @@ local function postPrompt()
|
||||
table.insert(warnings, tostring(e))
|
||||
else
|
||||
warnings = {"Transferring to Everest..."}
|
||||
advDraw()
|
||||
advDraw(gpu)
|
||||
if performDisclaim then
|
||||
performDisclaim()
|
||||
-- Give Everest time (this isn't perceptible, and is really just a safety measure)
|
||||
@ -269,7 +287,7 @@ local function postPrompt()
|
||||
else
|
||||
table.insert(warnings, "Couldn't communicate with Everest...")
|
||||
end
|
||||
advDraw()
|
||||
advDraw(gpu)
|
||||
sleep(1)
|
||||
shutdown(true)
|
||||
end
|
||||
@ -280,12 +298,13 @@ local function initializeSystem()
|
||||
-- Note that we should try to keep going with this if there's no reason to do otherwise.
|
||||
local gpuAc = neo.requestAccess("c.gpu")
|
||||
local screenAc = neo.requestAccess("c.screen")
|
||||
local gpu
|
||||
-- time to setup gpu/screen variables!
|
||||
if gpuAc and screenAc then
|
||||
local scrBestWHD = 0
|
||||
for s in screenAc.list() do
|
||||
for g in gpuAc.list() do
|
||||
g.bind(s.address)
|
||||
g.bind(s.address, false)
|
||||
local w, h = g.maxResolution()
|
||||
local whd = w * h * g.maxDepth()
|
||||
if whd > scrBestWHD then
|
||||
@ -348,7 +367,7 @@ local function initializeSystem()
|
||||
else
|
||||
gpu.setBackground(0xFFFFFF)
|
||||
end
|
||||
basicDraw()
|
||||
basicDraw(gpu)
|
||||
end
|
||||
if steps[w] then
|
||||
if steps[w] == "INJECT" then
|
||||
@ -407,7 +426,9 @@ end
|
||||
-- System initialized
|
||||
if finalPrompt() then
|
||||
-- Safe Mode
|
||||
basicDraw()
|
||||
local gpu = gpuG()
|
||||
rstfbDraw(gpu)
|
||||
basicDraw(gpu)
|
||||
local nsm = neo.requestAccess("x.neo.sys.manage")
|
||||
if nsm then
|
||||
gpu.set(2, 4, "Rebooting for Safe Mode...")
|
||||
@ -420,6 +441,9 @@ if finalPrompt() then
|
||||
-- assume sysconf.lua did something very bad
|
||||
gpu.set(2, 4, "No NSM. Wiping configuration completely.")
|
||||
local fs = neo.requestAccess("c.filesystem")
|
||||
if not fs then
|
||||
gpu.set(2, 4, "Failed to get permission, you're doomed.")
|
||||
end
|
||||
fs.primary.remove("/data/sys-glacier/sysconf.lua")
|
||||
end
|
||||
-- Do not give anything a chance to alter the new configuration
|
||||
|
@ -113,61 +113,11 @@ keymaps = {
|
||||
["??-dvorak"] = {
|
||||
{19, "PYFGCRL"},
|
||||
{19, "pyfgcrl"},
|
||||
{30, "AOEUIDHTN"},
|
||||
{30, "aoeuidhtn"},
|
||||
{45, "QJKXBM"},
|
||||
{45, "qjkxbm"},
|
||||
{30, "AOEUIDHTNS"},
|
||||
{30, "aoeuidhtns"},
|
||||
{45, "QJKXBMWVZ"},
|
||||
{45, "qjkxbmwvz"},
|
||||
},
|
||||
["??-dvorak-full"] = {
|
||||
{16, "\"<>PYFGCRL"},
|
||||
{16, "',.pyfgcrl"},
|
||||
{30, "AOEUIDHTN"},
|
||||
{30, "aoeuidhtn"},
|
||||
{44, ":QJKXBM"},
|
||||
{44, ";qjkxbm"},
|
||||
},
|
||||
["cz-qwertz"] = {
|
||||
{2, "+ěščřžýáíé="}, -- The last letter is a *compose key*. #WTF
|
||||
{2, "1234567890%"},
|
||||
{15, "\tQWERTZUIOP/("},
|
||||
{15, "\tqwertzuiopú)"},
|
||||
{30, "ASDFGHJKL\"!'"},
|
||||
{30, "asdfghjklů§"},
|
||||
{44, "YXCVBNM?:_"},
|
||||
{44, "yxcvbnm,.-"},
|
||||
},
|
||||
["de-qwertz"] = {
|
||||
{2, "1234567890ß"}, -- another one?
|
||||
{2, "!\"§$%&/()=?"},
|
||||
{15, "\tQWERTZUIOPÜ*"},
|
||||
{15, "\tqwertzuiopü+"},
|
||||
{30, "ASDFGHJKLÖÄ"},
|
||||
{30, "asdfghjklÖÄ"},
|
||||
{44, "YXCVBNM;:_"},
|
||||
{44, "yxcvbnm,.-"},
|
||||
},
|
||||
["uk-qwerty"] = {
|
||||
{41, "`"}, {41, "¬"},
|
||||
{2, "1234567890-="},
|
||||
{2, "!\"£$%^&*()_+"},
|
||||
{15, "\tQWERTYUIOP{}"},
|
||||
{15, "\tqwertyuiop[]"},
|
||||
{30, "ASDFGHJKL:@"},
|
||||
{30, "asdfghjkl;'"},
|
||||
{44, "ZXCVBNM<>?"},
|
||||
{44, "zxcvbnm,./"},
|
||||
},
|
||||
["us-qwerty"] = {
|
||||
{41, "`"}, {41, "~"},
|
||||
{2, "1234567890-="},
|
||||
{2, "!@#$%^&*()_+"},
|
||||
{15, "\tQWERTYUIOP{}\r"},
|
||||
{15, "\tqwertyuiop[]\r"},
|
||||
{30, "ASDFGHJKL\"|"},
|
||||
{30, "asdfghjkl'\\"},
|
||||
{44, "ZXCVBNM<>?"},
|
||||
{44, "zxcvbnm,./"},
|
||||
}
|
||||
}
|
||||
local unknownKeymapContains = {}
|
||||
currentKeymap = "unknown"
|
||||
@ -241,12 +191,22 @@ unicode.keymap = function (text)
|
||||
local km = unicode.getKeymap()
|
||||
local rtext = ""
|
||||
local codes = {}
|
||||
local notQ = false
|
||||
for i = 1, unicode.len(text) do
|
||||
local ch = unicode.sub(text, i, i)
|
||||
local okc = unicode.getKCByCh(ch, "uk-qwerty") or 0
|
||||
rtext = rtext .. (unicode.getChByKC(okc, currentKeymap) or unicode.getChByKC(okc, "unknown") or ch)
|
||||
local okc = unicode.getKCByCh(ch, "??-qwerty") or 0
|
||||
local ch2 = unicode.getChByKC(okc, currentKeymap) or unicode.getChByKC(okc, "unknown")
|
||||
if not ch2 then
|
||||
ch2 = "?"
|
||||
else
|
||||
notQ = true
|
||||
end
|
||||
rtext = rtext .. ch2
|
||||
codes[i] = unicode.getKCByCh(ch, currentKeymap) or unicode.getKCByCh(ch, "unknown")
|
||||
end
|
||||
if not notQ then
|
||||
rtext = text
|
||||
end
|
||||
return rtext, codes
|
||||
end
|
||||
|
||||
|
609
preSH-Ancient-Est-2-10-2017.lua
Normal file
609
preSH-Ancient-Est-2-10-2017.lua
Normal file
@ -0,0 +1,609 @@
|
||||
-- KOSNEO inst.
|
||||
-- This is released into the public domain.
|
||||
-- No warranty is provided, implied or otherwise.
|
||||
|
||||
-- PADPADPADPADPADPADPADPAD
|
||||
|
||||
local C, O, G, D = component, computer
|
||||
local sAddr = C.list("screen", true)()
|
||||
if sAddr then
|
||||
G = C.list("gpu", true)()
|
||||
if G then
|
||||
G = C.proxy(G)
|
||||
G.bind(sAddr)
|
||||
G.setForeground(0xFFFFFF)
|
||||
G.setBackground(0x000000)
|
||||
G.setResolution(50, 5)
|
||||
G.setDepth(1)
|
||||
G.fill(1, 1, 50, 5, " ")
|
||||
G.setBackground(0xFFFFFF)
|
||||
G.setForeground(0x000000)
|
||||
G.fill(1, 2, 50, 1, " ")
|
||||
G.set(2, 2, "KittenOS NEO Installer")
|
||||
end
|
||||
end
|
||||
|
||||
D = C.proxy(O.getBootAddress())
|
||||
|
||||
local file = nil
|
||||
local fileName = "Starting..."
|
||||
local fileSizeRm = 0
|
||||
local ws = 0
|
||||
|
||||
local convoct
|
||||
convoct = function (oct)
|
||||
local v = oct:byte(#oct) - 0x30
|
||||
if #oct > 1 then
|
||||
return (convoct(oct:sub(1, #oct - 1)) * 8) + v
|
||||
end
|
||||
return v
|
||||
end
|
||||
local function sectorCore(sector)
|
||||
if ws > 0 then
|
||||
ws = ws - 1
|
||||
return
|
||||
end
|
||||
if file then
|
||||
local takeaway = math.min(512, fileSizeRm)
|
||||
D.write(file, sector:sub(1, takeaway))
|
||||
fileSizeRm = fileSizeRm - takeaway
|
||||
if fileSizeRm == 0 then
|
||||
D.close(file)
|
||||
file = nil
|
||||
end
|
||||
else
|
||||
local name = sector:sub(1, 100):gsub("\x00", "")
|
||||
local sz = convoct(sector:sub(125, 135))
|
||||
if name:sub(1, 5) ~= "code/" then
|
||||
ws = math.ceil(sz / 512)
|
||||
else
|
||||
if name:sub(#name, #name) == "/" then
|
||||
ws = math.ceil(sz / 512)
|
||||
D.makeDirectory(name:sub(6))
|
||||
else
|
||||
fileName = name:sub(6)
|
||||
file = D.open(fileName, "wb")
|
||||
fileSizeRm = sz
|
||||
if file then
|
||||
if fileSizeRm == 0 then
|
||||
D.close(file)
|
||||
file = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local dieCB = function () end
|
||||
|
||||
local sectorNum = 0
|
||||
local sectorCount = 0
|
||||
|
||||
local function sector(n)
|
||||
sectorCore(n)
|
||||
sectorNum = sectorNum + 1
|
||||
if G then
|
||||
local a = sectorNum / sectorCount
|
||||
G.fill(1, 2, 50, 1, " ")
|
||||
G.set(2, 2, "KittenOS NEO Installer : " .. fileName)
|
||||
G.setForeground(0xFFFFFF)
|
||||
G.setBackground(0x000000)
|
||||
G.fill(2, 4, 48, 1, " ")
|
||||
G.setBackground(0xFFFFFF)
|
||||
G.setForeground(0x000000)
|
||||
G.fill(2, 4, math.ceil(48 * a), 1, " ")
|
||||
end
|
||||
if sectorNum % 8 == 0 then
|
||||
O.pullSignal(0.05)
|
||||
end
|
||||
if sectorNum == sectorCount then
|
||||
dieCB()
|
||||
O.shutdown(true)
|
||||
end
|
||||
end
|
||||
|
||||
sectorCount = 260
|
||||
D.remove("init-symsear.lua")
|
||||
D.rename("init.lua", "init-symsear.lua")
|
||||
local instHandle = D.open("init-symsear.lua", "rb")
|
||||
dieCB = function ()
|
||||
D.close(instHandle)
|
||||
D.remove("init-symsear.lua")
|
||||
end
|
||||
local syms = {" ","s","e","t","a","i","\24","(","r",".","\
|
||||
","p","\"","o","c","m",", ","\1","l","n",")","d","u","\17","\9","x","-","\7","\6","\8","\4","\13","\2","\3","\5","g","\14","\21","\11"," then\
|
||||
","1","w"," ","\12","\18","\22","f","F","y",",","\20","re","b","k"," = ","\23","return "," local ","\16","v"," if ","\
|
||||
","\15","\19","\
|
||||
"," ","[","en","/","0","]","path","nction (","\
|
||||
","se","h"," =","or","S","T","le","\
|
||||
local ",")\
|
||||
","= fu","on"," == ","ne",")\
|
||||
","functio","\
|
||||
end\
|
||||
","D","{"," t","n ","oc","lo"," end\
|
||||
","\0\0\0\0\0\0\0\0\0","un"," i","W","\0\0\0\0\0\0","fu","et"," end\
|
||||
","then ","nd","ni","A","ing"," tab","loca","etting",")\
|
||||
","ct","C","P","}","\
|
||||
end\
|
||||
",")\
|
||||
","onit","= ","end\
|
||||
","\0","I","Y"," do\
|
||||
","return\
|
||||
","le.inser"," = func","= \"","al"," r"," e","in","he","nc"," e","j","donkonit","tion ()",") do\
|
||||
"," the","\
|
||||
",")\
|
||||
","ur","#","+","N","cursor",".inse",", v ","nction (w"," neo.req"," for "," then\
|
||||
","\0\0\0\0\0\0\0","nd\
|
||||
","()\
|
||||
","neo.","ath","table","l ","do","2","3",":","H"," = nil\
|
||||
","nd\
|
||||
e","hen\
|
||||
","\7local ","indowCore",")\
|
||||
end\
|
||||
","d\") end\
|
||||
"," = false","if ","pairs(","dow","string\"","ti","O","uestAcces","nd\
|
||||
if ","icode."," if","v in ","pkg, pid","000","750\0000001","end\
|
||||
e","750\0000000"," else\
|
||||
","window","end","00",".neo.sys.","neoux.tc","= {}\
|
||||
","(window, ","5","=","E","R",") end\
|
||||
"," cursor","request","ode/app"," return e","\" the","equire("," "," then",".neo.pub.","hile true"," end"," en","\0\0","B","M"," ret","for ","in ipai"," true\
|
||||
","close","code.sub","error(\"","return t","oroutine"," end\
|
||||
if","end\
|
||||
en","tion ","\", funct",":sub(","vailable"," end\
|
||||
"," l"," == \"","prima"," if type(","ryWindow","window.s"," end\
|
||||
","L","X","~","on ("," in ipair"," for _, v"," for k","\0\0\0\0\0cod","lose()\
|
||||
"," = funct","rror(\"Exp","nsurePath","s.primary","primary","buildingS","unic"," "," re","surfaces","disallowe","ackground","neoux.","ccess","selectUnk"," end\
|
||||
"," = uni","\
|
||||
end\
|
||||
"," f","7","Z","z","for k","rue\
|
||||
end\
|
||||
","ode.len("," end\
|
||||
","lse\
|
||||
",") end","end\
|
||||
"," fu",":sub(1, ","sub(1, 4)"," ","neo","the","if not "," th","tion","unknownA","end\
|
||||
","[1] == \"","= unico","Acces","\
|
||||
end\
|
||||
\
|
||||
l","n\
|
||||
","\") end\
|
||||
","de.len("," end","\" then\
|
||||
","0\0000001","urface","nd\
|
||||
","()\
|
||||
","(surfaces"," if ","\0\0\0\0\0\0\0\0","unc","urn","\
|
||||
"," end\
|
||||
"," neoux","ction","\
|
||||
end\
|
||||
","\
|
||||
","neoux","\24\0\0\0\0\0\0\0\0","\
|
||||
end"," end\
|
||||
end\
|
||||
","\
|
||||
end\
|
||||
"," if "," err","s[1] == \"","unicode."," window"," if ","ocal fun","= false","\0\0\0\0\0\0\0000","\0\0\0\0\0\0\00000","code","_, v in i","()\
|
||||
","d\
|
||||
","f ev == \""," return",", bg, fg"," end"," neoux.","\0\0\0","w.close(","\
|
||||
if ev"," i"," if not ","if kc == ",")\
|
||||
end\
|
||||
","indow","onkonit","00175","table.",", bg, fg)"," l"," end\
|
||||
",") == \"","d\
|
||||
"," return ","rn","ca","q"," tabl"," error(\"","end\
|
||||
re"," in ","hen err","nd\
|
||||
en","nd\
|
||||
","\
|
||||
end","turn ","x.neo.","ion ("," table","false","string","e.len(","d\
|
||||
"," re","1, unicod","cursorX ","local ","end\
|
||||
end\
|
||||
","cal","\" then e","nd\
|
||||
if k","ion","00644\00000"," end\
|
||||
","\
|
||||
end"," window."," e","if not","== \"",", func"," neo.",", functi","\
|
||||
end\
|
||||
end"," r","end\
|
||||
","ion (w)\
|
||||
","\
|
||||
end"," = false\
|
||||
"," ret","tu"," end\
|
||||
","f ","unction","= nil\
|
||||
","th","n\
|
||||
","6","U","_","requir","eturn\
|
||||
"," funct","eturn tr","\
|
||||
\
|
||||
local"," table.","eques","rn ",")\
|
||||
r",".insert(","ode.",")\
|
||||
end","== ","\0\0\0\0\0\0\0c","n\
|
||||
","\0\0\0\0\0","()\
|
||||
"," = nil","able.","n\
|
||||
"," = n","return","000644\0000","Access","able","etu","d\
|
||||
","\
|
||||
if ","end\
|
||||
end","nction (p","ub(1, 4) "," return "," return","lse\
|
||||
","abl","= uni","for k, ","\0\0\0\0\0\0\0\0c","cursorY","ble","bg, fg)\
|
||||
","\
|
||||
e","ind","ret","tring\"","000000"," neo","pairs","then\
|
||||
",")\
|
||||
","le.inse","loc","\
|
||||
end","n error","\
|
||||
end\
|
||||
\
|
||||
","if s[1] =","lse\
|
||||
","turn","ursor","function","neou","\0\0\0\0\0\0c","function ","\0000001","end\
|
||||
e","eo.","Access(\""," re"," lo","\
|
||||
e",")\
|
||||
end","urn ","\
|
||||
re"," end\
|
||||
e"," = f","\0\0\0\0","cal ","\0000000644\0","in ip","\
|
||||
en"," return",")\
|
||||
i","ction ","\
|
||||
end\
|
||||
","ode","equire(\"","r(\"Expect","ctio"," cursorY","if","%","4","<","G","\
|
||||
local f","\
|
||||
ret"," for ","d\
|
||||
if"," erro","true\
|
||||
end","ed\") end","hen ","nd\
|
||||
en","al ","on ","] then\
|
||||
","string\")","for _, ","unicode.l","[1] == ","true\
|
||||
","uestAc","nd\
|
||||
end\
|
||||
"," for k, "," if ev ","then\
|
||||
","\
|
||||
en",")\
|
||||
en","do\
|
||||
","e.ins",".primary"," true","coroutine","return\
|
||||
","airs(",") end\
|
||||
","nd\
|
||||
end\
|
||||
\
|
||||
","\
|
||||
return","window, ","end\
|
||||
e","end\
|
||||
end","750\0000","eturn t",", functio"," e","d\") end","en\
|
||||
","ocal","icode.len","e\
|
||||
","n\
|
||||
","w.close()"," uni","sub(","n ipairs("," for ","end\
|
||||
","ion ()","end\
|
||||
en","quest","cursorY ","eturn","unicode.s","x.neo.pub"," = neo","hen\
|
||||
","then\
|
||||
","string\") ","in ipa"," retur","indowCor"," re","750\00000"," do\
|
||||
",")\
|
||||
if "," then ret","\") end"," en","n\
|
||||
","ipairs"," then err","d\
|
||||
en","= f"," local",".neo.","\24\0\0\0\0\0\0\0","func","()\
|
||||
",")\
|
||||
en","curs","\
|
||||
loca","ode/apps","nd\
|
||||
if "," i"," = neo.r","kg, pid, ","\
|
||||
i","win","code.sub(","require","wind"," else\
|
||||
","close()"," end\
|
||||
e","\
|
||||
\
|
||||
local "," then re","\
|
||||
e",".request","wnAvailab","tion (","\
|
||||
local ","error(","\0000001750\0","n\
|
||||
","d\
|
||||
"," ","uestA","reques","end\
|
||||
end\
|
||||
\
|
||||
","ion ()\
|
||||
"," curso","then\
|
||||
","0001750","surfac",".close("," function","= neo.","if type("," loc","d\
|
||||
e","oroutine."," do\
|
||||
"," else\
|
||||
","tion ()\
|
||||
",", v in ","window.","neo.re","0000","\000000","\
|
||||
end\
|
||||
","ipairs("," ret","\"x.neo.pu","error","\
|
||||
i","\
|
||||
end","()\
|
||||
","= nil\
|
||||
","nsert(","n erro","rror(\"","nil\
|
||||
","cursorX ="," do\
|
||||
"," for","turn f","en\
|
||||
"," table.","\
|
||||
","\") end\
|
||||
","\") end\
|
||||
",".close()\
|
||||
","\
|
||||
re","d\
|
||||
e","\
|
||||
end\
|
||||
","ownAvaila","000644\00000"," false\
|
||||
","\
|
||||
re","false\
|
||||
","ion ()\
|
||||
",")\
|
||||
e","urn end\
|
||||
",")\
|
||||
if","x.neo.sys","indow, ","then\
|
||||
",")\
|
||||
if t","cti","ion ","ion (w","\" then"," = nil\
|
||||
","then","e\" then\
|
||||
"," if","on (w)\
|
||||
",") do\
|
||||
"," en","tAccess(\"","surePath"," end\
|
||||
end","\
|
||||
end\
|
||||
","e.inse"," table.i"," local","oca","n (","0 then\
|
||||
",") end\
|
||||
"," loc","se\
|
||||
","do\
|
||||
","nd\
|
||||
end\
|
||||
"," then e","0000644\0","ion ()\
|
||||
","ocal ","end\
|
||||
if ","e\
|
||||
"," then\
|
||||
"," local","icode.le","\" then "," ==","] == \"","eoux","ndow","\0\0\0\0\0c","nownAvail"," functi","0\000000000","eoux.tc","hen error"," = neo.","table.ins"," window","(window","d\
|
||||
if ","\
|
||||
if ","\
|
||||
local","end\
|
||||
e","nd\
|
||||
end","insert("," local ","k, v i","surface","eturn ","\
|
||||
loc","sub(1, ","end\
|
||||
if ","io","!","$","&","'","*","8","9",";",">","?","@","J","K","Q","V","\\","^","|","<22>","…","ˆ","‰","Œ","<22>","Ž","<22>","<22>","’","“","”","˜","¦","¬","¼","½","Â","ï",}
|
||||
local bytBuf = ""
|
||||
local bitBuf = ""
|
||||
local function getByte()
|
||||
if bytBuf == "" then
|
||||
bytBuf = D.read(instHandle, 64)
|
||||
end
|
||||
local r = bytBuf:byte()
|
||||
bytBuf = bytBuf:sub(2)
|
||||
return r
|
||||
end
|
||||
while true do
|
||||
if getByte() == 0 then break end
|
||||
end
|
||||
local function pb(c, p) if c % (p * 2) ~= c % p then bitBuf = bitBuf .. "1" else bitBuf = bitBuf .. "0" end end
|
||||
local stn = 0
|
||||
local function getBit()
|
||||
if bitBuf == "" then
|
||||
local c = getByte()
|
||||
c = (c - stn) % 256 stn = stn + 3
|
||||
pb(c, 1)
|
||||
pb(c, 2)
|
||||
pb(c, 4)
|
||||
pb(c, 8)
|
||||
pb(c, 16)
|
||||
pb(c, 32)
|
||||
pb(c, 64)
|
||||
pb(c, 128)
|
||||
end
|
||||
local bit = bitBuf:sub(1, 1) == "1"
|
||||
bitBuf = bitBuf:sub(2)
|
||||
return bit
|
||||
end
|
||||
local buf = ""
|
||||
local mode = false
|
||||
local bc2 = 10
|
||||
while true do
|
||||
local bc = getBit()
|
||||
local v = 0
|
||||
if bc then bc = bc2 v = 64 else bc = 6 end
|
||||
for bit = 0, bc - 1 do
|
||||
if getBit() then v = v + (2 ^ bit) end
|
||||
end
|
||||
buf = buf .. syms[v]
|
||||
if mode then
|
||||
while #buf >= 512 do
|
||||
sector(buf:sub(1, 512))
|
||||
buf = buf:sub(513)
|
||||
end
|
||||
else
|
||||
if #buf == 27939 then
|
||||
stn = 0
|
||||
bc2 = 11
|
||||
bitBuf = ""
|
||||
syms = {}
|
||||
while #buf > 0 do
|
||||
local len = buf:byte()
|
||||
if len > 127 then error("symlen") end
|
||||
buf = buf:sub(2)
|
||||
local ch = buf:sub(1, len)
|
||||
buf = buf:sub(len + 1)
|
||||
table.insert(syms, ch)
|
||||
end
|
||||
mode = true
|
||||
end
|
||||
end
|
||||
end
|
||||
--[[ |