Skip to content

Commit

Permalink
doc: use kbd element in readline doc
Browse files Browse the repository at this point in the history
PR-URL: #35698
Reviewed-By: Daijiro Wachi <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
  • Loading branch information
Trott authored and BethGriggs committed Dec 10, 2020
1 parent 0fa58fb commit d900015
Showing 1 changed file with 48 additions and 46 deletions.
94 changes: 48 additions & 46 deletions doc/api/readline.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ The `'close'` event is emitted when one of the following occur:
* The `rl.close()` method is called and the `readline.Interface` instance has
relinquished control over the `input` and `output` streams;
* The `input` stream receives its `'end'` event;
* The `input` stream receives `<ctrl>-D` to signal end-of-transmission (EOT);
* The `input` stream receives `<ctrl>-C` to signal `SIGINT` and there is no
`'SIGINT'` event listener registered on the `readline.Interface` instance.
* The `input` stream receives <kbd>Ctrl</kbd>+<kbd>D</kbd> to signal
end-of-transmission (EOT);
* The `input` stream receives <kbd>Ctrl</kbd>+<kbd>C</kbd> to signal `SIGINT`
and there is no `'SIGINT'` event listener registered on the
`readline.Interface` instance.

The listener function is called without passing any arguments.

Expand Down Expand Up @@ -126,8 +128,8 @@ added: v0.7.5
-->

The `'SIGCONT'` event is emitted when a Node.js process previously moved into
the background using `<ctrl>-Z` (i.e. `SIGTSTP`) is then brought back to the
foreground using fg(1p).
the background using <kbd>Ctrl</kbd>+<kbd>Z</kbd> (i.e. `SIGTSTP`) is then
brought back to the foreground using fg(1p).

If the `input` stream was paused *before* the `SIGTSTP` request, this event will
not be emitted.
Expand All @@ -149,9 +151,9 @@ added: v0.3.0
-->

The `'SIGINT'` event is emitted whenever the `input` stream receives a
`<ctrl>-C` input, known typically as `SIGINT`. If there are no `'SIGINT'` event
listeners registered when the `input` stream receives a `SIGINT`, the `'pause'`
event will be emitted.
<kbd>Ctrl+C</kbd> input, known typically as `SIGINT`. If there are no `'SIGINT'`
event listeners registered when the `input` stream receives a `SIGINT`, the
`'pause'` event will be emitted.

The listener function is invoked without passing any arguments.

