[gnome-builder] highlighter: add ide_highlight_engine_invalidate()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] highlighter: add ide_highlight_engine_invalidate()
- Date: Sat, 9 May 2015 19:33:36 +0000 (UTC)
commit 516582606517059edf740ba2f22c2347a4001b01
Author: Christian Hergert <christian hergert me>
Date: Sat May 9 12:33:07 2015 -0700
highlighter: add ide_highlight_engine_invalidate()
This allows the caller to invalidate a specific region of the buffer.
If a portion of the buffer is already invalid, that region will be
extended to include the range of @begin to @end.
libide/ide-highlight-engine.c | 56 +++++++++++++++++++++++++++++++++++++++++
libide/ide-highlight-engine.h | 3 ++
2 files changed, 59 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-highlight-engine.c b/libide/ide-highlight-engine.c
index 4deaec5..4e7d374 100644
--- a/libide/ide-highlight-engine.c
+++ b/libide/ide-highlight-engine.c
@@ -724,3 +724,59 @@ ide_highlight_engine_rebuild (IdeHighlightEngine *self)
IDE_EXIT;
}
+
+/**
+ * ide_highlight_engine_invalidate:
+ * @self: An #IdeHighlightEngine.
+ * @begin: the beginning of the range to invalidate
+ * @end: the end of the range to invalidate
+ *
+ * This function will extend the invalidated range of the buffer to include
+ * the range of @begin to @end.
+ *
+ * The highlighter will be queued to interactively update the invalidated
+ * region.
+ *
+ * Updating the invalidated region of the buffer may take some time, as it is
+ * important that the highlighter does not block for more than 1-2 milliseconds
+ * to avoid dropping frames.
+ */
+void
+ide_highlight_engine_invalidate (IdeHighlightEngine *self,
+ const GtkTextIter *begin,
+ const GtkTextIter *end)
+{
+ GtkTextBuffer *buffer;
+ GtkTextIter mark_begin;
+ GtkTextIter mark_end;
+
+ IDE_ENTRY;
+
+ g_return_if_fail (IDE_IS_HIGHLIGHT_ENGINE (self));
+ g_return_if_fail (begin != NULL);
+ g_return_if_fail (end != NULL);
+ g_return_if_fail (gtk_text_iter_get_buffer (begin) == GTK_TEXT_BUFFER (self->buffer));
+ g_return_if_fail (gtk_text_iter_get_buffer (end) == GTK_TEXT_BUFFER (self->buffer));
+
+ buffer = GTK_TEXT_BUFFER (self->buffer);
+
+ gtk_text_buffer_get_iter_at_mark (buffer, &mark_begin, self->invalid_begin);
+ gtk_text_buffer_get_iter_at_mark (buffer, &mark_end, self->invalid_end);
+
+ if (gtk_text_iter_equal (&mark_begin, &mark_end))
+ {
+ gtk_text_buffer_move_mark (buffer, self->invalid_begin, begin);
+ gtk_text_buffer_move_mark (buffer, self->invalid_end, end);
+ }
+ else
+ {
+ if (gtk_text_iter_compare (begin, &mark_begin) < 0)
+ gtk_text_buffer_move_mark (buffer, self->invalid_begin, begin);
+ if (gtk_text_iter_compare (end, &mark_end) > 0)
+ gtk_text_buffer_move_mark (buffer, self->invalid_end, end);
+ }
+
+ ide_highlight_engine_queue_work (self);
+
+ IDE_EXIT;
+}
diff --git a/libide/ide-highlight-engine.h b/libide/ide-highlight-engine.h
index d04df0d..ad5349e 100644
--- a/libide/ide-highlight-engine.h
+++ b/libide/ide-highlight-engine.h
@@ -34,6 +34,9 @@ IdeHighlighter *ide_highlight_engine_get_highlighter (IdeHighlightEngine *se
void ide_highlight_engine_set_highlighter (IdeHighlightEngine *self,
IdeHighlighter *highlighter);
void ide_highlight_engine_rebuild (IdeHighlightEngine *self);
+void ide_highlight_engine_invalidate (IdeHighlightEngine *self,
+ const GtkTextIter *begin,
+ const GtkTextIter *end);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]