[gtksourceview/wip/chergert/vim: 284/293] wire up format to vim signal




commit f77882c43d23270d04ed2e0cc1da33f293158755
Author: Christian Hergert <chergert redhat com>
Date:   Wed Nov 3 17:29:20 2021 -0700

    wire up format to vim signal

 gtksourceview/vim/gtk-source-vim-command.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/gtksourceview/vim/gtk-source-vim-command.c b/gtksourceview/vim/gtk-source-vim-command.c
index c2406f47..2c717f1d 100644
--- a/gtksourceview/vim/gtk-source-vim-command.c
+++ b/gtksourceview/vim/gtk-source-vim-command.c
@@ -26,6 +26,7 @@
 #include "gtksourcebuffer.h"
 #include "gtksourceview.h"
 
+#include "gtk-source-vim.h"
 #include "gtk-source-vim-char-pending.h"
 #include "gtk-source-vim-command.h"
 #include "gtk-source-vim-registers.h"
@@ -60,7 +61,20 @@ static GHashTable *commands;
 static void
 gtk_source_vim_command_format (GtkSourceVimCommand *self)
 {
-       /* TODO */
+       GtkSourceVimState *root;
+       GtkSourceBuffer *buffer;
+       GtkTextIter iter;
+       GtkTextIter selection;
+
+       buffer = gtk_source_vim_state_get_buffer (GTK_SOURCE_VIM_STATE (self), &iter, &selection);
+       root = gtk_source_vim_state_get_root (GTK_SOURCE_VIM_STATE (self));
+
+       if (GTK_SOURCE_IS_VIM (root))
+       {
+               gtk_text_buffer_begin_user_action (GTK_TEXT_BUFFER (buffer));
+               gtk_source_vim_emit_format (GTK_SOURCE_VIM (root), &iter, &selection);
+               gtk_text_buffer_end_user_action (GTK_TEXT_BUFFER (buffer));
+       }
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]