[gtksourceview/wip/chergert/vim] allow special down-1 movement for repeat chars
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim] allow special down-1 movement for repeat chars
- Date: Wed, 3 Nov 2021 19:45:33 +0000 (UTC)
commit 4db2837ffef9f40e5fdcff1d0ba1f3308f00f62a
Author: Christian Hergert <chergert redhat com>
Date: Wed Nov 3 12:44:45 2021 -0700
allow special down-1 movement for repeat chars
things like yy or dd are really more like y0y or d0d and this makes that
a bit easier to replicate.
gtksourceview/vim/gtk-source-vim-motion.c | 25 +++++++++++++++++++++++++
gtksourceview/vim/gtk-source-vim-motion.h | 2 ++
2 files changed, 27 insertions(+)
---
diff --git a/gtksourceview/vim/gtk-source-vim-motion.c b/gtksourceview/vim/gtk-source-vim-motion.c
index f16a4d06..ec9b4e2e 100644
--- a/gtksourceview/vim/gtk-source-vim-motion.c
+++ b/gtksourceview/vim/gtk-source-vim-motion.c
@@ -71,6 +71,11 @@ struct _GtkSourceVimMotion
*/
int alter_count;
+ /* If this is specified, we want to treat it like a `j` but
+ * with the count subtracted by one. Useful for yy, dd, etc.
+ */
+ guint linewise_keyval;
+
/* Apply the motion when leaving the state. This is useful
* so that you can either capture a motion for future use
* or simply apply it immediately.
@@ -1325,6 +1330,17 @@ gtk_source_vim_motion_handle_keypress (GtkSourceVimState *state,
}
}
+ if (keyval != 0 && keyval == self->linewise_keyval)
+ {
+ self->motion = motion_next_line_visual_column;
+ self->inclusivity = EXCLUSIVE;
+ self->wise = LINEWISE;
+ self->alter_count = -1;
+ g_string_truncate (self->command_text, 0);
+ gtk_source_vim_state_pop (GTK_SOURCE_VIM_STATE (self));
+ return TRUE;
+ }
+
switch (keyval)
{
case GDK_KEY_0:
@@ -1897,3 +1913,12 @@ gtk_source_vim_motion_new_down (int alter_count)
return GTK_SOURCE_VIM_STATE (self);
}
+
+void
+gtk_source_vim_motion_set_linewise_keyval (GtkSourceVimMotion *self,
+ guint keyval)
+{
+ g_return_if_fail (GTK_SOURCE_IS_VIM_MOTION (self));
+
+ self->linewise_keyval = keyval;
+}
diff --git a/gtksourceview/vim/gtk-source-vim-motion.h b/gtksourceview/vim/gtk-source-vim-motion.h
index e74f5c27..3dda7eac 100644
--- a/gtksourceview/vim/gtk-source-vim-motion.h
+++ b/gtksourceview/vim/gtk-source-vim-motion.h
@@ -43,6 +43,8 @@ GtkSourceVimState *gtk_source_vim_motion_new_previous_line_end (void);
GtkSourceVimState *gtk_source_vim_motion_new_forward_char (void);
GtkSourceVimState *gtk_source_vim_motion_new_down (int adjust_count);
GtkSourceVimState *gtk_source_vim_motion_new_line_start (void);
+void gtk_source_vim_motion_set_linewise_keyval (GtkSourceVimMotion *self,
+ guint keyval);
void gtk_source_vim_motion_set_apply_on_leave (GtkSourceVimMotion *self,
gboolean apply_on_leave);
void gtk_source_vim_motion_set_mark (GtkSourceVimMotion *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]