[geany/geany] 307073: Make wordchars have precedence over whitespacechars
Colomban Wendling
git-noreply at geany.org
Fri Oct 5 23:32:54 UTC 2012
Branch: refs/heads/master
Author: Colomban Wendling <ban at herbesfolles.org>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Fri, 05 Oct 2012 23:32:54
Commit: 3070738df8e30cc62be877aba3d8bd43a5eef1bc
https://github.com/geany/geany/commit/3070738df8e30cc62be877aba3d8bd43a5eef1bc
Log Message:
-----------
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.
Modified Paths:
--------------
doc/geany.txt
src/highlighting.c
Modified: doc/geany.txt
3 files changed, 1 insertions(+), 2 deletions(-)
===================================================================
@@ -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
Modified: src/highlighting.c
30 files changed, 26 insertions(+), 4 deletions(-)
===================================================================
@@ -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);
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
More information about the Commits
mailing list