feat: implement IO.read method with stdin input buffer and prompt support

Add static `IO.read(prompt)` method to the IO class that writes the prompt to stdout
and reads a line from stdin into a 1024-byte buffer. The C implementation uses
`fgets` for input and returns the string via `wrenReturnString`. The Wren wrapper
calls `IO.write` for the prompt before delegating to the native `IO.read` method.
This commit is contained in:
Paul Woolcock
2015-01-02 16:07:43 +00:00
parent 3b63f25690
commit bdede9cd32
2 changed files with 27 additions and 0 deletions
+5
View File
@@ -78,4 +78,9 @@ class IO {
IO.writeString_(obj.toString)
return obj
}
static read(prompt) {
IO.write(prompt)
return IO.read
}
}