console enhancements: mouse events

Andy Koppe
Fri Nov 6 21:55:00 GMT 2009

2009/11/6 Thomas Wolff:
> * I would like to fix some key assignments:
>  - Control-(Shift-)6 inputs Control-^ which is not proper on international
>    keyboards if Shift-6 is not "^", Control-^ (the key) does not input
>    Control-^ (the character) on the other hand; the same glitch
>    occurs in the pure Windows console, however.
>    Unfortunately, with the functions being used it is not possible to
>    detect that shifted key "^" was hit together with Control; only
>    keycodes/scancodes are available when Control/Shift/Alt are used. So
>    I don't know whether this can easily be fixed. It works in mintty but
>    I think mintty uses different Windows functions.

Mintty roughly does the following for Ctrl(+Shift)+symbol combinations:
- obtain the keymap using GetKeyboardState()
- set the state of the Ctrl key to released
- invoke ToUnicode() to get the character code according to the keyboard layout
- if the character code is one of [\]_^? send the corresponding control code
- otherwise, set the state of both Ctrl and Alt to pressed (this is
equivalent to AltGr), and try ToUnicode() again

The last step means that e.g. Ctrl+9 on a German keyboard will send
^]. The proper combination would be Ctrl+AltGr+9, but since
AltGr==Ctrl+Alt, that can't be distinguished from AltGr+9 without
Ctrl. (Well, not without somewhat dodgy trickery anyway.)

Btw, ^[, ^], and ^\ are actually available as Ctrl+ü, Ctrl+plus, and
Ctrl+# in the German keyboard layout, but those combinations make no
sense unless you're familiar with the US layout. It's similar with
many, but by no means all, other layouts. (Microsoft's Keyboard Layout
Creator is a good way to inspect different layouts.)

>  - Pressing something like Alt-ö on a German keyboard leaves an illegal UTF-8
>    sequence (the second byte of the respective sequence) in input, apparently
>    because Alt-0xC3 is handled somehow. Don't know, though, whether this is
>    a cygwin console issue or maybe a readline issue.

Readline issue. It's fine in zsh.


More information about the Cygwin-patches mailing list