mirror of
https://github.com/weechat/weechat.git
synced 2026-07-09 03:03:12 +02:00
core: change mouse state when option weechat.look.mouse is changed
This commit is contained in:
+11
-2
@@ -3126,9 +3126,15 @@ command_mouse_timer_cb (void *data, int remaining_calls)
|
||||
(void) remaining_calls;
|
||||
|
||||
if (gui_mouse_enabled)
|
||||
{
|
||||
gui_mouse_disable ();
|
||||
config_file_option_set (config_look_mouse, "0", 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_mouse_enable ();
|
||||
config_file_option_set (config_look_mouse, "1", 1);
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
@@ -3172,6 +3178,7 @@ COMMAND_CALLBACK(mouse)
|
||||
if (string_strcasecmp (argv[1], "enable") == 0)
|
||||
{
|
||||
gui_mouse_enable ();
|
||||
config_file_option_set (config_look_mouse, "1", 1);
|
||||
gui_chat_printf (NULL, _("Mouse enabled"));
|
||||
if (argc > 2)
|
||||
command_mouse_timer (argv[2]);
|
||||
@@ -3182,6 +3189,7 @@ COMMAND_CALLBACK(mouse)
|
||||
if (string_strcasecmp (argv[1], "disable") == 0)
|
||||
{
|
||||
gui_mouse_disable ();
|
||||
config_file_option_set (config_look_mouse, "0", 1);
|
||||
gui_chat_printf (NULL, _("Mouse disabled"));
|
||||
if (argc > 2)
|
||||
command_mouse_timer (argv[2]);
|
||||
@@ -3194,11 +3202,13 @@ COMMAND_CALLBACK(mouse)
|
||||
if (gui_mouse_enabled)
|
||||
{
|
||||
gui_mouse_disable ();
|
||||
config_file_option_set (config_look_mouse, "0", 1);
|
||||
gui_chat_printf (NULL, _("Mouse disabled"));
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_mouse_enable ();
|
||||
config_file_option_set (config_look_mouse, "1", 1);
|
||||
gui_chat_printf (NULL, _("Mouse enabled"));
|
||||
}
|
||||
if (argc > 2)
|
||||
@@ -5865,8 +5875,7 @@ command_init ()
|
||||
" toggle: toggle mouse\n"
|
||||
" delay: delay (in seconds) after which initial mouse "
|
||||
"state is restored (useful to temporarily disable mouse)\n\n"
|
||||
"To enable/disable mouse at startup, use:\n"
|
||||
" /set weechat.look.mouse on/off\n\n"
|
||||
"The mouse state is saved in option \"weechat.look.mouse\".\n\n"
|
||||
"Examples:\n"
|
||||
" enable mouse:\n"
|
||||
" /mouse enable\n"
|
||||
|
||||
+22
-2
@@ -311,6 +311,26 @@ config_change_buffer_content (void *data, struct t_config_option *option)
|
||||
gui_current_window->refresh_needed = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* config_change_mouse: called when mouse state is changed
|
||||
*/
|
||||
|
||||
void
|
||||
config_change_mouse (void *data, struct t_config_option *option)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
if (gui_ok)
|
||||
{
|
||||
if (CONFIG_BOOLEAN(config_look_mouse))
|
||||
gui_mouse_enable ();
|
||||
else
|
||||
gui_mouse_disable ();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* config_change_buffer_notify_default: called when buffer default notify changes
|
||||
*/
|
||||
@@ -1915,8 +1935,8 @@ config_weechat_init_options ()
|
||||
config_look_mouse = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
"mouse", "boolean",
|
||||
N_("enable mouse support at startup (to enable it now, see /help mouse)"),
|
||||
NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
N_("enable mouse support"),
|
||||
NULL, 0, 0, "off", NULL, 0, NULL, NULL, &config_change_mouse, NULL, NULL, NULL);
|
||||
config_look_mouse_timer_delay = config_file_new_option (
|
||||
weechat_config_file, ptr_section,
|
||||
"mouse_timer_delay", "integer",
|
||||
|
||||
@@ -90,7 +90,6 @@ gui_mouse_enable ()
|
||||
{
|
||||
gui_mouse_enabled = 1;
|
||||
fprintf (stderr, "\033[?1005h\033[?1000h\033[?1002h");
|
||||
config_file_option_set (config_look_mouse, "1", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -102,7 +101,6 @@ gui_mouse_disable ()
|
||||
{
|
||||
gui_mouse_enabled = 0;
|
||||
fprintf (stderr, "\033[?1002l\033[?1000l\033[?1005l");
|
||||
config_file_option_set (config_look_mouse, "0", 1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user