Make wordchars have precedence over whitespacechars
This makes the "wordchars" setting from filetypes.common and each specific filetype override filetype.common's "whitespace_chars" setting, rather than it overriding filetype-specific "wordchars". This makes the it easy to chose filetype-specific "wordchars", where before user had not only to update this setting, but also the filetype.common "whitespace_chars" setting if it listed one or more of the new characters for the change to actually have an effect -- and changing "whitespace_chars" for every filetype. Closes #3429368.
This commit is contained in:
parent
565c917688
commit
3070738df8
@ -4003,8 +4003,7 @@ wordchars
|
||||
*Example:* (look at system filetypes.\* files)
|
||||
|
||||
.. note::
|
||||
This can be overridden by the *whitespace_chars*
|
||||
filetypes.common setting.
|
||||
This overrides the *whitespace_chars* filetypes.common setting.
|
||||
|
||||
comment_single
|
||||
A character or string which is used to comment code. If you want to use
|
||||
|
@ -629,16 +629,38 @@ static void styleset_common_init(GKeyFile *config, GKeyFile *config_home)
|
||||
}
|
||||
|
||||
|
||||
static void set_character_classes(ScintillaObject *sci, guint ft_id)
|
||||
{
|
||||
const gchar *word = (ft_id == GEANY_FILETYPES_NONE ?
|
||||
common_style_set.wordchars : style_sets[ft_id].wordchars);
|
||||
gchar *whitespace;
|
||||
guint i, j;
|
||||
|
||||
SSM(sci, SCI_SETWORDCHARS, 0, (sptr_t) word);
|
||||
|
||||
/* setting wordchars resets character classes, so we have to set whitespaces after
|
||||
* wordchars, but we want wordchars to have precenence over whitepace chars */
|
||||
whitespace = g_malloc0(strlen(whitespace_chars) + 1);
|
||||
for (i = 0, j = 0; whitespace_chars[i] != 0; i++)
|
||||
{
|
||||
if (! strchr(word, whitespace_chars[i]))
|
||||
whitespace[j++] = whitespace_chars[i];
|
||||
}
|
||||
whitespace[j] = 0;
|
||||
|
||||
SSM(sci, SCI_SETWHITESPACECHARS, 0, (sptr_t) whitespace);
|
||||
|
||||
g_free(whitespace);
|
||||
}
|
||||
|
||||
|
||||
static void styleset_common(ScintillaObject *sci, guint ft_id)
|
||||
{
|
||||
GeanyLexerStyle *style;
|
||||
|
||||
SSM(sci, SCI_STYLECLEARALL, 0, 0);
|
||||
|
||||
SSM(sci, SCI_SETWORDCHARS, 0, (sptr_t) (ft_id == GEANY_FILETYPES_NONE ?
|
||||
common_style_set.wordchars : style_sets[ft_id].wordchars));
|
||||
/* have to set whitespace after setting wordchars */
|
||||
SSM(sci, SCI_SETWHITESPACECHARS, 0, (sptr_t) whitespace_chars);
|
||||
set_character_classes(sci, ft_id);
|
||||
|
||||
/* caret colour, style and width */
|
||||
SSM(sci, SCI_SETCARETFORE, invert(common_style_set.styling[GCS_CARET].foreground), 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user