summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-05-20 16:22:18 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-05-20 17:08:25 +0200
commitb1759ab25a776417b4f05612719a37b69593e14f (patch)
treec1be6b3ec9feba3734b4e2ff8d1315ec08dd83d4 /src
parent3ca3ea32fd6d0d0f54ae033304bfcb2299bf79b5 (diff)
downloadweechat-b1759ab25a776417b4f05612719a37b69593e14f.zip
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".
Diffstat (limited to 'src')
-rw-r--r--src/plugins/exec/exec-buffer.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/src/plugins/exec/exec-buffer.c b/src/plugins/exec/exec-buffer.c
index fd69fe967..cb8872055 100644
--- a/src/plugins/exec/exec-buffer.c
+++ b/src/plugins/exec/exec-buffer.c
@@ -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);