[gtksourceview/wip/chergert/vim] add begin command helper
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim] add begin command helper
- Date: Fri, 29 Oct 2021 05:00:03 +0000 (UTC)
commit f05219b45cc7a4068227ca500d1701cd373cf434
Author: Christian Hergert <chergert redhat com>
Date: Thu Oct 28 21:59:39 2021 -0700
add begin command helper
gtksourceview/vim/gtk-source-vim-normal.c | 36 +++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
---
diff --git a/gtksourceview/vim/gtk-source-vim-normal.c b/gtksourceview/vim/gtk-source-vim-normal.c
index ce557c25..2e8c1e7c 100644
--- a/gtksourceview/vim/gtk-source-vim-normal.c
+++ b/gtksourceview/vim/gtk-source-vim-normal.c
@@ -22,6 +22,7 @@
#include "config.h"
#include "gtk-source-vim.h"
+#include "gtk-source-vim-command.h"
#include "gtk-source-vim-command-bar.h"
#include "gtk-source-vim-delete.h"
#include "gtk-source-vim-insert.h"
@@ -188,6 +189,41 @@ gtk_source_vim_normal_begin_insert (GtkSourceVimNormal *self,
return ret;
}
+static void
+gtk_source_vim_normal_begin_command (GtkSourceVimNormal *self,
+ GtkSourceVimState *insert_motion,
+ GtkSourceVimState *selection_motion,
+ const char *command_str)
+{
+ GtkSourceVimCommand *command;
+ int count;
+
+ g_assert (GTK_SOURCE_IS_VIM_NORMAL (self));
+ g_assert (!insert_motion || GTK_SOURCE_IS_VIM_MOTION (insert_motion));
+ g_assert (!selection_motion || GTK_SOURCE_IS_VIM_MOTION (selection_motion));
+
+ count = self->count, self->count = 0;
+
+ if (insert_motion)
+ gtk_source_vim_state_set_count (GTK_SOURCE_VIM_STATE (insert_motion), count);
+
+ if (selection_motion)
+ gtk_source_vim_state_set_count (GTK_SOURCE_VIM_STATE (selection_motion), count);
+
+ command = g_object_new (GTK_SOURCE_TYPE_VIM_COMMAND,
+ "motion", insert_motion,
+ "selection-motion", selection_motion,
+ "command", command_str,
+ NULL);
+
+ g_clear_object (&insert_motion);
+ g_clear_object (&selection_motion);
+
+ gtk_source_vim_state_push (GTK_SOURCE_VIM_STATE (self),
+ GTK_SOURCE_VIM_STATE (command));
+ gtk_source_vim_state_pop (GTK_SOURCE_VIM_STATE (command));
+}
+
static void
go_backward_char (GtkSourceVimNormal *self)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]