This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: console enhancements: mouse events


2009/11/7 Corinna Vinschen:
>> 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.)
>
> How does that work for ^^? ÂThe ^ key is a deadkey on the german keyboard
> layout, so the actual char value is only generated after pressing the key
> twice. ÂJust curious.

ToUnicode actually delivers the ^ character right away when pressing
the key, but with return value -1 to signify that it's a dead key and
that the next key will be modified accordingly. So for Ctrl+^, mintty
sends ^^ right away and then clears the dead key state using a trick
picked up from http://blogs.msdn.com/michkap/archive/2006/04/06/569632.aspx:
feed VK_DECIMALs into ToUnicode until it stops returning dead-key
characters.

(Yep, it's a terrible API for an unintuitive feature. See also
http://blogs.msdn.com/michkap/archive/2005/01/19/355870.aspx)

Andy


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]