Make io.read() support support not breaking

If false is passed as second param to io.read() it now will
not perform a line break after hitting return
This commit is contained in:
Kilobyte22 2014-07-06 18:05:16 +02:00
parent cd2c5b5977
commit d8ee287c96
2 changed files with 5 additions and 5 deletions

View File

@ -21,8 +21,8 @@ end
stdoutStream.close = stdinStream.close
stderrStream.close = stdinStream.close
function stdinStream:read(n)
local result = term.read(stdinHistory)
function stdinStream:read(n, dowrap)
local result = term.read(stdinHistory, dowrap)
while #stdinHistory > 10 do
table.remove(stdinHistory, 1)
end

View File

@ -80,7 +80,7 @@ function term.isAvailable()
return component.isAvailable("gpu") and component.isAvailable("screen")
end
function term.read(history)
function term.read(history, dobreak)
checkArg(1, history, "table", "nil")
history = history or {}
table.insert(history, "")
@ -286,7 +286,7 @@ function term.read(history)
table.remove(history)
end
term.setCursorBlink(false)
if term.getCursor() > 1 then
if term.getCursor() > 1 and dobreak ~= false then
print()
end
end