diff --git a/doc/api/repl.md b/doc/api/repl.md index fe8115a9536377..a194cf05a8148a 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -34,8 +34,8 @@ feature set. The following special commands are supported by all REPL instances: -* `.break`: When in the process of inputting a multi-line expression, entering - the `.break` command (or pressing the `-C` key combination) will abort +* `.break`: When in the process of inputting a multi-line expression, enter + the `.break` command (or press **Ctrl+C**) to abort further input or processing of that expression. * `.clear`: Resets the REPL `context` to an empty object and clears any multi-line expression being input. @@ -45,7 +45,7 @@ The following special commands are supported by all REPL instances: `> .save ./file/to/save.js` * `.load`: Load a file into the current REPL session. `> .load ./file/to/load.js` -* `.editor`: Enter editor mode (`-D` to finish, `-C` to cancel). +* `.editor`: Enter editor mode (**Ctrl+D** to finish, **Ctrl+C** to cancel). ```console > .editor @@ -63,10 +63,10 @@ welcome('Node.js User'); The following key combinations in the REPL have these special effects: -* `-C`: When pressed once, has the same effect as the `.break` command. +* **Ctrl+C**: When pressed once, has the same effect as the `.break` command. When pressed twice on a blank line, has the same effect as the `.exit` command. -* `-D`: Has the same effect as the `.exit` command. +* **Ctrl+D**: Has the same effect as the `.exit` command. * ``: When pressed on a blank line, displays global and local (scope) variables. When pressed while entering other input, displays relevant autocompletion options. @@ -246,14 +246,14 @@ added: v13.6.0 --> The REPL supports bi-directional reverse-i-search similar to [ZSH][]. It is -triggered with ` + R` to search backward and ` + S` to search -forward. +triggered with **Ctrl+R** to search backward and **Ctrl+S** to search +forwards. Duplicated history entires will be skipped. Entries are accepted as soon as any button is pressed that doesn't correspond -with the reverse search. Cancelling is possible by pressing `escape` or -` + C`. +with the reverse search. Cancelling is possible by pressing **Esc** or +**Ctrl+C**. Changing the direction immediately searches for the next entry in the expected direction from the current position on. @@ -282,7 +282,7 @@ repl.start({ prompt: '> ', eval: myEval }); #### Recoverable errors -As a user is typing input into the REPL prompt, pressing the `` key will +As a user is typing input into the REPL prompt, pressing **Enter** will send the current line of input to the `eval` function. In order to support multi-line input, the eval function can return an instance of `repl.Recoverable` to the provided callback function: @@ -379,8 +379,8 @@ added: v0.7.7 --> The `'exit'` event is emitted when the REPL is exited either by receiving the -`.exit` command as input, the user pressing `-C` twice to signal `SIGINT`, -or by pressing `-D` to signal `'end'` on the input stream. The listener +`.exit` command as input, the user pressing **Ctrl+C** twice to signal `SIGINT`, +or by pressing **Ctrl+D** to signal `'end'` on the input stream. The listener callback is invoked without any arguments. ```js diff --git a/lib/repl.js b/lib/repl.js index b13fece0713701..d178dbcefea43b 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -750,7 +750,9 @@ function REPLServer(prompt, sawSIGINT = false; return; } - self.output.write('(To exit, press ^C again or ^D or type .exit)\n'); + self.output.write( + '(To exit, press Ctrl+C again or Ctrl+D or type .exit)\n' + ); sawSIGINT = true; } else { sawSIGINT = false; @@ -815,7 +817,7 @@ function REPLServer(prompt, if (e && !self[kBufferedCommandSymbol] && cmd.trim().startsWith('npm ')) { self.output.write('npm should be run outside of the ' + 'Node.js REPL, in your normal shell.\n' + - '(Press Control-D to exit.)\n'); + '(Press Ctrl+D to exit.)\n'); self.displayPrompt(); return; } @@ -860,7 +862,7 @@ function REPLServer(prompt, if (self.editorMode) { self.output.write(`${self._initialPrompt}.editor\n`); self.output.write( - '// Entering editor mode (^D to finish, ^C to cancel)\n'); + '// Entering editor mode (Ctrl+D to finish, Ctrl+C to cancel)\n'); self.output.write(`${self[kBufferedCommandSymbol]}\n`); self.prompt(true); } else { @@ -1542,8 +1544,8 @@ function defineDefaultCommands(repl) { const line = `.${name}${cmd.help ? spaces + cmd.help : ''}\n`; this.output.write(line); } - this.output.write('\nPress ^C to abort current expression, ' + - '^D to exit the REPL\n'); + this.output.write('\nPress Ctrl+C to abort current expression, ' + + 'Ctrl+D to exit the REPL\n'); this.displayPrompt(); } }); @@ -1589,7 +1591,7 @@ function defineDefaultCommands(repl) { action() { _turnOnEditorMode(this); this.output.write( - '// Entering editor mode (^D to finish, ^C to cancel)\n'); + '// Entering editor mode (Ctrl+D to finish, Ctrl+C to cancel)\n'); } }); } diff --git a/test/parallel/test-repl-editor.js b/test/parallel/test-repl-editor.js index 41685f06e72c06..783d303b3aaf16 100644 --- a/test/parallel/test-repl-editor.js +++ b/test/parallel/test-repl-editor.js @@ -19,9 +19,10 @@ function run({ input, output, event, checkTerminalCodes = true }) { stream.write = (msg) => found += msg.replace('\r', ''); - let expected = `${terminalCode}.editor\n` + - '// Entering editor mode (^D to finish, ^C to cancel)\n' + - `${input}${output}\n${terminalCode}`; + let expected = + `${terminalCode}.editor\n` + + '// Entering editor mode (Ctrl+D to finish, Ctrl+C to cancel)\n' + + `${input}${output}\n${terminalCode}`; const replServer = repl.start({ prompt: '> ', @@ -47,7 +48,7 @@ function run({ input, output, event, checkTerminalCodes = true }) { const tests = [ { input: '', - output: '\n(To exit, press ^C again or ^D or type .exit)', + output: '\n(To exit, press Ctrl+C again or Ctrl+D or type .exit)', event: { ctrl: true, name: 'c' } }, { diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 8e3d1173b51131..e200ebbaeee4ea 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -373,7 +373,7 @@ const errorTests = [ send: 'npm install foobar', expect: [ 'npm should be run outside of the Node.js REPL, in your normal shell.', - '(Press Control-D to exit.)' + '(Press Ctrl+D to exit.)' ] }, { @@ -453,7 +453,7 @@ const errorTests = [ /\.load/, /\.save/, '', - 'Press ^C to abort current expression, ^D to exit the REPL', + 'Press Ctrl+C to abort current expression, Ctrl+D to exit the REPL', /'thefourtheye'/ ] },