Skip to content
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

Merged
merged 4 commits into from
May 28, 2018
Merged

vimode: A Vim Mode for Geany #735

merged 4 commits into from
May 28, 2018

Conversation

techee
Copy link
Member

@techee techee commented Apr 16, 2018

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.

@techee
Copy link
Member Author

techee commented Apr 16, 2018

This is the corresponding pull request in Geany: geany/geany#1829

@techee techee force-pushed the vim branch 3 times, most recently from 96058dd to b9dc6a7 Compare April 16, 2018 17:25
@elextr
Copy link
Member

elextr commented Apr 16, 2018

@techee since this plugin is the only way of testing the Geany PR, maybe you need some Vimist to test them both.

@techee
Copy link
Member Author

techee commented Apr 17, 2018

@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.

@elextr
Copy link
Member

elextr commented Apr 17, 2018

@techee <esc><esc>:wq! 1970s neurons still firing :)

I know what you think - the last thing Geany needed...
@pcworld
Copy link
Contributor

pcworld commented Apr 21, 2018

I used an Ubuntu 14.04 VM to test this out.

  • I took the sources of the Geany 1.33 PPA, applied your Geany patch (I ignored the GEANY_API_VERSION hunk as that failed to apply), then built with dpkg-buildpackage -us -uc -nc and installed the resulting packages.
    I'm not sure if the Geany patch is still necessary though given the comments in the PR, and I see that you did a force push but I can't find the original commit hash to compare with.
  • I cloned your branch and built vimode, copied vimode.so to ~/.config/geany/plugins and enabled the plugin in Geany.

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 viw behaves the same way.

Feel free to ignore if it's clear that it's my fault.

Edit: See my following comment for the reason.

KeyPress *kp;

if (ev->state & mask)
return NULL;
Copy link
Contributor

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)

Copy link
Member Author

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.

techee and others added 3 commits April 21, 2018 23:06
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.
@frlan
Copy link
Member

frlan commented May 5, 2018

@techee Still depending on the PR on Geany core, right?

@techee
Copy link
Member Author

techee commented May 6, 2018

@frlan Yep.

@elextr
Copy link
Member

elextr commented May 22, 2018

@frlan Geany core PR committed.

@techee
Copy link
Member Author

techee commented May 22, 2018

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.

@frlan frlan merged commit 1a575ee into geany:master May 28, 2018
@frlan
Copy link
Member

frlan commented May 28, 2018

Let's test it in real life

@techee
Copy link
Member Author

techee commented May 30, 2018

@frlan Thanks! I'll write an announcement on the mailing list so more people learn about the plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants