erdos/src/term/get.lua

32 lines
492 B
Lua

return function(con)
-- KostylLand
--- Special for (almost) terminal
--- (c) Er2 2022 <er2@dismail.de>
local function updK()
__run(true)
end
function con.getch(tout)
local t, ch = os.time(), nil
while ch == nil and ACTIVE do
updK()
ch = con.popbuf(false)
if tout and os.time() - t >= tout
then break end
end
return ch or ''
end
function con.getln()
local ln
while ln == nil and ACTIVE do
updK()
ln = con.popbuf(true)
end
return ln or ''
end
end