[gnome-builder/auto-indent] snippets: invalidate snippet region on text insertion
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/auto-indent] snippets: invalidate snippet region on text insertion
- Date: Wed, 17 Sep 2014 21:51:45 +0000 (UTC)
commit 45e028ca368155c87df7dd74402611c132be4fb7
Author: Christian Hergert <christian hergert me>
Date: Wed Sep 17 14:51:36 2014 -0700
snippets: invalidate snippet region on text insertion
This allows us to properly redraw the background when inserting text.
src/editor/gb-source-view.c | 43 +++++++++++++++++++++++++++++++++++++++----
1 files changed, 39 insertions(+), 4 deletions(-)
---
diff --git a/src/editor/gb-source-view.c b/src/editor/gb-source-view.c
index 76956ce..43c878d 100644
--- a/src/editor/gb-source-view.c
+++ b/src/editor/gb-source-view.c
@@ -339,6 +339,34 @@ animate_in (GbSourceView *view,
#undef Y_GROW
}
+static void
+gb_source_view_invalidate_range_mark (GbSourceView *view,
+ GtkTextMark *mark_begin,
+ GtkTextMark *mark_end)
+{
+ GtkTextBuffer *buffer;
+ GdkRectangle rect;
+ GtkTextIter begin;
+ GtkTextIter end;
+ GdkWindow *window;
+
+ g_return_if_fail (GB_IS_SOURCE_VIEW (view));
+ g_return_if_fail (GTK_IS_TEXT_MARK (mark_begin));
+ g_return_if_fail (GTK_IS_TEXT_MARK (mark_end));
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+
+ gtk_text_buffer_get_iter_at_mark (buffer, &begin, mark_begin);
+ gtk_text_buffer_get_iter_at_mark (buffer, &end, mark_end);
+
+ get_rect_for_iters (GTK_TEXT_VIEW (view), &begin, &end, &rect,
+ GTK_TEXT_WINDOW_TEXT);
+
+ window = gtk_text_view_get_window (GTK_TEXT_VIEW (view),
+ GTK_TEXT_WINDOW_TEXT);
+ gdk_window_invalidate_rect (window, &rect, FALSE);
+}
+
static gchar *
gb_source_view_get_line_prefix (GbSourceView *view,
const GtkTextIter *iter)
@@ -497,12 +525,19 @@ on_insert_text_after (GtkTextBuffer *buffer,
priv = view->priv;
- gb_source_view_block_handlers (view);
-
if ((snippet = g_queue_peek_head (priv->snippets)))
- gb_source_snippet_after_insert_text (snippet, buffer, iter, text, len);
+ {
+ GtkTextMark *begin;
+ GtkTextMark *end;
- gb_source_view_unblock_handlers (view);
+ gb_source_view_block_handlers (view);
+ gb_source_snippet_after_insert_text (snippet, buffer, iter, text, len);
+ gb_source_view_unblock_handlers (view);
+
+ begin = gb_source_snippet_get_mark_begin (snippet);
+ end = gb_source_snippet_get_mark_end (snippet);
+ gb_source_view_invalidate_range_mark (view, begin, end);
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]