From eec4a5b67186dc81696393e88f609f8fa640a4d6 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 19 Sep 2020 08:35:27 -0700 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/35270 Reviewed-By: Ruben Bridgewater --- doc/api/repl.md | 24 ++++++++++++------------ lib/repl.js | 14 ++++++++------ test/parallel/test-repl-editor.js | 9 +++++---- test/parallel/test-repl.js | 4 ++-- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/doc/api/repl.md b/doc/api/repl.md index 63879d26168d59..7c16a9c266784d 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. @@ -248,14 +248,14 @@ added: --> 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. @@ -284,7 +284,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: @@ -381,8 +381,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 aeef91e5e6d838..f60a49b3f49d43 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -726,7 +726,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; @@ -791,7 +793,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; } @@ -836,7 +838,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 { @@ -1508,8 +1510,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(); } }); @@ -1555,7 +1557,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 3cd4f35b011ca2..10a7e5ab189bba 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'/ ] },