Skip to content

Commit 0f4ecaa

Browse files
TrottMylesBorins
authored andcommitted
repl: standardize Control key indications
Throughout our messages and docs, we refer to the Control key in a surprisingly varied number of ways: * Control * Ctrl * Cntl * varied capitalization on the above (e.g., ctrl vs. Ctrl) Then, in key combinations: * One of the items from the previous list followed by `-` * ... or followed by `+` * ... surrounded or not by `<` and `>` * ... and inside backticks or not * ... or just `^` This is the start of standardization on the formulation recommended by the Microsoft Style Guide (e.g., **Ctrl+C**). PR-URL: #35270 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 86ac749 commit 0f4ecaa

File tree

4 files changed

+27
-24
lines changed

4 files changed

+27
-24
lines changed

doc/api/repl.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ feature set.
3434

3535
The following special commands are supported by all REPL instances:
3636

37-
* `.break`: When in the process of inputting a multi-line expression, entering
38-
the `.break` command (or pressing the `<ctrl>-C` key combination) will abort
37+
* `.break`: When in the process of inputting a multi-line expression, enter
38+
the `.break` command (or press **Ctrl+C**) to abort
3939
further input or processing of that expression.
4040
* `.clear`: Resets the REPL `context` to an empty object and clears any
4141
multi-line expression being input.
@@ -45,7 +45,7 @@ The following special commands are supported by all REPL instances:
4545
`> .save ./file/to/save.js`
4646
* `.load`: Load a file into the current REPL session.
4747
`> .load ./file/to/load.js`
48-
* `.editor`: Enter editor mode (`<ctrl>-D` to finish, `<ctrl>-C` to cancel).
48+
* `.editor`: Enter editor mode (**Ctrl+D** to finish, **Ctrl+C** to cancel).
4949

5050
```console
5151
> .editor
@@ -63,10 +63,10 @@ welcome('Node.js User');
6363

6464
The following key combinations in the REPL have these special effects:
6565

66-
* `<ctrl>-C`: When pressed once, has the same effect as the `.break` command.
66+
* **Ctrl+C**: When pressed once, has the same effect as the `.break` command.
6767
When pressed twice on a blank line, has the same effect as the `.exit`
6868
command.
69-
* `<ctrl>-D`: Has the same effect as the `.exit` command.
69+
* **Ctrl+D**: Has the same effect as the `.exit` command.
7070
* `<tab>`: When pressed on a blank line, displays global and local (scope)
7171
variables. When pressed while entering other input, displays relevant
7272
autocompletion options.
@@ -246,14 +246,14 @@ added: v13.6.0
246246
-->
247247

248248
The REPL supports bi-directional reverse-i-search similar to [ZSH][]. It is
249-
triggered with `<ctrl> + R` to search backward and `<ctrl> + S` to search
250-
forward.
249+
triggered with **Ctrl+R** to search backward and **Ctrl+S** to search
250+
forwards.
251251

252252
Duplicated history entires will be skipped.
253253

254254
Entries are accepted as soon as any button is pressed that doesn't correspond
255-
with the reverse search. Cancelling is possible by pressing `escape` or
256-
`<ctrl> + C`.
255+
with the reverse search. Cancelling is possible by pressing **Esc** or
256+
**Ctrl+C**.
257257

258258
Changing the direction immediately searches for the next entry in the expected
259259
direction from the current position on.
@@ -282,7 +282,7 @@ repl.start({ prompt: '> ', eval: myEval });
282282

283283
#### Recoverable errors
284284

285-
As a user is typing input into the REPL prompt, pressing the `<enter>` key will
285+
As a user is typing input into the REPL prompt, pressing **Enter** will
286286
send the current line of input to the `eval` function. In order to support
287287
multi-line input, the eval function can return an instance of `repl.Recoverable`
288288
to the provided callback function:
@@ -379,8 +379,8 @@ added: v0.7.7
379379
-->
380380

381381
The `'exit'` event is emitted when the REPL is exited either by receiving the
382-
`.exit` command as input, the user pressing `<ctrl>-C` twice to signal `SIGINT`,
383-
or by pressing `<ctrl>-D` to signal `'end'` on the input stream. The listener
382+
`.exit` command as input, the user pressing **Ctrl+C** twice to signal `SIGINT`,
383+
or by pressing **Ctrl+D** to signal `'end'` on the input stream. The listener
384384
callback is invoked without any arguments.
385385

386386
```js

