[gtksourceview/wip/chergert/vim: 14/363] add numbers for repeat




commit 3424a2544e1e952661098e8fb0afa42c2524006c
Author: Christian Hergert <chergert redhat com>
Date:   Thu Oct 21 16:36:45 2021 -0700

    add numbers for repeat

 gtksourceview/vim/gtk-source-vim-normal.c | 35 ++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-normal.c b/gtksourceview/vim/gtk-source-vim-normal.c
index 23614b7e..2acdc9eb 100644
--- a/gtksourceview/vim/gtk-source-vim-normal.c
+++ b/gtksourceview/vim/gtk-source-vim-normal.c
@@ -36,8 +36,16 @@ struct _GtkSourceVimNormal
        KeyHandler handler;
 
        int repeat;
+
+       guint has_repeat : 1;
 };
 
+static gboolean key_handler_initial (GtkSourceVimNormal *self,
+                                     guint               keyval,
+                                     guint               keycode,
+                                     GdkModifierType     mods,
+                                     const char         *string);
+
 G_DEFINE_TYPE (GtkSourceVimNormal, gtk_source_vim_normal, GTK_SOURCE_TYPE_VIM_STATE)
 
 static inline gboolean
@@ -67,9 +75,33 @@ key_handler_repeat (GtkSourceVimNormal *self,
                     GdkModifierType     mods,
                     const char         *string)
 {
+       int n;
+
        g_assert (GTK_SOURCE_IS_VIM_NORMAL (self));
 
-       return FALSE;
+       self->has_repeat = TRUE;
+
+       switch (keyval)
+       {
+               case GDK_KEY_0: case GDK_KEY_KP_0: n = 0; break;
+               case GDK_KEY_1: case GDK_KEY_KP_1: n = 1; break;
+               case GDK_KEY_2: case GDK_KEY_KP_2: n = 2; break;
+               case GDK_KEY_3: case GDK_KEY_KP_3: n = 3; break;
+               case GDK_KEY_4: case GDK_KEY_KP_4: n = 4; break;
+               case GDK_KEY_5: case GDK_KEY_KP_5: n = 5; break;
+               case GDK_KEY_6: case GDK_KEY_KP_6: n = 6; break;
+               case GDK_KEY_7: case GDK_KEY_KP_7: n = 7; break;
+               case GDK_KEY_8: case GDK_KEY_KP_8: n = 8; break;
+               case GDK_KEY_9: case GDK_KEY_KP_9: n = 9; break;
+
+               default:
+                       self->handler = key_handler_initial;
+                       return self->handler (self, keyval, keycode, mods, string);
+       }
+
+       self->repeat = self->repeat * 10 + n;
+
+       return TRUE;
 }
 
 static gboolean
@@ -473,4 +505,5 @@ gtk_source_vim_normal_clear (GtkSourceVimNormal *self)
 
        self->handler = key_handler_initial;
        self->repeat = 0;
+       self->has_repeat = FALSE;
 }


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