1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-09 03:03:12 +02:00

core: add signals "buffer_user_{input|closing}_xxx" for buffers created with /buffer add (closes #1848)

This commit is contained in:
Sébastien Helleu
2022-11-08 20:34:04 +01:00
parent 2e4a033f0d
commit 24665ae878
8 changed files with 234 additions and 12 deletions
+36 -1
View File
@@ -903,10 +903,22 @@ int
gui_buffer_user_input_cb (const void *pointer, void *data,
struct t_gui_buffer *buffer, const char *input_data)
{
char str_signal[1024];
int rc;
/* make C compiler happy */
(void) pointer;
(void) data;
snprintf (str_signal, sizeof (str_signal),
"buffer_user_input_%s",
buffer->name);
rc = hook_signal_send (str_signal,
WEECHAT_HOOK_SIGNAL_STRING, (void *)input_data);
if (rc == WEECHAT_RC_OK_EAT)
return WEECHAT_RC_OK;
if (string_strcasecmp (input_data, "q") == 0)
{
gui_buffer_close (buffer);
@@ -915,6 +927,29 @@ gui_buffer_user_input_cb (const void *pointer, void *data,
return WEECHAT_RC_OK;
}
/*
* Close callback for user buffers.
*/
int
gui_buffer_user_close_cb (const void *pointer, void *data,
struct t_gui_buffer *buffer)
{
char str_signal[1024];
/* make C compiler happy */
(void) pointer;
(void) data;
snprintf (str_signal, sizeof (str_signal),
"buffer_user_closing_%s",
buffer->name);
hook_signal_send (str_signal,
WEECHAT_HOOK_SIGNAL_STRING, NULL);
return WEECHAT_RC_OK;
}
/*
* Creates a new user buffer in current window.
*
@@ -944,7 +979,7 @@ gui_buffer_new_user (const char *name, enum t_gui_buffer_type buffer_type)
new_buffer = gui_buffer_new_props (NULL, name, properties,
&gui_buffer_user_input_cb, NULL, NULL,
NULL, NULL, NULL);
&gui_buffer_user_close_cb, NULL, NULL);
if (properties)
hashtable_free (properties);