Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: document readline keybindings #20825

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion doc/api/readline.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ added: v0.1.98

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.
a [TTY][] text terminal. See [`TTY keybindings`][] for a list of covered key
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: remove "covered"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

combinations.

If `key` is specified, `data` is ignored.

Expand Down Expand Up @@ -535,3 +536,4 @@ rl.on('line', (line) => {
[TTY]: tty.html
[Writable]: stream.html#stream_writable_streams
[reading files]: #readline_example_read_file_stream_line_by_line
[`TTY keybindings`]: tty.html#tty_tty_keybindings
102 changes: 102 additions & 0 deletions doc/api/tty.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,109 @@ The `tty.isatty()` method returns `true` if the given `fd` is associated with
a TTY and `false` if it is not, including whenever `fd` is not a non-negative
integer.

## TTY keybindings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we document these in the readline doc? While a TTY is required for most of these, they shouldonly affect readline behaviour

Copy link
Member

@BridgeAR BridgeAR May 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it would be fine to add a reference to those in the repl and in here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@addaleax @BridgeAR just to be clear, I'll add the table of keybindings in the readline doc and ref the table in REPL and TTY doc.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shobhitchittora Yes, that’s the idea (although I don’t really understand why this would be added to the TTY doc)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@addaleax I saw this code in readline -

Interface.prototype.write = function(d, key) {
  if (this.paused) this.resume();
  this.terminal ? this._ttyWrite(d, key) : this._normalWrite(d);
};

and thought that TTY case need a doc. But yeah we can have the table in readline doc and ref it in REPL and / or TTY.

Need you opinion on this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, exactly – it’s code in readline. :) We should point out that these codes apply only for TTYs, but it’s not something that’s interesting for code that uses TTYs in general.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@addaleax you are right, the TTY docs are actually the wrong place for this. The repl should have a reference however.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


<table>
<tr>
<th>Keybindings</th>
<th>Description</th>
</tr>
<tr>
<td><code>ctrl+shift+backspace</code></td>
<td>delete line left</td>
</tr>
<tr>
<td><code>ctrl+shift+delete</code></td>
<td>delete line right</td>
</tr>
<tr>
<td><code>ctrl+c</code></td>
<td>emits SIGINT</td>
</tr>
<tr>
<td><code>ctrl+h</code></td>
<td>delete left</td>
</tr>
<tr>
<td><code>ctrl+d</code></td>
<td>delete right or EOF</td>
</tr>
<tr>
<td><code>ctrl+u</code></td>
<td>delete from current to line start</td>
</tr>
<tr>
<td><code>ctrl+k</code></td>
<td>delete from current to end of line</td>
</tr>
<tr>
<td><code>ctrl+a</code></td>
<td>goto start of line</td>
</tr>
<tr>
<td><code>ctrl+e</code></td>
<td>goto to end of line</td>
</tr>
<tr>
<td><code>ctrl+b</code></td>
<td>back one character</td>
</tr>
<tr>
<td><code>ctrl+f</code></td>
<td>forward one character</td>
</tr>
<tr>
<td><code>ctrl+l</code></td>
<td>clear screen </td>
</tr>
<tr>
<td><code>ctrl+n</code></td>
<td>next history item</td>
</tr>
<tr>
<td><code>ctrl+p</code></td>
<td>prev history item </td>
</tr>
<tr>
<td><code>ctrl+z</code></td>
<td>(need clarification)</td>
</tr>
<tr>
<td><code>ctrl+w</code> or <code>ctrl+backspace</code></td>
<td>delete backwards to a word boundary</td>
</tr>
<tr>
<td><code>ctrl+delete</code></td>
<td>delete forward to a word boundary</td>
</tr>
<tr>
<td><code>ctrl+left</code></td>
<td>word left </td>
</tr>
<tr>
<td><code>ctrl+right</code></td>
<td>word right</td>
</tr>
<tr>
<td><code>meta+b</code></td>
<td>word left</td>
</tr>
<tr>
<td><code>meta+f</code></td>
<td>word right</td>
</tr>
<tr>
<td><code>meta+d</code> or <code>meta+delete</code></td>
<td>delete word right</td>
</tr>
<tr>
<td><code>meta+backspace</code></td>
<td>delete word left </td>
</tr>
</table>

[`net.Socket`]: net.html#net_class_net_socket
[`process.stdin`]: process.html#process_process_stdin
[`process.stdout`]: process.html#process_process_stdout
[`process.stderr`]: process.html#process_process_stderr
[`TTY keybindings`]: #tty_tty_keybindings