my try. ugly but work
error = function(s)
console.writecolor("red", s.."\n")
end
run = function(s)
local f = load(s)
local f2 = load('print('..s..')')
local result, reason = pcall(f)
if result == false then
local result2, reason2 = pcall(f2)
if result2 == false then
error(reason)
end
end
end
Home = "G"
End = "O"
Up = "H"
Down = "P"
Left = "K"
Right = "M"
Delete = "S"
Back = "\b"
Esc = "\027"
Return = "\r"
Enter = Return
function get_line()
text = ""
repeat
local key, special = console.readchar()
if special == true then
if key == Home then
console.write("\r"..string.rep (" ", 120).."\r")
text = ""
elseif key == Delete then
console.write('\b \b')
text = text:sub(1, -2)
end
else
if key == Esc then
console.write("\r"..string.rep (" ", 110).."\r")
text = ""
elseif key == Back then
console.write('\b \b')
text = text:sub(1, -2)
else
console.write(key)
text = text..key
end
end
until key == Enter
print()
return text
end
repeat
text = get_line()
run(text)
until text == Enter