Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: key bindings for urxvt, add home/end combinations #396

Merged
merged 6 commits into from
Oct 3, 2022

Conversation

knz
Copy link
Contributor

@knz knz commented Aug 12, 2022

Fixes #310.
Fixes #403.

cc @muesli

@knz
Copy link
Contributor Author

knz commented Aug 12, 2022

cc @maaslalani

@meowgorithm
Copy link
Member

Let's make sure we verify this one very carefully, including in both urxvt and otherwise.

@knz
Copy link
Contributor Author

knz commented Aug 19, 2022

All right I think there are two different changes here. I will split the PR which will simplify.

@knz
Copy link
Contributor Author

knz commented Aug 19, 2022

Ready for another look - I have split up the PR into bite-sized commits, so that they become easier to review individually.

@muesli
Copy link
Contributor

muesli commented Sep 27, 2022

@knz Could you do me a favor and rebase this once more?

@knz
Copy link
Contributor Author

knz commented Sep 27, 2022

Done.

@@ -382,10 +382,10 @@ var sequences = map[string]Key{
"\x1b[2;3~": {Type: KeyInsert, Alt: true},
"\x1b[3~": {Type: KeyDelete},
"\x1b[3;3~": {Type: KeyDelete, Alt: true},
"\x1b[1~": {Type: KeyHome},
Copy link
Contributor

@muesli muesli Sep 28, 2022

Choose a reason for hiding this comment

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

While you're right and most every terminal seems to send \x1b[H for the home key, I do find references to this sequence being used for home as well. We should probably keep it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Same question/remark for KeyEnd, too.

Copy link
Member

Choose a reason for hiding this comment

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

Fwiw, I added this after testing against home and receiving that value (same case for end). As long as there’s no collision, I’d also err on keeping it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On which terminal was that?

Copy link
Member

Choose a reason for hiding this comment

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

To be quite honest I don't remember anymore, though do I think it's worth investigating.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll update this commit and keep the previous sequences for KeyHome and KeyEnd for now. If we can confirm they aren't used anywhere we can still remove them eventually.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, pushed my changes to your fork.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok this works for me. thanks for the edit!

key.go Outdated

"\x1b[H": {Type: KeyHome}, // vt100
"\x1b[1;3H": {Type: KeyHome, Alt: true}, // vt100
"\x1b[F": {Type: KeyHome}, // vt100
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should read KeyEnd. Fixing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed and pushed, but noticed you corrected the mistake yourself in one of the later commits.

@muesli
Copy link
Contributor

muesli commented Oct 2, 2022

@knz Help me understand why the last commit improves troubleshootability? I find the function keys a bit all over the place still.

Edit: Just to clarify, I'm happy with the change, I'm just wondering if I'm missing something obvious.

@muesli muesli added the bug Something isn't working label Oct 2, 2022
@knz
Copy link
Contributor Author

knz commented Oct 2, 2022

why the last commit improves troubleshootability?

As I was cross-checking the codes for the function keys with the source code of all the terminal emulators listed in the termenv docs, I was doing them in order of function key (starting at F1, then F2, etc). It was super hard to do because they were not in function key order in key.go. That's why I rearranged them. But feel free to drop that latest commit if you believe it's not worth the hassle.

@knz knz changed the title Fix key bindings for urxvt, add home/end combinations fix: key bindings for urxvt, add home/end combinations Oct 3, 2022
@muesli muesli added the enhancement New feature or request label Oct 3, 2022
@muesli muesli merged commit 0851898 into charmbracelet:master Oct 3, 2022
@muesli
Copy link
Contributor

muesli commented Oct 3, 2022

Thank you @knz, great work 🙌

knz added a commit to knz/bubbletea that referenced this pull request Oct 7, 2022
We started supporting insert in charmbracelet#418, but then accidentally
removed it during a rebase in charmbracelet#396. Oops.
muesli pushed a commit that referenced this pull request Oct 7, 2022
We started supporting insert in #418, but then accidentally
removed it during a rebase in #396. Oops.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Input key codes for home/end are incorrect capture ctrl+Home/End keys
3 participants