magiblot / tvision

A modern port of Turbo Vision 2.0, the classical framework for text-based user interfaces. Now cross-platform and with Unicode support.
Other
1.99k stars 150 forks source link

Improve non-latin menu items hot keys handling #99

Open unxed opened 1 year ago

unxed commented 1 year ago

Let's imagine we are developing some app with Russian interface. Menu item "File" will be called "Файл" in Russian. The problem is that even if we create it like "~Ф~айл", hotkey Alt+Ф will work in Russian keyboard layout only. Not very comfortable.

To solve this issue, we need:

1) Some way to assign latin hot keys to non-latin menu items, so "Файл" could get hotkey Alt+A (Latin "A" is on the same key as Russian "Ф").

2) Support terminals that provide keyboard layout independent keystroke information. For now I know 4 terminals that supports this, each utilizing it's own protocol.

a) far2l in "tty extensions" mode, already supported by tvision

b) kovidgoyal's kitty keyboard protocol: https://sw.kovidgoyal.net/kitty/keyboard-protocol/

c) iTerm2 raw key reporting mode: https://gitlab.com/gnachman/iterm2/-/issues/7440#note_129307021

d) Windows Terminal https://github.com/microsoft/terminal/blob/main/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md https://github.com/microsoft/terminal/pull/6309

magiblot commented 1 year ago

Hi @unxed!

First of all, I would like to find out how GUIs behave in this case, and whether it would be desirable to mimic the behaviour of GUIs, or if it would be clearly better to do something else.

Therefore, since you are a regular user of the Russian keyboard layout, I would be very grateful if you could gather the following information from different application types (Qt, GTK, Windows...):

Thank you.

unxed commented 1 year ago
GTK (Nemo app):

Does Alt+Ф trigger a ~Ф~айл menu entry?
Yes
Does Alt+A (latin A) trigger a ~Ф~айл menu entry?
Yes
Does Alt+F (latin F) trigger a ~Ф~айл menu entry?
No
Does Alt+У trigger an ~E~dit menu entry?
Yes
Does Alt+Е (cyrillic Е) trigger an ~E~dit menu entry?
No

Qt (qBittorrent app):

Does Alt+Ф trigger a ~Ф~айл menu entry?
Yes
Does Alt+A (latin A) trigger a ~Ф~айл menu entry?
No
Does Alt+F (latin F) trigger a ~Ф~айл menu entry?
No
Does Alt+У trigger an ~E~dit menu entry?
Yes
Does Alt+Е (cyrillic Е) trigger an ~E~dit menu entry?
No

Windows (notepad++ app*)
* tested in Wine as not having Windows at hands right now

Does Alt+Ф trigger a ~Ф~айл menu entry?
No (but Alt+Shift+Ф does**)
Does Alt+A (latin A) trigger a ~Ф~айл menu entry?
No (but Alt+Shift+A does**)
Does Alt+F (latin F) trigger a ~Ф~айл menu entry?
No
Does Alt+У trigger an ~E~dit menu entry?
No
Does Alt+Е (cyrillic Е) trigger an ~E~dit menu entry?
No

** It seems that the hotkeys of the Russian-language menu have case sensitivity:
where hotkeys are assigned to a lowercase character, Shift is not required.
But maybe a Wine bug.

I would call the GTK behavior the most convenient and intuitive.