Skip to content

Conversation

@matthias314
Copy link

@matthias314 matthias314 commented Jan 2, 2025

This PR 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.) 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, contrary to the documentation, and similarly for the other cursor keys. I've implemented the documented codes. 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

JoeKar commented Jan 5, 2025

With micro-editor/micro#3593 being merged micro-editor/tcell is used for now as tcell source and issues & PRs created in zyedidia/tcell might be unconsidered.

@matthias314
Copy link
Author

OK. I'm going to open a PR there.

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