mirror of
https://github.com/weechat/weechat.git
synced 2026-07-01 23:36:37 +02:00
fset: fix refresh of options after changing marked options
This commit is contained in:
@@ -237,7 +237,7 @@ fset_command_fset (const void *pointer, void *data,
|
||||
{
|
||||
if (fset_option_count_marked > 0)
|
||||
{
|
||||
fset_option_config_changed_timer = 1;
|
||||
fset_option_enable_timer_config_changed ();
|
||||
num_options = weechat_arraylist_size (fset_options);
|
||||
for (i = 0; i < num_options; i++)
|
||||
{
|
||||
@@ -249,7 +249,7 @@ fset_command_fset (const void *pointer, void *data,
|
||||
fset_option_toggle_value (ptr_fset_option, ptr_option);
|
||||
}
|
||||
}
|
||||
fset_option_config_changed_timer = 0;
|
||||
fset_option_disable_timer_config_changed ();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -267,7 +267,7 @@ fset_command_fset (const void *pointer, void *data,
|
||||
|
||||
if (fset_option_count_marked > 0)
|
||||
{
|
||||
fset_option_config_changed_timer = 1;
|
||||
fset_option_enable_timer_config_changed ();
|
||||
num_options = weechat_arraylist_size (fset_options);
|
||||
for (i = 0; i < num_options; i++)
|
||||
{
|
||||
@@ -279,7 +279,7 @@ fset_command_fset (const void *pointer, void *data,
|
||||
fset_option_add_value (ptr_fset_option, ptr_option, value);
|
||||
}
|
||||
}
|
||||
fset_option_config_changed_timer = 0;
|
||||
fset_option_disable_timer_config_changed ();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -303,7 +303,7 @@ fset_command_fset (const void *pointer, void *data,
|
||||
{
|
||||
if (fset_option_count_marked > 0)
|
||||
{
|
||||
fset_option_config_changed_timer = 1;
|
||||
fset_option_enable_timer_config_changed ();
|
||||
num_options = weechat_arraylist_size (fset_options);
|
||||
for (i = 0; i < num_options; i++)
|
||||
{
|
||||
@@ -315,7 +315,7 @@ fset_command_fset (const void *pointer, void *data,
|
||||
fset_option_reset_value (ptr_fset_option, ptr_option);
|
||||
}
|
||||
}
|
||||
fset_option_config_changed_timer = 0;
|
||||
fset_option_disable_timer_config_changed ();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -329,7 +329,7 @@ fset_command_fset (const void *pointer, void *data,
|
||||
{
|
||||
if (fset_option_count_marked > 0)
|
||||
{
|
||||
fset_option_config_changed_timer = 1;
|
||||
fset_option_enable_timer_config_changed ();
|
||||
num_options = weechat_arraylist_size (fset_options);
|
||||
for (i = 0; i < num_options; i++)
|
||||
{
|
||||
@@ -341,7 +341,7 @@ fset_command_fset (const void *pointer, void *data,
|
||||
fset_option_unset_value (ptr_fset_option, ptr_option);
|
||||
}
|
||||
}
|
||||
fset_option_config_changed_timer = 0;
|
||||
fset_option_disable_timer_config_changed ();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -42,7 +42,8 @@ struct t_hashtable *fset_option_filter_hashtable_extra_vars = NULL;
|
||||
struct t_hashtable *fset_option_filter_hashtable_options = NULL;
|
||||
|
||||
/* refresh */
|
||||
int fset_option_config_changed_timer = 0;
|
||||
int fset_option_config_changed_use_timer = 0;
|
||||
struct t_hashtable *fset_option_timer_options_changed = NULL;
|
||||
struct t_hook *fset_option_timer_hook = NULL;
|
||||
|
||||
/* types */
|
||||
@@ -1153,7 +1154,7 @@ fset_option_config_changed (const char *option_name)
|
||||
full_refresh = 1;
|
||||
}
|
||||
}
|
||||
else if (!ptr_option)
|
||||
else if (ptr_option)
|
||||
{
|
||||
/* option added: get options and refresh the whole buffer */
|
||||
full_refresh = 1;
|
||||
@@ -1162,6 +1163,7 @@ fset_option_config_changed (const char *option_name)
|
||||
if (full_refresh)
|
||||
{
|
||||
fset_option_get_options ();
|
||||
fset_buffer_selected_line = 0;
|
||||
fset_buffer_refresh (1);
|
||||
}
|
||||
else
|
||||
@@ -1184,6 +1186,24 @@ fset_option_config_changed (const char *option_name)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback called by the timer for each option changed.
|
||||
*/
|
||||
|
||||
void
|
||||
fset_option_timer_option_changed_cb (void *data,
|
||||
struct t_hashtable *hashtable,
|
||||
const void *key,
|
||||
const void *value)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) hashtable;
|
||||
(void) value;
|
||||
|
||||
fset_option_config_changed (key);
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for timer after an option is changed.
|
||||
*/
|
||||
@@ -1195,9 +1215,21 @@ fset_option_config_timer_cb (const void *pointer,
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) remaining_calls;
|
||||
|
||||
fset_option_config_changed ((const char *)data);
|
||||
if (fset_option_timer_options_changed)
|
||||
{
|
||||
weechat_hashtable_map (fset_option_timer_options_changed,
|
||||
&fset_option_timer_option_changed_cb,
|
||||
NULL);
|
||||
weechat_hashtable_free (fset_option_timer_options_changed);
|
||||
fset_option_timer_options_changed = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
fset_option_config_changed (NULL);
|
||||
}
|
||||
|
||||
fset_option_timer_hook = NULL;
|
||||
|
||||
@@ -1230,7 +1262,7 @@ fset_option_config_cb (const void *pointer,
|
||||
if (ptr_info && (strcmp (ptr_info, "1") == 0))
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
if (fset_option_config_changed_timer)
|
||||
if (fset_option_config_changed_use_timer)
|
||||
{
|
||||
if (!fset_option_timer_hook)
|
||||
{
|
||||
@@ -1238,6 +1270,8 @@ fset_option_config_cb (const void *pointer,
|
||||
1, 0, 1,
|
||||
&fset_option_config_timer_cb, NULL, NULL);
|
||||
}
|
||||
weechat_hashtable_set (fset_option_timer_options_changed,
|
||||
option, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1247,6 +1281,38 @@ fset_option_config_cb (const void *pointer,
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Enables a timer when options are changed.
|
||||
*/
|
||||
|
||||
void
|
||||
fset_option_enable_timer_config_changed ()
|
||||
{
|
||||
if (fset_option_timer_options_changed)
|
||||
{
|
||||
weechat_hashtable_remove_all (fset_option_timer_options_changed);
|
||||
}
|
||||
else
|
||||
{
|
||||
fset_option_timer_options_changed = weechat_hashtable_new (
|
||||
32,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_POINTER,
|
||||
NULL, NULL);
|
||||
}
|
||||
fset_option_config_changed_use_timer = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Disables timer when options are changed.
|
||||
*/
|
||||
|
||||
void
|
||||
fset_option_disable_timer_config_changed ()
|
||||
{
|
||||
fset_option_config_changed_use_timer = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns hdata for option.
|
||||
*/
|
||||
@@ -1480,4 +1546,9 @@ fset_option_end ()
|
||||
weechat_hashtable_free (fset_option_filter_hashtable_options);
|
||||
fset_option_filter_hashtable_options = NULL;
|
||||
}
|
||||
if (fset_option_timer_options_changed)
|
||||
{
|
||||
weechat_hashtable_free (fset_option_timer_options_changed);
|
||||
fset_option_timer_options_changed = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,6 @@ extern struct t_arraylist *fset_options;
|
||||
extern int fset_option_count_marked;
|
||||
extern struct t_hashtable *fset_option_max_length_field;
|
||||
extern char *fset_option_filter;
|
||||
extern int fset_option_config_changed_timer;
|
||||
extern char *fset_option_type_string[];
|
||||
extern char *fset_option_type_string_short[];
|
||||
extern char *fset_option_type_string_tiny[];
|
||||
@@ -93,6 +92,8 @@ extern int fset_option_config_cb (const void *pointer,
|
||||
void *data,
|
||||
const char *option,
|
||||
const char *value);
|
||||
extern void fset_option_enable_timer_config_changed ();
|
||||
extern void fset_option_disable_timer_config_changed ();
|
||||
extern struct t_hdata *fset_option_hdata_option_cb (const void *pointer,
|
||||
void *data,
|
||||
const char *hdata_name);
|
||||
|
||||
Reference in New Issue
Block a user