[gtksourceview/wip/chergert/vim: 43/73] start processing cmdbar a bit more
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim: 43/73] start processing cmdbar a bit more
- Date: Tue, 26 Oct 2021 23:20:37 +0000 (UTC)
commit 39f7d1ed20ae6f6578ee3430cc5dc6eea1c3d6ca
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]