-
Notifications
You must be signed in to change notification settings - Fork 272
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
vimode: A Vim Mode for Geany #735
Conversation
This is the corresponding pull request in Geany: geany/geany#1829 |
96058dd
to
b9dc6a7
Compare
@techee since this plugin is the only way of testing the Geany PR, maybe you need some Vimist to test them both. |
@elextr Nah, brave non-vim user is enough. To make sure the Geany PR works, one only needs to know 1 vi command - "i". When you press "i", you enter the insert mode without adding the "i" character to the editor (that means that the "key-press" event "return FALSE" works). Now you can type something which shows in the editor (which means that the "key-press" event "return TRUE" works). That's it. Now you can quickly disable the plugin to avoid further brain damage. |
@techee |
I know what you think - the last thing Geany needed...
I used an Ubuntu 14.04 VM to test this out.
I get the block cursor so it seems the plugin itself is enabled. However it does not seem to capture keys correctly, i.e. typing text inserts text, Ctrl-W closes the current tab and pressing keys when text is selected replaces the selection. Pressing escape does not seem to have any effect. I did not change the vimode options. Note that Feel free to ignore if it's clear that it's my fault. Edit: See my following comment for the reason. |
vimode/src/keypress.c
Outdated
KeyPress *kp; | ||
|
||
if (ev->state & mask) | ||
return NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found the cause of my issue with vimode not recognizing keypresses. I have num lock enabled, which maps to GDK_MOD2_MASK
in GDK in X11 (in my configuration at least). The following patch fixes it for me, however an even less restrictive mask might be appropriate in order to avoid further false positives:
--- a/vimode/src/keypress.c
+++ b/vimode/src/keypress.c
@@ -23,7 +23,7 @@
KeyPress *kp_from_event_key(GdkEventKey *ev)
{
- guint mask = GDK_MODIFIER_MASK & ~(GDK_SHIFT_MASK | GDK_LOCK_MASK | GDK_CONTROL_MASK);
+ guint mask = GDK_MODIFIER_MASK & ~(GDK_SHIFT_MASK | GDK_LOCK_MASK | GDK_CONTROL_MASK | GDK_MOD2_MASK);
KeyPress *kp;
if (ev->state & mask)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pcworld Thanks, I've changed the code to return NULL only if ev->state contains Alt (GDK_MOD1_MASK). Should be enough and makes sure some other modifier isn't missed by accident.
Sorry for the force pushes, I didn't assume someone would make pull requests before it's merged. I'll do normal commits from now on so if you want to do more pull requests, there should be no problems now.
The previous mask was too restrictive and didn't contain GDK_MOD2_MASK used for numlock. To avoid similar problems in the future, ignore only Alt keypresses.
:help % specifies: > Find the next item in this line after or under the cursor and jump to > its match.
@techee Still depending on the PR on Geany core, right? |
@frlan Yep. |
@frlan Geany core PR committed. |
I've just tried to compile against Geany master and everything seems to work fine. So I guess the patch can be merged unless something else is missing. |
Let's test it in real life |
@frlan Thanks! I'll write an announcement on the mailing list so more people learn about the plugin. |
I know what you think - the last thing Geany needed...
This plugin depends on adding the "key-press" signal to Geany and won't work without it (even though it will probably compile alright). It shouldn't be merged before this functionality is in Geany.
@frlan Now it's finally pull request ready so if you have some patches or suggestions, please let me know.