rl.write(data[, key])
rl.write()
方法将 data
或 key
标识的按键序列写入 output
。
仅当 output
是 TTY 文本终端时才支持 key
参数。
有快捷键组合的列表,请参见 TTY 快捷键。
如果指定了 key
,则忽略 data
。
当调用时,如果 input
流已暂停,则 rl.write()
将恢复它。
如果 readline.Interface
创建时 output
被设置为 null
或 undefined
,则不会写入 data
和 key
。
rl.write('删除这个!');
// 模拟 Ctrl+U 删除先前写入的行。
rl.write(null, { ctrl: true, name: 'u' });
rl.write()
方法将数据写入 readline
的 Interface
的 input
,就像它是由用户提供的一样。
The rl.write()
method will write either data
or a key sequence identified
by key
to the output
. The key
argument is supported only if output
is
a TTY text terminal. See TTY keybindings for a list of key
combinations.
If key
is specified, data
is ignored.
When called, rl.write()
will resume the input
stream if it has been
paused.
If the readline.Interface
was created with output
set to null
or
undefined
the data
and key
are not written.
rl.write('Delete this!');
// Simulate Ctrl+U to delete the line written previously
rl.write(null, { ctrl: true, name: 'u' });
The rl.write()
method will write the data to the readline
Interface
's
input
as if it were provided by the user.