2006-10-02 11:31:54 +00:00
|
|
|
/*
|
|
|
|
* symbols.c - this file is part of Geany, a fast and lightweight IDE
|
|
|
|
*
|
2012-06-18 01:13:05 +02:00
|
|
|
* Copyright 2006-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
|
|
|
* Copyright 2006-2012 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
|
|
|
|
* Copyright 2011-2012 Colomban Wendling <ban(at)herbesfolles(dot)org>
|
2006-10-02 11:31:54 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
2012-08-24 19:25:57 +02:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2006-10-02 11:31:54 +00:00
|
|
|
*/
|
|
|
|
|
2010-05-05 16:26:25 +00:00
|
|
|
/**
|
|
|
|
* @file symbols.h
|
|
|
|
* Tag-related functions.
|
|
|
|
**/
|
|
|
|
|
2007-02-24 11:41:56 +00:00
|
|
|
/*
|
2008-11-03 17:25:35 +00:00
|
|
|
* Symbol Tree and TagManager-related convenience functions.
|
|
|
|
* TagManager parses tags for each document, and also adds them to the workspace (session).
|
|
|
|
* Global tags are lists of tags for each filetype, loaded when a document with a
|
2007-02-24 11:41:56 +00:00
|
|
|
* matching filetype is first loaded.
|
|
|
|
*/
|
|
|
|
|
2008-07-08 16:30:37 +00:00
|
|
|
#include "SciLexer.h"
|
2006-10-02 11:31:54 +00:00
|
|
|
#include "geany.h"
|
2006-11-08 11:42:05 +00:00
|
|
|
|
|
|
|
#include <ctype.h>
|
2007-01-13 13:25:05 +00:00
|
|
|
#include <string.h>
|
2007-03-21 13:26:16 +00:00
|
|
|
#include <stdlib.h>
|
2006-11-08 11:42:05 +00:00
|
|
|
|
2007-12-12 20:04:45 +00:00
|
|
|
#include "prefix.h"
|
2006-10-02 11:31:54 +00:00
|
|
|
#include "symbols.h"
|
|
|
|
#include "utils.h"
|
|
|
|
#include "filetypes.h"
|
2006-11-08 11:42:05 +00:00
|
|
|
#include "encodings.h"
|
|
|
|
#include "document.h"
|
2008-06-02 15:31:59 +00:00
|
|
|
#include "documentprivate.h"
|
2007-01-14 12:12:18 +00:00
|
|
|
#include "support.h"
|
2007-04-18 15:21:33 +00:00
|
|
|
#include "msgwindow.h"
|
2009-09-28 11:16:59 +00:00
|
|
|
#include "sidebar.h"
|
2007-08-23 11:34:06 +00:00
|
|
|
#include "main.h"
|
2007-09-25 12:39:41 +00:00
|
|
|
#include "navqueue.h"
|
|
|
|
#include "ui_utils.h"
|
2008-04-23 16:47:42 +00:00
|
|
|
#include "editor.h"
|
2008-07-08 16:30:37 +00:00
|
|
|
#include "sciwrappers.h"
|
2012-04-26 13:18:05 +01:00
|
|
|
#include "filetypesprivate.h"
|
2013-03-17 13:26:28 +00:00
|
|
|
#include "search.h"
|
2006-10-02 11:31:54 +00:00
|
|
|
|
2007-07-28 14:10:49 +00:00
|
|
|
|
2006-12-16 17:18:53 +00:00
|
|
|
const guint TM_GLOBAL_TYPE_MASK =
|
|
|
|
tm_tag_class_t | tm_tag_enum_t | tm_tag_interface_t |
|
2009-04-09 12:41:29 +00:00
|
|
|
tm_tag_struct_t | tm_tag_typedef_t | tm_tag_union_t | tm_tag_namespace_t;
|
2006-12-16 17:18:53 +00:00
|
|
|
|
|
|
|
|
2007-02-06 16:13:57 +00:00
|
|
|
static gchar **html_entities = NULL;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gboolean tags_loaded;
|
|
|
|
const gchar *tag_file;
|
|
|
|
} TagFileInfo;
|
|
|
|
|
2008-08-28 16:59:20 +00:00
|
|
|
/* Check before adding any more tags files, usually they should be downloaded separately. */
|
2008-02-27 13:17:29 +00:00
|
|
|
enum /* Geany tag files */
|
2006-10-02 11:31:54 +00:00
|
|
|
{
|
|
|
|
GTF_C,
|
|
|
|
GTF_PASCAL,
|
|
|
|
GTF_PHP,
|
|
|
|
GTF_HTML_ENTITIES,
|
|
|
|
GTF_LATEX,
|
2008-06-10 16:39:17 +00:00
|
|
|
GTF_PYTHON,
|
2006-10-02 11:31:54 +00:00
|
|
|
GTF_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
static TagFileInfo tag_file_info[GTF_MAX] =
|
|
|
|
{
|
2009-01-17 18:44:38 +00:00
|
|
|
{FALSE, "c99.tags"},
|
2006-10-02 11:31:54 +00:00
|
|
|
{FALSE, "pascal.tags"},
|
|
|
|
{FALSE, "php.tags"},
|
|
|
|
{FALSE, "html_entities.tags"},
|
2008-06-10 16:39:17 +00:00
|
|
|
{FALSE, "latex.tags"},
|
|
|
|
{FALSE, "python.tags"}
|
2006-10-02 11:31:54 +00:00
|
|
|
};
|
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
static GPtrArray *top_level_iter_names = NULL;
|
|
|
|
|
2008-11-20 16:52:46 +00:00
|
|
|
static struct
|
|
|
|
{
|
2008-11-21 13:06:09 +00:00
|
|
|
GtkWidget *expand_all;
|
|
|
|
GtkWidget *collapse_all;
|
2008-11-20 16:52:46 +00:00
|
|
|
GtkWidget *sort_by_name;
|
|
|
|
GtkWidget *sort_by_appearance;
|
2013-03-17 13:26:28 +00:00
|
|
|
GtkWidget *find_usage;
|
|
|
|
GtkWidget *find_doc_usage;
|
2013-03-25 15:41:52 +00:00
|
|
|
GtkWidget *find_in_files;
|
2008-11-20 16:52:46 +00:00
|
|
|
}
|
2013-03-17 13:26:28 +00:00
|
|
|
symbol_menu;
|
2008-11-20 16:52:46 +00:00
|
|
|
|
2006-10-02 11:31:54 +00:00
|
|
|
|
2008-02-20 11:24:23 +00:00
|
|
|
static void html_tags_loaded(void);
|
2007-05-11 11:58:56 +00:00
|
|
|
static void load_user_tags(filetype_id ft_id);
|
2006-10-02 11:31:54 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* get the tags_ignore list, exported by tagmanager's options.c */
|
2008-02-24 10:18:36 +00:00
|
|
|
extern gchar **c_tags_ignore;
|
2008-02-18 19:51:34 +00:00
|
|
|
|
2008-11-25 12:09:08 +00:00
|
|
|
/* ignore certain tokens when parsing C-like syntax.
|
|
|
|
* Also works for reloading. */
|
2008-02-20 11:24:23 +00:00
|
|
|
static void load_c_ignore_tags(void)
|
2008-02-18 19:51:34 +00:00
|
|
|
{
|
2012-08-09 18:15:47 -07:00
|
|
|
gchar *path = g_build_filename(app->configdir, "ignore.tags", NULL);
|
2008-02-18 19:51:34 +00:00
|
|
|
gchar *content;
|
|
|
|
|
|
|
|
if (g_file_get_contents(path, &content, NULL, NULL))
|
|
|
|
{
|
2012-04-23 16:58:55 +01:00
|
|
|
/* historically we ignore the glib _DECLS for tag generation */
|
|
|
|
SETPTR(content, g_strconcat("G_BEGIN_DECLS G_END_DECLS\n", content, NULL));
|
|
|
|
|
2008-11-25 12:09:08 +00:00
|
|
|
g_strfreev(c_tags_ignore);
|
2008-02-18 19:51:34 +00:00
|
|
|
c_tags_ignore = g_strsplit_set(content, " \n\r", -1);
|
|
|
|
g_free(content);
|
|
|
|
}
|
|
|
|
g_free(path);
|
|
|
|
}
|
|
|
|
|
2006-10-02 11:31:54 +00:00
|
|
|
|
2008-11-25 12:09:08 +00:00
|
|
|
void symbols_reload_config_files(void)
|
|
|
|
{
|
|
|
|
load_c_ignore_tags();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-25 17:43:39 +00:00
|
|
|
static gsize get_tag_count(void)
|
2009-05-01 15:04:46 +00:00
|
|
|
{
|
|
|
|
GPtrArray *tags = tm_get_workspace()->global_tags;
|
|
|
|
gsize count = tags ? tags->len : 0;
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* wrapper for tm_workspace_load_global_tags().
|
|
|
|
* note that the tag count only counts new global tags added - if a tag has the same name,
|
|
|
|
* currently it replaces the existing tag, so loading a file twice will say 0 tags the 2nd time. */
|
|
|
|
static gboolean symbols_load_global_tags(const gchar *tags_file, GeanyFiletype *ft)
|
|
|
|
{
|
|
|
|
gboolean result;
|
|
|
|
gsize old_tag_count = get_tag_count();
|
|
|
|
|
|
|
|
result = tm_workspace_load_global_tags(tags_file, ft->lang);
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
geany_debug("Loaded %s (%s), %u tag(s).", tags_file, ft->name,
|
2009-05-13 22:17:30 +00:00
|
|
|
(guint) (get_tag_count() - old_tag_count));
|
2009-05-01 15:04:46 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-26 17:11:49 +00:00
|
|
|
/* Ensure that the global tags file(s) for the file_type_idx filetype is loaded.
|
|
|
|
* This provides autocompletion, calltips, etc. */
|
2011-11-06 01:12:42 +01:00
|
|
|
void symbols_global_tags_loaded(guint file_type_idx)
|
2006-10-02 11:31:54 +00:00
|
|
|
{
|
|
|
|
TagFileInfo *tfi;
|
2007-02-06 16:13:57 +00:00
|
|
|
gint tag_type;
|
2006-10-02 11:31:54 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* load ignore list for C/C++ parser */
|
2008-02-18 19:51:34 +00:00
|
|
|
if ((file_type_idx == GEANY_FILETYPES_C || file_type_idx == GEANY_FILETYPES_CPP) &&
|
|
|
|
c_tags_ignore == NULL)
|
|
|
|
{
|
|
|
|
load_c_ignore_tags();
|
|
|
|
}
|
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (cl_options.ignore_global_tags || app->tm_workspace == NULL)
|
2008-02-26 17:11:49 +00:00
|
|
|
return;
|
|
|
|
|
2009-10-20 12:07:12 +00:00
|
|
|
/* load config in case of custom filetypes */
|
|
|
|
filetypes_load_config(file_type_idx, FALSE);
|
|
|
|
|
2008-02-26 17:11:49 +00:00
|
|
|
load_user_tags(file_type_idx);
|
|
|
|
|
2006-10-02 11:31:54 +00:00
|
|
|
switch (file_type_idx)
|
|
|
|
{
|
2007-03-26 12:18:51 +00:00
|
|
|
case GEANY_FILETYPES_PHP:
|
2006-10-02 11:31:54 +00:00
|
|
|
case GEANY_FILETYPES_HTML:
|
|
|
|
html_tags_loaded();
|
2007-03-26 12:18:51 +00:00
|
|
|
}
|
|
|
|
switch (file_type_idx)
|
|
|
|
{
|
2007-02-06 16:13:57 +00:00
|
|
|
case GEANY_FILETYPES_CPP:
|
2008-02-27 13:17:29 +00:00
|
|
|
symbols_global_tags_loaded(GEANY_FILETYPES_C); /* load C global tags */
|
|
|
|
/* no C++ tagfile yet */
|
2007-03-26 12:18:51 +00:00
|
|
|
return;
|
2007-02-06 16:13:57 +00:00
|
|
|
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;
|
2008-06-10 16:39:17 +00:00
|
|
|
case GEANY_FILETYPES_PYTHON:tag_type = GTF_PYTHON; break;
|
2006-10-02 11:31:54 +00:00
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
2007-02-06 16:13:57 +00:00
|
|
|
tfi = &tag_file_info[tag_type];
|
2006-10-02 11:31:54 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (! tfi->tags_loaded)
|
2006-10-02 11:31:54 +00:00
|
|
|
{
|
2012-08-09 18:15:47 -07:00
|
|
|
gchar *fname = g_build_filename(app->datadir, tfi->tag_file, NULL);
|
2007-02-06 16:13:57 +00:00
|
|
|
|
2009-05-01 15:04:46 +00:00
|
|
|
symbols_load_global_tags(fname, filetypes[file_type_idx]);
|
2006-10-02 11:31:54 +00:00
|
|
|
tfi->tags_loaded = TRUE;
|
2007-02-06 16:13:57 +00:00
|
|
|
g_free(fname);
|
2006-10-02 11:31:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* HTML tagfile is just a list of entities for autocompletion (e.g. '&') */
|
2008-02-20 11:24:23 +00:00
|
|
|
static void html_tags_loaded(void)
|
2006-10-02 11:31:54 +00:00
|
|
|
{
|
|
|
|
TagFileInfo *tfi;
|
|
|
|
|
2009-04-05 21:07:40 +00:00
|
|
|
if (cl_options.ignore_global_tags)
|
|
|
|
return;
|
2006-10-02 11:31:54 +00:00
|
|
|
|
|
|
|
tfi = &tag_file_info[GTF_HTML_ENTITIES];
|
2009-04-15 22:47:33 +00:00
|
|
|
if (! tfi->tags_loaded)
|
2006-10-02 11:31:54 +00:00
|
|
|
{
|
2012-08-09 18:15:47 -07:00
|
|
|
gchar *file = g_build_filename(app->datadir, tfi->tag_file, NULL);
|
2007-02-06 16:13:57 +00:00
|
|
|
|
2006-10-02 11:31:54 +00:00
|
|
|
html_entities = utils_read_file_in_array(file);
|
|
|
|
tfi->tags_loaded = TRUE;
|
|
|
|
g_free(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-09 12:04:15 +00:00
|
|
|
GString *symbols_find_tags_as_string(GPtrArray *tags_array, guint tag_types, gint lang)
|
2006-10-02 11:31:54 +00:00
|
|
|
{
|
2006-11-08 11:42:05 +00:00
|
|
|
guint j;
|
2007-10-09 12:04:15 +00:00
|
|
|
TMTag *tag;
|
2006-10-02 11:31:54 +00:00
|
|
|
GString *s = NULL;
|
2006-11-08 11:42:05 +00:00
|
|
|
GPtrArray *typedefs;
|
2009-04-09 12:41:29 +00:00
|
|
|
gint tag_lang;
|
2006-10-02 11:31:54 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_val_if_fail(tags_array != NULL, NULL);
|
2006-10-02 11:31:54 +00:00
|
|
|
|
2006-11-08 11:42:05 +00:00
|
|
|
typedefs = tm_tags_extract(tags_array, tag_types);
|
|
|
|
|
|
|
|
if ((typedefs) && (typedefs->len > 0))
|
|
|
|
{
|
|
|
|
s = g_string_sized_new(typedefs->len * 10);
|
|
|
|
for (j = 0; j < typedefs->len; ++j)
|
2006-10-02 11:31:54 +00:00
|
|
|
{
|
2007-10-09 12:04:15 +00:00
|
|
|
tag = TM_TAG(typedefs->pdata[j]);
|
2009-04-09 12:41:29 +00:00
|
|
|
/* tag->atts.file.lang contains (for some reason) the line of the tag if
|
|
|
|
* tag->atts.entry.file is not NULL */
|
|
|
|
tag_lang = (tag->atts.entry.file) ? tag->atts.entry.file->lang : tag->atts.file.lang;
|
|
|
|
|
|
|
|
/* the check for tag_lang == lang is necessary to avoid wrong type colouring of
|
|
|
|
* e.g. PHP classes in C++ files
|
|
|
|
* lang = -2 disables the check */
|
|
|
|
if (tag->name && (tag_lang == lang || lang == -2))
|
2006-10-02 11:31:54 +00:00
|
|
|
{
|
2009-04-09 12:41:29 +00:00
|
|
|
if (j != 0)
|
|
|
|
g_string_append_c(s, ' ');
|
|
|
|
g_string_append(s, tag->name);
|
2006-10-02 11:31:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-03-24 17:24:39 +00:00
|
|
|
if (typedefs)
|
|
|
|
g_ptr_array_free(typedefs, TRUE);
|
2006-10-02 11:31:54 +00:00
|
|
|
return s;
|
|
|
|
}
|
2006-11-08 11:42:05 +00:00
|
|
|
|
|
|
|
|
2010-05-05 16:26:25 +00:00
|
|
|
/** Gets the context separator used by the tag manager for a particular file
|
|
|
|
* type.
|
|
|
|
* @param ft_id File type identifier.
|
|
|
|
* @return The context separator string.
|
|
|
|
*
|
|
|
|
* @since 0.19
|
|
|
|
*/
|
2007-08-15 15:37:21 +00:00
|
|
|
const gchar *symbols_get_context_separator(gint ft_id)
|
2007-01-12 12:33:17 +00:00
|
|
|
{
|
|
|
|
switch (ft_id)
|
|
|
|
{
|
2008-02-27 13:17:29 +00:00
|
|
|
case GEANY_FILETYPES_C: /* for C++ .h headers or C structs */
|
2007-01-12 12:33:17 +00:00
|
|
|
case GEANY_FILETYPES_CPP:
|
2008-08-27 12:44:54 +00:00
|
|
|
case GEANY_FILETYPES_GLSL: /* for structs */
|
2008-02-27 13:17:29 +00:00
|
|
|
/*case GEANY_FILETYPES_RUBY:*/ /* not sure what to use atm*/
|
2009-06-01 15:21:55 +00:00
|
|
|
return "::";
|
2007-01-12 12:33:17 +00:00
|
|
|
|
2009-06-02 14:45:23 +00:00
|
|
|
/* avoid confusion with other possible separators in group/section name */
|
|
|
|
case GEANY_FILETYPES_CONF:
|
|
|
|
case GEANY_FILETYPES_REST:
|
|
|
|
return ":::";
|
|
|
|
|
2007-01-12 12:33:17 +00:00
|
|
|
default:
|
2009-06-01 15:21:55 +00:00
|
|
|
return ".";
|
2007-01-12 12:33:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-07 22:09:08 +00:00
|
|
|
GString *symbols_get_macro_list(gint lang)
|
2006-11-08 11:42:05 +00:00
|
|
|
{
|
|
|
|
guint j, i;
|
|
|
|
GPtrArray *ftags;
|
|
|
|
GString *words;
|
2009-04-07 22:09:08 +00:00
|
|
|
gint tag_lang;
|
|
|
|
TMTag *tag;
|
2006-11-08 11:42:05 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (app->tm_workspace->work_objects == NULL)
|
2007-03-24 12:10:43 +00:00
|
|
|
return NULL;
|
|
|
|
|
2006-11-08 11:42:05 +00:00
|
|
|
ftags = g_ptr_array_sized_new(50);
|
|
|
|
words = g_string_sized_new(200);
|
|
|
|
|
|
|
|
for (j = 0; j < app->tm_workspace->work_objects->len; j++)
|
|
|
|
{
|
2008-03-24 17:24:39 +00:00
|
|
|
GPtrArray *tags;
|
|
|
|
|
2006-11-08 11:42:05 +00:00
|
|
|
tags = tm_tags_extract(TM_WORK_OBJECT(app->tm_workspace->work_objects->pdata[j])->tags_array,
|
|
|
|
tm_tag_enum_t | tm_tag_variable_t | tm_tag_macro_t | tm_tag_macro_with_arg_t);
|
|
|
|
if (NULL != tags)
|
|
|
|
{
|
2008-08-29 17:00:02 +00:00
|
|
|
for (i = 0; ((i < tags->len) && (i < editor_prefs.autocompletion_max_entries)); ++i)
|
2006-11-08 11:42:05 +00:00
|
|
|
{
|
2009-04-07 22:09:08 +00:00
|
|
|
tag = TM_TAG(tags->pdata[i]);
|
|
|
|
tag_lang = (tag->atts.entry.file) ?
|
|
|
|
tag->atts.entry.file->lang : tag->atts.file.lang;
|
|
|
|
|
|
|
|
if (tag_lang == lang)
|
|
|
|
g_ptr_array_add(ftags, (gpointer) tags->pdata[i]);
|
2006-11-08 11:42:05 +00:00
|
|
|
}
|
2008-03-24 17:24:39 +00:00
|
|
|
g_ptr_array_free(tags, TRUE);
|
2006-11-08 11:42:05 +00:00
|
|
|
}
|
|
|
|
}
|
2009-04-07 22:09:08 +00:00
|
|
|
|
|
|
|
if (ftags->len == 0)
|
|
|
|
{
|
|
|
|
g_ptr_array_free(ftags, TRUE);
|
|
|
|
g_string_free(words, TRUE);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-11-08 11:42:05 +00:00
|
|
|
tm_tags_sort(ftags, NULL, FALSE);
|
|
|
|
for (j = 0; j < ftags->len; j++)
|
|
|
|
{
|
2009-04-05 21:07:40 +00:00
|
|
|
if (j > 0)
|
|
|
|
g_string_append_c(words, '\n');
|
2006-11-08 11:42:05 +00:00
|
|
|
g_string_append(words, TM_TAG(ftags->pdata[j])->name);
|
|
|
|
}
|
|
|
|
g_ptr_array_free(ftags, TRUE);
|
|
|
|
return words;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-27 13:18:15 +00:00
|
|
|
/* Note: if tags is sorted, we can use bsearch or tm_tags_find() to speed this up. */
|
2006-11-08 11:42:05 +00:00
|
|
|
static TMTag *
|
|
|
|
symbols_find_tm_tag(const GPtrArray *tags, const gchar *tag_name)
|
|
|
|
{
|
|
|
|
guint i;
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_val_if_fail(tags != NULL, NULL);
|
2006-11-08 11:42:05 +00:00
|
|
|
|
|
|
|
for (i = 0; i < tags->len; ++i)
|
|
|
|
{
|
2006-12-07 16:09:45 +00:00
|
|
|
if (utils_str_equal(TM_TAG(tags->pdata[i])->name, tag_name))
|
2006-11-08 11:42:05 +00:00
|
|
|
return TM_TAG(tags->pdata[i]);
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-24 16:44:43 +00:00
|
|
|
static TMTag *find_work_object_tag(const TMWorkObject *workobj,
|
2011-12-17 23:10:03 +01:00
|
|
|
const gchar *tag_name, guint type)
|
2006-11-08 11:42:05 +00:00
|
|
|
{
|
2008-03-24 17:24:39 +00:00
|
|
|
GPtrArray *tags;
|
2006-11-08 11:42:05 +00:00
|
|
|
TMTag *tmtag;
|
|
|
|
|
2009-04-05 21:07:40 +00:00
|
|
|
if (G_LIKELY(workobj != NULL))
|
2006-11-08 11:42:05 +00:00
|
|
|
{
|
2008-03-24 16:44:43 +00:00
|
|
|
tags = tm_tags_extract(workobj->tags_array, type);
|
|
|
|
if (tags != NULL)
|
2006-11-08 11:42:05 +00:00
|
|
|
{
|
2008-03-24 16:44:43 +00:00
|
|
|
tmtag = symbols_find_tm_tag(tags, tag_name);
|
2008-03-24 17:24:39 +00:00
|
|
|
|
|
|
|
g_ptr_array_free(tags, TRUE);
|
|
|
|
|
2008-03-24 16:44:43 +00:00
|
|
|
if (tmtag != NULL)
|
|
|
|
return tmtag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL; /* not found */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-12-17 23:10:03 +01:00
|
|
|
static TMTag *find_workspace_tag(const gchar *tag_name, guint type)
|
2008-03-24 16:44:43 +00:00
|
|
|
{
|
|
|
|
guint j;
|
2008-04-08 15:21:54 +00:00
|
|
|
const GPtrArray *work_objects = NULL;
|
2008-03-24 16:44:43 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (app->tm_workspace != NULL)
|
2008-03-24 16:44:43 +00:00
|
|
|
work_objects = app->tm_workspace->work_objects;
|
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (work_objects != NULL)
|
2008-03-24 16:44:43 +00:00
|
|
|
{
|
|
|
|
for (j = 0; j < work_objects->len; j++)
|
|
|
|
{
|
|
|
|
TMWorkObject *workobj = TM_WORK_OBJECT(work_objects->pdata[j]);
|
|
|
|
TMTag *tmtag;
|
|
|
|
|
2008-03-24 17:02:50 +00:00
|
|
|
tmtag = find_work_object_tag(workobj, tag_name, type);
|
2006-11-08 11:42:05 +00:00
|
|
|
if (tmtag != NULL)
|
|
|
|
return tmtag;
|
|
|
|
}
|
|
|
|
}
|
2008-02-27 13:17:29 +00:00
|
|
|
return NULL; /* not found */
|
2006-11-08 11:42:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-20 11:24:23 +00:00
|
|
|
const gchar **symbols_get_html_entities(void)
|
2006-12-15 17:09:05 +00:00
|
|
|
{
|
2009-04-15 22:47:33 +00:00
|
|
|
if (html_entities == NULL)
|
2008-02-27 13:17:29 +00:00
|
|
|
html_tags_loaded(); /* if not yet created, force creation of the array but shouldn't occur */
|
2006-12-15 17:09:05 +00:00
|
|
|
|
2007-03-26 12:18:51 +00:00
|
|
|
return (const gchar **) html_entities;
|
2006-12-15 17:09:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
/* sort by name, then line */
|
|
|
|
static gint compare_symbol(const TMTag *tag_a, const TMTag *tag_b)
|
2007-01-13 13:25:05 +00:00
|
|
|
{
|
2007-04-23 15:15:13 +00:00
|
|
|
gint ret;
|
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
if (tag_a == NULL || tag_b == NULL)
|
|
|
|
return 0;
|
2007-01-13 13:25:05 +00:00
|
|
|
|
2009-02-18 14:57:58 +00:00
|
|
|
if (tag_a->name == NULL)
|
2011-08-06 18:34:14 +00:00
|
|
|
return -(tag_a->name != tag_b->name);
|
2009-02-18 14:57:58 +00:00
|
|
|
|
|
|
|
if (tag_b->name == NULL)
|
2011-08-06 18:34:14 +00:00
|
|
|
return tag_a->name != tag_b->name;
|
2009-02-18 14:57:58 +00:00
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
ret = strcmp(tag_a->name, tag_b->name);
|
2007-04-23 15:15:13 +00:00
|
|
|
if (ret == 0)
|
|
|
|
{
|
2008-11-03 17:25:35 +00:00
|
|
|
return tag_a->atts.entry.line - tag_b->atts.entry.line;
|
2007-04-23 15:15:13 +00:00
|
|
|
}
|
|
|
|
return ret;
|
2007-01-13 13:25:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-06 17:25:15 +00:00
|
|
|
/* sort by line, then scope */
|
2008-11-03 17:25:35 +00:00
|
|
|
static gint compare_symbol_lines(gconstpointer a, gconstpointer b)
|
2007-08-16 17:19:16 +00:00
|
|
|
{
|
2008-11-03 17:25:35 +00:00
|
|
|
const TMTag *tag_a = TM_TAG(a);
|
|
|
|
const TMTag *tag_b = TM_TAG(b);
|
2011-03-06 17:25:15 +00:00
|
|
|
gint ret;
|
2007-08-16 17:19:16 +00:00
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
if (a == NULL || b == NULL)
|
|
|
|
return 0;
|
|
|
|
|
2011-03-06 17:25:15 +00:00
|
|
|
ret = tag_a->atts.entry.line - tag_b->atts.entry.line;
|
|
|
|
if (ret == 0)
|
|
|
|
{
|
|
|
|
if (tag_a->atts.entry.scope == NULL)
|
|
|
|
return -(tag_a->atts.entry.scope != tag_b->atts.entry.scope);
|
|
|
|
if (tag_b->atts.entry.scope == NULL)
|
|
|
|
return tag_a->atts.entry.scope != tag_b->atts.entry.scope;
|
|
|
|
else
|
|
|
|
return strcmp(tag_a->atts.entry.scope, tag_b->atts.entry.scope);
|
|
|
|
}
|
|
|
|
return ret;
|
2007-08-16 17:19:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
static GList *get_tag_list(GeanyDocument *doc, guint tag_types)
|
2007-01-13 13:25:05 +00:00
|
|
|
{
|
2008-11-03 17:25:35 +00:00
|
|
|
GList *tag_names = NULL;
|
|
|
|
TMTag *tag;
|
|
|
|
guint i;
|
2007-01-13 13:25:05 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_val_if_fail(doc, NULL);
|
2007-04-23 15:15:13 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (! doc->tm_file || ! doc->tm_file->tags_array)
|
2008-11-03 17:25:35 +00:00
|
|
|
return NULL;
|
2007-07-31 17:07:33 +00:00
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
for (i = 0; i < doc->tm_file->tags_array->len; ++i)
|
|
|
|
{
|
|
|
|
tag = TM_TAG(doc->tm_file->tags_array->pdata[i]);
|
2009-04-05 21:07:40 +00:00
|
|
|
if (G_UNLIKELY(tag == NULL))
|
2008-11-03 17:25:35 +00:00
|
|
|
return NULL;
|
2007-04-23 15:15:13 +00:00
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
if (tag->type & tag_types)
|
|
|
|
{
|
2011-03-10 22:27:04 +00:00
|
|
|
tag_names = g_list_prepend(tag_names, tag);
|
2007-01-13 13:25:05 +00:00
|
|
|
}
|
|
|
|
}
|
2008-11-03 17:25:35 +00:00
|
|
|
tag_names = g_list_sort(tag_names, compare_symbol_lines);
|
|
|
|
return tag_names;
|
2007-01-13 13:25:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* amount of types in the symbol list (currently max. 8 are used) */
|
2007-09-17 15:28:27 +00:00
|
|
|
#define MAX_SYMBOL_TYPES (sizeof(tv_iters) / sizeof(GtkTreeIter))
|
|
|
|
|
2007-01-14 12:12:18 +00:00
|
|
|
struct TreeviewSymbols
|
|
|
|
{
|
|
|
|
GtkTreeIter tag_function;
|
|
|
|
GtkTreeIter tag_class;
|
|
|
|
GtkTreeIter tag_macro;
|
|
|
|
GtkTreeIter tag_member;
|
|
|
|
GtkTreeIter tag_variable;
|
|
|
|
GtkTreeIter tag_namespace;
|
|
|
|
GtkTreeIter tag_struct;
|
2012-01-06 13:39:26 +00:00
|
|
|
GtkTreeIter tag_interface;
|
2007-09-17 15:28:27 +00:00
|
|
|
GtkTreeIter tag_type;
|
2007-01-14 12:12:18 +00:00
|
|
|
GtkTreeIter tag_other;
|
|
|
|
} tv_iters;
|
|
|
|
|
2007-01-15 11:48:14 +00:00
|
|
|
|
2008-02-20 11:24:23 +00:00
|
|
|
static void init_tag_iters(void)
|
2007-01-14 12:12:18 +00:00
|
|
|
{
|
2008-02-27 13:17:29 +00:00
|
|
|
/* init all GtkTreeIters with -1 to make them invalid to avoid crashes when switching between
|
|
|
|
* filetypes(e.g. config file to Python crashes Geany without this) */
|
2007-01-14 12:12:18 +00:00
|
|
|
tv_iters.tag_function.stamp = -1;
|
|
|
|
tv_iters.tag_class.stamp = -1;
|
|
|
|
tv_iters.tag_member.stamp = -1;
|
|
|
|
tv_iters.tag_macro.stamp = -1;
|
|
|
|
tv_iters.tag_variable.stamp = -1;
|
|
|
|
tv_iters.tag_namespace.stamp = -1;
|
|
|
|
tv_iters.tag_struct.stamp = -1;
|
2012-01-06 13:39:26 +00:00
|
|
|
tv_iters.tag_interface.stamp = -1;
|
2007-09-17 15:28:27 +00:00
|
|
|
tv_iters.tag_type.stamp = -1;
|
2007-01-14 12:12:18 +00:00
|
|
|
tv_iters.tag_other.stamp = -1;
|
2007-01-15 11:48:14 +00:00
|
|
|
}
|
2007-01-14 12:12:18 +00:00
|
|
|
|
2007-01-15 11:48:14 +00:00
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
static GdkPixbuf *get_tag_icon(const gchar *icon_name)
|
2007-05-23 12:32:06 +00:00
|
|
|
{
|
2007-07-22 14:38:47 +00:00
|
|
|
static GtkIconTheme *icon_theme = NULL;
|
2012-10-15 15:23:30 +02:00
|
|
|
static gint x = -1;
|
2007-07-22 14:38:47 +00:00
|
|
|
|
2012-10-15 15:23:30 +02:00
|
|
|
if (G_UNLIKELY(x < 0))
|
2007-07-22 14:38:47 +00:00
|
|
|
{
|
2012-10-15 15:23:30 +02:00
|
|
|
gint dummy;
|
2007-07-22 14:38:47 +00:00
|
|
|
icon_theme = gtk_icon_theme_get_default();
|
2012-10-15 15:23:30 +02:00
|
|
|
gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &x, &dummy);
|
2007-07-22 14:38:47 +00:00
|
|
|
}
|
2008-11-03 17:25:35 +00:00
|
|
|
return gtk_icon_theme_load_icon(icon_theme, icon_name, x, 0, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Update the symbol list rather than clearing and re-building it
The main advantages of not clearing and rebuilding the whole list is
that it doesn't loose the folding and selection (as far as the selected
row(s) still exist after the update, of course), and it reduces
flickering upon update.
The current implementation works in 3-steps:
1) mark all rows as invalid;
2) insert/update the rows, according to the new tag list, marking them
as valid;
3) remove all rows that are still invalid.
This walks (rows) the first time, (tags*rows) the second and (rows) the
third. This also uses an extra column to store the row's validity.
A (probably) better implementation would be to:
1) walk the current rows, updating them if necessary, or removing them;
2) add the remaining tags that weren't there before.
This is probably faster in theory (and probably also in practice), but
it needs to refactor a lot the code to easily update *or* create a row,
what the current code does not provide.
Basically this is would be a two-pass update, walking (rows*tags) in
the first pass, and only the remaining non-added tags in the second.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5562 ea778897-0a13-0410-b9d1-a72fbfd435f5
2011-03-05 22:53:13 +00:00
|
|
|
/* finds the next iter at any level
|
|
|
|
* @param iter in/out, the current iter, will be changed to the next one
|
2011-11-18 21:35:24 +01:00
|
|
|
* @param down whether to try the child iter
|
Update the symbol list rather than clearing and re-building it
The main advantages of not clearing and rebuilding the whole list is
that it doesn't loose the folding and selection (as far as the selected
row(s) still exist after the update, of course), and it reduces
flickering upon update.
The current implementation works in 3-steps:
1) mark all rows as invalid;
2) insert/update the rows, according to the new tag list, marking them
as valid;
3) remove all rows that are still invalid.
This walks (rows) the first time, (tags*rows) the second and (rows) the
third. This also uses an extra column to store the row's validity.
A (probably) better implementation would be to:
1) walk the current rows, updating them if necessary, or removing them;
2) add the remaining tags that weren't there before.
This is probably faster in theory (and probably also in practice), but
it needs to refactor a lot the code to easily update *or* create a row,
what the current code does not provide.
Basically this is would be a two-pass update, walking (rows*tags) in
the first pass, and only the remaining non-added tags in the second.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5562 ea778897-0a13-0410-b9d1-a72fbfd435f5
2011-03-05 22:53:13 +00:00
|
|
|
* @return TRUE if there @p iter was set, or FALSE if there is no next iter */
|
2011-11-18 21:35:24 +01:00
|
|
|
static gboolean next_iter(GtkTreeModel *model, GtkTreeIter *iter, gboolean down)
|
Update the symbol list rather than clearing and re-building it
The main advantages of not clearing and rebuilding the whole list is
that it doesn't loose the folding and selection (as far as the selected
row(s) still exist after the update, of course), and it reduces
flickering upon update.
The current implementation works in 3-steps:
1) mark all rows as invalid;
2) insert/update the rows, according to the new tag list, marking them
as valid;
3) remove all rows that are still invalid.
This walks (rows) the first time, (tags*rows) the second and (rows) the
third. This also uses an extra column to store the row's validity.
A (probably) better implementation would be to:
1) walk the current rows, updating them if necessary, or removing them;
2) add the remaining tags that weren't there before.
This is probably faster in theory (and probably also in practice), but
it needs to refactor a lot the code to easily update *or* create a row,
what the current code does not provide.
Basically this is would be a two-pass update, walking (rows*tags) in
the first pass, and only the remaining non-added tags in the second.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5562 ea778897-0a13-0410-b9d1-a72fbfd435f5
2011-03-05 22:53:13 +00:00
|
|
|
{
|
|
|
|
GtkTreeIter guess;
|
|
|
|
GtkTreeIter copy = *iter;
|
|
|
|
|
|
|
|
/* go down if the item has children */
|
2011-11-18 21:35:24 +01:00
|
|
|
if (down && gtk_tree_model_iter_children(model, &guess, iter))
|
Update the symbol list rather than clearing and re-building it
The main advantages of not clearing and rebuilding the whole list is
that it doesn't loose the folding and selection (as far as the selected
row(s) still exist after the update, of course), and it reduces
flickering upon update.
The current implementation works in 3-steps:
1) mark all rows as invalid;
2) insert/update the rows, according to the new tag list, marking them
as valid;
3) remove all rows that are still invalid.
This walks (rows) the first time, (tags*rows) the second and (rows) the
third. This also uses an extra column to store the row's validity.
A (probably) better implementation would be to:
1) walk the current rows, updating them if necessary, or removing them;
2) add the remaining tags that weren't there before.
This is probably faster in theory (and probably also in practice), but
it needs to refactor a lot the code to easily update *or* create a row,
what the current code does not provide.
Basically this is would be a two-pass update, walking (rows*tags) in
the first pass, and only the remaining non-added tags in the second.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5562 ea778897-0a13-0410-b9d1-a72fbfd435f5
2011-03-05 22:53:13 +00:00
|
|
|
*iter = guess;
|
|
|
|
/* or to the next item at the same level */
|
|
|
|
else if (gtk_tree_model_iter_next(model, ©))
|
|
|
|
*iter = copy;
|
|
|
|
/* or to the next item at a parent level */
|
|
|
|
else if (gtk_tree_model_iter_parent(model, &guess, iter))
|
|
|
|
{
|
|
|
|
copy = guess;
|
|
|
|
while(TRUE)
|
|
|
|
{
|
|
|
|
if (gtk_tree_model_iter_next(model, ©))
|
|
|
|
{
|
|
|
|
*iter = copy;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else if (gtk_tree_model_iter_parent(model, ©, &guess))
|
|
|
|
guess = copy;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean find_toplevel_iter(GtkTreeStore *store, GtkTreeIter *iter, const gchar *title)
|
|
|
|
{
|
|
|
|
GtkTreeModel *model = GTK_TREE_MODEL(store);
|
|
|
|
|
|
|
|
if (!gtk_tree_model_get_iter_first(model, iter))
|
|
|
|
return FALSE;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
gchar *candidate;
|
|
|
|
|
|
|
|
gtk_tree_model_get(model, iter, SYMBOLS_COLUMN_NAME, &candidate, -1);
|
|
|
|
/* FIXME: what if 2 different items have the same name?
|
|
|
|
* this should never happen, but might be caused by a typo in a translation */
|
|
|
|
if (utils_str_equal(candidate, title))
|
|
|
|
{
|
|
|
|
g_free(candidate);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
g_free(candidate);
|
|
|
|
}
|
|
|
|
while (gtk_tree_model_iter_next(model, iter));
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
/* Adds symbol list groups in (iter*, title) pairs.
|
|
|
|
* The list must be ended with NULL. */
|
|
|
|
static void G_GNUC_NULL_TERMINATED
|
|
|
|
tag_list_add_groups(GtkTreeStore *tree_store, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
GtkTreeIter *iter;
|
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(top_level_iter_names);
|
2007-05-23 12:32:06 +00:00
|
|
|
|
2011-08-06 18:34:14 +00:00
|
|
|
va_start(args, tree_store);
|
|
|
|
for (; iter = va_arg(args, GtkTreeIter*), iter != NULL;)
|
|
|
|
{
|
2007-05-23 12:32:06 +00:00
|
|
|
gchar *title = va_arg(args, gchar*);
|
2007-07-20 16:33:16 +00:00
|
|
|
gchar *icon_name = va_arg(args, gchar *);
|
|
|
|
GdkPixbuf *icon = NULL;
|
|
|
|
|
2007-07-22 14:38:47 +00:00
|
|
|
if (icon_name)
|
|
|
|
{
|
2008-11-03 17:25:35 +00:00
|
|
|
icon = get_tag_icon(icon_name);
|
2007-07-20 16:33:16 +00:00
|
|
|
}
|
2007-05-23 12:32:06 +00:00
|
|
|
|
2011-08-06 18:34:14 +00:00
|
|
|
g_assert(title != NULL);
|
2008-11-03 17:25:35 +00:00
|
|
|
g_ptr_array_add(top_level_iter_names, title);
|
|
|
|
|
Update the symbol list rather than clearing and re-building it
The main advantages of not clearing and rebuilding the whole list is
that it doesn't loose the folding and selection (as far as the selected
row(s) still exist after the update, of course), and it reduces
flickering upon update.
The current implementation works in 3-steps:
1) mark all rows as invalid;
2) insert/update the rows, according to the new tag list, marking them
as valid;
3) remove all rows that are still invalid.
This walks (rows) the first time, (tags*rows) the second and (rows) the
third. This also uses an extra column to store the row's validity.
A (probably) better implementation would be to:
1) walk the current rows, updating them if necessary, or removing them;
2) add the remaining tags that weren't there before.
This is probably faster in theory (and probably also in practice), but
it needs to refactor a lot the code to easily update *or* create a row,
what the current code does not provide.
Basically this is would be a two-pass update, walking (rows*tags) in
the first pass, and only the remaining non-added tags in the second.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5562 ea778897-0a13-0410-b9d1-a72fbfd435f5
2011-03-05 22:53:13 +00:00
|
|
|
if (!find_toplevel_iter(tree_store, iter, title))
|
|
|
|
gtk_tree_store_append(tree_store, iter, NULL);
|
2007-07-20 16:33:16 +00:00
|
|
|
|
2007-08-24 11:31:27 +00:00
|
|
|
if (G_IS_OBJECT(icon))
|
|
|
|
{
|
2008-11-03 17:25:35 +00:00
|
|
|
gtk_tree_store_set(tree_store, iter, SYMBOLS_COLUMN_ICON, icon, -1);
|
2007-07-22 14:38:47 +00:00
|
|
|
g_object_unref(icon);
|
2007-08-24 11:31:27 +00:00
|
|
|
}
|
2011-11-20 20:26:57 +01:00
|
|
|
gtk_tree_store_set(tree_store, iter, SYMBOLS_COLUMN_NAME, title, -1);
|
2007-05-23 12:32:06 +00:00
|
|
|
}
|
|
|
|
va_end(args);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
static void add_top_level_items(GeanyDocument *doc)
|
2007-01-15 11:48:14 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
filetype_id ft_id = doc->file_type->id;
|
2008-09-26 17:28:50 +00:00
|
|
|
GtkTreeStore *tag_store = doc->priv->tag_store;
|
2007-01-15 11:48:14 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (top_level_iter_names == NULL)
|
2008-11-03 17:25:35 +00:00
|
|
|
top_level_iter_names = g_ptr_array_new();
|
|
|
|
else
|
|
|
|
g_ptr_array_set_size(top_level_iter_names, 0);
|
|
|
|
|
2007-01-15 11:48:14 +00:00
|
|
|
init_tag_iters();
|
|
|
|
|
|
|
|
switch (ft_id)
|
2007-01-14 12:12:18 +00:00
|
|
|
{
|
|
|
|
case GEANY_FILETYPES_DIFF:
|
|
|
|
{
|
2007-05-23 17:20:47 +00:00
|
|
|
tag_list_add_groups(tag_store,
|
2007-07-20 16:33:16 +00:00
|
|
|
&(tv_iters.tag_function), _("Files"), NULL, NULL);
|
2007-01-14 12:12:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GEANY_FILETYPES_DOCBOOK:
|
|
|
|
{
|
2007-05-23 17:20:47 +00:00
|
|
|
tag_list_add_groups(tag_store,
|
2007-07-20 16:33:16 +00:00
|
|
|
&(tv_iters.tag_function), _("Chapter"), NULL,
|
|
|
|
&(tv_iters.tag_class), _("Section"), NULL,
|
|
|
|
&(tv_iters.tag_member), _("Sect1"), NULL,
|
|
|
|
&(tv_iters.tag_macro), _("Sect2"), NULL,
|
|
|
|
&(tv_iters.tag_variable), _("Sect3"), NULL,
|
|
|
|
&(tv_iters.tag_struct), _("Appendix"), NULL,
|
|
|
|
&(tv_iters.tag_other), _("Other"), NULL,
|
|
|
|
NULL);
|
2007-01-14 12:12:18 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-05-23 12:32:06 +00:00
|
|
|
case GEANY_FILETYPES_HASKELL:
|
2007-05-23 17:20:47 +00:00
|
|
|
tag_list_add_groups(tag_store,
|
2007-07-20 16:33:16 +00:00
|
|
|
&tv_iters.tag_namespace, _("Module"), NULL,
|
2008-12-19 16:49:37 +00:00
|
|
|
&tv_iters.tag_type, _("Types"), NULL,
|
2007-07-20 16:33:16 +00:00
|
|
|
&tv_iters.tag_macro, _("Type constructors"), NULL,
|
|
|
|
&tv_iters.tag_function, _("Functions"), "classviewer-method",
|
2007-05-23 12:32:06 +00:00
|
|
|
NULL);
|
|
|
|
break;
|
2011-01-30 15:03:51 +00:00
|
|
|
case GEANY_FILETYPES_COBOL:
|
|
|
|
tag_list_add_groups(tag_store,
|
|
|
|
&tv_iters.tag_class, _("Program"), "classviewer-class",
|
|
|
|
&tv_iters.tag_function, _("File"), "classviewer-method",
|
|
|
|
&tv_iters.tag_namespace, _("Sections"), "classviewer-namespace",
|
|
|
|
&tv_iters.tag_macro, _("Paragraph"), "classviewer-other",
|
|
|
|
&tv_iters.tag_struct, _("Group"), "classviewer-struct",
|
|
|
|
&tv_iters.tag_variable, _("Data"), "classviewer-var",
|
|
|
|
NULL);
|
|
|
|
break;
|
2007-07-02 17:09:48 +00:00
|
|
|
case GEANY_FILETYPES_CONF:
|
|
|
|
tag_list_add_groups(tag_store,
|
2008-11-10 17:16:35 +00:00
|
|
|
&tv_iters.tag_namespace, _("Sections"), "classviewer-other",
|
|
|
|
&tv_iters.tag_macro, _("Keys"), "classviewer-var",
|
2007-07-02 17:09:48 +00:00
|
|
|
NULL);
|
|
|
|
break;
|
2009-04-21 20:52:19 +00:00
|
|
|
case GEANY_FILETYPES_NSIS:
|
|
|
|
tag_list_add_groups(tag_store,
|
|
|
|
&tv_iters.tag_namespace, _("Sections"), "classviewer-other",
|
|
|
|
&tv_iters.tag_function, _("Functions"), "classviewer-method",
|
|
|
|
&(tv_iters.tag_variable), _("Variables"), "classviewer-var",
|
|
|
|
NULL);
|
|
|
|
break;
|
2007-01-14 12:12:18 +00:00
|
|
|
case GEANY_FILETYPES_LATEX:
|
|
|
|
{
|
2007-05-23 17:20:47 +00:00
|
|
|
tag_list_add_groups(tag_store,
|
2007-07-20 16:33:16 +00:00
|
|
|
&(tv_iters.tag_function), _("Command"), NULL,
|
|
|
|
&(tv_iters.tag_class), _("Environment"), NULL,
|
|
|
|
&(tv_iters.tag_member), _("Section"), NULL,
|
|
|
|
&(tv_iters.tag_macro), _("Subsection"), NULL,
|
|
|
|
&(tv_iters.tag_variable), _("Subsubsection"), NULL,
|
|
|
|
&(tv_iters.tag_struct), _("Label"), NULL,
|
|
|
|
&(tv_iters.tag_namespace), _("Chapter"), NULL,
|
|
|
|
&(tv_iters.tag_other), _("Other"), NULL,
|
|
|
|
NULL);
|
2007-01-14 12:12:18 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-11-07 14:39:45 +00:00
|
|
|
case GEANY_FILETYPES_MATLAB:
|
|
|
|
{
|
|
|
|
tag_list_add_groups(tag_store,
|
|
|
|
&(tv_iters.tag_function), _("Functions"), "classviewer-method",
|
|
|
|
&(tv_iters.tag_struct), _("Structures"), "classviewer-struct",
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
}
|
2012-12-03 15:17:43 +01:00
|
|
|
case GEANY_FILETYPES_ABAQUS:
|
|
|
|
{
|
|
|
|
tag_list_add_groups(tag_store,
|
|
|
|
&(tv_iters.tag_class), _("Parts"), NULL,
|
|
|
|
&(tv_iters.tag_member), _("Assembly"), NULL,
|
|
|
|
&(tv_iters.tag_namespace), _("Steps"), NULL,
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
}
|
2010-02-21 14:54:53 +00:00
|
|
|
case GEANY_FILETYPES_R:
|
|
|
|
{
|
|
|
|
tag_list_add_groups(tag_store,
|
|
|
|
&(tv_iters.tag_function), _("Functions"), "classviewer-method",
|
|
|
|
&(tv_iters.tag_struct), _("Other"), NULL,
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
}
|
2007-01-14 12:12:18 +00:00
|
|
|
case GEANY_FILETYPES_PERL:
|
|
|
|
{
|
2007-05-23 17:20:47 +00:00
|
|
|
tag_list_add_groups(tag_store,
|
2009-09-29 11:07:10 +00:00
|
|
|
&(tv_iters.tag_namespace), _("Package"), "classviewer-namespace",
|
2007-07-20 16:33:16 +00:00
|
|
|
&(tv_iters.tag_function), _("Functions"), "classviewer-method",
|
2009-09-29 11:07:10 +00:00
|
|
|
&(tv_iters.tag_macro), _("Labels"), NULL,
|
|
|
|
&(tv_iters.tag_type), _("Constants"), NULL,
|
2009-11-10 18:37:23 +00:00
|
|
|
&(tv_iters.tag_other), _("Other"), "classviewer-other",
|
2007-07-20 16:33:16 +00:00
|
|
|
NULL);
|
2007-01-14 12:12:18 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-07-09 15:11:18 +00:00
|
|
|
case GEANY_FILETYPES_PHP:
|
|
|
|
{
|
|
|
|
tag_list_add_groups(tag_store,
|
2012-01-06 13:39:26 +00:00
|
|
|
&(tv_iters.tag_interface), _("Interfaces"), "classviewer-struct",
|
2007-07-20 16:33:16 +00:00
|
|
|
&(tv_iters.tag_class), _("Classes"), "classviewer-class",
|
|
|
|
&(tv_iters.tag_function), _("Functions"), "classviewer-method",
|
2007-11-18 17:17:59 +00:00
|
|
|
&(tv_iters.tag_macro), _("Constants"), "classviewer-macro",
|
2007-07-20 16:33:16 +00:00
|
|
|
&(tv_iters.tag_variable), _("Variables"), "classviewer-var",
|
|
|
|
NULL);
|
2007-07-09 15:11:18 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-03-09 18:50:41 +00:00
|
|
|
case GEANY_FILETYPES_HTML:
|
|
|
|
{
|
|
|
|
tag_list_add_groups(tag_store,
|
2008-12-11 17:32:11 +00:00
|
|
|
&(tv_iters.tag_function), _("Functions"), NULL,
|
2008-12-19 16:28:14 +00:00
|
|
|
&(tv_iters.tag_member), _("Anchors"), NULL,
|
|
|
|
&(tv_iters.tag_namespace), _("H1 Headings"), NULL,
|
|
|
|
&(tv_iters.tag_class), _("H2 Headings"), NULL,
|
|
|
|
&(tv_iters.tag_variable), _("H3 Headings"), NULL,
|
2008-03-09 18:50:41 +00:00
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
}
|
2008-10-12 17:52:22 +00:00
|
|
|
case GEANY_FILETYPES_CSS:
|
|
|
|
{
|
|
|
|
tag_list_add_groups(tag_store,
|
|
|
|
&(tv_iters.tag_class), _("Classes"), "classviewer-class",
|
|
|
|
&(tv_iters.tag_variable), _("ID Selectors"), "classviewer-var",
|
|
|
|
&(tv_iters.tag_struct), _("Type Selectors"), "classviewer-struct", NULL);
|
|
|
|
break;
|
|
|
|
}
|
2007-08-14 11:50:03 +00:00
|
|
|
case GEANY_FILETYPES_REST:
|
2009-09-06 20:57:42 +00:00
|
|
|
case GEANY_FILETYPES_TXT2TAGS:
|
2009-09-20 18:46:56 +00:00
|
|
|
case GEANY_FILETYPES_ABC:
|
2007-08-14 11:50:03 +00:00
|
|
|
{
|
|
|
|
tag_list_add_groups(tag_store,
|
|
|
|
&(tv_iters.tag_namespace), _("Chapter"), NULL,
|
|
|
|
&(tv_iters.tag_member), _("Section"), NULL,
|
|
|
|
&(tv_iters.tag_macro), _("Subsection"), NULL,
|
|
|
|
&(tv_iters.tag_variable), _("Subsubsection"), NULL,
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
}
|
2012-11-01 11:14:55 +11:00
|
|
|
case GEANY_FILETYPES_ASCIIDOC:
|
|
|
|
{
|
|
|
|
tag_list_add_groups(tag_store,
|
2012-11-01 13:29:59 +11:00
|
|
|
&(tv_iters.tag_namespace), _("Document"), NULL,
|
|
|
|
&(tv_iters.tag_member), _("Section Level 1"), NULL,
|
|
|
|
&(tv_iters.tag_macro), _("Section Level 2"), NULL,
|
|
|
|
&(tv_iters.tag_variable), _("Section Level 3"), NULL,
|
|
|
|
&(tv_iters.tag_struct), _("Section Level 4"), NULL,
|
2012-11-01 11:14:55 +11:00
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
}
|
2007-01-14 12:12:18 +00:00
|
|
|
case GEANY_FILETYPES_RUBY:
|
|
|
|
{
|
2007-05-23 17:20:47 +00:00
|
|
|
tag_list_add_groups(tag_store,
|
2012-09-06 20:43:49 +02:00
|
|
|
&(tv_iters.tag_namespace), _("Modules"), "classviewer-namespace",
|
2007-07-20 16:33:16 +00:00
|
|
|
&(tv_iters.tag_class), _("Classes"), "classviewer-class",
|
2007-11-29 18:24:06 +00:00
|
|
|
&(tv_iters.tag_member), _("Singletons"), "classviewer-struct",
|
2007-07-20 16:33:16 +00:00
|
|
|
&(tv_iters.tag_function), _("Methods"), "classviewer-method",
|
|
|
|
NULL);
|
2007-01-14 12:12:18 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-03-21 16:47:17 +00:00
|
|
|
case GEANY_FILETYPES_TCL:
|
2009-06-28 10:42:34 +00:00
|
|
|
{
|
|
|
|
tag_list_add_groups(tag_store,
|
|
|
|
&(tv_iters.tag_namespace), _("Namespaces"), "classviewer-namespace",
|
|
|
|
&(tv_iters.tag_class), _("Classes"), "classviewer-class",
|
|
|
|
&(tv_iters.tag_member), _("Methods"), "classviewer-method",
|
2009-06-29 19:46:04 +00:00
|
|
|
&(tv_iters.tag_function), _("Procedures"), "classviewer-other",
|
2009-06-28 10:42:34 +00:00
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
}
|
2007-01-14 12:12:18 +00:00
|
|
|
case GEANY_FILETYPES_PYTHON:
|
|
|
|
{
|
2007-05-23 17:20:47 +00:00
|
|
|
tag_list_add_groups(tag_store,
|
2007-07-20 16:33:16 +00:00
|
|
|
&(tv_iters.tag_class), _("Classes"), "classviewer-class",
|
2008-11-10 17:31:45 +00:00
|
|
|
&(tv_iters.tag_member), _("Methods"), "classviewer-macro",
|
2007-07-20 16:33:16 +00:00
|
|
|
&(tv_iters.tag_function), _("Functions"), "classviewer-method",
|
2007-08-07 12:36:03 +00:00
|
|
|
&(tv_iters.tag_variable), _("Variables"), "classviewer-var",
|
2009-05-19 20:17:21 +00:00
|
|
|
&(tv_iters.tag_namespace), _("Imports"), "classviewer-namespace",
|
2007-07-20 16:33:16 +00:00
|
|
|
NULL);
|
2007-01-14 12:12:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GEANY_FILETYPES_VHDL:
|
|
|
|
{
|
2007-05-23 17:20:47 +00:00
|
|
|
tag_list_add_groups(tag_store,
|
2009-11-24 16:27:37 +00:00
|
|
|
&(tv_iters.tag_namespace), _("Package"), "classviewer-namespace",
|
2009-11-26 12:33:28 +00:00
|
|
|
&(tv_iters.tag_class), _("Entities"), "classviewer-class",
|
|
|
|
&(tv_iters.tag_struct), _("Architectures"), "classviewer-struct",
|
|
|
|
&(tv_iters.tag_type), _("Types"), "classviewer-other",
|
|
|
|
&(tv_iters.tag_function), _("Functions / Procedures"), "classviewer-method",
|
|
|
|
&(tv_iters.tag_variable), _("Variables / Signals"), "classviewer-var",
|
2012-09-02 19:12:42 +02:00
|
|
|
&(tv_iters.tag_member), _("Processes / Blocks / Components"), "classviewer-member",
|
2009-11-24 16:27:37 +00:00
|
|
|
&(tv_iters.tag_other), _("Other"), "classviewer-other",
|
2009-12-07 17:51:37 +00:00
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GEANY_FILETYPES_VERILOG:
|
|
|
|
{
|
|
|
|
tag_list_add_groups(tag_store,
|
|
|
|
&(tv_iters.tag_type), _("Events"), "classviewer-macro",
|
|
|
|
&(tv_iters.tag_class), _("Modules"), "classviewer-class",
|
|
|
|
&(tv_iters.tag_function), _("Functions / Tasks"), "classviewer-method",
|
|
|
|
&(tv_iters.tag_variable), _("Variables"), "classviewer-var",
|
|
|
|
&(tv_iters.tag_other), _("Other"), "classviewer-other",
|
2007-07-20 16:33:16 +00:00
|
|
|
NULL);
|
2007-01-14 12:12:18 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-01-15 11:48:14 +00:00
|
|
|
case GEANY_FILETYPES_JAVA:
|
2007-01-14 12:12:18 +00:00
|
|
|
{
|
2007-05-23 17:20:47 +00:00
|
|
|
tag_list_add_groups(tag_store,
|
2009-09-30 19:44:59 +00:00
|
|
|
&(tv_iters.tag_namespace), _("Package"), "classviewer-namespace",
|
2012-01-06 13:39:26 +00:00
|
|
|
&(tv_iters.tag_interface), _("Interfaces"), "classviewer-struct",
|
2007-07-20 16:33:16 +00:00
|
|
|
&(tv_iters.tag_class), _("Classes"), "classviewer-class",
|
|
|
|
&(tv_iters.tag_function), _("Methods"), "classviewer-method",
|
|
|
|
&(tv_iters.tag_member), _("Members"), "classviewer-member",
|
|
|
|
&(tv_iters.tag_other), _("Other"), "classviewer-other",
|
|
|
|
NULL);
|
2007-01-15 11:48:14 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-03-13 09:58:27 +00:00
|
|
|
case GEANY_FILETYPES_AS:
|
|
|
|
{
|
|
|
|
tag_list_add_groups(tag_store,
|
|
|
|
&(tv_iters.tag_namespace), _("Package"), "classviewer-namespace",
|
2012-01-06 13:39:26 +00:00
|
|
|
&(tv_iters.tag_interface), _("Interfaces"), "classviewer-struct",
|
2009-03-13 09:58:27 +00:00
|
|
|
&(tv_iters.tag_class), _("Classes"), "classviewer-class",
|
|
|
|
&(tv_iters.tag_function), _("Functions"), "classviewer-method",
|
|
|
|
&(tv_iters.tag_member), _("Properties"), "classviewer-member",
|
|
|
|
&(tv_iters.tag_variable), _("Variables"), "classviewer-var",
|
|
|
|
&(tv_iters.tag_macro), _("Constants"), "classviewer-macro",
|
|
|
|
&(tv_iters.tag_other), _("Other"), "classviewer-other",
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
}
|
2007-07-26 09:50:12 +00:00
|
|
|
case GEANY_FILETYPES_HAXE:
|
|
|
|
{
|
|
|
|
tag_list_add_groups(tag_store,
|
2012-01-06 13:39:26 +00:00
|
|
|
&(tv_iters.tag_interface), _("Interfaces"), "classviewer-struct",
|
2007-07-26 09:50:12 +00:00
|
|
|
&(tv_iters.tag_class), _("Classes"), "classviewer-class",
|
|
|
|
&(tv_iters.tag_function), _("Methods"), "classviewer-method",
|
2007-11-18 17:17:59 +00:00
|
|
|
&(tv_iters.tag_type), _("Types"), "classviewer-macro",
|
2007-07-26 09:50:12 +00:00
|
|
|
&(tv_iters.tag_variable), _("Variables"), "classviewer-var",
|
2007-09-17 15:28:27 +00:00
|
|
|
&(tv_iters.tag_other), _("Other"), "classviewer-other",
|
2007-07-26 09:50:12 +00:00
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
}
|
2007-11-23 16:05:53 +00:00
|
|
|
case GEANY_FILETYPES_BASIC:
|
|
|
|
{
|
|
|
|
tag_list_add_groups(tag_store,
|
|
|
|
&(tv_iters.tag_function), _("Functions"), "classviewer-method",
|
|
|
|
&(tv_iters.tag_variable), _("Variables"), "classviewer-var",
|
|
|
|
&(tv_iters.tag_macro), _("Constants"), "classviewer-macro",
|
|
|
|
&(tv_iters.tag_struct), _("Types"), "classviewer-namespace",
|
|
|
|
&(tv_iters.tag_namespace), _("Labels"), "classviewer-member",
|
|
|
|
&(tv_iters.tag_other), _("Other"), "classviewer-other",
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
}
|
2008-07-14 18:27:20 +00:00
|
|
|
case GEANY_FILETYPES_F77:
|
2008-03-03 20:16:52 +00:00
|
|
|
case GEANY_FILETYPES_FORTRAN:
|
|
|
|
{
|
|
|
|
tag_list_add_groups(tag_store,
|
2008-07-14 18:27:20 +00:00
|
|
|
&(tv_iters.tag_namespace), _("Module"), "classviewer-class",
|
2012-01-06 13:39:26 +00:00
|
|
|
&(tv_iters.tag_interface), _("Interfaces"), "classviewer-struct",
|
2008-03-03 20:16:52 +00:00
|
|
|
&(tv_iters.tag_function), _("Functions"), "classviewer-method",
|
|
|
|
&(tv_iters.tag_member), _("Subroutines"), "classviewer-method",
|
|
|
|
&(tv_iters.tag_variable), _("Variables"), "classviewer-var",
|
|
|
|
&(tv_iters.tag_type), _("Types"), "classviewer-namespace",
|
|
|
|
&(tv_iters.tag_macro), _("Blocks"), "classviewer-member",
|
|
|
|
&(tv_iters.tag_other), _("Other"), "classviewer-other",
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
}
|
2008-03-05 18:18:19 +00:00
|
|
|
case GEANY_FILETYPES_ASM:
|
|
|
|
{
|
|
|
|
tag_list_add_groups(tag_store,
|
|
|
|
&(tv_iters.tag_namespace), _("Labels"), "classviewer-namespace",
|
|
|
|
&(tv_iters.tag_function), _("Macros"), "classviewer-method",
|
|
|
|
&(tv_iters.tag_macro), _("Defines"), "classviewer-macro",
|
|
|
|
&(tv_iters.tag_struct), _("Types"), "classviewer-struct",
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
}
|
2008-03-23 15:25:42 +00:00
|
|
|
case GEANY_FILETYPES_MAKE:
|
|
|
|
tag_list_add_groups(tag_store,
|
|
|
|
&tv_iters.tag_function, _("Targets"), "classviewer-method",
|
|
|
|
&tv_iters.tag_macro, _("Macros"), "classviewer-macro",
|
|
|
|
NULL);
|
|
|
|
break;
|
2011-04-10 14:52:57 +00:00
|
|
|
case GEANY_FILETYPES_SQL:
|
|
|
|
{
|
|
|
|
tag_list_add_groups(tag_store,
|
|
|
|
&(tv_iters.tag_function), _("Functions"), "classviewer-method",
|
|
|
|
&(tv_iters.tag_namespace), _("Procedures"), "classviewer-namespace",
|
|
|
|
&(tv_iters.tag_struct), _("Indexes"), "classviewer-struct",
|
|
|
|
&(tv_iters.tag_class), _("Tables"), "classviewer-class",
|
|
|
|
&(tv_iters.tag_macro), _("Triggers"), "classviewer-macro",
|
|
|
|
&(tv_iters.tag_member), _("Views"), "classviewer-var",
|
|
|
|
&(tv_iters.tag_other), _("Other"), "classviewer-other",
|
|
|
|
NULL);
|
|
|
|
break;
|
|
|
|
}
|
2007-01-15 11:48:14 +00:00
|
|
|
case GEANY_FILETYPES_D:
|
|
|
|
default:
|
|
|
|
{
|
2007-05-23 17:20:47 +00:00
|
|
|
if (ft_id == GEANY_FILETYPES_D)
|
2007-07-20 16:33:16 +00:00
|
|
|
tag_list_add_groups(tag_store,
|
|
|
|
&(tv_iters.tag_namespace), _("Module"), NULL, NULL);
|
|
|
|
else
|
|
|
|
tag_list_add_groups(tag_store,
|
|
|
|
&(tv_iters.tag_namespace), _("Namespaces"), "classviewer-namespace", NULL);
|
2007-01-15 11:48:14 +00:00
|
|
|
|
2007-05-23 17:20:47 +00:00
|
|
|
tag_list_add_groups(tag_store,
|
2007-07-20 16:33:16 +00:00
|
|
|
&(tv_iters.tag_class), _("Classes"), "classviewer-class",
|
2012-01-06 13:39:26 +00:00
|
|
|
&(tv_iters.tag_interface), _("Interfaces"), "classviewer-struct",
|
2007-07-20 16:33:16 +00:00
|
|
|
&(tv_iters.tag_function), _("Functions"), "classviewer-method",
|
|
|
|
&(tv_iters.tag_member), _("Members"), "classviewer-member",
|
2008-12-19 16:49:37 +00:00
|
|
|
&(tv_iters.tag_struct), _("Structs"), "classviewer-struct",
|
|
|
|
&(tv_iters.tag_type), _("Typedefs / Enums"), "classviewer-struct",
|
2007-07-20 16:33:16 +00:00
|
|
|
NULL);
|
2007-05-23 17:20:47 +00:00
|
|
|
|
2007-01-15 11:48:14 +00:00
|
|
|
if (ft_id != GEANY_FILETYPES_D)
|
|
|
|
{
|
2007-05-23 17:20:47 +00:00
|
|
|
tag_list_add_groups(tag_store,
|
2007-07-20 16:33:16 +00:00
|
|
|
&(tv_iters.tag_macro), _("Macros"), "classviewer-macro", NULL);
|
2007-01-15 11:48:14 +00:00
|
|
|
}
|
2007-05-23 17:20:47 +00:00
|
|
|
tag_list_add_groups(tag_store,
|
2007-07-20 16:33:16 +00:00
|
|
|
&(tv_iters.tag_variable), _("Variables"), "classviewer-var",
|
|
|
|
&(tv_iters.tag_other), _("Other"), "classviewer-other", NULL);
|
2007-01-14 12:12:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-05 22:47:13 +00:00
|
|
|
/* removes toplevel items that have no children */
|
2008-05-12 13:46:19 +00:00
|
|
|
static void hide_empty_rows(GtkTreeStore *store)
|
2007-07-28 14:10:49 +00:00
|
|
|
{
|
2011-03-05 22:47:13 +00:00
|
|
|
GtkTreeIter iter;
|
|
|
|
gboolean cont = TRUE;
|
2007-07-28 14:10:49 +00:00
|
|
|
|
2008-05-12 13:46:19 +00:00
|
|
|
if (! gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter))
|
2008-02-27 13:17:29 +00:00
|
|
|
return; /* stop when first iter is invalid, i.e. no elements */
|
2007-07-28 14:10:49 +00:00
|
|
|
|
2011-03-05 22:47:13 +00:00
|
|
|
while (cont)
|
2007-07-28 14:10:49 +00:00
|
|
|
{
|
2008-05-12 13:46:19 +00:00
|
|
|
if (! gtk_tree_model_iter_has_child(GTK_TREE_MODEL(store), &iter))
|
2011-03-05 22:47:13 +00:00
|
|
|
cont = gtk_tree_store_remove(store, &iter);
|
|
|
|
else
|
|
|
|
cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter);
|
2007-07-28 14:10:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-29 12:50:52 +00:00
|
|
|
static const gchar *get_symbol_name(GeanyDocument *doc, const TMTag *tag, gboolean found_parent)
|
2007-01-13 13:25:05 +00:00
|
|
|
{
|
2008-11-03 17:25:35 +00:00
|
|
|
gchar *utf8_name;
|
|
|
|
const gchar *scope = tag->atts.entry.scope;
|
|
|
|
static GString *buffer = NULL; /* buffer will be small so we can keep it for reuse */
|
|
|
|
gboolean doc_is_utf8 = FALSE;
|
|
|
|
|
|
|
|
/* encodings_convert_to_utf8_from_charset() fails with charset "None", so skip conversion
|
|
|
|
* for None at this point completely */
|
|
|
|
if (utils_str_equal(doc->encoding, "UTF-8") ||
|
|
|
|
utils_str_equal(doc->encoding, "None"))
|
|
|
|
doc_is_utf8 = TRUE;
|
2012-10-18 16:55:33 +02:00
|
|
|
else /* normally the tags will always be in UTF-8 since we parse from our buffer, but a
|
|
|
|
* plugin might have called tm_source_file_update(), so check to be sure */
|
|
|
|
doc_is_utf8 = g_utf8_validate(tag->name, -1, NULL);
|
2008-11-03 17:25:35 +00:00
|
|
|
|
|
|
|
if (! doc_is_utf8)
|
|
|
|
utf8_name = encodings_convert_to_utf8_from_charset(tag->name,
|
2012-01-03 13:30:38 +00:00
|
|
|
-1, doc->encoding, TRUE);
|
2008-11-03 17:25:35 +00:00
|
|
|
else
|
|
|
|
utf8_name = tag->name;
|
2008-06-15 13:35:48 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (utf8_name == NULL)
|
2008-11-03 17:25:35 +00:00
|
|
|
return NULL;
|
2007-05-23 12:32:06 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (! buffer)
|
2008-11-03 17:25:35 +00:00
|
|
|
buffer = g_string_new(NULL);
|
2008-03-18 16:09:11 +00:00
|
|
|
else
|
2008-11-03 17:25:35 +00:00
|
|
|
g_string_truncate(buffer, 0);
|
2008-03-18 16:09:11 +00:00
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
/* check first char of scope is a wordchar */
|
|
|
|
if (!found_parent && scope &&
|
|
|
|
strpbrk(scope, GEANY_WORDCHARS) == scope)
|
|
|
|
{
|
2010-10-25 17:24:47 +00:00
|
|
|
const gchar *sep = symbols_get_context_separator(doc->file_type->id);
|
2007-01-13 13:25:05 +00:00
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
g_string_append(buffer, scope);
|
|
|
|
g_string_append(buffer, sep);
|
|
|
|
}
|
|
|
|
g_string_append(buffer, utf8_name);
|
|
|
|
|
|
|
|
if (! doc_is_utf8)
|
|
|
|
g_free(utf8_name);
|
|
|
|
|
|
|
|
g_string_append_printf(buffer, " [%lu]", tag->atts.entry.line);
|
|
|
|
|
|
|
|
return buffer->str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-29 12:50:52 +00:00
|
|
|
static gchar *get_symbol_tooltip(GeanyDocument *doc, const TMTag *tag)
|
|
|
|
{
|
|
|
|
gchar *utf8_name = editor_get_calltip_text(doc->editor, tag);
|
|
|
|
|
|
|
|
/* encodings_convert_to_utf8_from_charset() fails with charset "None", so skip conversion
|
|
|
|
* for None at this point completely */
|
2008-12-29 10:41:04 +00:00
|
|
|
if (utf8_name != NULL &&
|
|
|
|
! utils_str_equal(doc->encoding, "UTF-8") &&
|
|
|
|
! utils_str_equal(doc->encoding, "None"))
|
2008-11-29 12:50:52 +00:00
|
|
|
{
|
2012-01-25 16:26:16 +00:00
|
|
|
SETPTR(utf8_name,
|
2012-01-03 13:30:38 +00:00
|
|
|
encodings_convert_to_utf8_from_charset(utf8_name, -1, doc->encoding, TRUE));
|
2008-11-29 12:50:52 +00:00
|
|
|
}
|
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (utf8_name != NULL)
|
2012-01-25 16:26:16 +00:00
|
|
|
SETPTR(utf8_name, g_markup_escape_text(utf8_name, -1));
|
2009-02-18 15:20:27 +00:00
|
|
|
|
2008-11-29 12:50:52 +00:00
|
|
|
return utf8_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
/* find the last word in "foo::bar::blah", e.g. "blah" */
|
2010-04-25 17:43:39 +00:00
|
|
|
static const gchar *get_parent_name(const TMTag *tag, filetype_id ft_id)
|
2008-11-03 17:25:35 +00:00
|
|
|
{
|
|
|
|
const gchar *scope = tag->atts.entry.scope;
|
2008-10-02 15:48:50 +00:00
|
|
|
const gchar *separator = symbols_get_context_separator(ft_id);
|
2008-11-03 17:25:35 +00:00
|
|
|
const gchar *str, *ptr;
|
2007-01-13 13:25:05 +00:00
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
if (!scope)
|
|
|
|
return NULL;
|
2008-03-18 16:09:11 +00:00
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
str = scope;
|
2007-01-13 13:25:05 +00:00
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
while (1)
|
2007-01-13 13:25:05 +00:00
|
|
|
{
|
2008-11-03 17:25:35 +00:00
|
|
|
ptr = strstr(str, separator);
|
|
|
|
if (ptr)
|
|
|
|
{
|
|
|
|
str = ptr + strlen(separator);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
2007-04-23 15:15:13 +00:00
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
return NZV(str) ? str : NULL;
|
|
|
|
}
|
2007-01-14 12:12:18 +00:00
|
|
|
|
2007-04-23 15:15:13 +00:00
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
static GtkTreeIter *get_tag_type_iter(TMTagType tag_type, filetype_id ft_id)
|
|
|
|
{
|
|
|
|
GtkTreeIter *iter = NULL;
|
|
|
|
|
|
|
|
switch (tag_type)
|
|
|
|
{
|
|
|
|
case tm_tag_prototype_t:
|
|
|
|
case tm_tag_method_t:
|
|
|
|
case tm_tag_function_t:
|
2007-01-13 13:25:05 +00:00
|
|
|
{
|
2008-11-03 17:25:35 +00:00
|
|
|
iter = &tv_iters.tag_function;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case tm_tag_macro_t:
|
|
|
|
case tm_tag_macro_with_arg_t:
|
|
|
|
{
|
|
|
|
iter = &tv_iters.tag_macro;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case tm_tag_class_t:
|
|
|
|
{
|
|
|
|
iter = &tv_iters.tag_class;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case tm_tag_member_t:
|
|
|
|
case tm_tag_field_t:
|
|
|
|
{
|
|
|
|
iter = &tv_iters.tag_member;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case tm_tag_typedef_t:
|
|
|
|
case tm_tag_enum_t:
|
|
|
|
{
|
2008-12-19 16:49:37 +00:00
|
|
|
iter = &tv_iters.tag_type;
|
|
|
|
break;
|
2008-11-03 17:25:35 +00:00
|
|
|
}
|
|
|
|
case tm_tag_union_t:
|
|
|
|
case tm_tag_struct_t:
|
|
|
|
{
|
|
|
|
iter = &tv_iters.tag_struct;
|
|
|
|
break;
|
|
|
|
}
|
2012-01-06 13:39:26 +00:00
|
|
|
case tm_tag_interface_t:
|
|
|
|
iter = &tv_iters.tag_interface;
|
|
|
|
break;
|
2008-11-03 17:25:35 +00:00
|
|
|
case tm_tag_variable_t:
|
|
|
|
{
|
|
|
|
iter = &tv_iters.tag_variable;
|
|
|
|
break;
|
2007-01-13 13:25:05 +00:00
|
|
|
}
|
2008-11-03 17:25:35 +00:00
|
|
|
case tm_tag_namespace_t:
|
|
|
|
case tm_tag_package_t:
|
|
|
|
{
|
|
|
|
iter = &tv_iters.tag_namespace;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
iter = &tv_iters.tag_other;
|
2007-01-13 13:25:05 +00:00
|
|
|
}
|
2008-11-03 17:25:35 +00:00
|
|
|
}
|
2009-04-05 21:07:40 +00:00
|
|
|
if (G_LIKELY(iter->stamp != -1))
|
2008-11-03 17:25:35 +00:00
|
|
|
return iter;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-07-20 16:33:16 +00:00
|
|
|
|
2008-10-02 12:06:20 +00:00
|
|
|
|
2009-11-10 18:37:23 +00:00
|
|
|
static GdkPixbuf *get_child_icon(GtkTreeStore *tree_store, GtkTreeIter *parent)
|
|
|
|
{
|
|
|
|
GdkPixbuf *icon = NULL;
|
|
|
|
|
|
|
|
if (parent == &tv_iters.tag_other)
|
|
|
|
{
|
|
|
|
return get_tag_icon("classviewer-var");
|
|
|
|
}
|
|
|
|
/* copy parent icon */
|
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(tree_store), parent,
|
|
|
|
SYMBOLS_COLUMN_ICON, &icon, -1);
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-05 22:56:55 +00:00
|
|
|
static gboolean tag_equal(gconstpointer v1, gconstpointer v2)
|
|
|
|
{
|
|
|
|
const TMTag *t1 = v1;
|
|
|
|
const TMTag *t2 = v2;
|
|
|
|
|
|
|
|
return (t1->type == t2->type && strcmp(t1->name, t2->name) == 0 &&
|
2011-09-12 16:58:31 +00:00
|
|
|
utils_str_equal(t1->atts.entry.scope, t2->atts.entry.scope) &&
|
|
|
|
/* include arglist in match to support e.g. C++ overloading */
|
|
|
|
utils_str_equal(t1->atts.entry.arglist, t2->atts.entry.arglist));
|
2011-03-05 22:56:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* inspired from g_str_hash() */
|
|
|
|
static guint tag_hash(gconstpointer v)
|
|
|
|
{
|
|
|
|
const TMTag *tag = v;
|
2011-03-14 17:37:44 +00:00
|
|
|
const gchar *p;
|
2011-03-05 22:56:55 +00:00
|
|
|
guint32 h = 5381;
|
|
|
|
|
|
|
|
h = (h << 5) + h + tag->type;
|
|
|
|
for (p = tag->name; *p != '\0'; p++)
|
|
|
|
h = (h << 5) + h + *p;
|
|
|
|
if (tag->atts.entry.scope)
|
|
|
|
{
|
|
|
|
for (p = tag->atts.entry.scope; *p != '\0'; p++)
|
|
|
|
h = (h << 5) + h + *p;
|
|
|
|
}
|
2011-09-12 16:58:31 +00:00
|
|
|
/* for e.g. C++ overloading */
|
|
|
|
if (tag->atts.entry.arglist)
|
|
|
|
{
|
|
|
|
for (p = tag->atts.entry.arglist; *p != '\0'; p++)
|
|
|
|
h = (h << 5) + h + *p;
|
|
|
|
}
|
2011-03-05 22:56:55 +00:00
|
|
|
|
|
|
|
return h;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-20 20:26:57 +01:00
|
|
|
/* like gtk_tree_view_expand_to_path() but with an iter */
|
|
|
|
static void tree_view_expand_to_iter(GtkTreeView *view, GtkTreeIter *iter)
|
Update the symbol list rather than clearing and re-building it
The main advantages of not clearing and rebuilding the whole list is
that it doesn't loose the folding and selection (as far as the selected
row(s) still exist after the update, of course), and it reduces
flickering upon update.
The current implementation works in 3-steps:
1) mark all rows as invalid;
2) insert/update the rows, according to the new tag list, marking them
as valid;
3) remove all rows that are still invalid.
This walks (rows) the first time, (tags*rows) the second and (rows) the
third. This also uses an extra column to store the row's validity.
A (probably) better implementation would be to:
1) walk the current rows, updating them if necessary, or removing them;
2) add the remaining tags that weren't there before.
This is probably faster in theory (and probably also in practice), but
it needs to refactor a lot the code to easily update *or* create a row,
what the current code does not provide.
Basically this is would be a two-pass update, walking (rows*tags) in
the first pass, and only the remaining non-added tags in the second.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5562 ea778897-0a13-0410-b9d1-a72fbfd435f5
2011-03-05 22:53:13 +00:00
|
|
|
{
|
2011-11-20 20:26:57 +01:00
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(view);
|
|
|
|
GtkTreePath *path = gtk_tree_model_get_path(model, iter);
|
2011-03-05 22:56:55 +00:00
|
|
|
|
2011-11-20 20:26:57 +01:00
|
|
|
gtk_tree_view_expand_to_path(view, path);
|
|
|
|
gtk_tree_path_free(path);
|
2011-03-05 22:56:55 +00:00
|
|
|
}
|
|
|
|
|
Update the symbol list rather than clearing and re-building it
The main advantages of not clearing and rebuilding the whole list is
that it doesn't loose the folding and selection (as far as the selected
row(s) still exist after the update, of course), and it reduces
flickering upon update.
The current implementation works in 3-steps:
1) mark all rows as invalid;
2) insert/update the rows, according to the new tag list, marking them
as valid;
3) remove all rows that are still invalid.
This walks (rows) the first time, (tags*rows) the second and (rows) the
third. This also uses an extra column to store the row's validity.
A (probably) better implementation would be to:
1) walk the current rows, updating them if necessary, or removing them;
2) add the remaining tags that weren't there before.
This is probably faster in theory (and probably also in practice), but
it needs to refactor a lot the code to easily update *or* create a row,
what the current code does not provide.
Basically this is would be a two-pass update, walking (rows*tags) in
the first pass, and only the remaining non-added tags in the second.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5562 ea778897-0a13-0410-b9d1-a72fbfd435f5
2011-03-05 22:53:13 +00:00
|
|
|
|
2011-11-20 20:26:57 +01:00
|
|
|
/* like gtk_tree_store_remove() but finds the next iter at any level */
|
|
|
|
static gboolean tree_store_remove_row(GtkTreeStore *store, GtkTreeIter *iter)
|
2011-03-05 22:56:55 +00:00
|
|
|
{
|
2011-11-20 20:26:57 +01:00
|
|
|
GtkTreeIter parent;
|
|
|
|
gboolean has_parent;
|
|
|
|
gboolean cont;
|
2011-03-05 22:56:55 +00:00
|
|
|
|
2011-11-20 20:26:57 +01:00
|
|
|
has_parent = gtk_tree_model_iter_parent(GTK_TREE_MODEL(store), &parent, iter);
|
|
|
|
cont = gtk_tree_store_remove(store, iter);
|
|
|
|
/* if there is no next at this level but there is a parent iter, continue from it */
|
|
|
|
if (! cont && has_parent)
|
2011-03-05 22:56:55 +00:00
|
|
|
{
|
2011-11-20 20:26:57 +01:00
|
|
|
*iter = parent;
|
|
|
|
cont = next_iter(GTK_TREE_MODEL(store), iter, FALSE);
|
Update the symbol list rather than clearing and re-building it
The main advantages of not clearing and rebuilding the whole list is
that it doesn't loose the folding and selection (as far as the selected
row(s) still exist after the update, of course), and it reduces
flickering upon update.
The current implementation works in 3-steps:
1) mark all rows as invalid;
2) insert/update the rows, according to the new tag list, marking them
as valid;
3) remove all rows that are still invalid.
This walks (rows) the first time, (tags*rows) the second and (rows) the
third. This also uses an extra column to store the row's validity.
A (probably) better implementation would be to:
1) walk the current rows, updating them if necessary, or removing them;
2) add the remaining tags that weren't there before.
This is probably faster in theory (and probably also in practice), but
it needs to refactor a lot the code to easily update *or* create a row,
what the current code does not provide.
Basically this is would be a two-pass update, walking (rows*tags) in
the first pass, and only the remaining non-added tags in the second.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5562 ea778897-0a13-0410-b9d1-a72fbfd435f5
2011-03-05 22:53:13 +00:00
|
|
|
}
|
|
|
|
|
2011-11-20 20:26:57 +01:00
|
|
|
return cont;
|
Update the symbol list rather than clearing and re-building it
The main advantages of not clearing and rebuilding the whole list is
that it doesn't loose the folding and selection (as far as the selected
row(s) still exist after the update, of course), and it reduces
flickering upon update.
The current implementation works in 3-steps:
1) mark all rows as invalid;
2) insert/update the rows, according to the new tag list, marking them
as valid;
3) remove all rows that are still invalid.
This walks (rows) the first time, (tags*rows) the second and (rows) the
third. This also uses an extra column to store the row's validity.
A (probably) better implementation would be to:
1) walk the current rows, updating them if necessary, or removing them;
2) add the remaining tags that weren't there before.
This is probably faster in theory (and probably also in practice), but
it needs to refactor a lot the code to easily update *or* create a row,
what the current code does not provide.
Basically this is would be a two-pass update, walking (rows*tags) in
the first pass, and only the remaining non-added tags in the second.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5562 ea778897-0a13-0410-b9d1-a72fbfd435f5
2011-03-05 22:53:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-18 14:23:13 +01:00
|
|
|
/* adds a new element in the parent table if it's key is known.
|
|
|
|
* duplicates are kept */
|
2011-11-20 20:26:57 +01:00
|
|
|
static void update_parents_table(GHashTable *table, const TMTag *tag, const gchar *parent_name,
|
|
|
|
const GtkTreeIter *iter)
|
2008-11-03 17:25:35 +00:00
|
|
|
{
|
2012-03-18 14:23:13 +01:00
|
|
|
GList **list;
|
|
|
|
if (g_hash_table_lookup_extended(table, tag->name, NULL, (gpointer *) &list) &&
|
2011-11-20 20:26:57 +01:00
|
|
|
! utils_str_equal(parent_name, tag->name) /* prevent Foo::Foo from making parent = child */)
|
|
|
|
{
|
2012-03-18 14:23:13 +01:00
|
|
|
if (! list)
|
|
|
|
{
|
|
|
|
list = g_slice_alloc(sizeof *list);
|
|
|
|
*list = NULL;
|
|
|
|
g_hash_table_insert(table, tag->name, list);
|
|
|
|
}
|
|
|
|
*list = g_list_prepend(*list, g_slice_dup(GtkTreeIter, iter));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void free_iter_slice_list(gpointer data)
|
|
|
|
{
|
|
|
|
GList **list = data;
|
|
|
|
|
|
|
|
if (list)
|
|
|
|
{
|
|
|
|
GList *node;
|
|
|
|
foreach_list(node, *list)
|
|
|
|
g_slice_free(GtkTreeIter, node->data);
|
|
|
|
g_list_free(*list);
|
|
|
|
g_slice_free1(sizeof *list, list);
|
2011-11-20 20:26:57 +01:00
|
|
|
}
|
|
|
|
}
|
2008-10-02 12:06:20 +00:00
|
|
|
|
|
|
|
|
2012-03-18 14:23:13 +01:00
|
|
|
/* inserts a @data in @table on key @tag.
|
|
|
|
* previous data is not overwritten if the key is duplicated, but rather the
|
|
|
|
* two values are kept in a list
|
2012-04-22 10:54:41 +10:00
|
|
|
*
|
2012-03-18 14:23:13 +01:00
|
|
|
* table is: GHashTable<TMTag, GList<GList<TMTag>>> */
|
|
|
|
static void tags_table_insert(GHashTable *table, TMTag *tag, GList *data)
|
2011-11-20 23:15:12 +01:00
|
|
|
{
|
2012-03-18 14:23:13 +01:00
|
|
|
GList *list = g_hash_table_lookup(table, tag);
|
|
|
|
list = g_list_prepend(list, data);
|
|
|
|
g_hash_table_insert(table, tag, list);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* looks up the entry in @table that better matches @tag.
|
|
|
|
* if there are more than one candidate, the one that has closest line position to @tag is chosen */
|
|
|
|
static GList *tags_table_lookup(GHashTable *table, TMTag *tag)
|
|
|
|
{
|
|
|
|
GList *data = NULL;
|
|
|
|
GList *node = g_hash_table_lookup(table, tag);
|
|
|
|
if (node)
|
|
|
|
{
|
|
|
|
glong delta;
|
|
|
|
data = node->data;
|
|
|
|
|
|
|
|
#define TAG_DELTA(a, b) ABS((glong) TM_TAG(a)->atts.entry.line - (glong) TM_TAG(b)->atts.entry.line)
|
|
|
|
|
|
|
|
delta = TAG_DELTA(((GList *) node->data)->data, tag);
|
|
|
|
for (node = node->next; node; node = node->next)
|
|
|
|
{
|
|
|
|
glong d = TAG_DELTA(((GList *) node->data)->data, tag);
|
|
|
|
|
|
|
|
if (d < delta)
|
|
|
|
{
|
|
|
|
data = node->data;
|
|
|
|
delta = d;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef TAG_DELTA
|
|
|
|
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* removes the element at @tag from @table.
|
|
|
|
* @tag must be the exact pointer used at insertion time */
|
|
|
|
static void tags_table_remove(GHashTable *table, TMTag *tag)
|
|
|
|
{
|
|
|
|
GList *list = g_hash_table_lookup(table, tag);
|
|
|
|
if (list)
|
|
|
|
{
|
|
|
|
GList *node;
|
|
|
|
foreach_list(node, list)
|
|
|
|
{
|
|
|
|
if (((GList *) node->data)->data == tag)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
list = g_list_delete_link(list, node);
|
|
|
|
if (list)
|
|
|
|
g_hash_table_insert(table, tag, list);
|
|
|
|
else
|
|
|
|
g_hash_table_remove(table, tag);
|
|
|
|
}
|
2011-11-20 23:15:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-22 20:20:53 +02:00
|
|
|
static void tags_table_destroy(GHashTable *table)
|
|
|
|
{
|
|
|
|
/* free any leftover elements. note that we can't register a value_free_func when
|
|
|
|
* creating the hash table because we only want to free it when destroying the table,
|
|
|
|
* not when inserting a duplicate (we handle this manually) */
|
|
|
|
GHashTableIter iter;
|
|
|
|
gpointer value;
|
|
|
|
|
|
|
|
g_hash_table_iter_init(&iter, table);
|
|
|
|
while (g_hash_table_iter_next(&iter, NULL, &value))
|
|
|
|
g_list_free(value);
|
|
|
|
g_hash_table_destroy(table);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-20 20:26:57 +01:00
|
|
|
/*
|
|
|
|
* Updates the tag tree for a document with the tags in *list.
|
|
|
|
* @param doc a document
|
|
|
|
* @param tags a pointer to a GList* holding the tags to add/update. This
|
|
|
|
* list may be updated, removing updated elements.
|
2012-01-03 13:30:38 +00:00
|
|
|
*
|
2011-11-20 20:26:57 +01:00
|
|
|
* The update is done in two passes:
|
|
|
|
* 1) walking the current tree, update tags that still exist and remove the
|
|
|
|
* obsolescent ones;
|
|
|
|
* 2) walking the remaining (non updated) tags, adds them in the list.
|
2012-01-03 13:30:38 +00:00
|
|
|
*
|
2011-11-20 20:26:57 +01:00
|
|
|
* For better performances, we use 2 hash tables:
|
|
|
|
* - one containing all the tags for lookup in the first pass (actually stores a
|
|
|
|
* reference in the tags list for removing it efficiently), avoiding list search
|
|
|
|
* on each tag;
|
|
|
|
* - the other holding "tag-name":row references for tags having children, used to
|
|
|
|
* lookup for a parent in both passes, avoiding tree traversal.
|
|
|
|
*/
|
|
|
|
static void update_tree_tags(GeanyDocument *doc, GList **tags)
|
|
|
|
{
|
|
|
|
GtkTreeStore *store = doc->priv->tag_store;
|
|
|
|
GtkTreeModel *model = GTK_TREE_MODEL(store);
|
|
|
|
GHashTable *parents_table;
|
|
|
|
GHashTable *tags_table;
|
|
|
|
GtkTreeIter iter;
|
|
|
|
gboolean cont;
|
|
|
|
GList *item;
|
|
|
|
|
|
|
|
/* Build hash tables holding tags and parents */
|
|
|
|
/* parent table holds "tag-name":GtkTreeIter */
|
2012-03-18 14:23:13 +01:00
|
|
|
parents_table = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, free_iter_slice_list);
|
2011-11-20 20:26:57 +01:00
|
|
|
/* tags table is another representation of the @tags list, TMTag:GList<TMTag> */
|
|
|
|
tags_table = g_hash_table_new_full(tag_hash, tag_equal, NULL, NULL);
|
|
|
|
foreach_list(item, *tags)
|
2008-11-03 17:25:35 +00:00
|
|
|
{
|
2011-11-20 20:26:57 +01:00
|
|
|
TMTag *tag = item->data;
|
2008-11-03 17:25:35 +00:00
|
|
|
const gchar *name;
|
|
|
|
|
2012-03-18 14:23:13 +01:00
|
|
|
tags_table_insert(tags_table, tag, item);
|
2008-10-02 12:06:20 +00:00
|
|
|
|
2011-11-20 20:26:57 +01:00
|
|
|
name = get_parent_name(tag, doc->file_type->id);
|
|
|
|
if (name)
|
|
|
|
g_hash_table_insert(parents_table, (gpointer) name, NULL);
|
|
|
|
}
|
2007-07-20 16:33:16 +00:00
|
|
|
|
2011-11-20 20:26:57 +01:00
|
|
|
/* First pass, update existing rows or delete them.
|
|
|
|
* It is OK to delete them since we walk top down so we would remove
|
|
|
|
* parents before checking for their children, thus never implicitly
|
|
|
|
* deleting an updated child */
|
|
|
|
cont = gtk_tree_model_get_iter_first(model, &iter);
|
|
|
|
while (cont)
|
|
|
|
{
|
|
|
|
TMTag *tag;
|
2008-11-03 17:25:35 +00:00
|
|
|
|
2011-11-20 20:26:57 +01:00
|
|
|
gtk_tree_model_get(model, &iter, SYMBOLS_COLUMN_TAG, &tag, -1);
|
|
|
|
if (! tag) /* most probably a toplevel, skip it */
|
|
|
|
cont = next_iter(model, &iter, TRUE);
|
|
|
|
else
|
Update the symbol list rather than clearing and re-building it
The main advantages of not clearing and rebuilding the whole list is
that it doesn't loose the folding and selection (as far as the selected
row(s) still exist after the update, of course), and it reduces
flickering upon update.
The current implementation works in 3-steps:
1) mark all rows as invalid;
2) insert/update the rows, according to the new tag list, marking them
as valid;
3) remove all rows that are still invalid.
This walks (rows) the first time, (tags*rows) the second and (rows) the
third. This also uses an extra column to store the row's validity.
A (probably) better implementation would be to:
1) walk the current rows, updating them if necessary, or removing them;
2) add the remaining tags that weren't there before.
This is probably faster in theory (and probably also in practice), but
it needs to refactor a lot the code to easily update *or* create a row,
what the current code does not provide.
Basically this is would be a two-pass update, walking (rows*tags) in
the first pass, and only the remaining non-added tags in the second.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5562 ea778897-0a13-0410-b9d1-a72fbfd435f5
2011-03-05 22:53:13 +00:00
|
|
|
{
|
2011-11-20 20:26:57 +01:00
|
|
|
GList *found_item;
|
Update the symbol list rather than clearing and re-building it
The main advantages of not clearing and rebuilding the whole list is
that it doesn't loose the folding and selection (as far as the selected
row(s) still exist after the update, of course), and it reduces
flickering upon update.
The current implementation works in 3-steps:
1) mark all rows as invalid;
2) insert/update the rows, according to the new tag list, marking them
as valid;
3) remove all rows that are still invalid.
This walks (rows) the first time, (tags*rows) the second and (rows) the
third. This also uses an extra column to store the row's validity.
A (probably) better implementation would be to:
1) walk the current rows, updating them if necessary, or removing them;
2) add the remaining tags that weren't there before.
This is probably faster in theory (and probably also in practice), but
it needs to refactor a lot the code to easily update *or* create a row,
what the current code does not provide.
Basically this is would be a two-pass update, walking (rows*tags) in
the first pass, and only the remaining non-added tags in the second.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5562 ea778897-0a13-0410-b9d1-a72fbfd435f5
2011-03-05 22:53:13 +00:00
|
|
|
|
2012-03-18 14:23:13 +01:00
|
|
|
found_item = tags_table_lookup(tags_table, tag);
|
2011-11-20 20:26:57 +01:00
|
|
|
if (! found_item) /* tag doesn't exist, remove it */
|
|
|
|
cont = tree_store_remove_row(store, &iter);
|
|
|
|
else /* tag still exist, update it */
|
Update the symbol list rather than clearing and re-building it
The main advantages of not clearing and rebuilding the whole list is
that it doesn't loose the folding and selection (as far as the selected
row(s) still exist after the update, of course), and it reduces
flickering upon update.
The current implementation works in 3-steps:
1) mark all rows as invalid;
2) insert/update the rows, according to the new tag list, marking them
as valid;
3) remove all rows that are still invalid.
This walks (rows) the first time, (tags*rows) the second and (rows) the
third. This also uses an extra column to store the row's validity.
A (probably) better implementation would be to:
1) walk the current rows, updating them if necessary, or removing them;
2) add the remaining tags that weren't there before.
This is probably faster in theory (and probably also in practice), but
it needs to refactor a lot the code to easily update *or* create a row,
what the current code does not provide.
Basically this is would be a two-pass update, walking (rows*tags) in
the first pass, and only the remaining non-added tags in the second.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5562 ea778897-0a13-0410-b9d1-a72fbfd435f5
2011-03-05 22:53:13 +00:00
|
|
|
{
|
2011-11-20 20:26:57 +01:00
|
|
|
const gchar *name;
|
|
|
|
const gchar *parent_name;
|
|
|
|
TMTag *found = found_item->data;
|
|
|
|
|
|
|
|
parent_name = get_parent_name(found, doc->file_type->id);
|
|
|
|
/* if parent is unknown, ignore it */
|
|
|
|
if (parent_name && ! g_hash_table_lookup(parents_table, parent_name))
|
|
|
|
parent_name = NULL;
|
|
|
|
|
|
|
|
/* only update fields that (can) have changed (name that holds line
|
|
|
|
* number, and the tag itself) */
|
|
|
|
name = get_symbol_name(doc, found, parent_name != NULL);
|
|
|
|
gtk_tree_store_set(store, &iter,
|
|
|
|
SYMBOLS_COLUMN_NAME, name,
|
|
|
|
SYMBOLS_COLUMN_TAG, found,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
update_parents_table(parents_table, found, parent_name, &iter);
|
|
|
|
|
|
|
|
/* remove the updated tag from the table and list */
|
2012-03-18 14:23:13 +01:00
|
|
|
tags_table_remove(tags_table, found);
|
2011-11-20 20:26:57 +01:00
|
|
|
*tags = g_list_delete_link(*tags, found_item);
|
|
|
|
|
|
|
|
cont = next_iter(model, &iter, TRUE);
|
Update the symbol list rather than clearing and re-building it
The main advantages of not clearing and rebuilding the whole list is
that it doesn't loose the folding and selection (as far as the selected
row(s) still exist after the update, of course), and it reduces
flickering upon update.
The current implementation works in 3-steps:
1) mark all rows as invalid;
2) insert/update the rows, according to the new tag list, marking them
as valid;
3) remove all rows that are still invalid.
This walks (rows) the first time, (tags*rows) the second and (rows) the
third. This also uses an extra column to store the row's validity.
A (probably) better implementation would be to:
1) walk the current rows, updating them if necessary, or removing them;
2) add the remaining tags that weren't there before.
This is probably faster in theory (and probably also in practice), but
it needs to refactor a lot the code to easily update *or* create a row,
what the current code does not provide.
Basically this is would be a two-pass update, walking (rows*tags) in
the first pass, and only the remaining non-added tags in the second.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5562 ea778897-0a13-0410-b9d1-a72fbfd435f5
2011-03-05 22:53:13 +00:00
|
|
|
}
|
2008-11-03 17:25:35 +00:00
|
|
|
|
2011-11-20 20:26:57 +01:00
|
|
|
tm_tag_unref(tag);
|
|
|
|
}
|
2007-01-13 13:25:05 +00:00
|
|
|
}
|
2008-11-03 17:25:35 +00:00
|
|
|
|
2011-11-20 20:26:57 +01:00
|
|
|
/* Second pass, now we have a tree cleaned up from invalid rows,
|
|
|
|
* we simply add new ones */
|
|
|
|
foreach_list (item, *tags)
|
|
|
|
{
|
|
|
|
TMTag *tag = item->data;
|
|
|
|
GtkTreeIter *parent;
|
2008-11-03 17:25:35 +00:00
|
|
|
|
2011-11-20 20:26:57 +01:00
|
|
|
parent = get_tag_type_iter(tag->type, doc->file_type->id);
|
|
|
|
if (G_UNLIKELY(! parent))
|
|
|
|
geany_debug("Missing symbol-tree parent iter for type %d!", tag->type);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gboolean expand;
|
|
|
|
const gchar *name;
|
|
|
|
const gchar *parent_name;
|
|
|
|
gchar *tooltip;
|
|
|
|
GdkPixbuf *icon = get_child_icon(store, parent);
|
|
|
|
|
|
|
|
parent_name = get_parent_name(tag, doc->file_type->id);
|
|
|
|
if (parent_name)
|
|
|
|
{
|
2012-03-18 14:23:13 +01:00
|
|
|
GList **candidates;
|
|
|
|
GtkTreeIter *parent_search = NULL;
|
|
|
|
|
|
|
|
/* walk parent candidates to find the better one.
|
|
|
|
* if there are more than one, take the one that has the closest line number
|
|
|
|
* after the tag we're searching the parent for */
|
|
|
|
candidates = g_hash_table_lookup(parents_table, parent_name);
|
|
|
|
if (candidates)
|
|
|
|
{
|
|
|
|
GList *node;
|
|
|
|
glong delta = G_MAXLONG;
|
|
|
|
foreach_list(node, *candidates)
|
|
|
|
{
|
|
|
|
TMTag *parent_tag;
|
|
|
|
glong d;
|
|
|
|
|
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(store), node->data,
|
|
|
|
SYMBOLS_COLUMN_TAG, &parent_tag, -1);
|
|
|
|
|
|
|
|
d = tag->atts.entry.line - parent_tag->atts.entry.line;
|
|
|
|
if (! parent_search || (d >= 0 && d < delta))
|
|
|
|
{
|
|
|
|
delta = d;
|
|
|
|
parent_search = node->data;
|
|
|
|
}
|
2013-03-17 17:28:46 +01:00
|
|
|
tm_tag_unref(parent_tag);
|
2012-03-18 14:23:13 +01:00
|
|
|
}
|
|
|
|
}
|
2008-11-03 17:25:35 +00:00
|
|
|
|
2011-11-20 20:26:57 +01:00
|
|
|
if (parent_search)
|
|
|
|
parent = parent_search;
|
|
|
|
else
|
|
|
|
parent_name = NULL;
|
|
|
|
}
|
2008-11-03 17:25:35 +00:00
|
|
|
|
2011-11-20 20:26:57 +01:00
|
|
|
/* only expand to the iter if the parent was empty, otherwise we let the
|
|
|
|
* folding as it was before (already expanded, or closed by the user) */
|
|
|
|
expand = ! gtk_tree_model_iter_has_child(model, parent);
|
|
|
|
|
|
|
|
/* insert the new element */
|
|
|
|
gtk_tree_store_append(store, &iter, parent);
|
|
|
|
name = get_symbol_name(doc, tag, parent_name != NULL);
|
|
|
|
tooltip = get_symbol_tooltip(doc, tag);
|
|
|
|
gtk_tree_store_set(store, &iter,
|
|
|
|
SYMBOLS_COLUMN_NAME, name,
|
|
|
|
SYMBOLS_COLUMN_TOOLTIP, tooltip,
|
|
|
|
SYMBOLS_COLUMN_ICON, icon,
|
|
|
|
SYMBOLS_COLUMN_TAG, tag,
|
|
|
|
-1);
|
|
|
|
g_free(tooltip);
|
|
|
|
if (G_LIKELY(icon))
|
|
|
|
g_object_unref(icon);
|
|
|
|
|
|
|
|
update_parents_table(parents_table, tag, parent_name, &iter);
|
2008-11-03 17:25:35 +00:00
|
|
|
|
2011-11-20 20:26:57 +01:00
|
|
|
if (expand)
|
|
|
|
tree_view_expand_to_iter(GTK_TREE_VIEW(doc->priv->tag_tree), &iter);
|
|
|
|
}
|
2008-11-03 17:25:35 +00:00
|
|
|
}
|
|
|
|
|
2011-11-20 20:26:57 +01:00
|
|
|
g_hash_table_destroy(parents_table);
|
2013-04-22 20:20:53 +02:00
|
|
|
tags_table_destroy(tags_table);
|
2008-10-02 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
/* we don't want to sort 1st-level nodes, but we can't return 0 because the tree sort
|
|
|
|
* is not stable, so the order is already lost. */
|
|
|
|
static gint compare_top_level_names(const gchar *a, const gchar *b)
|
|
|
|
{
|
2009-07-20 12:25:24 +00:00
|
|
|
guint i;
|
2008-12-11 12:49:26 +00:00
|
|
|
const gchar *name;
|
2008-11-03 17:25:35 +00:00
|
|
|
|
2011-11-15 15:43:49 +01:00
|
|
|
/* This should never happen as it would mean that two or more top
|
|
|
|
* level items have the same name but it can happen by typos in the translations. */
|
2011-11-17 03:50:27 +01:00
|
|
|
if (utils_str_equal(a, b))
|
|
|
|
return 1;
|
2011-11-15 15:43:49 +01:00
|
|
|
|
2009-07-20 12:25:24 +00:00
|
|
|
foreach_ptr_array(name, i, top_level_iter_names)
|
2008-11-03 17:25:35 +00:00
|
|
|
{
|
|
|
|
if (utils_str_equal(name, a))
|
|
|
|
return -1;
|
|
|
|
if (utils_str_equal(name, b))
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
g_warning("Couldn't find top level node '%s' or '%s'!", a, b);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-05 12:50:29 +00:00
|
|
|
static gboolean tag_has_missing_parent(const TMTag *tag, GtkTreeStore *store,
|
|
|
|
GtkTreeIter *iter)
|
|
|
|
{
|
|
|
|
/* if the tag has a parent tag, it should be at depth >= 2 */
|
|
|
|
return NZV(tag->atts.entry.scope) &&
|
|
|
|
gtk_tree_store_iter_depth(store, iter) == 1;
|
|
|
|
}
|
2008-11-04 18:14:04 +00:00
|
|
|
|
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
static gint tree_sort_func(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
gboolean sort_by_name = GPOINTER_TO_INT(user_data);
|
2011-03-05 22:50:04 +00:00
|
|
|
TMTag *tag_a, *tag_b;
|
|
|
|
gint cmp;
|
2008-11-03 17:25:35 +00:00
|
|
|
|
|
|
|
gtk_tree_model_get(model, a, SYMBOLS_COLUMN_TAG, &tag_a, -1);
|
|
|
|
gtk_tree_model_get(model, b, SYMBOLS_COLUMN_TAG, &tag_b, -1);
|
|
|
|
|
2008-11-05 12:50:29 +00:00
|
|
|
/* Check if the iters can be sorted based on tag name and line, not tree item name.
|
|
|
|
* Sort by tree name if the scope was prepended, e.g. 'ScopeNameWithNoTag::TagName'. */
|
|
|
|
if (tag_a && !tag_has_missing_parent(tag_a, GTK_TREE_STORE(model), a) &&
|
|
|
|
tag_b && !tag_has_missing_parent(tag_b, GTK_TREE_STORE(model), b))
|
2008-11-03 17:25:35 +00:00
|
|
|
{
|
2011-03-05 22:50:04 +00:00
|
|
|
cmp = sort_by_name ? compare_symbol(tag_a, tag_b) :
|
2008-11-03 17:25:35 +00:00
|
|
|
compare_symbol_lines(tag_a, tag_b);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gchar *astr, *bstr;
|
|
|
|
|
|
|
|
gtk_tree_model_get(model, a, SYMBOLS_COLUMN_NAME, &astr, -1);
|
|
|
|
gtk_tree_model_get(model, b, SYMBOLS_COLUMN_NAME, &bstr, -1);
|
|
|
|
|
|
|
|
/* if a is toplevel, b must be also */
|
|
|
|
if (gtk_tree_store_iter_depth(GTK_TREE_STORE(model), a) == 0)
|
2008-11-04 18:14:04 +00:00
|
|
|
{
|
2008-11-03 17:25:35 +00:00
|
|
|
cmp = compare_top_level_names(astr, bstr);
|
2008-11-04 18:14:04 +00:00
|
|
|
}
|
2008-11-03 17:25:35 +00:00
|
|
|
else
|
2008-11-04 18:14:04 +00:00
|
|
|
{
|
2010-06-06 18:02:49 +00:00
|
|
|
/* this is what g_strcmp0() does */
|
|
|
|
if (! astr)
|
2011-03-05 22:50:04 +00:00
|
|
|
cmp = -(astr != bstr);
|
2011-11-15 15:43:49 +01:00
|
|
|
else if (! bstr)
|
2011-03-05 22:50:04 +00:00
|
|
|
cmp = astr != bstr;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cmp = strcmp(astr, bstr);
|
|
|
|
|
|
|
|
/* sort duplicate 'ScopeName::OverloadedTagName' items by line as well */
|
|
|
|
if (tag_a && tag_b)
|
|
|
|
if (!sort_by_name ||
|
|
|
|
(utils_str_equal(tag_a->name, tag_b->name) &&
|
|
|
|
utils_str_equal(tag_a->atts.entry.scope, tag_b->atts.entry.scope)))
|
|
|
|
cmp = compare_symbol_lines(tag_a, tag_b);
|
|
|
|
}
|
2008-11-04 18:14:04 +00:00
|
|
|
}
|
2008-11-03 17:25:35 +00:00
|
|
|
g_free(astr);
|
|
|
|
g_free(bstr);
|
|
|
|
}
|
2011-03-05 22:50:04 +00:00
|
|
|
tm_tag_unref(tag_a);
|
|
|
|
tm_tag_unref(tag_b);
|
|
|
|
|
|
|
|
return cmp;
|
2008-11-03 17:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void sort_tree(GtkTreeStore *store, gboolean sort_by_name)
|
|
|
|
{
|
2009-09-17 16:39:11 +00:00
|
|
|
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store), SYMBOLS_COLUMN_NAME, tree_sort_func,
|
2008-11-03 17:25:35 +00:00
|
|
|
GINT_TO_POINTER(sort_by_name), NULL);
|
|
|
|
|
2009-09-17 16:39:11 +00:00
|
|
|
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(store), SYMBOLS_COLUMN_NAME, GTK_SORT_ASCENDING);
|
2008-11-03 17:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-10-02 15:48:50 +00:00
|
|
|
gboolean symbols_recreate_tag_list(GeanyDocument *doc, gint sort_mode)
|
|
|
|
{
|
2008-11-03 17:25:35 +00:00
|
|
|
GList *tags;
|
2008-10-02 15:48:50 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_val_if_fail(doc != NULL, FALSE);
|
2008-10-02 15:48:50 +00:00
|
|
|
|
2008-11-03 17:25:35 +00:00
|
|
|
tags = get_tag_list(doc, tm_tag_max_t);
|
2009-04-15 22:47:33 +00:00
|
|
|
if (tags == NULL)
|
2008-10-02 15:48:50 +00:00
|
|
|
return FALSE;
|
|
|
|
|
Update the symbol list rather than clearing and re-building it
The main advantages of not clearing and rebuilding the whole list is
that it doesn't loose the folding and selection (as far as the selected
row(s) still exist after the update, of course), and it reduces
flickering upon update.
The current implementation works in 3-steps:
1) mark all rows as invalid;
2) insert/update the rows, according to the new tag list, marking them
as valid;
3) remove all rows that are still invalid.
This walks (rows) the first time, (tags*rows) the second and (rows) the
third. This also uses an extra column to store the row's validity.
A (probably) better implementation would be to:
1) walk the current rows, updating them if necessary, or removing them;
2) add the remaining tags that weren't there before.
This is probably faster in theory (and probably also in practice), but
it needs to refactor a lot the code to easily update *or* create a row,
what the current code does not provide.
Basically this is would be a two-pass update, walking (rows*tags) in
the first pass, and only the remaining non-added tags in the second.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@5562 ea778897-0a13-0410-b9d1-a72fbfd435f5
2011-03-05 22:53:13 +00:00
|
|
|
/* FIXME: Not sure why we detached the model here? */
|
|
|
|
|
|
|
|
/* disable sorting during update because the code doesn't support correctly
|
|
|
|
* models that are currently being built */
|
|
|
|
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(doc->priv->tag_store), GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, 0);
|
|
|
|
|
2008-10-02 15:48:50 +00:00
|
|
|
/* add grandparent type iters */
|
2008-11-03 17:25:35 +00:00
|
|
|
add_top_level_items(doc);
|
2008-10-02 15:48:50 +00:00
|
|
|
|
2011-11-20 20:26:57 +01:00
|
|
|
update_tree_tags(doc, &tags);
|
2008-11-03 17:25:35 +00:00
|
|
|
g_list_free(tags);
|
2008-10-02 12:06:20 +00:00
|
|
|
|
2008-09-26 17:28:50 +00:00
|
|
|
hide_empty_rows(doc->priv->tag_store);
|
2008-10-02 12:06:20 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (sort_mode == SYMBOLS_SORT_USE_PREVIOUS)
|
2008-11-20 17:01:02 +00:00
|
|
|
sort_mode = doc->priv->symbol_list_sort_mode;
|
2008-11-03 17:25:35 +00:00
|
|
|
|
|
|
|
sort_tree(doc->priv->tag_store, sort_mode == SYMBOLS_SORT_BY_NAME);
|
2008-11-20 16:52:46 +00:00
|
|
|
doc->priv->symbol_list_sort_mode = sort_mode;
|
2008-11-03 17:25:35 +00:00
|
|
|
|
2007-01-13 13:25:05 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-27 11:00:29 +00:00
|
|
|
/* Detects a global tags filetype from the *.lang.* language extension.
|
|
|
|
* Returns NULL if there was no matching TM language. */
|
2008-05-16 14:17:54 +00:00
|
|
|
static GeanyFiletype *detect_global_tags_filetype(const gchar *utf8_filename)
|
2007-04-27 11:00:29 +00:00
|
|
|
{
|
|
|
|
gchar *tags_ext;
|
2012-04-23 13:44:22 +01:00
|
|
|
gchar *shortname = utils_strdupa(utf8_filename);
|
2008-05-16 14:17:54 +00:00
|
|
|
GeanyFiletype *ft = NULL;
|
2007-04-27 11:00:29 +00:00
|
|
|
|
2012-04-23 13:44:22 +01:00
|
|
|
tags_ext = g_strrstr(shortname, ".tags");
|
2009-04-15 22:47:33 +00:00
|
|
|
if (tags_ext)
|
2007-04-27 11:00:29 +00:00
|
|
|
{
|
2008-02-27 13:17:29 +00:00
|
|
|
*tags_ext = '\0'; /* remove .tags extension */
|
2008-03-05 17:09:57 +00:00
|
|
|
ft = filetypes_detect_from_extension(shortname);
|
2012-04-23 13:44:22 +01:00
|
|
|
if (ft->id != GEANY_FILETYPES_NONE)
|
|
|
|
return ft;
|
2007-04-27 11:00:29 +00:00
|
|
|
}
|
2012-04-23 13:44:22 +01:00
|
|
|
return NULL;
|
2007-04-27 11:00:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-21 13:26:16 +00:00
|
|
|
/* Adapted from anjuta-2.0.2/global-tags/tm_global_tags.c, thanks.
|
2007-04-27 11:00:29 +00:00
|
|
|
* Needs full paths for filenames, except for C/C++ tag files, when CFLAGS includes
|
|
|
|
* the relevant path.
|
2007-03-21 13:26:16 +00:00
|
|
|
* Example:
|
2007-04-27 11:00:29 +00:00
|
|
|
* CFLAGS=-I/home/user/libname-1.x geany -g libname.d.tags libname.h */
|
2007-09-28 11:48:55 +00:00
|
|
|
int symbols_generate_global_tags(int argc, char **argv, gboolean want_preprocess)
|
2007-03-21 13:26:16 +00:00
|
|
|
{
|
2012-04-22 10:54:41 +10:00
|
|
|
/* -E pre-process, -dD output user macros, -p prof info (?) */
|
2012-04-24 17:19:40 +01:00
|
|
|
const char pre_process[] = "gcc -E -dD -p -I.";
|
2007-03-21 13:26:16 +00:00
|
|
|
|
|
|
|
if (argc > 2)
|
|
|
|
{
|
|
|
|
/* Create global taglist */
|
|
|
|
int status;
|
|
|
|
char *command;
|
2007-04-27 11:00:29 +00:00
|
|
|
const char *tags_file = argv[1];
|
|
|
|
char *utf8_fname;
|
2008-05-16 14:17:54 +00:00
|
|
|
GeanyFiletype *ft;
|
2007-04-27 11:00:29 +00:00
|
|
|
|
|
|
|
utf8_fname = utils_get_utf8_from_locale(tags_file);
|
|
|
|
ft = detect_global_tags_filetype(utf8_fname);
|
|
|
|
g_free(utf8_fname);
|
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (ft == NULL)
|
2007-04-27 11:00:29 +00:00
|
|
|
{
|
2007-04-30 11:56:50 +00:00
|
|
|
g_printerr(_("Unknown filetype extension for \"%s\".\n"), tags_file);
|
2007-04-27 11:00:29 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2010-02-01 21:44:10 +00:00
|
|
|
/* load config in case of custom filetypes */
|
|
|
|
filetypes_load_config(ft->id, FALSE);
|
|
|
|
|
2008-07-03 13:46:01 +00:00
|
|
|
/* load ignore list for C/C++ parser */
|
|
|
|
if (ft->id == GEANY_FILETYPES_C || ft->id == GEANY_FILETYPES_CPP)
|
|
|
|
load_c_ignore_tags();
|
|
|
|
|
2007-09-28 11:48:55 +00:00
|
|
|
if (want_preprocess && (ft->id == GEANY_FILETYPES_C || ft->id == GEANY_FILETYPES_CPP))
|
2007-04-27 11:00:29 +00:00
|
|
|
command = g_strdup_printf("%s %s", pre_process, NVL(getenv("CFLAGS"), ""));
|
|
|
|
else
|
2008-02-27 13:17:29 +00:00
|
|
|
command = NULL; /* don't preprocess */
|
2007-04-27 11:00:29 +00:00
|
|
|
|
|
|
|
geany_debug("Generating %s tags file.", ft->name);
|
2007-11-30 18:01:43 +00:00
|
|
|
tm_get_workspace();
|
2011-08-19 00:07:41 +00:00
|
|
|
status = tm_workspace_create_global_tags(command, (const char **) (argv + 2),
|
2007-04-27 11:00:29 +00:00
|
|
|
argc - 2, tags_file, ft->lang);
|
2007-03-21 13:26:16 +00:00
|
|
|
g_free(command);
|
2008-07-03 13:46:01 +00:00
|
|
|
symbols_finalize(); /* free c_tags_ignore data */
|
2007-04-27 11:00:29 +00:00
|
|
|
if (! status)
|
|
|
|
{
|
2007-11-30 18:01:43 +00:00
|
|
|
g_printerr(_("Failed to create tags file, perhaps because no tags "
|
|
|
|
"were found.\n"));
|
2007-03-21 13:26:16 +00:00
|
|
|
return 1;
|
2007-04-27 11:00:29 +00:00
|
|
|
}
|
2007-03-21 13:26:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-04-30 11:56:50 +00:00
|
|
|
g_printerr(_("Usage: %s -g <Tag File> <File list>\n\n"), argv[0]);
|
|
|
|
g_printerr(_("Example:\n"
|
2007-03-21 13:26:16 +00:00
|
|
|
"CFLAGS=`pkg-config gtk+-2.0 --cflags` %s -g gtk2.c.tags"
|
2007-04-30 11:56:50 +00:00
|
|
|
" /usr/include/gtk-2.0/gtk/gtk.h\n"), argv[0]);
|
2007-03-21 13:26:16 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-20 11:24:23 +00:00
|
|
|
void symbols_show_load_tags_dialog(void)
|
2007-04-18 15:21:33 +00:00
|
|
|
{
|
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkFileFilter *filter;
|
|
|
|
|
2008-05-22 14:41:28 +00:00
|
|
|
dialog = gtk_file_chooser_dialog_new(_("Load Tags"), GTK_WINDOW(main_widgets.window),
|
2007-04-18 15:21:33 +00:00
|
|
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OPEN, GTK_RESPONSE_OK,
|
|
|
|
NULL);
|
2007-05-15 15:16:16 +00:00
|
|
|
gtk_widget_set_name(dialog, "GeanyDialog");
|
2007-04-18 15:21:33 +00:00
|
|
|
filter = gtk_file_filter_new();
|
2012-04-23 13:44:22 +01:00
|
|
|
gtk_file_filter_set_name(filter, _("Geany tag files (*.*.tags)"));
|
|
|
|
gtk_file_filter_add_pattern(filter, "*.*.tags");
|
2007-04-18 15:21:33 +00:00
|
|
|
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
|
|
|
|
|
|
|
|
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
|
|
|
|
{
|
|
|
|
GSList *flist = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
|
|
|
|
GSList *item;
|
|
|
|
|
|
|
|
for (item = flist; item != NULL; item = g_slist_next(item))
|
|
|
|
{
|
|
|
|
gchar *fname = item->data;
|
|
|
|
gchar *utf8_fname;
|
2008-05-16 14:17:54 +00:00
|
|
|
GeanyFiletype *ft;
|
2007-04-18 15:21:33 +00:00
|
|
|
|
|
|
|
utf8_fname = utils_get_utf8_from_locale(fname);
|
2007-04-27 11:00:29 +00:00
|
|
|
ft = detect_global_tags_filetype(utf8_fname);
|
|
|
|
|
2009-05-01 15:04:46 +00:00
|
|
|
if (ft != NULL && symbols_load_global_tags(fname, ft))
|
2008-12-04 15:56:54 +00:00
|
|
|
/* For translators: the first wildcard is the filetype, the second the filename */
|
2010-11-04 18:06:09 +00:00
|
|
|
ui_set_statusbar(TRUE, _("Loaded %s tags file '%s'."),
|
|
|
|
filetypes_get_display_name(ft), utf8_fname);
|
2007-04-27 11:00:29 +00:00
|
|
|
else
|
2007-10-24 10:52:48 +00:00
|
|
|
ui_set_statusbar(TRUE, _("Could not load tags file '%s'."), utf8_fname);
|
2007-04-27 11:00:29 +00:00
|
|
|
|
2007-04-18 15:21:33 +00:00
|
|
|
g_free(utf8_fname);
|
|
|
|
g_free(fname);
|
|
|
|
}
|
|
|
|
g_slist_free(flist);
|
|
|
|
}
|
|
|
|
gtk_widget_destroy(dialog);
|
|
|
|
}
|
2007-05-11 11:58:56 +00:00
|
|
|
|
|
|
|
|
2012-04-26 13:18:05 +01:00
|
|
|
static void detect_tag_files(const GSList *file_list)
|
2007-05-11 11:58:56 +00:00
|
|
|
{
|
|
|
|
const GSList *node;
|
|
|
|
|
|
|
|
for (node = file_list; node != NULL; node = g_slist_next(node))
|
|
|
|
{
|
|
|
|
gchar *fname = node->data;
|
|
|
|
gchar *utf8_fname = utils_get_utf8_from_locale(fname);
|
2008-05-16 14:17:54 +00:00
|
|
|
GeanyFiletype *ft = detect_global_tags_filetype(utf8_fname);
|
2007-05-11 11:58:56 +00:00
|
|
|
|
|
|
|
g_free(utf8_fname);
|
|
|
|
|
2009-03-20 16:18:32 +00:00
|
|
|
if (FILETYPE_ID(ft) != GEANY_FILETYPES_NONE)
|
2012-05-08 19:27:40 +02:00
|
|
|
ft->priv->tag_files = g_slist_prepend(ft->priv->tag_files, fname);
|
2007-05-11 11:58:56 +00:00
|
|
|
else
|
|
|
|
geany_debug("Unknown filetype for file '%s'.", fname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-26 13:18:05 +01:00
|
|
|
static void init_user_tags(void)
|
2007-05-11 11:58:56 +00:00
|
|
|
{
|
2009-04-30 12:54:15 +00:00
|
|
|
GSList *file_list = NULL, *list = NULL;
|
2011-04-13 12:59:20 +00:00
|
|
|
gchar *dir;
|
2007-05-11 11:58:56 +00:00
|
|
|
|
2012-02-06 16:41:18 +00:00
|
|
|
dir = g_build_filename(app->configdir, "tags", NULL);
|
2009-04-30 12:54:15 +00:00
|
|
|
/* create the user tags dir for next time if it doesn't exist */
|
|
|
|
if (! g_file_test(dir, G_FILE_TEST_IS_DIR))
|
|
|
|
{
|
|
|
|
utils_mkdir(dir, FALSE);
|
|
|
|
}
|
2012-05-08 19:32:04 +02:00
|
|
|
file_list = utils_get_file_list_full(dir, TRUE, FALSE, NULL);
|
2009-04-30 12:54:15 +00:00
|
|
|
|
2012-02-06 16:41:18 +00:00
|
|
|
SETPTR(dir, g_build_filename(app->datadir, "tags", NULL));
|
2012-05-08 19:32:04 +02:00
|
|
|
list = utils_get_file_list_full(dir, TRUE, FALSE, NULL);
|
2011-04-13 12:59:20 +00:00
|
|
|
g_free(dir);
|
|
|
|
|
2009-04-30 12:54:15 +00:00
|
|
|
file_list = g_slist_concat(file_list, list);
|
2012-04-26 13:18:05 +01:00
|
|
|
detect_tag_files(file_list);
|
|
|
|
/* don't need to delete list contents because they are stored in ft->priv->tag_files */
|
2007-05-11 11:58:56 +00:00
|
|
|
g_slist_free(file_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void load_user_tags(filetype_id ft_id)
|
|
|
|
{
|
2009-08-12 11:19:54 +00:00
|
|
|
static guchar *tags_loaded = NULL;
|
2012-04-26 13:18:05 +01:00
|
|
|
static gboolean init_tags = FALSE;
|
|
|
|
const GSList *node;
|
2009-05-01 15:04:46 +00:00
|
|
|
GeanyFiletype *ft = filetypes[ft_id];
|
2007-05-11 11:58:56 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(ft_id > 0);
|
2007-05-11 11:58:56 +00:00
|
|
|
|
2009-08-12 11:19:54 +00:00
|
|
|
if (!tags_loaded)
|
|
|
|
tags_loaded = g_new0(guchar, filetypes_array->len);
|
2009-04-15 22:47:33 +00:00
|
|
|
if (tags_loaded[ft_id])
|
2007-05-11 11:58:56 +00:00
|
|
|
return;
|
2008-02-27 13:17:29 +00:00
|
|
|
tags_loaded[ft_id] = TRUE; /* prevent reloading */
|
2007-05-11 11:58:56 +00:00
|
|
|
|
2012-04-26 13:18:05 +01:00
|
|
|
if (!init_tags)
|
|
|
|
{
|
|
|
|
init_user_tags();
|
|
|
|
init_tags = TRUE;
|
|
|
|
}
|
2007-05-11 11:58:56 +00:00
|
|
|
|
2012-04-26 13:18:05 +01:00
|
|
|
for (node = ft->priv->tag_files; node != NULL; node = g_slist_next(node))
|
2007-05-11 11:58:56 +00:00
|
|
|
{
|
2009-04-30 12:54:15 +00:00
|
|
|
const gchar *fname = node->data;
|
2007-05-11 11:58:56 +00:00
|
|
|
|
2009-05-01 15:04:46 +00:00
|
|
|
symbols_load_global_tags(fname, ft);
|
2007-05-11 11:58:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-23 13:17:42 +00:00
|
|
|
static gboolean goto_tag(const gchar *name, gboolean definition)
|
2007-09-25 12:39:41 +00:00
|
|
|
{
|
|
|
|
const gint forward_types = tm_tag_prototype_t | tm_tag_externvar_t;
|
2011-12-17 23:10:03 +01:00
|
|
|
guint type;
|
2008-03-24 16:44:43 +00:00
|
|
|
TMTag *tmtag = NULL;
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *old_doc = document_get_current();
|
2008-02-10 12:34:28 +00:00
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* goto tag definition: all except prototypes / forward declarations / externs */
|
2007-09-25 12:39:41 +00:00
|
|
|
type = (definition) ? tm_tag_max_t - forward_types : forward_types;
|
|
|
|
|
2008-03-24 16:44:43 +00:00
|
|
|
/* first look in the current document */
|
2008-06-15 13:35:48 +00:00
|
|
|
if (old_doc != NULL && old_doc->tm_file)
|
|
|
|
tmtag = find_work_object_tag(old_doc->tm_file, name, type);
|
2008-03-24 16:44:43 +00:00
|
|
|
|
|
|
|
/* if not found, look in the workspace */
|
|
|
|
if (tmtag == NULL)
|
|
|
|
tmtag = find_workspace_tag(name, type);
|
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (tmtag != NULL)
|
2007-09-25 12:39:41 +00:00
|
|
|
{
|
2008-06-15 13:35:48 +00:00
|
|
|
GeanyDocument *new_doc = document_find_by_real_path(
|
2008-06-03 17:22:04 +00:00
|
|
|
tmtag->atts.entry.file->work_object.file_name);
|
|
|
|
|
2010-11-23 13:17:42 +00:00
|
|
|
if (new_doc)
|
2008-01-02 21:20:33 +00:00
|
|
|
{
|
2010-11-23 13:17:42 +00:00
|
|
|
/* If we are already on the tag line, swap definition/declaration */
|
|
|
|
if (new_doc == old_doc &&
|
|
|
|
tmtag->atts.entry.line == (guint)sci_get_current_line(old_doc->editor->sci) + 1)
|
|
|
|
{
|
|
|
|
if (goto_tag(name, !definition))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* not found in opened document, should open */
|
2008-06-15 13:35:48 +00:00
|
|
|
new_doc = document_open_file(tmtag->atts.entry.file->work_object.file_name, FALSE, NULL, NULL);
|
2008-01-02 21:20:33 +00:00
|
|
|
}
|
2007-09-25 12:39:41 +00:00
|
|
|
|
2008-06-15 13:35:48 +00:00
|
|
|
if (navqueue_goto_line(old_doc, new_doc, tmtag->atts.entry.line))
|
2007-09-25 12:39:41 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2010-11-23 13:17:42 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gboolean symbols_goto_tag(const gchar *name, gboolean definition)
|
|
|
|
{
|
|
|
|
if (goto_tag(name, definition))
|
|
|
|
return TRUE;
|
|
|
|
|
2008-02-27 13:17:29 +00:00
|
|
|
/* if we are here, there was no match and we are beeping ;-) */
|
2007-09-25 12:39:41 +00:00
|
|
|
utils_beep();
|
2010-11-23 13:17:42 +00:00
|
|
|
|
|
|
|
if (!definition)
|
2007-10-24 10:52:48 +00:00
|
|
|
ui_set_statusbar(FALSE, _("Forward declaration \"%s\" not found."), name);
|
2007-09-25 12:39:41 +00:00
|
|
|
else
|
2007-10-24 10:52:48 +00:00
|
|
|
ui_set_statusbar(FALSE, _("Definition of \"%s\" not found."), name);
|
2007-09-25 12:39:41 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-08 16:30:37 +00:00
|
|
|
/* This could perhaps be improved to check for #if, class etc. */
|
|
|
|
static gint get_function_fold_number(GeanyDocument *doc)
|
|
|
|
{
|
|
|
|
/* for Java the functions are always one fold level above the class scope */
|
2010-10-25 17:24:47 +00:00
|
|
|
if (doc->file_type->id == GEANY_FILETYPES_JAVA)
|
2008-07-08 16:30:37 +00:00
|
|
|
return SC_FOLDLEVELBASE + 1;
|
|
|
|
else
|
|
|
|
return SC_FOLDLEVELBASE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-17 22:41:24 +02:00
|
|
|
/* Should be used only with get_current_tag_cached.
|
|
|
|
* tag_types caching might trigger recomputation too often but this isn't used differently often
|
|
|
|
* enough to be an issue for now */
|
|
|
|
static gboolean current_tag_changed(GeanyDocument *doc, gint cur_line, gint fold_level, guint tag_types)
|
2008-07-08 16:30:37 +00:00
|
|
|
{
|
|
|
|
static gint old_line = -2;
|
|
|
|
static GeanyDocument *old_doc = NULL;
|
|
|
|
static gint old_fold_num = -1;
|
2012-09-17 22:41:24 +02:00
|
|
|
static guint old_tag_types = 0;
|
2008-07-08 16:30:37 +00:00
|
|
|
const gint fold_num = fold_level & SC_FOLDLEVELNUMBERMASK;
|
|
|
|
gboolean ret;
|
|
|
|
|
|
|
|
/* check if the cached line and file index have changed since last time: */
|
2012-09-17 22:41:24 +02:00
|
|
|
if (doc == NULL || doc != old_doc || old_tag_types != tag_types)
|
2008-07-08 16:30:37 +00:00
|
|
|
ret = TRUE;
|
2012-09-17 22:41:24 +02:00
|
|
|
else if (cur_line == old_line)
|
2008-07-08 16:30:37 +00:00
|
|
|
ret = FALSE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* if the line has only changed by 1 */
|
|
|
|
if (abs(cur_line - old_line) == 1)
|
|
|
|
{
|
2012-09-17 14:26:39 +02:00
|
|
|
/* It's the same function if the fold number hasn't changed */
|
|
|
|
ret = (fold_num != old_fold_num);
|
2008-07-08 16:30:37 +00:00
|
|
|
}
|
|
|
|
else ret = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* record current line and file index for next time */
|
|
|
|
old_line = cur_line;
|
|
|
|
old_doc = doc;
|
|
|
|
old_fold_num = fold_num;
|
2012-09-17 22:41:24 +02:00
|
|
|
old_tag_types = tag_types;
|
2008-07-08 16:30:37 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Parse the function name up to 2 lines before tag_line.
|
|
|
|
* C++ like syntax should be parsed by parse_cpp_function_at_line, otherwise the return
|
|
|
|
* type or argument names can be confused with the function name. */
|
|
|
|
static gchar *parse_function_at_line(ScintillaObject *sci, gint tag_line)
|
|
|
|
{
|
|
|
|
gint start, end, max_pos;
|
|
|
|
gchar *cur_tag;
|
|
|
|
gint fn_style;
|
|
|
|
|
|
|
|
switch (sci_get_lexer(sci))
|
|
|
|
{
|
|
|
|
case SCLEX_RUBY: fn_style = SCE_RB_DEFNAME; break;
|
|
|
|
case SCLEX_PYTHON: fn_style = SCE_P_DEFNAME; break;
|
|
|
|
default: fn_style = SCE_C_IDENTIFIER; /* several lexers use SCE_C_IDENTIFIER */
|
|
|
|
}
|
|
|
|
start = sci_get_position_from_line(sci, tag_line - 2);
|
|
|
|
max_pos = sci_get_position_from_line(sci, tag_line + 1);
|
|
|
|
while (sci_get_style_at(sci, start) != fn_style
|
|
|
|
&& start < max_pos) start++;
|
|
|
|
|
|
|
|
end = start;
|
|
|
|
while (sci_get_style_at(sci, end) == fn_style
|
|
|
|
&& end < max_pos) end++;
|
|
|
|
|
2009-04-05 21:07:40 +00:00
|
|
|
if (start == end)
|
|
|
|
return NULL;
|
2008-07-08 16:30:37 +00:00
|
|
|
cur_tag = g_malloc(end - start + 1);
|
|
|
|
sci_get_text_range(sci, start, end, cur_tag);
|
|
|
|
return cur_tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Parse the function name */
|
|
|
|
static gchar *parse_cpp_function_at_line(ScintillaObject *sci, gint tag_line)
|
|
|
|
{
|
|
|
|
gint start, end, first_pos, max_pos;
|
|
|
|
gint tmp;
|
|
|
|
gchar c;
|
|
|
|
gchar *cur_tag;
|
|
|
|
|
|
|
|
first_pos = end = sci_get_position_from_line(sci, tag_line);
|
|
|
|
max_pos = sci_get_position_from_line(sci, tag_line + 1);
|
|
|
|
tmp = 0;
|
|
|
|
/* goto the begin of function body */
|
|
|
|
while (end < max_pos &&
|
|
|
|
(tmp = sci_get_char_at(sci, end)) != '{' &&
|
|
|
|
tmp != 0) end++;
|
|
|
|
if (tmp == 0) end --;
|
|
|
|
|
|
|
|
/* go back to the end of function identifier */
|
|
|
|
while (end > 0 && end > first_pos - 500 &&
|
|
|
|
(tmp = sci_get_char_at(sci, end)) != '(' &&
|
|
|
|
tmp != 0) end--;
|
|
|
|
end--;
|
|
|
|
if (end < 0) end = 0;
|
|
|
|
|
|
|
|
/* skip whitespaces between identifier and ( */
|
|
|
|
while (end > 0 && isspace(sci_get_char_at(sci, end))) end--;
|
|
|
|
|
|
|
|
start = end;
|
|
|
|
c = 0;
|
|
|
|
/* Use tmp to find SCE_C_IDENTIFIER or SCE_C_GLOBALCLASS chars */
|
|
|
|
while (start >= 0 && ((tmp = sci_get_style_at(sci, start)) == SCE_C_IDENTIFIER
|
|
|
|
|| tmp == SCE_C_GLOBALCLASS
|
|
|
|
|| (c = sci_get_char_at(sci, start)) == '~'
|
|
|
|
|| c == ':'))
|
|
|
|
start--;
|
|
|
|
if (start != 0 && start < end) start++; /* correct for last non-matching char */
|
|
|
|
|
|
|
|
if (start == end) return NULL;
|
|
|
|
cur_tag = g_malloc(end - start + 2);
|
|
|
|
sci_get_text_range(sci, start, end + 1, cur_tag);
|
|
|
|
return cur_tag;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-17 22:41:24 +02:00
|
|
|
static gint get_fold_header_after(ScintillaObject *sci, gint line)
|
2008-07-08 16:30:37 +00:00
|
|
|
{
|
2012-09-17 22:41:24 +02:00
|
|
|
gint line_count = sci_get_line_count(sci);
|
2008-07-08 16:30:37 +00:00
|
|
|
|
2012-09-17 22:41:24 +02:00
|
|
|
for (; line < line_count; line++)
|
2008-07-08 16:30:37 +00:00
|
|
|
{
|
2012-09-17 22:41:24 +02:00
|
|
|
if (sci_get_fold_level(sci, line) & SC_FOLDLEVELHEADERFLAG)
|
|
|
|
return line;
|
2008-07-08 16:30:37 +00:00
|
|
|
}
|
|
|
|
|
2012-09-17 22:41:24 +02:00
|
|
|
return -1;
|
|
|
|
}
|
2008-07-08 16:30:37 +00:00
|
|
|
|
|
|
|
|
2012-09-17 22:41:24 +02:00
|
|
|
static gint get_current_tag_name(GeanyDocument *doc, gchar **tagname, guint tag_types)
|
|
|
|
{
|
|
|
|
gint line;
|
|
|
|
gint parent;
|
|
|
|
|
|
|
|
line = sci_get_current_line(doc->editor->sci);
|
|
|
|
parent = sci_get_fold_parent(doc->editor->sci, line);
|
|
|
|
/* if we're inside a fold level and we have up-to-date tags, get the function from TM */
|
|
|
|
if (parent >= 0 && doc->tm_file != NULL && doc->tm_file->tags_array != NULL &&
|
2012-09-17 03:02:25 +02:00
|
|
|
(! doc->changed || editor_prefs.autocompletion_update_freq > 0))
|
2008-07-08 16:30:37 +00:00
|
|
|
{
|
2012-09-17 22:41:24 +02:00
|
|
|
const TMTag *tag = tm_get_current_tag(doc->tm_file->tags_array, parent + 1, tag_types);
|
2008-07-08 16:30:37 +00:00
|
|
|
|
2012-09-17 22:41:24 +02:00
|
|
|
if (tag)
|
2008-07-08 16:30:37 +00:00
|
|
|
{
|
2012-09-17 22:41:24 +02:00
|
|
|
gint tag_line = tag->atts.entry.line - 1;
|
|
|
|
gint last_child = line + 1;
|
|
|
|
|
|
|
|
/* if it may be a false positive because we're inside a fold level not inside anything
|
|
|
|
* we match, e.g. a #if in C or C++, we check we're inside the fold level that start
|
|
|
|
* right after the tag we got from TM */
|
|
|
|
if (abs(tag_line - parent) > 1)
|
|
|
|
{
|
|
|
|
gint tag_fold = get_fold_header_after(doc->editor->sci, tag_line);
|
|
|
|
if (tag_fold >= 0)
|
|
|
|
last_child = scintilla_send_message(doc->editor->sci, SCI_GETLASTCHILD, tag_fold, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (line <= last_child)
|
|
|
|
{
|
|
|
|
if (tag->atts.entry.scope)
|
|
|
|
*tagname = g_strconcat(tag->atts.entry.scope,
|
|
|
|
symbols_get_context_separator(doc->file_type->id), tag->name, NULL);
|
|
|
|
else
|
|
|
|
*tagname = g_strdup(tag->name);
|
|
|
|
|
|
|
|
return tag_line;
|
|
|
|
}
|
2008-07-08 16:30:37 +00:00
|
|
|
}
|
|
|
|
}
|
2012-09-17 22:41:24 +02:00
|
|
|
/* for the poor guy with a modified document and without real time tag parsing, we fallback
|
|
|
|
* to dirty and inaccurate hand-parsing */
|
|
|
|
else if (parent >= 0 && doc->file_type != NULL && doc->file_type->id != GEANY_FILETYPES_NONE)
|
2008-07-08 16:30:37 +00:00
|
|
|
{
|
|
|
|
const gint fn_fold = get_function_fold_number(doc);
|
2012-09-17 22:41:24 +02:00
|
|
|
gint tag_line = parent;
|
|
|
|
gint fold_level = sci_get_fold_level(doc->editor->sci, tag_line);
|
2008-07-08 16:30:37 +00:00
|
|
|
|
2012-09-17 22:41:24 +02:00
|
|
|
/* find the top level fold point */
|
|
|
|
while (tag_line >= 0 && (fold_level & SC_FOLDLEVELNUMBERMASK) != fn_fold)
|
2008-07-08 16:30:37 +00:00
|
|
|
{
|
2008-07-14 11:13:54 +00:00
|
|
|
tag_line = sci_get_fold_parent(doc->editor->sci, tag_line);
|
|
|
|
fold_level = sci_get_fold_level(doc->editor->sci, tag_line);
|
2012-09-17 22:41:24 +02:00
|
|
|
}
|
2008-07-08 16:30:37 +00:00
|
|
|
|
|
|
|
if (tag_line >= 0)
|
|
|
|
{
|
2012-09-17 22:41:24 +02:00
|
|
|
gchar *cur_tag;
|
|
|
|
|
2008-07-14 11:13:54 +00:00
|
|
|
if (sci_get_lexer(doc->editor->sci) == SCLEX_CPP)
|
|
|
|
cur_tag = parse_cpp_function_at_line(doc->editor->sci, tag_line);
|
2008-07-08 16:30:37 +00:00
|
|
|
else
|
2008-07-14 11:13:54 +00:00
|
|
|
cur_tag = parse_function_at_line(doc->editor->sci, tag_line);
|
2008-07-08 16:30:37 +00:00
|
|
|
|
|
|
|
if (cur_tag != NULL)
|
|
|
|
{
|
|
|
|
*tagname = cur_tag;
|
|
|
|
return tag_line;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-17 22:41:24 +02:00
|
|
|
*tagname = g_strdup(_("unknown"));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gint get_current_tag_name_cached(GeanyDocument *doc, const gchar **tagname, guint tag_types)
|
|
|
|
{
|
|
|
|
static gint tag_line = -1;
|
|
|
|
static gchar *cur_tag = NULL;
|
|
|
|
|
|
|
|
if (doc == NULL) /* reset current function */
|
|
|
|
{
|
|
|
|
current_tag_changed(NULL, -1, -1, 0);
|
|
|
|
g_free(cur_tag);
|
|
|
|
cur_tag = g_strdup(_("unknown"));
|
|
|
|
if (tagname != NULL)
|
|
|
|
*tagname = cur_tag;
|
|
|
|
tag_line = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gint line = sci_get_current_line(doc->editor->sci);
|
|
|
|
gint fold_level = sci_get_fold_level(doc->editor->sci, line);
|
|
|
|
|
|
|
|
if (current_tag_changed(doc, line, fold_level, tag_types))
|
|
|
|
{
|
|
|
|
g_free(cur_tag);
|
|
|
|
tag_line = get_current_tag_name(doc, &cur_tag, tag_types);
|
|
|
|
}
|
|
|
|
*tagname = cur_tag;
|
|
|
|
}
|
|
|
|
|
2008-07-08 16:30:37 +00:00
|
|
|
return tag_line;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-17 22:41:24 +02:00
|
|
|
/* Sets *tagname to point at the current function or tag name.
|
|
|
|
* If doc is NULL, reset the cached current tag data to ensure it will be reparsed on the next
|
|
|
|
* call to this function.
|
|
|
|
* Returns: line number of the current tag, or -1 if unknown. */
|
|
|
|
gint symbols_get_current_function(GeanyDocument *doc, const gchar **tagname)
|
|
|
|
{
|
|
|
|
return get_current_tag_name_cached(doc, tagname, tm_tag_function_t | tm_tag_method_t);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-17 22:51:36 +02:00
|
|
|
/* same as symbols_get_current_function() but finds class, namespaces and more */
|
|
|
|
gint symbols_get_current_scope(GeanyDocument *doc, const gchar **tagname)
|
|
|
|
{
|
|
|
|
guint tag_types = (tm_tag_function_t | tm_tag_method_t | tm_tag_class_t |
|
|
|
|
tm_tag_struct_t | tm_tag_enum_t | tm_tag_union_t);
|
|
|
|
|
|
|
|
/* Python parser reports imports as namespaces which confuses the scope detection */
|
|
|
|
if (doc && doc->file_type->lang != filetypes[GEANY_FILETYPES_PYTHON]->lang)
|
|
|
|
tag_types |= tm_tag_namespace_t;
|
|
|
|
|
|
|
|
return get_current_tag_name_cached(doc, tagname, tag_types);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-20 16:52:46 +00:00
|
|
|
static void on_symbol_tree_sort_clicked(GtkMenuItem *menuitem, gpointer user_data)
|
2008-11-18 13:29:53 +00:00
|
|
|
{
|
|
|
|
gint sort_mode = GPOINTER_TO_INT(user_data);
|
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (ignore_callback)
|
2008-11-20 16:52:46 +00:00
|
|
|
return;
|
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (doc != NULL)
|
2008-11-18 13:29:53 +00:00
|
|
|
doc->has_tags = symbols_recreate_tag_list(doc, sort_mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-20 16:52:46 +00:00
|
|
|
static void on_symbol_tree_menu_show(GtkWidget *widget,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GeanyDocument *doc = document_get_current();
|
2008-11-21 13:06:09 +00:00
|
|
|
gboolean enable;
|
|
|
|
|
|
|
|
enable = doc && doc->has_tags;
|
|
|
|
gtk_widget_set_sensitive(symbol_menu.sort_by_name, enable);
|
|
|
|
gtk_widget_set_sensitive(symbol_menu.sort_by_appearance, enable);
|
|
|
|
gtk_widget_set_sensitive(symbol_menu.expand_all, enable);
|
|
|
|
gtk_widget_set_sensitive(symbol_menu.collapse_all, enable);
|
2013-03-17 13:26:28 +00:00
|
|
|
gtk_widget_set_sensitive(symbol_menu.find_usage, enable);
|
|
|
|
gtk_widget_set_sensitive(symbol_menu.find_doc_usage, enable);
|
2008-11-20 16:52:46 +00:00
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (! doc)
|
2008-11-20 16:52:46 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
ignore_callback = TRUE;
|
|
|
|
|
|
|
|
if (doc->priv->symbol_list_sort_mode == SYMBOLS_SORT_BY_NAME)
|
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(symbol_menu.sort_by_name), TRUE);
|
|
|
|
else
|
|
|
|
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(symbol_menu.sort_by_appearance), TRUE);
|
|
|
|
|
|
|
|
ignore_callback = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-21 13:06:09 +00:00
|
|
|
static void on_expand_collapse(GtkWidget *widget, gpointer user_data)
|
|
|
|
{
|
2011-10-30 22:52:29 +01:00
|
|
|
gboolean expand = GPOINTER_TO_INT(user_data);
|
2008-11-21 13:06:09 +00:00
|
|
|
GeanyDocument *doc = document_get_current();
|
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
if (! doc)
|
2008-11-21 13:06:09 +00:00
|
|
|
return;
|
|
|
|
|
2009-04-15 22:47:33 +00:00
|
|
|
g_return_if_fail(doc->priv->tag_tree);
|
2008-11-21 13:06:09 +00:00
|
|
|
|
|
|
|
if (expand)
|
|
|
|
gtk_tree_view_expand_all(GTK_TREE_VIEW(doc->priv->tag_tree));
|
|
|
|
else
|
|
|
|
gtk_tree_view_collapse_all(GTK_TREE_VIEW(doc->priv->tag_tree));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-25 15:54:12 +00:00
|
|
|
static void on_find_usage(GtkWidget *widget, G_GNUC_UNUSED gpointer unused)
|
2013-03-17 13:26:28 +00:00
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeSelection *selection;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
GeanyDocument *doc;
|
2013-03-17 17:28:46 +01:00
|
|
|
TMTag *tag = NULL;
|
2013-03-17 13:26:28 +00:00
|
|
|
|
|
|
|
doc = document_get_current();
|
|
|
|
if (!doc)
|
|
|
|
return;
|
|
|
|
|
|
|
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(doc->priv->tag_tree));
|
|
|
|
if (gtk_tree_selection_get_selected(selection, &model, &iter))
|
|
|
|
gtk_tree_model_get(model, &iter, SYMBOLS_COLUMN_TAG, &tag, -1);
|
|
|
|
if (tag)
|
2013-03-17 17:28:46 +01:00
|
|
|
{
|
2013-03-25 15:41:52 +00:00
|
|
|
if (widget == symbol_menu.find_in_files)
|
|
|
|
search_show_find_in_files_dialog_full(tag->name, NULL);
|
|
|
|
else
|
2013-03-25 15:54:12 +00:00
|
|
|
search_find_usage(tag->name, tag->name, SCFIND_WHOLEWORD | SCFIND_MATCHCASE,
|
|
|
|
widget == symbol_menu.find_usage);
|
2013-03-25 15:41:52 +00:00
|
|
|
|
2013-03-17 17:28:46 +01:00
|
|
|
tm_tag_unref(tag);
|
|
|
|
}
|
2013-03-17 13:26:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-18 13:29:53 +00:00
|
|
|
static void create_taglist_popup_menu(void)
|
|
|
|
{
|
2008-11-20 16:52:46 +00:00
|
|
|
GtkWidget *item, *menu;
|
2008-11-18 13:29:53 +00:00
|
|
|
|
2008-11-20 16:52:46 +00:00
|
|
|
tv.popup_taglist = menu = gtk_menu_new();
|
2008-11-18 13:29:53 +00:00
|
|
|
|
2008-11-23 15:42:33 +00:00
|
|
|
symbol_menu.expand_all = item = ui_image_menu_item_new(GTK_STOCK_ADD, _("_Expand All"));
|
2008-11-21 13:06:09 +00:00
|
|
|
gtk_widget_show(item);
|
|
|
|
gtk_container_add(GTK_CONTAINER(menu), item);
|
2011-10-30 22:52:29 +01:00
|
|
|
g_signal_connect(item, "activate", G_CALLBACK(on_expand_collapse), GINT_TO_POINTER(TRUE));
|
2008-11-21 13:06:09 +00:00
|
|
|
|
2008-11-23 15:42:33 +00:00
|
|
|
symbol_menu.collapse_all = item = ui_image_menu_item_new(GTK_STOCK_REMOVE, _("_Collapse All"));
|
2008-11-21 13:06:09 +00:00
|
|
|
gtk_widget_show(item);
|
|
|
|
gtk_container_add(GTK_CONTAINER(menu), item);
|
2011-10-30 22:52:29 +01:00
|
|
|
g_signal_connect(item, "activate", G_CALLBACK(on_expand_collapse), GINT_TO_POINTER(FALSE));
|
2008-11-21 13:06:09 +00:00
|
|
|
|
|
|
|
item = gtk_separator_menu_item_new();
|
|
|
|
gtk_widget_show(item);
|
|
|
|
gtk_container_add(GTK_CONTAINER(menu), item);
|
|
|
|
|
2008-11-20 16:52:46 +00:00
|
|
|
symbol_menu.sort_by_name = item = gtk_radio_menu_item_new_with_mnemonic(NULL,
|
|
|
|
_("Sort by _Name"));
|
2008-11-18 13:29:53 +00:00
|
|
|
gtk_widget_show(item);
|
2008-11-21 13:06:09 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(menu), item);
|
2008-11-20 16:52:46 +00:00
|
|
|
g_signal_connect(item, "activate", G_CALLBACK(on_symbol_tree_sort_clicked),
|
2008-11-18 13:29:53 +00:00
|
|
|
GINT_TO_POINTER(SYMBOLS_SORT_BY_NAME));
|
|
|
|
|
2008-11-20 16:52:46 +00:00
|
|
|
symbol_menu.sort_by_appearance = item = gtk_radio_menu_item_new_with_mnemonic_from_widget(
|
|
|
|
GTK_RADIO_MENU_ITEM(item), _("Sort by _Appearance"));
|
2008-11-18 13:29:53 +00:00
|
|
|
gtk_widget_show(item);
|
2008-11-21 13:06:09 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(menu), item);
|
2008-11-20 16:52:46 +00:00
|
|
|
g_signal_connect(item, "activate", G_CALLBACK(on_symbol_tree_sort_clicked),
|
2008-11-18 13:29:53 +00:00
|
|
|
GINT_TO_POINTER(SYMBOLS_SORT_BY_APPEARANCE));
|
|
|
|
|
2013-03-17 13:26:28 +00:00
|
|
|
item = gtk_separator_menu_item_new();
|
|
|
|
gtk_widget_show(item);
|
|
|
|
gtk_container_add(GTK_CONTAINER(menu), item);
|
|
|
|
|
|
|
|
symbol_menu.find_usage = item = ui_image_menu_item_new(GTK_STOCK_FIND, _("Find _Usage"));
|
|
|
|
gtk_widget_show(item);
|
|
|
|
gtk_container_add(GTK_CONTAINER(menu), item);
|
2013-03-25 15:54:12 +00:00
|
|
|
g_signal_connect(item, "activate", G_CALLBACK(on_find_usage), symbol_menu.find_usage);
|
2013-03-17 13:26:28 +00:00
|
|
|
|
|
|
|
symbol_menu.find_doc_usage = item = ui_image_menu_item_new(GTK_STOCK_FIND, _("Find _Document Usage"));
|
|
|
|
gtk_widget_show(item);
|
|
|
|
gtk_container_add(GTK_CONTAINER(menu), item);
|
2013-03-25 15:54:12 +00:00
|
|
|
g_signal_connect(item, "activate", G_CALLBACK(on_find_usage), symbol_menu.find_doc_usage);
|
2013-03-17 13:26:28 +00:00
|
|
|
|
2013-03-25 15:41:52 +00:00
|
|
|
symbol_menu.find_in_files = item = ui_image_menu_item_new(GTK_STOCK_FIND, _("Find in F_iles"));
|
|
|
|
gtk_widget_show(item);
|
|
|
|
gtk_container_add(GTK_CONTAINER(menu), item);
|
|
|
|
g_signal_connect(item, "activate", G_CALLBACK(on_find_usage), NULL);
|
|
|
|
|
2008-11-20 16:52:46 +00:00
|
|
|
g_signal_connect(menu, "show", G_CALLBACK(on_symbol_tree_menu_show), NULL);
|
|
|
|
|
2008-11-21 13:06:09 +00:00
|
|
|
sidebar_add_common_menu_items(GTK_MENU(menu));
|
2008-11-18 13:29:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-26 13:15:53 +00:00
|
|
|
static void on_document_save(G_GNUC_UNUSED GObject *object, GeanyDocument *doc)
|
|
|
|
{
|
2012-02-06 16:41:18 +00:00
|
|
|
gchar *f = g_build_filename(app->configdir, "ignore.tags", NULL);
|
2011-04-13 12:59:20 +00:00
|
|
|
|
2008-11-26 13:15:53 +00:00
|
|
|
g_return_if_fail(NZV(doc->real_path));
|
|
|
|
|
2011-04-13 12:59:20 +00:00
|
|
|
if (utils_str_equal(doc->real_path, f))
|
2008-11-26 13:15:53 +00:00
|
|
|
load_c_ignore_tags();
|
2011-04-13 12:59:20 +00:00
|
|
|
|
|
|
|
g_free(f);
|
2008-11-26 13:15:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-18 13:29:53 +00:00
|
|
|
void symbols_init(void)
|
|
|
|
{
|
2011-04-13 12:59:20 +00:00
|
|
|
gchar *f;
|
|
|
|
|
2008-11-18 13:29:53 +00:00
|
|
|
create_taglist_popup_menu();
|
2008-11-26 13:15:53 +00:00
|
|
|
|
2012-02-06 16:41:18 +00:00
|
|
|
f = g_build_filename(app->configdir, "ignore.tags", NULL);
|
2011-04-13 12:59:20 +00:00
|
|
|
ui_add_config_file_menu_item(f, NULL, NULL);
|
|
|
|
g_free(f);
|
|
|
|
|
2008-11-26 13:15:53 +00:00
|
|
|
g_signal_connect(geany_object, "document-save", G_CALLBACK(on_document_save), NULL);
|
2008-11-18 13:29:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void symbols_finalize(void)
|
|
|
|
{
|
|
|
|
g_strfreev(html_entities);
|
|
|
|
g_strfreev(c_tags_ignore);
|
|
|
|
}
|