[gtksourceview/wip/chergert/vim] add plumbing to stash a visible column



commit dd19c0053f9f3fa5026262b8725c7346b69b9136
Author: Christian Hergert <chergert redhat com>
Date:   Tue Nov 2 19:52:44 2021 -0700

    add plumbing to stash a visible column

 gtksourceview/vim/gtk-source-vim-state.c | 46 ++++++++++++++++++++++++++++++++
 gtksourceview/vim/gtk-source-vim-state.h |  3 +++
 2 files changed, 49 insertions(+)
---
diff --git a/gtksourceview/vim/gtk-source-vim-state.c b/gtksourceview/vim/gtk-source-vim-state.c
index c34a989c..64fcb4a6 100644
--- a/gtksourceview/vim/gtk-source-vim-state.c
+++ b/gtksourceview/vim/gtk-source-vim-state.c
@@ -39,9 +39,11 @@ typedef struct
        const char        *current_register;
 
        int                count;
+       guint              column;
 
        guint              count_set : 1;
        guint              can_repeat : 1;
+       guint              column_set : 1;
 } GtkSourceVimStatePrivate;
 
 G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GtkSourceVimState, gtk_source_vim_state, G_TYPE_OBJECT)
@@ -1071,3 +1073,47 @@ gtk_source_vim_state_set_current_register_value (GtkSourceVimState *self,
                                              value);
        }
 }
+
+guint
+gtk_source_vim_state_get_visual_column (GtkSourceVimState *self)
+{
+       GtkSourceVimStatePrivate *priv = gtk_source_vim_state_get_instance_private (self);
+       GtkSourceView *view;
+       GtkTextIter iter;
+
+       g_return_val_if_fail (GTK_SOURCE_IS_VIM_STATE (self), FALSE);
+
+       if (priv->column_set)
+       {
+               return priv->column;
+       }
+
+       if (priv->parent != NULL)
+       {
+               return gtk_source_vim_state_get_visual_column (priv->parent);
+       }
+
+       view = gtk_source_vim_state_get_view (self);
+       gtk_source_vim_state_get_buffer (self, &iter, NULL);
+
+       return gtk_source_view_get_visual_column (view, &iter);
+}
+
+void
+gtk_source_vim_state_set_visual_column (GtkSourceVimState *self,
+                                        int                visual_column)
+{
+       GtkSourceVimStatePrivate *priv = gtk_source_vim_state_get_instance_private (self);
+
+       g_return_if_fail (GTK_SOURCE_IS_VIM_STATE (self));
+
+       if (visual_column < 0)
+       {
+               priv->column_set = FALSE;
+               return;
+       }
+
+       priv->column = visual_column;
+       priv->column_set = TRUE;
+}
+
diff --git a/gtksourceview/vim/gtk-source-vim-state.h b/gtksourceview/vim/gtk-source-vim-state.h
index d46d6499..8cde2813 100644
--- a/gtksourceview/vim/gtk-source-vim-state.h
+++ b/gtksourceview/vim/gtk-source-vim-state.h
@@ -120,6 +120,9 @@ void               gtk_source_vim_state_keyval_to_string           (guint
 void               gtk_source_vim_state_keyval_unescaped           (guint              keyval,
                                                                     GdkModifierType    mods,
                                                                     char               str[16]);
+guint              gtk_source_vim_state_get_visual_column          (GtkSourceVimState *self);
+void               gtk_source_vim_state_set_visual_column          (GtkSourceVimState *self,
+                                                                    int                visual_column);
 
 static inline gboolean
 gtk_source_vim_state_is_escape (guint           keyval,


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