[gtksourceview/wip/chergert/vim] extract motion test



commit ac66aaa8ce48c230198e6c9b9b25515c6230f7d7
Author: Christian Hergert <chergert redhat com>
Date:   Tue Nov 2 14:59:22 2021 -0700

    extract motion test

 gtksourceview/vim/gtk-source-vim-visual.c | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-visual.c b/gtksourceview/vim/gtk-source-vim-visual.c
index 2e828907..636756f5 100644
--- a/gtksourceview/vim/gtk-source-vim-visual.c
+++ b/gtksourceview/vim/gtk-source-vim-visual.c
@@ -315,6 +315,26 @@ gtk_source_vim_visual_delete (GtkSourceVimVisual *self)
        return TRUE;
 }
 
+static gboolean
+gtk_source_vim_visual_try_motion (GtkSourceVimVisual *self,
+                                  guint               keyval,
+                                  guint               keycode,
+                                  GdkModifierType     mods,
+                                  const char         *str)
+{
+       GtkSourceVimState *motion;
+
+       g_assert (GTK_SOURCE_IS_VIM_VISUAL (self));
+
+       /* Try to apply a motion to our cursor */
+       motion = gtk_source_vim_motion_new ();
+       gtk_source_vim_motion_set_mark (GTK_SOURCE_VIM_MOTION (motion), self->cursor);
+       gtk_source_vim_state_push (GTK_SOURCE_VIM_STATE (self), motion);
+       gtk_source_vim_state_synthesize (motion, keyval, mods);
+
+       return TRUE;
+}
+
 static gboolean
 key_handler_initial (GtkSourceVimVisual *self,
                      guint               keyval,
@@ -322,8 +342,6 @@ key_handler_initial (GtkSourceVimVisual *self,
                      GdkModifierType     mods,
                      const char         *string)
 {
-       GtkSourceVimState *motion;
-
        g_assert (GTK_SOURCE_IS_VIM_VISUAL (self));
 
        switch (keyval)
@@ -362,13 +380,7 @@ key_handler_initial (GtkSourceVimVisual *self,
                        break;
        }
 
-       /* Try to apply a motion to our cursor */
-       motion = gtk_source_vim_motion_new ();
-       gtk_source_vim_motion_set_mark (GTK_SOURCE_VIM_MOTION (motion), self->cursor);
-       gtk_source_vim_state_push (GTK_SOURCE_VIM_STATE (self), motion);
-       gtk_source_vim_state_synthesize (motion, keyval, mods);
-
-       return TRUE;
+       return gtk_source_vim_visual_try_motion (self, keyval, keycode, mods, string);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]