From 95b74de316bdfa0f44cc772c620423bca117942e Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 28 Jun 2000 21:47:13 +0000 Subject: /HILIGHT changed. -nick option now tells to hilight only the nick, not the whole line. -mask option matches the text for nick mask (it didn't even work before). git-svn-id: http://svn.irssi.org/repos/irssi/trunk@391 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/fe-common/irc/fe-events.c | 6 ++++-- src/fe-common/irc/irc-hilight-text.c | 35 +++++++++-------------------------- src/fe-common/irc/irc-hilight-text.h | 3 ++- 3 files changed, 15 insertions(+), 29 deletions(-) (limited to 'src/fe-common/irc') diff --git a/src/fe-common/irc/fe-events.c b/src/fe-common/irc/fe-events.c index c0a9e64e..d67e5775 100644 --- a/src/fe-common/irc/fe-events.c +++ b/src/fe-common/irc/fe-events.c @@ -53,7 +53,9 @@ static void msg_beep_check(IRC_SERVER_REC *server, int level) } } -static void print_channel_msg(IRC_SERVER_REC *server, const char *msg, const char *nick, const char *addr, const char *target) +static void print_channel_msg(IRC_SERVER_REC *server, const char *msg, + const char *nick, const char *addr, + const char *target) { CHANNEL_REC *chanrec; NICK_REC *nickrec; @@ -62,7 +64,7 @@ static void print_channel_msg(IRC_SERVER_REC *server, const char *msg, const cha chanrec = channel_find(server, target); for_me = irc_nick_match(server->nick, msg); - color = irc_hilight_find_nick(target, nick, addr); + color = irc_hilight_find_nick(target, nick, addr, MSGLEVEL_PUBLIC, msg); nickrec = chanrec == NULL ? NULL : nicklist_find(chanrec, nick); nickmode = (!settings_get_bool("show_nickmode") || nickrec == NULL) ? "" : diff --git a/src/fe-common/irc/irc-hilight-text.c b/src/fe-common/irc/irc-hilight-text.c index da9bb258..7c8a46be 100644 --- a/src/fe-common/irc/irc-hilight-text.c +++ b/src/fe-common/irc/irc-hilight-text.c @@ -19,36 +19,19 @@ */ #include "module.h" +#include "settings.h" #include "hilight-text.h" -char *irc_hilight_find_nick(const char *channel, const char *nick, const char *address) +char *irc_hilight_find_nick(const char *channel, const char *nick, + const char *address, int level, const char *msg) { - GSList *tmp; - char *color; - int len, best_match; + char *color, *mask; - g_return_val_if_fail(channel != NULL, NULL); - g_return_val_if_fail(nick != NULL, NULL); - g_return_val_if_fail(address != NULL, NULL); + mask = g_strdup_printf("%s!%s", nick, address); + color = hilight_match(channel, mask, level, msg); + g_free(mask); - color = NULL; best_match = 0; - for (tmp = hilights; tmp != NULL; tmp = tmp->next) { - HILIGHT_REC *rec = tmp->data; - - if (!rec->nickmask) - continue; - - len = strlen(rec->text); - if (best_match < len) { - best_match = len; - color = rec->color; - } - } - - if (best_match == 0) - return NULL; - - if (color == NULL) color = "\00316"; - return g_strconcat(isdigit(*color) ? "\003" : "", color, NULL); + return color; } + diff --git a/src/fe-common/irc/irc-hilight-text.h b/src/fe-common/irc/irc-hilight-text.h index 6acf8a8b..243ec653 100644 --- a/src/fe-common/irc/irc-hilight-text.h +++ b/src/fe-common/irc/irc-hilight-text.h @@ -1,6 +1,7 @@ #ifndef __IRC_HILIGHT_TEXT_H #define __IRC_HILIGHT_TEXT_H -char *irc_hilight_find_nick(const char *channel, const char *nick, const char *address); +char *irc_hilight_find_nick(const char *channel, const char *nick, + const char *address, int level, const char *msg); #endif -- cgit v1.2.3