[geany/geany-plugins] 55a25b: Merge pull request #820 from techee/vi_fix

Frank Lanitz git-noreply at xxxxx
Sun Mar 24 18:17:36 UTC 2019


Branch:      refs/heads/master
Author:      Frank Lanitz <frank at frank.uvena.de>
Committer:   GitHub <noreply at github.com>
Date:        Sun, 24 Mar 2019 18:17:36 UTC
Commit:      55a25bbc71a58310e86dfc0a94e123c01564388f
             https://github.com/geany/geany-plugins/commit/55a25bbc71a58310e86dfc0a94e123c01564388f

Log Message:
-----------
Merge pull request #820 from techee/vi_fix

vimode: Fix repeated commands like 10dd not working


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