core: add flag "input_get_empty" in buffer
The default value is 0 (legacy behavior). When it is set to 1, an empty input (just by pressing Return with nothing in input) is sent to the input callback, which receives an empty string.
This commit is contained in:
parent
8c554d88c9
commit
db0bdc2ac6
@ -20,6 +20,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
|
||||
|
||||
New features::
|
||||
|
||||
* core: add flag "input_get_empty" in buffer
|
||||
* core: add signals "buffer_filters_enabled" and "buffer_filters_disabled"
|
||||
* core: support loading of plugins from path in environment variable "WEECHAT_EXTRA_LIBDIR" (issue #971, issue #979)
|
||||
* alias: add infolist "alias_default" (list of default aliases)
|
||||
|
@ -534,6 +534,7 @@ _input_callback_ (pointer) +
|
||||
_input_callback_pointer_ (pointer) +
|
||||
_input_callback_data_ (pointer) +
|
||||
_input_get_unknown_commands_ (integer) +
|
||||
_input_get_empty_ (integer) +
|
||||
_input_buffer_ (string) +
|
||||
_input_buffer_alloc_ (integer) +
|
||||
_input_buffer_size_ (integer) +
|
||||
|
@ -534,6 +534,7 @@ _input_callback_ (pointer) +
|
||||
_input_callback_pointer_ (pointer) +
|
||||
_input_callback_data_ (pointer) +
|
||||
_input_get_unknown_commands_ (integer) +
|
||||
_input_get_empty_ (integer) +
|
||||
_input_buffer_ (string) +
|
||||
_input_buffer_alloc_ (integer) +
|
||||
_input_buffer_size_ (integer) +
|
||||
|
@ -11801,6 +11801,7 @@ Arguments:
|
||||
** _input_: 1 if input is enabled, otherwise 0
|
||||
** _input_get_unknown_commands_: 1 if unknown commands are sent to input
|
||||
callback, otherwise 0
|
||||
** _input_get_empty_: 1 if empty input is sent to input callback, otherwise 0
|
||||
** _input_size_: input size (in bytes)
|
||||
** _input_length_: input length (number of chars)
|
||||
** _input_pos_: cursor position in buffer input
|
||||
@ -12099,6 +12100,9 @@ Properties:
|
||||
get unknown commands, for example if user type "/unknowncmd", buffer will
|
||||
receive it (no error about unknown command).
|
||||
|
||||
| input_get_empty | "0" or "1" |
|
||||
"0" to disable empty input on this buffer (default behavior), "1" to get empty input.
|
||||
|
||||
| localvar_set_xxx | any string |
|
||||
Set new value for local variable _xxx_ (variable is created if it does not
|
||||
exist).
|
||||
|
@ -534,6 +534,7 @@ _input_callback_ (pointer) +
|
||||
_input_callback_pointer_ (pointer) +
|
||||
_input_callback_data_ (pointer) +
|
||||
_input_get_unknown_commands_ (integer) +
|
||||
_input_get_empty_ (integer) +
|
||||
_input_buffer_ (string) +
|
||||
_input_buffer_alloc_ (integer) +
|
||||
_input_buffer_size_ (integer) +
|
||||
|
@ -12048,6 +12048,8 @@ Paramètres :
|
||||
** _input_ : 1 si la zone de saisie est activée, sinon 0
|
||||
** _input_get_unknown_commands_ : 1 si les commandes inconnues sont envoyées
|
||||
à la fonction de rappel "input", sinon 0
|
||||
** _input_get_empty_ : 1 si une entrée vide est envoyée à la fonction de rappel
|
||||
"input", sinon 0
|
||||
** _input_size_ : taille de la zone de saisie (en octets)
|
||||
** _input_length_ : longueur de la zone de saisie (nombre de caractères)
|
||||
** _input_pos_ : position du curseur dans la zone de saisie
|
||||
@ -12359,6 +12361,10 @@ Propriétés :
|
||||
l'utilisateur tape "/commandeinconnue", le tampon le recevra (pas d'erreur
|
||||
sur la commande inconnue).
|
||||
|
||||
| input_get_empty | "0" ou "1" |
|
||||
"0" pour désactiver l'entrée vide sur ce tampon (comportement par défaut),
|
||||
"1" pour recevoir l'entrée vide.
|
||||
|
||||
| localvar_set_xxx | toute chaîne |
|
||||
Change la valeur de la variable locale _xxx_ (la variable est créée si elle
|
||||
n'existe pas).
|
||||
|
@ -534,6 +534,7 @@ _input_callback_ (pointer) +
|
||||
_input_callback_pointer_ (pointer) +
|
||||
_input_callback_data_ (pointer) +
|
||||
_input_get_unknown_commands_ (integer) +
|
||||
_input_get_empty_ (integer) +
|
||||
_input_buffer_ (string) +
|
||||
_input_buffer_alloc_ (integer) +
|
||||
_input_buffer_size_ (integer) +
|
||||
|
@ -12260,6 +12260,8 @@ Argomenti:
|
||||
** _input_: 1 se l'input è abilitato, altrimenti 0
|
||||
** _input_get_unknown_commands_: 1 se i comandi sconosciuti vengono inviati
|
||||
alla callback di input, altrimenti 0
|
||||
// TRANSLATION MISSING
|
||||
** _input_get_empty_: 1 if empty input is sent to input callback, otherwise 0
|
||||
** _input_size_: dimensione per l'input (in byte)
|
||||
** _input_length_: lunghezza dell'input (numero di caratteri)
|
||||
** _input_pos_: posizione del cursore nell'input del buffer
|
||||
@ -12585,6 +12587,10 @@ Properties:
|
||||
digita "/unknowncmd", verrà ricevuto dal buffer (nessun errore riguardo il
|
||||
comando sconosciuto).
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| input_get_empty | "0" oppure "1" |
|
||||
"0" to disable empty input on this buffer (default behavior), "1" to get empty input.
|
||||
|
||||
| localvar_set_xxx | qualsiasi stringa |
|
||||
Imposta il nuovo valore per la variabile locale _xxx_ (la variabile verrà
|
||||
creata se non esiste).
|
||||
|
@ -534,6 +534,7 @@ _input_callback_ (pointer) +
|
||||
_input_callback_pointer_ (pointer) +
|
||||
_input_callback_data_ (pointer) +
|
||||
_input_get_unknown_commands_ (integer) +
|
||||
_input_get_empty_ (integer) +
|
||||
_input_buffer_ (string) +
|
||||
_input_buffer_alloc_ (integer) +
|
||||
_input_buffer_size_ (integer) +
|
||||
|
@ -11805,6 +11805,8 @@ int weechat_buffer_get_integer (struct t_gui_buffer *buffer,
|
||||
** _input_: 入力可能な場合は 1、そうでない場合は 0
|
||||
** _input_get_unknown_commands_: 未定義のコマンドを入力コールバックに送信する場合は
|
||||
1、そうでない場合は 0
|
||||
// TRANSLATION MISSING
|
||||
** _input_get_empty_: 1 if empty input is sent to input callback, otherwise 0
|
||||
** _input_size_: 入力サイズ (バイト単位)
|
||||
** _input_length_: 入力長 (文字数)
|
||||
** _input_pos_: バッファ入力におけるカーソル位置
|
||||
@ -12101,6 +12103,10 @@ void weechat_buffer_set (struct t_gui_buffer *buffer, const char *property,
|
||||
(デフォルト)、未定義のコマンドを受け入れる場合は "1"、例えばユーザが "/unknowncmd"
|
||||
を入力した場合、バッファはこれを受け入れる (未定義のコマンドに対するエラーを出さない)
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| input_get_empty | "0" または "1" |
|
||||
"0" to disable empty input on this buffer (default behavior), "1" to get empty input.
|
||||
|
||||
| localvar_set_xxx | 任意の文字列 |
|
||||
ローカル変数 _xxx_ の新しい値を設定
|
||||
(存在しない変数の場合は変数を作成する)
|
||||
|
@ -534,6 +534,7 @@ _input_callback_ (pointer) +
|
||||
_input_callback_pointer_ (pointer) +
|
||||
_input_callback_data_ (pointer) +
|
||||
_input_get_unknown_commands_ (integer) +
|
||||
_input_get_empty_ (integer) +
|
||||
_input_buffer_ (string) +
|
||||
_input_buffer_alloc_ (integer) +
|
||||
_input_buffer_size_ (integer) +
|
||||
|
@ -194,8 +194,7 @@ input_data (struct t_gui_buffer *buffer, const char *data)
|
||||
|
||||
rc = WEECHAT_RC_OK;
|
||||
|
||||
if (!buffer || !gui_buffer_valid (buffer)
|
||||
|| !data || !data[0] || (data[0] == '\r') || (data[0] == '\n'))
|
||||
if (!buffer || !gui_buffer_valid (buffer) || !data)
|
||||
{
|
||||
return WEECHAT_RC_ERROR;
|
||||
}
|
||||
@ -213,12 +212,12 @@ input_data (struct t_gui_buffer *buffer, const char *data)
|
||||
data);
|
||||
|
||||
/* data was dropped? */
|
||||
if (new_data && !new_data[0])
|
||||
if (data[0] && new_data && !new_data[0])
|
||||
goto end;
|
||||
|
||||
first_command = 1;
|
||||
ptr_data = (new_data) ? new_data : data;
|
||||
while (ptr_data && ptr_data[0])
|
||||
while (ptr_data)
|
||||
{
|
||||
/*
|
||||
* if the buffer pointer is not valid any more (or if it's another
|
||||
|
@ -509,6 +509,9 @@ upgrade_weechat_read_buffer (struct t_infolist *infolist)
|
||||
ptr_buffer->input = infolist_integer (infolist, "input");
|
||||
ptr_buffer->input_get_unknown_commands =
|
||||
infolist_integer (infolist, "input_get_unknown_commands");
|
||||
ptr_buffer->input_get_empty =
|
||||
infolist_integer (infolist, "input_get_empty");
|
||||
|
||||
if (infolist_integer (infolist, "input_buffer_alloc") > 0)
|
||||
{
|
||||
ptr_buffer->input_buffer =
|
||||
|
@ -84,9 +84,9 @@ char *gui_buffer_properties_get_integer[] =
|
||||
"nicklist_case_sensitive", "nicklist_max_length", "nicklist_display_groups",
|
||||
"nicklist_count", "nicklist_groups_count", "nicklist_nicks_count",
|
||||
"nicklist_visible_count", "input", "input_get_unknown_commands",
|
||||
"input_size", "input_length", "input_pos", "input_1st_display",
|
||||
"num_history", "text_search", "text_search_exact", "text_search_regex",
|
||||
"text_search_where", "text_search_found",
|
||||
"input_get_empty", "input_size", "input_length", "input_pos",
|
||||
"input_1st_display", "num_history", "text_search", "text_search_exact",
|
||||
"text_search_regex", "text_search_where", "text_search_found",
|
||||
NULL
|
||||
};
|
||||
char *gui_buffer_properties_get_string[] =
|
||||
@ -107,7 +107,7 @@ char *gui_buffer_properties_set[] =
|
||||
"highlight_words_del", "highlight_regex", "highlight_tags_restrict",
|
||||
"highlight_tags", "hotlist_max_level_nicks", "hotlist_max_level_nicks_add",
|
||||
"hotlist_max_level_nicks_del", "input", "input_pos",
|
||||
"input_get_unknown_commands",
|
||||
"input_get_unknown_commands", "input_get_empty",
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -661,6 +661,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
|
||||
new_buffer->input_callback_pointer = input_callback_pointer;
|
||||
new_buffer->input_callback_data = input_callback_data;
|
||||
new_buffer->input_get_unknown_commands = 0;
|
||||
new_buffer->input_get_empty = 0;
|
||||
gui_buffer_input_buffer_init (new_buffer);
|
||||
|
||||
/* undo for input */
|
||||
@ -1063,6 +1064,8 @@ gui_buffer_get_integer (struct t_gui_buffer *buffer, const char *property)
|
||||
return buffer->input;
|
||||
else if (string_strcasecmp (property, "input_get_unknown_commands") == 0)
|
||||
return buffer->input_get_unknown_commands;
|
||||
else if (string_strcasecmp (property, "input_get_empty") == 0)
|
||||
return buffer->input_get_empty;
|
||||
else if (string_strcasecmp (property, "input_size") == 0)
|
||||
return buffer->input_buffer_size;
|
||||
else if (string_strcasecmp (property, "input_length") == 0)
|
||||
@ -1760,6 +1763,20 @@ gui_buffer_set_input_get_unknown_commands (struct t_gui_buffer *buffer,
|
||||
buffer->input_get_unknown_commands = (input_get_unknown_commands) ? 1 : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets flag "input_get_empty" for a buffer.
|
||||
*/
|
||||
|
||||
void
|
||||
gui_buffer_set_input_get_empty (struct t_gui_buffer *buffer,
|
||||
int input_get_empty)
|
||||
{
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
buffer->input_get_empty = (input_get_empty) ? 1 : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets unread marker for a buffer.
|
||||
*/
|
||||
@ -2025,6 +2042,13 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
|
||||
if (error && !error[0])
|
||||
gui_buffer_set_input_get_unknown_commands (buffer, number);
|
||||
}
|
||||
else if (string_strcasecmp (property, "input_get_empty") == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (value, &error, 10);
|
||||
if (error && !error[0])
|
||||
gui_buffer_set_input_get_empty (buffer, number);
|
||||
}
|
||||
else if (string_strncasecmp (property, "localvar_set_", 13) == 0)
|
||||
{
|
||||
if (value)
|
||||
@ -4125,6 +4149,7 @@ gui_buffer_hdata_buffer_cb (const void *pointer, void *data,
|
||||
HDATA_VAR(struct t_gui_buffer, input_callback_pointer, POINTER, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_gui_buffer, input_callback_data, POINTER, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_gui_buffer, input_get_unknown_commands, INTEGER, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_gui_buffer, input_get_empty, INTEGER, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_gui_buffer, input_buffer, STRING, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_gui_buffer, input_buffer_alloc, INTEGER, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_gui_buffer, input_buffer_size, INTEGER, 0, NULL, NULL);
|
||||
@ -4321,6 +4346,8 @@ gui_buffer_add_to_infolist (struct t_infolist *infolist,
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "input_get_unknown_commands", buffer->input_get_unknown_commands))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "input_get_empty", buffer->input_get_empty))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "input_buffer", buffer->input_buffer))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "input_buffer_alloc", buffer->input_buffer_alloc))
|
||||
@ -4532,6 +4559,7 @@ gui_buffer_print_log ()
|
||||
log_printf (" input_callback_pointer. : 0x%lx", ptr_buffer->input_callback_pointer);
|
||||
log_printf (" input_callback_data . . : 0x%lx", ptr_buffer->input_callback_data);
|
||||
log_printf (" input_get_unknown_cmd . : %d", ptr_buffer->input_get_unknown_commands);
|
||||
log_printf (" input_get_empty . . . . : %d", ptr_buffer->input_get_empty);
|
||||
log_printf (" input_buffer. . . . . . : '%s'", ptr_buffer->input_buffer);
|
||||
log_printf (" input_buffer_alloc. . . : %d", ptr_buffer->input_buffer_alloc);
|
||||
log_printf (" input_buffer_size . . . : %d", ptr_buffer->input_buffer_size);
|
||||
|
@ -154,6 +154,8 @@ struct t_gui_buffer
|
||||
/* to this buffer */
|
||||
int input_get_unknown_commands; /* 1 if unknown commands are sent to */
|
||||
/* input_callback */
|
||||
int input_get_empty; /* 1 if empty input is sent to */
|
||||
/* input_callback */
|
||||
char *input_buffer; /* input buffer */
|
||||
int input_buffer_alloc; /* input buffer: allocated size */
|
||||
int input_buffer_size; /* buffer size in bytes */
|
||||
|
@ -412,7 +412,8 @@ gui_input_return (struct t_gui_buffer *buffer)
|
||||
gui_window_bare_display_toggle (NULL);
|
||||
}
|
||||
|
||||
if (buffer->input && (buffer->input_buffer_size > 0))
|
||||
if (buffer->input
|
||||
&& (buffer->input_get_empty || (buffer->input_buffer_size > 0)))
|
||||
{
|
||||
buffer->input_buffer[buffer->input_buffer_size] = '\0';
|
||||
command = strdup (buffer->input_buffer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user