diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/guile/weechat-guile-api.c | 15 | ||||
-rw-r--r-- | src/plugins/javascript/weechat-js-api.cpp | 14 | ||||
-rw-r--r-- | src/plugins/lua/weechat-lua-api.c | 17 | ||||
-rw-r--r-- | src/plugins/perl/weechat-perl-api.c | 15 | ||||
-rw-r--r-- | src/plugins/php/weechat-php-api.c | 17 | ||||
-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/plugin.c | 1 | ||||
-rw-r--r-- | src/plugins/python/weechat-python-api.c | 16 | ||||
-rw-r--r-- | src/plugins/ruby/weechat-ruby-api.c | 20 | ||||
-rw-r--r-- | src/plugins/tcl/weechat-tcl-api.c | 15 | ||||
-rw-r--r-- | src/plugins/weechat-plugin.h | 5 |
12 files changed, 136 insertions, 1 deletions
diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c index 8355c441c..09b514b83 100644 --- a/src/plugins/guile/weechat-guile-api.c +++ b/src/plugins/guile/weechat-guile-api.c @@ -429,6 +429,20 @@ weechat_guile_api_string_format_size (SCM size) } SCM +weechat_guile_api_string_color_code_size (SCM string) +{ + int size; + + API_INIT_FUNC(1, "string_color_code_size", API_RETURN_INT(0)); + if (!scm_is_string (string)) + API_WRONG_ARGS(API_RETURN_INT(0)); + + size = weechat_string_color_code_size (API_SCM_TO_STRING(string)); + + API_RETURN_INT(size); +} + +SCM weechat_guile_api_string_remove_color (SCM string, SCM replacement) { char *result; @@ -5012,6 +5026,7 @@ weechat_guile_api_module_init (void *data) API_DEF_FUNC(string_has_highlight_regex, 2); API_DEF_FUNC(string_mask_to_regex, 1); API_DEF_FUNC(string_format_size, 1); + API_DEF_FUNC(string_color_code_size, 1); API_DEF_FUNC(string_remove_color, 2); API_DEF_FUNC(string_is_command_char, 1); API_DEF_FUNC(string_input_for_buffer, 1); diff --git a/src/plugins/javascript/weechat-js-api.cpp b/src/plugins/javascript/weechat-js-api.cpp index 67b3ef68f..8938ab0da 100644 --- a/src/plugins/javascript/weechat-js-api.cpp +++ b/src/plugins/javascript/weechat-js-api.cpp @@ -376,6 +376,19 @@ API_FUNC(string_format_size) API_RETURN_STRING_FREE(result); } +API_FUNC(string_color_code_size) +{ + int size; + + API_INIT_FUNC(1, "string_color_code_size", "s", API_RETURN_INT(0)); + + v8::String::Utf8Value string(args[0]); + + size = weechat_string_color_code_size (*string); + + API_RETURN_INT(size); +} + API_FUNC(string_remove_color) { char *result; @@ -4945,6 +4958,7 @@ WeechatJsV8::loadLibs() API_DEF_FUNC(string_has_highlight_regex); API_DEF_FUNC(string_mask_to_regex); API_DEF_FUNC(string_format_size); + API_DEF_FUNC(string_color_code_size); API_DEF_FUNC(string_remove_color); API_DEF_FUNC(string_is_command_char); API_DEF_FUNC(string_input_for_buffer); diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c index 057c0c491..72cbd6267 100644 --- a/src/plugins/lua/weechat-lua-api.c +++ b/src/plugins/lua/weechat-lua-api.c @@ -423,6 +423,22 @@ API_FUNC(string_format_size) API_RETURN_STRING_FREE(result); } +API_FUNC(string_color_code_size) +{ + const char *string; + int size; + + API_INIT_FUNC(1, "string_color_code_size", API_RETURN_INT(0)); + if (lua_gettop (L) < 1) + API_WRONG_ARGS(API_RETURN_INT(0)); + + string = lua_tostring (L, -1); + + size = weechat_string_color_code_size (string); + + API_RETURN_INT(size); +} + API_FUNC(string_remove_color) { const char *string, *replacement; @@ -5309,6 +5325,7 @@ const struct luaL_Reg weechat_lua_api_funcs[] = { API_DEF_FUNC(string_has_highlight_regex), API_DEF_FUNC(string_mask_to_regex), API_DEF_FUNC(string_format_size), + API_DEF_FUNC(string_color_code_size), API_DEF_FUNC(string_remove_color), API_DEF_FUNC(string_is_command_char), API_DEF_FUNC(string_input_for_buffer), diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c index d9fc273af..62e1823a4 100644 --- a/src/plugins/perl/weechat-perl-api.c +++ b/src/plugins/perl/weechat-perl-api.c @@ -383,6 +383,20 @@ API_FUNC(string_format_size) API_RETURN_STRING_FREE(result); } +API_FUNC(string_color_code_size) +{ + int size; + dXSARGS; + + API_INIT_FUNC(1, "string_color_code_size", API_RETURN_INT(0)); + if (items < 1) + API_WRONG_ARGS(API_RETURN_INT(0)); + + size = weechat_string_color_code_size (SvPV_nolen (ST (0))); /* string */ + + API_RETURN_INT(size); +} + API_FUNC(string_remove_color) { char *result, *string, *replacement; @@ -5266,6 +5280,7 @@ weechat_perl_api_init (pTHX) API_DEF_FUNC(string_has_highlight_regex); API_DEF_FUNC(string_mask_to_regex); API_DEF_FUNC(string_format_size); + API_DEF_FUNC(string_color_code_size); API_DEF_FUNC(string_remove_color); API_DEF_FUNC(string_is_command_char); API_DEF_FUNC(string_input_for_buffer); diff --git a/src/plugins/php/weechat-php-api.c b/src/plugins/php/weechat-php-api.c index 6b05825c4..8d5e4bc34 100644 --- a/src/plugins/php/weechat-php-api.c +++ b/src/plugins/php/weechat-php-api.c @@ -497,6 +497,23 @@ API_FUNC(string_format_size) API_RETURN_STRING_FREE(result); } +API_FUNC(string_color_code_size) +{ + zend_string *z_string; + char *string; + int result; + + API_INIT_FUNC(1, "string_color_code_size", API_RETURN_INT(0)); + if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_string) == FAILURE) + API_WRONG_ARGS(API_RETURN_INT(0)); + + string = ZSTR_VAL(z_string); + + result = weechat_string_color_code_size ((const char *)string); + + API_RETURN_INT(result); +} + API_FUNC(string_remove_color) { zend_string *z_string, *z_replacement; diff --git a/src/plugins/php/weechat-php-api.h b/src/plugins/php/weechat-php-api.h index 71ca67b26..65ce9d356 100644 --- a/src/plugins/php/weechat-php-api.h +++ b/src/plugins/php/weechat-php-api.h @@ -59,6 +59,7 @@ PHP_FUNCTION(weechat_string_has_highlight); PHP_FUNCTION(weechat_string_has_highlight_regex); PHP_FUNCTION(weechat_string_mask_to_regex); PHP_FUNCTION(weechat_string_format_size); +PHP_FUNCTION(weechat_string_color_code_size); PHP_FUNCTION(weechat_string_remove_color); PHP_FUNCTION(weechat_string_is_command_char); PHP_FUNCTION(weechat_string_input_for_buffer); diff --git a/src/plugins/php/weechat-php.c b/src/plugins/php/weechat-php.c index 93a1f2069..ace023828 100644 --- a/src/plugins/php/weechat-php.c +++ b/src/plugins/php/weechat-php.c @@ -112,6 +112,7 @@ const zend_function_entry weechat_functions[] = { PHP_FE(weechat_string_has_highlight_regex, NULL) PHP_FE(weechat_string_mask_to_regex, NULL) PHP_FE(weechat_string_format_size, NULL) + PHP_FE(weechat_string_color_code_size, NULL) PHP_FE(weechat_string_remove_color, NULL) PHP_FE(weechat_string_is_command_char, NULL) PHP_FE(weechat_string_input_for_buffer, NULL) diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index 5f0a75f5c..f1f840463 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -632,6 +632,7 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv) new_plugin->string_split_command = &string_split_command; new_plugin->string_free_split_command = &string_free_split_command; new_plugin->string_format_size = &string_format_size; + new_plugin->string_color_code_size = &gui_color_code_size; new_plugin->string_remove_color = &gui_color_decode; new_plugin->string_base_encode = &string_base_encode; new_plugin->string_base_decode = &string_base_decode; diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c index 690c33d1f..b55efe7f7 100644 --- a/src/plugins/python/weechat-python-api.c +++ b/src/plugins/python/weechat-python-api.c @@ -369,6 +369,21 @@ API_FUNC(string_format_size) API_RETURN_STRING_FREE(result); } +API_FUNC(string_color_code_size) +{ + char *string; + int size; + + API_INIT_FUNC(1, "string_color_code_size", API_RETURN_INT(0)); + string = NULL; + if (!PyArg_ParseTuple (args, "s", &string)) + API_WRONG_ARGS(API_RETURN_INT(0)); + + size = weechat_string_color_code_size (string); + + API_RETURN_INT(size); +} + API_FUNC(string_remove_color) { char *string, *replacement, *result; @@ -5217,6 +5232,7 @@ PyMethodDef weechat_python_funcs[] = API_DEF_FUNC(string_has_highlight_regex), API_DEF_FUNC(string_mask_to_regex), API_DEF_FUNC(string_format_size), + API_DEF_FUNC(string_color_code_size), API_DEF_FUNC(string_remove_color), API_DEF_FUNC(string_is_command_char), API_DEF_FUNC(string_input_for_buffer), diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c index 20c003f1b..e993af323 100644 --- a/src/plugins/ruby/weechat-ruby-api.c +++ b/src/plugins/ruby/weechat-ruby-api.c @@ -449,6 +449,25 @@ weechat_ruby_api_string_format_size (VALUE class, VALUE size) } static VALUE +weechat_ruby_api_string_color_code_size (VALUE class, VALUE string) +{ + char *c_string; + int size; + + API_INIT_FUNC(1, "string_color_code_size", API_RETURN_INT(0)); + if (NIL_P (string)) + API_WRONG_ARGS(API_RETURN_INT(0)); + + Check_Type (string, T_STRING); + + c_string = StringValuePtr (string); + + size = weechat_string_color_code_size (c_string); + + API_RETURN_INT(size); +} + +static VALUE weechat_ruby_api_string_remove_color (VALUE class, VALUE string, VALUE replacement) { @@ -6424,6 +6443,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) API_DEF_FUNC(string_has_highlight_regex, 2); API_DEF_FUNC(string_mask_to_regex, 1); API_DEF_FUNC(string_format_size, 1); + API_DEF_FUNC(string_color_code_size, 1); API_DEF_FUNC(string_remove_color, 2); API_DEF_FUNC(string_is_command_char, 1); API_DEF_FUNC(string_input_for_buffer, 1); diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c index 528e501dc..475f746e4 100644 --- a/src/plugins/tcl/weechat-tcl-api.c +++ b/src/plugins/tcl/weechat-tcl-api.c @@ -530,6 +530,20 @@ API_FUNC(string_format_size) API_RETURN_STRING_FREE(result); } +API_FUNC(string_color_code_size) +{ + Tcl_Obj *objp; + int result, i; + + API_INIT_FUNC(1, "string_color_code_size", API_RETURN_INT(0)); + if (objc < 2) + API_WRONG_ARGS(API_RETURN_INT(0)); + + result = weechat_string_color_code_size (Tcl_GetStringFromObj (objv[1], &i)); /* string */ + + API_RETURN_INT(result); +} + API_FUNC(string_remove_color) { Tcl_Obj *objp; @@ -5739,6 +5753,7 @@ void weechat_tcl_api_init (Tcl_Interp *interp) API_DEF_FUNC(string_has_highlight_regex); API_DEF_FUNC(string_mask_to_regex); API_DEF_FUNC(string_format_size); + API_DEF_FUNC(string_color_code_size); API_DEF_FUNC(string_remove_color); API_DEF_FUNC(string_is_command_char); API_DEF_FUNC(string_input_for_buffer); diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index 44c74ea2d..b8cf10456 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -67,7 +67,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 "20200621-01" +#define WEECHAT_PLUGIN_API_VERSION "20200822-01" /* macros for defining plugin infos */ #define WEECHAT_PLUGIN_NAME(__name) \ @@ -334,6 +334,7 @@ struct t_weechat_plugin char **(*string_split_command) (const char *command, char separator); void (*string_free_split_command) (char **split_command); char *(*string_format_size) (unsigned long long size); + int (*string_color_code_size) (const char *string); char *(*string_remove_color) (const char *string, const char *replacement); int (*string_base_encode) (int base, const char *from, int length, char *to); @@ -1265,6 +1266,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); (weechat_plugin->string_free_split_command)(__split_command) #define weechat_string_format_size(__size) \ (weechat_plugin->string_format_size)(__size) +#define weechat_string_color_code_size(__string) \ + (weechat_plugin->string_color_code_size)(__string) #define weechat_string_remove_color(__string, __replacement) \ (weechat_plugin->string_remove_color)(__string, __replacement) #define weechat_string_base_encode(__base, __from, __length, __to) \ |