From ee7c280d7e8acd5ec255da6e12959d812b5897f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20G=C3=B6rs?= Date: Sun, 2 Nov 2014 18:01:33 +0100 Subject: [PATCH] core: add bar item "mouse_status", new options weechat.look.item_mouse_status and weechat.color.status_mouse --- src/core/wee-config.c | 14 ++++++++++++++ src/core/wee-config.h | 2 ++ src/gui/gui-bar-item.c | 41 ++++++++++++++++++++++++++++++++++++++++- src/gui/gui-bar-item.h | 1 + 4 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/core/wee-config.c b/src/core/wee-config.c index 78a5cefd5..60d3359ef 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -135,6 +135,7 @@ struct t_config_option *config_look_input_undo_max; struct t_config_option *config_look_item_time_format; struct t_config_option *config_look_item_buffer_filter; struct t_config_option *config_look_item_buffer_zoom; +struct t_config_option *config_look_item_mouse_status; struct t_config_option *config_look_jump_current_to_previous_buffer; struct t_config_option *config_look_jump_previous_buffer_when_closing; struct t_config_option *config_look_jump_smart_back_to_buffer; @@ -229,6 +230,7 @@ struct t_config_option *config_color_status_data_msg; struct t_config_option *config_color_status_data_other; struct t_config_option *config_color_status_data_private; struct t_config_option *config_color_status_filter; +struct t_config_option *config_color_status_mouse; struct t_config_option *config_color_status_name; struct t_config_option *config_color_status_name_ssl; struct t_config_option *config_color_status_nicklist_count; @@ -2437,6 +2439,12 @@ config_weechat_init_options () N_("string used to show zoom on merged buffer " "(bar item \"buffer_zoom\")"), NULL, 0, 0, "!", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL); + config_look_item_mouse_status = config_file_new_option ( + weechat_config_file, ptr_section, + "item_mouse_status", "string", + N_("string used to show if mouse is enabled/disabled" + "(bar item \"mouse_status\")"), + NULL, 0, 0, "M", NULL, 0, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL); config_look_jump_current_to_previous_buffer = config_file_new_option ( weechat_config_file, ptr_section, "jump_current_to_previous_buffer", "boolean", @@ -3104,6 +3112,12 @@ config_weechat_init_options () N_("text color for filter indicator in status bar"), NULL, -1, 0, "green", NULL, 0, NULL, NULL, &config_change_color, NULL, NULL, NULL); + config_color_status_mouse = config_file_new_option ( + weechat_config_file, ptr_section, + "status_mouse", "color", + N_("text color for mouse indicator in status bar"), + NULL, -1, 0, "green", NULL, 0, + NULL, NULL, &config_change_color, NULL, NULL, NULL); config_color_status_name = config_file_new_option ( weechat_config_file, ptr_section, "status_name", "color", diff --git a/src/core/wee-config.h b/src/core/wee-config.h index 5d1128bf1..181d24129 100644 --- a/src/core/wee-config.h +++ b/src/core/wee-config.h @@ -172,6 +172,7 @@ extern struct t_config_option *config_look_input_undo_max; extern struct t_config_option *config_look_item_time_format; extern struct t_config_option *config_look_item_buffer_filter; extern struct t_config_option *config_look_item_buffer_zoom; +extern struct t_config_option *config_look_item_mouse_status; extern struct t_config_option *config_look_jump_current_to_previous_buffer; extern struct t_config_option *config_look_jump_previous_buffer_when_closing; extern struct t_config_option *config_look_jump_smart_back_to_buffer; @@ -264,6 +265,7 @@ extern struct t_config_option *config_color_status_data_msg; extern struct t_config_option *config_color_status_data_other; extern struct t_config_option *config_color_status_data_private; extern struct t_config_option *config_color_status_filter; +extern struct t_config_option *config_color_status_mouse; extern struct t_config_option *config_color_status_name; extern struct t_config_option *config_color_status_name_ssl; extern struct t_config_option *config_color_status_nicklist_count; diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c index 9fddb9658..ed78db4bc 100644 --- a/src/gui/gui-bar-item.c +++ b/src/gui/gui-bar-item.c @@ -53,6 +53,7 @@ #include "gui-line.h" #include "gui-nicklist.h" #include "gui-window.h" +#include "gui-mouse.h" struct t_gui_bar_item *gui_bar_items = NULL; /* first bar item */ @@ -62,7 +63,7 @@ char *gui_bar_item_names[GUI_BAR_NUM_ITEMS] = "buffer_count", "buffer_last_number", "buffer_plugin", "buffer_number", "buffer_name", "buffer_short_name", "buffer_modes", "buffer_filter", "buffer_zoom", "buffer_nicklist_count", "scroll", "hotlist", "completion", - "buffer_title", "buffer_nicklist", "window_number" + "buffer_title", "buffer_nicklist", "window_number", "mouse_status" }; char *gui_bar_items_default_for_bars[][2] = { { GUI_BAR_DEFAULT_NAME_INPUT, @@ -1725,6 +1726,35 @@ gui_bar_item_default_window_number (void *data, struct t_gui_bar_item *item, return strdup (str_number); } +/* + * Default item for mouse status. + */ + +char * +gui_bar_item_default_mouse_status (void *data, struct t_gui_bar_item *item, + struct t_gui_window *window, + struct t_gui_buffer *buffer, + struct t_hashtable *extra_info) +{ + char str_mouse[512]; + + /* make C compiler happy */ + (void) data; + (void) item; + (void) window; + (void) extra_info; + + if (!buffer || !gui_mouse_enabled) + return NULL; + + snprintf (str_mouse, sizeof (str_mouse), + "%s%s", + gui_color_get_custom (gui_color_get_name (CONFIG_COLOR(config_color_status_mouse))), + CONFIG_STRING(config_look_item_mouse_status)); + + return strdup (str_mouse); +} + /* * Focus on nicklist. */ @@ -2134,6 +2164,15 @@ gui_bar_item_init () gui_bar_item_names[GUI_BAR_ITEM_WINDOW_NUMBER]); gui_bar_item_hook_signal ("window_closed", gui_bar_item_names[GUI_BAR_ITEM_WINDOW_NUMBER]); + + /* mouse status */ + gui_bar_item_new (NULL, + gui_bar_item_names[GUI_BAR_ITEM_MOUSE_STATUS], + &gui_bar_item_default_mouse_status, NULL); + gui_bar_item_hook_signal ("mouse_enabled", + gui_bar_item_names[GUI_BAR_ITEM_MOUSE_STATUS]); + gui_bar_item_hook_signal ("mouse_disabled", + gui_bar_item_names[GUI_BAR_ITEM_MOUSE_STATUS]); } /* diff --git a/src/gui/gui-bar-item.h b/src/gui/gui-bar-item.h index 1ea670009..005a799c6 100644 --- a/src/gui/gui-bar-item.h +++ b/src/gui/gui-bar-item.h @@ -43,6 +43,7 @@ enum t_gui_bar_item_weechat GUI_BAR_ITEM_BUFFER_TITLE, GUI_BAR_ITEM_BUFFER_NICKLIST, GUI_BAR_ITEM_WINDOW_NUMBER, + GUI_BAR_ITEM_MOUSE_STATUS, /* number of bar items */ GUI_BAR_NUM_ITEMS, };