[geany/geany-plugins] 47e165: vimode: Fix repeated commands like 10dd not working

Jiří Techet git-noreply at xxxxx
Sun Mar 24 18:17:45 UTC 2019


Branch:      refs/heads/master
Author:      Jiří Techet <techet at gmail.com>
Committer:   Jiří Techet <techet at gmail.com>
Date:        Sat, 09 Feb 2019 23:17:54 UTC
Commit:      47e16587e6f6d7bc0193d5dc3f17bc8f594b833b
             https://github.com/geany/geany-plugins/commit/47e16587e6f6d7bc0193d5dc3f17bc8f594b833b

Log Message:
-----------
vimode: Fix repeated commands like 10dd not working

By last-minute mistake made before the initial plugin release, none of the
repeat commands worked because numbers were removed from the key press
list. This patch fixes that issue.

This is what happens when the author of the plugin actually doesn't use
what he has created.


Modified Paths:
--------------
    vimode/src/cmd-runner.c
    vimode/src/vi.c

Modified: vimode/src/cmd-runner.c
22 lines changed, 17 insertions(+), 5 deletions(-)
===================================================================
@@ -428,6 +428,18 @@ static gboolean is_cmdpart(GSList *kpl, CmdDef *cmds)
 }
 
 
+static gboolean is_printable(GSList *kpl)
+{
+	guint mask = GDK_MODIFIER_MASK & ~(GDK_SHIFT_MASK | GDK_LOCK_MASK);
+	KeyPress *kp = g_slist_nth_data(kpl, 0);
+
+	if (kp->modif & mask)
+		return FALSE;
+
+	return g_unichar_isprint(gdk_keyval_to_unicode(kp->key));
+}
+
+
 static CmdDef *get_cmd_to_run(GSList *kpl, CmdDef *cmds, gboolean have_selection)
 {
 	gint i;
@@ -609,7 +621,7 @@ static gboolean perform_repeat_cmd(CmdContext *ctx)
 }
 
 
-static gboolean process_cmd(CmdDef *cmds, CmdContext *ctx)
+static gboolean process_cmd(CmdDef *cmds, CmdContext *ctx, gboolean ins_mode)
 {
 	gboolean consumed;
 	gboolean performed = FALSE;
@@ -618,7 +630,7 @@ static gboolean process_cmd(CmdDef *cmds, CmdContext *ctx)
 		SSM(ctx->sci, SCI_GETSELECTIONEND, 0, 0) - SSM(ctx->sci, SCI_GETSELECTIONSTART, 0, 0) > 0;
 	CmdDef *def = get_cmd_to_run(ctx->kpl, cmds, have_selection);
 
-	consumed = is_cmdpart(ctx->kpl, cmds);
+	consumed = is_cmdpart(ctx->kpl, cmds) || (!ins_mode && is_printable(ctx->kpl));
 
 	if (def)
 	{
@@ -667,17 +679,17 @@ static gboolean process_cmd(CmdDef *cmds, CmdContext *ctx)
 
 gboolean cmd_perform_cmd(CmdContext *ctx)
 {
-	return process_cmd(cmd_mode_cmds, ctx);
+	return process_cmd(cmd_mode_cmds, ctx, FALSE);
 }
 
 
 gboolean cmd_perform_vis(CmdContext *ctx)
 {
-	return process_cmd(vis_mode_cmds, ctx);
+	return process_cmd(vis_mode_cmds, ctx, FALSE);
 }
 
 
 gboolean cmd_perform_ins(CmdContext *ctx)
 {
-	return process_cmd(ins_mode_cmds, ctx);
+	return process_cmd(ins_mode_cmds, ctx, TRUE);
 }


Modified: vimode/src/vi.c
12 lines changed, 0 insertions(+), 12 deletions(-)
===================================================================
@@ -210,17 +210,6 @@ void vi_set_active_sci(ScintillaObject *sci)
 }
 
 
-static gboolean is_printable(GdkEventKey *ev)
-{
-	guint mask = GDK_MODIFIER_MASK & ~(GDK_SHIFT_MASK | GDK_LOCK_MASK);
-
-	if (ev->state & mask)
-		return FALSE;
-
-	return g_unichar_isprint(gdk_keyval_to_unicode(ev->keyval));
-}
-
-
 gboolean vi_notify_key_press(GdkEventKey *event)
 {
 	ScintillaObject *sci = ctx.sci;
@@ -244,7 +233,6 @@ gboolean vi_notify_key_press(GdkEventKey *event)
 			consumed = cmd_perform_cmd(&ctx);
 		else
 			consumed = cmd_perform_vis(&ctx);
-		consumed = consumed || is_printable(event);
 	}
 	else //insert, replace mode
 	{



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list