From 5831aecf60fc16ebe34093d6f56b46af90bc9597 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Fri, 26 Jun 2026 16:05:18 +1200 Subject: [PATCH] tty: add raw-vt and io raw modes --- doc/api/tty.md | 30 ++++++++++++++--- lib/tty.js | 24 +++++++++++--- src/tty_wrap.cc | 10 ++++-- test/pseudo-tty/test-set-raw-mode-modes.js | 36 +++++++++++++++++++++ test/pseudo-tty/test-set-raw-mode-modes.out | 4 +++ 5 files changed, 92 insertions(+), 12 deletions(-) create mode 100644 test/pseudo-tty/test-set-raw-mode-modes.js create mode 100644 test/pseudo-tty/test-set-raw-mode-modes.out diff --git a/doc/api/tty.md b/doc/api/tty.md index 03f86cd66052fd..b626a9ed6218de 100644 --- a/doc/api/tty.md +++ b/doc/api/tty.md @@ -69,12 +69,18 @@ A `boolean` that is always `true` for `tty.ReadStream` instances. -* `mode` {boolean} If `true`, configures the `tty.ReadStream` to operate as a - raw device. If `false`, configures the `tty.ReadStream` to operate in its - default mode. The `readStream.isRaw` property will be set to the resulting - mode. +* `mode` {boolean|string} If `true` or `'raw-vt'`, configures the + `tty.ReadStream` to operate as a raw device. If `'io'`, configures the + `tty.ReadStream` to operate in binary-safe I/O mode. If `false`, configures + the `tty.ReadStream` to operate in its default mode. The `readStream.isRaw` + property will be set to whether the stream is in raw mode, and the + `readStream.rawMode` property will be set to the resulting mode. * Returns: {this} The read stream instance. Allows configuration of `tty.ReadStream` so that it operates as a raw device. @@ -86,6 +92,22 @@ characters. Ctrl+C will no longer cause a `SIGINT` when in this mode. This mode does not affect terminal output processing, such as newline translation on Unix terminals. +When in binary-safe I/O mode, terminal output processing is also disabled. +This corresponds to libuv's `UV_TTY_MODE_IO` mode and is not supported on +Windows. + +### `readStream.rawMode` + + + +* {boolean|string} + +The current raw mode for the `tty.ReadStream`. This is `false` when the stream +is in its default mode, `'raw-vt'` when raw input mode is enabled, and `'io'` +when binary-safe I/O mode is enabled. + ## Class: `tty.WriteStream`