[gtksourceview/wip/chergert/vim] simplify



commit b49b2da6ec0bf8332c43764281ba69360f039273
Author: Christian Hergert <chergert redhat com>
Date:   Wed Oct 27 07:49:17 2021 -0700

    simplify

 gtksourceview/vim/gtk-source-vim-normal.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-normal.c b/gtksourceview/vim/gtk-source-vim-normal.c
index 52134826..2ce9e495 100644
--- a/gtksourceview/vim/gtk-source-vim-normal.c
+++ b/gtksourceview/vim/gtk-source-vim-normal.c
@@ -103,11 +103,13 @@ key_handler_repeat (GtkSourceVimNormal *self,
        return TRUE;
 }
 
-static void
+static GtkSourceVimState *
 begin_insert (GtkSourceVimNormal *self,
               GtkSourceVimState  *motion,
               gboolean            after_char)
 {
+       GtkSourceVimState *ret;
+
        g_assert (GTK_SOURCE_IS_VIM_NORMAL (self));
        g_assert (!motion || GTK_SOURCE_IS_VIM_MOTION (motion));
 
@@ -126,7 +128,9 @@ begin_insert (GtkSourceVimNormal *self,
                gtk_source_vim_state_select (GTK_SOURCE_VIM_STATE (self), &iter, &iter);
        }
 
-       gtk_source_vim_state_push (GTK_SOURCE_VIM_STATE (self), gtk_source_vim_insert_new ());
+       ret = gtk_source_vim_insert_new ();
+       gtk_source_vim_state_push (GTK_SOURCE_VIM_STATE (self), ret);
+       return ret;
 }
 
 static gboolean
@@ -175,8 +179,7 @@ key_handler_command (GtkSourceVimNormal *self,
        switch (keyval)
        {
                case GDK_KEY_i:
-                       new_state = gtk_source_vim_insert_new ();
-                       gtk_source_vim_state_push (GTK_SOURCE_VIM_STATE (self), new_state);
+                       begin_insert (self, gtk_source_vim_motion_new_none (), FALSE);
                        return TRUE;
 
                case GDK_KEY_R:
@@ -185,13 +188,15 @@ key_handler_command (GtkSourceVimNormal *self,
                        return TRUE;
 
                case GDK_KEY_I:
-                       new_state = gtk_source_vim_motion_new_first_char ();
-                       begin_insert (self, new_state, FALSE);
+                       begin_insert (self, gtk_source_vim_motion_new_first_char (), FALSE);
                        return TRUE;
 
                case GDK_KEY_A:
-                       new_state = gtk_source_vim_motion_new_line_end ();
-                       begin_insert (self, new_state, TRUE);
+                       begin_insert (self, gtk_source_vim_motion_new_line_end (), TRUE);
+                       return TRUE;
+
+               case GDK_KEY_o:
+                       new_state = begin_insert (self, gtk_source_vim_motion_new_line_end (), TRUE);
                        return TRUE;
 
                case GDK_KEY_a:
@@ -199,7 +204,6 @@ key_handler_command (GtkSourceVimNormal *self,
                case GDK_KEY_C:
                case GDK_KEY_D:
                case GDK_KEY_J:
-               case GDK_KEY_o:
                case GDK_KEY_O:
                case GDK_KEY_p:
                case GDK_KEY_P:


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