Skip to content

doc: document readline keybindings - #20825

Closed
shobhitchittora wants to merge 7 commits into
nodejs:masterfrom
shobhitchittora:doc-tty-keybindings
Closed

doc: document readline keybindings#20825
shobhitchittora wants to merge 7 commits into
nodejs:masterfrom
shobhitchittora:doc-tty-keybindings

Conversation

@shobhitchittora

Copy link
Copy Markdown
Contributor

Closes: #20814

  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Affected subsystem(s)

doc

@nodejs-github-botnodejs-github-bot added the doc Issues and PRs related to the documentations. label May 18, 2018
Comment threaddoc/api/tty.md Outdated
a TTY and `false` if it is not, including whenever `fd` is not a non-negative
integer.

## TTY keybindings

Copy link
Copy Markdown
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

@BridgeARBridgeARMay 19, 2018

Copy link
Copy Markdown
Member

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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Done.

@vsemozhetbytvsemozhetbyt added the readline Issues and PRs related to the built-in readline module. label May 19, 2018
@richardlau

Copy link
Copy Markdown
Member

Nit: handled is misspelled in the commit message. Alternatively maybe use the shorter doc: document readline keybindings.

@shobhitchittorashobhitchittora changed the title doc: adds handeled tty write keybindingsdoc: document readline keybindingsMay 20, 2018
Comment threaddoc/api/readline.md Outdated
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
Copy Markdown
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
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Done.

1. Adds ref in repl doc
2. Removes ref from tty doc
Closes: nodejs#20814
@shobhitchittora

Copy link
Copy Markdown
ContributorAuthor

@addaleax@Trott is TTY keybindings fine or the bindings should be named Special keys?

Comment threaddoc/api/repl.md Outdated
[`util.inspect()`]: util.html#util_util_inspect_object_options
[curl(1)]: https://curl.haxx.se/docs/manpage.html
[stream]: stream.html
[`TTY keybindings`]: readline.html#readline_tty_keybindings

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems we do not need backticks in this case (this is not a code fragment). So this should be [TTY keybindings] and go before the [curl(1)]: (as per ASCII sorting we use in reference lists).

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done.

Comment threaddoc/api/tty.md Outdated
[`process.stdin`]: process.html#process_process_stdin
[`process.stdout`]: process.html#process_process_stdout
[`process.stderr`]: process.html#process_process_stderr
[`process.stderr`]: process.html#process_process_stderr No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing line break at the end of the file?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done

Comment threaddoc/api/repl.md Outdated
variables. When pressed while entering other input, displays relevant
autocompletion options.

For a full list of special keys, refer [`TTY keybindings`][].

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

refer -> refer to?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done

Comment threaddoc/api/readline.md Outdated
[TTY]: tty.html
[Writable]: stream.html#stream_writable_streams
[reading files]: #readline_example_read_file_stream_line_by_line
[`TTY keybindings`]: #readline_tty_keybindings

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems we do not need backticks in this case (this is not a code fragment). So this should be [TTY keybindings] and go after the [TTY]: (as per ASCII sorting we use in reference lists).

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We need the same fix in the text)

Comment threaddoc/api/readline.md Outdated
</tr>
<tr>
<td><code>ctrl+c</code></td>
<td>emits SIGINT</td>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

emits -> emit for consistency with other cells?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done

Comment threaddoc/api/readline.md Outdated
</tr>
<tr>
<td><code>ctrl+a</code></td>
<td>goto start of line</td>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

goto -> go to?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done

Comment threaddoc/api/readline.md Outdated
</tr>
<tr>
<td><code>ctrl+e</code></td>
<td>goto to end of line</td>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

goto to -> go to?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done

Comment threaddoc/api/readline.md Outdated
</tr>
<tr>
<td><code>ctrl+p</code></td>
<td>prev history item </td>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

prev -> previous for more formal style?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done.

@vsemozhetbyt

Copy link
Copy Markdown
Contributor

Should we note that some bindings are OS-dependent? For example, these seem to not work for me on Windows as documented (tested in REPL): ctrl+shift+backspace, ctrl+u, ctrl+backspace, meta+delete (i.e. win+delete).

