-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Improve processing of key events in W32 GUI #10155
Conversation
This changeset adds what's essentially a replacement for TranslateMessage that takes into account the user keyboard layout and enables more events to be processed without having to special-case them. The use of MapVirtualKey allows Vim to resolve some of the "virtual" keycodes such as VK_OEM_{1..6} and friends according to the user kb layout. We call ToUnicode with an intentionally reduced keyboard state to avoid a pitfall of TranslateMessage: not every combinations of Ctrl+<key> produce a keycode (eg. Ctrl+] does not) and thus no WM_CHAR would be emitted for them. Since we only care about the character rather than its interaction with Ctrl or Alt let's drop those from the state matrix. The remaining code performs what TranslateMessage would do and pump the appropriate messages in the main loop. Two main differences: - Dead keys are handled in-place, no WM_DEADCHAR is emitted. - Modifiers are handled together with the keys they're associated to rather than leaving them in the input queue.
Codecov Report
@@ Coverage Diff @@
## master #10155 +/- ##
==========================================
- Coverage 81.97% 80.95% -1.03%
==========================================
Files 167 161 -6
Lines 187872 185512 -2360
Branches 42368 41940 -428
==========================================
- Hits 154017 150178 -3839
- Misses 21506 22789 +1283
- Partials 12349 12545 +196
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
No feedback about this PR? This change is much needed to make gVim able to map keys like |
This break IME (input method editor). I can not input multi-byte strings with this patch. |
Thanks for the feedback, I did try the latest version of this patch with the Japanese IME and now it seems to be working again. |
I'll wait for @mattn to confirm. |
I'm okay to merge. |
This change breaks key presses of ':' and other keys of neo2's 3rd level. Can you please fix this patch? 8.2.4807: processing key eveints in Win32 GUI is not ideal |
Hi @chrisbra, |
unfortunately, there doesn't seem to be a way to download those compiled binaries. I have now created #11762 to address this and give users the possibility to download the artifcats and test that. That means, once it is merged and PR authors rebase their work on top of it, you can then download artifacts and test those changes. |
@chrisbra thank you!! |
@chrisbra and @cmon1701 @cmon1701 when you can access a build of gvim (I'm not sure how @chrisbra #11762 works yet), but if you can get at least |
You go to the Appveyor CI page for vim and click on the PR that you are interested in. E.g. for #11767 you click on https://ci.appveyor.com/project/chrisbra/vim/builds/45810751 and there you will see the last Appveyor (windows builds and tests) results for that particular build. You will have a tab called artifacts, from which you can then download those build binaries (vim.exe and gvim.exe) |
Cool, thanks @chrisbra |
Ah, I've left my comment on the code page. After 4807 you can't press Ctrl+S (Windows 10) in Cyrillic layout in insert mode - you get 'ы' instead. You can't underestimate the lack of fast saving. The same is for other Ctrl keys too, like Ctrl+A, Ctrl+C, Ctrl+V etc. I didn't try 4806 but in 4803 everything was ok. |
Hi @sme-prus001 This PR was done over 10 months ago, and since then more recent changes have addressed some Ctrl+... functionality, at least I'm aware of the Ctrl+_ behavior was put back. Would it be possible for you to confirm if this is still a problem with the latest gVim? If you need to, you can grab an installer from here: https://github.com/vim/vim-win32-installer/releases I'll see if I can add some test scripts to cover this. |
Hi,
Thank you for the response.
I think it's in all the releases since that, because I was first alarmed when I installed the latest 9.0 and the functionality was not there. So I went to try other versions and find out what and when happened and found that commit. The url you gave me is exactly what I used.
You must have Cyrillic (or other non-Latin?) keyboard installed, open vim, insert mode, Alt+Shift to switch to Cyrillic, type some text, press Ctrl+S. If saved - ok, if 'ы' appeared - bad.
Vim should be installed with options "Vim with all enhancements (default)", "Remap a few keys", "Right: popup menu, Left: select mode (Windows)".
***@***.***
Regards
Georgiy Pruss
Edited: removed old messages, headers and other unrelated text.
|
@sme-prus001 thanks for the info. I'll try and test it. |
@LemonBoy It seems that vim and gVim started to mangle the key codes from the keyboard. It is still unclear for me why, but the current state is that pressing Just for the record here, I will reiterate that the keyboard still emits Could you confirm that the changes you committed, modify, or filter key codes received from the OS? |
This changeset adds what's essentially a replacement for
TranslateMessage that takes into account the user keyboard layout and
enables more events to be processed without having to special-case them.
The use of MapVirtualKey allows Vim to resolve some of the "virtual"
keycodes such as VK_OEM_{1..6} and friends according to the user kb
layout.
We call ToUnicode with an intentionally reduced keyboard state to avoid
a pitfall of TranslateMessage: not every combinations of Ctrl+
produce a keycode (eg. Ctrl+] does not) and thus no WM_CHAR would be
emitted for them. Since we only care about the character rather than its
interaction with Ctrl or Alt let's drop those from the state matrix.
The remaining code performs what TranslateMessage would do and pump the
appropriate messages in the main loop.
Two main differences:
rather than leaving them in the input queue.
Please test this patch with different keyboard layouts and try mappings including Ctrl and Alt, I've been using this for a couple of days with no problem at all.
Fixes the problem I noticed on my Windows machine and allows me to map
<C-]>
.Fixes #9895 again, in a different way.
CC @mattn and @k-takata, your feedback as seasoned Win32 hackers is much appreciated.