[gtksourceview/wip/chergert/vim] make begin_command like delete



commit ee9a87a1e5678e11480d3373ca2553bd85c71870
Author: Christian Hergert <chergert redhat com>
Date:   Tue Nov 2 13:51:24 2021 -0700

    make begin_command like delete

 gtksourceview/vim/gtk-source-vim-visual.c | 33 ++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-visual.c b/gtksourceview/vim/gtk-source-vim-visual.c
index 646af1fe..e7c06f9b 100644
--- a/gtksourceview/vim/gtk-source-vim-visual.c
+++ b/gtksourceview/vim/gtk-source-vim-visual.c
@@ -272,6 +272,27 @@ key_handler_register (GtkSourceVimVisual *self,
        return TRUE;
 }
 
+static gboolean
+gtk_source_vim_visual_begin_command (GtkSourceVimVisual *self,
+                                     const char         *command)
+{
+       g_assert (GTK_SOURCE_IS_VIM_VISUAL (self));
+       g_assert (command != NULL);
+
+       gtk_source_vim_visual_clear (self);
+       g_clear_object (&self->command);
+
+       gtk_source_vim_state_set_can_repeat (GTK_SOURCE_VIM_STATE (self), TRUE);
+
+       self->command = gtk_source_vim_command_new (command);
+       gtk_source_vim_state_set_parent (self->command, GTK_SOURCE_VIM_STATE (self));
+       gtk_source_vim_state_repeat (self->command);
+
+       gtk_source_vim_state_pop (GTK_SOURCE_VIM_STATE (self));
+
+       return TRUE;
+}
+
 static gboolean
 gtk_source_vim_visual_delete (GtkSourceVimVisual *self)
 {
@@ -316,17 +337,7 @@ key_handler_initial (GtkSourceVimVisual *self,
                        return TRUE;
 
                case GDK_KEY_y:
-               {
-                       GtkSourceVimState *command;
-                       command = g_object_new (GTK_SOURCE_TYPE_VIM_COMMAND,
-                                               "parent", self,
-                                               "command", ":yank",
-                                               NULL);
-                       gtk_source_vim_state_repeat (command);
-                       gtk_source_vim_state_pop (GTK_SOURCE_VIM_STATE (self));
-                       g_object_unref (command);
-                       return TRUE;
-               }
+                       return gtk_source_vim_visual_begin_command (self, ":yank");
 
                case GDK_KEY_v:
                        self->mode = GTK_SOURCE_VIM_VISUAL_CHAR;


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