2000-04-26 04:03:38 -04:00
|
|
|
/*
|
|
|
|
hilight-text.c : irssi
|
|
|
|
|
|
|
|
Copyright (C) 1999-2000 Timo Sirainen
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2007-05-08 14:41:10 -04:00
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2000-04-26 04:03:38 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "module.h"
|
|
|
|
#include "module-formats.h"
|
|
|
|
#include "signals.h"
|
|
|
|
#include "commands.h"
|
2001-01-20 23:14:24 -05:00
|
|
|
#include "levels.h"
|
2000-04-26 04:03:38 -04:00
|
|
|
#include "misc.h"
|
|
|
|
#include "lib-config/iconfig.h"
|
|
|
|
#include "settings.h"
|
|
|
|
|
2000-08-26 11:39:44 -04:00
|
|
|
#include "servers.h"
|
2001-01-20 23:14:24 -05:00
|
|
|
#include "channels.h"
|
|
|
|
#include "nicklist.h"
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
#include "hilight-text.h"
|
2001-01-20 23:14:24 -05:00
|
|
|
#include "nickmatch-cache.h"
|
2000-10-28 16:14:19 -04:00
|
|
|
#include "printtext.h"
|
2000-11-12 15:20:05 -05:00
|
|
|
#include "formats.h"
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-01-20 23:14:24 -05:00
|
|
|
static NICKMATCH_REC *nickmatch;
|
|
|
|
static int never_hilight_level, default_hilight_level;
|
2000-04-26 04:03:38 -04:00
|
|
|
GSList *hilights;
|
|
|
|
|
2008-06-04 15:33:00 -04:00
|
|
|
static void reset_level_cache(void)
|
2001-01-20 23:14:24 -05:00
|
|
|
{
|
|
|
|
GSList *tmp;
|
|
|
|
|
|
|
|
never_hilight_level = MSGLEVEL_ALL & ~default_hilight_level;
|
|
|
|
for (tmp = hilights; tmp != NULL; tmp = tmp->next) {
|
|
|
|
HILIGHT_REC *rec = tmp->data;
|
|
|
|
|
|
|
|
if (never_hilight_level & rec->level)
|
2016-04-28 18:12:28 -04:00
|
|
|
never_hilight_level &= ~rec->level;
|
2001-01-20 23:14:24 -05:00
|
|
|
}
|
2008-06-04 15:33:00 -04:00
|
|
|
}
|
2001-01-20 23:14:24 -05:00
|
|
|
|
2008-06-04 15:33:00 -04:00
|
|
|
static void reset_cache(void)
|
|
|
|
{
|
|
|
|
reset_level_cache();
|
2001-01-20 23:14:24 -05:00
|
|
|
nickmatch_rebuild(nickmatch);
|
|
|
|
}
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
static void hilight_add_config(HILIGHT_REC *rec)
|
|
|
|
{
|
|
|
|
CONFIG_NODE *node;
|
|
|
|
|
2000-05-09 09:14:07 -04:00
|
|
|
g_return_if_fail(rec != NULL);
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
node = iconfig_node_traverse("(hilights", TRUE);
|
2015-01-06 21:40:34 -05:00
|
|
|
node = iconfig_node_section(node, NULL, NODE_TYPE_BLOCK);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2016-04-28 18:12:28 -04:00
|
|
|
iconfig_node_set_str(node, "text", rec->text);
|
|
|
|
if (rec->level > 0) iconfig_node_set_int(node, "level", rec->level);
|
|
|
|
if (rec->color) iconfig_node_set_str(node, "color", rec->color);
|
|
|
|
if (rec->act_color) iconfig_node_set_str(node, "act_color", rec->act_color);
|
|
|
|
if (rec->priority > 0) iconfig_node_set_int(node, "priority", rec->priority);
|
|
|
|
iconfig_node_set_bool(node, "nick", rec->nick);
|
|
|
|
iconfig_node_set_bool(node, "word", rec->word);
|
|
|
|
if (rec->nickmask) iconfig_node_set_bool(node, "mask", TRUE);
|
|
|
|
if (rec->fullword) iconfig_node_set_bool(node, "fullword", TRUE);
|
|
|
|
if (rec->regexp) iconfig_node_set_bool(node, "regexp", TRUE);
|
2016-04-28 19:01:34 -04:00
|
|
|
if (rec->case_sensitive) iconfig_node_set_bool(node, "matchcase", TRUE);
|
2016-04-28 18:12:28 -04:00
|
|
|
if (rec->servertag) iconfig_node_set_str(node, "servertag", rec->servertag);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
if (rec->channels != NULL && *rec->channels != NULL) {
|
2015-01-06 21:40:34 -05:00
|
|
|
node = iconfig_node_section(node, "channels", NODE_TYPE_LIST);
|
2000-11-26 05:24:30 -05:00
|
|
|
iconfig_node_add_list(node, rec->channels);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void hilight_remove_config(HILIGHT_REC *rec)
|
|
|
|
{
|
|
|
|
CONFIG_NODE *node;
|
|
|
|
|
2000-05-09 09:14:07 -04:00
|
|
|
g_return_if_fail(rec != NULL);
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
node = iconfig_node_traverse("hilights", FALSE);
|
2000-05-10 09:57:42 -04:00
|
|
|
if (node != NULL) iconfig_node_list_remove(node, g_slist_index(hilights, rec));
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void hilight_destroy(HILIGHT_REC *rec)
|
|
|
|
{
|
2000-05-09 09:14:07 -04:00
|
|
|
g_return_if_fail(rec != NULL);
|
|
|
|
|
2016-01-29 10:22:14 -05:00
|
|
|
if (rec->preg != NULL) g_regex_unref(rec->preg);
|
2001-01-20 23:14:24 -05:00
|
|
|
if (rec->channels != NULL) g_strfreev(rec->channels);
|
2000-04-26 04:03:38 -04:00
|
|
|
g_free_not_null(rec->color);
|
2001-01-20 23:14:24 -05:00
|
|
|
g_free_not_null(rec->act_color);
|
|
|
|
g_free(rec->text);
|
2000-04-26 04:03:38 -04:00
|
|
|
g_free(rec);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void hilights_destroy_all(void)
|
|
|
|
{
|
|
|
|
g_slist_foreach(hilights, (GFunc) hilight_destroy, NULL);
|
|
|
|
g_slist_free(hilights);
|
|
|
|
hilights = NULL;
|
|
|
|
}
|
|
|
|
|
2002-05-19 02:50:50 -04:00
|
|
|
static void hilight_init_rec(HILIGHT_REC *rec)
|
|
|
|
{
|
2016-01-29 10:22:14 -05:00
|
|
|
if (rec->preg != NULL)
|
2016-01-14 08:10:00 -05:00
|
|
|
g_regex_unref(rec->preg);
|
|
|
|
|
2016-06-23 07:25:23 -04:00
|
|
|
rec->preg = g_regex_new(rec->text, G_REGEX_OPTIMIZE | G_REGEX_RAW | G_REGEX_CASELESS, 0, NULL);
|
2002-05-19 02:50:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void hilight_create(HILIGHT_REC *rec)
|
|
|
|
{
|
|
|
|
if (g_slist_find(hilights, rec) != NULL) {
|
|
|
|
hilight_remove_config(rec);
|
2004-09-13 15:02:02 -04:00
|
|
|
hilights = g_slist_remove(hilights, rec);
|
2002-05-19 02:50:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
hilights = g_slist_append(hilights, rec);
|
|
|
|
hilight_add_config(rec);
|
|
|
|
|
|
|
|
hilight_init_rec(rec);
|
|
|
|
|
|
|
|
signal_emit("hilight created", 1, rec);
|
|
|
|
}
|
|
|
|
|
|
|
|
void hilight_remove(HILIGHT_REC *rec)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
2000-05-09 09:14:07 -04:00
|
|
|
g_return_if_fail(rec != NULL);
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
hilight_remove_config(rec);
|
|
|
|
hilights = g_slist_remove(hilights, rec);
|
2002-05-19 02:50:50 -04:00
|
|
|
|
|
|
|
signal_emit("hilight destroyed", 1, rec);
|
2000-04-26 04:03:38 -04:00
|
|
|
hilight_destroy(rec);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HILIGHT_REC *hilight_find(const char *text, char **channels)
|
|
|
|
{
|
|
|
|
GSList *tmp;
|
|
|
|
char **chan;
|
|
|
|
|
|
|
|
g_return_val_if_fail(text != NULL, NULL);
|
|
|
|
|
|
|
|
for (tmp = hilights; tmp != NULL; tmp = tmp->next) {
|
|
|
|
HILIGHT_REC *rec = tmp->data;
|
|
|
|
|
2014-06-10 12:06:19 -04:00
|
|
|
if (g_ascii_strcasecmp(rec->text, text) != 0)
|
2000-04-26 04:03:38 -04:00
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((channels == NULL && rec->channels == NULL))
|
|
|
|
return rec; /* no channels - ok */
|
|
|
|
|
2015-04-07 21:39:05 -04:00
|
|
|
if (channels != NULL && g_strcmp0(*channels, "*") == 0)
|
2000-04-26 04:03:38 -04:00
|
|
|
return rec; /* ignore channels */
|
|
|
|
|
|
|
|
if (channels == NULL || rec->channels == NULL)
|
|
|
|
continue; /* other doesn't have channels */
|
|
|
|
|
2016-02-13 08:16:05 -05:00
|
|
|
if (g_strv_length(channels) != g_strv_length(rec->channels))
|
2000-04-26 04:03:38 -04:00
|
|
|
continue; /* different amount of channels */
|
|
|
|
|
|
|
|
/* check that channels match */
|
|
|
|
for (chan = channels; *chan != NULL; chan++) {
|
|
|
|
if (strarray_find(rec->channels, *chan) == -1)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*chan == NULL)
|
|
|
|
return rec; /* channels ok */
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-06-23 07:25:23 -04:00
|
|
|
static gboolean hilight_match_text(HILIGHT_REC *rec, const char *text,
|
2016-04-28 18:12:28 -04:00
|
|
|
int *match_beg, int *match_end)
|
2001-01-20 23:14:24 -05:00
|
|
|
{
|
2016-06-23 07:25:23 -04:00
|
|
|
gboolean ret = FALSE;
|
2001-01-20 23:14:24 -05:00
|
|
|
|
|
|
|
if (rec->regexp) {
|
2016-01-29 10:22:14 -05:00
|
|
|
if (rec->preg != NULL) {
|
2016-06-23 07:25:23 -04:00
|
|
|
GMatchInfo *match;
|
|
|
|
|
2016-01-14 08:10:00 -05:00
|
|
|
g_regex_match (rec->preg, text, 0, &match);
|
|
|
|
|
2016-06-23 07:25:23 -04:00
|
|
|
if (g_match_info_matches(match))
|
|
|
|
ret = g_match_info_fetch_pos(match, 0, match_beg, match_end);
|
|
|
|
|
|
|
|
g_match_info_free(match);
|
2001-01-20 23:14:24 -05:00
|
|
|
}
|
|
|
|
} else {
|
2016-06-23 07:25:23 -04:00
|
|
|
char *match;
|
|
|
|
|
2016-04-28 19:01:34 -04:00
|
|
|
if (rec->case_sensitive) {
|
|
|
|
match = rec->fullword ?
|
|
|
|
strstr_full(text, rec->text) :
|
|
|
|
strstr(text, rec->text);
|
2016-04-30 14:26:26 -04:00
|
|
|
} else {
|
2016-04-28 19:01:34 -04:00
|
|
|
match = rec->fullword ?
|
|
|
|
stristr_full(text, rec->text) :
|
|
|
|
stristr(text, rec->text);
|
|
|
|
}
|
2001-01-20 23:14:24 -05:00
|
|
|
if (match != NULL) {
|
|
|
|
if (match_beg != NULL && match_end != NULL) {
|
|
|
|
*match_beg = (int) (match-text);
|
|
|
|
*match_end = *match_beg + strlen(rec->text);
|
|
|
|
}
|
2016-06-23 07:25:23 -04:00
|
|
|
ret = TRUE;
|
2001-01-20 23:14:24 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-23 07:25:23 -04:00
|
|
|
return ret;
|
2001-01-20 23:14:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#define hilight_match_level(rec, level) \
|
|
|
|
(level & (((rec)->level != 0 ? rec->level : default_hilight_level)))
|
|
|
|
|
|
|
|
#define hilight_match_channel(rec, channel) \
|
|
|
|
((rec)->channels == NULL || ((channel) != NULL && \
|
|
|
|
strarray_find((rec)->channels, (channel)) != -1))
|
|
|
|
|
|
|
|
HILIGHT_REC *hilight_match(SERVER_REC *server, const char *channel,
|
|
|
|
const char *nick, const char *address,
|
|
|
|
int level, const char *str,
|
|
|
|
int *match_beg, int *match_end)
|
2000-04-26 04:03:38 -04:00
|
|
|
{
|
|
|
|
GSList *tmp;
|
2001-01-20 23:14:24 -05:00
|
|
|
CHANNEL_REC *chanrec;
|
|
|
|
NICK_REC *nickrec;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2000-06-28 17:47:13 -04:00
|
|
|
g_return_val_if_fail(str != NULL, NULL);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-01-20 23:14:24 -05:00
|
|
|
if ((never_hilight_level & level) == level)
|
|
|
|
return NULL;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-01-20 23:14:24 -05:00
|
|
|
if (nick != NULL) {
|
|
|
|
/* check nick mask hilights */
|
|
|
|
chanrec = channel_find(server, channel);
|
|
|
|
nickrec = chanrec == NULL ? NULL :
|
|
|
|
nicklist_find(chanrec, nick);
|
|
|
|
if (nickrec != NULL) {
|
|
|
|
HILIGHT_REC *rec;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-01-20 23:14:24 -05:00
|
|
|
if (nickrec->host == NULL)
|
|
|
|
nicklist_set_host(chanrec, nickrec, address);
|
|
|
|
|
|
|
|
rec = nickmatch_find(nickmatch, nickrec);
|
|
|
|
if (rec != NULL && hilight_match_level(rec, level))
|
|
|
|
return rec;
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-20 23:14:24 -05:00
|
|
|
for (tmp = hilights; tmp != NULL; tmp = tmp->next) {
|
|
|
|
HILIGHT_REC *rec = tmp->data;
|
|
|
|
|
|
|
|
if (!rec->nickmask && hilight_match_level(rec, level) &&
|
2016-04-28 18:12:28 -04:00
|
|
|
hilight_match_channel(rec, channel) &&
|
|
|
|
(rec->servertag == NULL ||
|
|
|
|
(server != NULL && g_ascii_strcasecmp(rec->servertag, server->tag) == 0)) &&
|
|
|
|
hilight_match_text(rec, str, match_beg, match_end))
|
2001-01-20 23:14:24 -05:00
|
|
|
return rec;
|
|
|
|
}
|
|
|
|
|
2016-04-28 18:12:28 -04:00
|
|
|
return NULL;
|
2001-01-09 16:06:45 -05:00
|
|
|
}
|
|
|
|
|
2001-03-16 20:52:43 -05:00
|
|
|
static char *hilight_get_act_color(HILIGHT_REC *rec)
|
2001-02-18 22:25:24 -05:00
|
|
|
{
|
2001-03-16 20:52:43 -05:00
|
|
|
g_return_val_if_fail(rec != NULL, NULL);
|
2001-02-18 22:25:24 -05:00
|
|
|
|
2001-03-16 20:52:43 -05:00
|
|
|
return g_strdup(rec->act_color != NULL ? rec->act_color :
|
|
|
|
rec->color != NULL ? rec->color :
|
|
|
|
settings_get_str("hilight_act_color"));
|
2001-02-18 22:25:24 -05:00
|
|
|
}
|
|
|
|
|
2004-10-06 12:25:34 -04:00
|
|
|
char *hilight_get_color(HILIGHT_REC *rec)
|
2001-01-09 16:06:45 -05:00
|
|
|
{
|
2001-01-20 23:14:24 -05:00
|
|
|
const char *color;
|
2001-01-09 16:06:45 -05:00
|
|
|
|
|
|
|
g_return_val_if_fail(rec != NULL, NULL);
|
|
|
|
|
2001-03-16 20:52:43 -05:00
|
|
|
color = rec->color != NULL ? rec->color :
|
|
|
|
settings_get_str("hilight_color");
|
2001-01-09 16:06:45 -05:00
|
|
|
|
2001-06-26 17:28:00 -04:00
|
|
|
return format_string_expand(color, NULL);
|
2000-06-28 17:47:13 -04:00
|
|
|
}
|
2000-06-27 15:11:25 -04:00
|
|
|
|
2004-10-06 12:25:34 -04:00
|
|
|
void hilight_update_text_dest(TEXT_DEST_REC *dest, HILIGHT_REC *rec)
|
2001-01-20 23:14:24 -05:00
|
|
|
{
|
|
|
|
dest->level |= MSGLEVEL_HILIGHT;
|
|
|
|
|
|
|
|
if (rec->priority > 0)
|
|
|
|
dest->hilight_priority = rec->priority;
|
|
|
|
|
2002-02-11 03:23:02 -05:00
|
|
|
g_free_and_null(dest->hilight_color);
|
2015-04-07 21:39:05 -04:00
|
|
|
if (rec->act_color != NULL && g_strcmp0(rec->act_color, "%n") == 0)
|
2002-02-11 03:23:02 -05:00
|
|
|
dest->level |= MSGLEVEL_NO_ACT;
|
2016-04-28 18:12:28 -04:00
|
|
|
else
|
2002-02-11 03:23:02 -05:00
|
|
|
dest->hilight_color = hilight_get_act_color(rec);
|
2001-01-20 23:14:24 -05:00
|
|
|
}
|
|
|
|
|
2004-10-06 12:25:34 -04:00
|
|
|
static void hilight_print(int index, HILIGHT_REC *rec);
|
|
|
|
|
2001-05-31 18:35:49 -04:00
|
|
|
static void sig_print_text(TEXT_DEST_REC *dest, const char *text,
|
|
|
|
const char *stripped)
|
2000-06-28 17:47:13 -04:00
|
|
|
{
|
2001-05-31 18:35:49 -04:00
|
|
|
HILIGHT_REC *hilight;
|
|
|
|
char *color, *newstr;
|
2001-07-15 15:03:27 -04:00
|
|
|
int old_level, hilight_start, hilight_end, hilight_len;
|
2001-12-04 09:08:34 -05:00
|
|
|
int nick_match;
|
2000-06-28 17:47:13 -04:00
|
|
|
|
2001-07-15 15:03:27 -04:00
|
|
|
if (dest->level & MSGLEVEL_NOHILIGHT)
|
|
|
|
return;
|
2001-01-09 16:06:45 -05:00
|
|
|
|
2015-12-27 18:07:42 -05:00
|
|
|
hilight_start = hilight_end = 0;
|
|
|
|
hilight = hilight_match(dest->server, dest->target, dest->nick,
|
|
|
|
dest->address, dest->level, stripped,
|
|
|
|
&hilight_start, &hilight_end);
|
2015-09-24 07:03:02 -04:00
|
|
|
|
2001-05-31 18:35:49 -04:00
|
|
|
if (hilight == NULL)
|
2001-07-16 13:20:23 -04:00
|
|
|
return;
|
2001-07-22 08:08:36 -04:00
|
|
|
|
2001-12-04 09:08:34 -05:00
|
|
|
nick_match = hilight->nick && (dest->level & (MSGLEVEL_PUBLIC|MSGLEVEL_ACTIONS)) == MSGLEVEL_PUBLIC;
|
2001-05-31 18:35:49 -04:00
|
|
|
|
2001-12-14 17:04:28 -05:00
|
|
|
old_level = dest->level;
|
2001-12-04 09:08:34 -05:00
|
|
|
if (!nick_match || (dest->level & MSGLEVEL_HILIGHT)) {
|
2014-06-29 19:05:46 -04:00
|
|
|
/* 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;
|
2015-04-07 05:26:28 -04:00
|
|
|
/* update the level / hilight info */
|
|
|
|
hilight_update_text_dest(dest, hilight);
|
2001-12-04 09:08:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (nick_match)
|
2001-11-19 16:10:39 -05:00
|
|
|
return; /* fe-messages.c should have taken care of this */
|
|
|
|
|
2001-07-15 15:03:27 -04:00
|
|
|
if (old_level & MSGLEVEL_HILIGHT) {
|
|
|
|
/* nick is highlighted, just set priority */
|
|
|
|
return;
|
|
|
|
}
|
2001-11-19 16:10:39 -05:00
|
|
|
|
2001-05-31 18:35:49 -04:00
|
|
|
color = hilight_get_color(hilight);
|
|
|
|
hilight_len = hilight_end-hilight_start;
|
2000-06-28 17:47:13 -04:00
|
|
|
|
2001-05-31 18:35:49 -04:00
|
|
|
if (!hilight->word) {
|
2001-01-20 23:14:24 -05:00
|
|
|
/* hilight whole line */
|
2001-05-31 18:35:49 -04:00
|
|
|
char *tmp = strip_codes(text);
|
2001-01-20 23:14:24 -05:00
|
|
|
newstr = g_strconcat(color, tmp, NULL);
|
2016-04-28 18:12:28 -04:00
|
|
|
g_free(tmp);
|
2001-01-20 23:14:24 -05:00
|
|
|
} else {
|
|
|
|
/* hilight part of the line */
|
2016-04-28 18:12:28 -04:00
|
|
|
GString *tmp;
|
|
|
|
char *middle;
|
2001-01-20 23:14:24 -05:00
|
|
|
int pos, color_pos, color_len;
|
|
|
|
|
2016-04-28 18:12:28 -04:00
|
|
|
tmp = g_string_new(NULL);
|
2001-01-20 23:14:24 -05:00
|
|
|
|
2016-04-28 18:12:28 -04:00
|
|
|
/* start of the line */
|
2001-05-31 18:35:49 -04:00
|
|
|
pos = strip_real_length(text, hilight_start, NULL, NULL);
|
|
|
|
g_string_append(tmp, text);
|
2016-04-28 18:12:28 -04:00
|
|
|
g_string_truncate(tmp, pos);
|
2001-01-20 23:14:24 -05:00
|
|
|
|
|
|
|
/* color */
|
2016-04-28 18:12:28 -04:00
|
|
|
g_string_append(tmp, color);
|
2001-01-20 23:14:24 -05:00
|
|
|
|
|
|
|
/* middle of the line, stripped */
|
2001-05-31 18:35:49 -04:00
|
|
|
middle = strip_codes(text+pos);
|
2016-04-28 18:12:28 -04:00
|
|
|
pos = tmp->len;
|
2001-01-20 23:14:24 -05:00
|
|
|
g_string_append(tmp, middle);
|
2016-04-28 18:12:28 -04:00
|
|
|
g_string_truncate(tmp, pos+hilight_len);
|
|
|
|
g_free(middle);
|
2001-01-20 23:14:24 -05:00
|
|
|
|
|
|
|
/* end of the line */
|
2001-05-31 18:35:49 -04:00
|
|
|
pos = strip_real_length(text, hilight_end,
|
2001-01-20 23:14:24 -05:00
|
|
|
&color_pos, &color_len);
|
2001-02-22 05:52:29 -05:00
|
|
|
if (color_pos > 0)
|
2008-05-31 09:18:43 -04:00
|
|
|
g_string_append_len(tmp, text+color_pos, color_len);
|
2001-02-22 05:52:29 -05:00
|
|
|
else {
|
|
|
|
/* no colors in line, change back to default */
|
2008-05-31 09:18:43 -04:00
|
|
|
g_string_append_c(tmp, 4);
|
|
|
|
g_string_append_c(tmp, FORMAT_STYLE_DEFAULTS);
|
2001-02-22 03:35:53 -05:00
|
|
|
}
|
2001-05-31 18:35:49 -04:00
|
|
|
g_string_append(tmp, text+pos);
|
2001-01-20 23:14:24 -05:00
|
|
|
|
2016-04-28 18:12:28 -04:00
|
|
|
newstr = tmp->str;
|
|
|
|
g_string_free(tmp, FALSE);
|
2001-01-20 23:14:24 -05:00
|
|
|
}
|
2000-06-28 17:47:13 -04:00
|
|
|
|
2001-05-31 18:35:49 -04:00
|
|
|
signal_emit("print text", 3, dest, newstr, stripped);
|
2000-06-28 17:47:13 -04:00
|
|
|
|
2001-01-20 23:14:24 -05:00
|
|
|
g_free(color);
|
|
|
|
g_free(newstr);
|
2000-06-30 15:50:56 -04:00
|
|
|
|
2001-01-20 23:14:24 -05:00
|
|
|
signal_stop();
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2004-10-06 12:25:34 -04:00
|
|
|
HILIGHT_REC *hilight_match_nick(SERVER_REC *server, const char *channel,
|
2001-01-20 23:14:24 -05:00
|
|
|
const char *nick, const char *address,
|
|
|
|
int level, const char *msg)
|
2001-01-09 16:06:45 -05:00
|
|
|
{
|
|
|
|
HILIGHT_REC *rec;
|
2000-09-30 18:49:48 -04:00
|
|
|
|
2001-01-20 23:14:24 -05:00
|
|
|
rec = hilight_match(server, channel, nick, address,
|
2016-04-28 18:12:28 -04:00
|
|
|
level, msg, NULL, NULL);
|
2004-10-06 12:25:34 -04:00
|
|
|
return (rec == NULL || !rec->nick) ? NULL : rec;
|
2000-09-30 18:49:48 -04:00
|
|
|
}
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
static void read_hilight_config(void)
|
|
|
|
{
|
|
|
|
CONFIG_NODE *node;
|
|
|
|
HILIGHT_REC *rec;
|
|
|
|
GSList *tmp;
|
|
|
|
char *text, *color;
|
|
|
|
|
|
|
|
hilights_destroy_all();
|
|
|
|
|
|
|
|
node = iconfig_node_traverse("hilights", FALSE);
|
2001-01-26 13:52:01 -05:00
|
|
|
if (node == NULL) {
|
|
|
|
reset_cache();
|
|
|
|
return;
|
|
|
|
}
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2002-02-02 12:37:44 -05:00
|
|
|
tmp = config_node_first(node->value);
|
|
|
|
for (; tmp != NULL; tmp = config_node_next(tmp)) {
|
2000-04-26 04:03:38 -04:00
|
|
|
node = tmp->data;
|
|
|
|
|
|
|
|
if (node->type != NODE_TYPE_BLOCK)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
text = config_node_get_str(node, "text", NULL);
|
|
|
|
if (text == NULL || *text == '\0')
|
|
|
|
continue;
|
|
|
|
|
|
|
|
rec = g_new0(HILIGHT_REC, 1);
|
|
|
|
hilights = g_slist_append(hilights, rec);
|
|
|
|
|
|
|
|
rec->text = g_strdup(text);
|
2001-01-20 23:14:24 -05:00
|
|
|
|
|
|
|
color = config_node_get_str(node, "color", NULL);
|
2000-04-26 04:03:38 -04:00
|
|
|
rec->color = color == NULL || *color == '\0' ? NULL :
|
|
|
|
g_strdup(color);
|
2001-01-20 23:14:24 -05:00
|
|
|
|
|
|
|
color = config_node_get_str(node, "act_color", NULL);
|
|
|
|
rec->act_color = color == NULL || *color == '\0' ? NULL :
|
|
|
|
g_strdup(color);
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
rec->level = config_node_get_int(node, "level", 0);
|
2001-01-09 16:06:45 -05:00
|
|
|
rec->priority = config_node_get_int(node, "priority", 0);
|
2000-06-30 15:50:56 -04:00
|
|
|
rec->nick = config_node_get_bool(node, "nick", TRUE);
|
2001-01-20 23:14:24 -05:00
|
|
|
rec->word = config_node_get_bool(node, "word", TRUE);
|
2016-04-28 19:01:34 -04:00
|
|
|
rec->case_sensitive = config_node_get_bool(node, "matchcase", FALSE);
|
2001-01-20 23:14:24 -05:00
|
|
|
|
2000-06-30 15:50:56 -04:00
|
|
|
rec->nickmask = config_node_get_bool(node, "mask", FALSE);
|
2000-04-26 04:03:38 -04:00
|
|
|
rec->fullword = config_node_get_bool(node, "fullword", FALSE);
|
|
|
|
rec->regexp = config_node_get_bool(node, "regexp", FALSE);
|
2014-07-06 18:55:15 -04:00
|
|
|
rec->servertag = config_node_get_str(node, "servertag", NULL);
|
2002-05-19 02:50:50 -04:00
|
|
|
hilight_init_rec(rec);
|
2001-01-20 23:14:24 -05:00
|
|
|
|
2015-01-06 21:40:34 -05:00
|
|
|
node = iconfig_node_section(node, "channels", -1);
|
2000-04-26 04:03:38 -04:00
|
|
|
if (node != NULL) rec->channels = config_node_get_list(node);
|
|
|
|
}
|
2001-01-20 23:14:24 -05:00
|
|
|
|
2016-04-28 18:12:28 -04:00
|
|
|
reset_cache();
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void hilight_print(int index, HILIGHT_REC *rec)
|
|
|
|
{
|
|
|
|
char *chans, *levelstr;
|
2002-10-14 08:03:37 -04:00
|
|
|
GString *options;
|
|
|
|
|
|
|
|
options = g_string_new(NULL);
|
2015-11-09 17:06:56 -05:00
|
|
|
|
|
|
|
if (rec->nick && rec->word) { /* default case, no option */ }
|
|
|
|
else if (rec->nick)
|
|
|
|
g_string_append(options, "-nick ");
|
|
|
|
else if (rec->word)
|
|
|
|
g_string_append(options, "-word ");
|
|
|
|
else
|
|
|
|
g_string_append(options, "-line ");
|
2002-10-14 08:03:37 -04:00
|
|
|
|
2007-10-18 14:35:12 -04:00
|
|
|
if (rec->nickmask) g_string_append(options, "-mask ");
|
2007-10-22 12:45:48 -04:00
|
|
|
if (rec->fullword) g_string_append(options, "-full ");
|
2016-04-29 05:00:34 -04:00
|
|
|
if (rec->case_sensitive) g_string_append(options, "-matchcase ");
|
2002-10-14 08:03:37 -04:00
|
|
|
if (rec->regexp) {
|
|
|
|
g_string_append(options, "-regexp ");
|
2016-01-29 10:22:14 -05:00
|
|
|
if (rec->preg == NULL)
|
2002-10-14 08:03:37 -04:00
|
|
|
g_string_append(options, "[INVALID!] ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rec->priority != 0)
|
2009-02-08 12:22:42 -05:00
|
|
|
g_string_append_printf(options, "-priority %d ", rec->priority);
|
2014-07-06 18:55:15 -04:00
|
|
|
if (rec->servertag != NULL)
|
|
|
|
g_string_append_printf(options, "-network %s ", rec->servertag);
|
2002-10-14 08:03:37 -04:00
|
|
|
if (rec->color != NULL)
|
2009-02-08 12:22:42 -05:00
|
|
|
g_string_append_printf(options, "-color %s ", rec->color);
|
2002-10-14 08:03:37 -04:00
|
|
|
if (rec->act_color != NULL)
|
2009-02-08 12:22:42 -05:00
|
|
|
g_string_append_printf(options, "-actcolor %s ", rec->act_color);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
chans = rec->channels == NULL ? NULL :
|
|
|
|
g_strjoinv(",", rec->channels);
|
|
|
|
levelstr = rec->level == 0 ? NULL :
|
|
|
|
bits2level(rec->level);
|
2005-02-11 12:27:09 -05:00
|
|
|
if (levelstr != NULL)
|
|
|
|
levelstr = g_strconcat(levelstr, " ", NULL);
|
2000-04-26 04:03:38 -04:00
|
|
|
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP,
|
2016-04-28 18:12:28 -04:00
|
|
|
TXT_HILIGHT_LINE, index, rec->text,
|
|
|
|
chans != NULL ? chans : "",
|
|
|
|
levelstr != NULL ? levelstr : "",
|
|
|
|
options->str);
|
2000-04-26 04:03:38 -04:00
|
|
|
g_free_not_null(chans);
|
|
|
|
g_free_not_null(levelstr);
|
2002-10-14 08:03:37 -04:00
|
|
|
g_string_free(options, TRUE);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cmd_hilight_show(void)
|
|
|
|
{
|
|
|
|
GSList *tmp;
|
|
|
|
int index;
|
|
|
|
|
2001-01-07 14:42:59 -05:00
|
|
|
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_HILIGHT_HEADER);
|
2000-04-26 04:03:38 -04:00
|
|
|
index = 1;
|
|
|
|
for (tmp = hilights; tmp != NULL; tmp = tmp->next, index++) {
|
|
|
|
HILIGHT_REC *rec = tmp->data;
|
|
|
|
|
|
|
|
hilight_print(index, rec);
|
|
|
|
}
|
2001-01-07 14:42:59 -05:00
|
|
|
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_HILIGHT_FOOTER);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2016-04-29 05:00:34 -04:00
|
|
|
/* SYNTAX: HILIGHT [-nick | -word | -line] [-mask | -full | -matchcase | -regexp]
|
2001-01-20 23:14:24 -05:00
|
|
|
[-color <color>] [-actcolor <color>] [-level <level>]
|
2014-07-06 18:55:15 -04:00
|
|
|
[-network <network>] [-channels <channels>] <text> */
|
2000-04-26 04:03:38 -04:00
|
|
|
static void cmd_hilight(const char *data)
|
|
|
|
{
|
2016-04-28 18:12:28 -04:00
|
|
|
GHashTable *optlist;
|
2000-04-26 04:03:38 -04:00
|
|
|
HILIGHT_REC *rec;
|
2014-07-06 18:55:15 -04:00
|
|
|
char *colorarg, *actcolorarg, *levelarg, *priorityarg, *chanarg, *text, *servertag;
|
2000-06-17 21:18:12 -04:00
|
|
|
char **channels;
|
|
|
|
void *free_arg;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
g_return_if_fail(data != NULL);
|
|
|
|
|
|
|
|
if (*data == '\0') {
|
|
|
|
cmd_hilight_show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
|
2016-04-28 18:12:28 -04:00
|
|
|
PARAM_FLAG_GETREST, "hilight", &optlist, &text))
|
2000-06-17 21:18:12 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
chanarg = g_hash_table_lookup(optlist, "channels");
|
|
|
|
levelarg = g_hash_table_lookup(optlist, "level");
|
2001-01-09 16:06:45 -05:00
|
|
|
priorityarg = g_hash_table_lookup(optlist, "priority");
|
2000-06-17 21:18:12 -04:00
|
|
|
colorarg = g_hash_table_lookup(optlist, "color");
|
2001-01-20 23:14:24 -05:00
|
|
|
actcolorarg = g_hash_table_lookup(optlist, "actcolor");
|
2014-07-06 18:55:15 -04:00
|
|
|
servertag = g_hash_table_lookup(optlist, "network");
|
2000-06-17 21:18:12 -04:00
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
if (*text == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
|
|
|
|
|
2000-06-17 21:18:12 -04:00
|
|
|
channels = (chanarg == NULL || *chanarg == '\0') ? NULL :
|
2008-03-28 14:30:26 -04:00
|
|
|
g_strsplit(chanarg, ",", -1);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
|
|
|
rec = hilight_find(text, channels);
|
|
|
|
if (rec == NULL) {
|
|
|
|
rec = g_new0(HILIGHT_REC, 1);
|
|
|
|
|
2001-01-20 23:14:24 -05:00
|
|
|
/* default to nick/word hilighting */
|
2016-04-28 18:12:28 -04:00
|
|
|
rec->nick = TRUE;
|
2001-01-20 23:14:24 -05:00
|
|
|
rec->word = TRUE;
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
rec->text = g_strdup(text);
|
|
|
|
rec->channels = channels;
|
|
|
|
} else {
|
|
|
|
g_strfreev(channels);
|
|
|
|
}
|
|
|
|
|
2000-07-09 10:25:03 -04:00
|
|
|
rec->level = (levelarg == NULL || *levelarg == '\0') ? 0 :
|
2009-02-21 16:17:51 -05:00
|
|
|
level2bits(replace_chars(levelarg, ',', ' '), NULL);
|
2001-01-09 16:06:45 -05:00
|
|
|
rec->priority = priorityarg == NULL ? 0 : atoi(priorityarg);
|
2001-01-20 23:14:24 -05:00
|
|
|
|
|
|
|
if (g_hash_table_lookup(optlist, "line") != NULL) {
|
|
|
|
rec->word = FALSE;
|
|
|
|
rec->nick = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_hash_table_lookup(optlist, "word") != NULL) {
|
|
|
|
rec->word = TRUE;
|
2016-04-28 18:12:28 -04:00
|
|
|
rec->nick = FALSE;
|
2001-01-20 23:14:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (g_hash_table_lookup(optlist, "nick") != NULL)
|
2016-04-28 18:12:28 -04:00
|
|
|
rec->nick = TRUE;
|
2001-01-20 23:14:24 -05:00
|
|
|
|
2000-06-28 17:47:13 -04:00
|
|
|
rec->nickmask = g_hash_table_lookup(optlist, "mask") != NULL;
|
2001-03-17 01:58:13 -05:00
|
|
|
rec->fullword = g_hash_table_lookup(optlist, "full") != NULL;
|
2000-06-17 21:18:12 -04:00
|
|
|
rec->regexp = g_hash_table_lookup(optlist, "regexp") != NULL;
|
2016-04-29 05:00:34 -04:00
|
|
|
rec->case_sensitive = g_hash_table_lookup(optlist, "matchcase") != NULL;
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-01-20 23:14:24 -05:00
|
|
|
if (colorarg != NULL) {
|
2001-07-15 15:03:27 -04:00
|
|
|
g_free_and_null(rec->color);
|
2001-01-20 23:14:24 -05:00
|
|
|
if (*colorarg != '\0')
|
|
|
|
rec->color = g_strdup(colorarg);
|
|
|
|
}
|
|
|
|
if (actcolorarg != NULL) {
|
2001-07-15 15:03:27 -04:00
|
|
|
g_free_and_null(rec->act_color);
|
2001-01-20 23:14:24 -05:00
|
|
|
if (*actcolorarg != '\0')
|
|
|
|
rec->act_color = g_strdup(actcolorarg);
|
|
|
|
}
|
2014-07-06 18:55:15 -04:00
|
|
|
if (servertag != NULL) {
|
|
|
|
g_free_and_null(rec->servertag);
|
|
|
|
if (*servertag != '\0')
|
|
|
|
rec->servertag = g_strdup(servertag);
|
2014-01-11 09:38:25 -05:00
|
|
|
}
|
2001-01-20 23:14:24 -05:00
|
|
|
|
2002-05-19 02:50:50 -04:00
|
|
|
hilight_create(rec);
|
2000-07-09 10:25:03 -04:00
|
|
|
|
|
|
|
hilight_print(g_slist_index(hilights, rec)+1, rec);
|
2016-04-28 18:12:28 -04:00
|
|
|
cmd_params_free(free_arg);
|
2001-01-20 23:14:24 -05:00
|
|
|
|
|
|
|
reset_cache();
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2000-07-23 19:19:22 -04:00
|
|
|
/* SYNTAX: DEHILIGHT <id>|<mask> */
|
2000-04-26 04:03:38 -04:00
|
|
|
static void cmd_dehilight(const char *data)
|
|
|
|
{
|
|
|
|
HILIGHT_REC *rec;
|
|
|
|
GSList *tmp;
|
|
|
|
|
|
|
|
if (is_numeric(data, ' ')) {
|
|
|
|
/* with index number */
|
2000-05-04 06:32:42 -04:00
|
|
|
tmp = g_slist_nth(hilights, atoi(data)-1);
|
2000-04-26 04:03:38 -04:00
|
|
|
rec = tmp == NULL ? NULL : tmp->data;
|
|
|
|
} else {
|
|
|
|
/* with mask */
|
|
|
|
char *chans[2] = { "*", NULL };
|
2016-04-28 18:12:28 -04:00
|
|
|
rec = hilight_find(data, chans);
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (rec == NULL)
|
2001-01-07 14:42:59 -05:00
|
|
|
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_HILIGHT_NOT_FOUND, data);
|
2000-05-09 09:14:07 -04:00
|
|
|
else {
|
2001-01-07 14:42:59 -05:00
|
|
|
printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_HILIGHT_REMOVED, rec->text);
|
2000-05-09 09:14:07 -04:00
|
|
|
hilight_remove(rec);
|
2016-04-28 18:12:28 -04:00
|
|
|
reset_cache();
|
2000-05-09 09:14:07 -04:00
|
|
|
}
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
2001-01-20 23:14:24 -05:00
|
|
|
static void hilight_nick_cache(GHashTable *list, CHANNEL_REC *channel,
|
2016-04-28 18:12:28 -04:00
|
|
|
NICK_REC *nick)
|
2001-01-20 23:14:24 -05:00
|
|
|
{
|
|
|
|
GSList *tmp;
|
|
|
|
HILIGHT_REC *match;
|
2016-04-28 18:12:28 -04:00
|
|
|
char *nickmask;
|
2001-01-20 23:14:24 -05:00
|
|
|
int len, best_match;
|
|
|
|
|
|
|
|
if (nick->host == NULL)
|
2016-04-28 18:12:28 -04:00
|
|
|
return; /* don't check until host is known */
|
2001-01-20 23:14:24 -05:00
|
|
|
|
|
|
|
nickmask = g_strconcat(nick->nick, "!", nick->host, NULL);
|
|
|
|
|
|
|
|
best_match = 0; match = NULL;
|
|
|
|
for (tmp = hilights; tmp != NULL; tmp = tmp->next) {
|
|
|
|
HILIGHT_REC *rec = tmp->data;
|
|
|
|
|
|
|
|
if (rec->nickmask &&
|
2016-04-28 18:12:28 -04:00
|
|
|
hilight_match_channel(rec, channel->name) &&
|
|
|
|
match_wildcards(rec->text, nickmask)) {
|
2001-01-20 23:14:24 -05:00
|
|
|
len = strlen(rec->text);
|
|
|
|
if (best_match < len) {
|
|
|
|
best_match = len;
|
|
|
|
match = rec;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
g_free_not_null(nickmask);
|
|
|
|
|
|
|
|
if (match != NULL)
|
2016-04-28 18:12:28 -04:00
|
|
|
g_hash_table_insert(list, nick, match);
|
2001-01-20 23:14:24 -05:00
|
|
|
}
|
|
|
|
|
2001-01-13 09:04:11 -05:00
|
|
|
static void read_settings(void)
|
|
|
|
{
|
2002-12-28 12:54:13 -05:00
|
|
|
default_hilight_level = settings_get_level("hilight_level");
|
2008-06-04 15:33:00 -04:00
|
|
|
reset_level_cache();
|
2001-01-13 09:04:11 -05:00
|
|
|
}
|
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
void hilight_text_init(void)
|
|
|
|
{
|
2001-03-16 20:52:43 -05:00
|
|
|
settings_add_str("lookandfeel", "hilight_color", "%Y");
|
|
|
|
settings_add_str("lookandfeel", "hilight_act_color", "%M");
|
2002-12-28 12:54:13 -05:00
|
|
|
settings_add_level("lookandfeel", "hilight_level", "PUBLIC DCCMSGS");
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2016-04-28 18:12:28 -04:00
|
|
|
read_settings();
|
2001-01-20 23:14:24 -05:00
|
|
|
|
|
|
|
nickmatch = nickmatch_init(hilight_nick_cache);
|
|
|
|
read_hilight_config();
|
|
|
|
|
2001-01-09 16:06:45 -05:00
|
|
|
signal_add_first("print text", (SIGNAL_FUNC) sig_print_text);
|
2016-04-28 18:12:28 -04:00
|
|
|
signal_add("setup reread", (SIGNAL_FUNC) read_hilight_config);
|
|
|
|
signal_add("setup changed", (SIGNAL_FUNC) read_settings);
|
2001-01-09 16:06:45 -05:00
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
command_bind("hilight", NULL, (SIGNAL_FUNC) cmd_hilight);
|
|
|
|
command_bind("dehilight", NULL, (SIGNAL_FUNC) cmd_dehilight);
|
2016-04-29 05:00:34 -04:00
|
|
|
command_set_options("hilight", "-color -actcolor -level -priority -network -channels nick word line mask full regexp matchcase");
|
2000-04-26 04:03:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void hilight_text_deinit(void)
|
|
|
|
{
|
|
|
|
hilights_destroy_all();
|
2016-04-28 18:12:28 -04:00
|
|
|
nickmatch_deinit(nickmatch);
|
2000-04-26 04:03:38 -04:00
|
|
|
|
2001-01-09 16:06:45 -05:00
|
|
|
signal_remove("print text", (SIGNAL_FUNC) sig_print_text);
|
2016-04-28 18:12:28 -04:00
|
|
|
signal_remove("setup reread", (SIGNAL_FUNC) read_hilight_config);
|
|
|
|
signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
|
2001-01-09 16:06:45 -05:00
|
|
|
|
2000-04-26 04:03:38 -04:00
|
|
|
command_unbind("hilight", (SIGNAL_FUNC) cmd_hilight);
|
|
|
|
command_unbind("dehilight", (SIGNAL_FUNC) cmd_dehilight);
|
|
|
|
}
|