adamyg / mcwin32

Midnight Commander for Windows
https://sourceforge.net/projects/mcwin32/
204 stars 13 forks source link

Fix keyboard issues #39

Closed proski closed 1 year ago

proski commented 1 year ago

Fixed issues: #34 and #37

The first two commits should be self-explanatory. Here are some comments about the last commit.

Windows reports pressed modifiers (e.g. Shift) as events. If somebody wants to use Escape-?, they press and release Escape, then press Shift, then press the ? key (normally / without Shift on US keyboard).

So to capture ? mc should either get into business of interpreting modifiers on its own (bad idea) or wait for an event that Windows interprets as a character.

What should mc ignore? I was thinking of ignoring just modifiers, but decided against it. Some users can use other keys to switch keyboard layouts, e.g. Alt-Space is sometimes used to switch between Latin and Cyrillic keyboard.

So the logic in this PR is to ignore all keys that mc or Windows cannot interpret. Nobody would press Escape-F1 to have F1 functionality (it could be treated as Alt-F1 eventually). Most likely they meant to press something else. Non-ASCII characters after Escape are also ignored mostly for the safety of the mc core code.

When an unknown key press is detected, the waiting resumes with the same timeout. For instance, if the Escape timeout is 1 second, it's possible to get Alt-? by pressing Escape, then Shift 0.9 s later, then ? 0.9 s later. I believe it's reasonable, as key with modifiers take longer to press.

Neustradamus commented 1 year ago

@adamyg: Any news about this PR?