Support "alt+enter" sending \e\r#2364
Support "alt+enter" sending \e\r#2364NHDaly wants to merge 5 commits intoxtermjs:masterfrom NHDaly:patch-1
\e\r#2364Conversation
Add (failing) test for "alt+return" key combination sending `\e\n` (used in some REPLs to insert a newline)
|
Does xterm or other terminals do this? |
\e\n\e\n
|
At least Konsole and alacritty do -- this is Enter followed by Alt-Enter: Apparently xterm specifies modes for this as well. |
|
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.
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+"? |
\e\n\e\r
Looks like we need another DECSET mode? These are currently maintained here |
|
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. |
|
Thanks for thinking seriously about the right way to handle this! 🎉 :) |
|
Friendly ping: have there been any further thoughts on this? :) Thanks! |
|
@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). |
Tyriar
left a comment
There was a problem hiding this comment.
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:
Line 1284 in ffd27df
A text search across the repo should reveal how these modes work.
|
@NHDaly friendly ping, we wouldn't be able to merge this without only conditionally doing it in that mode. |
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!! |
|
@NHDaly no worries, thanks for the effort. I'll close this for now but it's still open to anyone else to contribute. |
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.