feat: add Stdin.isTerminal method to detect TTY connection
Add a new `isTerminal` static method to the Stdin class that returns `true` when stdin is connected to a TTY (interactive terminal) and `false` when input comes from a pipe. Implementation uses libuv's `uv_guess_handle` to check the stdin descriptor. Includes documentation, foreign method declaration, module registration, and a test expecting `false` since tests run non-interactively.
This commit is contained in:
@@ -39,6 +39,7 @@ extern void statIsDirectory(WrenVM* vm);
|
||||
extern void statIsFile(WrenVM* vm);
|
||||
extern void stdinIsRaw(WrenVM* vm);
|
||||
extern void stdinIsRawSet(WrenVM* vm);
|
||||
extern void stdinIsTerminal(WrenVM* vm);
|
||||
extern void stdinReadStart(WrenVM* vm);
|
||||
extern void stdinReadStop(WrenVM* vm);
|
||||
extern void schedulerCaptureMethods(WrenVM* vm);
|
||||
@@ -147,6 +148,7 @@ static ModuleRegistry modules[] =
|
||||
CLASS(Stdin)
|
||||
STATIC_METHOD("isRaw", stdinIsRaw)
|
||||
STATIC_METHOD("isRaw=(_)", stdinIsRawSet)
|
||||
STATIC_METHOD("isTerminal", stdinIsTerminal)
|
||||
STATIC_METHOD("readStart_()", stdinReadStart)
|
||||
STATIC_METHOD("readStop_()", stdinReadStop)
|
||||
END_CLASS
|
||||
|
||||
Reference in New Issue
Block a user