lib/repl.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,9 @@ function REPLServer(prompt,
750750
sawSIGINT = false;
751751
return;
752752
}
753-
self.output.write('(To exit, press ^C again or ^D or type .exit)\n');
753+
self.output.write(
754+
'(To exit, press Ctrl+C again or Ctrl+D or type .exit)\n'
755+
);
754756
sawSIGINT = true;
755757
} else {
756758
sawSIGINT = false;
@@ -815,7 +817,7 @@ function REPLServer(prompt,
815817
if (e && !self[kBufferedCommandSymbol] && cmd.trim().startsWith('npm ')) {
816818
self.output.write('npm should be run outside of the ' +
817819
'Node.js REPL, in your normal shell.\n' +
818-
'(Press Control-D to exit.)\n');
820+
'(Press Ctrl+D to exit.)\n');
819821
self.displayPrompt();
820822
return;
821823
}
@@ -860,7 +862,7 @@ function REPLServer(prompt,
860862
if (self.editorMode) {
861863
self.output.write(`${self._initialPrompt}.editor\n`);
862864
self.output.write(
863-
'// Entering editor mode (^D to finish, ^C to cancel)\n');
865+
'// Entering editor mode (Ctrl+D to finish, Ctrl+C to cancel)\n');
864866
self.output.write(`${self[kBufferedCommandSymbol]}\n`);
865867
self.prompt(true);
866868
} else {
@@ -1542,8 +1544,8 @@ function defineDefaultCommands(repl) {
15421544
const line = `.${name}${cmd.help ? spaces + cmd.help : ''}\n`;
15431545
this.output.write(line);
15441546
}
1545-
this.output.write('\nPress ^C to abort current expression, ' +
1546-
'^D to exit the REPL\n');
1547+
this.output.write('\nPress Ctrl+C to abort current expression, ' +
1548+
'Ctrl+D to exit the REPL\n');
15471549
this.displayPrompt();
15481550
}
15491551
});
@@ -1589,7 +1591,7 @@ function defineDefaultCommands(repl) {
15891591
action() {
15901592
_turnOnEditorMode(this);
15911593
this.output.write(
1592-
'// Entering editor mode (^D to finish, ^C to cancel)\n');
1594+
'// Entering editor mode (Ctrl+D to finish, Ctrl+C to cancel)\n');
15931595
}
15941596
});
15951597
}

test/parallel/test-repl-editor.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ function run({ input, output, event, checkTerminalCodes = true }) {
1919

2020
stream.write = (msg) => found += msg.replace('\r', '');
2121

22-
let expected = `${terminalCode}.editor\n` +
23-
'// Entering editor mode (^D to finish, ^C to cancel)\n' +
24-
`${input}${output}\n${terminalCode}`;
22+
let expected =
23+
`${terminalCode}.editor\n` +
24+
'// Entering editor mode (Ctrl+D to finish, Ctrl+C to cancel)\n' +
25+
`${input}${output}\n${terminalCode}`;
2526

2627
const replServer = repl.start({
2728
prompt: '> ',
@@ -47,7 +48,7 @@ function run({ input, output, event, checkTerminalCodes = true }) {
4748
const tests = [
4849
{
4950
input: '',
50-
output: '\n(To exit, press ^C again or ^D or type .exit)',
51+
output: '\n(To exit, press Ctrl+C again or Ctrl+D or type .exit)',
5152
event: { ctrl: true, name: 'c' }
5253
},
5354
{

test/parallel/test-repl.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ const errorTests = [
373373
send: 'npm install foobar',
374374
expect: [
375375
'npm should be run outside of the Node.js REPL, in your normal shell.',
376-
'(Press Control-D to exit.)'
376+
'(Press Ctrl+D to exit.)'
377377
]
378378
},
379379
{
@@ -453,7 +453,7 @@ const errorTests = [
453453
/\.load/,
454454
/\.save/,
455455
'',
456-
'Press ^C to abort current expression, ^D to exit the REPL',
456+
'Press Ctrl+C to abort current expression, Ctrl+D to exit the REPL',
457457
/'thefourtheye'/
458458
]
459459
},

0 commit comments

Comments
 (0)