working commands again, terminal fixes
This commit is contained in:
parent
b080d64053
commit
d917aad352
3 changed files with 35 additions and 15 deletions
25
A/ccp.lua
25
A/ccp.lua
|
@ -72,20 +72,37 @@ await(function()
|
||||||
end
|
end
|
||||||
con.print '\n'
|
con.print '\n'
|
||||||
|
|
||||||
elseif argv[1]:match '%u:' then
|
elseif argv[1]:match '^%u:$' then
|
||||||
cd = argv[1]
|
cd = argv[1]
|
||||||
|
|
||||||
elseif argv[1]:lower() == 'type' then
|
elseif argv[1]:lower() == 'type' then
|
||||||
con.print(fsRead(argv[2]))
|
con.print(fsRead(argv[2]))
|
||||||
con.print '\n'
|
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
|
end
|
||||||
|
|
||||||
return not runs
|
return not runs
|
||||||
end)
|
end)
|
||||||
|
|
||||||
return sh
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
2
main.lua
2
main.lua
|
@ -5,5 +5,7 @@ require 'src.os' (con)
|
||||||
|
|
||||||
require 'autoexec'
|
require 'autoexec'
|
||||||
|
|
||||||
|
con.println('BP>'.. ('-'):rep(con.w - 6) ..'<BP')
|
||||||
|
|
||||||
con.getch()
|
con.getch()
|
||||||
love.event.push 'quit'
|
love.event.push 'quit'
|
||||||
|
|
|
@ -12,21 +12,22 @@ function con.keydown(k)
|
||||||
end
|
end
|
||||||
|
|
||||||
function con.popbuf(line)
|
function con.popbuf(line)
|
||||||
local v = buf[#buf-1] or ''
|
if not line and buf[#buf]
|
||||||
if line then
|
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
|
if v:sub(-1) == '\n' then
|
||||||
buf[#buf-1] = ''
|
buf[#buf-1] = nil
|
||||||
return v:sub(1, -2)
|
v = v:sub(1, -2)
|
||||||
|
if not line then v = v:sub(1, 1) end
|
||||||
|
return v
|
||||||
end
|
end
|
||||||
else
|
|
||||||
buf[#buf] = bs(buf[#buf])
|
|
||||||
v = v:sub(1,1)
|
|
||||||
end
|
|
||||||
return nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function con.type(text)
|
function con.type(text)
|
||||||
buf[#buf] = buf[#buf].. text
|
buf[#buf] = (buf[#buf] or '').. text
|
||||||
con.print(text)
|
con.print(text)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue