working commands again, terminal fixes

This commit is contained in:
Er2 2022-02-22 21:53:03 +03:00
parent b080d64053
commit d917aad352
3 changed files with 35 additions and 15 deletions

View file

@ -72,20 +72,37 @@ await(function()
end
con.print '\n'
elseif argv[1]:match '%u:' then
elseif argv[1]:match '^%u:$' then
cd = argv[1]
elseif argv[1]:lower() == 'type' then
con.print(fsRead(argv[2]))
con.print '\n'
else con.println(argv[1].. ': command not found')
elseif argv[1]:lower() == 'exit'
then runs = false
else
local v = (argv[1]:sub(-4) == '.lua'
and argv[1]
or argv[1]..'.lua')
local pat
if fsHas(cd..v) then pat = cd..v
elseif fsHas(v) then pat = v
end
if not pat
then con.println(argv[1].. ': command not found')
else local suc, msg
suc, msg = pcall(select(2,pcall(load, (fsRead(pat)))))
if not suc then con.println 'err'
else suc, msg = pcall(msg, argv, con)
if not suc then con.println(msg) end
end
end
end
return not runs
end)
return sh
end

View file

@ -5,5 +5,7 @@ require 'src.os' (con)
require 'autoexec'
con.println('BP>'.. ('-'):rep(con.w - 6) ..'<BP')
con.getch()
love.event.push 'quit'

View file

@ -12,21 +12,22 @@ function con.keydown(k)
end
function con.popbuf(line)
local v = buf[#buf-1] or ''
if line then
if v:sub(-1) == '\n' then
buf[#buf-1] = ''
return v:sub(1, -2)
end
else
buf[#buf] = bs(buf[#buf])
v = v:sub(1,1)
if not line and buf[#buf]
then return buf[#buf]:sub(1, 1) end
local v = buf[#buf-1]
if not v then return nil end
if v:sub(-1) == '\n' then
buf[#buf-1] = nil
v = v:sub(1, -2)
if not line then v = v:sub(1, 1) end
return v
end
return nil
end
function con.type(text)
buf[#buf] = buf[#buf].. text
buf[#buf] = (buf[#buf] or '').. text
con.print(text)
end