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. You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany-plugins/pull/735
-- Commit Summary --
* vimode: A Vim Mode for Geany
-- File Changes --
M MAINTAINERS (7) M Makefile.am (4) M build/geany-plugins.nsi (1) A build/vimode.m4 (9) M configure.ac (1) A vimode/AUTHORS (1) A vimode/COPYING (340) A vimode/ChangeLog (0) A vimode/Makefile.am (4) A vimode/NEWS (0) A vimode/README (565) A vimode/THANKS (8) A vimode/index.txt (1657) A vimode/src/Makefile.am (58) A vimode/src/backends/backend-geany.c (341) A vimode/src/backends/backend-viw.c (246) A vimode/src/cmd-params.c (46) A vimode/src/cmd-params.h (76) A vimode/src/cmd-runner.c (683) A vimode/src/cmd-runner.h (28) A vimode/src/cmds/changemode.c (242) A vimode/src/cmds/changemode.h (51) A vimode/src/cmds/edit.c (449) A vimode/src/cmds/edit.h (66) A vimode/src/cmds/motion.c (528) A vimode/src/cmds/motion.h (77) A vimode/src/cmds/special.c (117) A vimode/src/cmds/special.h (38) A vimode/src/cmds/txtobjs.c (190) A vimode/src/cmds/txtobjs.h (41) A vimode/src/context.h (62) A vimode/src/excmd-params.h (37) A vimode/src/excmd-prompt.c (134) A vimode/src/excmd-prompt.h (30) A vimode/src/excmd-runner.c (458) A vimode/src/excmd-runner.h (26) A vimode/src/excmds/excmds.c (66) A vimode/src/excmds/excmds.h (33) A vimode/src/keypress.c (196) A vimode/src/keypress.h (38) A vimode/src/sci.c (33) A vimode/src/sci.h (43) A vimode/src/utils.c (221) A vimode/src/utils.h (36) A vimode/src/vi.c (383) A vimode/src/vi.h (64)
-- Patch Links --
https://github.com/geany/geany-plugins/pull/735.patch https://github.com/geany/geany-plugins/pull/735.diff
This is the corresponding pull request in Geany: https://github.com/geany/geany/pull/1829
@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 `<esc><esc>:wq!` 1970s neurons still firing :)
I used an Ubuntu 14.04 VM to test this out.
- I took the sources of the [Geany 1.33 PPA](https://launchpad.net/~geany-dev/+archive/ubuntu/ppa), applied [your Geany patch](https://github.com/geany/geany/pull/1829) (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.
pcworld commented on this pull request.
- along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "keypress.h" +#include "utils.h" + +#include <gdk/gdkkeysyms.h> + +KeyPress *kp_from_event_key(GdkEventKey *ev) +{ + guint mask = GDK_MODIFIER_MASK & ~(GDK_SHIFT_MASK | GDK_LOCK_MASK | GDK_CONTROL_MASK); + KeyPress *kp; + + if (ev->state & mask) + return NULL;
I found the cause of my issue with vimode not recognizing keypresses. I have num lock enabled, which maps to [`GDK_MOD2_MASK`](https://github.com/GNOME/gtk/blob/cfa04805a327300056b7cfb5b3c127e667b8f4c3/g...) 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:
```diff --- 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) ```
@techee pushed 1 commit.
46102a8 vimode: Only ignore key presses containing Alt
techee commented on this pull request.
- along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "keypress.h" +#include "utils.h" + +#include <gdk/gdkkeysyms.h> + +KeyPress *kp_from_event_key(GdkEventKey *ev) +{ + guint mask = GDK_MODIFIER_MASK & ~(GDK_SHIFT_MASK | GDK_LOCK_MASK | GDK_CONTROL_MASK); + KeyPress *kp; + + if (ev->state & mask) + return NULL;
@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 pushed 1 commit.
17833ef vimode: % searches for first suitable character
@techee pushed 1 commit.
e2c9197 vimode: Use dedicated Geany key-press signal instead of key-press-event
@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.
Merged #735.
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.
github-comments@lists.geany.org