1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

fset: add ${description}, add options fset.color.description and fset.color.description_selected

This commit is contained in:
Sébastien Helleu
2017-05-30 21:10:20 +02:00
parent ef19c4ed90
commit 3515134b19
5 changed files with 56 additions and 1 deletions
+16
View File
@@ -278,6 +278,22 @@ fset_buffer_display_line (int y, struct t_fset_option *fset_option)
weechat_hashtable_set (fset_buffer_hashtable_extra_vars,
"max", str_field);
/* description */
ptr_field = weechat_hdata_string (fset_hdata_fset_option,
fset_option, "description");
snprintf (str_field, sizeof (str_field), "%s", ptr_field);
weechat_hashtable_set (fset_buffer_hashtable_extra_vars,
"__description", str_field);
snprintf (str_field, sizeof (str_field),
"%s%s",
weechat_color (weechat_config_string (fset_config_color_description[selected_line])),
ptr_field);
weechat_hashtable_set (fset_buffer_hashtable_extra_vars,
"_description", str_field);
fset_buffer_fills_field (str_field, sizeof (str_field), "description", 64);
weechat_hashtable_set (fset_buffer_hashtable_extra_vars,
"description", str_field);
/* set other variables depending on the value */
weechat_hashtable_set (fset_buffer_hashtable_extra_vars,
"value_undef",
+17
View File
@@ -44,6 +44,7 @@ struct t_config_option *fset_config_format_option_current;
/* fset config, color section */
struct t_config_option *fset_config_color_default_value[2];
struct t_config_option *fset_config_color_description[2];
struct t_config_option *fset_config_color_max[2];
struct t_config_option *fset_config_color_min[2];
struct t_config_option *fset_config_color_name[2];
@@ -237,6 +238,22 @@ fset_config_init ()
NULL, NULL, NULL,
&fset_config_change_color, NULL, NULL,
NULL, NULL, NULL);
fset_config_color_description[0] = weechat_config_new_option (
fset_config_file, ptr_section,
"description", "color",
N_("color for description"),
NULL, 0, 0, "default", NULL, 0,
NULL, NULL, NULL,
&fset_config_change_color, NULL, NULL,
NULL, NULL, NULL);
fset_config_color_description[1] = weechat_config_new_option (
fset_config_file, ptr_section,
"description_selected", "color",
N_("color for description on the selected line"),
NULL, 0, 0, "white", NULL, 0,
NULL, NULL, NULL,
&fset_config_change_color, NULL, NULL,
NULL, NULL, NULL);
fset_config_color_max[0] = weechat_config_new_option (
fset_config_file, ptr_section,
"max", "color",
+1
View File
@@ -32,6 +32,7 @@ extern struct t_config_option *fset_config_format_option;
extern struct t_config_option *fset_config_format_option_current;
extern struct t_config_option *fset_config_color_default_value[2];
extern struct t_config_option *fset_config_color_description[2];
extern struct t_config_option *fset_config_color_max[2];
extern struct t_config_option *fset_config_color_min[2];
extern struct t_config_option *fset_config_color_name[2];
+21 -1
View File
@@ -258,7 +258,7 @@ void
fset_option_set_values (struct t_fset_option *fset_option,
struct t_config_option *option)
{
const char *ptr_parent_name, *ptr_type;
const char *ptr_parent_name, *ptr_type, *ptr_description;
void *ptr_default_value, *ptr_value;
struct t_config_option *ptr_parent_option;
int *ptr_min, *ptr_max;
@@ -349,6 +349,15 @@ fset_option_set_values (struct t_fset_option *fset_option,
ptr_max = weechat_config_option_get_pointer (option, "max");
snprintf (str_value, sizeof (str_value), "%d", *ptr_max);
fset_option->max = strdup (str_value);
/* description */
if (fset_option->description)
{
free (fset_option->description);
fset_option->description = NULL;
}
ptr_description = weechat_config_option_get_string (option, "description");
fset_option->description = strdup ((ptr_description) ? ptr_description : "");
}
/*
@@ -439,6 +448,10 @@ fset_option_set_max_length_fields_option (struct t_fset_option *fset_option)
/* max */
fset_option_set_max_length_field (
"max", weechat_strlen_screen (fset_option->max));
/* description */
fset_option_set_max_length_field (
"description", weechat_strlen_screen (fset_option->description));
}
/*
@@ -512,6 +525,7 @@ fset_option_alloc (struct t_config_file *config_file,
new_fset_option->parent_value = NULL;
new_fset_option->min = NULL;
new_fset_option->max = NULL;
new_fset_option->description = NULL;
fset_option_set_values (new_fset_option, option);
if (!fset_option_match_filters (ptr_config_name, ptr_section_name,
new_fset_option))
@@ -636,6 +650,8 @@ fset_option_free (struct t_fset_option *fset_option)
free (fset_option->min);
if (fset_option->max)
free (fset_option->max);
if (fset_option->description)
free (fset_option->description);
free (fset_option);
}
@@ -837,6 +853,7 @@ fset_option_hdata_option_cb (const void *pointer, void *data,
WEECHAT_HDATA_VAR(struct t_fset_option, parent_value, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_fset_option, min, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_fset_option, max, STRING, 0, NULL, NULL);
WEECHAT_HDATA_VAR(struct t_fset_option, description, STRING, 0, NULL, NULL);
}
return hdata;
}
@@ -878,6 +895,8 @@ fset_option_add_to_infolist (struct t_infolist *infolist,
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "max", fset_option->max))
return 0;
if (!weechat_infolist_new_var_string (ptr_item, "description", fset_option->description))
return 0;
return 1;
}
@@ -906,6 +925,7 @@ fset_option_print_log ()
weechat_log_printf (" parent_value. . . . . : '%s'", ptr_fset_option->parent_value);
weechat_log_printf (" min . . . . . . . . . : '%s'", ptr_fset_option->min);
weechat_log_printf (" max . . . . . . . . . : '%s'", ptr_fset_option->max);
weechat_log_printf (" description . . . . . : '%s'", ptr_fset_option->description);
}
}
+1
View File
@@ -32,6 +32,7 @@ struct t_fset_option
char *parent_value; /* parent option value */
char *min; /* min value */
char *max; /* max value */
char *description; /* option description */
struct t_fset_option *prev_option; /* link to previous option */
struct t_fset_option *next_option; /* link to next option */
};