Skip to content

better function key support for rxvt-unicode #1

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

Open
wants to merge 1 commit into
base: legacy
Choose a base branch
from

Conversation

matthias314
Copy link

This PR (copied here from zyedidia#30) adds function key support for rxvt-unicode (urxvt) in a way analogous to xterm. Specifically, it can report the following keys:

  • F1 to F10, also with any combination of Shift, Ctrl and Alt. (Alt plus function key is often caught by the window manager, however.) Currently combinations of function keys with Shift are reported as F11 to F20 and the rest as raw key events.
  • F11 and F12 (and up to F20, if you have them) if used together with Shift and possibly Ctrl and/or Alt.
  • Insert, Delete, Home, End, PageUp, PageDown, also with any combination of Shift, Ctrl and Alt (Note that by default Shift plus Insert, PageUp and PageDown are caught by urxvt for its own purposes.) Currently, the modifier combinations Shift+Ctrl and Alt-Shift-Ctrl are reported as raw key events.
  • Up, Down, Right, Left, also with Shift or Ctrl, possibly plus Alt. Currently Ctrl-Up is reported as raw key event (same plus Alt) and Ctrl-Shift-Up as Up (same plus Alt) .

The following work with tweaking the user's .Xresources:

  • By default, urxvt doesn't distinguish F11 (plus Ctrl) from Shift-F1 (plus Ctrl), same for F12 (up to F20). I've added newly invented key codes for these cases. To use them, one needs to add something like the following to .Xresources:
    URxvt.keysym.F11: string:\033[23#
    URxvt.keysym.S-F11: string:\033[23$
    URxvt.keysym.C-F11: string:\033[23&
    URxvt.keysym.C-S-F11: string:\033[23@
    URxvt.keysym.M-F11: string:\033\033[23#
    URxvt.keysym.M-S-F11: string:\033\033[23$
    URxvt.keysym.M-C-F11: string:\033\033[23&
    URxvt.keysym.M-C-S-F11: string:\033\033[23@
    
    Then F11 works with any combination of modifiers. For F12 one needs to replace [23 by [24.
  • urxvt sends the same key codes for Shift-Up and Ctrl-Shift-Up, and similarly for the other cursor keys. I've instead implemented the "application mode" codes for Ctrl-Shift, see the urxvt documentation. To use them, one needs something like the following in .Xresources:
    URxvt.keysym.C-S-Up: string:\033OA
    URxvt.keysym.C-S-Down: string:\033OB
    URxvt.keysym.C-S-Right: string:\033OC
    URxvt.keysym.C-S-Left: string:\033OD
    URxvt.keysym.M-C-S-Up: string:\033\033OA
    URxvt.keysym.M-C-S-Down: string:\033\033OB
    URxvt.keysym.M-C-S-Right: string:\033\033OC
    URxvt.keysym.M-C-S-Left: string:\033\033OD
    
    Then cursor keys work with any combination of modifiers. (Some might be caught by the window manager.)

The PR also seems to work with rxvt-like terminals (tested with Eterm). I don't kow about the original rxvt; I didn't find it in a web search.

@JoeKar
Copy link
Member

JoeKar commented Jan 5, 2025

Please also consider checking gdamore/tcell, since this might be upstream relevant and then should be fixed there too.

@matthias314
Copy link
Author

@gdamore Would you be interested in this PR? It has several merge conflicts with your main branch, so I'd rather ask before I start fixing them.

@matthias314
Copy link
Author

It seems that @gdamore is not interested. Are you, @JoeKar?

@JoeKar
Copy link
Member

JoeKar commented Feb 3, 2025

Maybe he prefers to receive it as issue or PR directly within the upstream repository.

I've no problem with such stuff, but we've to keep in mind that we like to get closer to the upstream version instead of moving away. 😉
When we go such a direction we might end in a situation of allowing special modified treatment for all the different terminals. 🤔

Anyway please leave it open till we find some time to consider it.
Currently we're really busy with the tons of issues and PRs opened in micro itself.

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.

2 participants