feat: add Stdin.isRaw property to query and set terminal raw mode on stdin

Add foreign static getter `isRaw` and setter `isRaw=(value)` to the Stdin class, backed by a new `isStdinRaw` boolean flag and `uv_tty_set_mode` calls. The getter returns the current raw mode state, while the setter initializes the stdin stream if needed and applies raw or normal mode only when stdin is a TTY. Also includes a test file verifying default false, reading bytes in normal mode, enabling raw mode, and reading subsequent bytes.
This commit is contained in:
Bob Nystrom
2016-05-20 22:19:18 +00:00
parent 6394e1c486
commit efa97cdccf
6 changed files with 103 additions and 19 deletions
+4
View File
@@ -35,6 +35,8 @@ extern void statSpecialDevice(WrenVM* vm);
extern void statUser(WrenVM* vm);
extern void statIsDirectory(WrenVM* vm);
extern void statIsFile(WrenVM* vm);
extern void stdinIsRaw(WrenVM* vm);
extern void stdinIsRawSet(WrenVM* vm);
extern void stdinReadStart(WrenVM* vm);
extern void stdinReadStop(WrenVM* vm);
extern void schedulerCaptureMethods(WrenVM* vm);
@@ -141,6 +143,8 @@ static ModuleRegistry modules[] =
METHOD("isFile", statIsFile)
END_CLASS
CLASS(Stdin)
STATIC_METHOD("isRaw", stdinIsRaw)
STATIC_METHOD("isRaw=(_)", stdinIsRawSet)
STATIC_METHOD("readStart_()", stdinReadStart)
STATIC_METHOD("readStop_()", stdinReadStop)
END_CLASS