[gtksourceview/wip/chergert/vim] add execute command helper
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim] add execute command helper
- Date: Thu, 11 Nov 2021 01:01:07 +0000 (UTC)
commit 1ed93aae0b785f6e27b48e68d29dcb8112b332e6
Author: Christian Hergert <chergert redhat com>
Date: Wed Nov 10 17:00:02 2021 -0800
add execute command helper
docs/reference/gtksourceview-5.0-sections.txt | 1 +
gtksourceview/gtksourcevimimcontext.c | 35 +++++++++++++++++++++++++++
gtksourceview/gtksourcevimimcontext.h | 3 +++
3 files changed, 39 insertions(+)
---
diff --git a/docs/reference/gtksourceview-5.0-sections.txt b/docs/reference/gtksourceview-5.0-sections.txt
index 11fbe422..b552943b 100644
--- a/docs/reference/gtksourceview-5.0-sections.txt
+++ b/docs/reference/gtksourceview-5.0-sections.txt
@@ -1150,6 +1150,7 @@ GtkSourceVimIMContext
gtk_source_vim_im_context_new
gtk_source_vim_im_context_get_command_text
gtk_source_vim_im_context_get_command_bar_text
+gtk_source_vim_im_context_execute_command
<SUBSECTION Standard>
GtkSourceVimIMContextClass
GTK_SOURCE_TYPE_VIM_IM_CONTEXT
diff --git a/gtksourceview/gtksourcevimimcontext.c b/gtksourceview/gtksourcevimimcontext.c
index 86f67b17..a5fd02c1 100644
--- a/gtksourceview/gtksourcevimimcontext.c
+++ b/gtksourceview/gtksourcevimimcontext.c
@@ -26,6 +26,7 @@
#include "gtksource-enumtypes.h"
#include "vim/gtk-source-vim.h"
+#include "vim/gtk-source-vim-command.h"
/**
* SECTION:vimimcontext
@@ -524,3 +525,37 @@ gtk_source_vim_im_context_get_command_bar_text (GtkSourceVimIMContext *self)
return gtk_source_vim_get_command_bar_text (self->vim);
}
+
+/**
+ * gtk_source_vim_im_context_execute_command:
+ * @self: a #GtkSourceVimIMContext
+ * @command: the command text
+ *
+ * Executes @command as if it was typed into the command bar by the
+ * user except that this does not emit the
+ * #GtkSourceVimIMContext::execute-command signal.
+ *
+ * Since: 5.4
+ */
+void
+gtk_source_vim_im_context_execute_command (GtkSourceVimIMContext *self,
+ const char *command)
+{
+ GtkSourceVimState *normal;
+ GtkSourceVimState *parsed;
+
+ g_return_if_fail (GTK_SOURCE_IS_VIM_IM_CONTEXT (self));
+ g_return_if_fail (command != NULL);
+
+ if (self->vim == NULL)
+ return;
+
+ normal = gtk_source_vim_state_get_child (GTK_SOURCE_VIM_STATE (self->vim));
+ if (!(parsed = gtk_source_vim_command_new_parsed (normal, command)))
+ return;
+
+ gtk_source_vim_state_set_parent (parsed, normal);
+ gtk_source_vim_state_repeat (parsed);
+ gtk_source_vim_state_unparent (parsed);
+ g_object_unref (parsed);
+}
diff --git a/gtksourceview/gtksourcevimimcontext.h b/gtksourceview/gtksourcevimimcontext.h
index 6c08f540..95c4e9ad 100644
--- a/gtksourceview/gtksourcevimimcontext.h
+++ b/gtksourceview/gtksourcevimimcontext.h
@@ -42,5 +42,8 @@ GTK_SOURCE_AVAILABLE_IN_ALL
const char *gtk_source_vim_im_context_get_command_text (GtkSourceVimIMContext *self);
GTK_SOURCE_AVAILABLE_IN_ALL
const char *gtk_source_vim_im_context_get_command_bar_text (GtkSourceVimIMContext *self);
+GTK_SOURCE_AVAILABLE_IN_ALL
+void gtk_source_vim_im_context_execute_command (GtkSourceVimIMContext *self,
+ const char *command);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]