[gtksourceview/wip/chergert/vim: 228/293] handle g? in visual mode




commit d8a7122db3b47bcafa10795d42eed5c786542f25
Author: Christian Hergert <chergert redhat com>
Date:   Tue Nov 2 15:06:54 2021 -0700

    handle g? in visual mode

 gtksourceview/vim/gtk-source-vim-visual.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
---
diff --git a/gtksourceview/vim/gtk-source-vim-visual.c b/gtksourceview/vim/gtk-source-vim-visual.c
index 636756f5..23c288ff 100644
--- a/gtksourceview/vim/gtk-source-vim-visual.c
+++ b/gtksourceview/vim/gtk-source-vim-visual.c
@@ -335,6 +335,32 @@ gtk_source_vim_visual_try_motion (GtkSourceVimVisual *self,
        return TRUE;
 }
 
+static gboolean
+key_handler_g (GtkSourceVimVisual *self,
+              guint               keyval,
+              guint               keycode,
+              GdkModifierType     mods,
+              const char         *string)
+{
+       GtkSourceVimState *new_state;
+
+       g_assert (GTK_SOURCE_IS_VIM_VISUAL (self));
+
+       switch (keyval)
+       {
+               case GDK_KEY_question:
+                       return gtk_source_vim_visual_begin_command (self, "rot13");
+
+               default:
+                       new_state = gtk_source_vim_motion_new ();
+                       gtk_source_vim_motion_set_mark (GTK_SOURCE_VIM_MOTION (new_state), self->cursor);
+                       gtk_source_vim_state_push (GTK_SOURCE_VIM_STATE (self), new_state);
+                       gtk_source_vim_state_synthesize (new_state, GDK_KEY_g, 0);
+                       gtk_source_vim_state_synthesize (new_state, keyval, mods);
+                       return TRUE;
+       }
+}
+
 static gboolean
 key_handler_initial (GtkSourceVimVisual *self,
                      guint               keyval,
@@ -376,6 +402,10 @@ key_handler_initial (GtkSourceVimVisual *self,
                case GDK_KEY_u:
                        return gtk_source_vim_visual_begin_command (self, "downcase");
 
+               case GDK_KEY_g:
+                       self->handler = key_handler_g;
+                       return TRUE;
+
                default:
                        break;
        }


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