[gtksourceview/wip/chergert/vim] allow replaying last visual
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim] allow replaying last visual
- Date: Sat, 30 Oct 2021 22:58:01 +0000 (UTC)
commit 376852a0bef6d0f594da04be78601c3d44bba02a
Author: Christian Hergert <chergert redhat com>
Date: Sat Oct 30 15:57:41 2021 -0700
allow replaying last visual
this allows you to exit visual mode, then type gv to renter it. If text
has been entered between the marks, the range will expand just as it does
in VIM.
gtksourceview/vim/gtk-source-vim-normal.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
---
diff --git a/gtksourceview/vim/gtk-source-vim-normal.c b/gtksourceview/vim/gtk-source-vim-normal.c
index 2597390a..74788ff7 100644
--- a/gtksourceview/vim/gtk-source-vim-normal.c
+++ b/gtksourceview/vim/gtk-source-vim-normal.c
@@ -44,6 +44,7 @@ struct _GtkSourceVimNormal
GtkSourceVimState parent_instance;
GString *command_text;
GtkSourceVimState *repeat;
+ GtkSourceVimState *last_visual;
KeyHandler handler;
int count;
guint has_count : 1;
@@ -725,6 +726,14 @@ key_handler_g (GtkSourceVimNormal *self,
gtk_source_vim_state_synthesize (new_state, keyval, mods);
return TRUE;
+ case GDK_KEY_v:
+ if (self->last_visual == NULL)
+ return gtk_source_vim_normal_bail (self);
+
+ new_state = gtk_source_vim_visual_clone (GTK_SOURCE_VIM_VISUAL (self->last_visual));
+ gtk_source_vim_state_push (GTK_SOURCE_VIM_STATE (self), new_state);
+ return TRUE;
+
default:
return gtk_source_vim_normal_bail (self);
}
@@ -994,6 +1003,12 @@ gtk_source_vim_normal_resume (GtkSourceVimState *state,
go_backward_char (self);
}
+ if (GTK_SOURCE_IS_VIM_VISUAL (from))
+ {
+ /* Store last visual around for reselection in gv */
+ g_set_object (&self->last_visual, from);
+ }
+
/* Always scroll the insert mark onscreen */
gtk_text_view_scroll_mark_onscreen (GTK_TEXT_VIEW (view), insert);
@@ -1033,6 +1048,7 @@ gtk_source_vim_normal_dispose (GObject *object)
{
GtkSourceVimNormal *self = (GtkSourceVimNormal *)object;
+ g_clear_object (&self->last_visual);
g_clear_object (&self->repeat);
g_string_free (self->command_text, TRUE);
self->command_text = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]