diff options
-rw-r--r-- | src/plugins/typing/typing-bar-item.c | 13 | ||||
-rw-r--r-- | src/plugins/typing/typing-config.c | 33 | ||||
-rw-r--r-- | src/plugins/typing/typing-config.h | 1 |
3 files changed, 42 insertions, 5 deletions
diff --git a/src/plugins/typing/typing-bar-item.c b/src/plugins/typing/typing-bar-item.c index bfba92b78..a4647e304 100644 --- a/src/plugins/typing/typing-bar-item.c +++ b/src/plugins/typing/typing-bar-item.c @@ -76,7 +76,8 @@ typing_bar_item_typing (const void *pointer, void *data, struct t_hashtable *extra_info) { struct t_hashtable *ptr_nicks; - char **str_nicks_typing, **str_typing; + char **str_nicks_typing, **str_typing, *str_typing_cut; + int max_length; /* make C compiler happy */ (void) pointer; @@ -106,7 +107,15 @@ typing_bar_item_typing (const void *pointer, void *data, weechat_string_dyn_free (str_nicks_typing, 1); - return weechat_string_dyn_free (str_typing, 0); + max_length = weechat_config_integer (typing_config_look_item_max_length); + if (max_length == 0) + return weechat_string_dyn_free (str_typing, 0); + + str_typing_cut = weechat_string_cut (*str_typing, max_length, 1, 1, "…"); + + weechat_string_dyn_free (str_typing, 1); + + return str_typing_cut; } /* diff --git a/src/plugins/typing/typing-config.c b/src/plugins/typing/typing-config.c index bd76e8ba0..a0fda1128 100644 --- a/src/plugins/typing/typing-config.c +++ b/src/plugins/typing/typing-config.c @@ -22,6 +22,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <limits.h> #include "../weechat-plugin.h" #include "typing.h" @@ -40,6 +41,7 @@ struct t_config_option *typing_config_look_delay_purge_typing; struct t_config_option *typing_config_look_delay_set_paused; struct t_config_option *typing_config_look_enabled_nicks; struct t_config_option *typing_config_look_enabled_self; +struct t_config_option *typing_config_look_item_max_length; /* @@ -81,6 +83,22 @@ typing_config_change_enabled (const void *pointer, void *data, } /* + * Callback for changes on options "typing.look.item_max_length". + */ + +void +typing_config_change_item_max_length (const void *pointer, void *data, + struct t_config_option *option) +{ + /* make C compiler happy */ + (void) pointer; + (void) data; + (void) option; + + weechat_bar_item_update (TYPING_BAR_ITEM_NAME); +} + +/* * Initializes typing configuration file. * * Returns: @@ -119,21 +137,21 @@ typing_config_init () "delay_purge_paused", "integer", N_("number of seconds after paused status has been set: if reached, " "the typing status is removed"), - NULL, 1, 3600, "30", NULL, 0, + NULL, 1, INT_MAX, "30", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); typing_config_look_delay_purge_typing = weechat_config_new_option ( typing_config_file, ptr_section, "delay_purge_typing", "integer", N_("number of seconds after typing status has been set: if reached, " "the typing status is removed"), - NULL, 1, 3600, "6", NULL, 0, + NULL, 1, INT_MAX, "6", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); typing_config_look_delay_set_paused = weechat_config_new_option ( typing_config_file, ptr_section, "delay_set_paused", "integer", N_("number of seconds after typing last char: if reached, the typing " "status becomes \"paused\" and no more typing signals are sent"), - NULL, 1, 3600, "10", NULL, 0, + NULL, 1, INT_MAX, "10", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); typing_config_look_enabled_nicks = weechat_config_new_option ( typing_config_file, ptr_section, @@ -152,6 +170,15 @@ typing_config_init () NULL, NULL, NULL, &typing_config_change_enabled, NULL, NULL, NULL, NULL, NULL); + typing_config_look_item_max_length = weechat_config_new_option ( + typing_config_file, ptr_section, + "item_max_length", "integer", + N_("max number of chars displayed in the bar item \"typing\" " + "(0 = do not truncate content)"), + NULL, 0, INT_MAX, "0", NULL, 0, + NULL, NULL, NULL, + &typing_config_change_item_max_length, NULL, NULL, + NULL, NULL, NULL); return 1; } diff --git a/src/plugins/typing/typing-config.h b/src/plugins/typing/typing-config.h index c0da80558..d78c091ce 100644 --- a/src/plugins/typing/typing-config.h +++ b/src/plugins/typing/typing-config.h @@ -27,6 +27,7 @@ extern struct t_config_option *typing_config_look_delay_purge_typing; extern struct t_config_option *typing_config_look_delay_set_paused; extern struct t_config_option *typing_config_look_enabled_nicks; extern struct t_config_option *typing_config_look_enabled_self; +extern struct t_config_option *typing_config_look_item_max_length; extern int typing_config_init (); extern int typing_config_read (); |