[gtksourceview/wip/chergert/vim: 45/293] start processing cmdbar a bit more




commit 27b1d3d5d7c50c8039bd185d47183c3710939dc9
Author: Christian Hergert <chergert redhat com>
Date:   Fri Oct 22 12:37:32 2021 -0700

    start processing cmdbar a bit more

 gtksourceview/vim/gtk-source-vim-command-bar.c | 37 ++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
---
diff --git a/gtksourceview/vim/gtk-source-vim-command-bar.c b/gtksourceview/vim/gtk-source-vim-command-bar.c
index 01c01dc1..3040fe65 100644
--- a/gtksourceview/vim/gtk-source-vim-command-bar.c
+++ b/gtksourceview/vim/gtk-source-vim-command-bar.c
@@ -67,6 +67,16 @@ do_notify (GtkSourceVimCommandBar *self)
        }
 }
 
+static void
+do_execute (GtkSourceVimCommandBar *self,
+           const char             *command)
+{
+       g_assert (GTK_SOURCE_IS_VIM_COMMAND_BAR (self));
+       g_assert (command != NULL);
+
+       g_print ("Exec command: %s\n", command);
+}
+
 static gboolean
 gtk_source_vim_command_bar_handle_keypress (GtkSourceVimState *state,
                                             guint              keyval,
@@ -90,6 +100,33 @@ gtk_source_vim_command_bar_handle_keypress (GtkSourceVimState *state,
                return TRUE;
        }
 
+       switch (keyval)
+       {
+               case GDK_KEY_BackSpace:
+                       gsize len = g_utf8_strlen (self->buffer->str, -1);
+
+                       if (len > 1)
+                       {
+                               char *s = g_utf8_offset_to_pointer (self->buffer->str, len-1);
+                               g_string_truncate (self->buffer, s - self->buffer->str);
+                               do_notify (self);
+                       }
+
+                       return TRUE;
+
+               case GDK_KEY_Return:
+               case GDK_KEY_KP_Enter:
+               case GDK_KEY_ISO_Enter:
+                       do_execute (self, self->buffer->str);
+                       g_string_truncate (self->buffer, 0);
+                       do_notify (self);
+                       gtk_source_vim_state_pop (state);
+                       return TRUE;
+
+               default:
+                       break;
+       }
+
        if (str[0])
        {
                g_string_append (self->buffer, str);


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