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

support "rich keyboard" protocols by iTerm2/kovidgoyal's kitty/Windows Terminal #1575

Closed
unxed opened this issue Mar 30, 2023 · 5 comments
Closed

Comments

@unxed
Copy link
Contributor

unxed commented Mar 30, 2023

At the time far2l tty mode was firstly introduced, no terminal supported sending rich keypress information to console apps. Now it is possible in at least two terminals: iTerm2 on Mac and kovidgoyal's kitty on Mac/BSD/Linux.

Each one uses its own protocol for that (actually there is also third protocol for that, called "CSI u" or "libtickit protocol" and supported by some other terminals, but it does not suit far2l well as it is unable to tell equivalent latin letter for alt/ctrl+non_latin_letters key combinations, also no separate escape sequences for keyup/keydown events and some other limitations).

The first one is iTerm2 "raw keyboard" protocol:
https://gitlab.com/gnachman/iterm2/-/issues/7440#note_129307021

The second one is kovidgoyal's kitty keyboard protocol:
https://sw.kovidgoyal.net/kitty/keyboard-protocol/

If far2l's tty backend will support those portocols it will for sure improve UX of tty version users.

PS: Maybe iTerm2's protocol should not have priority in implementation as it looks like they are planning to adopt kovidgoyal kitty's one also sometime in the future:
https://gitlab.com/gnachman/iterm2/-/issues/10017

@unxed
Copy link
Contributor Author

unxed commented Mar 30, 2023

kovidgoyal's kitty keyboard protocol is also discussed for inclusion in Windows Terminal. I appreciate voting for it instead of "CSI u" as it fits far2l better:
microsoft/terminal#11509 (comment)

also GNOME Terminal and Konsole are discussing it:
https://bugs.kde.org/show_bug.cgi?id=435975
https://gitlab.gnome.org/GNOME/vte/-/issues/2601

@unxed
Copy link
Contributor Author

unxed commented Mar 30, 2023

Oh, Windows Terminal now has it's own "rich keyboard" protocol, fields from _KEY_EVENT_RECORD are sent inside special escape sequence!

https://github.com/microsoft/terminal/blob/main/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md

  ^[ [ ? 9001 h/l
              l: Disable win32-input-mode
              h: Enable win32-input-mode
  ^[ [ Vk ; Sc ; Uc ; Kd ; Cs ; Rc _

       Vk: the value of wVirtualKeyCode - any number. If omitted, defaults to '0'.

       Sc: the value of wVirtualScanCode - any number. If omitted, defaults to '0'.

       Uc: the decimal value of UnicodeChar - for example, NUL is "0", LF is
           "10", the character 'A' is "65". If omitted, defaults to '0'.

       Kd: the value of bKeyDown - either a '0' or '1'. If omitted, defaults to '0'.

       Cs: the value of dwControlKeyState - any number. If omitted, defaults to '0'.

       Rc: the value of wRepeatCount - any number. If omitted, defaults to '1'.

@unxed unxed changed the title support "reach keyboard" protocols by iTerm2 and kovidgoyal's kitty terminals support "rich keyboard" protocols by iTerm2/kovidgoyal's kitty/Windows Terminal Mar 30, 2023
@unxed
Copy link
Contributor Author

unxed commented Mar 31, 2023

Oh, Windows Terminal now has it's own "rich keyboard" protocol, fields from _KEY_EVENT_RECORD are sent inside special escape sequence!

Implemented it, see #1581

@unxed
Copy link
Contributor Author

unxed commented Apr 2, 2023

While testing win32-input-mode introduced in edf9b73 under Windows Terminal, noticed very strange Windows Terminal behavior: microsoft/terminal#15083

@unxed
Copy link
Contributor Author

unxed commented Apr 9, 2023

Wrote experimental parser for iTerm2's advanced input mode. @elfmz if you have Mac or hackintosh at hands, can you please check if it works correctly under iTerm2 or not?
https://github.com/unxed/far2l/tree/iterm2

Spec:
https://gitlab.com/gnachman/iterm2/-/issues/7440#note_129307021

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

No branches or pull requests

1 participant