Add -comment attribute to hilights

Add -comment attribute to hilights to assist those with many hilights
in tracking what they are used for.  Useful for channels ops or network
staff that often have many hilights set.
This commit is contained in:
John R. Dennison 2022-11-21 00:07:17 -06:00 committed by Ailin Nemui
commit ab45564d36
2 changed files with 20 additions and 4 deletions

View file

@ -81,6 +81,8 @@ static void hilight_add_config(HILIGHT_REC *rec)
if (rec->regexp) iconfig_node_set_bool(node, "regexp", TRUE);
if (rec->case_sensitive) iconfig_node_set_bool(node, "matchcase", TRUE);
if (rec->servertag) iconfig_node_set_str(node, "servertag", rec->servertag);
if (rec->comment)
iconfig_node_set_str(node, "comment", rec->comment);
if (rec->channels != NULL && *rec->channels != NULL) {
node = iconfig_node_section(node, "channels", NODE_TYPE_LIST);
@ -107,6 +109,7 @@ static void hilight_destroy(HILIGHT_REC *rec)
g_free_not_null(rec->color);
g_free_not_null(rec->act_color);
g_free_not_null(rec->servertag);
g_free_not_null(rec->comment);
g_free(rec->text);
g_free(rec);
}
@ -505,7 +508,7 @@ static void read_hilight_config(void)
CONFIG_NODE *node;
HILIGHT_REC *rec;
GSList *tmp;
char *text, *color, *servertag;
char *text, *color, *servertag, *comment;
hilights_destroy_all();
@ -551,6 +554,8 @@ static void read_hilight_config(void)
servertag = config_node_get_str(node, "servertag", NULL);
rec->servertag = servertag == NULL || *servertag == '\0' ? NULL :
g_strdup(servertag);
comment = config_node_get_str(node, "comment", NULL);
rec->comment = comment == NULL || *comment == '\0' ? NULL : g_strdup(comment);
hilight_init_rec(rec);
node = iconfig_node_section(node, "channels", -1);
@ -588,6 +593,8 @@ static void hilight_print(int index, HILIGHT_REC *rec)
g_string_append_printf(options, "-priority %d ", rec->priority);
if (rec->servertag != NULL)
g_string_append_printf(options, "-network %s ", rec->servertag);
if (rec->comment != NULL)
g_string_append_printf(options, "-comment %s ", rec->comment);
if (rec->color != NULL)
g_string_append_printf(options, "-color %s ", rec->color);
if (rec->act_color != NULL)
@ -626,12 +633,13 @@ static void cmd_hilight_show(void)
/* SYNTAX: HILIGHT [-nick | -word | -line] [-mask | -full | -matchcase | -regexp]
[-color <color>] [-actcolor <color>] [-level <level>] [-priority <number>]
[-network <network>] [-channels <channels>] <text> */
[-network <network>] [-channels <channels>] [-comment <comment>] <text> */
static void cmd_hilight(const char *data)
{
GHashTable *optlist;
HILIGHT_REC *rec;
char *colorarg, *actcolorarg, *levelarg, *priorityarg, *chanarg, *text, *servertag;
char *colorarg, *actcolorarg, *levelarg, *priorityarg, *chanarg, *text, *servertag,
*comment;
char **channels;
void *free_arg;
@ -652,6 +660,7 @@ static void cmd_hilight(const char *data)
colorarg = g_hash_table_lookup(optlist, "color");
actcolorarg = g_hash_table_lookup(optlist, "actcolor");
servertag = g_hash_table_lookup(optlist, "network");
comment = g_hash_table_lookup(optlist, "comment");
if (*text == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
@ -709,6 +718,11 @@ static void cmd_hilight(const char *data)
if (*servertag != '\0')
rec->servertag = g_strdup(servertag);
}
if (comment != NULL) {
g_free_and_null(rec->comment);
if (*comment != '\0')
rec->comment = g_strdup(comment);
}
hilight_create(rec);
@ -802,7 +816,8 @@ 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 -network -channels nick word line mask full regexp matchcase");
command_set_options("hilight", "-color -actcolor -level -priority -network -channels "
"-comment nick word line mask full regexp matchcase");
}
void hilight_text_deinit(void)

View file

@ -23,6 +23,7 @@ struct _HILIGHT_REC {
unsigned int case_sensitive:1;/* `text' must match case */
Regex *preg;
char *servertag;
char *comment;
};
extern GSList *hilights;