Skip to content

Commit

Permalink
Add tm_parser_scope_separator_printable()
Browse files Browse the repository at this point in the history
The added tm_parser_scope_separator_printable() function is a human
readable representation of scope separator. For most languages, this is
equal to the scope separator but for some (mostly markup languages),
some "strange" scope separators are used like \0x3 or \"\" and we need
something more readable when displayed to users. " > " seems to look
good.

This new function can be used to:
1. Format calltips (though real languages use human-readable scope sep)
2. Symbol tree filter and display.
  • Loading branch information
techee committed Jan 13, 2022
1 parent 3d2b203 commit fa4e00a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/symbols.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ static GList *get_tag_list(GeanyDocument *doc, TMTagType tag_types)
gboolean filtered = FALSE;
gchar **val;
gchar *full_tagname = g_strconcat(tag->scope ? tag->scope : "",
tag->scope ? tm_parser_scope_separator(tag->lang) : "",
tag->scope ? tm_parser_scope_separator_printable(tag->lang) : "",
tag->name, NULL);
gchar *normalized_tagname = g_utf8_normalize(full_tagname, -1, G_NORMALIZE_ALL);

Expand Down Expand Up @@ -960,7 +960,7 @@ static const gchar *get_symbol_name(GeanyDocument *doc, const TMTag *tag, gboole
if (!found_parent && scope &&
strpbrk(scope, GEANY_WORDCHARS) == scope)
{
const gchar *sep = tm_parser_scope_separator(tag->lang);
const gchar *sep = tm_parser_scope_separator_printable(tag->lang);

g_string_append(buffer, scope);
g_string_append(buffer, sep);
Expand Down
18 changes: 17 additions & 1 deletion src/tagmanager/tm_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ gchar *tm_parser_format_function(TMParserType lang, const gchar *fname, const gc
if (scope)
{
g_string_append(str, scope);
g_string_append(str, tm_parser_scope_separator(lang));
g_string_append(str, tm_parser_scope_separator_printable(lang));
}
g_string_append(str, fname);
g_string_append_c(str, ' ');
Expand Down Expand Up @@ -1030,6 +1030,22 @@ const gchar *tm_parser_scope_separator(TMParserType lang)
}


const gchar *tm_parser_scope_separator_printable(TMParserType lang)
{
switch (lang)
{
case TM_PARSER_TXT2TAGS:
case TM_PARSER_ASCIIDOC:
case TM_PARSER_CONF:
case TM_PARSER_REST:
return " > ";

default:
return tm_parser_scope_separator(lang);
}
}


gboolean tm_parser_has_full_scope(TMParserType lang)
{
switch (lang)
Expand Down
2 changes: 2 additions & 0 deletions src/tagmanager/tm_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ gchar *tm_parser_format_function(TMParserType lang, const gchar *fname, const gc

const gchar *tm_parser_scope_separator(TMParserType lang);

const gchar *tm_parser_scope_separator_printable(TMParserType lang);

gboolean tm_parser_has_full_scope(TMParserType lang);

gboolean tm_parser_langs_compatible(TMParserType lang, TMParserType other);
Expand Down

0 comments on commit fa4e00a

Please sign in to comment.