diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-command.c | 13 | ||||
-rw-r--r-- | src/core/wee-config.c | 24 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-mouse.c | 2 |
3 files changed, 33 insertions, 6 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 162f8d9fc..6c29e4d22 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -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" diff --git a/src/core/wee-config.c b/src/core/wee-config.c index 2a5a8f866..de3d32e3d 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -312,6 +312,26 @@ config_change_buffer_content (void *data, struct t_config_option *option) } /* + * 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", diff --git a/src/gui/curses/gui-curses-mouse.c b/src/gui/curses/gui-curses-mouse.c index 6ca1cff9e..d37cef5ad 100644 --- a/src/gui/curses/gui-curses-mouse.c +++ b/src/gui/curses/gui-curses-mouse.c @@ -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); } /* |