api: add new function strlen_screen
parent
50ab62b75d
commit
6be17ac263
|
@ -1,7 +1,7 @@
|
|||
WeeChat ChangeLog
|
||||
=================
|
||||
Sébastien Helleu <flashcode@flashtux.org>
|
||||
v0.4.2-dev, 2013-07-24
|
||||
v0.4.2-dev, 2013-07-27
|
||||
|
||||
|
||||
This document lists all changes for each version.
|
||||
|
@ -45,6 +45,7 @@ Version 0.4.2 (under dev!)
|
|||
"layout_window"
|
||||
* core: fix line alignment when option weechat.look.buffer_time_format is set
|
||||
to empty string
|
||||
* api: add new function strlen_screen
|
||||
* aspell: rename option aspell.look.color to aspell.color.misspelled, add option
|
||||
aspell.color.suggestions
|
||||
* aspell: add support of enchant library (patch #6858)
|
||||
|
|
|
@ -790,6 +790,48 @@ char *pos = weechat_strcasestr ("aBcDeF", "de"); /* result: pointer to "DeF" */
|
|||
[NOTE]
|
||||
This function is not available in scripting API.
|
||||
|
||||
weechat_strlen_screen
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
_New in version 0.4.2._
|
||||
|
||||
Return number of chars needed on screen to display UTF-8 string.
|
||||
Non-printable chars have a width of 1 (this is the difference with the function
|
||||
<<_weechat_utf8_strlen_screen,weechat_utf8_strlen_screen>>).
|
||||
|
||||
Prototype:
|
||||
|
||||
[source,C]
|
||||
----------------------------------------
|
||||
int weechat_strlen_screen (const char *string);
|
||||
----------------------------------------
|
||||
|
||||
Arguments:
|
||||
|
||||
* 'string': string
|
||||
|
||||
Return value:
|
||||
|
||||
* number of chars needed on screen to display UTF-8 string
|
||||
|
||||
C example:
|
||||
|
||||
[source,C]
|
||||
----------------------------------------
|
||||
int length_on_screen = weechat_strlen_screen ("é"); /* == 1 */
|
||||
----------------------------------------
|
||||
|
||||
Script (Python):
|
||||
|
||||
[source,python]
|
||||
----------------------------------------
|
||||
# prototype
|
||||
length = weechat.strlen_screen(string)
|
||||
|
||||
# example
|
||||
length = weechat.strlen_screen("é") # 1
|
||||
----------------------------------------
|
||||
|
||||
weechat_string_match
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
|
|
@ -798,6 +798,49 @@ char *pos = weechat_strcasestr ("aBcDeF", "de"); /* résultat : pointeur vers "D
|
|||
[NOTE]
|
||||
Cette fonction n'est pas disponible dans l'API script.
|
||||
|
||||
weechat_strlen_screen
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
_Nouveau dans la version 0.4.2._
|
||||
|
||||
Retourne le nombre de caractères nécessaires pour afficher la chaîne UTF-8
|
||||
sur l'écran.
|
||||
Les caractères non affichables ont une longueur de 1 (c'est la différence avec
|
||||
la fonction <<_weechat_utf8_strlen_screen,weechat_utf8_strlen_screen>>).
|
||||
|
||||
Prototype :
|
||||
|
||||
[source,C]
|
||||
----------------------------------------
|
||||
int weechat_strlen_screen (const char *string);
|
||||
----------------------------------------
|
||||
|
||||
Paramètres :
|
||||
|
||||
* 'string' : chaîne
|
||||
|
||||
Valeur de retour :
|
||||
|
||||
* nombre de caractères nécessaires pour afficher la chaîne UTF-8 sur l'écran
|
||||
|
||||
Exemple en C :
|
||||
|
||||
[source,C]
|
||||
----------------------------------------
|
||||
int length_on_screen = weechat_strlen_screen ("é"); /* == 1 */
|
||||
----------------------------------------
|
||||
|
||||
Script (Python):
|
||||
|
||||
[source,python]
|
||||
----------------------------------------
|
||||
# prototype
|
||||
length = weechat.strlen_screen(string)
|
||||
|
||||
# exemple
|
||||
length = weechat.strlen_screen("é") # 1
|
||||
----------------------------------------
|
||||
|
||||
weechat_string_match
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
|
|
@ -804,6 +804,51 @@ char *pos = weechat_strcasestr ("aBcDeF", "de"); /* risultato: puntatore a "DeF"
|
|||
[NOTE]
|
||||
Questa funzione non è disponibile nelle API per lo scripting.
|
||||
|
||||
weechat_strlen_screen
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
_Novità nella versione 0.4.2._
|
||||
|
||||
Restituisce il numero di caratteri necessari per visualizzare la stringa
|
||||
UTF-8 su schermo.
|
||||
// TRANSLATION MISSING
|
||||
Non-printable chars have a width of 1 (this is the difference with the function
|
||||
<<_weechat_utf8_strlen_screen,weechat_utf8_strlen_screen>>).
|
||||
|
||||
Prototipo:
|
||||
|
||||
[source,C]
|
||||
----------------------------------------
|
||||
int weechat_strlen_screen (const char *string);
|
||||
----------------------------------------
|
||||
|
||||
Argomenti:
|
||||
|
||||
* 'string': stringa
|
||||
|
||||
Valore restituito:
|
||||
|
||||
* numero di caratteri necessari per visualizzare la stringa UTF-8
|
||||
su schermo
|
||||
|
||||
Esempio in C:
|
||||
|
||||
[source,C]
|
||||
----------------------------------------
|
||||
int length_on_screen = weechat_strlen_screen ("é"); /* == 1 */
|
||||
----------------------------------------
|
||||
|
||||
Script (Python):
|
||||
|
||||
[source,python]
|
||||
----------------------------------------
|
||||
# prototipo
|
||||
length = weechat.strlen_screen(string)
|
||||
|
||||
# esempio
|
||||
length = weechat.strlen_screen("é") # 1
|
||||
----------------------------------------
|
||||
|
||||
weechat_string_match
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
|
|
@ -317,6 +317,20 @@ weechat_guile_api_ngettext (SCM single, SCM plural, SCM count)
|
|||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
|
|
@ -276,6 +276,23 @@ weechat_lua_api_ngettext (lua_State *L)
|
|||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -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),
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -260,6 +260,22 @@ weechat_python_api_ngettext (PyObject *self, PyObject *args)
|
|||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -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),
|
||||
|
|
|
@ -295,6 +295,25 @@ weechat_ruby_api_ngettext (VALUE class, VALUE single, VALUE plural,
|
|||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -407,6 +407,25 @@ weechat_tcl_api_ngettext (ClientData clientData, Tcl_Interp *interp,
|
|||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -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) \
|
||||
|
|
Loading…
Reference in New Issue