Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Thu, 28 Apr 2016 23:35:21 UTC Commit: 6b262bb4ec041f4449d2736b38cf457ae9add822 https://github.com/geany/geany/commit/6b262bb4ec041f4449d2736b38cf457ae9add8...
Log Message: ----------- Make html_entities.tags a real tags file
This removes a fair amount of specific code that is just as well handled by the generic symbols completion code.
Modified Paths: -------------- data/tags/html_entities.tags src/editor.c src/symbols.c src/symbols.h src/utils.c src/utils.h
Modified: data/tags/html_entities.tags 3 lines changed, 1 insertions(+), 2 deletions(-) =================================================================== @@ -1,5 +1,4 @@ -# each of the following lines represent a html entity -# used in HTML and PHP files when typing &... +#format=tagmanager Á á Â
Modified: src/editor.c 48 lines changed, 4 insertions(+), 44 deletions(-) =================================================================== @@ -2076,56 +2076,16 @@ gchar *editor_get_calltip_text(GeanyEditor *editor, const TMTag *tag) }
-/* HTML entities auto completion from html_entities.tags text file */ -static gboolean -autocomplete_html(ScintillaObject *sci, const gchar *root, gsize rootlen) -{ - guint i; - gboolean found = FALSE; - GString *words; - const gchar **entities = symbols_get_html_entities(); - - if (*root != '&' || entities == NULL) - return FALSE; - - words = g_string_sized_new(500); - for (i = 0; ; i++) - { - if (entities[i] == NULL) - break; - else if (entities[i][0] == '#') - continue; - - if (! strncmp(entities[i], root, rootlen)) - { - if (words->len) - g_string_append_c(words, '\n'); - - g_string_append(words, entities[i]); - found = TRUE; - } - } - if (found) - show_autocomplete(sci, rootlen, words); - - g_string_free(words, TRUE); - return found; -} - - /* Current document & global tags autocompletion */ static gboolean -autocomplete_tags(GeanyEditor *editor, const gchar *root, gsize rootlen) +autocomplete_tags(GeanyEditor *editor, GeanyFiletype *ft, const gchar *root, gsize rootlen) { GPtrArray *tags; - GeanyDocument *doc; gboolean found;
g_return_val_if_fail(editor, FALSE);
- doc = editor->document; - - tags = tm_workspace_find_prefix(root, doc->file_type->lang, editor_prefs.autocompletion_max_entries); + tags = tm_workspace_find_prefix(root, ft->lang, editor_prefs.autocompletion_max_entries); found = tags->len > 0; if (found) show_tags_list(editor, tags, rootlen); @@ -2164,7 +2124,7 @@ static gboolean autocomplete_check_html(GeanyEditor *editor, gint style, gint po tmp = strchr(root, '&'); if (tmp != NULL) { - return autocomplete_html(editor->sci, tmp, strlen(tmp)); + return autocomplete_tags(editor, filetypes_index(GEANY_FILETYPES_HTML), tmp, strlen(tmp)); } } return FALSE; @@ -2338,7 +2298,7 @@ gboolean editor_start_auto_complete(GeanyEditor *editor, gint pos, gboolean forc { /* complete tags, except if forcing when completion is already visible */ if (!(force && SSM(sci, SCI_AUTOCACTIVE, 0, 0))) - ret = autocomplete_tags(editor, root, rootlen); + ret = autocomplete_tags(editor, editor->document->file_type, root, rootlen);
/* If forcing and there's nothing else to show, complete from words in document */ if (!ret && (force || editor_prefs.autocomplete_doc_words))
Modified: src/symbols.c 45 lines changed, 5 insertions(+), 40 deletions(-) =================================================================== @@ -64,8 +64,6 @@ #include <stdlib.h>
-static gchar **html_entities = NULL; - typedef struct { gboolean tags_loaded; @@ -138,7 +136,6 @@ static struct } symbol_menu;
-static void html_tags_loaded(void); static void load_user_tags(GeanyFiletypeID ft_id);
/* get the tags_ignore list, exported by tagmanager's options.c */ @@ -221,21 +218,19 @@ void symbols_global_tags_loaded(guint file_type_idx)
switch (file_type_idx) { - case GEANY_FILETYPES_PHP: - case GEANY_FILETYPES_HTML: - html_tags_loaded(); - } - switch (file_type_idx) - { case GEANY_FILETYPES_CPP: symbols_global_tags_loaded(GEANY_FILETYPES_C); /* load C global tags */ /* no C++ tagfile yet */ return; case GEANY_FILETYPES_C: tag_type = GTF_C; break; case GEANY_FILETYPES_PASCAL:tag_type = GTF_PASCAL; break; - case GEANY_FILETYPES_PHP: tag_type = GTF_PHP; break; case GEANY_FILETYPES_LATEX: tag_type = GTF_LATEX; break; case GEANY_FILETYPES_PYTHON:tag_type = GTF_PYTHON; break; + case GEANY_FILETYPES_HTML: tag_type = GTF_HTML_ENTITIES; break; + case GEANY_FILETYPES_PHP: + symbols_global_tags_loaded(GEANY_FILETYPES_HTML); /* load HTML global tags */ + tag_type = GTF_PHP; + break; default: return; } @@ -252,26 +247,6 @@ void symbols_global_tags_loaded(guint file_type_idx) }
-/* HTML tagfile is just a list of entities for autocompletion (e.g. '&') */ -static void html_tags_loaded(void) -{ - TagFileInfo *tfi; - - if (cl_options.ignore_global_tags) - return; - - tfi = &tag_file_info[GTF_HTML_ENTITIES]; - if (! tfi->tags_loaded) - { - gchar *file = g_build_filename(app->datadir, GEANY_TAGS_SUBDIR, tfi->tag_file, NULL); - - html_entities = utils_read_file_in_array(file); - tfi->tags_loaded = TRUE; - g_free(file); - } -} - - GString *symbols_find_typenames_as_string(TMParserType lang, gboolean global) { guint j; @@ -326,15 +301,6 @@ const gchar *symbols_get_context_separator(gint ft_id) }
-const gchar **symbols_get_html_entities(void) -{ - if (html_entities == NULL) - html_tags_loaded(); /* if not yet created, force creation of the array but shouldn't occur */ - - return (const gchar **) html_entities; -} - - /* sort by name, then line */ static gint compare_symbol(const TMTag *tag_a, const TMTag *tag_b) { @@ -2634,7 +2600,6 @@ void symbols_finalize(void) { guint i;
- g_strfreev(html_entities); g_strfreev(c_tags_ignore);
for (i = 0; i < G_N_ELEMENTS(symbols_icons); i++)
Modified: src/symbols.h 2 lines changed, 0 insertions(+), 2 deletions(-) =================================================================== @@ -52,8 +52,6 @@ void symbols_global_tags_loaded(guint file_type_idx);
GString *symbols_find_typenames_as_string(TMParserType lang, gboolean global);
-const gchar **symbols_get_html_entities(void); - gboolean symbols_recreate_tag_list(GeanyDocument *doc, gint sort_mode);
gint symbols_generate_global_tags(gint argc, gchar **argv, gboolean want_preprocess);
Modified: src/utils.c 19 lines changed, 0 insertions(+), 19 deletions(-) =================================================================== @@ -1060,25 +1060,6 @@ GIOChannel *utils_set_up_io_channel( }
-gchar **utils_read_file_in_array(const gchar *filename) -{ - gchar **result = NULL; - gchar *data; - - g_return_val_if_fail(filename != NULL, NULL); - - g_file_get_contents(filename, &data, NULL, NULL); - - if (data != NULL) - { - result = g_strsplit_set(data, "\r\n", -1); - g_free(data); - } - - return result; -} - - /* Contributed by Stefan Oltmanns, thanks. * Replaces \, \r, \n, \t and \uXXX by their real counterparts. * keep_backslash is used for regex strings to leave '\' and '?' in place */
Modified: src/utils.h 2 lines changed, 0 insertions(+), 2 deletions(-) =================================================================== @@ -289,8 +289,6 @@ gchar *utils_get_current_time_string(void); GIOChannel *utils_set_up_io_channel(gint fd, GIOCondition cond, gboolean nblock, GIOFunc func, gpointer data);
-gchar **utils_read_file_in_array(const gchar *filename); - gboolean utils_str_replace_escape(gchar *string, gboolean keep_backslash);
gboolean utils_wrap_string(gchar *string, gint wrapstart);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).