[gtksourceview/wip/chergert/vim] incremental work on improving visual replay of commands



commit c87d7b25752ddb60213a2ef79ce431d39d46de1a
Author: Christian Hergert <chergert redhat com>
Date:   Sun Oct 31 18:07:25 2021 -0700

    incremental work on improving visual replay of commands

 gtksourceview/vim/gtk-source-vim-normal.c |  2 ++
 gtksourceview/vim/gtk-source-vim-visual.c | 14 ++++++++++++++
 2 files changed, 16 insertions(+)
---
diff --git a/gtksourceview/vim/gtk-source-vim-normal.c b/gtksourceview/vim/gtk-source-vim-normal.c
index 74788ff7..db584ae4 100644
--- a/gtksourceview/vim/gtk-source-vim-normal.c
+++ b/gtksourceview/vim/gtk-source-vim-normal.c
@@ -245,6 +245,8 @@ gtk_source_vim_normal_begin_visual (GtkSourceVimNormal     *self,
        visual = gtk_source_vim_visual_new (mode);
        gtk_source_vim_state_set_count (visual, count);
 
+       gtk_source_vim_normal_clear (self);
+
        gtk_source_vim_state_push (GTK_SOURCE_VIM_STATE (self), visual);
 }
 
diff --git a/gtksourceview/vim/gtk-source-vim-visual.c b/gtksourceview/vim/gtk-source-vim-visual.c
index 43dce89f..1e28868d 100644
--- a/gtksourceview/vim/gtk-source-vim-visual.c
+++ b/gtksourceview/vim/gtk-source-vim-visual.c
@@ -392,19 +392,33 @@ static void
 gtk_source_vim_visual_repeat (GtkSourceVimState *state)
 {
        GtkSourceVimVisual *self = (GtkSourceVimVisual *)state;
+       GtkSourceBuffer *buffer;
+       GtkTextIter iter;
+       GtkTextIter selection;
        int count;
 
        g_assert (GTK_SOURCE_IS_VIM_STATE (self));
 
        count = gtk_source_vim_state_get_count (state);
+       buffer = gtk_source_vim_state_get_buffer (state, &iter, &selection);
+
+       gtk_text_buffer_move_mark (GTK_TEXT_BUFFER (buffer), self->cursor, &iter);
+       gtk_text_buffer_move_mark (GTK_TEXT_BUFFER (buffer), self->started_at, &selection);
 
        do
        {
                if (self->motion != NULL)
+               {
+                       gtk_source_vim_motion_set_mark (self->motion, self->cursor);
                        gtk_source_vim_state_repeat (GTK_SOURCE_VIM_STATE (self->motion));
+                       gtk_source_vim_visual_track_motion (self);
+                       gtk_source_vim_motion_set_mark (self->motion, NULL);
+               }
 
                if (self->command != NULL)
+               {
                        gtk_source_vim_state_repeat (self->command);
+               }
        } while (--count > 0);
 }
 


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