Fancier highlighting
parent
6416e6aaa2
commit
7d16d21b37
|
@ -23,9 +23,8 @@
|
|||
#define gtk_source_language_get_metadata _moo_gtk_source_language_get_metadata
|
||||
#define gtk_source_style_manager_new _moo_gtk_source_style_manager_new
|
||||
#define gtk_source_style_manager_set_search_path _moo_gtk_source_style_manager_set_search_path
|
||||
#define gtk_source_language_manager_get_available_languages _moo_gtk_source_language_manager_get_available_languages
|
||||
#define gtk_source_language_manager_list_languages _moo_gtk_source_language_manager_list_languages
|
||||
#define gtk_source_style_manager_list_schemes _moo_gtk_source_style_manager_list_schemes
|
||||
#define gtk_source_language_manager_get_available_languages _moo_gtk_source_language_manager_get_available_languages
|
||||
#define _gtk_source_engine_attach_buffer _moo_gtk_source_engine_attach_buffer
|
||||
#define _gtk_source_engine_text_inserted _moo_gtk_source_engine_text_inserted
|
||||
#define _gtk_source_engine_text_deleted _moo_gtk_source_engine_text_deleted
|
||||
|
|
|
@ -200,7 +200,8 @@ struct _ContextDefinition
|
|||
* context. */
|
||||
Regex *reg_all;
|
||||
|
||||
GtkSourceContextFlags flags;
|
||||
guint flags : 8;
|
||||
guint ref_count : 24;
|
||||
};
|
||||
|
||||
struct _SubPatternDefinition
|
||||
|
@ -289,6 +290,12 @@ struct _ContextPtr
|
|||
guint fixed : 1;
|
||||
};
|
||||
|
||||
struct _GtkSourceContextReplace
|
||||
{
|
||||
gchar *id;
|
||||
gchar *replace_with;
|
||||
};
|
||||
|
||||
struct _Segment
|
||||
{
|
||||
Segment *parent;
|
||||
|
@ -460,7 +467,8 @@ static void find_insertion_place (Segment *segment,
|
|||
Segment *hint);
|
||||
static void segment_destroy (GtkSourceContextEngine *ce,
|
||||
Segment *segment);
|
||||
static void context_definition_free (ContextDefinition *definition);
|
||||
static ContextDefinition *context_definition_ref(ContextDefinition *definition);
|
||||
static void context_definition_unref(ContextDefinition *definition);
|
||||
|
||||
static void segment_extend (Segment *state,
|
||||
gint end_at);
|
||||
|
@ -1294,7 +1302,7 @@ sub_pattern_new (Segment *segment,
|
|||
{
|
||||
SubPattern *sp;
|
||||
|
||||
sp = g_new0 (SubPattern, 1);
|
||||
sp = g_slice_new0 (SubPattern);
|
||||
sp->start_at = start_at;
|
||||
sp->end_at = end_at;
|
||||
sp->definition = sp_def;
|
||||
|
@ -1317,7 +1325,7 @@ sub_pattern_free (SubPattern *sp)
|
|||
#ifdef ENABLE_DEBUG
|
||||
memset (sp, 1, sizeof (SubPattern));
|
||||
#else
|
||||
g_free (sp);
|
||||
g_slice_free (SubPattern, sp);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -2388,11 +2396,11 @@ _gtk_source_context_data_new (GtkSourceLanguage *lang)
|
|||
|
||||
g_return_val_if_fail (GTK_IS_SOURCE_LANGUAGE (lang), NULL);
|
||||
|
||||
ctx_data = g_new0 (GtkSourceContextData, 1);
|
||||
ctx_data = g_slice_new0 (GtkSourceContextData);
|
||||
ctx_data->ref_count = 1;
|
||||
ctx_data->lang = lang;
|
||||
ctx_data->definitions = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
|
||||
(GDestroyNotify) context_definition_free);
|
||||
(GDestroyNotify) context_definition_unref);
|
||||
|
||||
return ctx_data;
|
||||
}
|
||||
|
@ -2425,7 +2433,7 @@ _gtk_source_context_data_unref (GtkSourceContextData *ctx_data)
|
|||
ctx_data->lang->priv->ctx_data == ctx_data)
|
||||
ctx_data->lang->priv->ctx_data = NULL;
|
||||
g_hash_table_destroy (ctx_data->definitions);
|
||||
g_free (ctx_data);
|
||||
g_slice_free (GtkSourceContextData, ctx_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2452,7 +2460,7 @@ regex_unref (Regex *regex)
|
|||
}
|
||||
else
|
||||
g_free (regex->u.info.pattern);
|
||||
g_free (regex);
|
||||
g_slice_free (Regex, regex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2524,7 +2532,7 @@ regex_new (const gchar *pattern,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
regex = g_new0 (Regex, 1);
|
||||
regex = g_slice_new0 (Regex);
|
||||
regex->ref_count = 1;
|
||||
|
||||
if (g_regex_match_simple (START_REF_REGEX, pattern, 0, 0))
|
||||
|
@ -2542,7 +2550,7 @@ regex_new (const gchar *pattern,
|
|||
|
||||
if (regex->u.regex.regex == NULL)
|
||||
{
|
||||
g_free (regex);
|
||||
g_slice_free (Regex, regex);
|
||||
regex = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -3139,7 +3147,7 @@ context_new (Context *parent,
|
|||
{
|
||||
Context *context;
|
||||
|
||||
context = g_new0 (Context, 1);
|
||||
context = g_slice_new0 (Context);
|
||||
context->ref_count = 1;
|
||||
context->definition = definition;
|
||||
context->parent = parent;
|
||||
|
@ -3250,7 +3258,7 @@ context_remove_child (Context *parent,
|
|||
#ifdef ENABLE_DEBUG
|
||||
memset (ptr, 1, sizeof (ContextPtr));
|
||||
#else
|
||||
g_free (ptr);
|
||||
g_slice_free (ContextPtr, ptr);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -3298,7 +3306,7 @@ context_unref (Context *context)
|
|||
#ifdef ENABLE_DEBUG
|
||||
memset (ptr, 1, sizeof (ContextPtr));
|
||||
#else
|
||||
g_free (ptr);
|
||||
g_slice_free (ContextPtr, ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -3308,7 +3316,7 @@ context_unref (Context *context)
|
|||
regex_unref (context->end);
|
||||
regex_unref (context->reg_all);
|
||||
g_free (context->subpattern_tags);
|
||||
g_free (context);
|
||||
g_slice_free (Context, context);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -3428,7 +3436,7 @@ create_child_context (Context *parent,
|
|||
|
||||
if (ptr == NULL)
|
||||
{
|
||||
ptr = g_new0 (ContextPtr, 1);
|
||||
ptr = g_slice_new0 (ContextPtr);
|
||||
ptr->next = parent->children;
|
||||
parent->children = ptr;
|
||||
ptr->definition = definition;
|
||||
|
@ -3504,7 +3512,7 @@ segment_new (GtkSourceContextEngine *ce,
|
|||
g_assert (!is_start || context != NULL);
|
||||
#endif
|
||||
|
||||
segment = g_new0 (Segment, 1);
|
||||
segment = g_slice_new0 (Segment);
|
||||
segment->parent = parent;
|
||||
segment->context = context_ref (context);
|
||||
segment->start_at = start_at;
|
||||
|
@ -3792,7 +3800,7 @@ segment_destroy (GtkSourceContextEngine *ce,
|
|||
g_assert (!g_slist_find (ce->priv->invalid, segment));
|
||||
memset (segment, 1, sizeof (Segment));
|
||||
#else
|
||||
g_free (segment);
|
||||
g_slice_free (Segment, segment);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -5467,27 +5475,26 @@ out:
|
|||
|
||||
static DefinitionChild *
|
||||
definition_child_new (ContextDefinition *definition,
|
||||
ContextDefinition *child_def,
|
||||
const gchar *child_id,
|
||||
const gchar *style,
|
||||
gboolean override_style,
|
||||
gboolean is_ref_all)
|
||||
gboolean is_ref_all,
|
||||
gboolean original_ref)
|
||||
{
|
||||
DefinitionChild *ch;
|
||||
|
||||
g_return_val_if_fail (child_def != NULL || child_id != NULL, NULL);
|
||||
g_return_val_if_fail (child_def == NULL || child_id == NULL, NULL);
|
||||
g_return_val_if_fail (child_id != NULL, NULL);
|
||||
|
||||
ch = g_new0 (DefinitionChild, 1);
|
||||
ch = g_slice_new0 (DefinitionChild);
|
||||
|
||||
if (child_id != NULL)
|
||||
ch->u.id = g_strdup (child_id);
|
||||
if (original_ref)
|
||||
ch->u.id = g_strdup_printf ("@%s", child_id);
|
||||
else
|
||||
ch->u.definition = child_def;
|
||||
ch->u.id = g_strdup (child_id);
|
||||
|
||||
ch->style = g_strdup (style);
|
||||
ch->is_ref_all = is_ref_all;
|
||||
ch->resolved = child_def != NULL;
|
||||
ch->resolved = FALSE;
|
||||
ch->override_style = override_style;
|
||||
|
||||
definition->children = g_slist_append (definition->children, ch);
|
||||
|
@ -5505,7 +5512,7 @@ definition_child_free (DefinitionChild *ch)
|
|||
#ifdef ENABLE_DEBUG
|
||||
memset (ch, 1, sizeof (DefinitionChild));
|
||||
#else
|
||||
g_free (ch);
|
||||
g_slice_free (DefinitionChild, ch);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -5537,7 +5544,7 @@ context_definition_new (const gchar *id,
|
|||
break;
|
||||
}
|
||||
|
||||
definition = g_new0 (ContextDefinition, 1);
|
||||
definition = g_slice_new0 (ContextDefinition);
|
||||
|
||||
if (match != NULL)
|
||||
{
|
||||
|
@ -5593,10 +5600,11 @@ context_definition_new (const gchar *id,
|
|||
|
||||
if (regex_error)
|
||||
{
|
||||
g_free (definition);
|
||||
g_slice_free (ContextDefinition, definition);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
definition->ref_count = 1;
|
||||
definition->id = g_strdup (id);
|
||||
definition->default_style = g_strdup (style);
|
||||
definition->type = type;
|
||||
|
@ -5608,12 +5616,20 @@ context_definition_new (const gchar *id,
|
|||
return definition;
|
||||
}
|
||||
|
||||
static ContextDefinition *
|
||||
context_definition_ref (ContextDefinition *definition)
|
||||
{
|
||||
g_return_val_if_fail (definition != NULL, NULL);
|
||||
definition->ref_count += 1;
|
||||
return definition;
|
||||
}
|
||||
|
||||
static void
|
||||
context_definition_free (ContextDefinition *definition)
|
||||
context_definition_unref (ContextDefinition *definition)
|
||||
{
|
||||
GSList *sub_pattern_list;
|
||||
|
||||
if (definition == NULL)
|
||||
if (definition == NULL || --definition->ref_count != 0)
|
||||
return;
|
||||
|
||||
switch (definition->type)
|
||||
|
@ -5637,7 +5653,7 @@ context_definition_free (ContextDefinition *definition)
|
|||
g_free (sp_def->style);
|
||||
if (sp_def->is_named)
|
||||
g_free (sp_def->u.name);
|
||||
g_free (sp_def);
|
||||
g_slice_free (SubPatternDefinition, sp_def);
|
||||
sub_pattern_list = sub_pattern_list->next;
|
||||
}
|
||||
g_slist_free (definition->sub_patterns);
|
||||
|
@ -5648,7 +5664,7 @@ context_definition_free (ContextDefinition *definition)
|
|||
|
||||
g_slist_foreach (definition->children, (GFunc) definition_child_free, NULL);
|
||||
g_slist_free (definition->children);
|
||||
g_free (definition);
|
||||
g_slice_free (ContextDefinition, definition);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -5715,7 +5731,7 @@ _gtk_source_context_data_define_context (GtkSourceContextData *ctx_data,
|
|||
{
|
||||
ContextDefinition *definition, *parent = NULL;
|
||||
ContextType type;
|
||||
|
||||
gchar *original_id;
|
||||
gboolean wrong_args = FALSE;
|
||||
|
||||
g_return_val_if_fail (ctx_data != NULL, FALSE);
|
||||
|
@ -5779,9 +5795,12 @@ _gtk_source_context_data_define_context (GtkSourceContextData *ctx_data,
|
|||
return FALSE;
|
||||
|
||||
g_hash_table_insert (ctx_data->definitions, g_strdup (id), definition);
|
||||
original_id = g_strdup_printf ("@%s", id);
|
||||
g_hash_table_insert (ctx_data->definitions, original_id,
|
||||
context_definition_ref (definition));
|
||||
|
||||
if (parent != NULL)
|
||||
definition_child_new (parent, definition, NULL, NULL, FALSE, FALSE);
|
||||
definition_child_new (parent, id, NULL, FALSE, FALSE, FALSE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -5846,7 +5865,7 @@ _gtk_source_context_data_add_sub_pattern (GtkSourceContextData *ctx_data,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
sp_def = g_new0 (SubPatternDefinition, 1);
|
||||
sp_def = g_slice_new0 (SubPatternDefinition);
|
||||
#ifdef NEED_DEBUG_ID
|
||||
sp_def->id = g_strdup (id);
|
||||
#endif
|
||||
|
@ -5935,8 +5954,8 @@ _gtk_source_context_data_add_ref (GtkSourceContextData *ctx_data,
|
|||
if (options & (GTK_SOURCE_CONTEXT_IGNORE_STYLE | GTK_SOURCE_CONTEXT_OVERRIDE_STYLE))
|
||||
override_style = TRUE;
|
||||
|
||||
definition_child_new (parent, ref, (ref == NULL) ? ref_id : NULL,
|
||||
style, override_style, all);
|
||||
definition_child_new (parent, ref_id, style, override_style, all,
|
||||
(options & GTK_SOURCE_CONTEXT_REF_ORIGINAL) != 0);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -5945,7 +5964,7 @@ _gtk_source_context_data_add_ref (GtkSourceContextData *ctx_data,
|
|||
* resolve_reference:
|
||||
*
|
||||
* Checks whether all children of a context definition refer to valid
|
||||
* contexts. Called from _gtk_source_context_data_resolve_refs.
|
||||
* contexts. Called from _gtk_source_context_data_finish_parse.
|
||||
*/
|
||||
struct ResolveRefData {
|
||||
GtkSourceContextData *ctx_data;
|
||||
|
@ -6005,18 +6024,79 @@ resolve_reference (G_GNUC_UNUSED const gchar *id,
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
process_replace (GtkSourceContextData *ctx_data,
|
||||
const gchar *id,
|
||||
const gchar *replace_with,
|
||||
GError **error)
|
||||
{
|
||||
ContextDefinition *to_replace, *new;
|
||||
|
||||
to_replace = LOOKUP_DEFINITION (ctx_data, id);
|
||||
|
||||
if (to_replace == NULL)
|
||||
{
|
||||
g_set_error (error, GTK_SOURCE_CONTEXT_ENGINE_ERROR,
|
||||
GTK_SOURCE_CONTEXT_ENGINE_ERROR_INVALID_REF,
|
||||
_("unknown context '%s'"), id);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
new = LOOKUP_DEFINITION (ctx_data, replace_with);
|
||||
|
||||
if (new == NULL)
|
||||
{
|
||||
g_set_error (error, GTK_SOURCE_CONTEXT_ENGINE_ERROR,
|
||||
GTK_SOURCE_CONTEXT_ENGINE_ERROR_INVALID_REF,
|
||||
_("unknown context '%s'"), replace_with);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_hash_table_insert (ctx_data->definitions, g_strdup (id), context_definition_ref (new));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GtkSourceContextReplace *
|
||||
_gtk_source_context_replace_new (const gchar *to_replace_id,
|
||||
const gchar *replace_with_id)
|
||||
{
|
||||
GtkSourceContextReplace *repl;
|
||||
|
||||
g_return_val_if_fail (to_replace_id != NULL, NULL);
|
||||
g_return_val_if_fail (replace_with_id != NULL, NULL);
|
||||
|
||||
repl = g_slice_new (GtkSourceContextReplace);
|
||||
repl->id = g_strdup (to_replace_id);
|
||||
repl->replace_with = g_strdup (replace_with_id);
|
||||
|
||||
return repl;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_source_context_replace_free (GtkSourceContextReplace *repl)
|
||||
{
|
||||
if (repl != NULL)
|
||||
{
|
||||
g_free (repl->id);
|
||||
g_free (repl->replace_with);
|
||||
g_slice_free (GtkSourceContextReplace, repl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* _gtk_source_context_data_resolve_refs:
|
||||
* _gtk_source_context_data_finish_parse:
|
||||
*
|
||||
* @ctx_data: #GtkSourceContextData.
|
||||
* @overrides: list of #GtkSourceContextOverride objects.
|
||||
* @error: error structure to be filled in when failed.
|
||||
*
|
||||
* Checks all context references. Lang file may use cross-references
|
||||
* between contexts, e.g. context A may include context B, and context
|
||||
* B in turn include context A. Hence during parsing it just records
|
||||
* referenced context id (if it's not present already), and then it
|
||||
* needs to check the references and replace them with actual context
|
||||
* definitions.
|
||||
* Checks all context references and applies overrides. Lang file may
|
||||
* use cross-references between contexts, e.g. context A may include
|
||||
* context B, and context B in turn include context A. Hence during
|
||||
* parsing it just records referenced context id, and then it needs to
|
||||
* check the references and replace them with actual context definitions
|
||||
* (which in turn may be overridden using <override> or <replace> tags).
|
||||
* May be called any number of times, must be called after parsing is
|
||||
* done.
|
||||
*
|
||||
|
@ -6024,7 +6104,8 @@ resolve_reference (G_GNUC_UNUSED const gchar *id,
|
|||
* references.
|
||||
*/
|
||||
gboolean
|
||||
_gtk_source_context_data_resolve_refs (GtkSourceContextData *ctx_data,
|
||||
_gtk_source_context_data_finish_parse (GtkSourceContextData *ctx_data,
|
||||
GList *overrides,
|
||||
GError **error)
|
||||
{
|
||||
struct ResolveRefData data;
|
||||
|
@ -6032,6 +6113,18 @@ _gtk_source_context_data_resolve_refs (GtkSourceContextData *ctx_data,
|
|||
g_return_val_if_fail (ctx_data != NULL, FALSE);
|
||||
g_return_val_if_fail (error != NULL && *error == NULL, FALSE);
|
||||
|
||||
while (overrides != NULL)
|
||||
{
|
||||
GtkSourceContextReplace *repl = overrides->data;
|
||||
|
||||
g_return_val_if_fail (repl != NULL, FALSE);
|
||||
|
||||
if (!process_replace (ctx_data, repl->id, repl->replace_with, error))
|
||||
return FALSE;
|
||||
|
||||
overrides = overrides->next;
|
||||
}
|
||||
|
||||
data.ctx_data = ctx_data;
|
||||
data.error = NULL;
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@ G_BEGIN_DECLS
|
|||
#define GTK_SOURCE_CONTEXT_ENGINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_SOURCE_CONTEXT_ENGINE, GtkSourceContextEngineClass))
|
||||
|
||||
typedef struct _GtkSourceContextData GtkSourceContextData;
|
||||
typedef struct _GtkSourceContextReplace GtkSourceContextReplace;
|
||||
|
||||
typedef struct _GtkSourceContextEngine GtkSourceContextEngine;
|
||||
typedef struct _GtkSourceContextEngineClass GtkSourceContextEngineClass;
|
||||
typedef struct _GtkSourceContextEnginePrivate GtkSourceContextEnginePrivate;
|
||||
|
@ -63,7 +65,8 @@ typedef enum {
|
|||
|
||||
typedef enum {
|
||||
GTK_SOURCE_CONTEXT_IGNORE_STYLE = 1 << 0,
|
||||
GTK_SOURCE_CONTEXT_OVERRIDE_STYLE = 1 << 1
|
||||
GTK_SOURCE_CONTEXT_OVERRIDE_STYLE = 1 << 1,
|
||||
GTK_SOURCE_CONTEXT_REF_ORIGINAL = 1 << 2
|
||||
} GtkSourceContextRefOptions;
|
||||
|
||||
GType _gtk_source_context_engine_get_type (void) G_GNUC_CONST;
|
||||
|
@ -102,7 +105,13 @@ gboolean _gtk_source_context_data_add_ref (GtkSourceContextData *data,
|
|||
gboolean all,
|
||||
GError **error);
|
||||
|
||||
gboolean _gtk_source_context_data_resolve_refs (GtkSourceContextData *data,
|
||||
GtkSourceContextReplace *
|
||||
_gtk_source_context_replace_new (const gchar *to_replace_id,
|
||||
const gchar *replace_with_id);
|
||||
void _gtk_source_context_replace_free (GtkSourceContextReplace *repl);
|
||||
|
||||
gboolean _gtk_source_context_data_finish_parse (GtkSourceContextData *data,
|
||||
GList *overrides,
|
||||
GError **error);
|
||||
|
||||
/* Only for lang files version 1, do not use it */
|
||||
|
|
|
@ -86,6 +86,10 @@ struct _ParserState
|
|||
* mapping is id -> id */
|
||||
GHashTable *loaded_lang_ids;
|
||||
|
||||
/* The list of replacements. The queue object is owned by the caller,
|
||||
* so parser_state only adds stuff to it */
|
||||
GQueue *replacements;
|
||||
|
||||
/* A serial number incremented to get unique generated names */
|
||||
guint id_cookie;
|
||||
|
||||
|
@ -111,6 +115,7 @@ static ParserState *parser_state_new (GtkSourceLanguage *language
|
|||
GtkSourceContextData *ctx_data,
|
||||
GHashTable *defined_regexes,
|
||||
GHashTable *styles_mapping,
|
||||
GQueue *replacements,
|
||||
xmlTextReader *reader,
|
||||
GHashTable *loaded_lang_ids);
|
||||
static void parser_state_destroy (ParserState *parser_state);
|
||||
|
@ -121,6 +126,7 @@ static gboolean file_parse (gchar *filename
|
|||
GHashTable *defined_regexes,
|
||||
GHashTable *styles,
|
||||
GHashTable *loaded_lang_ids,
|
||||
GQueue *replacements,
|
||||
GError **error);
|
||||
|
||||
static GRegexCompileFlags
|
||||
|
@ -143,6 +149,7 @@ static void handle_define_regex_element (ParserState *parser_state,
|
|||
static void handle_default_regex_options_element
|
||||
(ParserState *parser_state,
|
||||
GError **error);
|
||||
static void handle_replace_element (ParserState *parser_state);
|
||||
static void element_start (ParserState *parser_state,
|
||||
GError **error);
|
||||
static void element_end (ParserState *parser_state);
|
||||
|
@ -517,6 +524,7 @@ add_ref (ParserState *parser_state,
|
|||
parser_state->defined_regexes,
|
||||
parser_state->styles_mapping,
|
||||
parser_state->loaded_lang_ids,
|
||||
parser_state->replacements,
|
||||
&tmp_error);
|
||||
|
||||
if (tmp_error != NULL)
|
||||
|
@ -689,6 +697,11 @@ handle_context_element (ParserState *parser_state,
|
|||
|
||||
if (ref != NULL)
|
||||
{
|
||||
tmp = xmlTextReaderGetAttribute (parser_state->reader, BAD_CAST "original");
|
||||
if (tmp != NULL && str_to_bool (tmp))
|
||||
options |= GTK_SOURCE_CONTEXT_REF_ORIGINAL;
|
||||
xmlFree (tmp);
|
||||
|
||||
if (style_ref != NULL)
|
||||
options |= GTK_SOURCE_CONTEXT_OVERRIDE_STYLE;
|
||||
|
||||
|
@ -757,6 +770,29 @@ handle_context_element (ParserState *parser_state,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
handle_replace_element (ParserState *parser_state)
|
||||
{
|
||||
xmlChar *id, *ref;
|
||||
GtkSourceContextReplace *repl;
|
||||
gchar *replace_with;
|
||||
|
||||
id = xmlTextReaderGetAttribute (parser_state->reader, BAD_CAST "id");
|
||||
ref = xmlTextReaderGetAttribute (parser_state->reader, BAD_CAST "ref");
|
||||
|
||||
if (id_is_decorated ((gchar*) ref, NULL))
|
||||
replace_with = g_strdup ((gchar *) ref);
|
||||
else
|
||||
replace_with = decorate_id (parser_state, (gchar*) ref);
|
||||
|
||||
repl = _gtk_source_context_replace_new ((const gchar *) id, replace_with);
|
||||
g_queue_push_tail (parser_state->replacements, repl);
|
||||
|
||||
g_free (replace_with);
|
||||
xmlFree (ref);
|
||||
xmlFree (id);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_language_element (ParserState *parser_state,
|
||||
GError **error)
|
||||
|
@ -1235,6 +1271,7 @@ parse_language_with_id (ParserState *parser_state,
|
|||
parser_state->defined_regexes,
|
||||
parser_state->styles_mapping,
|
||||
parser_state->loaded_lang_ids,
|
||||
parser_state->replacements,
|
||||
&tmp_error);
|
||||
}
|
||||
|
||||
|
@ -1420,6 +1457,10 @@ element_start (ParserState *parser_state,
|
|||
{
|
||||
handle_context_element (parser_state, &tmp_error);
|
||||
}
|
||||
else if (xmlStrcmp (BAD_CAST "replace", name) == 0)
|
||||
{
|
||||
handle_replace_element (parser_state);
|
||||
}
|
||||
else if (xmlStrcmp (BAD_CAST "define-regex", name) == 0)
|
||||
{
|
||||
handle_define_regex_element (parser_state, &tmp_error);
|
||||
|
@ -1456,7 +1497,7 @@ element_end (ParserState *parser_state)
|
|||
|
||||
name = xmlTextReaderConstName (parser_state->reader);
|
||||
|
||||
if (!xmlStrcmp (name, BAD_CAST "context"))
|
||||
if (xmlStrcmp (name, BAD_CAST "context") == 0)
|
||||
{
|
||||
/* pop the first element in the curr_parents list */
|
||||
popped_id = g_queue_pop_head (parser_state->curr_parents);
|
||||
|
@ -1484,6 +1525,7 @@ file_parse (gchar *filename,
|
|||
GHashTable *defined_regexes,
|
||||
GHashTable *styles,
|
||||
GHashTable *loaded_lang_ids,
|
||||
GQueue *replacements,
|
||||
GError **error)
|
||||
{
|
||||
ParserState *parser_state;
|
||||
|
@ -1539,7 +1581,8 @@ file_parse (gchar *filename,
|
|||
|
||||
parser_state = parser_state_new (language, ctx_data,
|
||||
defined_regexes, styles,
|
||||
reader, loaded_lang_ids);
|
||||
replacements, reader,
|
||||
loaded_lang_ids);
|
||||
xmlTextReaderSetStructuredErrorHandler (reader,
|
||||
(xmlStructuredErrorFunc) text_reader_structured_error_func,
|
||||
&tmp_error);
|
||||
|
@ -1589,11 +1632,12 @@ parser_state_new (GtkSourceLanguage *language,
|
|||
GtkSourceContextData *ctx_data,
|
||||
GHashTable *defined_regexes,
|
||||
GHashTable *styles_mapping,
|
||||
GQueue *replacements,
|
||||
xmlTextReader *reader,
|
||||
GHashTable *loaded_lang_ids)
|
||||
{
|
||||
ParserState *parser_state;
|
||||
parser_state = g_new (ParserState, 1);
|
||||
parser_state = g_slice_new (ParserState);
|
||||
|
||||
parser_state->language = language;
|
||||
parser_state->ctx_data = ctx_data;
|
||||
|
@ -1607,6 +1651,7 @@ parser_state_new (GtkSourceLanguage *language,
|
|||
|
||||
parser_state->defined_regexes = defined_regexes;
|
||||
parser_state->styles_mapping = styles_mapping;
|
||||
parser_state->replacements = replacements;
|
||||
|
||||
parser_state->loaded_lang_ids = loaded_lang_ids;
|
||||
|
||||
|
@ -1630,7 +1675,7 @@ parser_state_destroy (ParserState *parser_state)
|
|||
g_free (parser_state->opening_delimiter);
|
||||
g_free (parser_state->closing_delimiter);
|
||||
|
||||
g_free (parser_state);
|
||||
g_slice_free (ParserState, parser_state);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -1656,6 +1701,7 @@ _gtk_source_language_file_parse_version2 (GtkSourceLanguage *language,
|
|||
GError *error = NULL;
|
||||
gchar *filename;
|
||||
GHashTable *loaded_lang_ids;
|
||||
GQueue *replacements;
|
||||
|
||||
g_return_val_if_fail (ctx_data != NULL, FALSE);
|
||||
|
||||
|
@ -1677,19 +1723,23 @@ _gtk_source_language_file_parse_version2 (GtkSourceLanguage *language,
|
|||
loaded_lang_ids = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
(GDestroyNotify) xmlFree,
|
||||
NULL);
|
||||
replacements = g_queue_new ();
|
||||
|
||||
success = file_parse (filename, language, ctx_data,
|
||||
defined_regexes, styles,
|
||||
loaded_lang_ids, &error);
|
||||
loaded_lang_ids, replacements,
|
||||
&error);
|
||||
|
||||
if (success)
|
||||
success = _gtk_source_context_data_resolve_refs (ctx_data, &error);
|
||||
success = _gtk_source_context_data_finish_parse (ctx_data, replacements->head, &error);
|
||||
|
||||
if (success)
|
||||
g_hash_table_foreach_steal (styles,
|
||||
(GHRFunc) steal_styles_mapping,
|
||||
language->priv->styles);
|
||||
|
||||
g_queue_foreach (replacements, (GFunc) _gtk_source_context_replace_free, NULL);
|
||||
g_queue_free (replacements);
|
||||
g_hash_table_destroy (loaded_lang_ids);
|
||||
g_hash_table_destroy (defined_regexes);
|
||||
g_hash_table_destroy (styles);
|
||||
|
|
|
@ -326,15 +326,17 @@ ensure_languages (GtkSourceLanguageManager *lm)
|
|||
*
|
||||
* Gets a list of available languages for the given language manager.
|
||||
*
|
||||
* Returns: a list of #GtkSourceLanguage. Return value is owned by @lm and should
|
||||
* not be modified or freed.
|
||||
* Returns: a list of #GtkSourceLanguage objects. It must be freed with
|
||||
* g_slist_free(), but its elements must not be unref'ed.
|
||||
**/
|
||||
const GSList *
|
||||
gtk_source_language_manager_get_available_languages (GtkSourceLanguageManager *lm)
|
||||
GSList *
|
||||
gtk_source_language_manager_list_languages (GtkSourceLanguageManager *lm)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_SOURCE_LANGUAGE_MANAGER (lm), NULL);
|
||||
|
||||
ensure_languages (lm);
|
||||
return lm->priv->available_languages;
|
||||
|
||||
return g_slist_copy (lm->priv->available_languages);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -61,7 +61,8 @@ GType gtk_source_language_manager_get_type (void) G_GNUC_CONST;
|
|||
GtkSourceLanguageManager *gtk_source_language_manager_new (void);
|
||||
GtkSourceLanguageManager *gtk_source_language_manager_get_default (void);
|
||||
|
||||
const GSList *gtk_source_language_manager_get_available_languages (GtkSourceLanguageManager *lm);
|
||||
/* list must be freed, its elements no */
|
||||
GSList *gtk_source_language_manager_list_languages (GtkSourceLanguageManager *lm);
|
||||
|
||||
GtkSourceLanguage *gtk_source_language_manager_get_language_by_id (GtkSourceLanguageManager *lm,
|
||||
const gchar *id);
|
||||
|
|
|
@ -376,20 +376,17 @@ reload_if_needed (GtkSourceStyleManager *mgr)
|
|||
*
|
||||
* Returns the list of style schemes.
|
||||
*
|
||||
* Returns: a list of #GtkSourceStyleScheme objects. Returned value
|
||||
* is owned by @manager and must not be modified or freed. It may
|
||||
* become invalid when style schemes are added or removed, so copy
|
||||
* the list and reference its elements if you need to keep the list
|
||||
* around.
|
||||
* Returns: a list of #GtkSourceStyleScheme objects. It must be freed with
|
||||
* g_slist_free(), but its elements must not be unref'ed
|
||||
**/
|
||||
const GSList *
|
||||
GSList *
|
||||
gtk_source_style_manager_list_schemes (GtkSourceStyleManager *manager)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_SOURCE_STYLE_MANAGER (manager), NULL);
|
||||
|
||||
reload_if_needed (manager);
|
||||
|
||||
return manager->priv->schemes;
|
||||
return g_slist_copy (manager->priv->schemes);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -71,8 +71,8 @@ gchar **gtk_source_style_manager_get_search_path (GtkSourceStyleManager
|
|||
gboolean gtk_source_style_manager_add_scheme (GtkSourceStyleManager *manager,
|
||||
const gchar *filename);
|
||||
|
||||
/* Pointer to internal list, do not modify */
|
||||
const GSList *gtk_source_style_manager_list_schemes (GtkSourceStyleManager *manager);
|
||||
/* list must be freed, its elements no */
|
||||
GSList *gtk_source_style_manager_list_schemes (GtkSourceStyleManager *manager);
|
||||
|
||||
GtkSourceStyleScheme *gtk_source_style_manager_get_scheme (GtkSourceStyleManager *manager,
|
||||
const gchar *scheme_id);
|
||||
|
|
|
@ -356,7 +356,7 @@ static const gchar *
|
|||
get_color_by_name (GtkSourceStyleScheme *scheme,
|
||||
const gchar *name)
|
||||
{
|
||||
const char *color;
|
||||
const char *color = NULL;
|
||||
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
|
|
|
@ -16,6 +16,12 @@ case "$base" in
|
|||
# echo '#include "mooedit/moolang.h"'
|
||||
# custom_cmd="-e s/g_object_new.*GTK_TYPE_SOURCE_LANGUAGE/g_object_new(MOO_TYPE_LANG/g"
|
||||
# ;;
|
||||
gtksourcelanguage-parser-2.c)
|
||||
echo '#include <mooutils/mooutils-misc.h>'
|
||||
;;
|
||||
gtksourcecontextengine.c)
|
||||
echo '#include <mooutils/mooutils-misc.h>'
|
||||
;;
|
||||
gtksourcelanguage-parser-1.c)
|
||||
echo '#include <glib/gmappedfile.h>'
|
||||
;;
|
||||
|
@ -62,4 +68,7 @@ sed -e 's/#include \"gtksourcecontextengine.h\"/#include \"gtksourcecontextengin
|
|||
-e 's/_gtk_text_region/gtk_text_region/g' \
|
||||
-e 's/gtk_text_region/_moo_gtk_text_region/g' \
|
||||
\
|
||||
-e 's/g_slice_new/_moo_new/g' \
|
||||
-e 's/g_slice_free/_moo_free/g' \
|
||||
\
|
||||
$custom_cmd "$1" || exit $?
|
||||
|
|
|
@ -187,6 +187,9 @@
|
|||
<zeroOrMore>
|
||||
<ref name="define-regex"/>
|
||||
</zeroOrMore>
|
||||
<zeroOrMore>
|
||||
<ref name="replace-context"/>
|
||||
</zeroOrMore>
|
||||
</interleave>
|
||||
</element>
|
||||
</define>
|
||||
|
@ -407,13 +410,15 @@
|
|||
<attribute name="ignore-style">
|
||||
<ref name="boolean-value"/>
|
||||
</attribute>
|
||||
<attribute name="original">
|
||||
<ref name="boolean-value"/>
|
||||
</attribute>
|
||||
</choice>
|
||||
</optional>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
|
||||
|
||||
<define name="define-regex">
|
||||
<element name="define-regex">
|
||||
<attribute name="id">
|
||||
|
@ -424,4 +429,15 @@
|
|||
</element>
|
||||
</define>
|
||||
|
||||
<define name="replace-context">
|
||||
<element name="replace">
|
||||
<attribute name="id">
|
||||
<ref name="ref-type"/>
|
||||
</attribute>
|
||||
<attribute name="ref">
|
||||
<ref name="ref-type"/>
|
||||
</attribute>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
</grammar>
|
||||
|
|
|
@ -43,6 +43,14 @@
|
|||
</include>
|
||||
</context>
|
||||
|
||||
<context id="m4-quoted-shell">
|
||||
<start>\[</start>
|
||||
<end>\]</end>
|
||||
<include>
|
||||
<context ref="m4"/>
|
||||
</include>
|
||||
</context>
|
||||
|
||||
<context id="m4-function-call"><!-- style-ref="test:_violet"-->
|
||||
<start>(?<=[\w\d_])\((?!\))</start>
|
||||
<end>\)</end>
|
||||
|
@ -220,7 +228,7 @@
|
|||
</context>
|
||||
|
||||
<context id="func-ms">
|
||||
<start>\b(AC_DEFUN(_ONCE)?|AM_CONDITIONAL)\s*(\()</start>
|
||||
<start>\b(AC_DEFUN(_ONCE)?|AM_CONDITIONAL|glib_DEFUN|AC_CACHE_VAL|AC_SUBST)\s*(\()</start>
|
||||
<end>\)</end>
|
||||
<include>
|
||||
<context sub-pattern="1" where="start" style-ref="ac-macro"/>
|
||||
|
@ -230,8 +238,19 @@
|
|||
</include>
|
||||
</context>
|
||||
|
||||
<context id="func-ss">
|
||||
<start>\b(AC_OUTPUT_COMMANDS)\s*(\()</start>
|
||||
<end>\)</end>
|
||||
<include>
|
||||
<context sub-pattern="1" where="start" style-ref="ac-macro"/>
|
||||
<context sub-pattern="2" where="start" style-ref="ac-macro"/>
|
||||
<context sub-pattern="0" where="end" style-ref="ac-macro"/>
|
||||
<context ref="ARGS-SS"/>
|
||||
</include>
|
||||
</context>
|
||||
|
||||
<context id="func-mms">
|
||||
<start>\b(m4_foreach)\s*(\()</start>
|
||||
<start>\b(m4_foreach|AC_CACHE_CHECK)\s*(\()</start>
|
||||
<end>\)</end>
|
||||
<include>
|
||||
<context sub-pattern="1" where="start" style-ref="m4-macro"/>
|
||||
|
@ -264,13 +283,24 @@
|
|||
</context>
|
||||
|
||||
<context id="func-mss">
|
||||
<start>\b(AC_CONFIG_COMMANDS|AC_ENABLE|AC_WITH|AC_TRY_CPP|AC_CHECK_HEADER|AC_LINK_IFELSE)\s*(\()</start>
|
||||
<start>\b(AC_(CONFIG_COMMANDS|ENABLE|WITH|TRY_CPP|LINK_IFELSE|CHECK_FUNCS?))\s*(\()</start>
|
||||
<end>\)</end>
|
||||
<include>
|
||||
<context sub-pattern="1" where="start" style-ref="ac-macro"/>
|
||||
<context sub-pattern="3" where="start" style-ref="ac-macro"/>
|
||||
<context sub-pattern="0" where="end" style-ref="ac-macro"/>
|
||||
<context ref="ARGS-MSS"/>
|
||||
</include>
|
||||
</context>
|
||||
|
||||
<context id="func-mssm">
|
||||
<start>\b(AC_CHECK_HEADERS?)\s*(\()</start>
|
||||
<end>\)</end>
|
||||
<include>
|
||||
<context sub-pattern="1" where="start" style-ref="ac-macro"/>
|
||||
<context sub-pattern="2" where="start" style-ref="ac-macro"/>
|
||||
<context sub-pattern="0" where="end" style-ref="ac-macro"/>
|
||||
<context ref="ARGS-MSS"/>
|
||||
<context ref="ARGS-MSSM"/>
|
||||
</include>
|
||||
</context>
|
||||
|
||||
|
@ -279,8 +309,13 @@
|
|||
<context ref="m4-comment"/>
|
||||
<context ref="func-m"/>
|
||||
<context ref="func-ms"/>
|
||||
<context ref="func-ss"/>
|
||||
<context ref="func-mss"/>
|
||||
<context ref="func-mms"/>
|
||||
<context ref="func-mmss"/>
|
||||
<context ref="func-mssm"/>
|
||||
<context ref="func-mmssm"/>
|
||||
<context ref="ac-m4-macro"/>
|
||||
<context ref="m4-macro"/>
|
||||
<context ref="ac-macros-1"/>
|
||||
<context ref="ac-macros-2"/>
|
||||
|
@ -295,17 +330,28 @@
|
|||
</include>
|
||||
</context>
|
||||
|
||||
<context id="shell-line-comment" style-ref="sh:comment" end-at-line-end="true">
|
||||
<start>(?<!\S)#|(?<=\[)#</start>
|
||||
<include>
|
||||
<context ref="sh:line-comment" original="true"/>
|
||||
</include>
|
||||
</context>
|
||||
|
||||
<replace id="sh:sh" ref="m4"/>
|
||||
<replace id="sh:line-comment" ref="shell-line-comment"/>
|
||||
|
||||
<context id="m4">
|
||||
<include>
|
||||
<context ref="m4-quoted-shell"/>
|
||||
<context ref="m4-pure"/>
|
||||
<context ref="sh:sh"/>
|
||||
<context ref="sh:sh" original="true"/>
|
||||
<context id="bad-paren" extend-parent="false" style-ref="def:error">
|
||||
<match>\)</match>
|
||||
</context>
|
||||
</include>
|
||||
</context>
|
||||
|
||||
<context id="m4-macro" style-ref="m4-macro">
|
||||
<context id="ac-m4-macro" style-ref="m4-macro">
|
||||
<prefix>\bm4_</prefix>
|
||||
<keyword>append(_uniq)?</keyword>
|
||||
<keyword>bpatsubst</keyword>
|
||||
|
@ -349,6 +395,10 @@
|
|||
<keyword>wrap</keyword>
|
||||
</context>
|
||||
|
||||
<context id="m4-macro" style-ref="m4-macro">
|
||||
<keyword>define</keyword>
|
||||
</context>
|
||||
|
||||
<context id="ac-macros-1" style-ref="ac-macro">
|
||||
<prefix>\bAC_</prefix>
|
||||
<keyword>AC_PROG_MKDIR_P</keyword>
|
||||
|
@ -364,8 +414,8 @@
|
|||
<keyword>CHECK_ALIGNOF</keyword>
|
||||
<keyword>CHECK_DECL(S(_ONCE)?)?</keyword>
|
||||
<keyword>CHECK_FILES?</keyword>
|
||||
<keyword>CHECK_FUNC(S(_ONCE)?)?</keyword>
|
||||
<keyword>CHECK_HEADER(S(_ONCE)?)?</keyword>
|
||||
<keyword>CHECK_FUNCS_ONCE</keyword>
|
||||
<keyword>CHECK_HEADERS_ONCE</keyword>
|
||||
<keyword>CHECK_LIB</keyword>
|
||||
<keyword>CHECK_MEMBERS?</keyword>
|
||||
<keyword>CHECK_PROGS?</keyword>
|
||||
|
@ -535,7 +585,6 @@
|
|||
<keyword>STRUCT_TIMEZONE</keyword>
|
||||
<keyword>STRUCT_TM</keyword>
|
||||
<keyword>SUBST_FILE</keyword>
|
||||
<keyword>SUBST</keyword>
|
||||
<keyword>SYS_INTERPRETER</keyword>
|
||||
<keyword>SYS_LARGEFILE</keyword>
|
||||
<keyword>SYS_LONG_FILE_NAMES</keyword>
|
||||
|
|
|
@ -55,6 +55,15 @@
|
|||
<context ref="def:line-continue"/>
|
||||
</include>
|
||||
</context>
|
||||
<context id="subshell">
|
||||
<start>\(</start>
|
||||
<end>\)</end>
|
||||
<include>
|
||||
<context sub-pattern="0" where="start" style-ref="keyword"/>
|
||||
<context sub-pattern="0" where="end" style-ref="keyword"/>
|
||||
<context ref="sh"/>
|
||||
</include>
|
||||
</context>
|
||||
<context id="backtick-string" style-ref="function">
|
||||
<start>`</start>
|
||||
<end>`</end>
|
||||
|
@ -317,7 +326,7 @@
|
|||
<context sub-pattern="0" where="start" style-ref="keyword"/>
|
||||
<context sub-pattern="0" where="end" style-ref="keyword"/>
|
||||
<context style-ref="others">
|
||||
<match>[^\)\s]+\)|;;</match>
|
||||
<match>[^\)\s]+\s*\)|;;</match>
|
||||
</context>
|
||||
<context ref="sh"/>
|
||||
</include>
|
||||
|
@ -328,6 +337,7 @@
|
|||
<context ref="def:escape"/>
|
||||
<context ref="string"/>
|
||||
<context ref="string-2"/>
|
||||
<context ref="subshell"/>
|
||||
<context ref="backtick-string"/>
|
||||
<context ref="line-comment"/>
|
||||
<context ref="case"/>
|
||||
|
|
|
@ -530,7 +530,7 @@ get_lang_for_mime_type (MooLangMgr *mgr,
|
|||
static void
|
||||
read_langs (MooLangMgr *mgr)
|
||||
{
|
||||
const GSList *langs = NULL;
|
||||
GSList *langs = NULL;
|
||||
|
||||
if (mgr->got_langs)
|
||||
return;
|
||||
|
@ -540,7 +540,7 @@ read_langs (MooLangMgr *mgr)
|
|||
mgr->got_langs = TRUE;
|
||||
|
||||
#ifdef MOO_USE_XML
|
||||
langs = gtk_source_language_manager_get_available_languages (GTK_SOURCE_LANGUAGE_MANAGER (mgr));
|
||||
langs = gtk_source_language_manager_list_languages (GTK_SOURCE_LANGUAGE_MANAGER (mgr));
|
||||
#endif
|
||||
|
||||
get_lang_info (mgr, MOO_LANG_NONE, TRUE);
|
||||
|
@ -559,7 +559,7 @@ read_langs (MooLangMgr *mgr)
|
|||
if (!info->mime_types_modified)
|
||||
info->mime_types = _moo_lang_get_mime_types (lang);
|
||||
|
||||
langs = langs->next;
|
||||
langs = g_slist_delete_link (langs, langs);
|
||||
}
|
||||
|
||||
g_signal_emit_by_name (mgr, "loaded");
|
||||
|
@ -756,14 +756,14 @@ GSList *
|
|||
moo_lang_mgr_get_sections (MooLangMgr *mgr)
|
||||
{
|
||||
GSList *sections = NULL;
|
||||
const GSList *list = NULL;
|
||||
GSList *list = NULL;
|
||||
|
||||
g_return_val_if_fail (MOO_IS_LANG_MGR (mgr), NULL);
|
||||
|
||||
read_langs (mgr);
|
||||
|
||||
#ifdef MOO_USE_XML
|
||||
list = gtk_source_language_manager_get_available_languages (GTK_SOURCE_LANGUAGE_MANAGER (mgr));
|
||||
list = gtk_source_language_manager_list_languages (GTK_SOURCE_LANGUAGE_MANAGER (mgr));
|
||||
#endif
|
||||
|
||||
while (list)
|
||||
|
@ -771,7 +771,7 @@ moo_lang_mgr_get_sections (MooLangMgr *mgr)
|
|||
const char *section = _moo_lang_get_section (list->data);
|
||||
if (section && !g_slist_find_custom (sections, section, (GCompareFunc) strcmp))
|
||||
sections = g_slist_prepend (sections, g_strdup (section));
|
||||
list = list->next;
|
||||
list = g_slist_delete_link (list, list);
|
||||
}
|
||||
|
||||
return sections;
|
||||
|
@ -781,24 +781,19 @@ moo_lang_mgr_get_sections (MooLangMgr *mgr)
|
|||
GSList *
|
||||
moo_lang_mgr_get_available_langs (MooLangMgr *mgr)
|
||||
{
|
||||
GSList *langs = NULL;
|
||||
const GSList *list = NULL;
|
||||
GSList *list = NULL;
|
||||
|
||||
g_return_val_if_fail (MOO_IS_LANG_MGR (mgr), NULL);
|
||||
|
||||
read_langs (mgr);
|
||||
|
||||
#ifdef MOO_USE_XML
|
||||
list = gtk_source_language_manager_get_available_languages (GTK_SOURCE_LANGUAGE_MANAGER (mgr));
|
||||
list = gtk_source_language_manager_list_languages (GTK_SOURCE_LANGUAGE_MANAGER (mgr));
|
||||
#endif
|
||||
|
||||
while (list)
|
||||
{
|
||||
langs = g_slist_prepend (langs, g_object_ref (list->data));
|
||||
list = list->next;
|
||||
}
|
||||
g_slist_foreach (list, (GFunc) g_object_ref, NULL);
|
||||
|
||||
return g_slist_reverse (langs);
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue