diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/guile/weechat-guile-api.c | 40 | ||||
-rw-r--r-- | src/plugins/javascript/weechat-js-api.cpp | 38 | ||||
-rw-r--r-- | src/plugins/lua/weechat-lua-api.c | 41 | ||||
-rw-r--r-- | src/plugins/perl/weechat-perl-api.c | 41 | ||||
-rw-r--r-- | src/plugins/php/weechat-php-api.c | 44 | ||||
-rw-r--r-- | src/plugins/php/weechat-php-api.h | 1 | ||||
-rw-r--r-- | src/plugins/php/weechat-php.c | 1 | ||||
-rw-r--r-- | src/plugins/php/weechat-php.stub.php | 1 | ||||
-rw-r--r-- | src/plugins/php/weechat-php_arginfo.h | 2 | ||||
-rw-r--r-- | src/plugins/php/weechat-php_legacy_arginfo.h | 2 | ||||
-rw-r--r-- | src/plugins/plugin-script-api.c | 67 | ||||
-rw-r--r-- | src/plugins/plugin-script-api.h | 15 | ||||
-rw-r--r-- | src/plugins/plugin.c | 1 | ||||
-rw-r--r-- | src/plugins/python/weechat-python-api.c | 43 | ||||
-rw-r--r-- | src/plugins/ruby/weechat-ruby-api.c | 53 | ||||
-rw-r--r-- | src/plugins/tcl/weechat-tcl-api.c | 42 | ||||
-rw-r--r-- | src/plugins/weechat-plugin.h | 39 |
17 files changed, 452 insertions, 19 deletions
diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c index 85f8561a3..fc176f60f 100644 --- a/src/plugins/guile/weechat-guile-api.c +++ b/src/plugins/guile/weechat-guile-api.c @@ -3347,6 +3347,45 @@ weechat_guile_api_buffer_new (SCM name, SCM function_input, SCM data_input, } SCM +weechat_guile_api_buffer_new_props (SCM name, SCM properties, + SCM function_input, SCM data_input, + SCM function_close, SCM data_close) +{ + struct t_hashtable *c_properties; + const char *result; + SCM return_value; + + API_INIT_FUNC(1, "buffer_new_props", API_RETURN_EMPTY); + if (!scm_is_string (name) || !scm_list_p (properties) + || !scm_is_string (function_input) || !scm_is_string (data_input) + || !scm_is_string (function_close) || !scm_is_string (data_close)) + API_WRONG_ARGS(API_RETURN_EMPTY); + + c_properties = weechat_guile_alist_to_hashtable (properties, + WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING); + + result = API_PTR2STR( + plugin_script_api_buffer_new_props ( + weechat_guile_plugin, + guile_current_script, + API_SCM_TO_STRING(name), + c_properties, + &weechat_guile_api_buffer_input_data_cb, + API_SCM_TO_STRING(function_input), + API_SCM_TO_STRING(data_input), + &weechat_guile_api_buffer_close_cb, + API_SCM_TO_STRING(function_close), + API_SCM_TO_STRING(data_close))); + + if (c_properties) + weechat_hashtable_free (c_properties); + + API_RETURN_STRING(result); +} + +SCM weechat_guile_api_buffer_search (SCM plugin, SCM name) { const char *result; @@ -5175,6 +5214,7 @@ weechat_guile_api_module_init (void *data) API_DEF_FUNC(unhook, 1); API_DEF_FUNC(unhook_all, 0); API_DEF_FUNC(buffer_new, 5); + API_DEF_FUNC(buffer_new_props, 6); API_DEF_FUNC(buffer_search, 2); API_DEF_FUNC(buffer_search_main, 0); API_DEF_FUNC(current_buffer, 0); diff --git a/src/plugins/javascript/weechat-js-api.cpp b/src/plugins/javascript/weechat-js-api.cpp index caf992c5f..93e6a2c2c 100644 --- a/src/plugins/javascript/weechat-js-api.cpp +++ b/src/plugins/javascript/weechat-js-api.cpp @@ -3270,6 +3270,43 @@ API_FUNC(buffer_new) API_RETURN_STRING(result); } +API_FUNC(buffer_new_props) +{ + struct t_hashtable *properties; + const char *result; + + API_INIT_FUNC(1, "buffer_new_props", "shssss", API_RETURN_EMPTY); + + v8::String::Utf8Value name(args[0]); + properties = weechat_js_object_to_hashtable ( + args[1]->ToObject(), + WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING); + v8::String::Utf8Value function_input(args[2]); + v8::String::Utf8Value data_input(args[3]); + v8::String::Utf8Value function_close(args[4]); + v8::String::Utf8Value data_close(args[5]); + + result = API_PTR2STR( + plugin_script_api_buffer_new_props ( + weechat_js_plugin, + js_current_script, + *name, + properties, + &weechat_js_api_buffer_input_data_cb, + *function_input, + *data_input, + &weechat_js_api_buffer_close_cb, + *function_close, + *data_close)); + + if (properties) + weechat_hashtable_free (properties); + + API_RETURN_STRING(result); +} + API_FUNC(buffer_search) { const char *result; @@ -5117,6 +5154,7 @@ WeechatJsV8::loadLibs() API_DEF_FUNC(unhook); API_DEF_FUNC(unhook_all); API_DEF_FUNC(buffer_new); + API_DEF_FUNC(buffer_new_props); API_DEF_FUNC(buffer_search); API_DEF_FUNC(buffer_search_main); API_DEF_FUNC(current_buffer); diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c index ee26fbe10..f03c99ffe 100644 --- a/src/plugins/lua/weechat-lua-api.c +++ b/src/plugins/lua/weechat-lua-api.c @@ -3505,6 +3505,46 @@ API_FUNC(buffer_new) API_RETURN_STRING(result); } +API_FUNC(buffer_new_props) +{ + const char *name, *function_input, *data_input, *function_close; + const char *data_close; + struct t_hashtable *properties; + const char *result; + + API_INIT_FUNC(1, "buffer_new_props", API_RETURN_EMPTY); + if (lua_gettop (L) < 6) + API_WRONG_ARGS(API_RETURN_EMPTY); + + name = lua_tostring (L, -6); + properties = weechat_lua_tohashtable (L, -5, + WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING); + function_input = lua_tostring (L, -4); + data_input = lua_tostring (L, -3); + function_close = lua_tostring (L, -2); + data_close = lua_tostring (L, -1); + + result = API_PTR2STR( + plugin_script_api_buffer_new_props ( + weechat_lua_plugin, + lua_current_script, + name, + properties, + &weechat_lua_api_buffer_input_data_cb, + function_input, + data_input, + &weechat_lua_api_buffer_close_cb, + function_close, + data_close)); + + if (properties) + weechat_hashtable_free (properties); + + API_RETURN_STRING(result); +} + API_FUNC(buffer_search) { const char *plugin, *name; @@ -5470,6 +5510,7 @@ const struct luaL_Reg weechat_lua_api_funcs[] = { API_DEF_FUNC(unhook), API_DEF_FUNC(unhook_all), API_DEF_FUNC(buffer_new), + API_DEF_FUNC(buffer_new_props), API_DEF_FUNC(buffer_search), API_DEF_FUNC(buffer_search_main), API_DEF_FUNC(current_buffer), diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c index 27438b3ee..791c276ce 100644 --- a/src/plugins/perl/weechat-perl-api.c +++ b/src/plugins/perl/weechat-perl-api.c @@ -3412,6 +3412,46 @@ API_FUNC(buffer_new) API_RETURN_STRING(result); } +API_FUNC(buffer_new_props) +{ + char *name, *function_input, *data_input, *function_close, *data_close; + struct t_hashtable *properties; + const char *result; + dXSARGS; + + API_INIT_FUNC(1, "buffer_new_props", API_RETURN_EMPTY); + if (items < 6) + API_WRONG_ARGS(API_RETURN_EMPTY); + + name = SvPV_nolen (ST (0)); + properties = weechat_perl_hash_to_hashtable (ST (1), + WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING); + function_input = SvPV_nolen (ST (2)); + data_input = SvPV_nolen (ST (3)); + function_close = SvPV_nolen (ST (4)); + data_close = SvPV_nolen (ST (5)); + + result = API_PTR2STR( + plugin_script_api_buffer_new_props ( + weechat_perl_plugin, + perl_current_script, + name, + properties, + &weechat_perl_api_buffer_input_data_cb, + function_input, + data_input, + &weechat_perl_api_buffer_close_cb, + function_close, + data_close)); + + if (properties) + weechat_hashtable_free (properties); + + API_RETURN_STRING(result); +} + API_FUNC(buffer_search) { char *plugin, *name; @@ -5423,6 +5463,7 @@ weechat_perl_api_init (pTHX) API_DEF_FUNC(unhook); API_DEF_FUNC(unhook_all); API_DEF_FUNC(buffer_new); + API_DEF_FUNC(buffer_new_props); API_DEF_FUNC(buffer_search); API_DEF_FUNC(buffer_search_main); API_DEF_FUNC(current_buffer); diff --git a/src/plugins/php/weechat-php-api.c b/src/plugins/php/weechat-php-api.c index b92580b38..f365bfa1e 100644 --- a/src/plugins/php/weechat-php-api.c +++ b/src/plugins/php/weechat-php-api.c @@ -3332,6 +3332,50 @@ API_FUNC(buffer_new) API_RETURN_STRING(result); } +API_FUNC(buffer_new_props) +{ + zend_string *z_name, *z_data_input, *z_data_close; + zval *z_properties, *z_input_callback, *z_close_callback; + char *name, *data_input, *data_close; + struct t_hashtable *properties; + const char *result; + + API_INIT_FUNC(1, "buffer_new_props", API_RETURN_EMPTY); + if (zend_parse_parameters (ZEND_NUM_ARGS(), "SazSzS", &z_name, + &z_properties, &z_input_callback, &z_data_input, + &z_close_callback, &z_data_close) == FAILURE) + API_WRONG_ARGS(API_RETURN_EMPTY); + + name = ZSTR_VAL(z_name); + properties = weechat_php_array_to_hashtable ( + z_properties, + WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING); + weechat_php_get_function_name (z_input_callback, input_callback_name); + data_input = ZSTR_VAL(z_data_input); + weechat_php_get_function_name (z_close_callback, close_callback_name); + data_close = ZSTR_VAL(z_data_close); + + result = API_PTR2STR( + plugin_script_api_buffer_new_props ( + weechat_php_plugin, + php_current_script, + (const char *)name, + properties, + &weechat_php_api_buffer_input_data_cb, + (const char *)input_callback_name, + (const char *)data_input, + &weechat_php_api_buffer_close_cb, + (const char *)close_callback_name, + (const char *)data_close)); + + if (properties) + weechat_hashtable_free (properties); + + API_RETURN_STRING(result); +} + API_FUNC(buffer_search) { zend_string *z_plugin, *z_name; diff --git a/src/plugins/php/weechat-php-api.h b/src/plugins/php/weechat-php-api.h index 283e4baed..563e09c1a 100644 --- a/src/plugins/php/weechat-php-api.h +++ b/src/plugins/php/weechat-php-api.h @@ -155,6 +155,7 @@ PHP_FUNCTION(weechat_hook_set); PHP_FUNCTION(weechat_unhook); PHP_FUNCTION(weechat_unhook_all); PHP_FUNCTION(weechat_buffer_new); +PHP_FUNCTION(weechat_buffer_new_props); PHP_FUNCTION(weechat_buffer_search); PHP_FUNCTION(weechat_buffer_search_main); PHP_FUNCTION(weechat_current_buffer); diff --git a/src/plugins/php/weechat-php.c b/src/plugins/php/weechat-php.c index 89ebdd7e9..115d821ff 100644 --- a/src/plugins/php/weechat-php.c +++ b/src/plugins/php/weechat-php.c @@ -213,6 +213,7 @@ const zend_function_entry weechat_functions[] = { PHP_FE(weechat_unhook, arginfo_weechat_unhook) PHP_FE(weechat_unhook_all, arginfo_weechat_unhook_all) PHP_FE(weechat_buffer_new, arginfo_weechat_buffer_new) + PHP_FE(weechat_buffer_new_props, arginfo_weechat_buffer_new_props) PHP_FE(weechat_buffer_search, arginfo_weechat_buffer_search) PHP_FE(weechat_buffer_search_main, arginfo_weechat_buffer_search_main) PHP_FE(weechat_current_buffer, arginfo_weechat_current_buffer) diff --git a/src/plugins/php/weechat-php.stub.php b/src/plugins/php/weechat-php.stub.php index b5488d14f..ba3a365fb 100644 --- a/src/plugins/php/weechat-php.stub.php +++ b/src/plugins/php/weechat-php.stub.php @@ -116,6 +116,7 @@ function weechat_hook_set(): mixed {} function weechat_unhook(): mixed {} function weechat_unhook_all(): mixed {} function weechat_buffer_new(): mixed {} +function weechat_buffer_new_props(): mixed {} function weechat_buffer_search(): mixed {} function weechat_buffer_search_main(): mixed {} function weechat_current_buffer(): mixed {} diff --git a/src/plugins/php/weechat-php_arginfo.h b/src/plugins/php/weechat-php_arginfo.h index 8067b169b..b963c6e08 100644 --- a/src/plugins/php/weechat-php_arginfo.h +++ b/src/plugins/php/weechat-php_arginfo.h @@ -222,6 +222,8 @@ ZEND_END_ARG_INFO() #define arginfo_weechat_buffer_new arginfo_weechat_register +#define arginfo_weechat_buffer_new_props arginfo_weechat_register + #define arginfo_weechat_buffer_search arginfo_weechat_register #define arginfo_weechat_buffer_search_main arginfo_weechat_register diff --git a/src/plugins/php/weechat-php_legacy_arginfo.h b/src/plugins/php/weechat-php_legacy_arginfo.h index c96907041..846fbeee5 100644 --- a/src/plugins/php/weechat-php_legacy_arginfo.h +++ b/src/plugins/php/weechat-php_legacy_arginfo.h @@ -222,6 +222,8 @@ ZEND_END_ARG_INFO() #define arginfo_weechat_buffer_new arginfo_weechat_register +#define arginfo_weechat_buffer_new_props arginfo_weechat_register + #define arginfo_weechat_buffer_search arginfo_weechat_register #define arginfo_weechat_buffer_search_main arginfo_weechat_register diff --git a/src/plugins/plugin-script-api.c b/src/plugins/plugin-script-api.c index 157d0b181..9ae37e4a0 100644 --- a/src/plugins/plugin-script-api.c +++ b/src/plugins/plugin-script-api.c @@ -1192,24 +1192,25 @@ plugin_script_api_hook_focus (struct t_weechat_plugin *weechat_plugin, } /* - * Creates a new buffer. + * Creates a new buffer with optional properties. */ struct t_gui_buffer * -plugin_script_api_buffer_new (struct t_weechat_plugin *weechat_plugin, - struct t_plugin_script *script, - const char *name, - int (*input_callback)(const void *pointer, - void *data, - struct t_gui_buffer *buffer, - const char *input_data), - const char *function_input, - const char *data_input, - int (*close_callback)(const void *pointer, - void *data, - struct t_gui_buffer *buffer), - const char *function_close, - const char *data_close) +plugin_script_api_buffer_new_props (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *name, + struct t_hashtable *properties, + int (*input_callback)(const void *pointer, + void *data, + struct t_gui_buffer *buffer, + const char *input_data), + const char *function_input, + const char *data_input, + int (*close_callback)(const void *pointer, + void *data, + struct t_gui_buffer *buffer), + const char *function_close, + const char *data_close) { char *function_and_data_input, *function_and_data_close; struct t_gui_buffer *new_buffer; @@ -1222,8 +1223,9 @@ plugin_script_api_buffer_new (struct t_weechat_plugin *weechat_plugin, function_and_data_close = plugin_script_build_function_and_data ( function_close, data_close); - new_buffer = weechat_buffer_new ( + new_buffer = weechat_buffer_new_props ( name, + properties, (function_and_data_input) ? input_callback : NULL, script, function_and_data_input, @@ -1257,6 +1259,39 @@ plugin_script_api_buffer_new (struct t_weechat_plugin *weechat_plugin, } /* + * Creates a new buffer. + */ + +struct t_gui_buffer * +plugin_script_api_buffer_new (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *name, + int (*input_callback)(const void *pointer, + void *data, + struct t_gui_buffer *buffer, + const char *input_data), + const char *function_input, + const char *data_input, + int (*close_callback)(const void *pointer, + void *data, + struct t_gui_buffer *buffer), + const char *function_close, + const char *data_close) +{ + return plugin_script_api_buffer_new_props ( + weechat_plugin, + script, + name, + NULL, /* properties */ + input_callback, + function_input, + data_input, + close_callback, + function_close, + data_close); +} + +/* * Adds a new bar item. * * Returns pointer to new bar item, NULL if error. diff --git a/src/plugins/plugin-script-api.h b/src/plugins/plugin-script-api.h index 0c01db775..b7a369dea 100644 --- a/src/plugins/plugin-script-api.h +++ b/src/plugins/plugin-script-api.h @@ -334,6 +334,21 @@ extern struct t_hook *plugin_script_api_hook_focus (struct t_weechat_plugin *wee struct t_hashtable *info), const char *function, const char *data); +extern struct t_gui_buffer *plugin_script_api_buffer_new_props (struct t_weechat_plugin *weechat_plugin, + struct t_plugin_script *script, + const char *name, + struct t_hashtable *properties, + int (*input_callback)(const void *pointer, + void *data, + struct t_gui_buffer *buffer, + const char *input_data), + const char *function_input, + const char *data_input, + int (*close_callback)(const void *pointer, + void *data, + struct t_gui_buffer *buffer), + const char *function_close, + const char *data_close); extern struct t_gui_buffer *plugin_script_api_buffer_new (struct t_weechat_plugin *weechat_plugin, struct t_plugin_script *script, const char *name, diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index e1c4cde0b..1e326f3c5 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -804,6 +804,7 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv) new_plugin->unhook_all = &unhook_all_plugin; new_plugin->buffer_new = &gui_buffer_new; + new_plugin->buffer_new_props = &gui_buffer_new_props; new_plugin->buffer_search = &gui_buffer_search_by_name; new_plugin->buffer_search_main = &gui_buffer_search_main; new_plugin->buffer_clear = &gui_buffer_clear; diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c index 6398e7d2e..90ffdaa47 100644 --- a/src/plugins/python/weechat-python-api.c +++ b/src/plugins/python/weechat-python-api.c @@ -3413,6 +3413,48 @@ API_FUNC(buffer_new) API_RETURN_STRING(result); } +API_FUNC(buffer_new_props) +{ + char *name, *function_input, *data_input, *function_close, *data_close; + struct t_hashtable *properties; + PyObject *dict; + const char *result; + + API_INIT_FUNC(1, "buffer_new_props", API_RETURN_EMPTY); + name = NULL; + dict = NULL; + function_input = NULL; + data_input = NULL; + function_close = NULL; + data_close = NULL; + if (!PyArg_ParseTuple (args, "sOssss", &name, &dict, + &function_input, &data_input, + &function_close, &data_close)) + API_WRONG_ARGS(API_RETURN_EMPTY); + + properties = weechat_python_dict_to_hashtable (dict, + WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING); + result = API_PTR2STR( + plugin_script_api_buffer_new_props ( + weechat_python_plugin, + python_current_script, + name, + properties, + &weechat_python_api_buffer_input_data_cb, + function_input, + data_input, + &weechat_python_api_buffer_close_cb, + function_close, + data_close)); + + if (properties) + weechat_hashtable_free (properties); + + API_RETURN_STRING(result); +} + API_FUNC(buffer_search) { char *plugin, *name; @@ -5333,6 +5375,7 @@ PyMethodDef weechat_python_funcs[] = API_DEF_FUNC(unhook), API_DEF_FUNC(unhook_all), API_DEF_FUNC(buffer_new), + API_DEF_FUNC(buffer_new_props), API_DEF_FUNC(buffer_search), API_DEF_FUNC(buffer_search_main), API_DEF_FUNC(current_buffer), diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c index d1883f49f..b55c13321 100644 --- a/src/plugins/ruby/weechat-ruby-api.c +++ b/src/plugins/ruby/weechat-ruby-api.c @@ -4102,6 +4102,58 @@ weechat_ruby_api_buffer_new (VALUE class, VALUE name, VALUE function_input, } static VALUE +weechat_ruby_api_buffer_new_props (VALUE class, VALUE name, VALUE properties, + VALUE function_input, + VALUE data_input, VALUE function_close, + VALUE data_close) +{ + char *c_name, *c_function_input, *c_data_input, *c_function_close; + char *c_data_close; + struct t_hashtable *c_properties; + const char *result; + + API_INIT_FUNC(1, "buffer_new_props", API_RETURN_EMPTY); + if (NIL_P (name) || NIL_P (properties) || NIL_P (function_input) + || NIL_P (data_input) || NIL_P (function_close) || NIL_P (data_close)) + API_WRONG_ARGS(API_RETURN_EMPTY); + + Check_Type (name, T_STRING); + Check_Type (properties, T_HASH); + Check_Type (function_input, T_STRING); + Check_Type (data_input, T_STRING); + Check_Type (function_close, T_STRING); + Check_Type (data_close, T_STRING); + + c_name = StringValuePtr (name); + c_properties = weechat_ruby_hash_to_hashtable (properties, + WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING); + c_function_input = StringValuePtr (function_input); + c_data_input = StringValuePtr (data_input); + c_function_close = StringValuePtr (function_close); + c_data_close = StringValuePtr (data_close); + + result = API_PTR2STR( + plugin_script_api_buffer_new_props ( + weechat_ruby_plugin, + ruby_current_script, + c_name, + c_properties, + &weechat_ruby_api_buffer_input_data_cb, + c_function_input, + c_data_input, + &weechat_ruby_api_buffer_close_cb, + c_function_close, + c_data_close)); + + if (c_properties) + weechat_hashtable_free (c_properties); + + API_RETURN_STRING(result); +} + +static VALUE weechat_ruby_api_buffer_search (VALUE class, VALUE plugin, VALUE name) { char *c_plugin, *c_name; @@ -6606,6 +6658,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) API_DEF_FUNC(unhook, 1); API_DEF_FUNC(unhook_all, 0); API_DEF_FUNC(buffer_new, 5); + API_DEF_FUNC(buffer_new_props, 6); API_DEF_FUNC(buffer_search, 2); API_DEF_FUNC(buffer_search_main, 0); API_DEF_FUNC(current_buffer, 0); diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c index a82aa4725..6d8fe6c0a 100644 --- a/src/plugins/tcl/weechat-tcl-api.c +++ b/src/plugins/tcl/weechat-tcl-api.c @@ -3738,6 +3738,47 @@ API_FUNC(buffer_new) API_RETURN_STRING(result); } +API_FUNC(buffer_new_props) +{ + Tcl_Obj *objp; + char *name, *function_input, *data_input, *function_close, *data_close; + struct t_hashtable *properties; + const char *result; + int i; + + API_INIT_FUNC(1, "buffer_new_props", API_RETURN_EMPTY); + if (objc < 7) + API_WRONG_ARGS(API_RETURN_EMPTY); + + name = Tcl_GetStringFromObj (objv[1], &i); + properties = weechat_tcl_dict_to_hashtable (interp, objv[2], + WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING); + function_input = Tcl_GetStringFromObj (objv[3], &i); + data_input = Tcl_GetStringFromObj (objv[4], &i); + function_close = Tcl_GetStringFromObj (objv[5], &i); + data_close = Tcl_GetStringFromObj (objv[6], &i); + + result = API_PTR2STR( + plugin_script_api_buffer_new_props ( + weechat_tcl_plugin, + tcl_current_script, + name, + properties, + &weechat_tcl_api_buffer_input_data_cb, + function_input, + data_input, + &weechat_tcl_api_buffer_close_cb, + function_close, + data_close)); + + if (properties) + weechat_hashtable_free (properties); + + API_RETURN_STRING(result); +} + API_FUNC(buffer_search) { Tcl_Obj *objp; @@ -5918,6 +5959,7 @@ void weechat_tcl_api_init (Tcl_Interp *interp) API_DEF_FUNC(unhook); API_DEF_FUNC(unhook_all); API_DEF_FUNC(buffer_new); + API_DEF_FUNC(buffer_new_props); API_DEF_FUNC(buffer_search); API_DEF_FUNC(buffer_search_main); API_DEF_FUNC(current_buffer); diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index c45ad250a..ff892c737 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -68,7 +68,7 @@ struct timeval; * please change the date with current one; for a second change at same * date, increment the 01, otherwise please keep 01. */ -#define WEECHAT_PLUGIN_API_VERSION "20220130-01" +#define WEECHAT_PLUGIN_API_VERSION "20220312-01" /* macros for defining plugin infos */ #define WEECHAT_PLUGIN_NAME(__name) \ @@ -893,6 +893,20 @@ struct t_weechat_plugin struct t_gui_buffer *buffer), const void *close_callback_pointer, void *close_callback_data); + struct t_gui_buffer *(*buffer_new_props) (struct t_weechat_plugin *plugin, + const char *name, + struct t_hashtable *properties, + int (*input_callback)(const void *pointer, + void *data, + struct t_gui_buffer *buffer, + const char *input_data), + const void *input_callback_pointer, + void *input_callback_data, + int (*close_callback)(const void *pointer, + void *data, + struct t_gui_buffer *buffer), + const void *close_callback_pointer, + void *close_callback_data); struct t_gui_buffer *(*buffer_search) (const char *plugin, const char *name); struct t_gui_buffer *(*buffer_search_main) (); void (*buffer_clear) (struct t_gui_buffer *buffer); @@ -1835,19 +1849,38 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); (weechat_plugin->unhook_all)(weechat_plugin, __subplugin) /* buffers */ -#define weechat_buffer_new(__name, __input_callback, \ +#define weechat_buffer_new(__name, \ + __input_callback, \ __input_callback_pointer, \ __input_callback_data, \ __close_callback, \ __close_callback_pointer, \ __close_callback_data) \ - (weechat_plugin->buffer_new)(weechat_plugin, __name, \ + (weechat_plugin->buffer_new)(weechat_plugin, \ + __name, \ __input_callback, \ __input_callback_pointer, \ __input_callback_data, \ __close_callback, \ __close_callback_pointer, \ __close_callback_data) +#define weechat_buffer_new_props(__name, \ + __properties, \ + __input_callback, \ + __input_callback_pointer, \ + __input_callback_data, \ + __close_callback, \ + __close_callback_pointer, \ + __close_callback_data) \ + (weechat_plugin->buffer_new_props)(weechat_plugin, \ + __name, \ + __properties, \ + __input_callback, \ + __input_callback_pointer, \ + __input_callback_data, \ + __close_callback, \ + __close_callback_pointer, \ + __close_callback_data) #define weechat_buffer_search(__plugin, __name) \ (weechat_plugin->buffer_search)(__plugin, __name) #define weechat_buffer_search_main() \ |