OC-PsychOS/modules/lib/readline.lua

21 lines
441 B
Lua
Raw Normal View History

2017-07-30 19:12:10 +10:00
function readln(rC)
local s,si="",os.getenv("sI")
while true do
_,sI,c,C = event.pull("key")
if sI == si then
if c == 13 then
write(" \n")
coroutine.yield()
return s
elseif c == 8 then
if s:len()>0 then s=s:sub(1,-2) write("\127") end
elseif c == 3 and C == 46 then
return false
2017-07-30 19:12:10 +10:00
elseif c > 31 and c < 127 then
s=s..string.char(c) write((rC or string.char(c)))
end
end
end
end
2017-08-01 21:39:10 +10:00
io.read = readln