diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c index 78423a12e..ba7863992 100644 --- a/src/plugins/guile/weechat-guile-api.c +++ b/src/plugins/guile/weechat-guile-api.c @@ -2003,6 +2003,30 @@ weechat_guile_api_config_unset_plugin (SCM option) API_RETURN_INT(rc); } +SCM +weechat_guile_api_theme_register (SCM name, SCM overrides) +{ + struct t_hashtable *c_overrides; + const char *result; + SCM return_value; + + API_INIT_FUNC(1, "theme_register", API_RETURN_EMPTY); + if (!scm_is_string (name) || !scm_list_p (overrides)) + API_WRONG_ARGS(API_RETURN_EMPTY); + + c_overrides = weechat_guile_alist_to_hashtable (overrides, + WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING); + + result = API_PTR2STR(weechat_theme_register (API_SCM_TO_STRING(name), + c_overrides)); + + weechat_hashtable_free (c_overrides); + + API_RETURN_STRING(result); +} + SCM weechat_guile_api_key_bind (SCM context, SCM keys) { @@ -5537,6 +5561,7 @@ weechat_guile_api_module_init (void *data) API_DEF_FUNC(config_set_plugin, 2); API_DEF_FUNC(config_set_desc_plugin, 2); API_DEF_FUNC(config_unset_plugin, 1); + API_DEF_FUNC(theme_register, 2); API_DEF_FUNC(key_bind, 2); API_DEF_FUNC(key_unbind, 2); API_DEF_FUNC(prefix, 1); diff --git a/src/plugins/javascript/weechat-js-api.cpp b/src/plugins/javascript/weechat-js-api.cpp index d2e045a48..5d69d2ac7 100644 --- a/src/plugins/javascript/weechat-js-api.cpp +++ b/src/plugins/javascript/weechat-js-api.cpp @@ -1898,6 +1898,28 @@ API_FUNC(config_unset_plugin) API_RETURN_INT(rc); } +API_FUNC(theme_register) +{ + struct t_hashtable *hashtable; + const char *result; + + API_INIT_FUNC(1, "theme_register", "sh", API_RETURN_EMPTY); + + v8::String::Utf8Value name(args[0]); + hashtable = weechat_js_object_to_hashtable ( + args[1]->ToObject(), + WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING); + + result = API_PTR2STR(weechat_theme_register (*name, hashtable)); + + if (hashtable) + weechat_hashtable_free (hashtable); + + API_RETURN_STRING(result); +} + API_FUNC(key_bind) { struct t_hashtable *hashtable; @@ -5468,6 +5490,7 @@ WeechatJsV8::loadLibs() API_DEF_FUNC(config_set_plugin); API_DEF_FUNC(config_set_desc_plugin); API_DEF_FUNC(config_unset_plugin); + API_DEF_FUNC(theme_register); API_DEF_FUNC(key_bind); API_DEF_FUNC(key_unbind); API_DEF_FUNC(prefix); diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c index e7822995a..3ae79952b 100644 --- a/src/plugins/lua/weechat-lua-api.c +++ b/src/plugins/lua/weechat-lua-api.c @@ -2081,6 +2081,29 @@ API_FUNC(config_unset_plugin) API_RETURN_INT(rc); } +API_FUNC(theme_register) +{ + const char *name; + struct t_hashtable *hashtable; + const char *result; + + API_INIT_FUNC(1, "theme_register", API_RETURN_EMPTY); + if (lua_gettop (L) < 2) + API_WRONG_ARGS(API_RETURN_EMPTY); + + name = lua_tostring (L, -2); + hashtable = weechat_lua_tohashtable (L, -1, + WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING); + + result = API_PTR2STR(weechat_theme_register (name, hashtable)); + + weechat_hashtable_free (hashtable); + + API_RETURN_STRING(result); +} + API_FUNC(key_bind) { const char *context; @@ -5849,6 +5872,7 @@ const struct luaL_Reg weechat_lua_api_funcs[] = { API_DEF_FUNC(config_set_plugin), API_DEF_FUNC(config_set_desc_plugin), API_DEF_FUNC(config_unset_plugin), + API_DEF_FUNC(theme_register), API_DEF_FUNC(key_bind), API_DEF_FUNC(key_unbind), API_DEF_FUNC(prefix), diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c index 7c3b400df..9c19676a7 100644 --- a/src/plugins/perl/weechat-perl-api.c +++ b/src/plugins/perl/weechat-perl-api.c @@ -2000,6 +2000,30 @@ API_FUNC(config_unset_plugin) API_RETURN_INT(rc); } +API_FUNC(theme_register) +{ + char *name; + struct t_hashtable *hashtable; + const char *result; + dXSARGS; + + API_INIT_FUNC(1, "theme_register", API_RETURN_EMPTY); + if (items < 2) + API_WRONG_ARGS(API_RETURN_EMPTY); + + name = SvPV_nolen (ST (0)); + hashtable = weechat_perl_hash_to_hashtable (ST (1), + WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING); + + result = API_PTR2STR(weechat_theme_register (name, hashtable)); + + weechat_hashtable_free (hashtable); + + API_RETURN_STRING(result); +} + API_FUNC(key_bind) { char *context; @@ -5801,6 +5825,7 @@ weechat_perl_api_init (pTHX) API_DEF_FUNC(config_set_plugin); API_DEF_FUNC(config_set_desc_plugin); API_DEF_FUNC(config_unset_plugin); + API_DEF_FUNC(theme_register); API_DEF_FUNC(key_bind); API_DEF_FUNC(key_unbind); API_DEF_FUNC(prefix); diff --git a/src/plugins/php/weechat-php-api.c b/src/plugins/php/weechat-php-api.c index 8238eaa67..c461c077a 100644 --- a/src/plugins/php/weechat-php-api.c +++ b/src/plugins/php/weechat-php-api.c @@ -2175,6 +2175,33 @@ API_FUNC(config_unset_plugin) API_RETURN_INT(result); } +API_FUNC(theme_register) +{ + zend_string *z_name; + zval *z_overrides; + char *name; + struct t_hashtable *overrides; + const char *result; + + API_INIT_FUNC(1, "theme_register", API_RETURN_EMPTY); + if (zend_parse_parameters (ZEND_NUM_ARGS(), "Sa", &z_name, + &z_overrides) == FAILURE) + API_WRONG_ARGS(API_RETURN_EMPTY); + + name = ZSTR_VAL(z_name); + overrides = weechat_php_array_to_hashtable (z_overrides, + WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING); + + result = API_PTR2STR(weechat_theme_register ((const char *)name, + overrides)); + + weechat_hashtable_free (overrides); + + API_RETURN_STRING(result); +} + API_FUNC(key_bind) { zend_string *z_context; diff --git a/src/plugins/php/weechat-php-api.h b/src/plugins/php/weechat-php-api.h index b878a4ef5..4096a6d80 100644 --- a/src/plugins/php/weechat-php-api.h +++ b/src/plugins/php/weechat-php-api.h @@ -132,6 +132,7 @@ PHP_FUNCTION(weechat_config_is_set_plugin); PHP_FUNCTION(weechat_config_set_plugin); PHP_FUNCTION(weechat_config_set_desc_plugin); PHP_FUNCTION(weechat_config_unset_plugin); +PHP_FUNCTION(weechat_theme_register); PHP_FUNCTION(weechat_key_bind); PHP_FUNCTION(weechat_key_unbind); PHP_FUNCTION(weechat_prefix); diff --git a/src/plugins/php/weechat-php.c b/src/plugins/php/weechat-php.c index c20ec9d3e..05a0c3ef6 100644 --- a/src/plugins/php/weechat-php.c +++ b/src/plugins/php/weechat-php.c @@ -190,6 +190,7 @@ const zend_function_entry weechat_functions[] = { PHP_FE(weechat_config_set_plugin, arginfo_weechat_config_set_plugin) PHP_FE(weechat_config_set_desc_plugin, arginfo_weechat_config_set_desc_plugin) PHP_FE(weechat_config_unset_plugin, arginfo_weechat_config_unset_plugin) + PHP_FE(weechat_theme_register, arginfo_weechat_theme_register) PHP_FE(weechat_key_bind, arginfo_weechat_key_bind) PHP_FE(weechat_key_unbind, arginfo_weechat_key_unbind) PHP_FE(weechat_prefix, arginfo_weechat_prefix) diff --git a/src/plugins/php/weechat-php_arginfo.h b/src/plugins/php/weechat-php_arginfo.h index 2345bc686..0e74af377 100644 --- a/src/plugins/php/weechat-php_arginfo.h +++ b/src/plugins/php/weechat-php_arginfo.h @@ -233,6 +233,11 @@ ZEND_END_ARG_INFO() #define arginfo_weechat_config_unset_plugin arginfo_weechat_charset_set +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_theme_register, 0, 2, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, p0, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, p1, IS_ARRAY, 0) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_key_bind, 0, 2, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, p0, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, p1, IS_ARRAY, 0) diff --git a/src/plugins/php/weechat-php_legacy_arginfo.h b/src/plugins/php/weechat-php_legacy_arginfo.h index e8de9d8ac..a8b3b8db5 100644 --- a/src/plugins/php/weechat-php_legacy_arginfo.h +++ b/src/plugins/php/weechat-php_legacy_arginfo.h @@ -194,6 +194,8 @@ ZEND_END_ARG_INFO() #define arginfo_weechat_config_unset_plugin arginfo_weechat_plugin_get_name +#define arginfo_weechat_theme_register arginfo_weechat_iconv_to_internal + #define arginfo_weechat_key_bind arginfo_weechat_iconv_to_internal #define arginfo_weechat_key_unbind arginfo_weechat_iconv_to_internal diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c index 88194ba71..6745a3511 100644 --- a/src/plugins/python/weechat-python-api.c +++ b/src/plugins/python/weechat-python-api.c @@ -2001,6 +2001,31 @@ API_FUNC(config_unset_plugin) API_RETURN_INT(rc); } +API_FUNC(theme_register) +{ + char *name; + PyObject *dict; + struct t_hashtable *hashtable; + const char *result; + + API_INIT_FUNC(1, "theme_register", API_RETURN_EMPTY); + name = NULL; + dict = NULL; + if (!PyArg_ParseTuple (args, "sO", &name, &dict)) + API_WRONG_ARGS(API_RETURN_EMPTY); + + hashtable = weechat_python_dict_to_hashtable (dict, + WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING); + + result = API_PTR2STR(weechat_theme_register (name, hashtable)); + + weechat_hashtable_free (hashtable); + + API_RETURN_STRING(result); +} + API_FUNC(key_bind) { char *context; @@ -5729,6 +5754,7 @@ PyMethodDef weechat_python_funcs[] = API_DEF_FUNC(config_set_plugin), API_DEF_FUNC(config_set_desc_plugin), API_DEF_FUNC(config_unset_plugin), + API_DEF_FUNC(theme_register), API_DEF_FUNC(key_bind), API_DEF_FUNC(key_unbind), API_DEF_FUNC(prefix), diff --git a/src/plugins/python/weechat.pyi b/src/plugins/python/weechat.pyi index a9f5abb82..d953ec7a5 100644 --- a/src/plugins/python/weechat.pyi +++ b/src/plugins/python/weechat.pyi @@ -1143,6 +1143,19 @@ def config_unset_plugin(option_name: str) -> int: ... +def theme_register(name: str, overrides: Dict[str, str]) -> str: + """`theme_register in WeeChat plugin API reference `_ + :: + + # example + weechat.theme_register("light", { + "irc.color.input_nick": "cyan", + "irc.color.topic_old": "darkgray", + }) + """ + ... + + def key_bind(context: str, keys: Dict[str, str]) -> int: """`key_bind in WeeChat plugin API reference `_ :: diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c index a5acd17cb..b7ba1805d 100644 --- a/src/plugins/ruby/weechat-ruby-api.c +++ b/src/plugins/ruby/weechat-ruby-api.c @@ -2478,6 +2478,33 @@ weechat_ruby_api_config_unset_plugin (VALUE class, VALUE option) API_RETURN_INT(rc); } +static VALUE +weechat_ruby_api_theme_register (VALUE class, VALUE name, VALUE overrides) +{ + char *c_name; + struct t_hashtable *c_overrides; + const char *result; + + API_INIT_FUNC(1, "theme_register", API_RETURN_EMPTY); + if (NIL_P (name) || NIL_P (overrides)) + API_WRONG_ARGS(API_RETURN_EMPTY); + + Check_Type (name, T_STRING); + Check_Type (overrides, T_HASH); + + c_name = StringValuePtr (name); + c_overrides = weechat_ruby_hash_to_hashtable (overrides, + WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING); + + result = API_PTR2STR(weechat_theme_register (c_name, c_overrides)); + + weechat_hashtable_free (c_overrides); + + API_RETURN_STRING(result); +} + static VALUE weechat_ruby_api_key_bind (VALUE class, VALUE context, VALUE keys) { @@ -7078,6 +7105,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) API_DEF_FUNC(config_set_plugin, 2); API_DEF_FUNC(config_set_desc_plugin, 2); API_DEF_FUNC(config_unset_plugin, 1); + API_DEF_FUNC(theme_register, 2); API_DEF_FUNC(key_bind, 2); API_DEF_FUNC(key_unbind, 2); API_DEF_FUNC(prefix, 1); diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c index 2fff10faf..816126274 100644 --- a/src/plugins/tcl/weechat-tcl-api.c +++ b/src/plugins/tcl/weechat-tcl-api.c @@ -2035,6 +2035,29 @@ API_FUNC(config_unset_plugin) API_RETURN_INT(rc); } +API_FUNC(theme_register) +{ + char *name; + struct t_hashtable *hashtable; + const char *result; + + API_INIT_FUNC(1, "theme_register", API_RETURN_EMPTY); + if (objc < 3) + API_WRONG_ARGS(API_RETURN_EMPTY); + + name = Tcl_GetString (objv[1]); + hashtable = weechat_tcl_dict_to_hashtable (interp, objv[2], + WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_STRING); + + result = API_PTR2STR(weechat_theme_register (name, hashtable)); + + weechat_hashtable_free (hashtable); + + API_RETURN_STRING(result); +} + API_FUNC(key_bind) { char *context; @@ -5806,6 +5829,7 @@ void weechat_tcl_api_init (Tcl_Interp *interp) API_DEF_FUNC(config_set_plugin); API_DEF_FUNC(config_set_desc_plugin); API_DEF_FUNC(config_unset_plugin); + API_DEF_FUNC(theme_register); API_DEF_FUNC(key_bind); API_DEF_FUNC(key_unbind); API_DEF_FUNC(prefix);