From 64b52da4064dffb4de83a8f95c43f6ee4eca9cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 4 Jul 2021 14:02:15 +0200 Subject: typing: add option typing.look.input_min_chars --- src/plugins/typing/typing-config.c | 7 +++++++ src/plugins/typing/typing-config.h | 1 + src/plugins/typing/typing.c | 6 ++++-- 3 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/typing/typing-config.c b/src/plugins/typing/typing-config.c index a0fda1128..368d8582a 100644 --- a/src/plugins/typing/typing-config.c +++ b/src/plugins/typing/typing-config.c @@ -41,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_input_min_chars; struct t_config_option *typing_config_look_item_max_length; @@ -170,6 +171,12 @@ typing_config_init () NULL, NULL, NULL, &typing_config_change_enabled, NULL, NULL, NULL, NULL, NULL); + typing_config_look_input_min_chars = weechat_config_new_option ( + typing_config_file, ptr_section, + "input_min_chars", "integer", + N_("min number of chars in message to trigger send of typing signals"), + NULL, 1, INT_MAX, "4", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); typing_config_look_item_max_length = weechat_config_new_option ( typing_config_file, ptr_section, "item_max_length", "integer", diff --git a/src/plugins/typing/typing-config.h b/src/plugins/typing/typing-config.h index d78c091ce..d714145e5 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_input_min_chars; extern struct t_config_option *typing_config_look_item_max_length; extern int typing_config_init (); diff --git a/src/plugins/typing/typing.c b/src/plugins/typing/typing.c index 003863228..d27fce1d7 100644 --- a/src/plugins/typing/typing.c +++ b/src/plugins/typing/typing.c @@ -102,7 +102,7 @@ typing_input_text_changed_signal_cb (const void *pointer, void *data, const char *signal, const char *type_data, void *signal_data) { - int text_search; + int text_search, input_valid; const char *ptr_input, *ptr_input_for_buffer; struct t_gui_buffer *ptr_buffer; struct t_typing_status *ptr_typing_status; @@ -121,8 +121,10 @@ typing_input_text_changed_signal_cb (const void *pointer, void *data, return WEECHAT_RC_OK; ptr_input = weechat_buffer_get_string (ptr_buffer, "input"); + input_valid = (ptr_input && ptr_input[0]) ? + weechat_utf8_strlen (ptr_input) >= weechat_config_integer (typing_config_look_input_min_chars) : 0; - if (ptr_input && ptr_input[0]) + if (input_valid) { /* input is a command? ignore it */ ptr_input_for_buffer = weechat_string_input_for_buffer (ptr_input); -- cgit debian/1.2.3+git2.25.1-1-2-gaceb0