Expand All @@ -168,10 +170,10 @@ rl.on('SIGINT', () => {
added: v0.7.5
-->

The `'SIGTSTP'` event is emitted when the `input` stream receives a `<ctrl>-Z`
input, typically known as `SIGTSTP`. If there are no `'SIGTSTP'` event listeners
registered when the `input` stream receives a `SIGTSTP`, the Node.js process
will be sent to the background.
The `'SIGTSTP'` event is emitted when the `input` stream receives a
<kbd>Ctrl</kbd>+<kbd>Z</kbd> input, typically known as `SIGTSTP`. If there are
no `'SIGTSTP'` event listeners registered when the `input` stream receives a
`SIGTSTP`, the Node.js process will be sent to the background.

When the program is resumed using fg(1p), the `'pause'` and `'SIGCONT'` events
will be emitted. These can be used to resume the `input` stream.
Expand Down Expand Up @@ -288,9 +290,9 @@ added: v0.1.98

* `data` {string}
* `key` {Object}
* `ctrl` {boolean} `true` to indicate the `<ctrl>` key.
* `meta` {boolean} `true` to indicate the `<Meta>` key.
* `shift` {boolean} `true` to indicate the `<Shift>` key.
* `ctrl` {boolean} `true` to indicate the <kbd>Ctrl</kbd> key.
* `meta` {boolean} `true` to indicate the <kbd>Meta</kbd> key.
* `shift` {boolean} `true` to indicate the <kbd>Shift</kbd> key.
* `name` {string} The name of the a key.

The `rl.write()` method will write either `data` or a key sequence identified
Expand All @@ -308,7 +310,7 @@ If the `readline.Interface` was created with `output` set to `null` or

```js
rl.write('Delete this!');
// Simulate Ctrl+u to delete the line written previously
// Simulate Ctrl+U to delete the line written previously
rl.write(null, { ctrl: true, name: 'u' });
```

Expand Down Expand Up @@ -751,117 +753,117 @@ const { createInterface } = require('readline');
<th>Notes</th>
</tr>
<tr>
<td><code>ctrl</code> + <code>shift</code> + <code>backspace</code></td>
<td><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Backspace</kbd></td>
<td>Delete line left</td>
<td>Doesn't work on Linux, Mac and Windows</td>
</tr>
<tr>
<td><code>ctrl</code> + <code>shift</code> + <code>delete</code></td>
<td><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Delete</kbd></td>
<td>Delete line right</td>
<td>Doesn't work on Mac</td>
</tr>
<tr>
<td><code>ctrl</code> + <code>c</code></td>
<td><kbd>Ctrl</kbd>+<kbd>C</kbd></td>
<td>Emit <code>SIGINT</code> or close the readline instance</td>
<td></td>
</tr>
<tr>
<td><code>ctrl</code> + <code>h</code></td>
<td><kbd>Ctrl</kbd>+<kbd>H</kbd></td>
<td>Delete left</td>
<td></td>
</tr>
<tr>
<td><code>ctrl</code> + <code>d</code></td>
<td><kbd>Ctrl</kbd>+<kbd>D</kbd></td>
<td>Delete right or close the readline instance in case the current line is empty / EOF</td>
<td>Doesn't work on Windows</td>
</tr>
<tr>
<td><code>ctrl</code> + <code>u</code></td>
<td><kbd>Ctrl</kbd>+<kbd>U</kbd></td>
<td>Delete from the current position to the line start</td>
<td></td>
</tr>
<tr>
<td><code>ctrl</code> + <code>k</code></td>
<td><kbd>Ctrl</kbd>+<kbd>K</kbd></td>
<td>Delete from the current position to the end of line</td>
<td></td>
</tr>
<tr>
<td><code>ctrl</code> + <code>a</code></td>
<td><kbd>Ctrl</kbd>+<kbd>A</kbd></td>
<td>Go to start of line</td>
<td></td>
</tr>
<tr>
<td><code>ctrl</code> + <code>e</code></td>
<td><kbd>Ctrl</kbd>+<kbd>E</kbd></td>
<td>Go to to end of line</td>
<td></td>
</tr>
<tr>
<td><code>ctrl</code> + <code>b</code></td>
<td><kbd>Ctrl</kbd>+<kbd>B</kbd></td>
<td>Back one character</td>
<td></td>
</tr>
<tr>
<td><code>ctrl</code> + <code>f</code></td>
<td><kbd>Ctrl</kbd>+<kbd>F</kbd></td>
<td>Forward one character</td>
<td></td>
</tr>
<tr>
<td><code>ctrl</code> + <code>l</code></td>
<td><kbd>Ctrl</kbd>+<kbd>L</kbd></td>
<td>Clear screen</td>
<td></td>
</tr>
<tr>
<td><code>ctrl</code> + <code>n</code></td>
<td><kbd>Ctrl</kbd>+<kbd>N</kbd></td>
<td>Next history item</td>
<td></td>
</tr>
<tr>
<td><code>ctrl</code> + <code>p</code></td>
<td><kbd>Ctrl</kbd>+<kbd>P</kbd></td>
<td>Previous history item</td>
<td></td>
</tr>
<tr>
<td><code>ctrl</code> + <code>z</code></td>
<td><kbd>Ctrl</kbd>+<kbd>Z</kbd></td>
<td>Moves running process into background. Type
<code>fg</code> and press <code>enter</code>
<code>fg</code> and press <kbd>Enter</kbd>
to return.</td>
<td>Doesn't work on Windows</td>
</tr>
<tr>
<td><code>ctrl</code> + <code>w</code> or <code>ctrl</code>
+ <code>backspace</code></td>
<td><kbd>Ctrl</kbd>+<kbd>W</kbd> or <kbd>Ctrl</kbd>
+<kbd>Backspace</kbd></td>
<td>Delete backward to a word boundary</td>
<td><code>ctrl</code> + <code>backspace</code> Doesn't
<td><kbd>Ctrl</kbd>+<kbd>Backspace</kbd> Doesn't
work on Linux, Mac and Windows</td>
</tr>
<tr>
<td><code>ctrl</code> + <code>delete</code></td>
<td><kbd>Ctrl</kbd>+<kbd>Delete</kbd></td>
<td>Delete forward to a word boundary</td>
<td>Doesn't work on Mac</td>
</tr>
<tr>
<td><code>ctrl</code> + <code>left</code> or
<code>meta</code> + <code>b</code></td>
<td><kbd>Ctrl</kbd>+<kbd>Left arrow</kbd> or
<kbd>Meta</kbd>+<kbd>B</kbd></td>
<td>Word left</td>
<td><code>ctrl</code> + <code>left</code> Doesn't work
<td><kbd>Ctrl</kbd>+<kbd>Left arrow</kbd> Doesn't work
on Mac</td>
</tr>
<tr>
<td><code>ctrl</code> + <code>right</code> or
<code>meta</code> + <code>f</code></td>
<td><kbd>Ctrl</kbd>+<kbd>Right arrow</kbd> or
<kbd>Meta</kbd>+<kbd>F</kbd></td>
<td>Word right</td>
<td><code>ctrl</code> + <code>right</code> Doesn't work
<td><kbd>Ctrl</kbd>+<kbd>Right arrow</kbd> Doesn't work
on Mac</td>
</tr>
<tr>
<td><code>meta</code> + <code>d</code> or <code>meta</code>
+ <code>delete</code></td>
<td><kbd>Meta</kbd>+<kbd>D</kbd> or <kbd>Meta</kbd>
+<kbd>Delete</kbd></td>
<td>Delete word right</td>
<td><code>meta</code> + <code>delete</code> Doesn't work
<td><kbd>Meta</kbd>+<kbd>Delete</kbd> Doesn't work
on windows</td>
</tr>
<tr>
<td><code>meta</code> + <code>backspace</code></td>
<td><kbd>Meta</kbd>+<kbd>Backspace</kbd></td>
<td>Delete word left</td>
<td>Doesn't work on Mac</td>
</tr>
Expand Down

0 comments on commit d900015

Please sign in to comment.