Merge Irssi 0.8.16-rc1
[silc.git] / apps / irssi / src / fe-common / core / hilight-text.c
1 /*
2  hilight-text.c : irssi
3
4     Copyright (C) 1999-2000 Timo Sirainen
5
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License along
17     with this program; if not, write to the Free Software Foundation, Inc.,
18     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #include "module.h"
22 #include "module-formats.h"
23 #include "signals.h"
24 #include "commands.h"
25 #include "levels.h"
26 #include "misc.h"
27 #include "lib-config/iconfig.h"
28 #include "settings.h"
29
30 #include "servers.h"
31 #include "channels.h"
32 #include "nicklist.h"
33
34 #include "hilight-text.h"
35 #include "nickmatch-cache.h"
36 #include "printtext.h"
37 #include "formats.h"
38
39 static NICKMATCH_REC *nickmatch;
40 static int never_hilight_level, default_hilight_level;
41 GSList *hilights;
42
43 static void reset_level_cache(void)
44 {
45         GSList *tmp;
46
47         never_hilight_level = MSGLEVEL_ALL & ~default_hilight_level;
48         for (tmp = hilights; tmp != NULL; tmp = tmp->next) {
49                 HILIGHT_REC *rec = tmp->data;
50
51                 if (never_hilight_level & rec->level)
52                         never_hilight_level &= ~rec->level;
53         }
54 }
55
56 static void reset_cache(void)
57 {
58         reset_level_cache();
59         nickmatch_rebuild(nickmatch);
60 }
61
62 static void hilight_add_config(HILIGHT_REC *rec)
63 {
64         CONFIG_NODE *node;
65
66         g_return_if_fail(rec != NULL);
67
68         node = iconfig_node_traverse("(hilights", TRUE);
69         node = config_node_section(node, NULL, NODE_TYPE_BLOCK);
70
71         iconfig_node_set_str(node, "text", rec->text);
72         if (rec->level > 0) iconfig_node_set_int(node, "level", rec->level);
73         if (rec->color) iconfig_node_set_str(node, "color", rec->color);
74         if (rec->act_color) iconfig_node_set_str(node, "act_color", rec->act_color);
75         if (rec->priority > 0) iconfig_node_set_int(node, "priority", rec->priority);
76         iconfig_node_set_bool(node, "nick", rec->nick);
77         iconfig_node_set_bool(node, "word", rec->word);
78         if (rec->nickmask) iconfig_node_set_bool(node, "mask", TRUE);
79         if (rec->fullword) iconfig_node_set_bool(node, "fullword", TRUE);
80         if (rec->regexp) iconfig_node_set_bool(node, "regexp", TRUE);
81
82         if (rec->channels != NULL && *rec->channels != NULL) {
83                 node = config_node_section(node, "channels", NODE_TYPE_LIST);
84                 iconfig_node_add_list(node, rec->channels);
85         }
86 }
87
88 static void hilight_remove_config(HILIGHT_REC *rec)
89 {
90         CONFIG_NODE *node;
91
92         g_return_if_fail(rec != NULL);
93
94         node = iconfig_node_traverse("hilights", FALSE);
95         if (node != NULL) iconfig_node_list_remove(node, g_slist_index(hilights, rec));
96 }
97
98 static void hilight_destroy(HILIGHT_REC *rec)
99 {
100         g_return_if_fail(rec != NULL);
101
102 #ifdef HAVE_REGEX_H
103         if (rec->regexp_compiled) regfree(&rec->preg);
104 #endif
105         if (rec->channels != NULL) g_strfreev(rec->channels);
106         g_free_not_null(rec->color);
107         g_free_not_null(rec->act_color);
108         g_free(rec->text);
109         g_free(rec);
110 }
111
112 static void hilights_destroy_all(void)
113 {
114         g_slist_foreach(hilights, (GFunc) hilight_destroy, NULL);
115         g_slist_free(hilights);
116         hilights = NULL;
117 }
118
119 static void hilight_init_rec(HILIGHT_REC *rec)
120 {
121 #ifdef HAVE_REGEX_H
122         if (rec->regexp_compiled) regfree(&rec->preg);
123         rec->regexp_compiled = !rec->regexp ? FALSE :
124                 regcomp(&rec->preg, rec->text, REG_EXTENDED|REG_ICASE) == 0;
125 #endif
126 }
127
128 void hilight_create(HILIGHT_REC *rec)
129 {
130         if (g_slist_find(hilights, rec) != NULL) {
131                 hilight_remove_config(rec);
132                 hilights = g_slist_remove(hilights, rec);
133         }
134
135         hilights = g_slist_append(hilights, rec);
136         hilight_add_config(rec);
137
138         hilight_init_rec(rec);
139
140         signal_emit("hilight created", 1, rec);
141 }
142
143 void hilight_remove(HILIGHT_REC *rec)
144 {
145         g_return_if_fail(rec != NULL);
146
147         hilight_remove_config(rec);
148         hilights = g_slist_remove(hilights, rec);
149
150         signal_emit("hilight destroyed", 1, rec);
151         hilight_destroy(rec);
152 }
153
154 static HILIGHT_REC *hilight_find(const char *text, char **channels)
155 {
156         GSList *tmp;
157         char **chan;
158
159         g_return_val_if_fail(text != NULL, NULL);
160
161         for (tmp = hilights; tmp != NULL; tmp = tmp->next) {
162                 HILIGHT_REC *rec = tmp->data;
163
164                 if (g_strcasecmp(rec->text, text) != 0)
165                         continue;
166
167                 if ((channels == NULL && rec->channels == NULL))
168                         return rec; /* no channels - ok */
169
170                 if (channels != NULL && strcmp(*channels, "*") == 0)
171                         return rec; /* ignore channels */
172
173                 if (channels == NULL || rec->channels == NULL)
174                         continue; /* other doesn't have channels */
175
176                 if (strarray_length(channels) != strarray_length(rec->channels))
177                         continue; /* different amount of channels */
178
179                 /* check that channels match */
180                 for (chan = channels; *chan != NULL; chan++) {
181                         if (strarray_find(rec->channels, *chan) == -1)
182                                 break;
183                 }
184
185                 if (*chan == NULL)
186                         return rec; /* channels ok */
187         }
188
189         return NULL;
190 }
191
192 static int hilight_match_text(HILIGHT_REC *rec, const char *text,
193                               int *match_beg, int *match_end)
194 {
195         char *match;
196
197         if (rec->regexp) {
198 #ifdef HAVE_REGEX_H
199                 regmatch_t rmatch[1];
200
201                 if (rec->regexp_compiled &&
202                     regexec(&rec->preg, text, 1, rmatch, 0) == 0) {
203                         if (rmatch[0].rm_so > 0 &&
204                             match_beg != NULL && match_end != NULL) {
205                                 *match_beg = rmatch[0].rm_so;
206                                 *match_end = rmatch[0].rm_eo;
207                         }
208                         return TRUE;
209                 }
210 #endif
211         } else {
212                 match = rec->fullword ?
213                         stristr_full(text, rec->text) :
214                         stristr(text, rec->text);
215                 if (match != NULL) {
216                         if (match_beg != NULL && match_end != NULL) {
217                                 *match_beg = (int) (match-text);
218                                 *match_end = *match_beg + strlen(rec->text);
219                         }
220                         return TRUE;
221                 }
222         }
223
224         return FALSE;
225 }
226
227 #define hilight_match_level(rec, level) \
228         (level & (((rec)->level != 0 ? rec->level : default_hilight_level)))
229
230 #define hilight_match_channel(rec, channel) \
231         ((rec)->channels == NULL || ((channel) != NULL && \
232                 strarray_find((rec)->channels, (channel)) != -1))
233
234 HILIGHT_REC *hilight_match(SERVER_REC *server, const char *channel,
235                            const char *nick, const char *address,
236                            int level, const char *str,
237                            int *match_beg, int *match_end)
238 {
239         GSList *tmp;
240         CHANNEL_REC *chanrec;
241         NICK_REC *nickrec;
242
243         g_return_val_if_fail(str != NULL, NULL);
244
245         if ((never_hilight_level & level) == level)
246                 return NULL;
247
248         if (nick != NULL) {
249                 /* check nick mask hilights */
250                 chanrec = channel_find(server, channel);
251                 nickrec = chanrec == NULL ? NULL :
252                         nicklist_find(chanrec, nick);
253                 if (nickrec != NULL) {
254                         HILIGHT_REC *rec;
255
256                         if (nickrec->host == NULL)
257                                 nicklist_set_host(chanrec, nickrec, address);
258
259                         rec = nickmatch_find(nickmatch, nickrec);
260                         if (rec != NULL && hilight_match_level(rec, level))
261                                 return rec;
262                 }
263         }
264
265         for (tmp = hilights; tmp != NULL; tmp = tmp->next) {
266                 HILIGHT_REC *rec = tmp->data;
267
268                 if (!rec->nickmask && hilight_match_level(rec, level) &&
269                     hilight_match_channel(rec, channel) &&
270                     hilight_match_text(rec, str, match_beg, match_end))
271                         return rec;
272         }
273
274         return NULL;
275 }
276
277 static char *hilight_get_act_color(HILIGHT_REC *rec)
278 {
279         g_return_val_if_fail(rec != NULL, NULL);
280
281         return g_strdup(rec->act_color != NULL ? rec->act_color :
282                         rec->color != NULL ? rec->color :
283                         settings_get_str("hilight_act_color"));
284 }
285
286 char *hilight_get_color(HILIGHT_REC *rec)
287 {
288         const char *color;
289
290         g_return_val_if_fail(rec != NULL, NULL);
291
292         color = rec->color != NULL ? rec->color :
293                 settings_get_str("hilight_color");
294
295         return format_string_expand(color, NULL);
296 }
297
298 void hilight_update_text_dest(TEXT_DEST_REC *dest, HILIGHT_REC *rec)
299 {
300         dest->level |= MSGLEVEL_HILIGHT;
301
302         if (rec->priority > 0)
303                 dest->hilight_priority = rec->priority;
304
305         g_free_and_null(dest->hilight_color);
306         if (rec->act_color != NULL && strcmp(rec->act_color, "%n") == 0)
307                 dest->level |= MSGLEVEL_NO_ACT;
308         else
309                 dest->hilight_color = hilight_get_act_color(rec);
310 }
311
312 static void hilight_print(int index, HILIGHT_REC *rec);
313
314 static void sig_print_text(TEXT_DEST_REC *dest, const char *text,
315                            const char *stripped)
316 {
317         HILIGHT_REC *hilight;
318         char *color, *newstr;
319         int old_level, hilight_start, hilight_end, hilight_len;
320         int nick_match;
321
322         if (dest->level & MSGLEVEL_NOHILIGHT)
323                 return;
324
325         hilight_start = hilight_end = 0;
326         hilight = hilight_match(dest->server, dest->target,
327                                 NULL, NULL, dest->level, stripped,
328                                 &hilight_start,
329                                 &hilight_end);
330         if (hilight == NULL)
331                 return;
332
333         nick_match = hilight->nick && (dest->level & (MSGLEVEL_PUBLIC|MSGLEVEL_ACTIONS)) == MSGLEVEL_PUBLIC;
334
335         old_level = dest->level;
336         if (!nick_match || (dest->level & MSGLEVEL_HILIGHT)) {
337                 /* update the level / hilight info */
338                 hilight_update_text_dest(dest, hilight);
339         }
340
341         if (nick_match)
342                 return; /* fe-messages.c should have taken care of this */
343
344         if (old_level & MSGLEVEL_HILIGHT) {
345                 /* nick is highlighted, just set priority */
346                 return;
347         }
348
349         color = hilight_get_color(hilight);
350         hilight_len = hilight_end-hilight_start;
351
352         if (!hilight->word) {
353                 /* hilight whole line */
354                 char *tmp = strip_codes(text);
355                 newstr = g_strconcat(color, tmp, NULL);
356                 g_free(tmp);
357         } else {
358                 /* hilight part of the line */
359                 GString *tmp;
360                 char *middle;
361                 int pos, color_pos, color_len;
362
363                 tmp = g_string_new(NULL);
364
365                 /* start of the line */
366                 pos = strip_real_length(text, hilight_start, NULL, NULL);
367                 g_string_append(tmp, text);
368                 g_string_truncate(tmp, pos);
369
370                 /* color */
371                 g_string_append(tmp, color);
372
373                 /* middle of the line, stripped */
374                 middle = strip_codes(text+pos);
375                 pos = tmp->len;
376                 g_string_append(tmp, middle);
377                 g_string_truncate(tmp, pos+hilight_len);
378                 g_free(middle);
379
380                 /* end of the line */
381                 pos = strip_real_length(text, hilight_end,
382                                         &color_pos, &color_len);
383                 if (color_pos > 0)
384                         g_string_append_len(tmp, text+color_pos, color_len);
385                 else {
386                         /* no colors in line, change back to default */
387                         g_string_append_c(tmp, 4);
388                         g_string_append_c(tmp, FORMAT_STYLE_DEFAULTS);
389                 }
390                 g_string_append(tmp, text+pos);
391
392                 newstr = tmp->str;
393                 g_string_free(tmp, FALSE);
394         }
395
396         signal_emit("print text", 3, dest, newstr, stripped);
397
398         g_free(color);
399         g_free(newstr);
400
401         signal_stop();
402 }
403
404 HILIGHT_REC *hilight_match_nick(SERVER_REC *server, const char *channel,
405                          const char *nick, const char *address,
406                          int level, const char *msg)
407 {
408         HILIGHT_REC *rec;
409
410         rec = hilight_match(server, channel, nick, address,
411                             level, msg, NULL, NULL);
412         return (rec == NULL || !rec->nick) ? NULL : rec;
413 }
414
415 static void read_hilight_config(void)
416 {
417         CONFIG_NODE *node;
418         HILIGHT_REC *rec;
419         GSList *tmp;
420         char *text, *color;
421
422         hilights_destroy_all();
423
424         node = iconfig_node_traverse("hilights", FALSE);
425         if (node == NULL) {
426                 reset_cache();
427                 return;
428         }
429
430         tmp = config_node_first(node->value);
431         for (; tmp != NULL; tmp = config_node_next(tmp)) {
432                 node = tmp->data;
433
434                 if (node->type != NODE_TYPE_BLOCK)
435                         continue;
436
437                 text = config_node_get_str(node, "text", NULL);
438                 if (text == NULL || *text == '\0')
439                         continue;
440
441                 rec = g_new0(HILIGHT_REC, 1);
442                 hilights = g_slist_append(hilights, rec);
443
444                 rec->text = g_strdup(text);
445
446                 color = config_node_get_str(node, "color", NULL);
447                 rec->color = color == NULL || *color == '\0' ? NULL :
448                         g_strdup(color);
449
450                 color = config_node_get_str(node, "act_color", NULL);
451                 rec->act_color = color == NULL || *color == '\0' ? NULL :
452                         g_strdup(color);
453
454                 rec->level = config_node_get_int(node, "level", 0);
455                 rec->priority = config_node_get_int(node, "priority", 0);
456                 rec->nick = config_node_get_bool(node, "nick", TRUE);
457                 rec->word = config_node_get_bool(node, "word", TRUE);
458
459                 rec->nickmask = config_node_get_bool(node, "mask", FALSE);
460                 rec->fullword = config_node_get_bool(node, "fullword", FALSE);
461                 rec->regexp = config_node_get_bool(node, "regexp", FALSE);
462
463                 hilight_init_rec(rec);
464
465                 node = config_node_section(node, "channels", -1);
466                 if (node != NULL) rec->channels = config_node_get_list(node);
467         }
468
469         reset_cache();
470 }
471
472 static void hilight_print(int index, HILIGHT_REC *rec)
473 {
474         char *chans, *levelstr;
475         GString *options;
476
477         options = g_string_new(NULL);
478         if (!rec->nick || !rec->word) {
479                 if (rec->nick) g_string_append(options, "-nick ");
480                 if (rec->word) g_string_append(options, "-word ");
481         }
482
483         if (rec->nickmask) g_string_append(options, "-mask ");
484         if (rec->fullword) g_string_append(options, "-full ");
485         if (rec->regexp) {
486                 g_string_append(options, "-regexp ");
487 #ifdef HAVE_REGEX_H
488                 if (!rec->regexp_compiled)
489                         g_string_append(options, "[INVALID!] ");
490 #endif
491         }
492
493         if (rec->priority != 0)
494                 g_string_append_printf(options, "-priority %d ", rec->priority);
495         if (rec->color != NULL)
496                 g_string_append_printf(options, "-color %s ", rec->color);
497         if (rec->act_color != NULL)
498                 g_string_append_printf(options, "-actcolor %s ", rec->act_color);
499
500         chans = rec->channels == NULL ? NULL :
501                 g_strjoinv(",", rec->channels);
502         levelstr = rec->level == 0 ? NULL :
503                 bits2level(rec->level);
504         if (levelstr != NULL)
505                 levelstr = g_strconcat(levelstr, " ", NULL);
506         printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP,
507                     TXT_HILIGHT_LINE, index, rec->text,
508                     chans != NULL ? chans : "",
509                     levelstr != NULL ? levelstr : "",
510                     options->str);
511         g_free_not_null(chans);
512         g_free_not_null(levelstr);
513         g_string_free(options, TRUE);
514 }
515
516 static void cmd_hilight_show(void)
517 {
518         GSList *tmp;
519         int index;
520
521         printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_HILIGHT_HEADER);
522         index = 1;
523         for (tmp = hilights; tmp != NULL; tmp = tmp->next, index++) {
524                 HILIGHT_REC *rec = tmp->data;
525
526                 hilight_print(index, rec);
527         }
528         printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_HILIGHT_FOOTER);
529 }
530
531 /* SYNTAX: HILIGHT [-nick | -word | -line] [-mask | -full | -regexp]
532                    [-color <color>] [-actcolor <color>] [-level <level>]
533                    [-channels <channels>] <text> */
534 static void cmd_hilight(const char *data)
535 {
536         GHashTable *optlist;
537         HILIGHT_REC *rec;
538         char *colorarg, *actcolorarg, *levelarg, *priorityarg, *chanarg, *text;
539         char **channels;
540         void *free_arg;
541
542         g_return_if_fail(data != NULL);
543
544         if (*data == '\0') {
545                 cmd_hilight_show();
546                 return;
547         }
548
549         if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS |
550                             PARAM_FLAG_GETREST, "hilight", &optlist, &text))
551                 return;
552
553         chanarg = g_hash_table_lookup(optlist, "channels");
554         levelarg = g_hash_table_lookup(optlist, "level");
555         priorityarg = g_hash_table_lookup(optlist, "priority");
556         colorarg = g_hash_table_lookup(optlist, "color");
557         actcolorarg = g_hash_table_lookup(optlist, "actcolor");
558
559         if (*text == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
560
561         channels = (chanarg == NULL || *chanarg == '\0') ? NULL :
562                 g_strsplit(chanarg, ",", -1);
563
564         rec = hilight_find(text, channels);
565         if (rec == NULL) {
566                 rec = g_new0(HILIGHT_REC, 1);
567
568                 /* default to nick/word hilighting */
569                 rec->nick = TRUE;
570                 rec->word = TRUE;
571
572                 rec->text = g_strdup(text);
573                 rec->channels = channels;
574         } else {
575                 g_strfreev(channels);
576         }
577
578         rec->level = (levelarg == NULL || *levelarg == '\0') ? 0 :
579                 level2bits(replace_chars(levelarg, ',', ' '), NULL);
580         rec->priority = priorityarg == NULL ? 0 : atoi(priorityarg);
581
582         if (g_hash_table_lookup(optlist, "line") != NULL) {
583                 rec->word = FALSE;
584                 rec->nick = FALSE;
585         }
586
587         if (g_hash_table_lookup(optlist, "word") != NULL) {
588                 rec->word = TRUE;
589                 rec->nick = FALSE;
590         }
591
592         if (g_hash_table_lookup(optlist, "nick") != NULL)
593                 rec->nick = TRUE;
594
595         rec->nickmask = g_hash_table_lookup(optlist, "mask") != NULL;
596         rec->fullword = g_hash_table_lookup(optlist, "full") != NULL;
597         rec->regexp = g_hash_table_lookup(optlist, "regexp") != NULL;
598
599         if (colorarg != NULL) {
600                 g_free_and_null(rec->color);
601                 if (*colorarg != '\0')
602                         rec->color = g_strdup(colorarg);
603         }
604         if (actcolorarg != NULL) {
605                 g_free_and_null(rec->act_color);
606                 if (*actcolorarg != '\0')
607                         rec->act_color = g_strdup(actcolorarg);
608         }
609
610         hilight_create(rec);
611
612         hilight_print(g_slist_index(hilights, rec)+1, rec);
613         cmd_params_free(free_arg);
614
615         reset_cache();
616 }
617
618 /* SYNTAX: DEHILIGHT <id>|<mask> */
619 static void cmd_dehilight(const char *data)
620 {
621         HILIGHT_REC *rec;
622         GSList *tmp;
623
624         if (is_numeric(data, ' ')) {
625                 /* with index number */
626                 tmp = g_slist_nth(hilights, atoi(data)-1);
627                 rec = tmp == NULL ? NULL : tmp->data;
628         } else {
629                 /* with mask */
630                 char *chans[2] = { "*", NULL };
631                 rec = hilight_find(data, chans);
632         }
633
634         if (rec == NULL)
635                 printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_HILIGHT_NOT_FOUND, data);
636         else {
637                 printformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE, TXT_HILIGHT_REMOVED, rec->text);
638                 hilight_remove(rec);
639                 reset_cache();
640         }
641 }
642
643 static void hilight_nick_cache(GHashTable *list, CHANNEL_REC *channel,
644                                NICK_REC *nick)
645 {
646         GSList *tmp;
647         HILIGHT_REC *match;
648         char *nickmask;
649         int len, best_match;
650
651         if (nick->host == NULL)
652                 return; /* don't check until host is known */
653
654         nickmask = g_strconcat(nick->nick, "!", nick->host, NULL);
655
656         best_match = 0; match = NULL;
657         for (tmp = hilights; tmp != NULL; tmp = tmp->next) {
658                 HILIGHT_REC *rec = tmp->data;
659
660                 if (rec->nickmask &&
661                     hilight_match_channel(rec, channel->name) &&
662                     match_wildcards(rec->text, nickmask)) {
663                         len = strlen(rec->text);
664                         if (best_match < len) {
665                                 best_match = len;
666                                 match = rec;
667                         }
668                 }
669         }
670         g_free_not_null(nickmask);
671
672         if (match != NULL)
673                 g_hash_table_insert(list, nick, match);
674 }
675
676 static void read_settings(void)
677 {
678         default_hilight_level = settings_get_level("hilight_level");
679         reset_level_cache();
680 }
681
682 void hilight_text_init(void)
683 {
684         settings_add_str("lookandfeel", "hilight_color", "%Y");
685         settings_add_str("lookandfeel", "hilight_act_color", "%M");
686         settings_add_level("lookandfeel", "hilight_level", "PUBLIC DCCMSGS");
687
688         read_settings();
689
690         nickmatch = nickmatch_init(hilight_nick_cache);
691         read_hilight_config();
692
693         signal_add_first("print text", (SIGNAL_FUNC) sig_print_text);
694         signal_add("setup reread", (SIGNAL_FUNC) read_hilight_config);
695         signal_add("setup changed", (SIGNAL_FUNC) read_settings);
696
697         command_bind("hilight", NULL, (SIGNAL_FUNC) cmd_hilight);
698         command_bind("dehilight", NULL, (SIGNAL_FUNC) cmd_dehilight);
699         command_set_options("hilight", "-color -actcolor -level -priority -channels nick word line mask full regexp");
700 }
701
702 void hilight_text_deinit(void)
703 {
704         hilights_destroy_all();
705         nickmatch_deinit(nickmatch);
706
707         signal_remove("print text", (SIGNAL_FUNC) sig_print_text);
708         signal_remove("setup reread", (SIGNAL_FUNC) read_hilight_config);
709         signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
710
711         command_unbind("hilight", (SIGNAL_FUNC) cmd_hilight);
712         command_unbind("dehilight", (SIGNAL_FUNC) cmd_dehilight);
713 }