From 669add63e866b11c47f94f750dcdbc8631a81218 Mon Sep 17 00:00:00 2001 From: Manuel Leiner Date: Sat, 11 Jan 2014 15:38:25 +0100 Subject: [PATCH 1/2] FS#155 hilight -tag --- src/fe-common/core/hilight-text.c | 16 +++++++++++++--- src/fe-common/core/hilight-text.h | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/fe-common/core/hilight-text.c b/src/fe-common/core/hilight-text.c index d4eeb1f3..0caf2ca2 100644 --- a/src/fe-common/core/hilight-text.c +++ b/src/fe-common/core/hilight-text.c @@ -78,6 +78,7 @@ static void hilight_add_config(HILIGHT_REC *rec) 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); + if (rec->tag) iconfig_node_set_str(node,"tag",rec->tag); if (rec->channels != NULL && *rec->channels != NULL) { node = config_node_section(node, "channels", NODE_TYPE_LIST); @@ -267,6 +268,7 @@ HILIGHT_REC *hilight_match(SERVER_REC *server, const char *channel, if (!rec->nickmask && hilight_match_level(rec, level) && hilight_match_channel(rec, channel) && + (rec->tag == NULL || (server != NULL && rec->tag != NULL && server->tag !=NULL && strcmp(rec->tag,server->tag) == 0)) && hilight_match_text(rec, str, match_beg, match_end)) return rec; } @@ -465,7 +467,7 @@ static void read_hilight_config(void) rec->nickmask = config_node_get_bool(node, "mask", FALSE); rec->fullword = config_node_get_bool(node, "fullword", FALSE); rec->regexp = config_node_get_bool(node, "regexp", FALSE); - + rec->tag = config_node_get_str(node,"tag",NULL); hilight_init_rec(rec); node = config_node_section(node, "channels", -1); @@ -498,6 +500,8 @@ static void hilight_print(int index, HILIGHT_REC *rec) if (rec->priority != 0) g_string_append_printf(options, "-priority %d ", rec->priority); + if (rec->tag != NULL) + g_string_append_printf(options, "-tag %s ", rec->tag); if (rec->color != NULL) g_string_append_printf(options, "-color %s ", rec->color); if (rec->act_color != NULL) @@ -541,7 +545,7 @@ static void cmd_hilight(const char *data) { GHashTable *optlist; HILIGHT_REC *rec; - char *colorarg, *actcolorarg, *levelarg, *priorityarg, *chanarg, *text; + char *colorarg, *actcolorarg, *levelarg, *priorityarg, *chanarg, *text, *tagarg=NULL; char **channels; void *free_arg; @@ -561,6 +565,7 @@ static void cmd_hilight(const char *data) priorityarg = g_hash_table_lookup(optlist, "priority"); colorarg = g_hash_table_lookup(optlist, "color"); actcolorarg = g_hash_table_lookup(optlist, "actcolor"); + tagarg = g_hash_table_lookup(optlist,"tag"); if (*text == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); @@ -612,6 +617,11 @@ static void cmd_hilight(const char *data) if (*actcolorarg != '\0') rec->act_color = g_strdup(actcolorarg); } + if (tagarg != NULL) { + g_free_and_null(rec->tag); + if (*tagarg != '\0') + rec->tag = g_strdup(tagarg); + } hilight_create(rec); @@ -702,7 +712,7 @@ void hilight_text_init(void) command_bind("hilight", NULL, (SIGNAL_FUNC) cmd_hilight); command_bind("dehilight", NULL, (SIGNAL_FUNC) cmd_dehilight); - command_set_options("hilight", "-color -actcolor -level -priority -channels nick word line mask full regexp"); + command_set_options("hilight", "-color -actcolor -level -priority -tag -channels nick word line mask full regexp"); } void hilight_text_deinit(void) diff --git a/src/fe-common/core/hilight-text.h b/src/fe-common/core/hilight-text.h index 74c58780..058efbc6 100644 --- a/src/fe-common/core/hilight-text.h +++ b/src/fe-common/core/hilight-text.h @@ -29,6 +29,7 @@ struct _HILIGHT_REC { unsigned int regexp_compiled:1; /* should always be TRUE, unless regexp is invalid */ regex_t preg; #endif + char *tag; }; extern GSList *hilights; From d3093418d42bf514eb808abc734f03669d4e18e7 Mon Sep 17 00:00:00 2001 From: Ailin Nemui Date: Mon, 7 Jul 2014 00:55:15 +0200 Subject: [PATCH 2/2] cleanup hilight -network patch --- docs/help/in/hilight.in | 1 + src/fe-common/core/hilight-text.c | 27 ++++++++++++++------------- src/fe-common/core/hilight-text.h | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/docs/help/in/hilight.in b/docs/help/in/hilight.in index 969b6500..fabbc2ea 100644 --- a/docs/help/in/hilight.in +++ b/docs/help/in/hilight.in @@ -14,6 +14,7 @@ -color: The color the display the highlight in. -actcolor: The color to mark the highlight activity in the statusbar. -level: Matches only on the given message level. + -network: Matches only on the given network. -channels: Matches only on the given channels. -priority: The priority to use when multiple highlights match. diff --git a/src/fe-common/core/hilight-text.c b/src/fe-common/core/hilight-text.c index 0caf2ca2..4b914517 100644 --- a/src/fe-common/core/hilight-text.c +++ b/src/fe-common/core/hilight-text.c @@ -78,7 +78,7 @@ static void hilight_add_config(HILIGHT_REC *rec) 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); - if (rec->tag) iconfig_node_set_str(node,"tag",rec->tag); + if (rec->servertag) iconfig_node_set_str(node, "servertag", rec->servertag); if (rec->channels != NULL && *rec->channels != NULL) { node = config_node_section(node, "channels", NODE_TYPE_LIST); @@ -268,7 +268,8 @@ HILIGHT_REC *hilight_match(SERVER_REC *server, const char *channel, if (!rec->nickmask && hilight_match_level(rec, level) && hilight_match_channel(rec, channel) && - (rec->tag == NULL || (server != NULL && rec->tag != NULL && server->tag !=NULL && strcmp(rec->tag,server->tag) == 0)) && + (rec->servertag == NULL || + (server != NULL && g_ascii_strcasecmp(rec->servertag, server->tag) == 0)) && hilight_match_text(rec, str, match_beg, match_end)) return rec; } @@ -467,7 +468,7 @@ static void read_hilight_config(void) rec->nickmask = config_node_get_bool(node, "mask", FALSE); rec->fullword = config_node_get_bool(node, "fullword", FALSE); rec->regexp = config_node_get_bool(node, "regexp", FALSE); - rec->tag = config_node_get_str(node,"tag",NULL); + rec->servertag = config_node_get_str(node, "servertag", NULL); hilight_init_rec(rec); node = config_node_section(node, "channels", -1); @@ -500,8 +501,8 @@ static void hilight_print(int index, HILIGHT_REC *rec) if (rec->priority != 0) g_string_append_printf(options, "-priority %d ", rec->priority); - if (rec->tag != NULL) - g_string_append_printf(options, "-tag %s ", rec->tag); + if (rec->servertag != NULL) + g_string_append_printf(options, "-network %s ", rec->servertag); if (rec->color != NULL) g_string_append_printf(options, "-color %s ", rec->color); if (rec->act_color != NULL) @@ -540,12 +541,12 @@ static void cmd_hilight_show(void) /* SYNTAX: HILIGHT [-nick | -word | -line] [-mask | -full | -regexp] [-color ] [-actcolor ] [-level ] - [-channels ] */ + [-network ] [-channels ] */ static void cmd_hilight(const char *data) { GHashTable *optlist; HILIGHT_REC *rec; - char *colorarg, *actcolorarg, *levelarg, *priorityarg, *chanarg, *text, *tagarg=NULL; + char *colorarg, *actcolorarg, *levelarg, *priorityarg, *chanarg, *text, *servertag; char **channels; void *free_arg; @@ -565,7 +566,7 @@ static void cmd_hilight(const char *data) priorityarg = g_hash_table_lookup(optlist, "priority"); colorarg = g_hash_table_lookup(optlist, "color"); actcolorarg = g_hash_table_lookup(optlist, "actcolor"); - tagarg = g_hash_table_lookup(optlist,"tag"); + servertag = g_hash_table_lookup(optlist, "network"); if (*text == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS); @@ -617,10 +618,10 @@ static void cmd_hilight(const char *data) if (*actcolorarg != '\0') rec->act_color = g_strdup(actcolorarg); } - if (tagarg != NULL) { - g_free_and_null(rec->tag); - if (*tagarg != '\0') - rec->tag = g_strdup(tagarg); + if (servertag != NULL) { + g_free_and_null(rec->servertag); + if (*servertag != '\0') + rec->servertag = g_strdup(servertag); } hilight_create(rec); @@ -712,7 +713,7 @@ void hilight_text_init(void) command_bind("hilight", NULL, (SIGNAL_FUNC) cmd_hilight); command_bind("dehilight", NULL, (SIGNAL_FUNC) cmd_dehilight); - command_set_options("hilight", "-color -actcolor -level -priority -tag -channels nick word line mask full regexp"); + command_set_options("hilight", "-color -actcolor -level -priority -network -channels nick word line mask full regexp"); } void hilight_text_deinit(void) diff --git a/src/fe-common/core/hilight-text.h b/src/fe-common/core/hilight-text.h index 058efbc6..d54ec4b5 100644 --- a/src/fe-common/core/hilight-text.h +++ b/src/fe-common/core/hilight-text.h @@ -29,7 +29,7 @@ struct _HILIGHT_REC { unsigned int regexp_compiled:1; /* should always be TRUE, unless regexp is invalid */ regex_t preg; #endif - char *tag; + char *servertag; }; extern GSList *hilights;