[gnome-builder] highlight: add debug helpers to re-highlight a buffer
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] highlight: add debug helpers to re-highlight a buffer
- Date: Fri, 27 Mar 2015 00:38:50 +0000 (UTC)
commit 44f86caf150aa746702fffb0aef16fceb24f5507
Author: Christian Hergert <christian hergert me>
Date: Thu Mar 26 14:07:50 2015 -0700
highlight: add debug helpers to re-highlight a buffer
data/keybindings/vim.css | 2 ++
libide/ide-buffer.c | 15 +++++++++++++++
libide/ide-buffer.h | 1 +
libide/ide-source-view.c | 26 ++++++++++++++++++++++++++
libide/ide-source-view.h | 1 +
5 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/data/keybindings/vim.css b/data/keybindings/vim.css
index 7596c7e..d2734db 100644
--- a/data/keybindings/vim.css
+++ b/data/keybindings/vim.css
@@ -110,6 +110,8 @@
@binding-set builder-vim-source-view-normal
{
+ bind "<ctrl><shift>r" { "rebuild-highlight" () };
+
bind "1" { "append-to-count" (1)
"set-mode" ("vim-normal-with-count", transient) };
bind "2" { "append-to-count" (2)
diff --git a/libide/ide-buffer.c b/libide/ide-buffer.c
index 4c4cd66..137ff4e 100644
--- a/libide/ide-buffer.c
+++ b/libide/ide-buffer.c
@@ -1653,3 +1653,18 @@ ide_buffer_get_iter_at_source_location (IdeBuffer *self,
if (gtk_text_iter_ends_line (iter) || !gtk_text_iter_forward_char (iter))
break;
}
+
+void
+ide_buffer_rehighlight (IdeBuffer *self)
+{
+ IdeBufferPrivate *priv = ide_buffer_get_instance_private (self);
+
+ IDE_ENTRY;
+
+ g_return_if_fail (IDE_IS_BUFFER (self));
+
+ if (priv->highlight_engine != NULL)
+ ide_highlight_engine_rebuild (priv->highlight_engine);
+
+ IDE_EXIT;
+}
diff --git a/libide/ide-buffer.h b/libide/ide-buffer.h
index 317bfb7..77fe1e7 100644
--- a/libide/ide-buffer.h
+++ b/libide/ide-buffer.h
@@ -87,6 +87,7 @@ void ide_buffer_check_for_volume_change (IdeBuffer *s
void ide_buffer_get_iter_at_source_location (IdeBuffer *self,
GtkTextIter *iter,
IdeSourceLocation *location);
+void ide_buffer_rehighlight (IdeBuffer *self);
G_END_DECLS
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index 39e8778..edf022e 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -219,6 +219,7 @@ enum {
POP_SNIPPET,
PUSH_SELECTION,
PUSH_SNIPPET,
+ REBUILD_HIGHLIGHT,
REPLAY_MACRO,
REQUEST_DOCUMENTATION,
RESTORE_INSERT_MARK,
@@ -4690,6 +4691,21 @@ ide_source_view_real_populate_popup (GtkTextView *text_view,
}
static void
+ide_source_view_real_rebuild_highlight (IdeSourceView *self)
+{
+ IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
+
+ IDE_ENTRY;
+
+ g_assert (IDE_IS_SOURCE_VIEW (self));
+
+ if (priv->buffer != NULL)
+ ide_buffer_rehighlight (priv->buffer);
+
+ IDE_EXIT;
+}
+
+static void
ide_source_view_dispose (GObject *object)
{
IdeSourceView *self = (IdeSourceView *)object;
@@ -4961,6 +4977,7 @@ ide_source_view_class_init (IdeSourceViewClass *klass)
klass->pop_selection = ide_source_view_real_pop_selection;
klass->push_selection = ide_source_view_real_push_selection;
klass->push_snippet = ide_source_view_real_push_snippet;
+ klass->rebuild_highlight = ide_source_view_real_rebuild_highlight;
klass->replay_macro = ide_source_view_real_replay_macro;
klass->restore_insert_mark = ide_source_view_real_restore_insert_mark;
klass->save_insert_mark = ide_source_view_real_save_insert_mark;
@@ -5506,6 +5523,15 @@ ide_source_view_class_init (IdeSourceViewClass *klass)
IDE_TYPE_SOURCE_SNIPPET_CONTEXT,
GTK_TYPE_TEXT_ITER);
+ gSignals [REBUILD_HIGHLIGHT] =
+ g_signal_new ("rebuild-highlight",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (IdeSourceViewClass, rebuild_highlight),
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 0);
+
/**
* IdeSourceView:replay-macro:
* @self: an #IdeSourceView.
diff --git a/libide/ide-source-view.h b/libide/ide-source-view.h
index 258bd7f..0704fb5 100644
--- a/libide/ide-source-view.h
+++ b/libide/ide-source-view.h
@@ -254,6 +254,7 @@ struct _IdeSourceViewClass
IdeSourceSnippet *snippet,
IdeSourceSnippetContext *context,
const GtkTextIter *location);
+ void (*rebuild_highlight) (IdeSourceView *self);
void (*replay_macro) (IdeSourceView *self,
gboolean use_count);
void (*request_documentation) (IdeSourceView *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]