[gnome-builder] libide: use mark for page scrolling
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide: use mark for page scrolling
- Date: Tue, 24 Mar 2015 00:09:35 +0000 (UTC)
commit 3c8bac3795e90dbb9591838d6c84d9018021451f
Author: Christian Hergert <christian hergert me>
Date: Tue Mar 10 00:29:22 2015 -0700
libide: use mark for page scrolling
Information about positioning of textiter's is updated in an idle
callback. That means that they wont always be up to date. If we use
scroll_to_mark instead of scroll to iter, it can finish the scroll
after the line information has been calculated.
This fixes spurious scrolling up and down with ctrl+f/b in vim mode.
libide/ide-source-view-movements.c | 9 +++++++--
libide/ide-source-view.c | 4 ++++
2 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/libide/ide-source-view-movements.c b/libide/ide-source-view-movements.c
index 7c6028b..fe9ef6f 100644
--- a/libide/ide-source-view-movements.c
+++ b/libide/ide-source-view-movements.c
@@ -695,6 +695,7 @@ ide_source_view_movements_move_page (Movement *mv)
{
GtkTextView *text_view = (GtkTextView *)mv->self;
GtkTextBuffer *buffer;
+ GtkTextMark *mark;
GdkRectangle rect;
GtkTextIter iter_top;
GtkTextIter iter_bottom;
@@ -735,8 +736,10 @@ ide_source_view_movements_move_page (Movement *mv)
text_iter_forward_to_nonspace_captive (&mv->insert);
ide_source_view_movements_select_range (mv);
+ mark = gtk_text_buffer_get_mark (buffer, "scroll-mark");
gtk_text_buffer_get_iter_at_line (buffer, &scroll_iter, line_top);
- gtk_text_view_scroll_to_iter (text_view, &scroll_iter, 0.0, TRUE, 1.0, 1.0);
+ gtk_text_buffer_move_mark (buffer, mark, &scroll_iter);
+ gtk_text_view_scroll_to_mark (text_view, mark, 0.0, TRUE, 1.0, 1.0);
mv->ignore_select = TRUE;
mv->ignore_scroll_to_insert = TRUE;
@@ -747,8 +750,10 @@ ide_source_view_movements_move_page (Movement *mv)
text_iter_forward_to_nonspace_captive (&mv->insert);
ide_source_view_movements_select_range (mv);
+ mark = gtk_text_buffer_get_mark (buffer, "scroll-mark");
gtk_text_buffer_get_iter_at_line (buffer, &scroll_iter, line_bottom);
- gtk_text_view_scroll_to_iter (text_view, &scroll_iter, 0.0, TRUE, 1.0, 0.0);
+ gtk_text_buffer_move_mark (buffer, mark, &scroll_iter);
+ gtk_text_view_scroll_to_mark (text_view, mark, 0.0, TRUE, 1.0, 0.0);
mv->ignore_select = TRUE;
mv->ignore_scroll_to_insert = TRUE;
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index 4063033..e0d918f 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -970,6 +970,7 @@ ide_source_view_connect_buffer (IdeSourceView *self,
IdeBuffer *buffer)
{
IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
+ GtkTextIter iter;
g_assert (IDE_IS_SOURCE_VIEW (self));
g_assert (IDE_IS_BUFFER (buffer));
@@ -1044,6 +1045,9 @@ ide_source_view_connect_buffer (IdeSourceView *self,
self,
0);
+ gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (buffer), &iter);
+ gtk_text_buffer_create_mark (GTK_TEXT_BUFFER (buffer), "scroll-mark", &iter, TRUE);
+
ide_source_view__buffer_notify_language_cb (self, NULL, buffer);
ide_source_view__buffer_notify_file_cb (self, NULL, buffer);
ide_source_view__buffer_notify_highlight_diagnostics_cb (self, NULL, buffer);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]