Compare commits

...

2 Commits

Author SHA1 Message Date
928a1db13c colours in the shell! 2020-03-26 14:41:06 +11:00
eccc80ad16 added tab support to the terminal emulator 2020-03-25 07:08:17 +11:00
2 changed files with 5 additions and 2 deletions

View File

@ -22,17 +22,18 @@ function shell.interactive()
local shenv = setmetatable({}, {__index=shindex})
local run = true
while run do
io.write(string.format("%s:%s> ",os.getenv("HOSTNAME") or "localhost",(os.getenv("PWD") or _VERSION)))
io.write(string.format("\27[32m%s:%s>\27[0m ",os.getenv("HOSTNAME") or "localhost",(os.getenv("PWD") or _VERSION)))
local input = io.read()
if input:sub(1,1) == "=" then
input = "return "..input:sub(2)
end
local f, r = load(input, "shell", "t", shenv)
if not f then
print(r)
print("\27[31m"..r)
else
local rt = {pcall(f)}
local rs = table.remove(rt,1)
if not rs then io.write("\27[31m") end
for k,v in pairs(rt) do
print(formatValue(v))
end

View File

@ -31,6 +31,8 @@ function vt100emu(gpu) -- takes GPU component proxy *gpu* and returns a function
cx = 1
elseif cc == "\27" then -- escape
mode = "e"
elseif cc == "\t" then
cx = 8*((cx+9)//8)
elseif string.byte(cc) > 31 and string.byte(cc) < 127 then -- printable, I guess
gpu.set(cx, cy, cc)
cx = cx + 1