diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-06-17 08:59:42 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-06-26 21:35:49 +0200 |
commit | 54dd19da92a2200e226232a78c901719f96d332c (patch) | |
tree | be6542540c3cce4dfd5c3b976e15e6728fece995 /src/plugins | |
parent | bc4294e297810c7b419d000d9e5bd8e3f7505820 (diff) | |
download | weechat-54dd19da92a2200e226232a78c901719f96d332c.zip |
api: add info "buffer" (closes #1962)
This info returns a pointer buffer with its full name.
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/plugin-api-info.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/plugins/plugin-api-info.c b/src/plugins/plugin-api-info.c index cde37b597..86443bf22 100644 --- a/src/plugins/plugin-api-info.c +++ b/src/plugins/plugin-api-info.c @@ -470,6 +470,34 @@ plugin_api_info_auto_load_scripts_cb (const void *pointer, void *data, } /* + * Returns WeeChat info "buffer". + */ + +char * +plugin_api_info_buffer_cb (const void *pointer, void *data, + const char *info_name, + const char *arguments) +{ + struct t_gui_buffer *ptr_buffer; + char value[64]; + + /* make C compiler happy */ + (void) pointer; + (void) data; + (void) info_name; + + if (!arguments || !arguments[0]) + return NULL; + + ptr_buffer = gui_buffer_search_by_full_name (arguments); + if (!ptr_buffer) + return NULL; + + snprintf (value, sizeof (value), "0x%lx", (unsigned long)ptr_buffer); + return strdup (value); +} + +/* * Returns WeeChat info "charset_terminal". */ @@ -1993,6 +2021,10 @@ plugin_api_info_init () "0 if the auto-load has been disabled by the user " "(option \"-s\" or \"--no-script\")"), NULL, &plugin_api_info_auto_load_scripts_cb, NULL, NULL); + hook_info (NULL, "buffer", + N_("buffer pointer"), + N_("buffer full name"), + &plugin_api_info_buffer_cb, NULL, NULL); hook_info (NULL, "charset_terminal", N_("terminal charset"), NULL, &plugin_api_info_charset_terminal_cb, NULL, NULL); |