[gtksourceview/wip/chergert/vim: 233/363] stash visible column in visual mode
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/vim: 233/363] stash visible column in visual mode
- Date: Mon, 8 Nov 2021 19:53:52 +0000 (UTC)
commit d2e7bfbbde03fb42de444c17efb913907e41eeb4
Author: Christian Hergert <chergert redhat com>
Date: Tue Nov 2 19:53:50 2021 -0700
stash visible column in visual mode
gtksourceview/vim/gtk-source-vim-visual.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
---
diff --git a/gtksourceview/vim/gtk-source-vim-visual.c b/gtksourceview/vim/gtk-source-vim-visual.c
index 15508295..b1a90dcc 100644
--- a/gtksourceview/vim/gtk-source-vim-visual.c
+++ b/gtksourceview/vim/gtk-source-vim-visual.c
@@ -23,6 +23,8 @@
#include <glib/gi18n.h>
+#include "gtksourceview.h"
+
#include "gtk-source-vim-char-pending.h"
#include "gtk-source-vim-command.h"
#include "gtk-source-vim-delete.h"
@@ -70,6 +72,23 @@ static gboolean key_handler_initial (GtkSourceVimVisual *self,
G_DEFINE_TYPE (GtkSourceVimVisual, gtk_source_vim_visual, GTK_SOURCE_TYPE_VIM_STATE)
+static void
+track_visible_column (GtkSourceVimVisual *self)
+{
+ GtkSourceBuffer *buffer;
+ GtkSourceView *view;
+ GtkTextIter iter;
+ guint visual_column;
+
+ buffer = gtk_source_vim_state_get_buffer (GTK_SOURCE_VIM_STATE (self), NULL, NULL);
+ view = gtk_source_vim_state_get_view (GTK_SOURCE_VIM_STATE (self));
+ gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (buffer),
+ &iter,
+ self->cursor);
+ visual_column = gtk_source_view_get_visual_column (view, &iter);
+ gtk_source_vim_state_set_visual_column (GTK_SOURCE_VIM_STATE (self), visual_column);
+}
+
static void
update_cursor_visible (GtkSourceVimVisual *self)
{
@@ -512,6 +531,8 @@ gtk_source_vim_visual_enter (GtkSourceVimState *state)
update_cursor_visible (self);
+ track_visible_column (self);
+
gtk_source_vim_visual_track_motion (self);
}
@@ -561,6 +582,11 @@ gtk_source_vim_visual_resume (GtkSourceVimState *state,
{
GtkSourceVimState *chained;
+ if (gtk_source_vim_motion_invalidates_visual_column (GTK_SOURCE_VIM_MOTION (from)))
+ {
+ track_visible_column (self);
+ }
+
/* Update our selection to match the motion. If we're in
* linewise, that needs to be updated to contain the whole line.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]