[gtksourceview/wip/chergert/vim] add command text for motions
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim] add command text for motions
- Date: Wed, 27 Oct 2021 00:17:56 +0000 (UTC)
commit bb23ae5e59d199f183f28e6f89a7b84ad0af7f4b
Author: Christian Hergert <chergert redhat com>
Date: Tue Oct 26 17:17:52 2021 -0700
add command text for motions
gtksourceview/vim/gtk-source-vim-motion.c | 34 +++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
---
diff --git a/gtksourceview/vim/gtk-source-vim-motion.c b/gtksourceview/vim/gtk-source-vim-motion.c
index ae4d8860..010d41ad 100644
--- a/gtksourceview/vim/gtk-source-vim-motion.c
+++ b/gtksourceview/vim/gtk-source-vim-motion.c
@@ -32,6 +32,9 @@ struct _GtkSourceVimMotion
{
GtkSourceVimState parent_instance;
+ /* Text as it's typed for append_command() */
+ GString *command_text;
+
/* A function to apply the motion */
Motion motion;
@@ -977,6 +980,8 @@ gtk_source_vim_motion_bail (GtkSourceVimMotion *self)
{
g_assert (GTK_SOURCE_IS_VIM_MOTION (self));
+ g_string_truncate (self->command_text, 0);
+
self->failed = TRUE;
gtk_source_vim_state_pop (GTK_SOURCE_VIM_STATE (self));
@@ -990,7 +995,10 @@ gtk_source_vim_motion_complete (GtkSourceVimMotion *self,
g_assert (GTK_SOURCE_IS_VIM_MOTION (self));
self->motion = motion;
+ g_string_truncate (self->command_text, 0);
+
gtk_source_vim_state_pop (GTK_SOURCE_VIM_STATE (self));
+
return TRUE;
}
@@ -1005,6 +1013,8 @@ gtk_source_vim_motion_handle_keypress (GtkSourceVimState *state,
g_assert (GTK_SOURCE_IS_VIM_MOTION (self));
+ g_string_append (self->command_text, string);
+
if (self->waiting_for_f_char)
{
if (string == NULL || string[0] == 0)
@@ -1219,9 +1229,31 @@ gtk_source_vim_motion_leave (GtkSourceVimState *state)
}
}
+static void
+gtk_source_vim_motion_append_command (GtkSourceVimState *state,
+ GString *string)
+{
+ GtkSourceVimMotion *self = (GtkSourceVimMotion *)state;
+
+ g_assert (GTK_SOURCE_IS_VIM_MOTION (self));
+ g_assert (state != NULL);
+
+ if (self->command_text->len > 0)
+ {
+ g_string_append_len (string,
+ self->command_text->str,
+ self->command_text->len);
+ }
+}
+
static void
gtk_source_vim_motion_finalize (GObject *object)
{
+ GtkSourceVimMotion *self = (GtkSourceVimMotion *)object;
+
+ g_string_free (self->command_text, TRUE);
+ self->command_text = NULL;
+
G_OBJECT_CLASS (gtk_source_vim_motion_parent_class)->finalize (object);
}
@@ -1233,6 +1265,7 @@ gtk_source_vim_motion_class_init (GtkSourceVimMotionClass *klass)
object_class->finalize = gtk_source_vim_motion_finalize;
+ state_class->append_command = gtk_source_vim_motion_append_command;
state_class->handle_keypress = gtk_source_vim_motion_handle_keypress;
state_class->leave = gtk_source_vim_motion_leave;
state_class->repeat = gtk_source_vim_motion_repeat;
@@ -1242,6 +1275,7 @@ static void
gtk_source_vim_motion_init (GtkSourceVimMotion *self)
{
self->apply_on_leave = TRUE;
+ self->command_text = g_string_new (NULL);
}
gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]