HILIGHT_REC *hilight_match_nick(SERVER_REC *server, const char *channel, const char *nick, const char *address, int level, const char *msg) { HILIGHT_REC *rec; rec = hilight_match(server, channel, nick, address, level, msg, NULL, NULL); return (rec == NULL || !rec->nick) ? NULL : rec; }
char *hilight_find_nick(const char *channel, const char *nick, const char *address, int level, const char *msg) { char *color, *mask; mask = g_strdup_printf("%s!%s", nick, address); color = hilight_match(channel, mask, level, msg); g_free(mask); last_nick_color = (color != NULL && *color == 3) ? atoi(color+1) : 0; return color; }
static void sig_print_text_stripped(TEXT_DEST_REC *dest, const char *str) { char *newstr, *color; int oldlevel; g_return_if_fail(str != NULL); if (dest->level & (MSGLEVEL_NOHILIGHT|MSGLEVEL_HILIGHT)) return; color = hilight_match(dest->target, NULL, dest->level, str); if (color == NULL) return; if (*color == 3) { /* colorify */ dest->window->last_color = atoi(color+1); } if (dest->window != active_win) { oldlevel = dest->window->new_data; dest->window->new_data = NEWDATA_HILIGHT; signal_emit("window hilight", 2, dest->window, GINT_TO_POINTER(oldlevel)); signal_emit("window activity", 2, dest->window, GINT_TO_POINTER(oldlevel)); } hilight_next = FALSE; /* update the level, but let the signal pass through.. */ dest->level |= MSGLEVEL_HILIGHT; newstr = g_strconcat(color, str, NULL); signal_emit("print text", 2, dest, newstr); g_free(newstr); hilight_next = TRUE; g_free_not_null(color); }
static void sig_print_text(TEXT_DEST_REC *dest, const char *text, const char *stripped) { HILIGHT_REC *hilight; char *color, *newstr; int old_level, hilight_start, hilight_end, hilight_len; int nick_match; if (dest->level & MSGLEVEL_NOHILIGHT) return; hilight_start = hilight_end = 0; hilight = hilight_match(dest->server, dest->target, NULL, NULL, dest->level, stripped, &hilight_start, &hilight_end); if (hilight == NULL) return; nick_match = hilight->nick && (dest->level & (MSGLEVEL_PUBLIC|MSGLEVEL_ACTIONS)) == MSGLEVEL_PUBLIC; old_level = dest->level; if (!nick_match || (dest->level & MSGLEVEL_HILIGHT)) { /* update the level / hilight info */ hilight_update_text_dest(dest, hilight); /* Remove NO_ACT, this means explicitly defined hilights will bypass * /IGNORE ... NO_ACT. * (It's still possible to use /hilight -actcolor %n to hide * hilight/beep). */ dest->level &= ~MSGLEVEL_NO_ACT; } if (nick_match) return; /* fe-messages.c should have taken care of this */ if (old_level & MSGLEVEL_HILIGHT) { /* nick is highlighted, just set priority */ return; } color = hilight_get_color(hilight); hilight_len = hilight_end-hilight_start; if (!hilight->word) { /* hilight whole line */ char *tmp = strip_codes(text); newstr = g_strconcat(color, tmp, NULL); g_free(tmp); } else { /* hilight part of the line */ GString *tmp; char *middle; int pos, color_pos, color_len; tmp = g_string_new(NULL); /* start of the line */ pos = strip_real_length(text, hilight_start, NULL, NULL); g_string_append(tmp, text); g_string_truncate(tmp, pos); /* color */ g_string_append(tmp, color); /* middle of the line, stripped */ middle = strip_codes(text+pos); pos = tmp->len; g_string_append(tmp, middle); g_string_truncate(tmp, pos+hilight_len); g_free(middle); /* end of the line */ pos = strip_real_length(text, hilight_end, &color_pos, &color_len); if (color_pos > 0) g_string_append_len(tmp, text+color_pos, color_len); else { /* no colors in line, change back to default */ g_string_append_c(tmp, 4); g_string_append_c(tmp, FORMAT_STYLE_DEFAULTS); } g_string_append(tmp, text+pos); newstr = tmp->str; g_string_free(tmp, FALSE); } signal_emit("print text", 3, dest, newstr, stripped); g_free(color); g_free(newstr); signal_stop(); }
static void sig_print_text(TEXT_DEST_REC *dest, const char *text, const char *stripped) { HILIGHT_REC *hilight; char *color, *newstr; int old_level, hilight_start, hilight_end, hilight_len; int nick_match; if (dest->level & MSGLEVEL_NOHILIGHT) return; hilight_start = hilight_end = 0; hilight = hilight_match(dest->server, dest->target, NULL, NULL, dest->level, stripped, &hilight_start, &hilight_end); if (hilight == NULL) return; nick_match = hilight->nick && (dest->level & (MSGLEVEL_PUBLIC|MSGLEVEL_ACTIONS)) == MSGLEVEL_PUBLIC; old_level = dest->level; if (!nick_match || (dest->level & MSGLEVEL_HILIGHT)) { /* update the level / hilight info */ hilight_update_text_dest(dest, hilight); } if (nick_match) return; /* fe-messages.c should have taken care of this */ if (old_level & MSGLEVEL_HILIGHT) { /* nick is highlighted, just set priority */ return; } color = hilight_get_color(hilight); hilight_len = hilight_end-hilight_start; if (!hilight->word) { /* hilight whole line */ char *tmp = strip_codes(text); newstr = g_strconcat(color, tmp, NULL); g_free(tmp); } else { /* hilight part of the line */ GString *tmp; char *middle, *lastcolor; int pos, color_pos, color_len; tmp = g_string_new(NULL); /* start of the line */ pos = strip_real_length(text, hilight_start, NULL, NULL); g_string_append(tmp, text); g_string_truncate(tmp, pos); /* color */ g_string_append(tmp, color); /* middle of the line, stripped */ middle = strip_codes(text+pos); pos = tmp->len; g_string_append(tmp, middle); g_string_truncate(tmp, pos+hilight_len); g_free(middle); /* end of the line */ pos = strip_real_length(text, hilight_end, &color_pos, &color_len); if (color_pos > 0) lastcolor = g_strndup(text+color_pos, color_len); else { /* no colors in line, change back to default */ lastcolor = g_malloc0(3); lastcolor[0] = 4; lastcolor[1] = FORMAT_STYLE_DEFAULTS; } g_string_append(tmp, lastcolor); g_string_append(tmp, text+pos); g_free(lastcolor); newstr = tmp->str; g_string_free(tmp, FALSE); } signal_emit("print text", 3, dest, newstr, stripped); g_free(color); g_free(newstr); signal_stop(); }