mirror of
https://github.com/weechat/weechat.git
synced 2026-07-01 23:36:37 +02:00
api: add function string_color_code_size (issue #1547)
This commit is contained in:
@@ -428,6 +428,20 @@ weechat_guile_api_string_format_size (SCM size)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -448,6 +448,25 @@ weechat_ruby_api_string_format_size (VALUE class, VALUE size)
|
||||
API_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) \
|
||||
|
||||
Reference in New Issue
Block a user