mirror of
https://github.com/irssi/irssi.git
synced 2025-01-03 14:56:47 -05:00
Merge pull request #1232 from vague666/fix_1228
Implement priority on the matched lines for /hilight
This commit is contained in:
commit
581c43ed1e
@ -244,8 +244,11 @@ HILIGHT_REC *hilight_match(SERVER_REC *server, const char *channel,
|
|||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
CHANNEL_REC *chanrec;
|
CHANNEL_REC *chanrec;
|
||||||
NICK_REC *nickrec;
|
NICK_REC *nickrec;
|
||||||
|
HILIGHT_REC *tmprec;
|
||||||
|
int priority = -1;
|
||||||
|
|
||||||
g_return_val_if_fail(str != NULL, NULL);
|
g_return_val_if_fail(str != NULL, NULL);
|
||||||
|
tmprec = NULL;
|
||||||
|
|
||||||
if ((never_hilight_level & level) == level)
|
if ((never_hilight_level & level) == level)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -270,15 +273,17 @@ HILIGHT_REC *hilight_match(SERVER_REC *server, const char *channel,
|
|||||||
for (tmp = hilights; tmp != NULL; tmp = tmp->next) {
|
for (tmp = hilights; tmp != NULL; tmp = tmp->next) {
|
||||||
HILIGHT_REC *rec = tmp->data;
|
HILIGHT_REC *rec = tmp->data;
|
||||||
|
|
||||||
if (!rec->nickmask && hilight_match_level(rec, level) &&
|
if (rec->priority > priority && !rec->nickmask && hilight_match_level(rec, level) &&
|
||||||
hilight_match_channel(rec, channel) &&
|
hilight_match_channel(rec, channel) &&
|
||||||
(rec->servertag == NULL ||
|
(rec->servertag == NULL ||
|
||||||
(server != NULL && g_ascii_strcasecmp(rec->servertag, server->tag) == 0)) &&
|
(server != NULL && g_ascii_strcasecmp(rec->servertag, server->tag) == 0)) &&
|
||||||
hilight_match_text(rec, str, match_beg, match_end))
|
hilight_match_text(rec, str, match_beg, match_end)) {
|
||||||
return rec;
|
tmprec = rec;
|
||||||
|
priority = rec->priority;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return tmprec;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *hilight_get_act_color(HILIGHT_REC *rec)
|
static char *hilight_get_act_color(HILIGHT_REC *rec)
|
||||||
@ -670,6 +675,7 @@ static void hilight_nick_cache(GHashTable *list, CHANNEL_REC *channel,
|
|||||||
HILIGHT_REC *match;
|
HILIGHT_REC *match;
|
||||||
char *nickmask;
|
char *nickmask;
|
||||||
int len, best_match;
|
int len, best_match;
|
||||||
|
int priority = -1;
|
||||||
|
|
||||||
if (nick->host == NULL)
|
if (nick->host == NULL)
|
||||||
return; /* don't check until host is known */
|
return; /* don't check until host is known */
|
||||||
@ -680,11 +686,12 @@ static void hilight_nick_cache(GHashTable *list, CHANNEL_REC *channel,
|
|||||||
for (tmp = hilights; tmp != NULL; tmp = tmp->next) {
|
for (tmp = hilights; tmp != NULL; tmp = tmp->next) {
|
||||||
HILIGHT_REC *rec = tmp->data;
|
HILIGHT_REC *rec = tmp->data;
|
||||||
|
|
||||||
if (rec->nickmask &&
|
if (rec->priority > priority && rec->nickmask &&
|
||||||
hilight_match_channel(rec, channel->name) &&
|
hilight_match_channel(rec, channel->name) &&
|
||||||
match_wildcards(rec->text, nickmask)) {
|
match_wildcards(rec->text, nickmask)) {
|
||||||
len = strlen(rec->text);
|
len = strlen(rec->text);
|
||||||
if (best_match < len) {
|
if (best_match < len) {
|
||||||
|
priority = rec->priority;
|
||||||
best_match = len;
|
best_match = len;
|
||||||
match = rec;
|
match = rec;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user