[gtksourceview/wip/chergert/gsv-gtk4: 40/117] engine: modernize GtkSourceContextEngine
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/gsv-gtk4: 40/117] engine: modernize GtkSourceContextEngine
- Date: Wed, 29 Jan 2020 17:30:45 +0000 (UTC)
commit b9e298b66957d0e6a787ddbd6c4827c0419cbdaf
Author: Christian Hergert <chergert redhat com>
Date: Thu Jan 9 12:29:47 2020 -0800
engine: modernize GtkSourceContextEngine
docs/reference/meson.build | 2 +-
gtksourceview/gtksourcecontextengine-private.h | 109 +++
gtksourceview/gtksourcecontextengine.c | 1078 ++++++++++++------------
gtksourceview/gtksourcecontextengine.h | 141 ----
gtksourceview/gtksourcelanguage-parser-2.c | 2 +-
gtksourceview/gtksourcelanguage-private.h | 2 +-
6 files changed, 650 insertions(+), 684 deletions(-)
---
diff --git a/docs/reference/meson.build b/docs/reference/meson.build
index 8415e80c..c0268eee 100644
--- a/docs/reference/meson.build
+++ b/docs/reference/meson.build
@@ -20,7 +20,7 @@ reference_private_h = [
'gtksourcecompletionwordslibrary.h',
'gtksourcecompletionwordsproposal.h',
'gtksourcecompletionwordsutils.h',
- 'gtksourcecontextengine.h',
+ 'gtksourcecontextengine-private.h',
'gtksourceencoding-private.h',
'gtksourceengine.h',
'gtksourcegutter-private.h',
diff --git a/gtksourceview/gtksourcecontextengine-private.h b/gtksourceview/gtksourcecontextengine-private.h
new file mode 100644
index 00000000..863c1e52
--- /dev/null
+++ b/gtksourceview/gtksourcecontextengine-private.h
@@ -0,0 +1,109 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; coding: utf-8 -*-
+ *
+ * This file is part of GtkSourceView
+ *
+ * Copyright 2003 - Gustavo Giráldez
+ * Copyright 2005 - Marco Barisione, Emanuele Aina
+ *
+ * GtkSourceView is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * GtkSourceView is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "gtksourceengine.h"
+#include "gtksourcetypes.h"
+#include "gtksourcetypes-private.h"
+
+G_BEGIN_DECLS
+
+#define GTK_SOURCE_TYPE_CONTEXT_ENGINE (_gtk_source_context_engine_get_type())
+
+typedef struct _GtkSourceContextData GtkSourceContextData;
+typedef struct _GtkSourceContextReplace GtkSourceContextReplace;
+typedef struct _GtkSourceContextClass GtkSourceContextClass;
+
+typedef enum _GtkSourceContextFlags {
+ GTK_SOURCE_CONTEXT_EXTEND_PARENT = 1 << 0,
+ GTK_SOURCE_CONTEXT_END_PARENT = 1 << 1,
+ GTK_SOURCE_CONTEXT_END_AT_LINE_END = 1 << 2,
+ GTK_SOURCE_CONTEXT_FIRST_LINE_ONLY = 1 << 3,
+ GTK_SOURCE_CONTEXT_ONCE_ONLY = 1 << 4,
+ GTK_SOURCE_CONTEXT_STYLE_INSIDE = 1 << 5
+} GtkSourceContextFlags;
+
+typedef enum _GtkSourceContextRefOptions {
+ GTK_SOURCE_CONTEXT_IGNORE_STYLE = 1 << 0,
+ GTK_SOURCE_CONTEXT_OVERRIDE_STYLE = 1 << 1,
+ GTK_SOURCE_CONTEXT_REF_ORIGINAL = 1 << 2
+} GtkSourceContextRefOptions;
+
+G_GNUC_INTERNAL
+G_DECLARE_FINAL_TYPE (GtkSourceContextEngine, _gtk_source_context_engine, GTK_SOURCE, CONTEXT_ENGINE,
GObject)
+
+G_GNUC_INTERNAL
+GtkSourceContextData *_gtk_source_context_data_new (GtkSourceLanguage *lang);
+G_GNUC_INTERNAL
+GtkSourceContextData *_gtk_source_context_data_ref (GtkSourceContextData *data);
+G_GNUC_INTERNAL
+void _gtk_source_context_data_unref (GtkSourceContextData *data);
+G_GNUC_INTERNAL
+GtkSourceContextClass *gtk_source_context_class_new (gchar const *name,
+ gboolean enabled);
+G_GNUC_INTERNAL
+void gtk_source_context_class_free (GtkSourceContextClass *cclass);
+G_GNUC_INTERNAL
+GtkSourceContextEngine *_gtk_source_context_engine_new (GtkSourceContextData *data);
+G_GNUC_INTERNAL
+gboolean _gtk_source_context_data_define_context (GtkSourceContextData *data,
+ const gchar *id,
+ const gchar *parent_id,
+ const gchar *match_regex,
+ const gchar *start_regex,
+ const gchar *end_regex,
+ const gchar *style,
+ GSList
*context_classes,
+ GtkSourceContextFlags flags,
+ GError **error);
+G_GNUC_INTERNAL
+gboolean _gtk_source_context_data_add_sub_pattern (GtkSourceContextData *data,
+ const gchar *id,
+ const gchar *parent_id,
+ const gchar *name,
+ const gchar *where,
+ const gchar *style,
+ GSList
*context_classes,
+ GError **error);
+G_GNUC_INTERNAL
+gboolean _gtk_source_context_data_add_ref (GtkSourceContextData *data,
+ const gchar *parent_id,
+ const gchar *ref_id,
+ GtkSourceContextRefOptions options,
+ const gchar *style,
+ gboolean all,
+ GError **error);
+G_GNUC_INTERNAL
+GtkSourceContextReplace *_gtk_source_context_replace_new (const gchar
*to_replace_id,
+ const gchar
*replace_with_id);
+G_GNUC_INTERNAL
+void _gtk_source_context_replace_free (GtkSourceContextReplace *repl);
+G_GNUC_INTERNAL
+gboolean _gtk_source_context_data_finish_parse (GtkSourceContextData *data,
+ GList *overrides,
+ GError **error);
+/* Only for lang files version 1, do not use it */
+G_GNUC_INTERNAL
+void _gtk_source_context_data_set_escape_char (GtkSourceContextData *data,
+ gunichar esc_char);
+
+G_END_DECLS
diff --git a/gtksourceview/gtksourcecontextengine.c b/gtksourceview/gtksourcecontextengine.c
index 33ddfc42..0594772d 100644
--- a/gtksourceview/gtksourcecontextengine.c
+++ b/gtksourceview/gtksourcecontextengine.c
@@ -21,10 +21,11 @@
#include "config.h"
-#include "gtksourcecontextengine.h"
#include <string.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
+
+#include "gtksourcecontextengine-private.h"
#include "gtksourceregion.h"
#include "gtksourcelanguage.h"
#include "gtksourcelanguage-private.h"
@@ -411,8 +412,10 @@ struct _GtkSourceContextData
GHashTable *definitions;
};
-struct _GtkSourceContextEnginePrivate
+struct _GtkSourceContextEngine
{
+ GObject parent_instance;
+
GtkSourceContextData *ctx_data;
GtkTextBuffer *buffer;
@@ -453,9 +456,9 @@ struct _GtkSourceContextEnginePrivate
};
#ifdef ENABLE_CHECK_TREE
-static void check_tree (GtkSourceContextEngine *ce);
-static void check_segment_list (Segment *segment);
-static void check_segment_children (Segment *segment);
+static void check_tree (GtkSourceContextEngine *ce);
+static void check_segment_list (Segment *segment);
+static void check_segment_children (Segment *segment);
#define CHECK_TREE check_tree
#define CHECK_SEGMENT_LIST check_segment_list
#define CHECK_SEGMENT_CHILDREN check_segment_children
@@ -465,66 +468,62 @@ static void check_segment_children (Segment *segment);
#define CHECK_SEGMENT_CHILDREN(s)
#endif
-static GQuark gtk_source_context_engine_error_quark (void) G_GNUC_CONST;
-
-static Segment *create_segment (GtkSourceContextEngine *ce,
- Segment *parent,
- Context *context,
- gint start_at,
- gint end_at,
- gboolean is_start,
- Segment *hint);
-static Segment *segment_new (GtkSourceContextEngine *ce,
- Segment *parent,
- Context *context,
- gint start_at,
- gint end_at,
- gboolean is_start);
-static Context *context_new (Context *parent,
- ContextDefinition *definition,
- const gchar *line_text,
- const gchar *style,
- gboolean ignore_children_style);
-static void context_unref (Context *context);
-static void context_freeze (Context *context);
-static void context_thaw (Context *context);
-static void erase_segments (GtkSourceContextEngine *ce,
- gint start,
- gint end,
- Segment *hint);
-static void segment_remove (GtkSourceContextEngine *ce,
- Segment *segment);
-
-static void find_insertion_place (Segment *segment,
- gint offset,
- Segment **parent,
- Segment **prev,
- Segment **next,
- Segment *hint);
-static void segment_destroy (GtkSourceContextEngine *ce,
- Segment *segment);
-static ContextDefinition *context_definition_ref(ContextDefinition *definition);
-static void context_definition_unref(ContextDefinition *definition);
-
-static void segment_extend (Segment *state,
- gint end_at);
-static Context *ancestor_context_ends_here (Context *state,
- LineInfo *line,
- gint pos);
-static void definition_iter_init (DefinitionsIter *iter,
- ContextDefinition *definition);
-static DefinitionChild *definition_iter_next (DefinitionsIter *iter);
-static void definition_iter_destroy (DefinitionsIter *iter);
-
-static void update_syntax (GtkSourceContextEngine *ce,
- const GtkTextIter *end,
- gint time);
-static void install_idle_worker (GtkSourceContextEngine *ce);
-static void install_first_update (GtkSourceContextEngine *ce);
+static GQuark gtk_source_context_engine_error_quark (void) G_GNUC_CONST;
+static Segment *create_segment (GtkSourceContextEngine *ce,
+ Segment *parent,
+ Context *context,
+ gint start_at,
+ gint end_at,
+ gboolean is_start,
+ Segment *hint);
+static Segment *segment_new (GtkSourceContextEngine *ce,
+ Segment *parent,
+ Context *context,
+ gint start_at,
+ gint end_at,
+ gboolean is_start);
+static Context *context_new (Context *parent,
+ ContextDefinition *definition,
+ const gchar *line_text,
+ const gchar *style,
+ gboolean
ignore_children_style);
+static void context_unref (Context *context);
+static void context_freeze (Context *context);
+static void context_thaw (Context *context);
+static void erase_segments (GtkSourceContextEngine *ce,
+ gint start,
+ gint end,
+ Segment *hint);
+static void segment_remove (GtkSourceContextEngine *ce,
+ Segment *segment);
+static void find_insertion_place (Segment *segment,
+ gint offset,
+ Segment **parent,
+ Segment **prev,
+ Segment **next,
+ Segment *hint);
+static void segment_destroy (GtkSourceContextEngine *ce,
+ Segment *segment);
+static ContextDefinition *context_definition_ref (ContextDefinition *definition);
+static void context_definition_unref (ContextDefinition *definition);
+static void segment_extend (Segment *state,
+ gint end_at);
+static Context *ancestor_context_ends_here (Context *state,
+ LineInfo *line,
+ gint pos);
+static void definition_iter_init (DefinitionsIter *iter,
+ ContextDefinition *definition);
+static DefinitionChild *definition_iter_next (DefinitionsIter *iter);
+static void definition_iter_destroy (DefinitionsIter *iter);
+static void update_syntax (GtkSourceContextEngine *ce,
+ const GtkTextIter *end,
+ gint time);
+static void install_idle_worker (GtkSourceContextEngine *ce);
+static void install_first_update (GtkSourceContextEngine *ce);
static ContextDefinition *
gtk_source_context_data_lookup (GtkSourceContextData *ctx_data,
- const gchar *id)
+ const gchar *id)
{
return g_hash_table_lookup (ctx_data->definitions, id);
}
@@ -573,7 +572,7 @@ gtk_source_context_class_free (GtkSourceContextClass *cclass)
static ContextClassTag *
context_class_tag_new (GtkTextTag *tag,
- gboolean enabled)
+ gboolean enabled)
{
ContextClassTag *attrtag = g_slice_new (ContextClassTag);
@@ -596,8 +595,8 @@ struct BufAndIters {
static void
unhighlight_region_cb (G_GNUC_UNUSED gpointer style,
- GSList *tags,
- gpointer user_data)
+ GSList *tags,
+ gpointer user_data)
{
struct BufAndIters *data = user_data;
@@ -613,27 +612,27 @@ unhighlight_region_cb (G_GNUC_UNUSED gpointer style,
static void
unhighlight_region (GtkSourceContextEngine *ce,
- const GtkTextIter *start,
- const GtkTextIter *end)
+ const GtkTextIter *start,
+ const GtkTextIter *end)
{
struct BufAndIters data;
- data.buffer = ce->priv->buffer;
+ data.buffer = ce->buffer;
data.start = start;
data.end = end;
if (gtk_text_iter_equal (start, end))
return;
- g_hash_table_foreach (ce->priv->tags, (GHFunc) unhighlight_region_cb, &data);
+ g_hash_table_foreach (ce->tags, (GHFunc) unhighlight_region_cb, &data);
}
#define MAX_STYLE_DEPENDENCY_DEPTH 50
static void
set_tag_style (GtkSourceContextEngine *ce,
- GtkTextTag *tag,
- const gchar *style_id)
+ GtkTextTag *tag,
+ const gchar *style_id)
{
GtkSourceStyle *style;
const char *map_to;
@@ -644,11 +643,11 @@ set_tag_style (GtkSourceContextEngine *ce,
gtk_source_style_apply (NULL, tag);
- if (ce->priv->style_scheme == NULL)
+ if (ce->style_scheme == NULL)
return;
map_to = style_id;
- style = gtk_source_style_scheme_get_style (ce->priv->style_scheme, style_id);
+ style = gtk_source_style_scheme_get_style (ce->style_scheme, style_id);
while (style == NULL)
{
@@ -662,11 +661,11 @@ set_tag_style (GtkSourceContextEngine *ce,
/* FIXME Style references really must be fixed, both parser for
* sane use in lang files, and engine for safe use. */
- map_to = gtk_source_language_get_style_fallback (ce->priv->ctx_data->lang, map_to);
+ map_to = gtk_source_language_get_style_fallback (ce->ctx_data->lang, map_to);
if (map_to == NULL)
break;
- style = gtk_source_style_scheme_get_style (ce->priv->style_scheme, map_to);
+ style = gtk_source_style_scheme_get_style (ce->style_scheme, map_to);
}
/* not having style is fine, since parser checks validity of every style reference,
@@ -677,18 +676,18 @@ set_tag_style (GtkSourceContextEngine *ce,
static GtkTextTag *
create_tag (GtkSourceContextEngine *ce,
- const gchar *style_id)
+ const gchar *style_id)
{
GtkTextTag *new_tag;
g_assert (style_id != NULL);
- new_tag = gtk_text_buffer_create_tag (ce->priv->buffer, NULL, NULL);
+ new_tag = gtk_text_buffer_create_tag (ce->buffer, NULL, NULL);
/* It must have priority lower than user tags but still
* higher than highlighting tags created before */
- gtk_text_tag_set_priority (new_tag, ce->priv->n_tags);
+ gtk_text_tag_set_priority (new_tag, ce->n_tags);
set_tag_style (ce, new_tag, style_id);
- ce->priv->n_tags += 1;
+ ce->n_tags += 1;
return new_tag;
}
@@ -696,7 +695,7 @@ create_tag (GtkSourceContextEngine *ce,
/* Find tag which has to be overridden. */
static GtkTextTag *
get_parent_tag (Context *context,
- const char *style)
+ const char *style)
{
while (context != NULL)
{
@@ -717,8 +716,8 @@ get_parent_tag (Context *context,
static GtkTextTag *
get_tag_for_parent (GtkSourceContextEngine *ce,
- const char *style,
- Context *parent)
+ const char *style,
+ Context *parent)
{
GSList *tags;
GtkTextTag *parent_tag = NULL;
@@ -727,7 +726,7 @@ get_tag_for_parent (GtkSourceContextEngine *ce,
g_return_val_if_fail (style != NULL, NULL);
parent_tag = get_parent_tag (parent, style);
- tags = g_hash_table_lookup (ce->priv->tags, style);
+ tags = g_hash_table_lookup (ce->tags, style);
if (tags && (!parent_tag ||
gtk_text_tag_get_priority (tags->data) > gtk_text_tag_get_priority (parent_tag)))
@@ -751,7 +750,7 @@ get_tag_for_parent (GtkSourceContextEngine *ce,
tag = create_tag (ce, style);
tags = g_slist_prepend (tags, g_object_ref (tag));
- g_hash_table_insert (ce->priv->tags, g_strdup (style), tags);
+ g_hash_table_insert (ce->tags, g_strdup (style), tags);
#ifdef ENABLE_DEBUG
{
@@ -770,7 +769,7 @@ get_tag_for_parent (GtkSourceContextEngine *ce,
parent = parent->parent;
}
- tags = g_hash_table_lookup (ce->priv->tags, style);
+ tags = g_hash_table_lookup (ce->tags, style);
n = g_slist_length (tags);
g_print ("created %d tag for style %s: %s\n", n, style, style_path->str);
g_string_free (style_path, TRUE);
@@ -783,8 +782,8 @@ get_tag_for_parent (GtkSourceContextEngine *ce,
static GtkTextTag *
get_subpattern_tag (GtkSourceContextEngine *ce,
- Context *context,
- SubPatternDefinition *sp_def)
+ Context *context,
+ SubPatternDefinition *sp_def)
{
if (sp_def->style == NULL)
return NULL;
@@ -803,7 +802,7 @@ get_subpattern_tag (GtkSourceContextEngine *ce,
static GtkTextTag *
get_context_tag (GtkSourceContextEngine *ce,
- Context *context)
+ Context *context)
{
if (context->style != NULL && context->tag == NULL)
context->tag = get_tag_for_parent (ce,
@@ -814,13 +813,13 @@ get_context_tag (GtkSourceContextEngine *ce,
static void
apply_tags (GtkSourceContextEngine *ce,
- Segment *segment,
- gint start_offset,
- gint end_offset)
+ Segment *segment,
+ gint start_offset,
+ gint end_offset)
{
GtkTextTag *tag;
GtkTextIter start_iter, end_iter;
- GtkTextBuffer *buffer = ce->priv->buffer;
+ GtkTextBuffer *buffer = ce->buffer;
SubPattern *sp;
Segment *child;
@@ -859,7 +858,7 @@ apply_tags (GtkSourceContextEngine *ce,
gtk_text_buffer_get_iter_at_offset (buffer, &start_iter, style_start_at);
end_iter = start_iter;
gtk_text_iter_forward_chars (&end_iter, style_end_at - style_start_at);
- gtk_text_buffer_apply_tag (ce->priv->buffer, tag, &start_iter, &end_iter);
+ gtk_text_buffer_apply_tag (ce->buffer, tag, &start_iter, &end_iter);
}
}
@@ -877,7 +876,7 @@ apply_tags (GtkSourceContextEngine *ce,
gtk_text_buffer_get_iter_at_offset (buffer, &start_iter, start);
end_iter = start_iter;
gtk_text_iter_forward_chars (&end_iter, end - start);
- gtk_text_buffer_apply_tag (ce->priv->buffer, tag, &start_iter, &end_iter);
+ gtk_text_buffer_apply_tag (ce->buffer, tag, &start_iter, &end_iter);
}
}
}
@@ -893,8 +892,8 @@ apply_tags (GtkSourceContextEngine *ce,
static void
highlight_region (GtkSourceContextEngine *ce,
- GtkTextIter *start,
- GtkTextIter *end)
+ GtkTextIter *start,
+ GtkTextIter *end)
{
#ifdef ENABLE_PROFILE
GTimer *timer;
@@ -912,7 +911,7 @@ highlight_region (GtkSourceContextEngine *ce,
/* First we need to delete tags in the regions. */
unhighlight_region (ce, start, end);
- apply_tags (ce, ce->priv->root_segment,
+ apply_tags (ce, ce->root_segment,
gtk_text_iter_get_offset (start),
gtk_text_iter_get_offset (end));
@@ -939,14 +938,14 @@ highlight_region (GtkSourceContextEngine *ce,
*/
static void
ensure_highlighted (GtkSourceContextEngine *ce,
- const GtkTextIter *start,
- const GtkTextIter *end)
+ const GtkTextIter *start,
+ const GtkTextIter *end)
{
GtkSourceRegion *region;
GtkSourceRegionIter reg_iter;
/* Get the subregions not yet highlighted. */
- region = gtk_source_region_intersect_subregion (ce->priv->refresh_region, start, end);
+ region = gtk_source_region_intersect_subregion (ce->refresh_region, start, end);
if (region == NULL)
return;
@@ -966,12 +965,12 @@ ensure_highlighted (GtkSourceContextEngine *ce,
g_clear_object (®ion);
/* Remove the just highlighted region. */
- gtk_source_region_subtract_subregion (ce->priv->refresh_region, start, end);
+ gtk_source_region_subtract_subregion (ce->refresh_region, start, end);
}
static GtkTextTag *
get_context_class_tag (GtkSourceContextEngine *ce,
- gchar const *name)
+ gchar const *name)
{
gchar *tag_name;
GtkTextTagTable *tag_table;
@@ -979,15 +978,15 @@ get_context_class_tag (GtkSourceContextEngine *ce,
tag_name = g_strdup_printf ("gtksourceview:context-classes:%s", name);
- tag_table = gtk_text_buffer_get_tag_table (ce->priv->buffer);
+ tag_table = gtk_text_buffer_get_tag_table (ce->buffer);
tag = gtk_text_tag_table_lookup (tag_table, tag_name);
if (tag == NULL)
{
- tag = gtk_text_buffer_create_tag (ce->priv->buffer, tag_name, NULL);
+ tag = gtk_text_buffer_create_tag (ce->buffer, tag_name, NULL);
g_return_val_if_fail (tag != NULL, NULL);
- ce->priv->context_classes = g_slist_prepend (ce->priv->context_classes,
+ ce->context_classes = g_slist_prepend (ce->context_classes,
g_object_ref (tag));
}
@@ -997,7 +996,7 @@ get_context_class_tag (GtkSourceContextEngine *ce,
static GSList *
extend_context_classes (GtkSourceContextEngine *ce,
- GSList *definitions)
+ GSList *definitions)
{
GSList *item;
GSList *ret = NULL;
@@ -1016,8 +1015,8 @@ extend_context_classes (GtkSourceContextEngine *ce,
static GSList *
get_subpattern_context_classes (GtkSourceContextEngine *ce,
- Context *context,
- SubPatternDefinition *sp_def)
+ Context *context,
+ SubPatternDefinition *sp_def)
{
g_assert (sp_def->index < context->definition->n_sub_patterns);
@@ -1036,7 +1035,7 @@ get_subpattern_context_classes (GtkSourceContextEngine *ce,
static GSList *
get_context_classes (GtkSourceContextEngine *ce,
- Context *context)
+ Context *context)
{
if (context->context_classes == NULL)
{
@@ -1050,15 +1049,15 @@ get_context_classes (GtkSourceContextEngine *ce,
static void
apply_context_classes (GtkSourceContextEngine *ce,
- GSList *context_classes,
- gint start,
- gint end)
+ GSList *context_classes,
+ gint start,
+ gint end)
{
GtkTextIter start_iter;
GtkTextIter end_iter;
GSList *item;
- gtk_text_buffer_get_iter_at_offset (ce->priv->buffer, &start_iter, start);
+ gtk_text_buffer_get_iter_at_offset (ce->buffer, &start_iter, start);
end_iter = start_iter;
gtk_text_iter_forward_chars (&end_iter, end - start);
@@ -1068,14 +1067,14 @@ apply_context_classes (GtkSourceContextEngine *ce,
if (attrtag->enabled)
{
- gtk_text_buffer_apply_tag (ce->priv->buffer,
+ gtk_text_buffer_apply_tag (ce->buffer,
attrtag->tag,
&start_iter,
&end_iter);
}
else
{
- gtk_text_buffer_remove_tag (ce->priv->buffer,
+ gtk_text_buffer_remove_tag (ce->buffer,
attrtag->tag,
&start_iter,
&end_iter);
@@ -1085,9 +1084,9 @@ apply_context_classes (GtkSourceContextEngine *ce,
static void
add_region_context_classes (GtkSourceContextEngine *ce,
- Segment *segment,
- gint start_offset,
- gint end_offset)
+ Segment *segment,
+ gint start_offset,
+ gint end_offset)
{
SubPattern *sp;
Segment *child;
@@ -1152,8 +1151,8 @@ add_region_context_classes (GtkSourceContextEngine *ce,
static void
remove_region_context_classes (GtkSourceContextEngine *ce,
- const GtkTextIter *start,
- const GtkTextIter *end)
+ const GtkTextIter *start,
+ const GtkTextIter *end)
{
GSList *l;
@@ -1162,18 +1161,18 @@ remove_region_context_classes (GtkSourceContextEngine *ce,
return;
}
- for (l = ce->priv->context_classes; l != NULL; l = l->next)
+ for (l = ce->context_classes; l != NULL; l = l->next)
{
GtkTextTag *tag = l->data;
- gtk_text_buffer_remove_tag (ce->priv->buffer, tag, start, end);
+ gtk_text_buffer_remove_tag (ce->buffer, tag, start, end);
}
}
static void
refresh_context_classes (GtkSourceContextEngine *ce,
- const GtkTextIter *start,
- const GtkTextIter *end)
+ const GtkTextIter *start,
+ const GtkTextIter *end)
{
#ifdef ENABLE_PROFILE
GTimer *timer;
@@ -1198,7 +1197,7 @@ refresh_context_classes (GtkSourceContextEngine *ce,
remove_region_context_classes (ce, start, &realend);
add_region_context_classes (ce,
- ce->priv->root_segment,
+ ce->root_segment,
gtk_text_iter_get_offset (start),
gtk_text_iter_get_offset (&realend));
@@ -1223,8 +1222,8 @@ refresh_context_classes (GtkSourceContextEngine *ce,
*/
static void
refresh_range (GtkSourceContextEngine *ce,
- const GtkTextIter *start,
- const GtkTextIter *end)
+ const GtkTextIter *start,
+ const GtkTextIter *end)
{
GtkTextIter real_end;
@@ -1243,7 +1242,7 @@ refresh_range (GtkSourceContextEngine *ce,
gtk_text_iter_backward_cursor_position (&real_end);
}
- g_signal_emit_by_name (ce->priv->buffer,
+ g_signal_emit_by_name (ce->buffer,
"highlight-updated",
start,
&real_end);
@@ -1263,7 +1262,7 @@ refresh_range (GtkSourceContextEngine *ce,
*/
static gint
segment_cmp (Segment *s1,
- Segment *s2)
+ Segment *s2)
{
if (s1->start_at < s2->start_at)
return -1;
@@ -1291,18 +1290,18 @@ segment_cmp (Segment *s1,
*/
static void
add_invalid (GtkSourceContextEngine *ce,
- Segment *segment)
+ Segment *segment)
{
#ifdef ENABLE_CHECK_TREE
- g_assert (!g_slist_find (ce->priv->invalid, segment));
+ g_assert (!g_slist_find (ce->invalid, segment));
#endif
g_return_if_fail (SEGMENT_IS_INVALID (segment));
- ce->priv->invalid = g_slist_insert_sorted (ce->priv->invalid,
+ ce->invalid = g_slist_insert_sorted (ce->invalid,
segment,
(GCompareFunc) segment_cmp);
- DEBUG (g_print ("%d invalid\n", g_slist_length (ce->priv->invalid)));
+ DEBUG (g_print ("%d invalid\n", g_slist_length (ce->invalid)));
}
/**
@@ -1316,12 +1315,12 @@ add_invalid (GtkSourceContextEngine *ce,
*/
static void
remove_invalid (GtkSourceContextEngine *ce,
- Segment *segment)
+ Segment *segment)
{
#ifdef ENABLE_CHECK_TREE
- g_assert (g_slist_find (ce->priv->invalid, segment) != NULL);
+ g_assert (g_slist_find (ce->invalid, segment) != NULL);
#endif
- ce->priv->invalid = g_slist_remove (ce->priv->invalid, segment);
+ ce->invalid = g_slist_remove (ce->invalid, segment);
}
/**
@@ -1335,8 +1334,8 @@ remove_invalid (GtkSourceContextEngine *ce,
*/
static void
fix_offsets_insert_ (Segment *segment,
- gint start,
- gint delta)
+ gint start,
+ gint delta)
{
Segment *child;
SubPattern *sp;
@@ -1373,11 +1372,11 @@ fix_offsets_insert_ (Segment *segment,
*/
static void
find_insertion_place_forward_ (Segment *segment,
- gint offset,
- Segment *start,
- Segment **parent,
- Segment **prev,
- Segment **next)
+ gint offset,
+ Segment *start,
+ Segment **parent,
+ Segment **prev,
+ Segment **next)
{
Segment *child;
@@ -1441,11 +1440,11 @@ find_insertion_place_forward_ (Segment *segment,
*/
static void
find_insertion_place_backward_ (Segment *segment,
- gint offset,
- Segment *start,
- Segment **parent,
- Segment **prev,
- Segment **next)
+ gint offset,
+ Segment *start,
+ Segment **parent,
+ Segment **prev,
+ Segment **next)
{
Segment *child;
@@ -1515,11 +1514,11 @@ find_insertion_place_backward_ (Segment *segment,
*/
static void
find_insertion_place (Segment *segment,
- gint offset,
- Segment **parent,
- Segment **prev,
- Segment **next,
- Segment *hint)
+ gint offset,
+ Segment **parent,
+ Segment **prev,
+ Segment **next,
+ Segment *hint)
{
g_assert (segment->start_at <= offset && segment->end_at >= offset);
@@ -1571,9 +1570,9 @@ find_insertion_place (Segment *segment,
*/
static Segment *
get_invalid_at (GtkSourceContextEngine *ce,
- gint offset)
+ gint offset)
{
- GSList *link = ce->priv->invalid;
+ GSList *link = ce->invalid;
while (link != NULL)
{
@@ -1602,7 +1601,7 @@ get_invalid_at (GtkSourceContextEngine *ce,
*/
static void
segment_add_subpattern (Segment *state,
- SubPattern *sp)
+ SubPattern *sp)
{
sp->next = state->sub_patterns;
state->sub_patterns = sp;
@@ -1622,9 +1621,9 @@ segment_add_subpattern (Segment *state,
*/
static SubPattern *
sub_pattern_new (Segment *segment,
- gint start_at,
- gint end_at,
- SubPatternDefinition *sp_def)
+ gint start_at,
+ gint end_at,
+ SubPatternDefinition *sp_def)
{
SubPattern *sp;
@@ -1663,7 +1662,7 @@ sub_pattern_free (SubPattern *sp)
*/
static void
segment_make_invalid_ (GtkSourceContextEngine *ce,
- Segment *segment)
+ Segment *segment)
{
Context *ctx;
SubPattern *sp;
@@ -1703,8 +1702,8 @@ segment_make_invalid_ (GtkSourceContextEngine *ce,
*/
static Segment *
simple_segment_split_ (GtkSourceContextEngine *ce,
- Segment *segment,
- gint offset)
+ Segment *segment,
+ gint offset)
{
SubPattern *sp;
Segment *new_segment, *invalid;
@@ -1764,11 +1763,11 @@ simple_segment_split_ (GtkSourceContextEngine *ce,
*/
static void
invalidate_region (GtkSourceContextEngine *ce,
- gint offset,
- gint length)
+ gint offset,
+ gint length)
{
- InvalidRegion *region = &ce->priv->invalid_region;
- GtkTextBuffer *buffer = ce->priv->buffer;
+ InvalidRegion *region = &ce->invalid_region;
+ GtkTextBuffer *buffer = ce->buffer;
GtkTextIter iter;
gint end_offset;
@@ -1836,8 +1835,8 @@ invalidate_region (GtkSourceContextEngine *ce,
*/
static void
insert_range (GtkSourceContextEngine *ce,
- gint offset,
- gint length)
+ gint offset,
+ gint length)
{
Segment *parent, *prev = NULL, *next = NULL, *new_segment;
Segment *segment;
@@ -1849,9 +1848,9 @@ insert_range (GtkSourceContextEngine *ce,
parent = get_invalid_at (ce, offset);
if (parent == NULL)
- find_insertion_place (ce->priv->root_segment, offset,
+ find_insertion_place (ce->root_segment, offset,
&parent, &prev, &next,
- ce->priv->hint);
+ ce->hint);
g_assert (parent->start_at <= offset);
g_assert (parent->end_at >= offset);
@@ -1948,13 +1947,13 @@ insert_range (GtkSourceContextEngine *ce,
*/
static void
gtk_source_context_engine_text_inserted (GtkSourceEngine *engine,
- gint start_offset,
- gint end_offset)
+ gint start_offset,
+ gint end_offset)
{
GtkTextIter iter;
GtkSourceContextEngine *ce = GTK_SOURCE_CONTEXT_ENGINE (engine);
- if (!ce->priv->disabled)
+ if (!ce->disabled)
{
g_return_if_fail (start_offset < end_offset);
@@ -1965,7 +1964,7 @@ gtk_source_context_engine_text_inserted (GtkSourceEngine *engine,
* highlighted because the engine analyzes the previous line, end
* context there is none, start context at this line is none too,
* and the engine stops. */
- gtk_text_buffer_get_iter_at_offset (ce->priv->buffer, &iter, end_offset);
+ gtk_text_buffer_get_iter_at_offset (ce->buffer, &iter, end_offset);
if (gtk_text_iter_starts_line (&iter) && !gtk_text_iter_ends_line (&iter))
{
gtk_text_iter_forward_to_line_end (&iter);
@@ -1986,8 +1985,8 @@ gtk_source_context_engine_text_inserted (GtkSourceEngine *engine,
*/
static inline gint
fix_offset_delete_one_ (gint offset,
- gint start,
- gint length)
+ gint start,
+ gint length)
{
if (offset > start)
{
@@ -2012,9 +2011,9 @@ fix_offset_delete_one_ (gint offset,
*/
static void
fix_offsets_delete_ (Segment *segment,
- gint offset,
- gint length,
- Segment *hint)
+ gint offset,
+ gint length,
+ Segment *hint)
{
Segment *child;
SubPattern *sp;
@@ -2064,14 +2063,14 @@ fix_offsets_delete_ (Segment *segment,
*/
static void
delete_range_ (GtkSourceContextEngine *ce,
- gint start,
- gint end)
+ gint start,
+ gint end)
{
g_return_if_fail (start < end);
/* FIXME adjacent invalid segments? */
erase_segments (ce, start, end, NULL);
- fix_offsets_delete_ (ce->priv->root_segment, start, end - start, ce->priv->hint);
+ fix_offsets_delete_ (ce->root_segment, start, end - start, ce->hint);
/* no need to invalidate at start, update_tree will do it */
@@ -2088,14 +2087,14 @@ delete_range_ (GtkSourceContextEngine *ce,
*/
static void
gtk_source_context_engine_text_deleted (GtkSourceEngine *engine,
- gint offset,
- gint length)
+ gint offset,
+ gint length)
{
GtkSourceContextEngine *ce = GTK_SOURCE_CONTEXT_ENGINE (engine);
g_return_if_fail (length > 0);
- if (!ce->priv->disabled)
+ if (!ce->disabled)
{
invalidate_region (ce, offset, - length);
}
@@ -2110,8 +2109,8 @@ gtk_source_context_engine_text_deleted (GtkSourceEngine *engine,
static Segment *
get_invalid_segment (GtkSourceContextEngine *ce)
{
- g_return_val_if_fail (ce->priv->invalid_region.empty, NULL);
- return ce->priv->invalid ? ce->priv->invalid->data : NULL;
+ g_return_val_if_fail (ce->invalid_region.empty, NULL);
+ return ce->invalid ? ce->invalid->data : NULL;
}
/**
@@ -2126,26 +2125,26 @@ get_invalid_line (GtkSourceContextEngine *ce)
GtkTextIter iter;
gint offset = G_MAXINT;
- if (!ce->priv->invalid_region.empty)
+ if (!ce->invalid_region.empty)
{
gint tmp;
- gtk_text_buffer_get_iter_at_mark (ce->priv->buffer,
+ gtk_text_buffer_get_iter_at_mark (ce->buffer,
&iter,
- ce->priv->invalid_region.start);
+ ce->invalid_region.start);
tmp = gtk_text_iter_get_offset (&iter);
offset = MIN (offset, tmp);
}
- if (ce->priv->invalid)
+ if (ce->invalid)
{
- Segment *segment = ce->priv->invalid->data;
+ Segment *segment = ce->invalid->data;
offset = MIN (offset, segment->start_at);
}
if (offset == G_MAXINT)
return -1;
- gtk_text_buffer_get_iter_at_offset (ce->priv->buffer, &iter, offset);
+ gtk_text_buffer_get_iter_at_offset (ce->buffer, &iter, offset);
return gtk_text_iter_get_line (&iter);
}
@@ -2158,7 +2157,7 @@ get_invalid_line (GtkSourceContextEngine *ce)
static void
update_tree (GtkSourceContextEngine *ce)
{
- InvalidRegion *region = &ce->priv->invalid_region;
+ InvalidRegion *region = &ce->invalid_region;
gint start, end, delta;
gint erase_start, erase_end;
GtkTextIter iter;
@@ -2166,9 +2165,9 @@ update_tree (GtkSourceContextEngine *ce)
if (region->empty)
return;
- gtk_text_buffer_get_iter_at_mark (ce->priv->buffer, &iter, region->start);
+ gtk_text_buffer_get_iter_at_mark (ce->buffer, &iter, region->start);
start = gtk_text_iter_get_offset (&iter);
- gtk_text_buffer_get_iter_at_mark (ce->priv->buffer, &iter, region->end);
+ gtk_text_buffer_get_iter_at_mark (ce->buffer, &iter, region->end);
end = gtk_text_iter_get_offset (&iter);
delta = region->delta;
@@ -2200,7 +2199,7 @@ update_tree (GtkSourceContextEngine *ce)
if (erase_start < erase_end)
{
erase_segments (ce, erase_start, erase_end, NULL);
- create_segment (ce, ce->priv->root_segment, NULL, erase_start, erase_end, FALSE, NULL);
+ create_segment (ce, ce->root_segment, NULL, erase_start, erase_end, FALSE, NULL);
}
else if (get_invalid_at (ce, start) == NULL)
{
@@ -2230,15 +2229,15 @@ update_tree (GtkSourceContextEngine *ce)
*/
static void
gtk_source_context_engine_update_highlight (GtkSourceEngine *engine,
- const GtkTextIter *start,
- const GtkTextIter *end,
- gboolean synchronous)
+ const GtkTextIter *start,
+ const GtkTextIter *end,
+ gboolean synchronous)
{
gint invalid_line;
gint end_line;
GtkSourceContextEngine *ce = GTK_SOURCE_CONTEXT_ENGINE (engine);
- if (!ce->priv->highlight || ce->priv->disabled)
+ if (!ce->highlight || ce->disabled)
return;
invalid_line = get_invalid_line (ce);
@@ -2282,20 +2281,20 @@ gtk_source_context_engine_update_highlight (GtkSourceEngine *engine,
*/
static void
enable_highlight (GtkSourceContextEngine *ce,
- gboolean enable)
+ gboolean enable)
{
GtkTextIter start, end;
- if (!enable == !ce->priv->highlight)
+ if (!enable == !ce->highlight)
return;
- ce->priv->highlight = enable != 0;
- gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (ce->priv->buffer),
+ ce->highlight = enable != 0;
+ gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (ce->buffer),
&start, &end);
if (enable)
{
- gtk_source_region_add_subregion (ce->priv->refresh_region, &start, &end);
+ gtk_source_region_add_subregion (ce->refresh_region, &start, &end);
refresh_range (ce, &start, &end);
}
@@ -2310,7 +2309,7 @@ buffer_notify_highlight_syntax_cb (GtkSourceContextEngine *ce)
{
gboolean highlight;
- g_object_get (ce->priv->buffer, "highlight-syntax", &highlight, NULL);
+ g_object_get (ce->buffer, "highlight-syntax", &highlight, NULL);
enable_highlight (ce, highlight);
}
@@ -2326,7 +2325,7 @@ buffer_notify_highlight_syntax_cb (GtkSourceContextEngine *ce)
static gboolean
all_analyzed (GtkSourceContextEngine *ce)
{
- return ce->priv->invalid == NULL && ce->priv->invalid_region.empty;
+ return ce->invalid == NULL && ce->invalid_region.empty;
}
/**
@@ -2341,7 +2340,7 @@ idle_worker (GtkSourceContextEngine *ce)
{
gboolean retval = G_SOURCE_CONTINUE;
- g_return_val_if_fail (ce->priv->buffer != NULL, G_SOURCE_REMOVE);
+ g_return_val_if_fail (ce->buffer != NULL, G_SOURCE_REMOVE);
/* analyze batch of text */
update_syntax (ce, NULL, INCREMENTAL_UPDATE_TIME_SLICE);
@@ -2349,7 +2348,7 @@ idle_worker (GtkSourceContextEngine *ce)
if (all_analyzed (ce))
{
- ce->priv->incremental_update = 0;
+ ce->incremental_update = 0;
retval = G_SOURCE_REMOVE;
}
@@ -2366,13 +2365,13 @@ idle_worker (GtkSourceContextEngine *ce)
static gboolean
first_update_callback (GtkSourceContextEngine *ce)
{
- g_return_val_if_fail (ce->priv->buffer != NULL, G_SOURCE_REMOVE);
+ g_return_val_if_fail (ce->buffer != NULL, G_SOURCE_REMOVE);
/* analyze batch of text */
update_syntax (ce, NULL, FIRST_UPDATE_TIME_SLICE);
CHECK_TREE (ce);
- ce->priv->first_update = 0;
+ ce->first_update = 0;
if (!all_analyzed (ce))
install_idle_worker (ce);
@@ -2390,8 +2389,8 @@ first_update_callback (GtkSourceContextEngine *ce)
static void
install_idle_worker (GtkSourceContextEngine *ce)
{
- if (ce->priv->first_update == 0 && ce->priv->incremental_update == 0)
- ce->priv->incremental_update =
+ if (ce->first_update == 0 && ce->incremental_update == 0)
+ ce->incremental_update =
gdk_threads_add_idle_full (INCREMENTAL_UPDATE_PRIORITY,
(GSourceFunc) idle_worker, ce, NULL);
}
@@ -2406,15 +2405,15 @@ install_idle_worker (GtkSourceContextEngine *ce)
static void
install_first_update (GtkSourceContextEngine *ce)
{
- if (ce->priv->first_update == 0)
+ if (ce->first_update == 0)
{
- if (ce->priv->incremental_update != 0)
+ if (ce->incremental_update != 0)
{
- g_source_remove (ce->priv->incremental_update);
- ce->priv->incremental_update = 0;
+ g_source_remove (ce->incremental_update);
+ ce->incremental_update = 0;
}
- ce->priv->first_update =
+ ce->first_update =
gdk_threads_add_idle_full (FIRST_UPDATE_PRIORITY,
(GSourceFunc) first_update_callback,
ce, NULL);
@@ -2426,11 +2425,10 @@ install_first_update (GtkSourceContextEngine *ce)
static void _gtk_source_engine_interface_init (GtkSourceEngineInterface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkSourceContextEngine,
- _gtk_source_context_engine,
- G_TYPE_OBJECT,
- G_ADD_PRIVATE (GtkSourceContextEngine)
- G_IMPLEMENT_INTERFACE (GTK_SOURCE_TYPE_ENGINE,
- _gtk_source_engine_interface_init))
+ _gtk_source_context_engine,
+ G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (GTK_SOURCE_TYPE_ENGINE,
+ _gtk_source_engine_interface_init))
static GQuark
gtk_source_context_engine_error_quark (void)
@@ -2443,8 +2441,8 @@ gtk_source_context_engine_error_quark (void)
static void
remove_tags_hash_cb (G_GNUC_UNUSED gpointer style,
- GSList *tags,
- GtkTextTagTable *table)
+ GSList *tags,
+ GtkTextTagTable *table)
{
GSList *l = tags;
@@ -2467,10 +2465,10 @@ remove_tags_hash_cb (G_GNUC_UNUSED gpointer style,
static void
destroy_tags_hash (GtkSourceContextEngine *ce)
{
- g_hash_table_foreach (ce->priv->tags, (GHFunc) remove_tags_hash_cb,
- gtk_text_buffer_get_tag_table (ce->priv->buffer));
- g_hash_table_destroy (ce->priv->tags);
- ce->priv->tags = NULL;
+ g_hash_table_foreach (ce->tags, (GHFunc) remove_tags_hash_cb,
+ gtk_text_buffer_get_tag_table (ce->buffer));
+ g_hash_table_destroy (ce->tags);
+ ce->tags = NULL;
}
static void
@@ -2479,9 +2477,9 @@ destroy_context_classes_list (GtkSourceContextEngine *ce)
GtkTextTagTable *table;
GSList *l;
- table = gtk_text_buffer_get_tag_table (ce->priv->buffer);
+ table = gtk_text_buffer_get_tag_table (ce->buffer);
- for (l = ce->priv->context_classes; l != NULL; l = l->next)
+ for (l = ce->context_classes; l != NULL; l = l->next)
{
GtkTextTag *tag = l->data;
@@ -2489,8 +2487,8 @@ destroy_context_classes_list (GtkSourceContextEngine *ce)
g_object_unref (tag);
}
- g_slist_free (ce->priv->context_classes);
- ce->priv->context_classes = NULL;
+ g_slist_free (ce->context_classes);
+ ce->context_classes = NULL;
}
/**
@@ -2503,47 +2501,47 @@ destroy_context_classes_list (GtkSourceContextEngine *ce)
*/
static void
gtk_source_context_engine_attach_buffer (GtkSourceEngine *engine,
- GtkTextBuffer *buffer)
+ GtkTextBuffer *buffer)
{
GtkSourceContextEngine *ce = GTK_SOURCE_CONTEXT_ENGINE (engine);
g_return_if_fail (!buffer || GTK_IS_TEXT_BUFFER (buffer));
- if (ce->priv->buffer == buffer)
+ if (ce->buffer == buffer)
return;
/* Detach previous buffer if there is one. */
- if (ce->priv->buffer != NULL)
+ if (ce->buffer != NULL)
{
- g_signal_handlers_disconnect_by_func (ce->priv->buffer,
+ g_signal_handlers_disconnect_by_func (ce->buffer,
(gpointer) buffer_notify_highlight_syntax_cb,
ce);
- if (ce->priv->first_update != 0)
- g_source_remove (ce->priv->first_update);
- if (ce->priv->incremental_update != 0)
- g_source_remove (ce->priv->incremental_update);
- ce->priv->first_update = 0;
- ce->priv->incremental_update = 0;
-
- if (ce->priv->root_segment != NULL)
- segment_destroy (ce, ce->priv->root_segment);
- if (ce->priv->root_context != NULL)
- context_unref (ce->priv->root_context);
- g_assert (!ce->priv->invalid);
- g_slist_free (ce->priv->invalid);
- ce->priv->root_segment = NULL;
- ce->priv->root_context = NULL;
- ce->priv->invalid = NULL;
-
- if (ce->priv->invalid_region.start != NULL)
- gtk_text_buffer_delete_mark (ce->priv->buffer,
- ce->priv->invalid_region.start);
- if (ce->priv->invalid_region.end != NULL)
- gtk_text_buffer_delete_mark (ce->priv->buffer,
- ce->priv->invalid_region.end);
- ce->priv->invalid_region.start = NULL;
- ce->priv->invalid_region.end = NULL;
+ if (ce->first_update != 0)
+ g_source_remove (ce->first_update);
+ if (ce->incremental_update != 0)
+ g_source_remove (ce->incremental_update);
+ ce->first_update = 0;
+ ce->incremental_update = 0;
+
+ if (ce->root_segment != NULL)
+ segment_destroy (ce, ce->root_segment);
+ if (ce->root_context != NULL)
+ context_unref (ce->root_context);
+ g_assert (!ce->invalid);
+ g_slist_free (ce->invalid);
+ ce->root_segment = NULL;
+ ce->root_context = NULL;
+ ce->invalid = NULL;
+
+ if (ce->invalid_region.start != NULL)
+ gtk_text_buffer_delete_mark (ce->buffer,
+ ce->invalid_region.start);
+ if (ce->invalid_region.end != NULL)
+ gtk_text_buffer_delete_mark (ce->buffer,
+ ce->invalid_region.end);
+ ce->invalid_region.start = NULL;
+ ce->invalid_region.end = NULL;
/* this deletes tags from the tag table, therefore there is no need
* in removing tags from the text (it may be very slow).
@@ -2552,51 +2550,51 @@ gtk_source_context_engine_attach_buffer (GtkSourceEngine *engine,
* nothing. Caveat: if tag table is shared with other buffer, we do
* need to remove tags. */
destroy_tags_hash (ce);
- ce->priv->n_tags = 0;
+ ce->n_tags = 0;
destroy_context_classes_list (ce);
- g_clear_object (&ce->priv->refresh_region);
+ g_clear_object (&ce->refresh_region);
}
- ce->priv->buffer = buffer;
+ ce->buffer = buffer;
if (buffer != NULL)
{
ContextDefinition *main_definition;
GtkTextIter start, end;
- main_definition = gtk_source_context_data_lookup_root (ce->priv->ctx_data);
+ main_definition = gtk_source_context_data_lookup_root (ce->ctx_data);
/* If we don't abort here, we will crash later (#485661). But it should
* never happen, _gtk_source_context_data_finish_parse checks main context. */
g_assert (main_definition != NULL);
- ce->priv->root_context = context_new (NULL, main_definition, NULL, NULL, FALSE);
- ce->priv->root_segment = create_segment (ce, NULL, ce->priv->root_context, 0, 0, TRUE, NULL);
+ ce->root_context = context_new (NULL, main_definition, NULL, NULL, FALSE);
+ ce->root_segment = create_segment (ce, NULL, ce->root_context, 0, 0, TRUE, NULL);
- ce->priv->tags = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- ce->priv->context_classes = NULL;
+ ce->tags = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ ce->context_classes = NULL;
gtk_text_buffer_get_bounds (buffer, &start, &end);
- ce->priv->invalid_region.start = gtk_text_buffer_create_mark (buffer, NULL,
+ ce->invalid_region.start = gtk_text_buffer_create_mark (buffer, NULL,
&start, TRUE);
- ce->priv->invalid_region.end = gtk_text_buffer_create_mark (buffer, NULL,
+ ce->invalid_region.end = gtk_text_buffer_create_mark (buffer, NULL,
&end, FALSE);
if (gtk_text_buffer_get_char_count (buffer) != 0)
{
- ce->priv->invalid_region.empty = FALSE;
- ce->priv->invalid_region.delta = gtk_text_buffer_get_char_count (buffer);
+ ce->invalid_region.empty = FALSE;
+ ce->invalid_region.delta = gtk_text_buffer_get_char_count (buffer);
}
else
{
- ce->priv->invalid_region.empty = TRUE;
- ce->priv->invalid_region.delta = 0;
+ ce->invalid_region.empty = TRUE;
+ ce->invalid_region.delta = 0;
}
- g_object_get (buffer, "highlight-syntax", &ce->priv->highlight, NULL);
- ce->priv->refresh_region = gtk_source_region_new (buffer);
+ g_object_get (buffer, "highlight-syntax", &ce->highlight, NULL);
+ ce->refresh_region = gtk_source_region_new (buffer);
g_signal_connect_swapped (buffer,
"notify::highlight-syntax",
@@ -2618,9 +2616,9 @@ gtk_source_context_engine_attach_buffer (GtkSourceEngine *engine,
static void
disable_syntax_analysis (GtkSourceContextEngine *ce)
{
- if (!ce->priv->disabled)
+ if (!ce->disabled)
{
- ce->priv->disabled = TRUE;
+ ce->disabled = TRUE;
gtk_source_context_engine_attach_buffer (GTK_SOURCE_ENGINE (ce), NULL);
/* FIXME maybe emit some signal here? */
}
@@ -2628,8 +2626,8 @@ disable_syntax_analysis (GtkSourceContextEngine *ce)
static void
set_tag_style_hash_cb (const char *style,
- GSList *tags,
- GtkSourceContextEngine *ce)
+ GSList *tags,
+ GtkSourceContextEngine *ce)
{
while (tags != NULL)
{
@@ -2648,7 +2646,7 @@ set_tag_style_hash_cb (const char *style,
*/
static void
gtk_source_context_engine_set_style_scheme (GtkSourceEngine *engine,
- GtkSourceStyleScheme *scheme)
+ GtkSourceStyleScheme *scheme)
{
GtkSourceContextEngine *ce;
@@ -2657,9 +2655,9 @@ gtk_source_context_engine_set_style_scheme (GtkSourceEngine *engine,
ce = GTK_SOURCE_CONTEXT_ENGINE (engine);
- if (g_set_object (&ce->priv->style_scheme, scheme))
+ if (g_set_object (&ce->style_scheme, scheme))
{
- g_hash_table_foreach (ce->priv->tags, (GHFunc) set_tag_style_hash_cb, ce);
+ g_hash_table_foreach (ce->tags, (GHFunc) set_tag_style_hash_cb, ce);
}
}
@@ -2668,7 +2666,7 @@ gtk_source_context_engine_finalize (GObject *object)
{
GtkSourceContextEngine *ce = GTK_SOURCE_CONTEXT_ENGINE (object);
- if (ce->priv->buffer != NULL)
+ if (ce->buffer != NULL)
{
g_critical ("finalizing engine with attached buffer");
/* Disconnect the buffer (if there is one), which destroys almost
@@ -2676,26 +2674,26 @@ gtk_source_context_engine_finalize (GObject *object)
gtk_source_context_engine_attach_buffer (GTK_SOURCE_ENGINE (ce), NULL);
}
- g_assert (!ce->priv->tags);
- g_assert (!ce->priv->root_context);
- g_assert (!ce->priv->root_segment);
+ g_assert (!ce->tags);
+ g_assert (!ce->root_context);
+ g_assert (!ce->root_segment);
- if (ce->priv->first_update != 0)
+ if (ce->first_update != 0)
{
- g_source_remove (ce->priv->first_update);
- ce->priv->first_update = 0;
+ g_source_remove (ce->first_update);
+ ce->first_update = 0;
}
- if (ce->priv->incremental_update != 0)
+ if (ce->incremental_update != 0)
{
- g_source_remove (ce->priv->incremental_update);
- ce->priv->incremental_update = 0;
+ g_source_remove (ce->incremental_update);
+ ce->incremental_update = 0;
}
- _gtk_source_context_data_unref (ce->priv->ctx_data);
+ _gtk_source_context_data_unref (ce->ctx_data);
- if (ce->priv->style_scheme != NULL)
- g_object_unref (ce->priv->style_scheme);
+ if (ce->style_scheme != NULL)
+ g_object_unref (ce->style_scheme);
G_OBJECT_CLASS (_gtk_source_context_engine_parent_class)->finalize (object);
}
@@ -2721,7 +2719,7 @@ _gtk_source_context_engine_class_init (GtkSourceContextEngineClass *klass)
static void
_gtk_source_context_engine_init (GtkSourceContextEngine *ce)
{
- ce->priv = _gtk_source_context_engine_get_instance_private (ce);
+ ce = _gtk_source_context_engine_get_instance_private (ce);
}
GtkSourceContextEngine *
@@ -2733,7 +2731,7 @@ _gtk_source_context_engine_new (GtkSourceContextData *ctx_data)
g_return_val_if_fail (ctx_data->lang != NULL, NULL);
ce = g_object_new (GTK_SOURCE_TYPE_CONTEXT_ENGINE, NULL);
- ce->priv->ctx_data = _gtk_source_context_data_ref (ctx_data);
+ ce->ctx_data = _gtk_source_context_data_ref (ctx_data);
return ce;
}
@@ -2742,7 +2740,7 @@ _gtk_source_context_engine_new (GtkSourceContextData *ctx_data)
* _gtk_source_context_data_new:
* @lang: #GtkSourceLanguage.
*
- * Creates new context definition set. It does not set lang->priv->ctx_data,
+ * Creates new context definition set. It does not set lang->ctx_data,
* that's lang business.
*/
GtkSourceContextData *
@@ -2774,7 +2772,7 @@ _gtk_source_context_data_ref (GtkSourceContextData *ctx_data)
* @ctx_data: #GtkSourceContextData.
*
* Decreases reference count in ctx_data. When reference count
- * drops to zero, ctx_data is freed, and ctx_data->lang->priv->ctx_data
+ * drops to zero, ctx_data is freed, and ctx_data->lang->ctx_data
* is unset.
*/
void
@@ -2807,9 +2805,9 @@ _gtk_source_context_data_unref (GtkSourceContextData *ctx_data)
*/
static void
apply_sub_patterns (Segment *state,
- LineInfo *line,
- GtkSourceRegex *regex,
- SubPatternWhere where)
+ LineInfo *line,
+ GtkSourceRegex *regex,
+ SubPatternWhere where)
{
GSList *sub_pattern_list = state->context->definition->sub_patterns;
@@ -2894,10 +2892,10 @@ apply_sub_patterns (Segment *state,
*/
static gboolean
can_apply_match (Context *state,
- LineInfo *line,
- gint match_start,
- gint *match_end,
- GtkSourceRegex *regex)
+ LineInfo *line,
+ gint match_start,
+ gint *match_end,
+ GtkSourceRegex *regex)
{
gint end_match_pos;
gboolean ancestor_ends;
@@ -2955,7 +2953,7 @@ can_apply_match (Context *state,
static gint
line_pos_to_offset (LineInfo *line,
- gint pos)
+ gint pos)
{
if (line->char_length != line->byte_length)
pos = g_utf8_pointer_to_offset (line->text, line->text + pos);
@@ -2982,10 +2980,10 @@ line_pos_to_offset (LineInfo *line,
*/
static gboolean
apply_match (Segment *state,
- LineInfo *line,
- gint *line_pos,
- GtkSourceRegex *regex,
- SubPatternWhere where)
+ LineInfo *line,
+ gint *line_pos,
+ GtkSourceRegex *regex,
+ SubPatternWhere where)
{
gint match_end;
@@ -3020,7 +3018,7 @@ apply_match (Segment *state,
*/
static GtkSourceRegex *
create_reg_all (Context *context,
- ContextDefinition *definition)
+ ContextDefinition *definition)
{
DefinitionsIter iter;
DefinitionChild *child_def;
@@ -3155,10 +3153,10 @@ context_ref (Context *context)
/* does not copy style */
static Context *
context_new (Context *parent,
- ContextDefinition *definition,
- const gchar *line_text,
- const gchar *style,
- gboolean ignore_children_style)
+ ContextDefinition *definition,
+ const gchar *line_text,
+ const gchar *style,
+ gboolean ignore_children_style)
{
Context *context;
@@ -3226,8 +3224,8 @@ context_new (Context *parent,
static void
context_unref_hash_cb (gpointer text,
- Context *context,
- gpointer user_data)
+ Context *context,
+ gpointer user_data)
{
context->parent = NULL;
context_unref (context);
@@ -3235,15 +3233,15 @@ context_unref_hash_cb (gpointer text,
static gboolean
remove_context_cb (G_GNUC_UNUSED gpointer text,
- Context *context,
- Context *target)
+ Context *context,
+ Context *target)
{
return context == target;
}
static void
context_remove_child (Context *parent,
- Context *context)
+ Context *context)
{
ContextPtr *ptr, *prev = NULL;
gboolean delete = TRUE;
@@ -3359,8 +3357,8 @@ context_unref (Context *context)
static void
context_freeze_hash_cb (gpointer text,
- Context *context,
- gpointer user_data)
+ Context *context,
+ gpointer user_data)
{
context_freeze (context);
}
@@ -3409,15 +3407,15 @@ context_freeze (Context *ctx)
static void
get_child_contexts_hash_cb (G_GNUC_UNUSED gpointer text,
- Context *context,
- GSList **list)
+ Context *context,
+ GSList **list)
{
*list = g_slist_prepend (*list, context);
}
static void
-context_thaw_cb (Context *ctx,
- gpointer user_data)
+context_thaw_cb (Context *ctx,
+ gpointer user_data)
{
context_thaw (ctx);
}
@@ -3466,8 +3464,8 @@ context_thaw (Context *ctx)
static Context *
create_child_context (Context *parent,
- DefinitionChild *child_def,
- const gchar *line_text)
+ DefinitionChild *child_def,
+ const gchar *line_text)
{
Context *context;
ContextPtr *ptr;
@@ -3548,11 +3546,11 @@ create_child_context (Context *parent,
*/
static Segment *
segment_new (GtkSourceContextEngine *ce,
- Segment *parent,
- Context *context,
- gint start_at,
- gint end_at,
- gboolean is_start)
+ Segment *parent,
+ Context *context,
+ gint start_at,
+ gint end_at,
+ gboolean is_start)
{
Segment *segment;
@@ -3575,10 +3573,10 @@ segment_new (GtkSourceContextEngine *ce,
static void
find_segment_position_forward_ (Segment *segment,
- gint start_at,
- gint end_at,
- Segment **prev,
- Segment **next)
+ gint start_at,
+ gint end_at,
+ Segment **prev,
+ Segment **next)
{
g_assert (segment->start_at <= start_at);
@@ -3617,10 +3615,10 @@ find_segment_position_forward_ (Segment *segment,
static void
find_segment_position_backward_ (Segment *segment,
- gint start_at,
- gint end_at,
- Segment **prev,
- Segment **next)
+ gint start_at,
+ gint end_at,
+ Segment **prev,
+ Segment **next)
{
g_assert (start_at < segment->end_at);
@@ -3654,11 +3652,11 @@ find_segment_position_backward_ (Segment *segment,
*/
static void
find_segment_position (Segment *parent,
- Segment *hint,
- gint start_at,
- gint end_at,
- Segment **prev,
- Segment **next)
+ Segment *hint,
+ gint start_at,
+ gint end_at,
+ Segment **prev,
+ Segment **next)
{
Segment *tmp;
@@ -3707,12 +3705,12 @@ find_segment_position (Segment *parent,
*/
static Segment *
create_segment (GtkSourceContextEngine *ce,
- Segment *parent,
- Context *context,
- gint start_at,
- gint end_at,
- gboolean is_start,
- Segment *hint)
+ Segment *parent,
+ Context *context,
+ gint start_at,
+ gint end_at,
+ gboolean is_start,
+ Segment *hint)
{
Segment *segment;
@@ -3726,7 +3724,7 @@ create_segment (GtkSourceContextEngine *ce,
if (hint == NULL)
{
- hint = ce->priv->hint;
+ hint = ce->hint;
while (hint != NULL && hint->parent != parent)
hint = hint->parent;
}
@@ -3769,7 +3767,7 @@ create_segment (GtkSourceContextEngine *ce,
*/
static void
segment_extend (Segment *state,
- gint end_at)
+ gint end_at)
{
while (state != NULL && state->end_at < end_at)
{
@@ -3781,7 +3779,7 @@ segment_extend (Segment *state,
static void
segment_destroy_children (GtkSourceContextEngine *ce,
- Segment *segment)
+ Segment *segment)
{
Segment *child;
SubPattern *sp;
@@ -3822,7 +3820,7 @@ segment_destroy_children (GtkSourceContextEngine *ce,
*/
static void
segment_destroy (GtkSourceContextEngine *ce,
- Segment *segment)
+ Segment *segment)
{
g_return_if_fail (segment != NULL);
@@ -3830,10 +3828,10 @@ segment_destroy (GtkSourceContextEngine *ce,
/* segment neighbours and parent may be invalid here,
* so we only can unset the hint */
- if (ce->priv->hint == segment)
- ce->priv->hint = NULL;
- if (ce->priv->hint2 == segment)
- ce->priv->hint2 = NULL;
+ if (ce->hint == segment)
+ ce->hint = NULL;
+ if (ce->hint2 == segment)
+ ce->hint2 = NULL;
if (SEGMENT_IS_INVALID (segment))
remove_invalid (ce, segment);
@@ -3841,7 +3839,7 @@ segment_destroy (GtkSourceContextEngine *ce,
context_unref (segment->context);
#ifdef ENABLE_DEBUG
- g_assert (!g_slist_find (ce->priv->invalid, segment));
+ g_assert (!g_slist_find (ce->invalid, segment));
memset (segment, 1, sizeof (Segment));
#else
g_slice_free (Segment, segment);
@@ -3855,11 +3853,11 @@ segment_destroy (GtkSourceContextEngine *ce,
*/
static gboolean
container_context_starts_here (GtkSourceContextEngine *ce,
- Segment *state,
- DefinitionChild *child_def,
- LineInfo *line,
- gint *line_pos, /* bytes */
- Segment **new_state)
+ Segment *state,
+ DefinitionChild *child_def,
+ LineInfo *line,
+ gint *line_pos, /* bytes */
+ Segment **new_state)
{
Context *new_context;
Segment *new_segment;
@@ -3896,7 +3894,7 @@ container_context_starts_here (GtkSourceContextEngine *ce,
line_pos_to_offset (line, *line_pos),
line_pos_to_offset (line, match_end),
TRUE,
- ce->priv->hint2);
+ ce->hint2);
/* This new context could end at the same position (i.e. have zero length),
* and then we get an infinite loop. We can't possibly know about it at this point
@@ -3919,7 +3917,7 @@ container_context_starts_here (GtkSourceContextEngine *ce,
SUB_PATTERN_WHERE_START);
*line_pos = match_end;
*new_state = new_segment;
- ce->priv->hint2 = NULL;
+ ce->hint2 = NULL;
context_unref (new_context);
return TRUE;
}
@@ -3930,12 +3928,12 @@ container_context_starts_here (GtkSourceContextEngine *ce,
* See child_starts_here().
*/
static gboolean
-simple_context_starts_here (GtkSourceContextEngine *ce,
- Segment *state,
- DefinitionChild *child_def,
- LineInfo *line,
- gint *line_pos, /* bytes */
- Segment **new_state)
+simple_context_starts_here (GtkSourceContextEngine *ce,
+ Segment *state,
+ DefinitionChild *child_def,
+ LineInfo *line,
+ gint *line_pos, /* bytes */
+ Segment **new_state)
{
gint match_end;
Context *new_context;
@@ -3987,9 +3985,9 @@ simple_context_starts_here (GtkSourceContextEngine *ce,
line_pos_to_offset (line, *line_pos),
line_pos_to_offset (line, match_end),
TRUE,
- ce->priv->hint2);
+ ce->hint2);
apply_sub_patterns (new_segment, line, definition->u.match, SUB_PATTERN_WHERE_DEFAULT);
- ce->priv->hint2 = new_segment;
+ ce->hint2 = new_segment;
}
/* Terminate parent if needed */
@@ -3997,7 +3995,7 @@ simple_context_starts_here (GtkSourceContextEngine *ce,
{
do
{
- ce->priv->hint2 = state;
+ ce->hint2 = state;
state = state->parent;
}
while (SEGMENT_ENDS_PARENT (state));
@@ -4026,11 +4024,11 @@ simple_context_starts_here (GtkSourceContextEngine *ce,
*/
static gboolean
child_starts_here (GtkSourceContextEngine *ce,
- Segment *state,
- DefinitionChild *child_def,
- LineInfo *line,
- gint *line_pos,
- Segment **new_state)
+ Segment *state,
+ DefinitionChild *child_def,
+ LineInfo *line,
+ gint *line_pos,
+ Segment **new_state)
{
g_return_val_if_fail (child_def->resolved, FALSE);
@@ -4067,8 +4065,8 @@ child_starts_here (GtkSourceContextEngine *ce,
*/
static gboolean
segment_ends_here (Segment *state,
- LineInfo *line,
- gint pos)
+ LineInfo *line,
+ gint pos)
{
g_assert (SEGMENT_IS_CONTAINER (state));
@@ -4093,8 +4091,8 @@ segment_ends_here (Segment *state,
*/
static Context *
ancestor_context_ends_here (Context *state,
- LineInfo *line,
- gint line_pos)
+ LineInfo *line,
+ gint line_pos)
{
Context *current_context;
GSList *current_context_list;
@@ -4156,9 +4154,9 @@ ancestor_context_ends_here (Context *state,
*/
static gboolean
ancestor_ends_here (Segment *state,
- LineInfo *line,
- gint line_pos,
- Segment **new_state)
+ LineInfo *line,
+ gint line_pos,
+ Segment **new_state)
{
Context *terminating_context;
@@ -4197,14 +4195,14 @@ ancestor_ends_here (Segment *state,
*/
static gboolean
next_segment (GtkSourceContextEngine *ce,
- Segment *state,
- LineInfo *line,
- gint *line_pos,
- Segment **new_state)
+ Segment *state,
+ LineInfo *line,
+ gint *line_pos,
+ Segment **new_state)
{
gint pos = *line_pos;
- g_assert (!ce->priv->hint2 || ce->priv->hint2->parent == state);
+ g_assert (!ce->hint2 || ce->hint2->parent == state);
g_assert (pos <= line->byte_length);
while (pos <= line->byte_length)
@@ -4307,7 +4305,7 @@ next_segment (GtkSourceContextEngine *ce,
state = state->parent;
*new_state = state->parent;
- ce->priv->hint2 = state;
+ ce->hint2 = state;
*line_pos = pos;
return TRUE;
}
@@ -4332,12 +4330,12 @@ next_segment (GtkSourceContextEngine *ce,
*/
static Segment *
check_line_end (GtkSourceContextEngine *ce,
- Segment *state)
+ Segment *state)
{
Segment *current_segment;
Segment *terminating_segment;
- g_assert (!ce->priv->hint2 || ce->priv->hint2->parent == state);
+ g_assert (!ce->hint2 || ce->hint2->parent == state);
/* A context can be terminated by the parent if extend_parent is
* FALSE, so we need to verify the end of all the parents of
@@ -4356,7 +4354,7 @@ check_line_end (GtkSourceContextEngine *ce,
if (terminating_segment != NULL)
{
- ce->priv->hint2 = terminating_segment;
+ ce->hint2 = terminating_segment;
return terminating_segment->parent;
}
else
@@ -4367,7 +4365,7 @@ check_line_end (GtkSourceContextEngine *ce,
static void
delete_zero_length_segments (GtkSourceContextEngine *ce,
- GList *list)
+ GList *list)
{
while (list != NULL)
{
@@ -4400,9 +4398,9 @@ delete_zero_length_segments (GtkSourceContextEngine *ce,
l = next;
}
- if (ce->priv->hint2 != NULL)
+ if (ce->hint2 != NULL)
{
- Segment *s2 = ce->priv->hint2;
+ Segment *s2 = ce->hint2;
gboolean child = FALSE;
while (s2 != NULL)
@@ -4417,7 +4415,7 @@ delete_zero_length_segments (GtkSourceContextEngine *ce,
}
if (child)
- ce->priv->hint2 = s->parent;
+ ce->hint2 = s->parent;
}
segment_remove (ce, s);
@@ -4440,8 +4438,8 @@ delete_zero_length_segments (GtkSourceContextEngine *ce,
*/
static Segment *
analyze_line (GtkSourceContextEngine *ce,
- Segment *state,
- LineInfo *line)
+ Segment *state,
+ LineInfo *line)
{
gint line_pos = 0;
GList *end_segments = NULL;
@@ -4449,9 +4447,9 @@ analyze_line (GtkSourceContextEngine *ce,
g_assert (SEGMENT_IS_CONTAINER (state));
- if (ce->priv->hint2 == NULL || ce->priv->hint2->parent != state)
- ce->priv->hint2 = state->last_child;
- g_assert (!ce->priv->hint2 || ce->priv->hint2->parent == state);
+ if (ce->hint2 == NULL || ce->hint2->parent != state)
+ ce->hint2 = state->last_child;
+ g_assert (!ce->hint2 || ce->hint2->parent == state);
timer = g_timer_new ();
@@ -4477,9 +4475,9 @@ analyze_line (GtkSourceContextEngine *ce,
state = new_state;
- if (ce->priv->hint2 == NULL || ce->priv->hint2->parent != state)
- ce->priv->hint2 = state->last_child;
- g_assert (!ce->priv->hint2 || ce->priv->hint2->parent == state);
+ if (ce->hint2 == NULL || ce->hint2->parent != state)
+ ce->hint2 = state->last_child;
+ g_assert (!ce->hint2 || ce->hint2->parent == state);
/* XXX this a temporary workaround for zero-length segments in the end
* of line. there are no zero-length segments in the middle because it goes
@@ -4491,7 +4489,7 @@ analyze_line (GtkSourceContextEngine *ce,
}
g_timer_destroy (timer);
- if (ce->priv->disabled)
+ if (ce->disabled)
return NULL;
/* Extend current state to the end of line. */
@@ -4534,9 +4532,9 @@ analyze_line (GtkSourceContextEngine *ce,
*/
static void
get_line_info (GtkTextBuffer *buffer,
- const GtkTextIter *line_start,
- const GtkTextIter *line_end,
- LineInfo *line)
+ const GtkTextIter *line_start,
+ const GtkTextIter *line_end,
+ LineInfo *line)
{
g_assert (!gtk_text_iter_equal (line_start, line_end));
@@ -4591,7 +4589,7 @@ line_info_destroy (LineInfo *line)
static void
segment_tree_zero_len (GtkSourceContextEngine *ce)
{
- Segment *root = ce->priv->root_segment;
+ Segment *root = ce->root_segment;
segment_destroy_children (ce, root);
root->start_at = root->end_at = 0;
CHECK_TREE (ce);
@@ -4600,7 +4598,7 @@ segment_tree_zero_len (GtkSourceContextEngine *ce)
#ifdef ENABLE_CHECK_TREE
static Segment *
get_segment_at_offset_slow_ (Segment *segment,
- gint offset)
+ gint offset)
{
Segment *child;
@@ -4670,7 +4668,7 @@ start:
#define SEGMENT_DISTANCE(s,o) (MIN (ABS ((s)->start_at - (o)), ABS ((s)->end_at - (o))))
static Segment *
get_segment_in_ (Segment *segment,
- gint offset)
+ gint offset)
{
Segment *child;
@@ -4732,7 +4730,7 @@ get_segment_in_ (Segment *segment,
/* assumes zero-length segments can't have children */
static Segment *
get_segment_ (Segment *segment,
- gint offset)
+ gint offset)
{
if (segment->parent != NULL)
{
@@ -4824,26 +4822,26 @@ get_segment_ (Segment *segment,
*/
static Segment *
get_segment_at_offset (GtkSourceContextEngine *ce,
- Segment *hint,
- gint offset)
+ Segment *hint,
+ gint offset)
{
Segment *result;
- if (offset == ce->priv->root_segment->end_at)
- return ce->priv->root_segment;
+ if (offset == ce->root_segment->end_at)
+ return ce->root_segment;
#ifdef ENABLE_DEBUG
/* if you see this message (often), then something is
* wrong with the hints business, i.e. optimizations
* do not work quite like they should */
- if (hint == NULL || hint == ce->priv->root_segment)
+ if (hint == NULL || hint == ce->root_segment)
{
static int c;
g_print ("searching from root %d\n", ++c);
}
#endif
- result = get_segment_ (hint ? hint : ce->priv->root_segment, offset);
+ result = get_segment_ (hint ? hint : ce->root_segment, offset);
#ifdef ENABLE_CHECK_TREE
g_assert (result == get_segment_at_offset_slow_ (hint, offset));
@@ -4864,7 +4862,7 @@ get_segment_at_offset (GtkSourceContextEngine *ce,
*/
static void
segment_remove (GtkSourceContextEngine *ce,
- Segment *segment)
+ Segment *segment)
{
if (segment->next != NULL)
segment->next->prev = segment->prev;
@@ -4876,28 +4874,28 @@ segment_remove (GtkSourceContextEngine *ce,
else
segment->parent->children = segment->next;
- /* if ce->priv->hint is being deleted, set it to some
+ /* if ce->hint is being deleted, set it to some
* neighbour segment */
- if (ce->priv->hint == segment)
+ if (ce->hint == segment)
{
if (segment->next != NULL)
- ce->priv->hint = segment->next;
+ ce->hint = segment->next;
else if (segment->prev != NULL)
- ce->priv->hint = segment->prev;
+ ce->hint = segment->prev;
else
- ce->priv->hint = segment->parent;
+ ce->hint = segment->parent;
}
- /* if ce->priv->hint2 is being deleted, set it to some
+ /* if ce->hint2 is being deleted, set it to some
* neighbour segment */
- if (ce->priv->hint2 == segment)
+ if (ce->hint2 == segment)
{
if (segment->next != NULL)
- ce->priv->hint2 = segment->next;
+ ce->hint2 = segment->next;
else if (segment->prev != NULL)
- ce->priv->hint2 = segment->prev;
+ ce->hint2 = segment->prev;
else
- ce->priv->hint2 = segment->parent;
+ ce->hint2 = segment->parent;
}
segment_destroy (ce, segment);
@@ -4905,9 +4903,9 @@ segment_remove (GtkSourceContextEngine *ce,
static void
segment_erase_middle_ (GtkSourceContextEngine *ce,
- Segment *segment,
- gint start,
- gint end)
+ Segment *segment,
+ gint start,
+ gint end)
{
Segment *new_segment, *child;
SubPattern *sp;
@@ -5015,9 +5013,9 @@ segment_erase_middle_ (GtkSourceContextEngine *ce,
*/
static void
segment_erase_range_ (GtkSourceContextEngine *ce,
- Segment *segment,
- gint start,
- gint end)
+ Segment *segment,
+ gint start,
+ gint end)
{
g_assert (start < end);
@@ -5131,8 +5129,8 @@ segment_erase_range_ (GtkSourceContextEngine *ce,
*/
static void
segment_merge (GtkSourceContextEngine *ce,
- Segment *first,
- Segment *second)
+ Segment *first,
+ Segment *second)
{
Segment *parent;
@@ -5215,26 +5213,26 @@ segment_merge (GtkSourceContextEngine *ce,
*
* Erases all non-toplevel segments in the interval
* [@start, @end]. Its action on the tree is roughly
- * equivalent to segment_erase_range_(ce->priv->root_segment, start, end)
+ * equivalent to segment_erase_range_(ce->root_segment, start, end)
* (but that does not accept toplevel segment).
*/
static void
erase_segments (GtkSourceContextEngine *ce,
- gint start,
- gint end,
- Segment *hint)
+ gint start,
+ gint end,
+ Segment *hint)
{
- Segment *root = ce->priv->root_segment;
+ Segment *root = ce->root_segment;
Segment *child, *hint_prev;
if (root->children == NULL)
return;
if (hint == NULL)
- hint = ce->priv->hint;
+ hint = ce->hint;
if (hint != NULL)
- while (hint != NULL && hint->parent != ce->priv->root_segment)
+ while (hint != NULL && hint->parent != ce->root_segment)
hint = hint->parent;
if (hint == NULL)
@@ -5252,14 +5250,14 @@ erase_segments (GtkSourceContextEngine *ce,
child = next;
if (next != NULL)
- ce->priv->hint = next;
+ ce->hint = next;
continue;
}
if (child->start_at > end)
{
- ce->priv->hint = child;
+ ce->hint = child;
break;
}
@@ -5272,8 +5270,8 @@ erase_segments (GtkSourceContextEngine *ce,
{
Segment *prev = child->prev;
- if (ce->priv->hint == NULL)
- ce->priv->hint = child;
+ if (ce->hint == NULL)
+ ce->hint = child;
if (child->start_at > end)
{
@@ -5313,8 +5311,8 @@ erase_segments (GtkSourceContextEngine *ce,
/* TODO it must be refactored. */
static void
update_syntax (GtkSourceContextEngine *ce,
- const GtkTextIter *end,
- gint time)
+ const GtkTextIter *end,
+ gint time)
{
GtkTextBuffer *buffer;
GtkTextIter start_iter, end_iter;
@@ -5327,10 +5325,10 @@ update_syntax (GtkSourceContextEngine *ce,
gboolean first_line = FALSE;
GTimer *timer;
- buffer = ce->priv->buffer;
- state = ce->priv->root_segment;
+ buffer = ce->buffer;
+ state = ce->root_segment;
- context_freeze (ce->priv->root_context);
+ context_freeze (ce->root_context);
update_tree (ce);
if (!gtk_text_buffer_get_char_count (buffer))
@@ -5395,7 +5393,7 @@ update_syntax (GtkSourceContextEngine *ce,
if (start_offset == end_offset)
{
g_assert (end_offset == gtk_text_buffer_get_char_count (buffer));
- g_assert (g_slist_length (ce->priv->invalid) == 1);
+ g_assert (g_slist_length (ce->invalid) == 1);
segment_remove (ce, invalid);
CHECK_TREE (ce);
goto out;
@@ -5427,7 +5425,7 @@ update_syntax (GtkSourceContextEngine *ce,
}
/* Analyze the line */
- erase_segments (ce, line_start_offset, line_end_offset, ce->priv->hint);
+ erase_segments (ce, line_start_offset, line_end_offset, ce->hint);
get_line_info (buffer, &line_start, &line_end, &line);
#ifdef ENABLE_CHECK_TREE
@@ -5439,26 +5437,26 @@ update_syntax (GtkSourceContextEngine *ce,
if (first_line)
{
- state = ce->priv->root_segment;
+ state = ce->root_segment;
}
else
{
state = get_segment_at_offset (ce,
- ce->priv->hint ? ce->priv->hint : state,
+ ce->hint ? ce->hint : state,
line_start_offset - 1);
}
g_assert (state->context != NULL);
- ce->priv->hint2 = ce->priv->hint;
+ ce->hint2 = ce->hint;
- if (ce->priv->hint2 != NULL && ce->priv->hint2->parent != state)
- ce->priv->hint2 = NULL;
+ if (ce->hint2 != NULL && ce->hint2->parent != state)
+ ce->hint2 = NULL;
state = analyze_line (ce, state, &line);
/* At this point analyze_line() could have disabled highlighting */
- if (ce->priv->disabled)
+ if (ce->disabled)
return;
#ifdef ENABLE_CHECK_TREE
@@ -5471,14 +5469,14 @@ update_syntax (GtkSourceContextEngine *ce,
/* XXX this is wrong */
/* I don't know anymore why it's wrong, I guess it means
* "may be inefficient" */
- if (ce->priv->hint2 != NULL)
- ce->priv->hint = ce->priv->hint2;
+ if (ce->hint2 != NULL)
+ ce->hint = ce->hint2;
else
- ce->priv->hint = state;
+ ce->hint = state;
line_info_destroy (&line);
- gtk_source_region_add_subregion (ce->priv->refresh_region, &line_start, &line_end);
+ gtk_source_region_add_subregion (ce->refresh_region, &line_start, &line_end);
analyzed_end = line_end_offset;
invalid = get_invalid_segment (ce);
@@ -5497,7 +5495,7 @@ update_syntax (GtkSourceContextEngine *ce,
{
Segment *old_state, *hint;
- hint = ce->priv->hint ? ce->priv->hint : state;
+ hint = ce->hint ? ce->hint : state;
old_state = get_segment_at_offset (ce, hint, line_end_offset);
/* We can merge old and new stuff if: contexts are the same,
@@ -5547,9 +5545,9 @@ update_syntax (GtkSourceContextEngine *ce,
if (analyzed_end == gtk_text_buffer_get_char_count (buffer))
{
- g_assert (g_slist_length (ce->priv->invalid) <= 1);
+ g_assert (g_slist_length (ce->invalid) <= 1);
- if (ce->priv->invalid != NULL)
+ if (ce->invalid != NULL)
{
invalid = get_invalid_segment (ce);
segment_remove (ce, invalid);
@@ -5572,7 +5570,7 @@ update_syntax (GtkSourceContextEngine *ce,
out:
/* must call context_thaw, so this is the only return point */
- context_thaw (ce->priv->root_context);
+ context_thaw (ce->root_context);
}
@@ -5580,11 +5578,11 @@ out:
static DefinitionChild *
definition_child_new (ContextDefinition *definition,
- const gchar *child_id,
- const gchar *style,
- gboolean override_style,
- gboolean is_ref_all,
- gboolean original_ref)
+ const gchar *child_id,
+ const gchar *style,
+ gboolean override_style,
+ gboolean is_ref_all,
+ gboolean original_ref)
{
DefinitionChild *ch;
@@ -5638,14 +5636,14 @@ copy_context_classes (GSList *context_classes)
static ContextDefinition *
context_definition_new (const gchar *id,
- ContextType type,
- const gchar *match,
- const gchar *start,
- const gchar *end,
- const gchar *style,
- GSList *context_classes,
- GtkSourceContextFlags flags,
- GError **error)
+ ContextType type,
+ const gchar *match,
+ const gchar *start,
+ const gchar *end,
+ const gchar *style,
+ GSList *context_classes,
+ GtkSourceContextFlags flags,
+ GError **error)
{
ContextDefinition *definition;
gboolean regex_error = FALSE;
@@ -5802,7 +5800,7 @@ context_definition_unref (ContextDefinition *definition)
static void
definition_iter_init (DefinitionsIter *iter,
- ContextDefinition *definition)
+ ContextDefinition *definition)
{
iter->children_stack = g_slist_prepend (NULL, definition->children);
}
@@ -5853,15 +5851,15 @@ definition_iter_next (DefinitionsIter *iter)
gboolean
_gtk_source_context_data_define_context (GtkSourceContextData *ctx_data,
- const gchar *id,
- const gchar *parent_id,
- const gchar *match_regex,
- const gchar *start_regex,
- const gchar *end_regex,
- const gchar *style,
- GSList *context_classes,
- GtkSourceContextFlags flags,
- GError **error)
+ const gchar *id,
+ const gchar *parent_id,
+ const gchar *match_regex,
+ const gchar *start_regex,
+ const gchar *end_regex,
+ const gchar *style,
+ GSList *context_classes,
+ GtkSourceContextFlags flags,
+ GError **error)
{
ContextDefinition *definition, *parent = NULL;
ContextType type;
@@ -5943,13 +5941,13 @@ _gtk_source_context_data_define_context (GtkSourceContextData *ctx_data,
gboolean
_gtk_source_context_data_add_sub_pattern (GtkSourceContextData *ctx_data,
- const gchar *id,
- const gchar *parent_id,
- const gchar *name,
- const gchar *where,
- const gchar *style,
- GSList *context_classes,
- GError **error)
+ const gchar *id,
+ const gchar *parent_id,
+ const gchar *name,
+ const gchar *where,
+ const gchar *style,
+ GSList *context_classes,
+ GError **error)
{
ContextDefinition *parent;
SubPatternDefinition *sp_def;
@@ -6046,12 +6044,12 @@ context_is_pure_container (ContextDefinition *def)
gboolean
_gtk_source_context_data_add_ref (GtkSourceContextData *ctx_data,
- const gchar *parent_id,
- const gchar *ref_id,
- GtkSourceContextRefOptions options,
- const gchar *style,
- gboolean all,
- GError **error)
+ const gchar *parent_id,
+ const gchar *ref_id,
+ GtkSourceContextRefOptions options,
+ const gchar *style,
+ gboolean all,
+ GError **error)
{
ContextDefinition *parent;
ContextDefinition *ref;
@@ -6111,8 +6109,8 @@ struct ResolveRefData {
static void
resolve_reference (G_GNUC_UNUSED const gchar *id,
- ContextDefinition *definition,
- gpointer user_data)
+ ContextDefinition *definition,
+ gpointer user_data)
{
GSList *l;
@@ -6164,9 +6162,9 @@ resolve_reference (G_GNUC_UNUSED const gchar *id,
static gboolean
process_replace (GtkSourceContextData *ctx_data,
- const gchar *id,
- const gchar *replace_with,
- GError **error)
+ const gchar *id,
+ const gchar *replace_with,
+ GError **error)
{
ContextDefinition *to_replace, *new;
@@ -6196,8 +6194,8 @@ process_replace (GtkSourceContextData *ctx_data,
}
GtkSourceContextReplace *
-_gtk_source_context_replace_new (const gchar *to_replace_id,
- const gchar *replace_with_id)
+_gtk_source_context_replace_new (const gchar *to_replace_id,
+ const gchar *replace_with_id)
{
GtkSourceContextReplace *repl;
@@ -6242,8 +6240,8 @@ _gtk_source_context_replace_free (GtkSourceContextReplace *repl)
*/
gboolean
_gtk_source_context_data_finish_parse (GtkSourceContextData *ctx_data,
- GList *overrides,
- GError **error)
+ GList *overrides,
+ GError **error)
{
struct ResolveRefData data;
gchar *root_id;
@@ -6297,7 +6295,7 @@ _gtk_source_context_data_finish_parse (GtkSourceContextData *ctx_data,
static void
add_escape_ref (ContextDefinition *definition,
- GtkSourceContextData *ctx_data)
+ GtkSourceContextData *ctx_data)
{
GError *error = NULL;
@@ -6325,8 +6323,8 @@ out:
static void
prepend_definition (G_GNUC_UNUSED gchar *id,
- ContextDefinition *definition,
- GSList **list)
+ ContextDefinition *definition,
+ GSList **list)
{
*list = g_slist_prepend (*list, definition);
}
@@ -6340,7 +6338,7 @@ prepend_definition (G_GNUC_UNUSED gchar *id,
next line. */
void
_gtk_source_context_data_set_escape_char (GtkSourceContextData *ctx_data,
- gunichar escape_char)
+ gunichar escape_char)
{
GError *error = NULL;
char buf[10];
@@ -6395,7 +6393,7 @@ out:
#ifdef ENABLE_CHECK_TREE
static void
check_segment (GtkSourceContextEngine *ce,
- Segment *segment)
+ Segment *segment)
{
Segment *child;
@@ -6404,9 +6402,9 @@ check_segment (GtkSourceContextEngine *ce,
g_assert (!segment->next || segment->next->start_at >= segment->end_at);
if (SEGMENT_IS_INVALID (segment))
- g_assert (g_slist_find (ce->priv->invalid, segment) != NULL);
+ g_assert (g_slist_find (ce->invalid, segment) != NULL);
else
- g_assert (g_slist_find (ce->priv->invalid, segment) == NULL);
+ g_assert (g_slist_find (ce->invalid, segment) == NULL);
if (segment->children != NULL)
g_assert (!SEGMENT_IS_INVALID (segment) && SEGMENT_IS_CONTAINER (segment));
@@ -6429,8 +6427,8 @@ struct CheckContextData {
static void
check_context_hash_cb (const char *text,
- Context *context,
- gpointer user_data)
+ Context *context,
+ gpointer user_data)
{
struct CheckContextData *data = user_data;
@@ -6468,21 +6466,21 @@ check_context (Context *context)
static void
check_tree (GtkSourceContextEngine *ce)
{
- Segment *root = ce->priv->root_segment;
+ Segment *root = ce->root_segment;
check_regex ();
g_assert (root->start_at == 0);
- if (ce->priv->invalid_region.empty)
- g_assert (root->end_at == gtk_text_buffer_get_char_count (ce->priv->buffer));
+ if (ce->invalid_region.empty)
+ g_assert (root->end_at == gtk_text_buffer_get_char_count (ce->buffer));
g_assert (!root->parent);
check_segment (ce, root);
- g_assert (!ce->priv->root_context->parent);
- g_assert (root->context == ce->priv->root_context);
- check_context (ce->priv->root_context);
+ g_assert (!ce->root_context->parent);
+ g_assert (root->context == ce->root_context);
+ check_context (ce->root_context);
}
static void
diff --git a/gtksourceview/gtksourcelanguage-parser-2.c b/gtksourceview/gtksourcelanguage-parser-2.c
index c0933435..b9ee0e5d 100644
--- a/gtksourceview/gtksourcelanguage-parser-2.c
+++ b/gtksourceview/gtksourcelanguage-parser-2.c
@@ -33,7 +33,7 @@
#include "gtksourcebuffer.h"
#include "gtksourcelanguage.h"
#include "gtksourcelanguage-private.h"
-#include "gtksourcecontextengine.h"
+#include "gtksourcecontextengine-private.h"
#include <glib.h>
#include <glib/gstdio.h>
diff --git a/gtksourceview/gtksourcelanguage-private.h b/gtksourceview/gtksourcelanguage-private.h
index c35efb35..73e952dd 100644
--- a/gtksourceview/gtksourcelanguage-private.h
+++ b/gtksourceview/gtksourcelanguage-private.h
@@ -22,7 +22,7 @@
#include <glib.h>
-#include "gtksourcecontextengine.h"
+#include "gtksourcecontextengine-private.h"
#include "gtksourcelanguagemanager.h"
G_BEGIN_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]