Skip to content

Support "alt+enter" sending \e\r#2364

Closed
NHDaly wants to merge 5 commits intoxtermjs:masterfrom
NHDaly:patch-1
Closed

Support "alt+enter" sending \e\r#2364
NHDaly wants to merge 5 commits intoxtermjs:masterfrom
NHDaly:patch-1

Conversation

@NHDaly
Copy link
Copy Markdown

@NHDaly NHDaly commented Aug 6, 2019

This is a PR to add support for "alt+enter" key binding to send \e\r (used in some REPLs to insert a newline).

EDIT:
It adds a test that "alt+return" key combination sends \e\r.
And I've added my guess at what the fix would be.

NHDaly and others added 2 commits August 6, 2019 14:49
Add (failing) test for "alt+return" key combination sending `\e\n` (used in some REPLs to insert a newline)
@Tyriar
Copy link
Copy Markdown
Member

Tyriar commented Aug 6, 2019

Does xterm or other terminals do this?

@NHDaly NHDaly changed the title Support "alt+enter sending \e\n Support "alt+enter" sending \e\n Aug 6, 2019
@pfitzseb
Copy link
Copy Markdown
Contributor

pfitzseb commented Aug 6, 2019

At least Konsole and alacritty do -- this is Enter followed by Alt-Enter:

λ showkey -a

Press any keys - Ctrl-D will terminate this program

^M       13 0015 0x0d
^[^M     27 0033 0x1b
         13 0015 0x0d
^D        4 0004 0x04

Apparently xterm specifies modes for this as well.

@NHDaly
Copy link
Copy Markdown
Author

NHDaly commented Aug 6, 2019

Oops! Sorry, i didn't realize i'd submitted the PR! I thought i was still editing it. ... haha it must have been that darned "shift+enter", which is very funny considering the situation. 😅

Sorry about that! :) I've just edited the first comment with a bit more information, including that I've just pushed up what I think is the right place for the fix.

Does xterm or other terminals do this?

I'm not exactly sure where to find documentation on this, but I think so. iTerm seems to do this on macOS, and a coworker who uses linux says his terminal does this as well.

But now that I'm digging into it more, this might just be because iTerm defaults to setting the option-keys to "Esc+"?

@NHDaly NHDaly changed the title Support "alt+enter" sending \e\n Support "alt+enter" sending \e\r Aug 6, 2019
@Tyriar Tyriar requested a review from jerch August 6, 2019 19:32
@Tyriar
Copy link
Copy Markdown
Member

Tyriar commented Aug 6, 2019

Apparently xterm specifies modes for this as well.

Looks like we need another DECSET mode? These are currently maintained here

public decPrivateModes: IDecPrivateModes;

@jerch
Copy link
Copy Markdown
Member

jerch commented Aug 6, 2019

Yes I think we should do as xterm does here and make it usable from application side with DECSET 1036 and 1039. I think we need to support both as we have an option to declare Option on Mac as Meta key.

Next question is whether this should be enabled by default. Seems most emulators enable this (quickly tested gnome-terminal, konsole, rxvt) only xterm sends by default the 8bit chars on Alt+Key, thus needs to be explicitly set via sequence or startup options. I'd say we should enable this by default too and make the default behavior customizable via ctor option.

Last but not least we have to check that this does not interfere with other key combinations.

@NHDaly
Copy link
Copy Markdown
Author

NHDaly commented Aug 6, 2019

Thanks for thinking seriously about the right way to handle this! 🎉 :)

@NHDaly
Copy link
Copy Markdown
Author

NHDaly commented Sep 10, 2019

Friendly ping: have there been any further thoughts on this? :) Thanks!

@jerch
Copy link
Copy Markdown
Member

jerch commented Sep 11, 2019

@NHDaly No updates on this. Since you opened this PR question at hand is whether you want to implement the DECSET and the tests yourself here (if thats to much "internal rubbish" for you we can start over with a new PR).

Copy link
Copy Markdown
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

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

To clarify, as per this comment we should only send this when the terminal has entered the specific mode. If you wanted to go down this route have a look at how the applicationCursorKeys is setup:

this._coreService.decPrivateModes.applicationCursorKeys = true;

A text search across the repo should reveal how these modes work.

@Tyriar
Copy link
Copy Markdown
Member

Tyriar commented Oct 17, 2019

@NHDaly friendly ping, we wouldn't be able to merge this without only conditionally doing it in that mode.

@NHDaly
Copy link
Copy Markdown
Author

NHDaly commented Oct 20, 2019

No updates on this. Since you opened this PR question at hand is whether you want to implement the DECSET and the tests yourself here (if thats to much "internal rubbish" for you we can start over with a new PR).

Hi, thanks for the ping! ❤️

I'm sorry i dropped this PR. Yes, unfortunately I don't have as many free cycles now as I had when I opened this PR, so if you'd be able to take over this work -- especially since it's going to be more involved and internal -- I would super appreciate it.

Feel free to either close this PR or to take it over. I currently have it set to "Allow updates from maintainers," so you should be able to do whatever is easiest for you! :)

Thanks again for your quick responses!!

@Tyriar
Copy link
Copy Markdown
Member

Tyriar commented Oct 22, 2019

@NHDaly no worries, thanks for the effort. I'll close this for now but it's still open to anyone else to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants