1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 07:16:37 +02:00

exec: create buffer with function buffer_new_props (issue #1942)

With this function, buffer properties are set when the buffer is created and
can be read immediately by other plugins/scripts, for example in a callback of
signal "buffer_opened".
This commit is contained in:
Sébastien Helleu
2023-05-20 16:22:18 +02:00
parent 3ca3ea32fd
commit b1759ab25a
+26 -12
View File
@@ -148,6 +148,7 @@ exec_buffer_new (const char *name, int free_content, int clear_buffer,
int switch_to_buffer)
{
struct t_gui_buffer *new_buffer;
struct t_hashtable *buffer_props;
int buffer_type;
new_buffer = weechat_buffer_search (EXEC_PLUGIN_NAME, name);
@@ -165,23 +166,36 @@ exec_buffer_new (const char *name, int free_content, int clear_buffer,
goto end;
}
new_buffer = weechat_buffer_new (name,
&exec_buffer_input_cb, NULL, NULL,
&exec_buffer_close_cb, NULL, NULL);
buffer_props = weechat_hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL, NULL);
if (buffer_props)
{
if (free_content)
weechat_hashtable_set (buffer_props, "type", "free");
weechat_hashtable_set (buffer_props, "clear", "1");
weechat_hashtable_set (buffer_props, "title", _("Executed commands"));
weechat_hashtable_set (buffer_props, "localvar_set_type", "exec");
weechat_hashtable_set (buffer_props, "localvar_set_no_log", "1");
weechat_hashtable_set (buffer_props, "time_for_each_line", "0");
weechat_hashtable_set (buffer_props, "input_get_unknown_commands", "0");
}
new_buffer = weechat_buffer_new_props (name,
buffer_props,
&exec_buffer_input_cb, NULL, NULL,
&exec_buffer_close_cb, NULL, NULL);
if (buffer_props)
weechat_hashtable_free (buffer_props);
/* failed to create buffer ? then return */
if (!new_buffer)
return NULL;
if (free_content)
weechat_buffer_set (new_buffer, "type", "free");
weechat_buffer_set (new_buffer, "clear", "1");
weechat_buffer_set (new_buffer, "title", _("Executed commands"));
weechat_buffer_set (new_buffer, "localvar_set_type", "exec");
weechat_buffer_set (new_buffer, "localvar_set_no_log", "1");
weechat_buffer_set (new_buffer, "time_for_each_line", "0");
weechat_buffer_set (new_buffer, "input_get_unknown_commands", "0");
end:
if (clear_buffer)
weechat_buffer_clear (new_buffer);