[gnome-builder/wip/libide] libide: track cursor offset when mode changes
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/libide] libide: track cursor offset when mode changes
- Date: Thu, 12 Mar 2015 05:50:08 +0000 (UTC)
commit 860b2be094afaf851e141fbdc7ddf411da818348
Author: Christian Hergert <christian hergert me>
Date: Wed Mar 11 22:49:39 2015 -0700
libide: track cursor offset when mode changes
This helps catch things more often, so that movements keep us on the
right position.
libide/ide-source-view.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index 41c7e71..185fbe0 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -2524,6 +2524,23 @@ ide_source_view_real_selection_theatric (IdeSourceView *self,
}
static void
+ide_source_view_save_offset (IdeSourceView *self)
+{
+ IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
+ GtkTextView *text_view = (GtkTextView *)self;
+ GtkTextBuffer *buffer;
+ GtkTextMark *insert;
+ GtkTextIter iter;
+
+ g_assert (IDE_IS_SOURCE_VIEW (self));
+
+ buffer = gtk_text_view_get_buffer (text_view);
+ insert = gtk_text_buffer_get_insert (buffer);
+ gtk_text_buffer_get_iter_at_mark (buffer, &iter, insert);
+ priv->target_line_offset = gtk_text_iter_get_line_offset (&iter);
+}
+
+static void
ide_source_view_real_set_mode (IdeSourceView *self,
const gchar *mode,
IdeSourceViewModeType type)
@@ -2546,6 +2563,8 @@ ide_source_view_real_set_mode (IdeSourceView *self,
}
#endif
+ ide_source_view_save_offset (self);
+
if (priv->mode)
{
IdeSourceViewMode *old_mode = g_object_ref (priv->mode);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]