1. typo fix
2. adding new lines
Closes: nodejs#20814
@shobhitchittora

Copy link
Copy Markdown
ContributorAuthor

@vsemozhetbyt I think it'd be great if we can do that. Unfortunately I don't have a windows system and cannot verify bindings for the same. All help is appreciated. 😇

Comment threaddoc/api/repl.md Outdated
[TTY keybindings]: readline.html#readline_tty_keybindings
[curl(1)]: https://curl.haxx.se/docs/manpage.html
[stream]: stream.html

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This empty line seems unneeded)

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done.

@vsemozhetbyt

Copy link
Copy Markdown
Contributor

cc @nodejs/platform-windows: can we have some more verification of keybindings and suggestions how to better document possible differences (if we should)?

@bzoz

bzoz commented May 24, 2018

Copy link
Copy Markdown
Contributor

Meta is the Alt key (maybe we should add that to the docs?), bindings with those work.

The ctrl+shift+... don't work on Windows and also do not work on WSL.

@vsemozhetbyt

Copy link
Copy Markdown
Contributor

@bzoz Sorry, was confused by the MDN page.

But alt+delete still does not work for me (alt+d works).

@BridgeARBridgeAR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM with the whitespace removed. My two comments would also be nice but I think that could also be done later on (even though I would prefer to have it that way right away).

Comment threaddoc/api/readline.md Outdated
</tr>
<tr>
<td><code>ctrl+shift+backspace</code></td>
<td>delete line left</td>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not a must but I personally would prefer the descriptions all to start with a upper case character.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done.

Comment threaddoc/api/readline.md Outdated
<th>Description</th>
</tr>
<tr>
<td><code>ctrl+shift+backspace</code></td>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggestion: add whitespace between the individual commands and maybe also only highlight the keys, not the plus. As in: <code>ctrl</code> + <code>shift</code> + <code>backspace</code>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any reason these are wrapped in <code> and not <kbd>?

@bzoz

bzoz commented May 24, 2018

Copy link
Copy Markdown
Contributor

