fset: add ${file}, ${section}, ${option}, add color options
This commit is contained in:
parent
384b3adf9e
commit
d71524c582
@ -1824,7 +1824,11 @@ config_file_option_get_string (struct t_config_option *option,
|
||||
if (!option || !property)
|
||||
return NULL;
|
||||
|
||||
if (string_strcasecmp (property, "name") == 0)
|
||||
if (string_strcasecmp (property, "config_name") == 0)
|
||||
return option->config_file->name;
|
||||
else if (string_strcasecmp (property, "section_name") == 0)
|
||||
return option->section->name;
|
||||
else if (string_strcasecmp (property, "name") == 0)
|
||||
return option->name;
|
||||
else if (string_strcasecmp (property, "parent_name") == 0)
|
||||
return option->parent_name;
|
||||
|
@ -140,6 +140,66 @@ fset_buffer_display_line (int y, struct t_fset_option *fset_option)
|
||||
weechat_hashtable_set (fset_buffer_hashtable_pointers,
|
||||
"fset_option", fset_option);
|
||||
|
||||
/* file */
|
||||
ptr_field = weechat_hdata_string (fset_hdata_fset_option,
|
||||
fset_option, "file");
|
||||
snprintf (str_field, sizeof (str_field), "%s", ptr_field);
|
||||
weechat_hashtable_set (fset_buffer_hashtable_extra_vars,
|
||||
"__file", str_field);
|
||||
snprintf (str_field, sizeof (str_field),
|
||||
"%s%s",
|
||||
weechat_color (
|
||||
weechat_config_string (
|
||||
(value_changed) ?
|
||||
fset_config_color_name_changed[selected_line] :
|
||||
fset_config_color_name[selected_line])),
|
||||
(ptr_field) ? ptr_field : "");
|
||||
weechat_hashtable_set (fset_buffer_hashtable_extra_vars,
|
||||
"_file", str_field);
|
||||
fset_buffer_fills_field (str_field, sizeof (str_field), "file", 16);
|
||||
weechat_hashtable_set (fset_buffer_hashtable_extra_vars,
|
||||
"file", str_field);
|
||||
|
||||
/* section */
|
||||
ptr_field = weechat_hdata_string (fset_hdata_fset_option,
|
||||
fset_option, "section");
|
||||
snprintf (str_field, sizeof (str_field), "%s", ptr_field);
|
||||
weechat_hashtable_set (fset_buffer_hashtable_extra_vars,
|
||||
"__section", str_field);
|
||||
snprintf (str_field, sizeof (str_field),
|
||||
"%s%s",
|
||||
weechat_color (
|
||||
weechat_config_string (
|
||||
(value_changed) ?
|
||||
fset_config_color_name_changed[selected_line] :
|
||||
fset_config_color_name[selected_line])),
|
||||
(ptr_field) ? ptr_field : "");
|
||||
weechat_hashtable_set (fset_buffer_hashtable_extra_vars,
|
||||
"_section", str_field);
|
||||
fset_buffer_fills_field (str_field, sizeof (str_field), "section", 16);
|
||||
weechat_hashtable_set (fset_buffer_hashtable_extra_vars,
|
||||
"section", str_field);
|
||||
|
||||
/* option */
|
||||
ptr_field = weechat_hdata_string (fset_hdata_fset_option,
|
||||
fset_option, "option");
|
||||
snprintf (str_field, sizeof (str_field), "%s", ptr_field);
|
||||
weechat_hashtable_set (fset_buffer_hashtable_extra_vars,
|
||||
"__option", str_field);
|
||||
snprintf (str_field, sizeof (str_field),
|
||||
"%s%s",
|
||||
weechat_color (
|
||||
weechat_config_string (
|
||||
(value_changed) ?
|
||||
fset_config_color_name_changed[selected_line] :
|
||||
fset_config_color_name[selected_line])),
|
||||
(ptr_field) ? ptr_field : "");
|
||||
weechat_hashtable_set (fset_buffer_hashtable_extra_vars,
|
||||
"_option", str_field);
|
||||
fset_buffer_fills_field (str_field, sizeof (str_field), "option", 16);
|
||||
weechat_hashtable_set (fset_buffer_hashtable_extra_vars,
|
||||
"option", str_field);
|
||||
|
||||
/* name */
|
||||
ptr_field = weechat_hdata_string (fset_hdata_fset_option,
|
||||
fset_option, "name");
|
||||
|
@ -514,10 +514,11 @@ fset_command_init ()
|
||||
" =xxx show only options with \"xxx\" in value\n"
|
||||
" ==xxx show only options with exact value \"xxx\"\n"
|
||||
" c:xxx show only options matching the evaluated "
|
||||
"condition \"xxx\", using following variables: name, parent_name, "
|
||||
"type (bool/int/str/col), default_value, default_value_undef, "
|
||||
"value, value_undef, value_changed, parent_value, min, max, "
|
||||
"description, description_en, string_values\n"
|
||||
"condition \"xxx\", using following variables: file, section, "
|
||||
"option, name, parent_name, type (bool/int/str/col), "
|
||||
"default_value, default_value_undef, value, value_undef, "
|
||||
"value_changed, parent_value, min, max, description, "
|
||||
"description_en, string_values\n"
|
||||
" s:x,y sort options by fields x,y "
|
||||
"(see /help fset.look.sort)\n"
|
||||
" s: reset sort to its default value "
|
||||
@ -531,7 +532,11 @@ fset_command_init ()
|
||||
"\n"
|
||||
"The following variables can be used in these options:\n"
|
||||
" - option data, with color and padded by spaces on the right:\n"
|
||||
" - ${name}: option name\n"
|
||||
" - ${file}: configuration file (for example \"weechat\" or "
|
||||
"\"irc\")\n"
|
||||
" - ${section}: section\n"
|
||||
" - ${option}: option name\n"
|
||||
" - ${name}: full option name (file.section.option)\n"
|
||||
" - ${parent_name}: parent option name\n"
|
||||
" - ${type}: option type (translated)\n"
|
||||
" - ${type_en}: option type (in English)\n"
|
||||
@ -586,7 +591,7 @@ fset_command_init ()
|
||||
" show all values which contain \"red\":\n"
|
||||
" /fset =red\n"
|
||||
" show all integer options in irc plugin:\n"
|
||||
" /fset c:${name} =~ ^irc.* && ${type} == int"),
|
||||
" /fset c:${file} == irc && ${type} == int"),
|
||||
"-bar"
|
||||
" || -toggle_bar"
|
||||
" || -refresh"
|
||||
|
@ -54,6 +54,8 @@ struct t_config_option *fset_config_format_option_current;
|
||||
|
||||
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_file[2];
|
||||
struct t_config_option *fset_config_color_file_changed[2];
|
||||
struct t_config_option *fset_config_color_help_default_value;
|
||||
struct t_config_option *fset_config_color_help_description;
|
||||
struct t_config_option *fset_config_color_help_name;
|
||||
@ -64,10 +66,14 @@ 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];
|
||||
struct t_config_option *fset_config_color_name_changed[2];
|
||||
struct t_config_option *fset_config_color_option[2];
|
||||
struct t_config_option *fset_config_color_option_changed[2];
|
||||
struct t_config_option *fset_config_color_parent_name[2];
|
||||
struct t_config_option *fset_config_color_parent_value[2];
|
||||
struct t_config_option *fset_config_color_quotes[2];
|
||||
struct t_config_option *fset_config_color_quotes_changed[2];
|
||||
struct t_config_option *fset_config_color_section[2];
|
||||
struct t_config_option *fset_config_color_section_changed[2];
|
||||
struct t_config_option *fset_config_color_string_values[2];
|
||||
struct t_config_option *fset_config_color_type[2];
|
||||
struct t_config_option *fset_config_color_unmarked[2];
|
||||
@ -436,6 +442,38 @@ fset_config_init ()
|
||||
NULL, NULL, NULL,
|
||||
&fset_config_change_color_cb, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
fset_config_color_file[0] = weechat_config_new_option (
|
||||
fset_config_file, ptr_section,
|
||||
"file", "color",
|
||||
N_("color for file"),
|
||||
NULL, 0, 0, "default", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&fset_config_change_color_cb, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
fset_config_color_file[1] = weechat_config_new_option (
|
||||
fset_config_file, ptr_section,
|
||||
"file_selected", "color",
|
||||
N_("color for file on the selected line"),
|
||||
NULL, 0, 0, "white", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&fset_config_change_color_cb, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
fset_config_color_file_changed[0] = weechat_config_new_option (
|
||||
fset_config_file, ptr_section,
|
||||
"file_changed", "color",
|
||||
N_("color for file if value is changed"),
|
||||
NULL, 0, 0, "brown", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&fset_config_change_color_cb, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
fset_config_color_file_changed[1] = weechat_config_new_option (
|
||||
fset_config_file, ptr_section,
|
||||
"file_changed_selected", "color",
|
||||
N_("color for file if value is changed on the selected line"),
|
||||
NULL, 0, 0, "yellow", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&fset_config_change_color_cb, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
fset_config_color_help_default_value = weechat_config_new_option (
|
||||
fset_config_file, ptr_section,
|
||||
"help_default_value", "color",
|
||||
@ -556,6 +594,38 @@ fset_config_init ()
|
||||
NULL, NULL, NULL,
|
||||
&fset_config_change_color_cb, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
fset_config_color_option[0] = weechat_config_new_option (
|
||||
fset_config_file, ptr_section,
|
||||
"option", "color",
|
||||
N_("color for option"),
|
||||
NULL, 0, 0, "default", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&fset_config_change_color_cb, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
fset_config_color_option[1] = weechat_config_new_option (
|
||||
fset_config_file, ptr_section,
|
||||
"option_selected", "color",
|
||||
N_("color for option on the selected line"),
|
||||
NULL, 0, 0, "white", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&fset_config_change_color_cb, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
fset_config_color_option_changed[0] = weechat_config_new_option (
|
||||
fset_config_file, ptr_section,
|
||||
"option_changed", "color",
|
||||
N_("color for option if value is changed"),
|
||||
NULL, 0, 0, "brown", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&fset_config_change_color_cb, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
fset_config_color_option_changed[1] = weechat_config_new_option (
|
||||
fset_config_file, ptr_section,
|
||||
"option_changed_selected", "color",
|
||||
N_("color for option if value is changed on the selected line"),
|
||||
NULL, 0, 0, "yellow", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&fset_config_change_color_cb, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
fset_config_color_parent_name[0] = weechat_config_new_option (
|
||||
fset_config_file, ptr_section,
|
||||
"parent_name", "color",
|
||||
@ -621,6 +691,38 @@ fset_config_init ()
|
||||
NULL, NULL, NULL,
|
||||
&fset_config_change_color_cb, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
fset_config_color_section[0] = weechat_config_new_option (
|
||||
fset_config_file, ptr_section,
|
||||
"section", "color",
|
||||
N_("color for section"),
|
||||
NULL, 0, 0, "default", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&fset_config_change_color_cb, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
fset_config_color_section[1] = weechat_config_new_option (
|
||||
fset_config_file, ptr_section,
|
||||
"section_selected", "color",
|
||||
N_("color for section on the selected line"),
|
||||
NULL, 0, 0, "white", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&fset_config_change_color_cb, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
fset_config_color_section_changed[0] = weechat_config_new_option (
|
||||
fset_config_file, ptr_section,
|
||||
"section_changed", "color",
|
||||
N_("color for section if value is changed"),
|
||||
NULL, 0, 0, "brown", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&fset_config_change_color_cb, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
fset_config_color_section_changed[1] = weechat_config_new_option (
|
||||
fset_config_file, ptr_section,
|
||||
"section_changed_selected", "color",
|
||||
N_("color for section if value is changed on the selected line"),
|
||||
NULL, 0, 0, "yellow", NULL, 0,
|
||||
NULL, NULL, NULL,
|
||||
&fset_config_change_color_cb, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
fset_config_color_string_values[0] = weechat_config_new_option (
|
||||
fset_config_file, ptr_section,
|
||||
"string_values", "color",
|
||||
|
@ -40,6 +40,8 @@ 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_file[2];
|
||||
extern struct t_config_option *fset_config_color_file_changed[2];
|
||||
extern struct t_config_option *fset_config_color_help_default_value;
|
||||
extern struct t_config_option *fset_config_color_help_description;
|
||||
extern struct t_config_option *fset_config_color_help_name;
|
||||
@ -50,10 +52,14 @@ 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];
|
||||
extern struct t_config_option *fset_config_color_name_changed[2];
|
||||
extern struct t_config_option *fset_config_color_option[2];
|
||||
extern struct t_config_option *fset_config_color_option_changed[2];
|
||||
extern struct t_config_option *fset_config_color_parent_name[2];
|
||||
extern struct t_config_option *fset_config_color_parent_value[2];
|
||||
extern struct t_config_option *fset_config_color_quotes[2];
|
||||
extern struct t_config_option *fset_config_color_quotes_changed[2];
|
||||
extern struct t_config_option *fset_config_color_section[2];
|
||||
extern struct t_config_option *fset_config_color_section_changed[2];
|
||||
extern struct t_config_option *fset_config_color_string_values[2];
|
||||
extern struct t_config_option *fset_config_color_type[2];
|
||||
extern struct t_config_option *fset_config_color_unmarked[2];
|
||||
|
@ -223,15 +223,14 @@ fset_option_string_match (const char *string, const char *mask)
|
||||
*/
|
||||
|
||||
int
|
||||
fset_option_match_filters (const char *config_name, const char *section_name,
|
||||
struct t_fset_option *fset_option)
|
||||
fset_option_match_filters (struct t_fset_option *fset_option)
|
||||
{
|
||||
int length, match;
|
||||
char *result;
|
||||
|
||||
if (!weechat_config_boolean (fset_config_look_show_plugin_description)
|
||||
&& (strcmp (config_name, "plugins") == 0)
|
||||
&& (strcmp (section_name, "desc") == 0))
|
||||
&& (strcmp (fset_option->file, "plugins") == 0)
|
||||
&& (strcmp (fset_option->section, "desc") == 0))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -243,6 +242,12 @@ fset_option_match_filters (const char *config_name, const char *section_name,
|
||||
{
|
||||
weechat_hashtable_set (fset_option_filter_hashtable_pointers,
|
||||
"fset_option", fset_option);
|
||||
weechat_hashtable_set (fset_option_filter_hashtable_extra_vars,
|
||||
"file", fset_option->file);
|
||||
weechat_hashtable_set (fset_option_filter_hashtable_extra_vars,
|
||||
"section", fset_option->section);
|
||||
weechat_hashtable_set (fset_option_filter_hashtable_extra_vars,
|
||||
"option", fset_option->option);
|
||||
weechat_hashtable_set (fset_option_filter_hashtable_extra_vars,
|
||||
"name", fset_option->name);
|
||||
weechat_hashtable_set (fset_option_filter_hashtable_extra_vars,
|
||||
@ -288,7 +293,8 @@ fset_option_match_filters (const char *config_name, const char *section_name,
|
||||
else if (strncmp (fset_option_filter, "f:", 2) == 0)
|
||||
{
|
||||
/* filter by config name */
|
||||
return (weechat_strcasecmp (config_name, fset_option_filter + 2) == 0) ? 1 : 0;
|
||||
return (weechat_strcasecmp (fset_option->file,
|
||||
fset_option_filter + 2) == 0) ? 1 : 0;
|
||||
}
|
||||
else if (strncmp (fset_option_filter, "t:", 2) == 0)
|
||||
{
|
||||
@ -306,7 +312,7 @@ fset_option_match_filters (const char *config_name, const char *section_name,
|
||||
}
|
||||
else if (strncmp (fset_option_filter, "d==", 3) == 0)
|
||||
{
|
||||
/* filter by modified values, exact value */
|
||||
/* filter by modified values (on exact value) */
|
||||
if (!fset_option_value_is_changed (fset_option))
|
||||
return 0;
|
||||
return (weechat_strcasecmp (
|
||||
@ -315,7 +321,7 @@ fset_option_match_filters (const char *config_name, const char *section_name,
|
||||
}
|
||||
else if (strncmp (fset_option_filter, "d=", 2) == 0)
|
||||
{
|
||||
/* filter by modified values, value */
|
||||
/* filter by modified values (on value) */
|
||||
if (!fset_option_value_is_changed (fset_option))
|
||||
return 0;
|
||||
return (fset_option_string_match (
|
||||
@ -324,7 +330,7 @@ fset_option_match_filters (const char *config_name, const char *section_name,
|
||||
}
|
||||
else if (strncmp (fset_option_filter, "d:", 2) == 0)
|
||||
{
|
||||
/* filter by modified values */
|
||||
/* filter by modified values (on name) */
|
||||
if (!fset_option_value_is_changed (fset_option))
|
||||
return 0;
|
||||
return fset_option_string_match (fset_option->name,
|
||||
@ -364,13 +370,39 @@ void
|
||||
fset_option_set_values (struct t_fset_option *fset_option,
|
||||
struct t_config_option *option)
|
||||
{
|
||||
const char *ptr_config_name, *ptr_section_name, *ptr_option_name;
|
||||
const char *ptr_parent_name, *ptr_description;
|
||||
const char **ptr_string_values;
|
||||
void *ptr_default_value, *ptr_value;
|
||||
struct t_config_option *ptr_parent_option;
|
||||
int *ptr_type, *ptr_min, *ptr_max;
|
||||
int length, *ptr_type, *ptr_min, *ptr_max;
|
||||
char str_value[64];
|
||||
|
||||
/* file */
|
||||
ptr_config_name = weechat_config_option_get_string (option, "config_name");
|
||||
fset_option->file = strdup (ptr_config_name);
|
||||
|
||||
/* section */
|
||||
ptr_section_name = weechat_config_option_get_string (option, "section_name");
|
||||
fset_option->section = strdup (ptr_section_name);
|
||||
|
||||
/* option */
|
||||
ptr_option_name = weechat_config_option_get_string (option, "name");
|
||||
fset_option->option = strdup (ptr_option_name);
|
||||
|
||||
/* name */
|
||||
length = strlen (ptr_config_name) + 1 +
|
||||
strlen (ptr_section_name) + 1 +
|
||||
strlen (ptr_option_name) + 1;
|
||||
fset_option->name = malloc (length);
|
||||
if (fset_option->name)
|
||||
{
|
||||
snprintf (fset_option->name, length, "%s.%s.%s",
|
||||
ptr_config_name,
|
||||
ptr_section_name,
|
||||
ptr_option_name);
|
||||
}
|
||||
|
||||
/* parent name */
|
||||
if (fset_option->parent_name)
|
||||
{
|
||||
@ -502,6 +534,18 @@ fset_option_set_max_length_fields_option (struct t_fset_option *fset_option)
|
||||
{
|
||||
int length, length_value, length_parent_value;
|
||||
|
||||
/* file */
|
||||
fset_option_set_max_length_field (
|
||||
"file", weechat_strlen_screen (fset_option->file));
|
||||
|
||||
/* section */
|
||||
fset_option_set_max_length_field (
|
||||
"section", weechat_strlen_screen (fset_option->section));
|
||||
|
||||
/* option */
|
||||
fset_option_set_max_length_field (
|
||||
"option", weechat_strlen_screen (fset_option->option));
|
||||
|
||||
/* name */
|
||||
fset_option_set_max_length_field (
|
||||
"name", weechat_strlen_screen (fset_option->name));
|
||||
@ -642,66 +686,40 @@ fset_option_set_max_length_fields_all ()
|
||||
*/
|
||||
|
||||
struct t_fset_option *
|
||||
fset_option_alloc (struct t_config_file *config_file,
|
||||
struct t_config_section *section,
|
||||
struct t_config_option *option)
|
||||
fset_option_alloc (struct t_config_option *option)
|
||||
{
|
||||
struct t_fset_option *new_fset_option;
|
||||
const char *ptr_config_name, *ptr_section_name, *ptr_option_name;
|
||||
char *option_name;
|
||||
int length;
|
||||
|
||||
new_fset_option = NULL;
|
||||
option_name = NULL;
|
||||
|
||||
ptr_config_name = weechat_hdata_string (fset_hdata_config_file,
|
||||
config_file, "name");
|
||||
ptr_section_name = weechat_hdata_string (fset_hdata_config_section,
|
||||
section, "name");
|
||||
ptr_option_name = weechat_hdata_string (fset_hdata_config_option,
|
||||
option, "name");
|
||||
length = strlen (ptr_config_name) + 1 +
|
||||
strlen (ptr_section_name) + 1 +
|
||||
strlen (ptr_option_name) + 1;
|
||||
option_name = malloc (length);
|
||||
if (!option_name)
|
||||
goto end;
|
||||
snprintf (option_name, length, "%s.%s.%s",
|
||||
ptr_config_name,
|
||||
ptr_section_name,
|
||||
ptr_option_name);
|
||||
|
||||
new_fset_option = malloc (sizeof (*new_fset_option));
|
||||
if (new_fset_option)
|
||||
if (!new_fset_option)
|
||||
return NULL;
|
||||
|
||||
new_fset_option->file = NULL;
|
||||
new_fset_option->section = NULL;
|
||||
new_fset_option->option = NULL;
|
||||
new_fset_option->name = NULL;
|
||||
new_fset_option->parent_name = NULL;
|
||||
new_fset_option->type = 0;
|
||||
new_fset_option->default_value = NULL;
|
||||
new_fset_option->value = NULL;
|
||||
new_fset_option->parent_value = NULL;
|
||||
new_fset_option->min = NULL;
|
||||
new_fset_option->max = NULL;
|
||||
new_fset_option->description = NULL;
|
||||
new_fset_option->string_values = NULL;
|
||||
new_fset_option->marked = 0;
|
||||
|
||||
fset_option_set_values (new_fset_option, option);
|
||||
|
||||
/* check if option match filters (if not, ignore it) */
|
||||
if (!fset_option_match_filters (new_fset_option))
|
||||
{
|
||||
new_fset_option->name = option_name;
|
||||
new_fset_option->parent_name = NULL;
|
||||
new_fset_option->type = 0;
|
||||
new_fset_option->default_value = NULL;
|
||||
new_fset_option->value = NULL;
|
||||
new_fset_option->parent_value = NULL;
|
||||
new_fset_option->min = NULL;
|
||||
new_fset_option->max = NULL;
|
||||
new_fset_option->description = NULL;
|
||||
new_fset_option->string_values = NULL;
|
||||
new_fset_option->marked = 0;
|
||||
fset_option_set_values (new_fset_option, option);
|
||||
if (!fset_option_match_filters (ptr_config_name, ptr_section_name,
|
||||
new_fset_option))
|
||||
{
|
||||
/* option does not match filters, ignore it */
|
||||
fset_option_free (new_fset_option);
|
||||
new_fset_option = NULL;
|
||||
goto end;
|
||||
}
|
||||
fset_option_set_max_length_fields_option (new_fset_option);
|
||||
}
|
||||
else
|
||||
{
|
||||
free (option_name);
|
||||
fset_option_free (new_fset_option);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
end:
|
||||
fset_option_set_max_length_fields_option (new_fset_option);
|
||||
|
||||
return new_fset_option;
|
||||
}
|
||||
|
||||
@ -759,6 +777,12 @@ fset_option_free (struct t_fset_option *fset_option)
|
||||
if (!fset_option)
|
||||
return;
|
||||
|
||||
if (fset_option->file)
|
||||
free (fset_option->file);
|
||||
if (fset_option->section)
|
||||
free (fset_option->section);
|
||||
if (fset_option->option)
|
||||
free (fset_option->option);
|
||||
if (fset_option->name)
|
||||
free (fset_option->name);
|
||||
if (fset_option->parent_name)
|
||||
@ -876,8 +900,7 @@ fset_option_get_options ()
|
||||
ptr_section, "options");
|
||||
while (ptr_option)
|
||||
{
|
||||
new_fset_option = fset_option_alloc (ptr_config, ptr_section,
|
||||
ptr_option);
|
||||
new_fset_option = fset_option_alloc (ptr_option);
|
||||
if (new_fset_option)
|
||||
weechat_arraylist_add (fset_options, new_fset_option);
|
||||
ptr_option = weechat_hdata_move (fset_hdata_config_option,
|
||||
@ -1250,6 +1273,9 @@ fset_option_hdata_option_cb (const void *pointer, void *data,
|
||||
hdata = weechat_hdata_new (hdata_name, NULL, NULL, 0, 0, NULL, NULL);
|
||||
if (hdata)
|
||||
{
|
||||
WEECHAT_HDATA_VAR(struct t_fset_option, file, STRING, 0, NULL, NULL);
|
||||
WEECHAT_HDATA_VAR(struct t_fset_option, section, STRING, 0, NULL, NULL);
|
||||
WEECHAT_HDATA_VAR(struct t_fset_option, option, STRING, 0, NULL, NULL);
|
||||
WEECHAT_HDATA_VAR(struct t_fset_option, name, STRING, 0, NULL, NULL);
|
||||
WEECHAT_HDATA_VAR(struct t_fset_option, parent_name, STRING, 0, NULL, NULL);
|
||||
WEECHAT_HDATA_VAR(struct t_fset_option, type, INTEGER, 0, NULL, NULL);
|
||||
@ -1286,6 +1312,12 @@ fset_option_add_to_infolist (struct t_infolist *infolist,
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "file", fset_option->file))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "section", fset_option->section))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "option", fset_option->option))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "name", fset_option->name))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "parent_name", fset_option->parent_name))
|
||||
@ -1336,6 +1368,9 @@ fset_option_print_log ()
|
||||
continue;
|
||||
weechat_log_printf ("");
|
||||
weechat_log_printf ("[fset option (addr:0x%lx)]", ptr_fset_option);
|
||||
weechat_log_printf (" file. . . . . . . . . : '%s'", ptr_fset_option->file);
|
||||
weechat_log_printf (" section . . . . . . . : '%s'", ptr_fset_option->section);
|
||||
weechat_log_printf (" option. . . . . . . . : '%s'", ptr_fset_option->option);
|
||||
weechat_log_printf (" name. . . . . . . . . : '%s'", ptr_fset_option->name);
|
||||
weechat_log_printf (" parent_name . . . . . : '%s'", ptr_fset_option->parent_name);
|
||||
weechat_log_printf (" type. . . . . . . . . : %d ('%s')",
|
||||
|
@ -34,7 +34,10 @@ enum t_fset_option_type
|
||||
|
||||
struct t_fset_option
|
||||
{
|
||||
char *name; /* option name */
|
||||
char *file; /* config file name (eg: "weechat")*/
|
||||
char *section; /* section name (eg: "look") */
|
||||
char *option; /* option name */
|
||||
char *name; /* option full name: file.sect.opt */
|
||||
char *parent_name; /* parent option name */
|
||||
enum t_fset_option_type type; /* option type */
|
||||
char *default_value; /* option default value */
|
||||
|
Loading…
x
Reference in New Issue
Block a user