mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
node:tty: use terminal VT mode on Windows (#21161)
mirrors: https://github.com/nodejs/node/pull/58358
This commit is contained in:
@@ -1471,6 +1471,7 @@ pub const struct_uv_tty_s = extern struct {
|
||||
normal = 0,
|
||||
raw = 1,
|
||||
io = 2,
|
||||
vt = 3,
|
||||
};
|
||||
|
||||
pub fn setMode(this: *uv_tty_t, mode: Mode) ReturnCode {
|
||||
|
||||
@@ -224,7 +224,11 @@ export fn Source__setRawModeStdin(raw: bool) c_int {
|
||||
.result => |tty| tty,
|
||||
.err => |e| return e.errno,
|
||||
};
|
||||
if (tty.setMode(if (raw) .raw else .normal).toError(.uv_tty_set_mode)) |err| {
|
||||
// UV_TTY_MODE_RAW_VT is a variant of UV_TTY_MODE_RAW that enables control sequence processing on the TTY implementer side,
|
||||
// rather than having libuv translate keypress events into control sequences, aligning behavior more closely with
|
||||
// POSIX platforms. This is also required to support some control sequences at all on Windows, such as bracketed paste mode.
|
||||
// The Node.js readline implementation handles differences between these modes.
|
||||
if (tty.setMode(if (raw) .vt else .normal).toError(.uv_tty_set_mode)) |err| {
|
||||
return err.errno;
|
||||
}
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user