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