diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2016-09-23 23:46:26 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2016-09-23 23:46:26 +0200 |
commit | 4cefa5ab1b5c89583d66c466bea00bc58c8dddfd (patch) | |
tree | 408d425fe9bf87458489655165940738077fe80b | |
parent | 92a4d4b5a7b276ab7a606d876d03fb346f4ceda4 (diff) | |
download | xK-4cefa5ab1b5c89583d66c466bea00bc58c8dddfd.tar.gz xK-4cefa5ab1b5c89583d66c466bea00bc58c8dddfd.tar.xz xK-4cefa5ab1b5c89583d66c466bea00bc58c8dddfd.zip |
degesch: fix highlight detection in colored text
-rw-r--r-- | degesch.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -5916,10 +5916,26 @@ irc_is_highlight (struct server *s, const char *message) if (!s->irc_user) return false; + // Strip formatting from the message so that it doesn't interfere + // with nickname detection (color sequences in particular) + struct formatter f; + formatter_init (&f, s->ctx, NULL); + formatter_parse_mirc (&f, message); + + struct str stripped; + str_init (&stripped); + for (size_t i = 0; i < f.items_len; i++) + { + if (f.items[i].type == FORMATTER_ITEM_TEXT) + str_append (&stripped, f.items[i].text); + } + formatter_free (&f); + // Well, this is rather crude but it should make most users happy. // Ideally we could do this at least in proper Unicode. - char *copy = xstrdup (message); + char *copy = irc_to_utf8 (stripped.str); cstr_transform (copy, s->irc_tolower); + str_free (&stripped); char *nick = xstrdup (s->irc_user->nickname); cstr_transform (nick, s->irc_tolower); |