diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2013-07-27 18:21:50 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2013-07-27 18:21:50 +0200 |
commit | 6be17ac2635614c6a63c9266df324f725e07087c (patch) | |
tree | b72e99299d952a883011fa7483c02a9f2caeca3d /src | |
parent | 50ab62b75d50f28c90d9eea1f786d90aa20cdfe1 (diff) | |
download | weechat-6be17ac2635614c6a63c9266df324f725e07087c.zip |
api: add new function strlen_screen
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/guile/weechat-guile-api.c | 15 | ||||
-rw-r--r-- | src/plugins/lua/weechat-lua-api.c | 18 | ||||
-rw-r--r-- | src/plugins/perl/weechat-perl-api.c | 15 | ||||
-rw-r--r-- | src/plugins/plugin.c | 1 | ||||
-rw-r--r-- | src/plugins/python/weechat-python-api.c | 17 | ||||
-rw-r--r-- | src/plugins/ruby/weechat-ruby-api.c | 20 | ||||
-rw-r--r-- | src/plugins/tcl/weechat-tcl-api.c | 20 | ||||
-rw-r--r-- | src/plugins/weechat-plugin.h | 5 |
8 files changed, 110 insertions, 1 deletions
diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c index 8f6e99873..5142eb862 100644 --- a/src/plugins/guile/weechat-guile-api.c +++ b/src/plugins/guile/weechat-guile-api.c @@ -318,6 +318,20 @@ weechat_guile_api_ngettext (SCM single, SCM plural, SCM count) } SCM +weechat_guile_api_strlen_screen (SCM string) +{ + int value; + + API_FUNC(1, "strlen_screen", API_RETURN_INT(0)); + if (!scm_is_string (string)) + API_WRONG_ARGS(API_RETURN_INT(0)); + + value = weechat_strlen_screen (API_SCM_TO_STRING(string)); + + API_RETURN_INT(value); +} + +SCM weechat_guile_api_string_match (SCM string, SCM mask, SCM case_sensitive) { int value; @@ -4586,6 +4600,7 @@ weechat_guile_api_module_init (void *data) API_DEF_FUNC(iconv_from_internal, 2); API_DEF_FUNC(gettext, 1); API_DEF_FUNC(ngettext, 3); + API_DEF_FUNC(strlen_screen, 1); API_DEF_FUNC(string_match, 3); API_DEF_FUNC(string_has_highlight, 2); API_DEF_FUNC(string_has_highlight_regex, 2); diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c index ba9b089bb..e60f2d3b3 100644 --- a/src/plugins/lua/weechat-lua-api.c +++ b/src/plugins/lua/weechat-lua-api.c @@ -277,6 +277,23 @@ weechat_lua_api_ngettext (lua_State *L) } static int +weechat_lua_api_strlen_screen (lua_State *L) +{ + const char *string; + int value; + + API_FUNC(1, "strlen_screen", API_RETURN_INT(0)); + if (lua_gettop (L) < 1) + API_WRONG_ARGS(API_RETURN_INT(0)); + + string = lua_tostring (L, -1); + + value = weechat_strlen_screen (string); + + API_RETURN_INT(value); +} + +static int weechat_lua_api_string_match (lua_State *L) { const char *string, *mask; @@ -5070,6 +5087,7 @@ const struct luaL_Reg weechat_lua_api_funcs[] = { API_DEF_FUNC(iconv_from_internal), API_DEF_FUNC(gettext), API_DEF_FUNC(ngettext), + API_DEF_FUNC(strlen_screen), API_DEF_FUNC(string_match), API_DEF_FUNC(string_has_highlight), API_DEF_FUNC(string_has_highlight_regex), diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c index 11d3f1c8c..19cb70ec8 100644 --- a/src/plugins/perl/weechat-perl-api.c +++ b/src/plugins/perl/weechat-perl-api.c @@ -278,6 +278,20 @@ XS (XS_weechat_api_ngettext) API_RETURN_STRING(result); } +XS (XS_weechat_api_strlen_screen) +{ + int value; + dXSARGS; + + API_FUNC(1, "strlen_screen", API_RETURN_INT(0)); + if (items < 1) + API_WRONG_ARGS(API_RETURN_INT(0)); + + value = weechat_strlen_screen (SvPV_nolen (ST (0))); /* string */ + + API_RETURN_INT(value); +} + XS (XS_weechat_api_string_match) { int value; @@ -4823,6 +4837,7 @@ weechat_perl_api_init (pTHX) API_DEF_FUNC(iconv_from_internal); API_DEF_FUNC(gettext); API_DEF_FUNC(ngettext); + API_DEF_FUNC(strlen_screen); API_DEF_FUNC(string_match); API_DEF_FUNC(string_has_highlight); API_DEF_FUNC(string_has_highlight_regex); diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index 3ad99bd68..4051689fa 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -510,6 +510,7 @@ plugin_load (const char *filename, int argc, char **argv) new_plugin->strncasecmp_range = &string_strncasecmp_range; new_plugin->strcmp_ignore_chars = &string_strcmp_ignore_chars; new_plugin->strcasestr = &string_strcasestr; + new_plugin->strlen_screen = &gui_chat_strlen_screen; new_plugin->string_match = &string_match; new_plugin->string_replace = &string_replace; new_plugin->string_expand_home = &string_expand_home; diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c index e2d776d69..6e2d39722 100644 --- a/src/plugins/python/weechat-python-api.c +++ b/src/plugins/python/weechat-python-api.c @@ -261,6 +261,22 @@ weechat_python_api_ngettext (PyObject *self, PyObject *args) } static PyObject * +weechat_python_api_strlen_screen (PyObject *self, PyObject *args) +{ + char *string; + int value; + + API_FUNC(1, "strlen_screen", API_RETURN_INT(0)); + string = NULL; + if (!PyArg_ParseTuple (args, "s", &string)) + API_WRONG_ARGS(API_RETURN_INT(0)); + + value = weechat_strlen_screen (string); + + API_RETURN_INT(value); +} + +static PyObject * weechat_python_api_string_match (PyObject *self, PyObject *args) { char *string, *mask; @@ -4975,6 +4991,7 @@ PyMethodDef weechat_python_funcs[] = API_DEF_FUNC(iconv_from_internal), API_DEF_FUNC(gettext), API_DEF_FUNC(ngettext), + API_DEF_FUNC(strlen_screen), API_DEF_FUNC(string_match), API_DEF_FUNC(string_has_highlight), API_DEF_FUNC(string_has_highlight_regex), diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c index 9888e5a93..6246ee76f 100644 --- a/src/plugins/ruby/weechat-ruby-api.c +++ b/src/plugins/ruby/weechat-ruby-api.c @@ -296,6 +296,25 @@ weechat_ruby_api_ngettext (VALUE class, VALUE single, VALUE plural, } static VALUE +weechat_ruby_api_strlen_screen (VALUE class, VALUE string) +{ + char *c_string; + int value; + + API_FUNC(1, "strlen_screen", API_RETURN_INT(0)); + if (NIL_P (string)) + API_WRONG_ARGS(API_RETURN_INT(0)); + + Check_Type (string, T_STRING); + + c_string = StringValuePtr (string); + + value = weechat_strlen_screen (c_string); + + API_RETURN_INT(value); +} + +static VALUE weechat_ruby_api_string_match (VALUE class, VALUE string, VALUE mask, VALUE case_sensitive) { @@ -5918,6 +5937,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) API_DEF_FUNC(iconv_from_internal, 2); API_DEF_FUNC(gettext, 1); API_DEF_FUNC(ngettext, 3); + API_DEF_FUNC(strlen_screen, 1); API_DEF_FUNC(string_match, 3); API_DEF_FUNC(string_has_highlight, 2); API_DEF_FUNC(string_has_highlight_regex, 2); diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c index 451d9d5e9..24a8ce4a3 100644 --- a/src/plugins/tcl/weechat-tcl-api.c +++ b/src/plugins/tcl/weechat-tcl-api.c @@ -408,6 +408,25 @@ weechat_tcl_api_ngettext (ClientData clientData, Tcl_Interp *interp, } static int +weechat_tcl_api_strlen_screen (ClientData clientData, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]) +{ + Tcl_Obj *objp; + char *string; + int result, i; + + API_FUNC(1, "strlen_screen", API_RETURN_INT(0)); + if (objc < 2) + API_WRONG_ARGS(API_RETURN_INT(0)); + + string = Tcl_GetStringFromObj (objv[1], &i); + + result = weechat_strlen_screen (string); + + API_RETURN_INT(result); +} + +static int weechat_tcl_api_string_match (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { @@ -5664,6 +5683,7 @@ void weechat_tcl_api_init (Tcl_Interp *interp) API_DEF_FUNC(iconv_from_internal); API_DEF_FUNC(gettext); API_DEF_FUNC(ngettext); + API_DEF_FUNC(strlen_screen); API_DEF_FUNC(string_match); API_DEF_FUNC(string_has_highlight); API_DEF_FUNC(string_has_highlight_regex); diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index fb78fb40a..82873d171 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -52,7 +52,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 "20130421-01" +#define WEECHAT_PLUGIN_API_VERSION "20130727-01" /* macros for defining plugin infos */ #define WEECHAT_PLUGIN_NAME(__name) \ @@ -225,6 +225,7 @@ struct t_weechat_plugin int (*strcmp_ignore_chars) (const char *string1, const char *string2, const char *chars_ignored, int case_sensitive); char *(*strcasestr) (const char *string, const char *search); + int (*strlen_screen) (const char *string); int (*string_match) (const char *string, const char *mask, int case_sensitive); char *(*string_replace) (const char *string, const char *search, @@ -969,6 +970,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); __case_sensitive) #define weechat_strcasestr(__string, __search) \ weechat_plugin->strcasestr(__string, __search) +#define weechat_strlen_screen(__string) \ + weechat_plugin->strlen_screen(__string) #define weechat_string_match(__string, __mask, __case_sensitive) \ weechat_plugin->string_match(__string, __mask, __case_sensitive) #define weechat_string_replace(__string, __search, __replace) \ |