From 980bef89fd6300da016d6aa7dec9121e42359f93 Mon Sep 17 00:00:00 2001 From: Carlo Lobrano Date: Thu, 3 Oct 2019 12:02:30 +0200 Subject: [PATCH 1/3] added "keystroke a: insert after current position" action Support for keystroke "a", which maps into "insert after current position" was missing from handle_key_press function. Fixed adding the case using the Gdk.Key.i as example. closes #614 --- plugins/vim-emulation/vim-emulation.vala | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/vim-emulation/vim-emulation.vala b/plugins/vim-emulation/vim-emulation.vala index 6f747452d2..4ba5a920c9 100644 --- a/plugins/vim-emulation/vim-emulation.vala +++ b/plugins/vim-emulation/vim-emulation.vala @@ -80,6 +80,18 @@ public class Scratch.Plugins.VimEmulation : Peas.ExtensionBase, Peas.Activatabl // Firstly let's set the mode switch (event.keyval) { //mode changing + case Gdk.Key.a: + if (mode == Mode.INSERT) { + return false; + } else { + // clean action string + action = ""; + } + + mode = Mode.INSERT; + view.move_cursor (Gtk.MovementStep.VISUAL_POSITIONS, 1, false); + debug ("Vim Emulation: INSERT Mode!"); + return true; case Gdk.Key.i: if (mode == Mode.INSERT) { return false; From 324fa9a47fc1b3f852d2db82b67f5168aa9aee81 Mon Sep 17 00:00:00 2001 From: Carlo Lobrano Date: Tue, 15 Oct 2019 10:38:09 +0200 Subject: [PATCH 2/3] vim-emulation: move "a" keystroke code into proper position Previously, code was in a "change mode" section, while "a" keystroke is also a movement action, so moved closed to the "A" keystroke implementation (code review). --- plugins/vim-emulation/vim-emulation.vala | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/plugins/vim-emulation/vim-emulation.vala b/plugins/vim-emulation/vim-emulation.vala index 8e2b3f0687..f71ae6efc2 100644 --- a/plugins/vim-emulation/vim-emulation.vala +++ b/plugins/vim-emulation/vim-emulation.vala @@ -79,18 +79,6 @@ public class Scratch.Plugins.VimEmulation : Peas.ExtensionBase, Peas.Activatable // Firstly let's set the mode switch (event.keyval) { //mode changing - case Gdk.Key.a: - if (mode == Mode.INSERT) { - return false; - } else { - // clean action string - action = ""; - } - - mode = Mode.INSERT; - view.move_cursor (Gtk.MovementStep.VISUAL_POSITIONS, 1, false); - debug ("Vim Emulation: INSERT Mode!"); - return true; case Gdk.Key.i: if (mode == Mode.INSERT) { return false; @@ -197,6 +185,17 @@ public class Scratch.Plugins.VimEmulation : Peas.ExtensionBase, Peas.Activatable buffer.place_cursor (start); debug ("Vim Emulation: INSERT Mode!"); break; + case Gdk.Key.a: + if (mode == Mode.INSERT) { + return false; + } + // clean action string + action = ""; + + mode = Mode.INSERT; + view.move_cursor (Gtk.MovementStep.VISUAL_POSITIONS, 1, false); + debug ("Vim Emulation: INSERT Mode!"); + return true; case Gdk.Key.A: if (mode == Mode.INSERT) { return false; From 12961f56a0e38a551ae74be8e67829019bb22660 Mon Sep 17 00:00:00 2001 From: Carlo Lobrano Date: Tue, 15 Oct 2019 17:05:56 +0200 Subject: [PATCH 3/3] vim-emulation: add [count] support to "a" keystroke Allow to start editing after [count] character, being [count] a number typed just after pressing the "a" key. --- plugins/vim-emulation/vim-emulation.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/vim-emulation/vim-emulation.vala b/plugins/vim-emulation/vim-emulation.vala index f71ae6efc2..ab3af5bf48 100644 --- a/plugins/vim-emulation/vim-emulation.vala +++ b/plugins/vim-emulation/vim-emulation.vala @@ -193,7 +193,7 @@ public class Scratch.Plugins.VimEmulation : Peas.ExtensionBase, Peas.Activatable action = ""; mode = Mode.INSERT; - view.move_cursor (Gtk.MovementStep.VISUAL_POSITIONS, 1, false); + view.move_cursor (Gtk.MovementStep.VISUAL_POSITIONS, number == "" ? 1 : int.parse (number), false); debug ("Vim Emulation: INSERT Mode!"); return true; case Gdk.Key.A: