68 lines
1.5 KiB
Lua
68 lines
1.5 KiB
Lua
function skex(s)
|
|
local c,cs,cT,lT,lP="","",{},{},1
|
|
local function lf(s)
|
|
local f=io.open(s,"rb")
|
|
c=f:read("*a")
|
|
f:close()
|
|
end
|
|
local function wf(s)
|
|
local f,c=io.open(s,"wb")
|
|
for k,v in ipairs(lT) do f:write(v.."\n") end
|
|
f:close()
|
|
end
|
|
if s then
|
|
lf(s)
|
|
for l in c:gmatch("[^\n]+") do lT[#lT+1]=l end
|
|
end
|
|
while true do
|
|
cs=io.read()
|
|
cT={}
|
|
for w in cs:gmatch("%S+") do cT[#cT+1]=w end
|
|
if cT[1] == "q" then break
|
|
elseif cT[1] == "l" then
|
|
for i = (tonumber(cT[2]) or 1), (tonumber(cT[3]) or #lT) do
|
|
if lT[i] then
|
|
print(tostring(i).."\t"..(lT[i] or ""))
|
|
end
|
|
end
|
|
elseif cT[1] == "a" or cT[1] == "i" or cT[1] == "s" then
|
|
if tonumber(cT[2]) then lP=tonumber(cT[2]) end
|
|
if cT[1] == "s" then for i = 1,tonumber(cT[3]) do table.remove(lT,i+(tonumber(cT[2])-1)) end end
|
|
if cT[1] == "a" then lP=lP+1 end
|
|
while true do
|
|
cs=io.read()
|
|
if cs~="." then
|
|
table.insert(lT,lP,cs)
|
|
lP=lP+1
|
|
else break end
|
|
end
|
|
elseif cT[1] == "f" then
|
|
s=cT[2] or s
|
|
print(s)
|
|
elseif cT[1] == "e" then
|
|
c=""
|
|
for k,v in ipairs(lT) do c=c..v.."\n" end
|
|
print(pcall(load(c)))
|
|
elseif cT[1] == "r" then
|
|
s=cT[2] or s
|
|
wf(s)
|
|
elseif cT[1] == "w" then
|
|
s=cT[2] or s
|
|
wf(s)
|
|
elseif cT[1] == "d" then
|
|
for i = 1, tonumber(cT[3])-tonumber(cT[2]) do
|
|
table.remove(lT,cT[2])
|
|
end
|
|
elseif cT[1] == "p" then
|
|
lP=tonumber(cT[2]) or lP
|
|
print(lP)
|
|
elseif cs:sub(1,1) == "!" then
|
|
c=""
|
|
for k,v in ipairs(lT) do c=c..v.."\n" end
|
|
print(pcall(load(cs:sub(2))))
|
|
else
|
|
print("?")
|
|
end
|
|
end
|
|
end
|