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

rfc: built-in option to request for "extended-keys" aka "CSI u" #4103

Closed
vbauerster opened this issue Mar 15, 2021 · 9 comments
Closed

rfc: built-in option to request for "extended-keys" aka "CSI u" #4103

vbauerster opened this issue Mar 15, 2021 · 9 comments

Comments

@vbauerster
Copy link
Contributor

Upcoming tmux 3.2 has introduced support for extended-keys. Basically it means that CSI u sequences are not automatically enabled inside tmux, unless requested by application by sending special escape sequence.

To enable extended keys application should send \033[>4;1m and to disable \033[>4;0m respectively.

I tried to apply following script with no success.

hook global ModuleLoaded tmux %{
    nop %sh{ printf '\033[>4;1m' }
    hook global KakEnd .* %{
        nop %sh{ printf '\033[>4;0m' }
    }
}

Issuing printf '\033[>4;1m' manually inside tmux and then starting kakoune works.

Probably there is need to have a built-in option for this, as I suppose my script didn't work because there is need to have some kind of direct access to the terminal.

@Screwtapello
Copy link
Contributor

Screwtapello commented Mar 15, 2021

The builtin-terminal-ui branch already sends a special sequence to enable extended-keys mode in Kitty: 89865b7

It's unfortunate that tmux and xterm seem to be using a different enable/disable sequence than Kitty and iTerm. I hope the actual key-encodings are compatible.

@vbauerster
Copy link
Contributor Author

Is it feasible to add \033[>4;1m variant as well? Or should I ask tmux's maintainer to support kitty style \033[>1u?

@kovidgoyal
Copy link

Note that I highly doubt the actual escape codes produced by xterm, iterm and kitty actually are the same for all keys (in particular for shifted variants), though they will be similar for most keys. For details see https://sw.kovidgoyal.net/kitty/keyboard-protocol.html and ongoing discussion in kovidgoyal/kitty#3248

If you have concerns as an application developer, I suggest chiming in on that issue asap. Once kitty 0.20 is released I will be much less willing to make changes to the protocol.

@vbauerster
Copy link
Contributor Author

Is it feasible to add \033[>4;1m variant as well? Or should I ask tmux's maintainer to support kitty style \033[>1u?

@mawww What do you think?

Maybe it's worth to let user define the on/off sequence, instead of hardcoding in the code?

Following script works unless new window is spawned by :new command. I suppose in new window there is different /dev/tty.

hook global ModuleLoaded tmux %{
    hook global WinCreate .* %{
        nop %sh{ printf '\033[>4;1m' > /dev/tty }
    }
    hook global KakEnd .* %{
        nop %sh{ printf '\033[>4;0m' > /dev/tty }
    }
}

@kovidgoyal
Copy link

This should make things easier for you: kovidgoyal/kitty@d360d07

@mawww
Copy link
Owner

mawww commented Mar 25, 2021

Kakoune will adapt to whatever the terminal landscape ends up being, sending the two sequences if necessary.

It is unfortunate we have those two sequences now, seeing that Kitty now supports the xterm variant we could migrate to it (and ask @gnachman to add support to it in iterm2, although I feel sorry having asked for the kitty variant and now requesting yet another sequence).

Ideally a consensus would form on terminal-wg regarding that sequence and we could use it as guidance, but while that group generates lots of valuable discussion it does not often reach anything close to consensus.

I guess for now we might wait and see, I am really happy to see some progress on that front, thanks again @kovidgoyal for working on that Kitty side.

@Delapouite
Copy link
Contributor

As a reference, related issue in neowim repo: neovim/neovim#14400

@gnachman
Copy link

gnachman commented May 1, 2021

@mawww iTerm2 supports CSI > 4 ; 1 m with the aim of xcode compatibility. I don't think I have enough context here—what change do you need on my side?

@mawww
Copy link
Owner

mawww commented May 2, 2021

@gnachman Thats great, I had opened an issue to support the kitty style CSI > 1 u which you did take care of, then I realized there was this alternate xterm version with CSI > 4 ; 1 m .

Now that kitty and iterm2 support the xterm escape sequence I can migrate Kakoune to just emit that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants