[gtksourceview/wip/chergert/vim: 282/293] add format signal
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim: 282/293] add format signal
- Date: Fri, 5 Nov 2021 04:23:08 +0000 (UTC)
commit ca46af3d419be11c2bd1e3632f12fea986f4393c
Author: Christian Hergert <chergert redhat com>
Date: Wed Nov 3 17:28:59 2021 -0700
add format signal
gtksourceview/vim/gtk-source-vim.c | 30 ++++++++++++++++++++++++++++++
gtksourceview/vim/gtk-source-vim.h | 3 +++
2 files changed, 33 insertions(+)
---
diff --git a/gtksourceview/vim/gtk-source-vim.c b/gtksourceview/vim/gtk-source-vim.c
index 6c7f3634..c78d2b00 100644
--- a/gtksourceview/vim/gtk-source-vim.c
+++ b/gtksourceview/vim/gtk-source-vim.c
@@ -44,6 +44,7 @@ enum {
enum {
EXECUTE_COMMAND,
+ FORMAT,
READY,
SPLIT,
N_SIGNALS
@@ -200,6 +201,23 @@ gtk_source_vim_class_init (GtkSourceVimClass *klass)
1,
G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
+ /**
+ * GtkSourceVim::format:
+ * @self: a #GtkSourceVim
+ * @begin: the beginning of the text range
+ * @end: the end of the text range
+ *
+ * Requests that the text range @begin to @end be reformatted.
+ * Applications should conntect to this signal to implement
+ * reformatting as they would like.
+ */
+ signals[FORMAT] =
+ g_signal_new ("format",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE, 2, GTK_TYPE_TEXT_ITER, GTK_TYPE_TEXT_ITER);
+
signals[READY] =
g_signal_new ("ready",
G_TYPE_FROM_CLASS (klass),
@@ -341,3 +359,15 @@ gtk_source_vim_emit_ready (GtkSourceVim *self)
g_signal_emit (self, signals[READY], 0);
}
+
+void
+gtk_source_vim_emit_format (GtkSourceVim *self,
+ GtkTextIter *begin,
+ GtkTextIter *end)
+{
+ g_return_if_fail (GTK_SOURCE_IS_VIM (self));
+ g_return_if_fail (begin != NULL);
+ g_return_if_fail (end != NULL);
+
+ g_signal_emit (self, signals[FORMAT], 0, begin, end);
+}
diff --git a/gtksourceview/vim/gtk-source-vim.h b/gtksourceview/vim/gtk-source-vim.h
index ff8a7e3d..3fb313fe 100644
--- a/gtksourceview/vim/gtk-source-vim.h
+++ b/gtksourceview/vim/gtk-source-vim.h
@@ -35,6 +35,9 @@ const char *gtk_source_vim_get_command_text (GtkSourceVim *self);
const char *gtk_source_vim_get_command_bar_text (GtkSourceVim *self);
gboolean gtk_source_vim_emit_execute_command (GtkSourceVim *self,
const char *command);
+void gtk_source_vim_emit_format (GtkSourceVim *self,
+ GtkTextIter *begin,
+ GtkTextIter *end);
void gtk_source_vim_emit_ready (GtkSourceVim *self);
void gtk_source_vim_emit_split (GtkSourceVim *self,
GtkOrientation orientation,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]