8000 numberedbookmarks: fix Ctrl+num and Ctrl+Shift+num on various keyboard layouts by techee · Pull Request #1458 · geany/geany-plugins · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

numberedbookmarks: fix Ctrl+num and Ctrl+Shift+num on various keyboard layouts #1458

8000 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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

techee
Copy link
Member
@techee techee commented Jun 27, 2025

Inside plugin_init(), the current version precomputes key values for number keys after pressing shift (on US keyboard, ! for 1, @, for 2, etc.) and uses these values for detecting key presses. However, it makes some assumptions that are not quite correct for all keyboard layouts:

  1. It assumes that keyboard layout cannot change and precomputes key values once on plugin init. It is quite common to change keyboard layout while using an editor and the precomputed values aren't correct in this case.
  2. It assumes that numbers are typed directly for all keyboard layouts without pressing shift. This is incorrect e.g. for the Czech keyboard where numbers are typed by Shift plus a key from the top row. In this case the current code doesn't precompute Shift+key values correctly
  3. By assuming that numbers are typed without shift, it detects Ctrl+numkey incorrectly on keyboard layouts requiring shift.

This patch fixes these issues in the following way:

  1. It moves key precomputation outside plugin_init() and performs it every time Ctrl+key or Ctrl+Shift+key is pressed.
  2. It stores precomputed numeric key values both for Shift+key and NonShift+key variants. Since the Shift key gets consumed by GTK and we can't be sure whether it was pressed or not, we can use these two groups and based on key presence in one of them we can determine whether Shift was pressed or not and perform the corresponding action.

…d layouts

Inside plugin_init(), the current version precomputes key values for
number keys after pressing shift (on US keyboard, ! for 1, @, for 2, etc.)
and uses these values for detecting key presses. However, it makes
some assumptions that are not quite correct for all keyboard layouts:

1. It assumes that keyboard layout cannot change and precomputes
key values once on plugin init. It is quite common to change keyboard
layout while using an editor and the precomputed values aren't correct
in this case.
2. It assumes that numbers are typed directly for all keyboard layouts
without pressing shift. This is incorrect e.g. for the Czech keyboard
where numbers are typed by Shift plus a key from the top row. In this
case the current code doesn't precompute Shift+key values correctly
3. By assuming that numbers are typed without shift, it detects
Ctrl+numkey incorrectly on keyboard layouts requiring shift.

This patch fixes these issues in the following way:
1. It moves key precomputation outside plugin_init() and performs it
every time Ctrl+key or Ctrl+Shift+key is pressed.
2. It stores precomputed numeric key values both for Shift+key and
NonShift+key variants. Since the Shift key gets consumed by GTK and
we can't be sure whether it was pressed or not, we can use these two
groups and based on key presence in one of them we can determine whether
Shift was pressed or not and perform the corresponding action.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0