diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2022-11-08 20:34:04 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2022-11-08 20:34:04 +0100 |
commit | 24665ae87855bdcd016c53fe048c940212938b69 (patch) | |
tree | 9adbc49ddbebd69551702f77abd5b3d3a7f3b4e8 /src/gui | |
parent | 2e4a033f0d7f58c87ac61e559bda6e206e5128e0 (diff) | |
download | weechat-24665ae87855bdcd016c53fe048c940212938b69.zip |
core: add signals "buffer_user_{input|closing}_xxx" for buffers created with `/buffer add` (closes #1848)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui-buffer.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index 4fbe8ee0e..16fab2c71 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -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); @@ -916,6 +928,29 @@ gui_buffer_user_input_cb (const void *pointer, void *data, } /* + * 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. * * Returns pointer to new buffer, NULL if error. @@ -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); |