mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 10:51:55 -04:00
Added edit, improved term, eeprom in devfs
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
This commit is contained in:
parent
dc7b641a54
commit
daf81473b9
189
src/main/resources/assets/opencomputers/loot/Plan9k/bin/edit.lua
Normal file
189
src/main/resources/assets/opencomputers/loot/Plan9k/bin/edit.lua
Normal file
@ -0,0 +1,189 @@
|
||||
local shell = require("shell")
|
||||
local term = require("term")
|
||||
local fs = require("filesystem")
|
||||
local unicode = require("unicode")
|
||||
|
||||
local args, options = shell.parse(...)
|
||||
|
||||
if not args[1] then
|
||||
print("Syntax: edit [file]")
|
||||
return
|
||||
end
|
||||
|
||||
local file = args[1]
|
||||
|
||||
local function read(from, to)
|
||||
local started, data
|
||||
while true do
|
||||
local char = io.read(1)
|
||||
if not char then
|
||||
error("Broken pipe")
|
||||
end
|
||||
if not started and char == from then
|
||||
started = true
|
||||
data = char
|
||||
elseif started then
|
||||
if char == to then
|
||||
return data .. char
|
||||
else
|
||||
data = data .. char
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--Cute, isn't it?
|
||||
io.write("\x1b[999;999H\x1b6n\x1b2J\x1b[30m\x1b[47m\x1bKEdit: " .. file .. "| F1 - save&quit | F3 - just quit\n\x1b[39m\x1b[49m")
|
||||
local code = read("\x1b", "R")
|
||||
local h, w = code:match("\x1b%[(%d+);(%d+)R")
|
||||
|
||||
local edith = h - 1
|
||||
local editw = w
|
||||
local x, y = 1, 1
|
||||
local atline = 1
|
||||
|
||||
local lines = {}
|
||||
|
||||
if fs.exists(file) then
|
||||
for line in io.lines(file) do
|
||||
lines[#lines + 1] = line
|
||||
end
|
||||
end
|
||||
|
||||
function setcur()
|
||||
io.write("\x1b[" .. (y - atline + 2) .. ";" .. (x) .. "H")
|
||||
end
|
||||
|
||||
local function render(startline, nlines)
|
||||
--io.write("\x1b["..(startline - atline + 1)..";1H")
|
||||
for n = 1, nlines do
|
||||
io.write("\x1b["..(startline - atline + n + 1)..";1H\x1b[K" .. unicode.sub(lines[n + startline - 1] or "", 1, editw))
|
||||
end
|
||||
setcur()
|
||||
end
|
||||
|
||||
render(1, edith)
|
||||
setcur()
|
||||
|
||||
local run = true
|
||||
local baseHandler, codeHandler
|
||||
local charHandler
|
||||
|
||||
local code = ""
|
||||
codeHandler = function(char)
|
||||
if char == "[" then code = code .. char
|
||||
elseif char == "0" then code = code .. char
|
||||
elseif code == "[" and char == "A" then
|
||||
charHandler = baseHandler
|
||||
if y - 1 < 1 then return end
|
||||
y = y - 1
|
||||
if unicode.len(lines[y]) < x then
|
||||
x = unicode.len(lines[y]) + 1
|
||||
end
|
||||
if y < atline then
|
||||
atline = y
|
||||
render(y, edith)
|
||||
end
|
||||
setcur()
|
||||
elseif code == "[" and char == "B" then
|
||||
charHandler = baseHandler
|
||||
y = y + 1
|
||||
lines[y] = lines[y] or ""
|
||||
if unicode.len(lines[y]) < x then
|
||||
x = unicode.len(lines[y]) + 1
|
||||
end
|
||||
if y > atline + edith - 1 then
|
||||
atline = y - edith + 1
|
||||
render(y - edith + 1, edith)
|
||||
end
|
||||
setcur()
|
||||
elseif code == "[" and char == "C" then
|
||||
charHandler = baseHandler
|
||||
if unicode.len(lines[y]) < x then
|
||||
y = y + 1
|
||||
x = 1
|
||||
lines[y] = lines[y] or ""
|
||||
if y > atline + edith - 1 then
|
||||
atline = y - edith + 1
|
||||
render(y - edith + 1, edith)
|
||||
end
|
||||
setcur()
|
||||
return
|
||||
end
|
||||
x = x + 1
|
||||
setcur()
|
||||
elseif code == "[" and char == "D" then
|
||||
charHandler = baseHandler
|
||||
if x - 1 < 1 then
|
||||
if y - 1 < 1 then return end
|
||||
y = y - 1
|
||||
if y < atline then
|
||||
atline = y
|
||||
render(y, edith)
|
||||
end
|
||||
x = unicode.len(lines[y]) + 1
|
||||
setcur()
|
||||
return
|
||||
end
|
||||
x = x - 1
|
||||
setcur()
|
||||
elseif code == "[0" and char == "P" or char == "R" then
|
||||
run = false
|
||||
io.write("\x1b[2J")
|
||||
if char == "P" then
|
||||
local out = io.open(file, "w")
|
||||
local text = ""
|
||||
for _, line in ipairs(lines) do
|
||||
text = text .. line .. "\n"
|
||||
end
|
||||
out:write(text)
|
||||
out:close()
|
||||
end
|
||||
else
|
||||
charHandler = baseHandler
|
||||
end
|
||||
end
|
||||
|
||||
baseHandler = function(char)
|
||||
if char == "\x1b" then
|
||||
code = ""
|
||||
charHandler = codeHandler
|
||||
elseif char == "\n" then
|
||||
line = lines[y]
|
||||
lines[y] = unicode.sub(line or "", 1, x - 1)
|
||||
table.insert(lines, y + 1, unicode.sub(line or "", x))
|
||||
x = 1
|
||||
render(y, atline + edith - y - 1)
|
||||
y = y + 1
|
||||
if y > atline + edith - 1 then
|
||||
atline = y - edith + 1
|
||||
render(y - edith + 1, edith)
|
||||
end
|
||||
setcur()
|
||||
elseif char == "\b" then
|
||||
if x > 1 then
|
||||
lines[y] = unicode.sub(lines[y] or "", 1, x-2)..unicode.sub(lines[y] or "", x)
|
||||
x = x - 1
|
||||
render(y, 1)
|
||||
elseif y > 1 then
|
||||
x = unicode.len(lines[y - 1]) + 1
|
||||
lines[y - 1] = lines[y - 1] .. lines[y]
|
||||
table.remove(lines, y)
|
||||
y = y - 1
|
||||
render(y, atline + edith - y - 1)
|
||||
end
|
||||
else
|
||||
lines[y] = unicode.sub(lines[y] or "", 1, x-1)..char..unicode.sub(lines[y] or "", x)
|
||||
render(y, 1)
|
||||
x = x + 1
|
||||
setcur()
|
||||
end
|
||||
end
|
||||
|
||||
charHandler = baseHandler
|
||||
|
||||
while run do
|
||||
local char = io.read(1)
|
||||
charHandler(char)
|
||||
end
|
||||
|
@ -29,12 +29,34 @@ local function checkCoord()
|
||||
if y > h then y = h end
|
||||
end
|
||||
|
||||
local preblinkbg = 0x000000
|
||||
local preblinkfg = 0x000000
|
||||
|
||||
local function unblink()
|
||||
if blinkState then
|
||||
blinkState = not blinkState
|
||||
component.invoke(gpu, "setBackground", blinkState and 0xFFFFFF or 0x000000)
|
||||
component.invoke(gpu, "set", x, y, component.invoke(gpu, "get", x, y) or " ")
|
||||
component.invoke(gpu, "setBackground", 0x000000)
|
||||
local char, fg, bg = component.invoke(gpu, "get", x, y)
|
||||
preblinkbg = blinkState and bg or preblinkbg
|
||||
preblinkfg = blinkState and fg or preblinkfg
|
||||
local oribg, obpal = component.invoke(gpu, "setBackground", blinkState and 0xFFFFFF or preblinkbg)
|
||||
local orifg, ofpal = component.invoke(gpu, "setForeground", blinkState and 0x000000 or preblinkfg)
|
||||
component.invoke(gpu, "set", x, y, char or " ")
|
||||
component.invoke(gpu, "setBackground", oribg)
|
||||
component.invoke(gpu, "setForeground", orifg)
|
||||
end
|
||||
end
|
||||
|
||||
local function reblink()
|
||||
if not blinkState then
|
||||
blinkState = not blinkState
|
||||
local char, fg, bg = component.invoke(gpu, "get", x, y)
|
||||
preblinkbg = blinkState and bg or preblinkbg
|
||||
preblinkfg = blinkState and fg or preblinkfg
|
||||
local oribg, obpal = component.invoke(gpu, "setBackground", blinkState and 0xFFFFFF or preblinkbg)
|
||||
local orifg, ofpal = component.invoke(gpu, "setForeground", blinkState and 0x000000 or preblinkfg)
|
||||
component.invoke(gpu, "set", x, y, char or " ")
|
||||
component.invoke(gpu, "setBackground", oribg)
|
||||
component.invoke(gpu, "setForeground", orifg)
|
||||
end
|
||||
end
|
||||
|
||||
@ -51,6 +73,7 @@ local function scroll()
|
||||
else
|
||||
y = y + 1
|
||||
end
|
||||
reblink()
|
||||
end
|
||||
|
||||
local printBuf = ""
|
||||
@ -77,6 +100,7 @@ local function backDelChar()
|
||||
x = x - 1
|
||||
unblink()
|
||||
component.invoke(gpu, "set", x, y, " ")
|
||||
reblink()
|
||||
end
|
||||
end
|
||||
|
||||
@ -92,6 +116,7 @@ function charHandlers.base(char)
|
||||
unblink()
|
||||
printBuffer()
|
||||
x = 1
|
||||
reblink()
|
||||
elseif char == "\t" then
|
||||
printBuf = printBuf .. " "
|
||||
elseif char == "\b" then
|
||||
@ -159,11 +184,16 @@ local lcommands = {}
|
||||
|
||||
lcommands["4"] = function()end --Reset to replacement mode
|
||||
|
||||
local ncommands = {}
|
||||
|
||||
ncommands["6"] = function()io.write("\x1b[" .. y .. ";" .. x .. "R")end
|
||||
|
||||
local commandMode = ""
|
||||
local commandBuf = ""
|
||||
local commandList = {}
|
||||
|
||||
--TODO \1b[C -- reset term to initial state
|
||||
|
||||
function charHandlers.control(char)
|
||||
if char == "\x1b" then
|
||||
commandList = {}
|
||||
@ -174,6 +204,7 @@ function charHandlers.control(char)
|
||||
elseif char == "[" then
|
||||
if commandMode ~= "" or commandBuf ~= "" then
|
||||
charHandlers.active = charHandlers.base
|
||||
reblink()
|
||||
return
|
||||
end
|
||||
commandMode = "["
|
||||
@ -181,6 +212,7 @@ function charHandlers.control(char)
|
||||
elseif char == "(" then
|
||||
if commandMode ~= "" or commandBuf ~= "" then
|
||||
charHandlers.active = charHandlers.base
|
||||
reblink()
|
||||
return
|
||||
end
|
||||
commandMode = "("
|
||||
@ -213,6 +245,18 @@ function charHandlers.control(char)
|
||||
end
|
||||
lcommands[command]()
|
||||
end
|
||||
elseif char == "n" then
|
||||
commandList[#commandList + 1] = commandBuf
|
||||
if not commandList[1] or commandList[1] == "" then
|
||||
commandList[1] = "0"
|
||||
end
|
||||
for _, command in ipairs(commandList) do
|
||||
if not ncommands[command] then
|
||||
pipes.log("Unknown escape code: " .. tostring(command))
|
||||
break
|
||||
end
|
||||
ncommands[command]()
|
||||
end
|
||||
elseif char == "d" then
|
||||
commandList[#commandList + 1] = commandBuf
|
||||
local n = tonumber(commandList[1]) or 1
|
||||
@ -225,9 +269,9 @@ function charHandlers.control(char)
|
||||
scrBot = nb
|
||||
elseif char == "H" or char == "f" then --set pos
|
||||
commandList[#commandList + 1] = commandBuf
|
||||
local nx, ny = tonumber(commandList[1]), tonumber(commandList[2])
|
||||
x = nx or 1
|
||||
y = ny or 1
|
||||
local ny, nx = tonumber(commandList[1]), tonumber(commandList[2])
|
||||
x = math.min(nx or 1, w)
|
||||
y = math.min(ny or 1, h)
|
||||
checkCoord()
|
||||
elseif char == "A" then --move up
|
||||
commandList[#commandList + 1] = commandBuf
|
||||
@ -237,6 +281,7 @@ function charHandlers.control(char)
|
||||
elseif char == "B" then --move down
|
||||
if commandMode == "(" then
|
||||
charHandlers.active = charHandlers.base
|
||||
reblink()
|
||||
return
|
||||
end
|
||||
commandList[#commandList + 1] = commandBuf
|
||||
@ -274,6 +319,7 @@ function charHandlers.control(char)
|
||||
return
|
||||
end
|
||||
charHandlers.active = charHandlers.base
|
||||
reblink()
|
||||
commandList = {}
|
||||
commandBuf = ""
|
||||
commandMode = ""
|
||||
@ -296,9 +342,14 @@ end
|
||||
|
||||
pipes.setTimer(function()
|
||||
blinkState = not blinkState
|
||||
component.invoke(gpu, "setBackground", blinkState and 0xFFFFFF or 0x000000)
|
||||
component.invoke(gpu, "set", x, y, component.invoke(gpu, "get", x, y) or " ")
|
||||
component.invoke(gpu, "setBackground", 0x000000)
|
||||
local char, fg, bg = component.invoke(gpu, "get", x, y)
|
||||
preblinkbg = blinkState and bg or preblinkbg
|
||||
preblinkfg = blinkState and fg or preblinkfg
|
||||
local oribg, obpal = component.invoke(gpu, "setBackground", blinkState and 0xFFFFFF or preblinkbg)
|
||||
local orifg, ofpal = component.invoke(gpu, "setForeground", blinkState and 0x000000 or preblinkfg)
|
||||
component.invoke(gpu, "set", x, y, char or " ")
|
||||
component.invoke(gpu, "setBackground", oribg)
|
||||
component.invoke(gpu, "setForeground", orifg)
|
||||
end, 0.5)
|
||||
|
||||
while true do
|
||||
|
@ -37,7 +37,7 @@ for gpu in component.list("gpu") do
|
||||
print("SIGINT!!")
|
||||
end
|
||||
|
||||
os.spawnp("/bin/getty.lua", mi, nil, nil, gpu)
|
||||
os.spawnp("/bin/getty.lua", mi, mo, nil, gpu)
|
||||
os.spawnp("/bin/readkey.lua", nil, mo, mo, screen, interruptHandler)
|
||||
|
||||
if not sout then
|
||||
|
@ -162,13 +162,27 @@ function on.key_down(_, source, ascii, keycode, user)
|
||||
keyboard.pressedCodes[keycode] = true
|
||||
|
||||
if ascii == 13 then ascii = 10 end
|
||||
if ascii ~= 0 then
|
||||
if ascii ~= 0 and ascii ~= 127 then
|
||||
io.stdout:write(unicode.char(ascii))
|
||||
else
|
||||
if keycode == 200 then io.stdout:write("\x1b[A")
|
||||
elseif keycode == 208 then io.stdout:write("\x1b[B")
|
||||
elseif keycode == 205 then io.stdout:write("\x1b[C")
|
||||
elseif keycode == 203 then io.stdout:write("\x1b[D")
|
||||
|
||||
elseif keycode == keyboard.keys.f1 then io.stdout:write("\x1b[0P")
|
||||
elseif keycode == keyboard.keys.f2 then io.stdout:write("\x1b[0Q")
|
||||
elseif keycode == keyboard.keys.f3 then io.stdout:write("\x1b[0R")
|
||||
elseif keycode == keyboard.keys.f4 then io.stdout:write("\x1b[0S")
|
||||
|
||||
elseif keycode == keyboard.keys.delete then io.stdout:write("\x1b[3~")
|
||||
elseif keycode == keyboard.keys.insert then io.stdout:write("\x1b[2~")
|
||||
elseif keycode == keyboard.keys.pageUp then io.stdout:write("\x1b[5~")
|
||||
elseif keycode == keyboard.keys.pageDown then io.stdout:write("\x1b[6~")
|
||||
elseif keycode == keyboard.keys.home then io.stdout:write("\x1b0H")
|
||||
elseif keycode == keyboard.keys["end"] then io.stdout:write("\x1b0F")
|
||||
elseif keycode == keyboard.keys.tab then io.stdout:write("\t")
|
||||
--TODO: rest fX keys
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -180,6 +194,7 @@ function on.key_up(_, source, ascii, keycode, user)
|
||||
end
|
||||
|
||||
function on.clipboard(_, source, data, user)
|
||||
if not keyboards[source] then return end
|
||||
io.stdout:write(data)
|
||||
end
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
_G._OSVERSION = "OpenLoader 0.2"
|
||||
_G._OSVERSION = "OpenLoader 0.3"
|
||||
local component = component or require('component')
|
||||
local computer = computer or require('computer')
|
||||
local unicode = unicode or require('unicode')
|
||||
@ -15,29 +15,45 @@ local gpu = component.list("gpu")()
|
||||
local w, h
|
||||
|
||||
local screen = component.list('screen')()
|
||||
for address in component.list('screen') do
|
||||
if #component.invoke(address, 'getKeyboards') > 0 then
|
||||
screen = address
|
||||
|
||||
local function gpucast(op, arg, ...)
|
||||
local res = {}
|
||||
local n = 1
|
||||
for address in component.list('screen') do
|
||||
component.invoke(gpu, "bind", address)
|
||||
if type(arg) == "table" then
|
||||
res[#res + 1] = {component.invoke(gpu, op, table.unpack(arg[n]))}
|
||||
else
|
||||
res[#res + 1] = {component.invoke(gpu, op, arg, ...)}
|
||||
end
|
||||
n = n + 1
|
||||
end
|
||||
return res
|
||||
end
|
||||
|
||||
local cls = function()end
|
||||
if gpu and screen then
|
||||
component.invoke(gpu, "bind", screen)
|
||||
--component.invoke(gpu, "bind", screen)
|
||||
w, h = component.invoke(gpu, "getResolution")
|
||||
component.invoke(gpu, "setResolution", w, h)
|
||||
component.invoke(gpu, "setBackground", 0x000000)
|
||||
component.invoke(gpu, "setForeground", 0xFFFFFF)
|
||||
component.invoke(gpu, "fill", 1, 1, w, h, " ")
|
||||
cls = function()component.invoke(gpu,"fill", 1, 1, w, h, " ")end
|
||||
local res = gpucast("getResolution")
|
||||
gpucast("setResolution", res)
|
||||
gpucast("setBackground", 0x000000)
|
||||
gpucast("setForeground", 0xFFFFFF)
|
||||
for _, e in ipairs(res)do
|
||||
table.insert(e, 1, 1)
|
||||
table.insert(e, 1, 1)
|
||||
e[#e+1] = " "
|
||||
end
|
||||
gpucast("fill", res)
|
||||
cls = function()gpucast("fill", res)end
|
||||
end
|
||||
local y = 1
|
||||
local function status(msg)
|
||||
if gpu and screen then
|
||||
component.invoke(gpu, "set", 1, y, msg)
|
||||
gpucast("set", 1, y, msg)
|
||||
if y == h then
|
||||
component.invoke(gpu, "copy", 1, 2, w, h - 1, 0, -1)
|
||||
component.invoke(gpu, "fill", 1, h, w, 1, " ")
|
||||
gpucast("copy", 1, 2, w, h - 1, 0, -1)
|
||||
gpucast("fill", 1, h, w, 1, " ")
|
||||
else
|
||||
y = y + 1
|
||||
end
|
||||
|
@ -32,18 +32,18 @@ proxy.open = function(path)
|
||||
local hnd = allocator:get()
|
||||
hnd.file = file
|
||||
if hnd.file.open then
|
||||
hnd.file:open()
|
||||
hnd.file.open(hnd)
|
||||
end
|
||||
return hnd.id
|
||||
end
|
||||
proxy.read = function(h, ...)
|
||||
return handles[h].file:read(...)
|
||||
return handles[h].file.read(handles[h], ...)
|
||||
end
|
||||
proxy.close = function(h)
|
||||
allocator:unset(handles[h])
|
||||
end
|
||||
proxy.write = function(h, ...)
|
||||
return handles[h].file:write(...)
|
||||
return handles[h].file.write(handles[h], ...)
|
||||
end
|
||||
proxy.isDirectory = function(path)
|
||||
local seg = kernel.modules.vfs.segments(path)
|
||||
|
@ -0,0 +1,50 @@
|
||||
function start()
|
||||
kernel.modules.devfs.data.eeprom = {
|
||||
__type = "f",
|
||||
open = function(hnd)
|
||||
if not component.list("eeprom")() then
|
||||
error("No eeprom installed")
|
||||
end
|
||||
hnd.pos = 1
|
||||
end,
|
||||
size = function()
|
||||
return component.invoke(component.list("eeprom")() or "", "getSize")
|
||||
end,
|
||||
write = function(h, data)
|
||||
if h.pos > 1 then
|
||||
data = component.invoke(component.list("eeprom")() or "", "get"):sub(1,h.pos) .. data
|
||||
end
|
||||
component.invoke(component.list("eeprom")() or "", "set", data)
|
||||
end,
|
||||
read = function(h, len)
|
||||
local res = component.invoke(component.list("eeprom")() or "", "get")
|
||||
res = res:sub(h.pos, len)
|
||||
h.pos = h.pos + len
|
||||
return res ~= "" and res
|
||||
end
|
||||
}
|
||||
kernel.modules.devfs.data["eeprom-data"] = {
|
||||
__type = "f",
|
||||
open = function(hnd)
|
||||
if not component.list("eeprom")() then
|
||||
error("No eeprom installed")
|
||||
end
|
||||
hnd.pos = 1
|
||||
end,
|
||||
size = function()
|
||||
return 256 --TODO: is this correct?
|
||||
end,
|
||||
write = function(h, data)
|
||||
if h.pos > 1 then
|
||||
data = component.invoke(component.list("eeprom")() or "", "getData"):sub(1,h.pos) .. data
|
||||
end
|
||||
component.invoke(component.list("eeprom")() or "", "setData", data)
|
||||
end,
|
||||
read = function(h, len)
|
||||
local res = component.invoke(component.list("eeprom")() or "", "getData")
|
||||
res = res:sub(h.pos, len)
|
||||
h.pos = h.pos + len
|
||||
return res ~= "" and res
|
||||
end
|
||||
}
|
||||
end
|
@ -1,9 +1,63 @@
|
||||
local term = {}
|
||||
|
||||
local function read(from, to)
|
||||
local started, data
|
||||
while true do
|
||||
local char = io.read(1)
|
||||
if not char then
|
||||
error("Broken pipe")
|
||||
end
|
||||
if not started and char == from then
|
||||
started = true
|
||||
data = char
|
||||
elseif started then
|
||||
if char == to then
|
||||
return data .. char
|
||||
else
|
||||
data = data .. char
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function term.clear()
|
||||
io.write("\x1b[2J")
|
||||
end
|
||||
|
||||
function term.clearLine()
|
||||
--io.write("\x1b[K")
|
||||
end
|
||||
|
||||
function term.getCursor()
|
||||
io.write("\x1b[6n")
|
||||
local code = read("\x1b", "R")
|
||||
local y, x = code:match("\x1b%[(%d+);(%d+)R")
|
||||
|
||||
return tonumber(x), tonumber(y)
|
||||
end
|
||||
|
||||
function term.getResolution()
|
||||
--io.write("\x1b[6n")
|
||||
--local code = read("\x1b", "R")
|
||||
--local y, x = code:match("\x1b%[(%d+);(%d+)R")
|
||||
|
||||
--return tonumber(x), tonumber(y)
|
||||
end
|
||||
|
||||
function term.setCursor(col, row)
|
||||
checkArg(1, col, "number")
|
||||
checkArg(2, row, "number")
|
||||
io.write("\x1b[" .. row .. ";" .. col .. "H")
|
||||
end
|
||||
|
||||
function term.isAvailable()
|
||||
return true
|
||||
end
|
||||
|
||||
function term.setCursorBlink(enabled)
|
||||
|
||||
end
|
||||
|
||||
function term.read(history)
|
||||
history = history or {}
|
||||
local x, y = 1, 1
|
||||
@ -74,6 +128,22 @@ function term.read(history)
|
||||
io.write("\x1b[" .. (x - 1) .. "D\x1b[K" .. line)
|
||||
x = unicode.len(line) + 1
|
||||
end
|
||||
elseif act == "3" and io.read(1) == "~" then
|
||||
local pre = unicode.sub(getLine(), 1, x - 1)
|
||||
local after = unicode.sub(getLine(), x + 1)
|
||||
setLine(pre .. after)
|
||||
--x = x
|
||||
io.write("\x1b[K" .. after .. "\x1b[" .. unicode.len(after) .. "D")
|
||||
end
|
||||
elseif mode == "0" then
|
||||
local act = io.read(1)
|
||||
if act == "H" then
|
||||
io.write("\x1b["..(x - 1).."D")
|
||||
x = 1
|
||||
elseif act == "F" then
|
||||
local line = getLine()
|
||||
io.write("\x1b[" .. (x - 1) .. "D\x1b[" .. (unicode.len(line)) .. "C")
|
||||
x = unicode.len(line) + 1
|
||||
end
|
||||
end
|
||||
elseif char:match("[%g%s]") then
|
||||
@ -82,4 +152,8 @@ function term.read(history)
|
||||
end
|
||||
end
|
||||
|
||||
function term.write(value, wrap)
|
||||
io.write(value)
|
||||
end
|
||||
|
||||
return term
|
||||
|
@ -236,6 +236,7 @@ mptFrontend = {
|
||||
for _, file in ipairs(data.files) do
|
||||
backend.copyFile(config.cacheDir.."mpt/"..data.name.."/".. data.checksum ..file, file)
|
||||
end
|
||||
backend.removeFile(config.cacheDir.."mpt/"..data.name.."/".. data.checksum)
|
||||
end,
|
||||
|
||||
removePackage = function(package)
|
||||
@ -304,6 +305,7 @@ mirrorFrontend = {
|
||||
for _, file in ipairs(data.files) do
|
||||
backend.copyFile(config.cacheDir.."mpt/"..data.name.."/".. data.checksum ..file, file)
|
||||
end
|
||||
backend.removeFile(config.cacheDir.."mpt/"..data.name.."/".. data.checksum)
|
||||
end,
|
||||
removePackage = function(package)
|
||||
for _, file in ipairs(base.installed[package].data.files) do
|
||||
|
@ -1 +1 @@
|
||||
{cacheDir="/var/lib/mpt/cache/",database="/var/lib/mpt/base.db",frontend={mpt={api="http://mpt.magik6k.net/api/"}}}
|
||||
{cacheDir="/var/lib/mpt/cache/",frontend={mpt={api="http://mpt.magik6k.net/api/"}},database="/var/lib/mpt/base.db"}
|
@ -1 +1 @@
|
||||
{installed={["plan9k-installer"]={deps={"plan9k","mpt"},data={checksum="52c8f82357c966ce3e19c97bf3942012",dependencies={"plan9k","mpt"},files={"/bin/install.lua"},name="plan9k-installer",repo="plan9k"},frontend="MPT"},["plan9k-drivers"]={deps={},data={checksum="6cbd5412ca13503484299daa0597f754",dependencies={},files={"/lib/modules/base/17_tape.lua"},name="plan9k-drivers",repo="plan9k"},frontend="MPT"},["plan9k-network"]={deps={},data={checksum="336f43272f6b38051d71a5d640716df7",dependencies={},files={"/lib/internet.lua","/bin/pastebin.lua","/bin/wget.lua","/lib/modules/base/17_network.lua","/lib/modules/base/19_libnetwork.lua","/bin/arp.lua","/bin/ifconfig.lua","/bin/ping.lua","/bin/route.lua","/lib/modules/network/loopback.lua","/lib/modules/network/modem.lua","/usr/bin/nc.lua","/lib/modules/network/tunnel.lua"},name="plan9k-network",repo="plan9k"},frontend="MPT"},mpt={deps={},data={checksum="37a61081c47a12904b8af615c938e6db",dependencies={},files={"/usr/bin/mpt.lua"},name="mpt",repo="mpt"},frontend="MPT"},["plan9k-core"]={deps={"pipes","plan9k-coreutil","plan9k-shell"},data={checksum="5e0b72825b5ae2e7bdd77addfafa055",dependencies={"pipes","plan9k-coreutil","plan9k-shell"},files={"/bin/init.lua","/bin/getty.lua","/bin/readkey.lua","/lib/rc.lua","/bin/rc.lua","/etc/rc.cfg"},name="plan9k-core",repo="plan9k"},frontend="MPT"},plan9k={deps={"plan9k-core","plan9k-network","plan9k-drivers"},data={checksum="-53f6ee1412ad0be211ff9aedfb202647",dependencies={"plan9k-core","plan9k-network","plan9k-drivers"},files={},name="plan9k",repo="plan9k"},frontend="MPT"},["openloader-init"]={deps={},data={checksum="28a395353488d35f6071631a6328b048",dependencies={},files={"/init.lua"},name="openloader-init",repo="disks"},frontend="MPT"},pipes={deps={"openloader-init"},data={checksum="-b9cd57614f2f1b2ed2708e7596b8a62",dependencies={"openloader-init"},files={"/boot/kernel/pipes","/lib/modules/base/05_vfs.lua","/lib/modules/base/20_threading.lua","/lib/modules/base/19_manageg.lua","/lib/modules/base/25_init.lua","/lib/modules/base/15_userspace.lua","/usr/man/pipes","/lib/modules/base/16_buffer.lua","/lib/modules/base/17_io.lua","/lib/modules/base/16_require.lua","/lib/modules/base/18_syscall.lua","/lib/modules/base/21_threadUtil.lua","/lib/modules/base/21_timer.lua","/lib/modules/base/16_component.lua","/lib/modules/base/15_keventd.lua","/lib/modules/base/10_procfs.lua","/lib/modules/base/01_util.lua","/lib/modules/base/10_devfs.lua","/lib/modules/base/18_pty.lua","/lib/modules/base/17_keyboard.lua"},name="pipes",repo="plan9k"},frontend="MPT"},["plan9k-fsutil"]={deps={"plan9k-corelibs"},data={checksum="-1e0c3c93f8155321d24e4d0d1db31cb6",dependencies={"plan9k-corelibs"},files={"/bin/cat.lua","/bin/ln.lua","/bin/ls.lua","/bin/mv.lua","/bin/rm.lua","/bin/tee.lua","/bin/df.lua","/bin/dd.lua","/bin/cp.lua"},name="plan9k-fsutil",repo="plan9k"},frontend="MPT"},["plan9k-shell"]={deps={},data={checksum="49cb5a0a3dea62e73c409ec5072112ac",dependencies={},files={"/bin/sh.lua"},name="plan9k-shell",repo="plan9k"},frontend="MPT"},["plan9k-corelibs"]={deps={},data={checksum="5efcf3df1abf690151c960690a75a768",dependencies={},files={"/lib/serialization.lua","/lib/term.lua","/lib/text.lua","/lib/shell.lua","/lib/event.lua"},name="plan9k-corelibs",repo="plan9k"},frontend="MPT"},["plan9k-coreutil"]={deps={"plan9k-corelibs","plan9k-fsutil"},data={checksum="-e7c7132468ae675bc57c29a93921f7b",dependencies={"plan9k-corelibs","plan9k-fsutil"},files={"/bin/echo.lua","/bin/wc.lua","/bin/ps.lua","/bin/lua.lua","/bin/kill.lua","/bin/reboot.lua","/bin/sleep.lua","/bin/clear.lua","/bin/components.lua","/bin/hostname.lua","/bin/dmesg.lua"},name="plan9k-coreutil",repo="plan9k"},frontend="MPT"}}}
|
||||
{installed={["plan9k-shell"]={frontend="MPT",data={name="plan9k-shell",checksum="49cb5a0a3dea62e73c409ec5072112ac",dependencies={},repo="plan9k",files={"/bin/sh.lua"}},deps={}},["plan9k-installer"]={frontend="MPT",data={name="plan9k-installer",checksum="52c8f82357c966ce3e19c97bf3942012",dependencies={"plan9k","mpt"},repo="plan9k",files={"/bin/install.lua"}},deps={"plan9k","mpt"}},["openloader-init"]={frontend="MPT",data={name="openloader-init",checksum="-45e6d7b1e41468c1d335952ee3b89e13",dependencies={},repo="disks",files={"/init.lua"}},deps={}},mpt={frontend="MPT",data={name="mpt",checksum="-4dd2104fef407efcf47ca2908f680340",dependencies={},repo="mpt",files={"/usr/bin/mpt.lua"}},deps={}},["plan9k-core"]={frontend="MPT",data={name="plan9k-core",checksum="-6b8c4bbb33c0c20a900a2b5e1e9476f7",dependencies={"pipes","plan9k-coreutil","plan9k-shell"},repo="plan9k",files={"/bin/init.lua","/bin/getty.lua","/bin/readkey.lua","/lib/rc.lua","/bin/rc.lua","/etc/rc.cfg"}},deps={"pipes","plan9k-coreutil","plan9k-shell"}},["plan9k-network"]={frontend="MPT",data={name="plan9k-network",checksum="336f43272f6b38051d71a5d640716df7",dependencies={},repo="plan9k",files={"/lib/internet.lua","/bin/pastebin.lua","/bin/wget.lua","/lib/modules/base/17_network.lua","/lib/modules/base/19_libnetwork.lua","/bin/arp.lua","/bin/ifconfig.lua","/bin/ping.lua","/bin/route.lua","/lib/modules/network/loopback.lua","/lib/modules/network/modem.lua","/usr/bin/nc.lua","/lib/modules/network/tunnel.lua"}},deps={}},["plan9k-corelibs"]={frontend="MPT",data={name="plan9k-corelibs",checksum="7d4b91ee265f364a6deafd9ca2881efa",dependencies={},repo="plan9k",files={"/lib/serialization.lua","/lib/term.lua","/lib/text.lua","/lib/shell.lua","/lib/event.lua"}},deps={}},["plan9k-fsutil"]={frontend="MPT",data={name="plan9k-fsutil",checksum="-1e0c3c93f8155321d24e4d0d1db31cb6",dependencies={"plan9k-corelibs"},repo="plan9k",files={"/bin/cat.lua","/bin/ln.lua","/bin/ls.lua","/bin/mv.lua","/bin/rm.lua","/bin/tee.lua","/bin/df.lua","/bin/dd.lua","/bin/cp.lua"}},deps={"plan9k-corelibs"}},["plan9k-edit"]={frontend="MPT",data={name="plan9k-edit",checksum="-5a8af91ab93ec0362f5bf1080eb94718",dependencies={},repo="plan9k",files={"/bin/edit.lua"}},deps={}},pipes={frontend="MPT",data={name="pipes",checksum="-51cf98ed4df4c9a20832a4c57086a57c",dependencies={"openloader-init"},repo="plan9k",files={"/boot/kernel/pipes","/lib/modules/base/05_vfs.lua","/lib/modules/base/20_threading.lua","/lib/modules/base/19_manageg.lua","/lib/modules/base/25_init.lua","/lib/modules/base/15_userspace.lua","/usr/man/pipes","/lib/modules/base/16_buffer.lua","/lib/modules/base/17_io.lua","/lib/modules/base/16_require.lua","/lib/modules/base/18_syscall.lua","/lib/modules/base/21_threadUtil.lua","/lib/modules/base/21_timer.lua","/lib/modules/base/16_component.lua","/lib/modules/base/15_keventd.lua","/lib/modules/base/10_procfs.lua","/lib/modules/base/01_util.lua","/lib/modules/base/10_devfs.lua","/lib/modules/base/18_pty.lua","/lib/modules/base/17_keyboard.lua"}},deps={"openloader-init"}},plan9k={frontend="MPT",data={name="plan9k",checksum="-c16ccdf21a1ff13be8f6258d1a17d89",dependencies={"plan9k-core","plan9k-network","plan9k-drivers","plan9k-edit"},repo="plan9k",files={}},deps={"plan9k-core","plan9k-network","plan9k-drivers","plan9k-edit"}},["plan9k-drivers"]={frontend="MPT",data={name="plan9k-drivers",checksum="-2a9819da9410d2803c1946d76bbd4250",dependencies={},repo="plan9k",files={"/lib/modules/base/17_tape.lua","/lib/modules/base/17_eeprom.lua"}},deps={}},["plan9k-coreutil"]={frontend="MPT",data={name="plan9k-coreutil",checksum="-e7c7132468ae675bc57c29a93921f7b",dependencies={"plan9k-corelibs","plan9k-fsutil"},repo="plan9k",files={"/bin/echo.lua","/bin/wc.lua","/bin/ps.lua","/bin/lua.lua","/bin/kill.lua","/bin/reboot.lua","/bin/sleep.lua","/bin/clear.lua","/bin/components.lua","/bin/hostname.lua","/bin/dmesg.lua"}},deps={"plan9k-corelibs","plan9k-fsutil"}}}}
|
Loading…
x
Reference in New Issue
Block a user