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

Implement ModifyOtherKeys #2628

Open
unxed opened this issue Jan 12, 2025 · 3 comments · May be fixed by #2629
Open

Implement ModifyOtherKeys #2628

unxed opened this issue Jan 12, 2025 · 3 comments · May be fixed by #2629

Comments

@unxed
Copy link
Contributor

unxed commented Jan 12, 2025

At least two notable terminals, xterm and mintty (cygwin's terminal) support one more keyboard protocol extension. It is much more simple that kitty spec, but can still help to make keyboard support better. We should support it also.

https://invisible-island.net/xterm/modified-keys.html

@unxed
Copy link
Contributor Author

unxed commented Jan 14, 2025

NB! ModifyOtherKeys protocol supports two modes.

In mode 1, activated by xterm -xrm '*modifyOtherKeys:1' or \033[>4;1m, only several key combinations are encoded in ModifyOtherKeys mode.

In mode 2, activated by xterm -xrm '*modifyOtherKeys:2' or \033[>4;2m, more combinations are supported, but quick search with Alt+letter stops working for non-Latin letters.

I am defaulting to mode 1 for now in the PR above, but in future we should make an option for user to decide.

UPD: I could not find any public issue tracker of xterm, so I wrote an email to it's author:

Hello, Thomas,

I would like to kindly ask for some improvements to the modifyOtherKeys protocol in xterm. Currently, when mode 2 is enabled, combinations of the Alt key with any letter in a non-Latin keyboard layout do not send any ESC sequences at all. In fact, they don’t send any characters either. I believe this is a bug. At the very least, a sequence of ESC and corresponding unicode char should be sent in this case.

Best regards,
Ivan Sorokin

@unxed
Copy link
Contributor Author

unxed commented Jan 14, 2025

quick search with Alt+letter stops working for non-Latin letters

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1093056

@unxed
Copy link
Contributor Author

unxed commented Jan 22, 2025

Bug in xterm with Alt+non_Latin_letter could be fixed by adding

        /*
         * For combinations of the Alt key with text-input keys,
         * in the case of a non-English keyboard layout,
         * we will send the Unicode character corresponding
         * to the pressed key.
         */
        int codepoint = keysym2ucs(kd.keysym);
        if ((input_char == -1) && (evt_state & Mod1Mask) && (codepoint > 0x7E)) {
            input_char = codepoint;
        }

just after

      input_char = ((kd.keysym < 256)
        ? (int) kd.keysym
        : ((kd.nbytes == 1)
           ? CharOf(kd.strbuf[0])
           : -1));

in input.c

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 a pull request may close this issue.

1 participant