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

Implement a new static `IO.read(prompt)` method in the IO class that writes a prompt string to stdout and reads a line from stdin into a fixed 1024-byte buffer. The C implementation adds a `MAX_READ_LEN` constant, an `ioRead` function using `fgets`, and registers the method via `wrenDefineStaticMethod`. The builtin source string is updated to include the new Wren method definition.
This commit is contained in:
Bob Nystrom
2015-01-12 04:05:52 +00:00
2 changed files with 27 additions and 0 deletions
+5
View File
@@ -79,6 +79,11 @@ class IO {
return obj
}
static read(prompt) {
IO.write(prompt)
return IO.read
}
static writeObject_(obj) {
var string = obj.toString
if (string is String) {