[gnome-builder] editor: allow clearing saved cursor position
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] editor: allow clearing saved cursor position
- Date: Thu, 22 Jan 2015 22:02:39 +0000 (UTC)
commit 77c0c1dcd1e334df3fd09e313e9f1185240df492
Author: Christian Hergert <christian hergert me>
Date: Thu Jan 22 13:56:24 2015 -0800
editor: allow clearing saved cursor position
Calling this will prevent jumping back to the previous position.
https://bugzilla.gnome.org/show_bug.cgi?id=743357
src/editor/gb-source-view.c | 16 ++++++++++++++--
src/editor/gb-source-view.h | 1 +
2 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/src/editor/gb-source-view.c b/src/editor/gb-source-view.c
index 58c6fb7..29546ad 100644
--- a/src/editor/gb-source-view.c
+++ b/src/editor/gb-source-view.c
@@ -2030,6 +2030,15 @@ gb_source_view_drag_data_received (GtkWidget *widget,
}
}
+void
+gb_source_view_clear_saved_cursor (GbSourceView *view)
+{
+ g_return_if_fail (GB_IS_SOURCE_VIEW (view));
+
+ view->priv->saved_line = -1;
+ view->priv->saved_line_offset = -1;
+}
+
static void
gb_source_view_save_cursor (GbSourceView *view)
{
@@ -2059,12 +2068,15 @@ gb_source_view_restore_cursor (GbSourceView *view)
priv = view->priv;
+ if (priv->saved_line == -1 || priv->saved_line_offset == -1)
+ return;
+
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
insert = gtk_text_buffer_get_insert (buffer);
gtk_text_buffer_get_iter_at_mark (buffer, &iter, insert);
- if ((view->priv->saved_line == gtk_text_iter_get_line (&iter)) &&
- (view->priv->saved_line_offset == gtk_text_iter_get_line_offset (&iter)))
+ if ((priv->saved_line == gtk_text_iter_get_line (&iter)) &&
+ (priv->saved_line_offset == gtk_text_iter_get_line_offset (&iter)))
return;
if (gb_gtk_text_buffer_get_iter_at_line_and_offset (buffer, &iter,
diff --git a/src/editor/gb-source-view.h b/src/editor/gb-source-view.h
index d1be242..c4a2869 100644
--- a/src/editor/gb-source-view.h
+++ b/src/editor/gb-source-view.h
@@ -74,6 +74,7 @@ void gb_source_view_begin_search (GbSourceView
GtkDirectionType direction,
const gchar *search_text);
void gb_source_view_clear_snippets (GbSourceView *view);
+void gb_source_view_clear_saved_cursor (GbSourceView *view);
GbSourceAutoIndenter *gb_source_view_get_auto_indenter (GbSourceView *view);
gboolean gb_source_view_get_overwrite_braces (GbSourceView *view);
gboolean gb_source_view_get_show_shadow (GbSourceView *view);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]