Skip to content

Commit

Permalink
highlighting: added API call to query GeanyLexerStyle by name
Browse files Browse the repository at this point in the history
  • Loading branch information
lpaulsen93 committed Oct 3, 2019
1 parent 46d5e75 commit 9ff6031
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/highlighting.c
Expand Up @@ -1159,6 +1159,30 @@ void highlighting_set_styles(ScintillaObject *sci, GeanyFiletype *ft)
}


/** Retrieves a @a named_style.
* If a style with the name @a named_style does not exist, NULL will be returned.
* @param named_style Key/name of the style as specified in the colorscheme file
* @return A pointer to the style struct.
*/
GEANY_API_SYMBOL
const GeanyLexerStyle *highlighting_get_named_style(const gchar *named_style)
{
GeanyLexerStyle *cs;
gchar *comma, *name = NULL;

g_return_val_if_fail(named_style, NULL);
name = utils_strdupa(named_style); /* named_style must not be written to, may be a static string */

comma = strstr(name, ",");
if (comma)
{
*comma = '\0'; /* terminate name to make lookup work */
}
cs = g_hash_table_lookup(named_style_hash, name);
return cs;
}


/** Retrieves a style @a style_id for the filetype @a ft_id.
* If the style was not already initialised
* (e.g. by by opening a file of this type), it will be initialised. The returned pointer is
Expand Down
2 changes: 2 additions & 0 deletions src/highlighting.h
Expand Up @@ -45,6 +45,8 @@ typedef struct GeanyLexerStyle
GeanyLexerStyle;


const GeanyLexerStyle *highlighting_get_named_style(const gchar *named_style);

const GeanyLexerStyle *highlighting_get_style(gint ft_id, gint style_id);

void highlighting_set_styles(ScintillaObject *sci, GeanyFiletype *ft);
Expand Down
2 changes: 1 addition & 1 deletion src/plugindata.h
Expand Up @@ -58,7 +58,7 @@ G_BEGIN_DECLS
* @warning You should not test for values below 200 as previously
* @c GEANY_API_VERSION was defined as an enum value, not a macro.
*/
#define GEANY_API_VERSION 239
#define GEANY_API_VERSION 240

/* hack to have a different ABI when built with GTK3 because loading GTK2-linked plugins
* with GTK3-linked Geany leads to crash */
Expand Down

0 comments on commit 9ff6031

Please sign in to comment.