[gtksourceview] Bracket matching: update bracket highlighting on context class changes
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] Bracket matching: update bracket highlighting on context class changes
- Date: Sun, 25 Oct 2015 12:06:38 +0000 (UTC)
commit 4e89830d00a7d50ebbeb88884f515fcd844aaaae
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun Oct 25 12:44:19 2015 +0100
Bracket matching: update bracket highlighting on context class changes
In a C file, type:
foo ("(ab)
Before this commit, the ) matched with the first (. It's because the
string context class is not updated directly.
To fix it, the bracket highlighting is now updated when the
highlight-updated signal is emitted.
If it causes performance problems, the bracket highlighting can be
temporarily disabled (e.g. on file loading). Or updating the bracket
highlighting can be done in an idle or timeout function.
gtksourceview/gtksourcebuffer.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/gtksourceview/gtksourcebuffer.c b/gtksourceview/gtksourcebuffer.c
index 4250ebc..8b28ba2 100644
--- a/gtksourceview/gtksourcebuffer.c
+++ b/gtksourceview/gtksourcebuffer.c
@@ -240,6 +240,11 @@ static void gtk_source_buffer_real_mark_deleted (GtkTextBuffer
*buffer,
static void gtk_source_buffer_real_undo (GtkSourceBuffer *buffer);
static void gtk_source_buffer_real_redo (GtkSourceBuffer *buffer);
+static void gtk_source_buffer_real_highlight_updated
+ (GtkSourceBuffer *buffer,
+ GtkTextIter *start,
+ GtkTextIter *end);
+
static void
gtk_source_buffer_constructed (GObject *object)
{
@@ -399,7 +404,8 @@ gtk_source_buffer_class_init (GtkSourceBufferClass *klass)
g_signal_new_class_handler ("highlight_updated",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- NULL, NULL, NULL, NULL,
+ G_CALLBACK (gtk_source_buffer_real_highlight_updated),
+ NULL, NULL, NULL,
G_TYPE_NONE,
2,
GTK_TYPE_TEXT_ITER | G_SIGNAL_TYPE_STATIC_SCOPE,
@@ -965,6 +971,14 @@ cursor_moved (GtkSourceBuffer *buffer)
}
static void
+gtk_source_buffer_real_highlight_updated (GtkSourceBuffer *buffer,
+ GtkTextIter *start,
+ GtkTextIter *end)
+{
+ update_bracket_highlighting (buffer);
+}
+
+static void
gtk_source_buffer_content_inserted (GtkTextBuffer *buffer,
gint start_offset,
gint end_offset)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]