diff options
author | Timo Sirainen <cras@irssi.org> | 2002-05-19 06:50:50 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2002-05-19 06:50:50 +0000 |
commit | dc0088f58456ba2b83d8f75057595ce0b5dd512a (patch) | |
tree | 05e75f2d023faa01d99c7ca7746980b5c7833884 /src/fe-common/core/hilight-text.c | |
parent | b9eda1adb6966121851c29fa7900e0706ac52d32 (diff) | |
download | irssi-dc0088f58456ba2b83d8f75057595ce0b5dd512a.zip |
hilight + keyboard fixes so it's possible for xirssi to modify them.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2816 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common/core/hilight-text.c')
-rw-r--r-- | src/fe-common/core/hilight-text.c | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/src/fe-common/core/hilight-text.c b/src/fe-common/core/hilight-text.c index 4d5466e2..1648e26d 100644 --- a/src/fe-common/core/hilight-text.c +++ b/src/fe-common/core/hilight-text.c @@ -112,12 +112,38 @@ static void hilights_destroy_all(void) hilights = NULL; } -static void hilight_remove(HILIGHT_REC *rec) +static void hilight_init_rec(HILIGHT_REC *rec) +{ +#ifdef HAVE_REGEX_H + if (rec->regexp_compiled) regfree(&rec->preg); + rec->regexp_compiled = !rec->regexp ? FALSE : + regcomp(&rec->preg, rec->text, REG_EXTENDED|REG_ICASE) == 0; +#endif +} + +void hilight_create(HILIGHT_REC *rec) +{ + if (g_slist_find(hilights, rec) != NULL) { + hilights = g_slist_remove(hilights, rec); + hilight_remove_config(rec); + } + + 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) { g_return_if_fail(rec != NULL); hilight_remove_config(rec); hilights = g_slist_remove(hilights, rec); + + signal_emit("hilight destroyed", 1, rec); hilight_destroy(rec); } @@ -435,11 +461,7 @@ static void read_hilight_config(void) rec->fullword = config_node_get_bool(node, "fullword", FALSE); rec->regexp = config_node_get_bool(node, "regexp", FALSE); -#ifdef HAVE_REGEX_H - rec->regexp_compiled = !rec->regexp ? FALSE : - regcomp(&rec->preg, rec->text, - REG_EXTENDED|REG_ICASE) == 0; -#endif + hilight_init_rec(rec); node = config_node_section(node, "channels", -1); if (node != NULL) rec->channels = config_node_get_list(node); @@ -527,9 +549,6 @@ static void cmd_hilight(const char *data) rec->channels = channels; } else { g_strfreev(channels); - - hilight_remove_config(rec); - hilights = g_slist_remove(hilights, rec); } rec->level = (levelarg == NULL || *levelarg == '\0') ? 0 : @@ -564,15 +583,7 @@ static void cmd_hilight(const char *data) rec->act_color = g_strdup(actcolorarg); } -#ifdef HAVE_REGEX_H - if (rec->regexp_compiled) - regfree(&rec->preg); - rec->regexp_compiled = !rec->regexp ? FALSE : - regcomp(&rec->preg, rec->text, REG_EXTENDED|REG_ICASE) == 0; -#endif - - hilights = g_slist_append(hilights, rec); - hilight_add_config(rec); + hilight_create(rec); hilight_print(g_slist_index(hilights, rec)+1, rec); cmd_params_free(free_arg); |