Synced with upstream
2006-08-27 Yevgen Muntyan <muntyan@tamu.edu> * gtksourceview/language-specs/automake.lang, gtksourceview/language-specs/check.sh, gtksourceview/language-specs/Makefile.am: new lang file for Makefile.am. * gtksourceview/language-specs/c.lang: override style for line-continue in macros; use def:string context. * gtksourceview/language-specs/def.lang: renamed 'c-style-escape' to 'escape', it's not really 'C style'; added 'escape' style to 'line-continue' context; added 'string' and 'single-quoted-string' contexts. * gtksourceview/language-specs/javascript.lang: replaced def:c-style-escape with def:escape. * gtksourceview/language-specs/language2.rng: added optional style-ref and ignore-style attributes to <context ref=""> tags. * gtksourceview/gtksourcecontextengine.[ch], gtksourceview/gtksourcelanguage-parser-2.c: made it possible to override style from referenced context: <context ref="some-context" style-ref="some-style"> means "use context some-context with style some-style", and ignore-style attribute means "use no style in this context". 2006-08-27 Yevgen Muntyan <muntyan@tamu.edu> * gtksourceview/language-specs/Makefile.am: install style scheme into $prefix/gtksourceview-2.0/styles dir. * gtksourceview/gtksourcecontextengine.c: fixed subpatterns handling (subpatterns tags were applied randomly); made high-priority one-time idle called more often, which hopefully make it look nicer; (gtk_source_context_engine_update_highlight): highlight as much as possible even if some part of requested area is not analyzed yet. * gtksourceview/gtksourcelanguage-parser-2.c: fixed two leaks. * gtksourceview/gtksourcelanguagesmanager.c, gtksourceview/gtksourcestylescheme.h, gtksourceview/gtksourceview.c: _gtk_source_style_scheme_get_default() - temporary workaround for no-builtin-scheme thing.
This commit is contained in:
parent
c7e5afb416
commit
b5825f26a1
@ -293,16 +293,16 @@
|
||||
</kdevdoctreeview>
|
||||
<kdevfilecreate>
|
||||
<filetypes>
|
||||
<type icon="source" ext="g" create="template" name="GAP source" >
|
||||
<type icon="source" ext="g" name="GAP source" create="template" >
|
||||
<descr>A new empty GAP source file</descr>
|
||||
</type>
|
||||
<type icon="source_cpp" ext="cpp" create="template" name="C++ Source" >
|
||||
<type icon="source_cpp" ext="cpp" name="C++ Source" create="template" >
|
||||
<descr>A new empty C++ file.</descr>
|
||||
</type>
|
||||
<type icon="source_h" ext="h" create="template" name="C/C++ Header" >
|
||||
<type icon="source_h" ext="h" name="C/C++ Header" create="template" >
|
||||
<descr>A new empty header file for C/C++.</descr>
|
||||
</type>
|
||||
<type icon="source_c" ext="c" create="template" name="C Source" >
|
||||
<type icon="source_c" ext="c" name="C Source" create="template" >
|
||||
<descr>A new empty C file.</descr>
|
||||
</type>
|
||||
</filetypes>
|
||||
|
@ -56,8 +56,11 @@
|
||||
/* Regex used to match "\%{...@start}". */
|
||||
#define START_REF_REGEX "(?<!\\\\)(\\\\\\\\)*\\\\%\\{(.*?)@start\\}"
|
||||
|
||||
#define FIRST_UPDATE_PRIORITY G_PRIORITY_HIGH_IDLE
|
||||
#define INCREMENTAL_UPDATE_PRIORITY GTK_TEXT_VIEW_PRIORITY_VALIDATE
|
||||
/* In milliseconds. */
|
||||
#define WORKER_TIME_SLICE 30
|
||||
#define FIRST_UPDATE_TIME_SLICE 10
|
||||
#define INCREMENTAL_UPDATE_TIME_SLICE 30
|
||||
|
||||
#define GTK_SOURCE_CONTEXT_ENGINE_ERROR (gtk_source_context_engine_error_quark ())
|
||||
|
||||
@ -96,7 +99,8 @@ typedef enum {
|
||||
GTK_SOURCE_CONTEXT_ENGINE_ERROR_INVALID_REF,
|
||||
GTK_SOURCE_CONTEXT_ENGINE_ERROR_INVALID_WHERE,
|
||||
GTK_SOURCE_CONTEXT_ENGINE_ERROR_INVALID_START_REF,
|
||||
GTK_SOURCE_CONTEXT_ENGINE_ERROR_INVALID_REGEX
|
||||
GTK_SOURCE_CONTEXT_ENGINE_ERROR_INVALID_REGEX,
|
||||
GTK_SOURCE_CONTEXT_ENGINE_ERROR_INVALID_STYLE
|
||||
} GtkSourceContextEngineError;
|
||||
|
||||
typedef enum {
|
||||
@ -149,6 +153,7 @@ struct _ContextDefinition
|
||||
|
||||
/* Sub patterns (list of SubPatternDefinition pointers.) */
|
||||
GSList *sub_patterns;
|
||||
guint n_sub_patterns;
|
||||
|
||||
/* Union of every regular expression we can find from this
|
||||
* context. */
|
||||
@ -174,6 +179,9 @@ struct _SubPatternDefinition
|
||||
gchar *style;
|
||||
SubPatternWhere where;
|
||||
|
||||
/* index in the ContextDefinition's list */
|
||||
guint index;
|
||||
|
||||
union
|
||||
{
|
||||
gint num;
|
||||
@ -211,7 +219,7 @@ struct _Context
|
||||
Regex *reg_all;
|
||||
|
||||
GtkTextTag *tag;
|
||||
GSList *subpattern_tags;
|
||||
GtkTextTag **subpattern_tags;
|
||||
|
||||
guint ref_count;
|
||||
guint frozen : 1;
|
||||
@ -284,8 +292,6 @@ struct _LineInfo
|
||||
/* Character length of line terminator, or 0 if it's the
|
||||
* last line in buffer. */
|
||||
gint eol_length;
|
||||
/* Line number in the buffer */
|
||||
gint line_no;
|
||||
};
|
||||
|
||||
struct _InvalidRegion
|
||||
@ -326,7 +332,8 @@ struct _GtkSourceContextEnginePrivate
|
||||
GSList *invalid;
|
||||
InvalidRegion invalid_region;
|
||||
|
||||
guint worker_handler;
|
||||
guint first_update;
|
||||
guint incremental_update;
|
||||
|
||||
/* Views highlight requests. */
|
||||
GtkTextRegion *highlight_requests;
|
||||
@ -391,6 +398,7 @@ 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);
|
||||
|
||||
|
||||
/* MODIFICATIONS AND STUFF ------------------------------------------------ */
|
||||
@ -425,6 +433,9 @@ unhighlight_region (GtkSourceContextEngine *ce,
|
||||
const GtkTextIter *start, *end;
|
||||
} data = {ce->priv->buffer, start, end};
|
||||
|
||||
if (gtk_text_iter_equal (start, end))
|
||||
return;
|
||||
|
||||
g_hash_table_foreach (ce->priv->tags, (GHFunc) unhighlight_region_cb, &data);
|
||||
}
|
||||
|
||||
@ -574,39 +585,21 @@ get_tag_for_parent (GtkSourceContextEngine *ce,
|
||||
static GtkTextTag *
|
||||
get_subpattern_tag (GtkSourceContextEngine *ce,
|
||||
Context *context,
|
||||
SubPatternDefinition *sp_def,
|
||||
guint index)
|
||||
SubPatternDefinition *sp_def)
|
||||
{
|
||||
GtkTextTag *tag;
|
||||
|
||||
if (!sp_def->style)
|
||||
return NULL;
|
||||
|
||||
if (context->subpattern_tags &&
|
||||
(tag = g_slist_nth_data (context->subpattern_tags, index)))
|
||||
{
|
||||
return tag;
|
||||
}
|
||||
|
||||
tag = get_tag_for_parent (ce, sp_def->style, context);
|
||||
g_return_val_if_fail (tag != NULL, NULL);
|
||||
g_assert (sp_def->index < context->definition->n_sub_patterns);
|
||||
|
||||
if (!context->subpattern_tags)
|
||||
{
|
||||
guint i, n;
|
||||
n = g_slist_length (context->definition->sub_patterns);
|
||||
for (i = 0; i < n; ++i)
|
||||
context->subpattern_tags =
|
||||
g_slist_prepend (context->subpattern_tags,
|
||||
i == n - index - 1 ? tag : NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
GSList *link = g_slist_nth (context->subpattern_tags, index);
|
||||
link->data = tag;
|
||||
}
|
||||
context->subpattern_tags = g_new0 (GtkTextTag*, context->definition->n_sub_patterns);
|
||||
|
||||
return tag;
|
||||
if (!context->subpattern_tags[sp_def->index])
|
||||
context->subpattern_tags[sp_def->index] = get_tag_for_parent (ce, sp_def->style, context);
|
||||
|
||||
g_return_val_if_fail (context->subpattern_tags[sp_def->index] != NULL, NULL);
|
||||
return context->subpattern_tags[sp_def->index];
|
||||
}
|
||||
|
||||
static GtkTextTag *
|
||||
@ -656,12 +649,16 @@ apply_tags (GtkSourceContextEngine *ce,
|
||||
{
|
||||
if (sp->start_at >= start_offset && sp->end_at <= end_offset)
|
||||
{
|
||||
tag = get_subpattern_tag (ce, segment->context, sp->definition, i);
|
||||
gtk_text_buffer_get_iter_at_offset (ce->priv->buffer, &start_iter,
|
||||
MAX (start_offset, sp->start_at));
|
||||
gtk_text_buffer_get_iter_at_offset (ce->priv->buffer, &end_iter,
|
||||
MIN (end_offset, sp->end_at));
|
||||
gtk_text_buffer_apply_tag (ce->priv->buffer, tag, &start_iter, &end_iter);
|
||||
tag = get_subpattern_tag (ce, segment->context, sp->definition);
|
||||
|
||||
if (tag)
|
||||
{
|
||||
gtk_text_buffer_get_iter_at_offset (ce->priv->buffer, &start_iter,
|
||||
MAX (start_offset, sp->start_at));
|
||||
gtk_text_buffer_get_iter_at_offset (ce->priv->buffer, &end_iter,
|
||||
MIN (end_offset, sp->end_at));
|
||||
gtk_text_buffer_apply_tag (ce->priv->buffer, tag, &start_iter, &end_iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -786,7 +783,8 @@ refresh_range (GtkSourceContextEngine *ce,
|
||||
{
|
||||
GtkTextIter real_end;
|
||||
|
||||
g_return_if_fail (!gtk_text_iter_equal (start, end));
|
||||
if (gtk_text_iter_equal (start, end))
|
||||
return;
|
||||
|
||||
if (modify_refresh_region)
|
||||
gtk_text_region_add (ce->priv->refresh_region, start, end);
|
||||
@ -1228,7 +1226,7 @@ invalidate_region (GtkSourceContextEngine *ce,
|
||||
|
||||
CHECK_TREE (ce);
|
||||
|
||||
install_idle_worker (ce);
|
||||
install_first_update (ce);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -1596,10 +1594,10 @@ update_tree (GtkSourceContextEngine *ce)
|
||||
start iter of the line it doesn't care about (and vice versa
|
||||
in update_syntax) */
|
||||
static void
|
||||
gtk_source_context_engine_update_highlight (GtkSourceEngine *engine,
|
||||
const GtkTextIter *start,
|
||||
const GtkTextIter *end,
|
||||
gboolean synchronous)
|
||||
gtk_source_context_engine_update_highlight (GtkSourceEngine *engine,
|
||||
const GtkTextIter *start,
|
||||
const GtkTextIter *end,
|
||||
gboolean synchronous)
|
||||
{
|
||||
gint invalid_line;
|
||||
gint end_line;
|
||||
@ -1626,8 +1624,19 @@ gtk_source_context_engine_update_highlight (GtkSourceEngine *engine,
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_text_region_add (ce->priv->highlight_requests, start, end);
|
||||
install_idle_worker (ce);
|
||||
if (gtk_text_iter_get_line (start) >= invalid_line)
|
||||
{
|
||||
gtk_text_region_add (ce->priv->highlight_requests, start, end);
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkTextIter valid_end = *start;
|
||||
gtk_text_iter_set_line (&valid_end, invalid_line);
|
||||
ensure_highlighted (ce, start, &valid_end);
|
||||
gtk_text_region_add (ce->priv->highlight_requests, &valid_end, end);
|
||||
}
|
||||
|
||||
install_first_update (ce);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1681,28 +1690,35 @@ idle_worker (GtkSourceContextEngine *ce)
|
||||
g_return_val_if_fail (ce->priv->buffer != NULL, FALSE);
|
||||
|
||||
/* analyze batch of text */
|
||||
update_syntax (ce, NULL, WORKER_TIME_SLICE);
|
||||
update_syntax (ce, NULL, INCREMENTAL_UPDATE_TIME_SLICE);
|
||||
CHECK_TREE (ce);
|
||||
|
||||
// /* XXX */
|
||||
// if (ce->priv->highlight)
|
||||
// {
|
||||
// GtkTextIter start, end;
|
||||
// gtk_text_region_subtract_region (ce->priv->highlight_requests,
|
||||
// ce->priv->refresh_region);
|
||||
// gtk_text_buffer_get_bounds (ce->priv->buffer, &start, &end);
|
||||
// ensure_highlighted (ce, &start, &end);
|
||||
// }
|
||||
|
||||
if (all_analyzed (ce))
|
||||
{
|
||||
ce->priv->worker_handler = 0;
|
||||
ce->priv->incremental_update = 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
first_update_callback (GtkSourceContextEngine *ce)
|
||||
{
|
||||
g_return_val_if_fail (ce->priv->buffer != NULL, FALSE);
|
||||
|
||||
/* analyze batch of text */
|
||||
update_syntax (ce, NULL, FIRST_UPDATE_TIME_SLICE);
|
||||
CHECK_TREE (ce);
|
||||
|
||||
ce->priv->first_update = 0;
|
||||
|
||||
if (!all_analyzed (ce))
|
||||
install_idle_worker (ce);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* install_idle_worker:
|
||||
*
|
||||
@ -1714,17 +1730,29 @@ idle_worker (GtkSourceContextEngine *ce)
|
||||
static void
|
||||
install_idle_worker (GtkSourceContextEngine *ce)
|
||||
{
|
||||
if (!ce->priv->worker_handler)
|
||||
{
|
||||
/* Use the text view validation priority to get
|
||||
* highlighted text even before complete validation of
|
||||
* the buffer. */
|
||||
ce->priv->worker_handler =
|
||||
g_idle_add_full (GTK_TEXT_VIEW_PRIORITY_VALIDATE,
|
||||
if (!ce->priv->first_update && !ce->priv->incremental_update)
|
||||
ce->priv->incremental_update =
|
||||
g_idle_add_full (INCREMENTAL_UPDATE_PRIORITY,
|
||||
(GSourceFunc) idle_worker, ce, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
install_first_update (GtkSourceContextEngine *ce)
|
||||
{
|
||||
if (!ce->priv->first_update)
|
||||
{
|
||||
if (ce->priv->incremental_update)
|
||||
{
|
||||
g_source_remove (ce->priv->incremental_update);
|
||||
ce->priv->incremental_update = 0;
|
||||
}
|
||||
|
||||
ce->priv->first_update =
|
||||
g_idle_add_full (FIRST_UPDATE_PRIORITY,
|
||||
(GSourceFunc) first_update_callback,
|
||||
ce, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* GtkSourceContextEngine class ------------------------------------------- */
|
||||
|
||||
@ -1792,11 +1820,12 @@ gtk_source_context_engine_attach_buffer (GtkSourceEngine *engine,
|
||||
(gpointer) buffer_notify_highlight_cb,
|
||||
ce);
|
||||
|
||||
if (ce->priv->worker_handler)
|
||||
{
|
||||
g_source_remove (ce->priv->worker_handler);
|
||||
ce->priv->worker_handler = 0;
|
||||
}
|
||||
if (ce->priv->first_update)
|
||||
g_source_remove (ce->priv->first_update);
|
||||
if (ce->priv->incremental_update)
|
||||
g_source_remove (ce->priv->incremental_update);
|
||||
ce->priv->first_update = 0;
|
||||
ce->priv->incremental_update = 0;
|
||||
|
||||
segment_destroy (ce, ce->priv->root_segment);
|
||||
context_unref (ce->priv->root_context);
|
||||
@ -1866,7 +1895,7 @@ gtk_source_context_engine_attach_buffer (GtkSourceEngine *engine,
|
||||
g_signal_connect_swapped (buffer, "notify::highlight",
|
||||
G_CALLBACK (buffer_notify_highlight_cb), ce);
|
||||
|
||||
install_idle_worker (ce);
|
||||
install_first_update (ce);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1919,7 +1948,8 @@ gtk_source_context_engine_finalize (GObject *object)
|
||||
g_assert (!ce->priv->tags);
|
||||
g_assert (!ce->priv->root_context);
|
||||
g_assert (!ce->priv->root_segment);
|
||||
g_assert (!ce->priv->worker_handler);
|
||||
g_assert (!ce->priv->first_update);
|
||||
g_assert (!ce->priv->incremental_update);
|
||||
|
||||
g_hash_table_destroy (ce->priv->definitions);
|
||||
g_free (ce->priv->id);
|
||||
@ -2091,9 +2121,7 @@ sub_pattern_to_int (const gchar *name)
|
||||
errno = 0;
|
||||
number = g_ascii_strtoull (name, &end_name, 10);
|
||||
|
||||
if (errno || number > G_MAXINT || *end_name)
|
||||
return -1;
|
||||
|
||||
g_return_val_if_fail (!errno && number < G_MAXINT && !*end_name, -1);
|
||||
return number;
|
||||
}
|
||||
|
||||
@ -2719,7 +2747,7 @@ context_unref (Context *context)
|
||||
|
||||
regex_unref (context->end);
|
||||
regex_unref (context->reg_all);
|
||||
g_slist_free (context->subpattern_tags); /* XXX */
|
||||
g_free (context->subpattern_tags);
|
||||
g_free (context);
|
||||
}
|
||||
|
||||
@ -3417,7 +3445,7 @@ next_segment (GtkSourceContextEngine *ce,
|
||||
if (!child_def->extend_parent && context_end_found)
|
||||
try_this = FALSE;
|
||||
|
||||
if (child_def->first_line_only && line->line_no == 0)
|
||||
if (child_def->first_line_only && line->start_at != 0)
|
||||
try_this = FALSE;
|
||||
|
||||
if (try_this)
|
||||
@ -3600,7 +3628,6 @@ get_line_info (GtkTextBuffer *buffer,
|
||||
|
||||
line->text = gtk_text_buffer_get_slice (buffer, line_start, line_end, TRUE);
|
||||
line->start_at = gtk_text_iter_get_offset (line_start);
|
||||
line->line_no = gtk_text_iter_get_line (line_start);
|
||||
|
||||
if (!gtk_text_iter_starts_line (line_end))
|
||||
{
|
||||
@ -4569,6 +4596,27 @@ out:
|
||||
|
||||
/* DEFINITIONS MANAGEMENT ------------------------------------------------- */
|
||||
|
||||
static DefinitionChild *
|
||||
definition_child_new (ContextDefinition *definition,
|
||||
ContextDefinition *child_def,
|
||||
gboolean is_ref_all)
|
||||
{
|
||||
DefinitionChild *ch = g_new0 (DefinitionChild, 1);
|
||||
|
||||
ch->is_ref_all = is_ref_all;
|
||||
ch->definition = child_def;
|
||||
|
||||
definition->children = g_slist_append (definition->children, ch);
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
static void
|
||||
definition_child_free (DefinitionChild *ch)
|
||||
{
|
||||
g_free (ch);
|
||||
}
|
||||
|
||||
static ContextDefinition *
|
||||
context_definition_new (const gchar *id,
|
||||
ContextType type,
|
||||
@ -4664,10 +4712,11 @@ context_definition_new (const gchar *id,
|
||||
definition->first_line_only = (options & GTK_SOURCE_CONTEXT_FIRST_LINE_ONLY) != 0;
|
||||
definition->children = NULL;
|
||||
definition->sub_patterns = NULL;
|
||||
definition->n_sub_patterns = 0;
|
||||
|
||||
/* Main contexts (i.e. the contexts with id "language:language")
|
||||
* should have extend-parent="true" and end-at-line-end="false". */
|
||||
if (!parent && egg_regex_match_simple ("(.+):\\1", id, 0, 0))
|
||||
if (!parent && egg_regex_match_simple ("^(.+):\\1$", id, 0, 0))
|
||||
{
|
||||
if (definition->end_at_line_end)
|
||||
{
|
||||
@ -4689,6 +4738,80 @@ context_definition_new (const gchar *id,
|
||||
return definition;
|
||||
}
|
||||
|
||||
static GtkSourceContextMatchOptions
|
||||
context_definition_get_options (ContextDefinition *definition)
|
||||
{
|
||||
GtkSourceContextMatchOptions options = 0;
|
||||
|
||||
if (definition->extend_parent)
|
||||
options |= GTK_SOURCE_CONTEXT_EXTEND_PARENT;
|
||||
if (definition->end_at_line_end)
|
||||
options |= GTK_SOURCE_CONTEXT_END_AT_LINE_END;
|
||||
if (definition->first_line_only)
|
||||
options |= GTK_SOURCE_CONTEXT_FIRST_LINE_ONLY;
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
static ContextDefinition *
|
||||
context_definition_copy (GtkSourceContextEngine *ce,
|
||||
ContextDefinition *definition,
|
||||
ContextDefinition *parent,
|
||||
const char *style,
|
||||
GError **error)
|
||||
{
|
||||
ContextDefinition *copy;
|
||||
gchar *id;
|
||||
GtkSourceContextMatchOptions options;
|
||||
const gchar *match = NULL;
|
||||
const gchar *start = NULL, *end = NULL;
|
||||
|
||||
switch (definition->type)
|
||||
{
|
||||
case CONTEXT_TYPE_SIMPLE:
|
||||
match = regex_get_pattern (definition->u.match);
|
||||
break;
|
||||
case CONTEXT_TYPE_CONTAINER:
|
||||
if (definition->u.start_end.start)
|
||||
start = regex_get_pattern (definition->u.start_end.start);
|
||||
if (definition->u.start_end.end)
|
||||
end = regex_get_pattern (definition->u.start_end.end);
|
||||
break;
|
||||
default:
|
||||
g_return_val_if_reached (NULL);
|
||||
}
|
||||
|
||||
DEBUG ({
|
||||
g_print ("match: %s\n", match ? match : "(null)");
|
||||
g_print ("start: %s\n", start ? start : "(null)");
|
||||
g_print ("end: %s\n", end ? end : "(null)");
|
||||
});
|
||||
|
||||
id = g_strdup_printf ("%s@%s@%s", ce->priv->id, parent->id, definition->id);
|
||||
|
||||
if (g_hash_table_lookup (ce->priv->definitions, id) != NULL)
|
||||
{
|
||||
guint i = 1;
|
||||
while (TRUE)
|
||||
{
|
||||
g_free (id);
|
||||
id = g_strdup_printf ("%s@%s@%s@%d", ce->priv->id, parent->id, definition->id, i);
|
||||
if (g_hash_table_lookup (ce->priv->definitions, id) == NULL)
|
||||
break;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
options = context_definition_get_options (definition);
|
||||
|
||||
copy = context_definition_new (id, definition->type, parent,
|
||||
match, start, end,
|
||||
style, options, error);
|
||||
|
||||
g_free (id);
|
||||
return copy;
|
||||
}
|
||||
|
||||
static void
|
||||
context_definition_free (ContextDefinition *definition)
|
||||
{
|
||||
@ -4727,7 +4850,7 @@ context_definition_free (ContextDefinition *definition)
|
||||
g_free (definition->style);
|
||||
regex_unref (definition->reg_all);
|
||||
|
||||
g_slist_foreach (definition->children, (GFunc) g_free, NULL);
|
||||
g_slist_foreach (definition->children, (GFunc) definition_child_free, NULL);
|
||||
g_slist_free (definition->children);
|
||||
g_free (definition);
|
||||
}
|
||||
@ -4779,18 +4902,6 @@ definition_iter_next (DefinitionsIter *iter)
|
||||
}
|
||||
}
|
||||
|
||||
static DefinitionChild *
|
||||
definition_child_new (ContextDefinition *definition,
|
||||
ContextDefinition *child_def,
|
||||
gboolean is_ref_all)
|
||||
{
|
||||
DefinitionChild *ch = g_new0 (DefinitionChild, 1);
|
||||
ch->is_ref_all = is_ref_all;
|
||||
ch->definition = child_def;
|
||||
definition->children = g_slist_append (definition->children, ch);
|
||||
return ch;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_source_context_engine_define_context (GtkSourceContextEngine *ce,
|
||||
const gchar *id,
|
||||
@ -4952,17 +5063,20 @@ _gtk_source_context_engine_add_sub_pattern (GtkSourceContextEngine *ce,
|
||||
sp_def->u.num = number;
|
||||
}
|
||||
|
||||
parent->sub_patterns = g_slist_prepend (parent->sub_patterns, sp_def);
|
||||
parent->sub_patterns = g_slist_append (parent->sub_patterns, sp_def);
|
||||
sp_def->index = parent->n_sub_patterns++;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gtk_source_context_engine_add_ref (GtkSourceContextEngine *ce,
|
||||
const gchar *parent_id,
|
||||
const gchar *ref_id,
|
||||
gboolean all,
|
||||
GError **error)
|
||||
_gtk_source_context_engine_add_ref (GtkSourceContextEngine *ce,
|
||||
const gchar *parent_id,
|
||||
const gchar *ref_id,
|
||||
GtkSourceContextRefOptions options,
|
||||
const gchar *style,
|
||||
gboolean all,
|
||||
GError **error)
|
||||
{
|
||||
ContextDefinition *parent;
|
||||
ContextDefinition *ref;
|
||||
@ -4971,6 +5085,16 @@ _gtk_source_context_engine_add_ref (GtkSourceContextEngine *ce,
|
||||
g_return_val_if_fail (ref_id != NULL, FALSE);
|
||||
g_return_val_if_fail (GTK_IS_SOURCE_CONTEXT_ENGINE (ce), FALSE);
|
||||
|
||||
if (all && (options & (GTK_SOURCE_CONTEXT_IGNORE_STYLE | GTK_SOURCE_CONTEXT_OVERRIDE_STYLE)))
|
||||
{
|
||||
g_set_error (error,
|
||||
GTK_SOURCE_CONTEXT_ENGINE_ERROR,
|
||||
GTK_SOURCE_CONTEXT_ENGINE_ERROR_INVALID_STYLE,
|
||||
"can't override style for '%s' reference",
|
||||
ref_id);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* If the id is already present in the hashtable it is a duplicate,
|
||||
* so we report the error (probably there is a duplicate id in the
|
||||
* XML lang file). */
|
||||
@ -5009,6 +5133,16 @@ _gtk_source_context_engine_add_ref (GtkSourceContextEngine *ce,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (options & (GTK_SOURCE_CONTEXT_IGNORE_STYLE | GTK_SOURCE_CONTEXT_OVERRIDE_STYLE))
|
||||
{
|
||||
ref = context_definition_copy (ce, ref, parent, style, error);
|
||||
|
||||
if (!ref)
|
||||
return FALSE;
|
||||
|
||||
g_hash_table_insert (ce->priv->definitions, g_strdup (ref->id), ref);
|
||||
}
|
||||
|
||||
definition_child_new (parent, ref, all);
|
||||
|
||||
return TRUE;
|
||||
@ -5026,14 +5160,14 @@ add_escape_ref (ContextDefinition *definition,
|
||||
|
||||
_gtk_source_context_engine_add_ref (ce, definition->id,
|
||||
"gtk-source-context-engine-escape",
|
||||
FALSE, &error);
|
||||
0, NULL, FALSE, &error);
|
||||
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
_gtk_source_context_engine_add_ref (ce, definition->id,
|
||||
"gtk-source-context-engine-line-escape",
|
||||
FALSE, &error);
|
||||
0, NULL, FALSE, &error);
|
||||
|
||||
out:
|
||||
if (error)
|
||||
|
@ -57,6 +57,11 @@ typedef enum {
|
||||
GTK_SOURCE_CONTEXT_FIRST_LINE_ONLY = 1 << 2,
|
||||
} GtkSourceContextMatchOptions;
|
||||
|
||||
typedef enum {
|
||||
GTK_SOURCE_CONTEXT_IGNORE_STYLE = 1 << 0,
|
||||
GTK_SOURCE_CONTEXT_OVERRIDE_STYLE = 1 << 1,
|
||||
} GtkSourceContextRefOptions;
|
||||
|
||||
GType _gtk_source_context_engine_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkSourceContextEngine *_gtk_source_context_engine_new (GtkSourceLanguage *lang);
|
||||
@ -84,6 +89,8 @@ gboolean _gtk_source_context_engine_add_sub_pattern
|
||||
gboolean _gtk_source_context_engine_add_ref (GtkSourceContextEngine *ce,
|
||||
const gchar *parent_id,
|
||||
const gchar *ref_id,
|
||||
GtkSourceContextRefOptions options,
|
||||
const gchar *style,
|
||||
gboolean all,
|
||||
GError **error);
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include <eggregex.h>
|
||||
|
||||
#define PARSER_ERROR parser_error_quark ()
|
||||
#define ATTR_NO_STYLE ""
|
||||
|
||||
typedef enum {
|
||||
PARSER_ERROR_CANNOT_OPEN = 0,
|
||||
@ -52,6 +53,7 @@ typedef enum {
|
||||
PARSER_ERROR_INVALID_DOC,
|
||||
PARSER_ERROR_WRONG_VERSION,
|
||||
PARSER_ERROR_WRONG_ID,
|
||||
PARSER_ERROR_WRONG_STYLE,
|
||||
PARSER_ERROR_MALFORMED_REGEX,
|
||||
PARSER_ERROR_MALFORMED_MAP_TO
|
||||
} ParserError;
|
||||
@ -97,10 +99,10 @@ typedef struct _ParserState ParserState;
|
||||
static GQuark parser_error_quark (void);
|
||||
static gboolean str_to_bool (gchar *string);
|
||||
static gchar *generate_new_id (ParserState *parser_state);
|
||||
static gboolean id_is_decorated (gchar *id,
|
||||
static gboolean id_is_decorated (const gchar *id,
|
||||
gchar **lang_id);
|
||||
static gchar *decorate_id (ParserState *parser_state,
|
||||
gchar *id);
|
||||
const gchar *id);
|
||||
|
||||
static ParserState *parser_state_new (GtkSourceLanguage *language,
|
||||
GtkSourceContextEngine *engine,
|
||||
@ -187,7 +189,8 @@ generate_new_id (ParserState *parser_state)
|
||||
}
|
||||
|
||||
static gboolean
|
||||
id_is_decorated (gchar *id, gchar **lang_id)
|
||||
id_is_decorated (const gchar *id,
|
||||
gchar **lang_id)
|
||||
{
|
||||
/* This function is quite simple because the XML validator check for
|
||||
* the correctness of the id with a regex */
|
||||
@ -226,7 +229,7 @@ id_is_decorated (gchar *id, gchar **lang_id)
|
||||
|
||||
static gchar *
|
||||
decorate_id (ParserState *parser_state,
|
||||
gchar *id)
|
||||
const gchar *id)
|
||||
{
|
||||
gchar *decorated_id;
|
||||
|
||||
@ -519,7 +522,11 @@ create_definition (ParserState *parser_state,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
add_ref (ParserState *parser_state, gchar *ref, GError **error)
|
||||
add_ref (ParserState *parser_state,
|
||||
const gchar *ref,
|
||||
GtkSourceContextRefOptions options,
|
||||
const gchar *style,
|
||||
GError **error)
|
||||
{
|
||||
gchar *container_id;
|
||||
gboolean all = FALSE;
|
||||
@ -561,6 +568,7 @@ add_ref (ParserState *parser_state, gchar *ref, GError **error)
|
||||
}
|
||||
}
|
||||
ref_id = g_strdup (ref);
|
||||
g_free (lang_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -575,6 +583,18 @@ add_ref (ParserState *parser_state, gchar *ref, GError **error)
|
||||
ref_id [strlen (ref_id) - 2] = '\0';
|
||||
}
|
||||
|
||||
if (all && (options & (GTK_SOURCE_CONTEXT_IGNORE_STYLE | GTK_SOURCE_CONTEXT_OVERRIDE_STYLE)))
|
||||
{
|
||||
g_set_error (&tmp_error, PARSER_ERROR,
|
||||
PARSER_ERROR_WRONG_STYLE,
|
||||
"style override used with wildcard context reference"
|
||||
" in language '%s' in ref '%s'",
|
||||
lang_id, ref);
|
||||
}
|
||||
}
|
||||
|
||||
if (tmp_error == NULL && parser_state->engine != NULL)
|
||||
{
|
||||
container_id = g_queue_peek_head (parser_state->curr_parents);
|
||||
|
||||
/* If the document is validated container_id is never NULL */
|
||||
@ -583,6 +603,8 @@ add_ref (ParserState *parser_state, gchar *ref, GError **error)
|
||||
_gtk_source_context_engine_add_ref (parser_state->engine,
|
||||
container_id,
|
||||
ref_id,
|
||||
options,
|
||||
style,
|
||||
all,
|
||||
&tmp_error);
|
||||
|
||||
@ -648,6 +670,8 @@ handle_context_element (ParserState *parser_state,
|
||||
xmlChar *ref, *sub_pattern, *tmp;
|
||||
int is_empty;
|
||||
gboolean success;
|
||||
gboolean ignore_style = FALSE;
|
||||
GtkSourceContextRefOptions options = 0;
|
||||
|
||||
GError *tmp_error = NULL;
|
||||
|
||||
@ -658,35 +682,67 @@ handle_context_element (ParserState *parser_state,
|
||||
sub_pattern = xmlTextReaderGetAttribute (parser_state->reader,
|
||||
BAD_CAST "sub-pattern");
|
||||
|
||||
tmp = xmlTextReaderGetAttribute (parser_state->reader,
|
||||
BAD_CAST "style-ref");
|
||||
|
||||
if (tmp == NULL || id_is_decorated ((gchar *)tmp, NULL))
|
||||
style_ref = g_strdup ((gchar *)tmp);
|
||||
else
|
||||
style_ref = decorate_id (parser_state, (gchar *)tmp);
|
||||
tmp = xmlTextReaderGetAttribute (parser_state->reader, BAD_CAST "ignore-style");
|
||||
if (tmp != NULL && str_to_bool ((gchar*) tmp))
|
||||
ignore_style = TRUE;
|
||||
xmlFree (tmp);
|
||||
|
||||
if (style_ref && !g_hash_table_lookup (parser_state->styles_mapping, style_ref))
|
||||
tmp = xmlTextReaderGetAttribute (parser_state->reader, BAD_CAST "style-ref");
|
||||
if (tmp == NULL || id_is_decorated ((gchar*) tmp, NULL))
|
||||
style_ref = g_strdup ((gchar*) tmp);
|
||||
else
|
||||
style_ref = decorate_id (parser_state, (gchar*) tmp);
|
||||
xmlFree (tmp);
|
||||
|
||||
if (ignore_style && !ref)
|
||||
{
|
||||
g_set_error (error, PARSER_ERROR,
|
||||
PARSER_ERROR_WRONG_STYLE,
|
||||
"ignore-style used not in a reference to context");
|
||||
|
||||
xmlFree (ref);
|
||||
g_free (style_ref);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ignore_style)
|
||||
{
|
||||
options |= GTK_SOURCE_CONTEXT_IGNORE_STYLE;
|
||||
|
||||
if (style_ref != NULL)
|
||||
g_warning ("style-ref and ignore-style used simultaneously");
|
||||
}
|
||||
|
||||
if (!ignore_style && style_ref && !g_hash_table_lookup (parser_state->styles_mapping, style_ref))
|
||||
{
|
||||
g_warning ("style '%s' not defined", style_ref);
|
||||
}
|
||||
|
||||
if (ref != NULL)
|
||||
{
|
||||
add_ref (parser_state, (gchar *)ref, &tmp_error);
|
||||
if (style_ref)
|
||||
options |= GTK_SOURCE_CONTEXT_OVERRIDE_STYLE;
|
||||
|
||||
add_ref (parser_state, (gchar*) ref, options, style_ref, &tmp_error);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *freeme = NULL;
|
||||
|
||||
tmp = xmlTextReaderGetAttribute (parser_state->reader, BAD_CAST "id");
|
||||
if (tmp == NULL)
|
||||
tmp = xmlStrdup (BAD_CAST generate_new_id (parser_state));
|
||||
{
|
||||
freeme = generate_new_id (parser_state);
|
||||
tmp = xmlStrdup (BAD_CAST freeme);
|
||||
}
|
||||
|
||||
if (id_is_decorated ((gchar *)tmp, NULL))
|
||||
id = g_strdup ((gchar *)tmp);
|
||||
if (id_is_decorated ((gchar*) tmp, NULL))
|
||||
id = g_strdup ((gchar*) tmp);
|
||||
else
|
||||
id = decorate_id (parser_state, (gchar *)tmp);
|
||||
id = decorate_id (parser_state, (gchar*) tmp);
|
||||
|
||||
g_free (freeme);
|
||||
xmlFree (tmp);
|
||||
|
||||
if (parser_state->engine != NULL)
|
||||
|
@ -670,3 +670,20 @@ gtk_source_languages_manager_get_available_style_schemes (GtkSourceLanguagesMana
|
||||
lm->priv->style_schemes = g_slist_reverse (lm->priv->style_schemes);
|
||||
return lm->priv->style_schemes;
|
||||
}
|
||||
|
||||
GtkSourceStyleScheme *
|
||||
_gtk_source_style_scheme_get_default (void)
|
||||
{
|
||||
GtkSourceStyleScheme *scheme = NULL;
|
||||
GtkSourceLanguagesManager *lm;
|
||||
const GSList *list;
|
||||
|
||||
lm = gtk_source_languages_manager_new ();
|
||||
list = gtk_source_languages_manager_get_available_style_schemes (lm);
|
||||
|
||||
if (list)
|
||||
scheme = g_object_ref (list->data);
|
||||
|
||||
g_object_unref (lm);
|
||||
return scheme;
|
||||
}
|
||||
|
@ -71,6 +71,8 @@ void gtk_source_style_scheme_set_style (GtkSourceStyleScheme *scheme,
|
||||
void _gtk_source_style_scheme_apply (GtkSourceStyleScheme *scheme,
|
||||
GtkWidget *widget);
|
||||
GtkSourceStyleScheme *_gtk_source_style_scheme_new_from_file (const gchar *filename);
|
||||
/* temporary hackaround, implemented in gtksourcelanguagesmanager.c, returns new instance */
|
||||
GtkSourceStyleScheme *_gtk_source_style_scheme_get_default (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -12,6 +12,7 @@ langs2 = \
|
||||
|
||||
langs1 = \
|
||||
ada.lang \
|
||||
automake.lang \
|
||||
changelog.lang \
|
||||
check.sh \
|
||||
csharp.lang \
|
||||
|
11
moo/mooedit/language-specs/automake.lang
Normal file
11
moo/mooedit/language-specs/automake.lang
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<language id="automake" _name="Automake" version="2.0" _section="Sources"
|
||||
globs="Makefile.am">
|
||||
<definitions>
|
||||
<context id="automake">
|
||||
<include>
|
||||
<context ref="makefile:makefile:*"/>
|
||||
</include>
|
||||
</context>
|
||||
</definitions>
|
||||
</language>
|
@ -76,27 +76,20 @@
|
||||
\b
|
||||
</start>
|
||||
<include>
|
||||
<context ref="def:line-continue"/>
|
||||
<context ref="def:line-continue" ignore-style="true"/>
|
||||
<context ref="comment"/>
|
||||
<context ref="comment-multiline"/>
|
||||
</include>
|
||||
</context>
|
||||
|
||||
<!-- Strings -->
|
||||
<context id="string" end-at-line-end="true" style-ref="string">
|
||||
<start>"</start>
|
||||
<end>"</end>
|
||||
<include>
|
||||
<context ref="def:line-continue"/>
|
||||
<context ref="def:c-style-escape"/>
|
||||
</include>
|
||||
</context>
|
||||
<context ref="def:string"/>
|
||||
|
||||
<context id="char" end-at-line-end="true" style-ref="char">
|
||||
<start>'</start>
|
||||
<end>'</end>
|
||||
<include>
|
||||
<context ref="def:c-style-escape"/>
|
||||
<context ref="def:escape"/>
|
||||
</include>
|
||||
</context>
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
# "./check.sh" without arguments will validate lang and styles files
|
||||
# specified here.
|
||||
|
||||
langs="c.lang cpp.lang def.lang html.lang \
|
||||
javascript.lang latex.lang xml.lang \
|
||||
langs="automake.lang c.lang cpp.lang def.lang html.lang \
|
||||
javascript.lang latex.lang makefile.lang xml.lang \
|
||||
yacc.lang"
|
||||
|
||||
styles="gvim.styles kde.styles"
|
||||
|
@ -102,7 +102,7 @@
|
||||
</include>
|
||||
</context>
|
||||
|
||||
<context id="line-continue">
|
||||
<context id="line-continue" style-ref="escape">
|
||||
<start>\\$</start>
|
||||
<end>^</end>
|
||||
</context>
|
||||
@ -112,9 +112,29 @@
|
||||
<end>$</end>
|
||||
</context>
|
||||
|
||||
<context id="c-style-escape" style-ref="escape">
|
||||
<context id="escape" style-ref="escape">
|
||||
<match>\\.</match>
|
||||
</context>
|
||||
|
||||
<!-- usual quoted string, ends at line end, \ is an escape char -->
|
||||
<context id="string" style-ref="string" end-at-line-end="true">
|
||||
<start>"</start>
|
||||
<end>"</end>
|
||||
<include>
|
||||
<context ref="escape"/>
|
||||
<context ref="line-continue"/>
|
||||
</include>
|
||||
</context>
|
||||
|
||||
<!-- same thing but with single quote marks -->
|
||||
<context id="single-quoted-string" style-ref="string" end-at-line-end="true">
|
||||
<start>'</start>
|
||||
<end>'</end>
|
||||
<include>
|
||||
<context ref="escape"/>
|
||||
<context ref="line-continue"/>
|
||||
</include>
|
||||
</context>
|
||||
|
||||
</definitions>
|
||||
</language>
|
||||
|
@ -61,7 +61,7 @@
|
||||
<context id="string-continue" style-ref="escape">
|
||||
<match>\\\n</match>
|
||||
</context>
|
||||
<context ref="def:c-style-escape"/>
|
||||
<context ref="def:escape"/>
|
||||
</include>
|
||||
</context>
|
||||
|
||||
@ -70,7 +70,7 @@
|
||||
<end>'</end>
|
||||
<include>
|
||||
<context ref="string-continue"/>
|
||||
<context ref="def:c-style-escape"/>
|
||||
<context ref="def:escape"/>
|
||||
</include>
|
||||
</context>
|
||||
|
||||
|
@ -255,7 +255,9 @@
|
||||
</attribute>
|
||||
</optional>
|
||||
<optional>
|
||||
<attribute name="style-ref"/>
|
||||
<attribute name="style-ref">
|
||||
<ref name="id-type"/>
|
||||
</attribute>
|
||||
</optional>
|
||||
<optional>
|
||||
<attribute name="extend-parent">
|
||||
@ -337,7 +339,9 @@
|
||||
</attribute>
|
||||
</optional>
|
||||
<optional>
|
||||
<attribute name="style-ref"/>
|
||||
<attribute name="style-ref">
|
||||
<ref name="id-type"/>
|
||||
</attribute>
|
||||
</optional>
|
||||
|
||||
<attribute name="sub-pattern"/>
|
||||
@ -352,7 +356,9 @@
|
||||
</attribute>
|
||||
</optional>
|
||||
<optional>
|
||||
<attribute name="style-ref"/>
|
||||
<attribute name="style-ref">
|
||||
<ref name="id-type"/>
|
||||
</attribute>
|
||||
</optional>
|
||||
|
||||
<attribute name="sub-pattern"/>
|
||||
@ -371,6 +377,16 @@
|
||||
<attribute name="ref">
|
||||
<ref name="ref-type"/>
|
||||
</attribute>
|
||||
<optional>
|
||||
<choice>
|
||||
<attribute name="style-ref">
|
||||
<ref name="id-type"/>
|
||||
</attribute>
|
||||
<attribute name="ignore-style">
|
||||
<ref name="boolean-value"/>
|
||||
</attribute>
|
||||
</choice>
|
||||
</optional>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
|
@ -1,96 +1,117 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE language SYSTEM "language.dtd">
|
||||
<language _name="Makefile" version="1.0" _section="Sources" mimetypes="text/x-makefile">
|
||||
<!--
|
||||
Authors: Ricardo Lenz <riclc@hotmail.com>
|
||||
Paolo Borelli <pborelli@katamail.com>
|
||||
-->
|
||||
<language id="makefile" _name="Makefile" version="2.0" _section="Sources"
|
||||
mimetypes="text/x-makefile" globs="Makefile*">
|
||||
<styles>
|
||||
<style id="comment" name="Comment" map-to="def:comment"/>
|
||||
<style id="function" name="Function" map-to="def:function"/>
|
||||
<style id="string" name="String" map-to="def:string"/>
|
||||
<style id="keyword" name="Keyword" map-to="def:keyword"/>
|
||||
<style id="variable" name="Variable" map-to="def:data-type"/>
|
||||
<style id="target" name="Target" map-to="def:function"/>
|
||||
</styles>
|
||||
|
||||
<escape-char>\</escape-char>
|
||||
<definitions>
|
||||
<define-regex id="variable">[a-zA-Z_][a-zA-Z0-9_]*</define-regex>
|
||||
|
||||
<line-comment _name ="Line Comment" style="Comment">
|
||||
<start-regex>#</start-regex>
|
||||
</line-comment>
|
||||
<context id="variable">
|
||||
<match>\$\((\%{variable})\)</match>
|
||||
<include>
|
||||
<context sub-pattern="1" style-ref="variable"/>
|
||||
</include>
|
||||
</context>
|
||||
|
||||
<string _name = "String" style = "String" end-at-line-end = "TRUE">
|
||||
<start-regex>"</start-regex>
|
||||
<end-regex>"</end-regex>
|
||||
</string>
|
||||
<context id="makefile">
|
||||
<include>
|
||||
<context ref="def:shebang"/>
|
||||
|
||||
<string _name = "String 2" style = "String" end-at-line-end = "TRUE">
|
||||
<start-regex>'</start-regex>
|
||||
<end-regex>'</end-regex>
|
||||
</string>
|
||||
<context id="line-comment" style-ref="comment" end-at-line-end="true">
|
||||
<start>#</start>
|
||||
<include>
|
||||
<context ref="def:line-continue"/>
|
||||
<context ref="def:comment:*"/>
|
||||
</include>
|
||||
</context>
|
||||
|
||||
<string _name = "Backtick String" style = "Function" end-at-line-end = "TRUE">
|
||||
<start-regex>`</start-regex>
|
||||
<end-regex>`</end-regex>
|
||||
</string>
|
||||
<context ref="def:string"/>
|
||||
<context ref="def:single-quoted-string"/>
|
||||
|
||||
<keyword-list _name = "Variable1" style = "Others 3" match-empty-string-at-beginning = "FALSE" match-empty-string-at-end = "FALSE">
|
||||
<keyword>[$]+[<>@?*{\(a-zA-Z0-9_][}\)a-zA-Z0-9_]*</keyword>
|
||||
</keyword-list>
|
||||
|
||||
<keyword-list _name = "Variable2" style = "Others 2" match-empty-string-at-beginning = "FALSE" match-empty-string-at-end = "FALSE">
|
||||
<keyword>^[ \t]*[a-zA-Z_][a-zA-Z0-9_]*[ \t]*\=</keyword>
|
||||
</keyword-list>
|
||||
<context id="backtick-string" style-ref="function" end-at-line-end="true">
|
||||
<start>`</start>
|
||||
<end>`</end>
|
||||
<include>
|
||||
<context ref="def:escape"/>
|
||||
<context ref="def:line-continue"/>
|
||||
</include>
|
||||
</context>
|
||||
|
||||
<keyword-list _name="Directives" style="Keyword" case-sensitive="TRUE">
|
||||
<keyword>define</keyword>
|
||||
<keyword>else</keyword>
|
||||
<keyword>endef</keyword>
|
||||
<keyword>endif</keyword>
|
||||
<!-- <keyword>export</keyword> FIXME: too many false positives -->
|
||||
<keyword>ifdef</keyword>
|
||||
<keyword>ifeq</keyword>
|
||||
<keyword>ifndef</keyword>
|
||||
<keyword>ifneq</keyword>
|
||||
<!-- <keyword>include</keyword> FIXME: too many false positives -->
|
||||
<keyword>override</keyword>
|
||||
<keyword>unexport</keyword>
|
||||
</keyword-list>
|
||||
<context id="variable-1" style-ref="variable" end-at-line-end="true">
|
||||
<start>^(\%{variable})\s*=</start>
|
||||
<include>
|
||||
<context sub-pattern="1" where="start"/>
|
||||
<context ref="variable"/>
|
||||
<context ref="def:line-continue"/>
|
||||
</include>
|
||||
</context>
|
||||
|
||||
<keyword-list _name="Functions" style="Function" case-sensitive="TRUE">
|
||||
<keyword>addprefix</keyword>
|
||||
<keyword>addsuffix</keyword>
|
||||
<keyword>basename</keyword>
|
||||
<keyword>call</keyword>
|
||||
<keyword>dir</keyword>
|
||||
<keyword>error</keyword>
|
||||
<keyword>filter</keyword>
|
||||
<keyword>filter-out</keyword>
|
||||
<keyword>findstring</keyword>
|
||||
<keyword>firstword</keyword>
|
||||
<keyword>foreach</keyword>
|
||||
<keyword>join</keyword>
|
||||
<keyword>notdir</keyword>
|
||||
<keyword>origin</keyword>
|
||||
<keyword>patsubst</keyword>
|
||||
<keyword>shell</keyword>
|
||||
<keyword>sort</keyword>
|
||||
<keyword>strip</keyword>
|
||||
<keyword>subst</keyword>
|
||||
<keyword>suffix</keyword>
|
||||
<keyword>warning</keyword>
|
||||
<keyword>wildcard</keyword>
|
||||
<keyword>word</keyword>
|
||||
<keyword>words</keyword>
|
||||
</keyword-list>
|
||||
|
||||
<pattern-item _name = "Targets" style = "Function">
|
||||
<regex>^[ \t]*([a-zA-Z0-9_\.\-]+)[ \t]*\:</regex>
|
||||
</pattern-item>
|
||||
<context id="targets">
|
||||
<match>^\s*([^\s]+)\s*\:</match>
|
||||
<include>
|
||||
<context sub-pattern="1" style-ref="target"/>
|
||||
</include>
|
||||
</context>
|
||||
|
||||
<keyword-list _name="Special Targets" style="Keyword" case-sensitive="TRUE"
|
||||
match-empty-string-at-beginning="FALSE" match-empty-string-at-end="TRUE"
|
||||
beginning-regex = "^">
|
||||
<keyword>\.DEFAULT</keyword>
|
||||
<keyword>\.EXPORT_ALL_VARIABLES</keyword>
|
||||
<keyword>\.IGNORE</keyword>
|
||||
<keyword>\.PHONY</keyword>
|
||||
<keyword>\.PRECIOUS</keyword>
|
||||
<keyword>\.SILENT</keyword>
|
||||
<keyword>\.SUFFIXES</keyword>
|
||||
</keyword-list>
|
||||
<context id="directives" style-ref="keyword">
|
||||
<keyword>define</keyword>
|
||||
<keyword>else</keyword>
|
||||
<keyword>endef</keyword>
|
||||
<keyword>endif</keyword>
|
||||
<keyword>ifdef</keyword>
|
||||
<keyword>ifeq</keyword>
|
||||
<keyword>ifndef</keyword>
|
||||
<keyword>ifneq</keyword>
|
||||
<keyword>override</keyword>
|
||||
<keyword>unexport</keyword>
|
||||
</context>
|
||||
|
||||
<context id="functions" style-ref="function">
|
||||
<keyword>addprefix</keyword>
|
||||
<keyword>addsuffix</keyword>
|
||||
<keyword>basename</keyword>
|
||||
<keyword>call</keyword>
|
||||
<keyword>dir</keyword>
|
||||
<keyword>error</keyword>
|
||||
<keyword>filter</keyword>
|
||||
<keyword>filter-out</keyword>
|
||||
<keyword>findstring</keyword>
|
||||
<keyword>firstword</keyword>
|
||||
<keyword>foreach</keyword>
|
||||
<keyword>join</keyword>
|
||||
<keyword>notdir</keyword>
|
||||
<keyword>origin</keyword>
|
||||
<keyword>patsubst</keyword>
|
||||
<keyword>shell</keyword>
|
||||
<keyword>sort</keyword>
|
||||
<keyword>strip</keyword>
|
||||
<keyword>subst</keyword>
|
||||
<keyword>suffix</keyword>
|
||||
<keyword>warning</keyword>
|
||||
<keyword>wildcard</keyword>
|
||||
<keyword>word</keyword>
|
||||
<keyword>words</keyword>
|
||||
</context>
|
||||
|
||||
<context id="special-targets" style-ref="keyword">
|
||||
<prefix>^</prefix>
|
||||
<suffix>\b</suffix>
|
||||
<keyword>\.DEFAULT</keyword>
|
||||
<keyword>\.EXPORT_ALL_VARIABLES</keyword>
|
||||
<keyword>\.IGNORE</keyword>
|
||||
<keyword>\.PHONY</keyword>
|
||||
<keyword>\.PRECIOUS</keyword>
|
||||
<keyword>\.SILENT</keyword>
|
||||
<keyword>\.SUFFIXES</keyword>
|
||||
</context>
|
||||
</include>
|
||||
</context>
|
||||
</definitions>
|
||||
</language>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<language id="xml" _name="XML" version="2.0" _section="Markup"
|
||||
mimetypes="application/xml;text/xml;image/svg+xml,text/rdf"
|
||||
globs="*.xml;*.rdf;*.svg;*.rng;*.lang">
|
||||
globs="*.xml;*.rdf;*.svg;*.rng;*.lang;*.xslt">
|
||||
<styles>
|
||||
<style id="comment" _name="Comment" map-to="def:comment"/>
|
||||
<style id="doctype" _name="DOCTYPE" map-to="def:preprocessor"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user