Hm.. Alt+Del does not work on Windows and WSL, but works on Linux. Libuv reports it as ^^[3~ on Windows.

Ctrl + Shift + Backspace does not work neither on Windows nor on Linux. On Windows libuv does not report any sequence at all.

Ctrl + Shift + Del works on both Windows and Linux.

Comment threaddoc/api/readline.md Outdated
</tr>
<tr>
<td><code>ctrl</code> + <code>z</code></td>
<td>(need clarification)</td>

@shobhitchittorashobhitchittoraMay 24, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Hey team.
Need clarification on this keybinding. I cannot think of a description for this. Can someone help with this?

cc @BridgeAR@vsemozhetbyt

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I do not know, sorry(

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

@BridgeAR I found this for ctrl + z -
https://nodejs.org/api/readline.html#readline_event_sigtstp

If it's fine we can either ref to this or take the first paragraph and add here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please document it as e.g.: Moves running process into background. Type 'fg' and press 'enter' to return..

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

done.

@vsemozhetbyt

Copy link
Copy Markdown
Contributor

@vsemozhetbyt

Copy link
Copy Markdown
Contributor

We have a linter issue:

06:00:06 Running Markdown linter on docs...
06:00:51 doc/api/readline.md
06:00:51 596:113 warning Line must be at most 80 characters maximum-line-length remark-lint
06:00:51 599:108 warning Line must be at most 80 characters maximum-line-length remark-lint
06:00:51 623:105 warning Line must be at most 80 characters maximum-line-length remark-lint

Comment threaddoc/api/readline.md Outdated
<td>Moves running process into background. Type <code>fg</code> and press <code>enter</code> to return.</td>
</tr>
<tr>
<td><code>ctrl</code> + <code>w</code> &nbsp; or &nbsp; <code>ctrl</code> + <code>backspace</code></td>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are these &nbsp; intended here and below?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Yeah! added them for more spacing, but removing for now.

@vsemozhetbyt

Copy link
Copy Markdown
Contributor

@vsemozhetbyt

Copy link
Copy Markdown
Contributor

Should we land as is or need we elaborate some note about OS-dependent differences?

@bzoz

bzoz commented May 27, 2018

Copy link
Copy Markdown
Contributor

I think we should document differences. And double check, since it looks like Ctrl + Shift + Backspace does not work on any platform.

@vsemozhetbyt

Copy link
Copy Markdown
Contributor

Let's do not stall this PR.

@shobhitchittora

Copy link
Copy Markdown
ContributorAuthor

@vsemozhetbyt please do let know if anything update / commit is required from my side.

@vsemozhetbyt

Copy link
Copy Markdown
Contributor

@nodejs/platform-macos Are there any additions from your team?

@vsemozhetbyt

Copy link
Copy Markdown
Contributor

ping @nodejs/documentation

@shobhitchittora

Copy link
Copy Markdown
ContributorAuthor

@vsemozhetbyt any updates on this?

@vsemozhetbyt

Copy link
Copy Markdown
Contributor

Sorry, it seems I've exhausted all the ways I could help(

@jasnelljasnell added the stalled Issues and PRs that are stalled. label Sep 10, 2018
Comment threaddoc/api/readline.md
</tr>
<tr>
<td><code>ctrl</code> + <code>left</code></td>
<td>Word left </td>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

On macOS, it's command+option+left. ctrl+left does not work.

Comment threaddoc/api/readline.md
</tr>
<tr>
<td><code>ctrl</code> + <code>right</code></td>
<td>Word right</td>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

On macOS, it's command+option+right. ctrl+right does not work.

Comment threaddoc/api/readline.md
</tr>
<tr>
<td><code>meta</code> + <code>backspace</code></td>
<td>Delete word left </td>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does not work on macOS.

@Trott

Copy link
Copy Markdown
Member

@shobhitchittora@vsemozhetbyt I've tested on my macOS laptop and have put the result in above as best I can. ("Meta" on macOS is "hold down the ESC key" and "backspace" is "fn + delete", in case that's relevant.)

Can that information be incorporated and this unstalled? Does anything else need to happen to unstall this?

@TrottTrott removed the stalled Issues and PRs that are stalled. label Nov 20, 2018
@Trott

Copy link
Copy Markdown
Member

Optimistically removing the stalled label...

@Trott

Copy link
Copy Markdown
Member

@shobhitchittora Are you planning to finish this one? Or would it make sense to put a help wanted label on it or something like that?

@TrottTrott added the help wanted Issues that need assistance from volunteers or PRs that need help to proceed. label Dec 4, 2018
@fhinkel

Copy link
Copy Markdown
Member

Closing this due to inactivity. Please reopen if needed.

@fhinkelfhinkel closed this Oct 26, 2019
@BridgeARBridgeAR mentioned this pull request Dec 21, 2019
4 tasks
HarshithaKP added a commit to HarshithaKP/node that referenced this pull request Jan 8, 2020
@HarshithaKPHarshithaKP mentioned this pull request Jan 8, 2020
4 tasks
BridgeAR pushed a commit that referenced this pull request Jan 13, 2020
This documents all readline key bindings. It is a rework of
#20825
PR-URL: #31256Fixes: #20814
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
MylesBorins pushed a commit that referenced this pull request Jan 16, 2020
This documents all readline key bindings. It is a rework of
#20825
PR-URL: #31256Fixes: #20814
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
codebytere pushed a commit that referenced this pull request Mar 14, 2020
This documents all readline key bindings. It is a rework of
#20825
PR-URL: #31256Fixes: #20814
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
targos pushed a commit to targos/node that referenced this pull request Apr 25, 2020
This documents all readline key bindings. It is a rework of
nodejs#20825
PR-URL: nodejs#31256Fixes: nodejs#20814
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
targos pushed a commit that referenced this pull request Apr 28, 2020
This documents all readline key bindings. It is a rework of
#20825
PR-URL: #31256Fixes: #20814
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docIssues and PRs related to the documentations.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.readlineIssues and PRs related to the built-in readline module.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

doc: add doc for tty writes ( readline.js / REPL )

10 participants

@shobhitchittora@richardlau@vsemozhetbyt@bzoz@BridgeAR@Trott@fhinkel@addaleax@jasnell@nodejs-github-bot