[gtksourceview/wip/chergert/vim] switch to visual if we discover a selection



commit 4af08ef56ef12bba4b4b2f92b9f1e006037827c7
Author: Christian Hergert <chergert redhat com>
Date:   Sat Nov 6 18:33:18 2021 -0700

    switch to visual if we discover a selection
    
    if we are in normal mode and a selection is made with the pointer, then
    try to enter visual mode.

 gtksourceview/vim/gtk-source-vim.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
---
diff --git a/gtksourceview/vim/gtk-source-vim.c b/gtksourceview/vim/gtk-source-vim.c
index fdd8878c..140a4286 100644
--- a/gtksourceview/vim/gtk-source-vim.c
+++ b/gtksourceview/vim/gtk-source-vim.c
@@ -30,6 +30,7 @@
 #include "gtk-source-vim-insert.h"
 #include "gtk-source-vim-normal.h"
 #include "gtk-source-vim-replace.h"
+#include "gtk-source-vim-visual.h"
 
 struct _GtkSourceVim
 {
@@ -149,6 +150,17 @@ constrain_insert_source (gpointer data)
                        gtk_text_buffer_select_range (GTK_TEXT_BUFFER (buffer), &iter, &iter);
                }
        }
+       else if (GTK_SOURCE_IS_VIM_NORMAL (current) &&
+                gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (buffer)))
+       {
+               GtkSourceVimState *visual;
+
+               /* Enter visual mode */
+               visual = gtk_source_vim_visual_new (GTK_SOURCE_VIM_VISUAL_CHAR);
+               gtk_source_vim_state_push (current, visual);
+               g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_COMMAND_TEXT]);
+               g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_COMMAND_BAR_TEXT]);
+       }
 
        return G_SOURCE_REMOVE;
 }


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