mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
fixed a bug where for whatever reason io.read would return 0x0D (CR)
Former-commit-id: 769e2d3931472d14ce66cfef3a496a3913dc51be
This commit is contained in:
@@ -88,21 +88,25 @@ end
|
||||
|
||||
io.read = function(option)
|
||||
if io.__openfile__ == "stdin" then
|
||||
local input = ""
|
||||
local inkey = null -- local variable init REQUIRED!
|
||||
local input = {}
|
||||
|
||||
-- RETURN not hit
|
||||
while inkey ~= 13 do
|
||||
inkey = machine.__readFromStdin()
|
||||
if inkey > 0 then
|
||||
while true do
|
||||
local inkey = machine.__readFromStdin()
|
||||
if inkey == 13 or inkey == 10 then
|
||||
break
|
||||
elseif inkey == 8 or inkey == 127 then
|
||||
io.write(string.char(inkey))
|
||||
input = input..string.char(inkey)
|
||||
table.remove(input)
|
||||
elseif inkey > 0 then
|
||||
io.write(string.char(inkey))
|
||||
table.insert(input, string.char(inkey))
|
||||
end
|
||||
end
|
||||
-- RETURN finally hit
|
||||
io.write("\n")
|
||||
|
||||
return input
|
||||
return table.concat(input)
|
||||
end
|
||||
|
||||
function _readAll()
|
||||
|
||||
Reference in New Issue
Block a user