[gtksourceview/wip/chergert/vim: 207/293] allow setting register with "<name>
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim: 207/293] allow setting register with "<name>
- Date: Fri, 5 Nov 2021 04:23:05 +0000 (UTC)
commit 4c55f37bb1029ef4a85e457af64e960b5394fe81
Author: Christian Hergert <chergert redhat com>
Date: Tue Nov 2 12:10:46 2021 -0700
allow setting register with "<name>
you can now do "myy to copy the line into register m
gtksourceview/vim/gtk-source-vim-normal.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
---
diff --git a/gtksourceview/vim/gtk-source-vim-normal.c b/gtksourceview/vim/gtk-source-vim-normal.c
index 403f4392..caaa9fdc 100644
--- a/gtksourceview/vim/gtk-source-vim-normal.c
+++ b/gtksourceview/vim/gtk-source-vim-normal.c
@@ -79,6 +79,7 @@ gtk_source_vim_normal_bail (GtkSourceVimNormal *self)
g_assert (GTK_SOURCE_IS_VIM_NORMAL (self));
gtk_source_vim_state_beep (GTK_SOURCE_VIM_STATE (self));
+ gtk_source_vim_state_set_current_register (GTK_SOURCE_VIM_STATE (self), NULL);
gtk_source_vim_normal_clear (self);
return TRUE;
@@ -684,6 +685,28 @@ key_handler_yank (GtkSourceVimNormal *self,
return TRUE;
}
+static gboolean
+key_handler_register (GtkSourceVimNormal *self,
+ guint keyval,
+ guint keycode,
+ GdkModifierType mods,
+ const char *string)
+{
+ g_assert (GTK_SOURCE_IS_VIM_NORMAL (self));
+
+ if (string == NULL || string[0] == 0)
+ {
+ /* We require a string to access the register */
+ return gtk_source_vim_normal_bail (self);
+ }
+
+ gtk_source_vim_state_set_current_register (GTK_SOURCE_VIM_STATE (self), string);
+
+ self->handler = key_handler_initial;
+
+ return TRUE;
+}
+
static gboolean
key_handler_split (GtkSourceVimNormal *self,
guint keyval,
@@ -889,6 +912,10 @@ key_handler_initial (GtkSourceVimNormal *self,
self->handler = key_handler_command;
break;
+ case GDK_KEY_quotedbl:
+ self->handler = key_handler_register;
+ return TRUE;
+
case GDK_KEY_y:
self->handler = key_handler_yank;
return TRUE;
@@ -1001,6 +1028,7 @@ gtk_source_vim_normal_resume (GtkSourceVimState *state,
gtk_source_vim_normal_clear (GTK_SOURCE_VIM_NORMAL (state));
gtk_source_vim_state_set_overwrite (state, TRUE);
+ gtk_source_vim_state_set_current_register (state, NULL);
/* Go back one character if we exited replace/insert state */
if (GTK_SOURCE_IS_VIM_INSERT (from) || GTK_SOURCE_IS_VIM_REPLACE (from))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]