readStream.setRawMode(mode)
mode<boolean> | <string> 如果true或'raw',会把tty.ReadStream配置为原始设备模式。如果'io',会把tty.ReadStream配置为二进制安全的 I/O 模式。如果false,会把tty.ReadStream配置为默认模式。readStream.isRaw属性会被设置为流是否处于原始模式,而readStream.rawMode属性会被设置为最终的模式。- 返回:<this> 读取流实例。
允许配置 tty.ReadStream,使其作为原始设备运行。
🌐 Allows configuration of tty.ReadStream so that it operates as a raw device.
在原始模式下,输入总是按字符逐个可用,不包括修饰键。此外,终端对输入字符的所有特殊处理都会被禁用,包括回显输入字符。 Ctrl+C 在这种模式下将不再触发 SIGINT。这种模式不会影响终端的输出处理,例如 Unix 终端上的换行转换。
在 Windows 上,setRawMode() 需要对控制台输入缓冲区的写权限。在使用 fs.open() 系列 API 打开 "\\\\.\\CONIN$"(用于传入 new tty.ReadStream())时,确保使用读/写标志,比如 'r+'。
🌐 On Windows, setRawMode() requires write permission to the console input
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+'.
在二进制安全 I/O 模式下,终端输出处理也会被禁用。这对应于 libuv 的 UV_TTY_MODE_IO 模式,并且在 Windows 上不支持。
🌐 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.