From 600663b23fae09574d36c52b68b20e38f2f0d270 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Mon, 24 Aug 2026 03:52:12 +1200 Subject: [PATCH] tty: add raw-vt and io raw modes Signed-off-by: Samuel Williams PR-URL: https://github.com/nodejs/node/pull/64140 Refs: https://github.com/nodejs/node/issues/63059 Refs: https://github.com/libuv/libuv/issues/32 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat --- doc/api/tty.md | 30 ++++++++++++-- lib/tty.js | 33 +++++++++++++--- src/tty_wrap.cc | 10 +++-- test/pseudo-tty/test-set-raw-mode-modes.js | 43 +++++++++++++++++++++ test/pseudo-tty/test-set-raw-mode-modes.out | 4 ++ 5 files changed, 108 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 cbfb3cc7837..f50848101e0 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'`, 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. @@ -91,6 +97,22 @@ buffer. When opening `"\\\\.\\CONIN$"` with the [`fs.open()`][] family of APIs (for passing into `new tty.ReadStream()`), be sure to use a read/write flag such as `'r+'`. +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'` when raw input mode is enabled, and `'io'` when +binary-safe I/O mode is enabled. + ## Class: `tty.WriteStream`