mirror of
https://github.com/weechat/weechat.git
synced 2026-07-01 23:36:37 +02:00
Add "replacement" argument for string_remove_color in plugin API
This commit is contained in:
@@ -48,6 +48,7 @@
|
||||
#include "../gui/gui-bar-item.h"
|
||||
#include "../gui/gui-buffer.h"
|
||||
#include "../gui/gui-chat.h"
|
||||
#include "../gui/gui-color.h"
|
||||
#include "../gui/gui-nicklist.h"
|
||||
#include "../gui/gui-window.h"
|
||||
#include "plugin.h"
|
||||
@@ -412,7 +413,7 @@ plugin_load (const char *filename)
|
||||
new_plugin->string_split_command = &string_split_command;
|
||||
new_plugin->string_free_splitted_command = &string_free_splitted_command;
|
||||
new_plugin->string_format_size = &string_format_size;
|
||||
new_plugin->string_remove_color = &string_remove_color;
|
||||
new_plugin->string_remove_color = &gui_color_decode;
|
||||
|
||||
new_plugin->utf8_has_8bits = &utf8_has_8bits;
|
||||
new_plugin->utf8_is_valid = &utf8_is_valid;
|
||||
|
||||
@@ -371,7 +371,7 @@ weechat_lua_api_ngettext (lua_State *L)
|
||||
static int
|
||||
weechat_lua_api_string_remove_color (lua_State *L)
|
||||
{
|
||||
const char *string;
|
||||
const char *string, *replacement;
|
||||
char *result;
|
||||
int n;
|
||||
|
||||
@@ -388,15 +388,16 @@ weechat_lua_api_string_remove_color (lua_State *L)
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 1)
|
||||
if (n < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("string_remove_color");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
string = lua_tostring (lua_current_interpreter, -1);
|
||||
string = lua_tostring (lua_current_interpreter, -2);
|
||||
replacement = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
result = weechat_string_remove_color (string);
|
||||
result = weechat_string_remove_color (string, replacement);
|
||||
|
||||
LUA_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ static XS (XS_weechat_api_ngettext)
|
||||
|
||||
static XS (XS_weechat_api_string_remove_color)
|
||||
{
|
||||
char *result, *string;
|
||||
char *result, *string, *replacement;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -328,14 +328,15 @@ static XS (XS_weechat_api_string_remove_color)
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (items < 1)
|
||||
if (items < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("string_remove_color");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
string = SvPV (ST (0), PL_na);
|
||||
result = weechat_string_remove_color (string);
|
||||
replacement = SvPV (ST (1), PL_na);
|
||||
result = weechat_string_remove_color (string, replacement);
|
||||
|
||||
PERL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ weechat_python_api_ngettext (PyObject *self, PyObject *args)
|
||||
static PyObject *
|
||||
weechat_python_api_string_remove_color (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *string, *result;
|
||||
char *string, *replacement, *result;
|
||||
PyObject *object;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -337,14 +337,15 @@ weechat_python_api_string_remove_color (PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
string = NULL;
|
||||
replacement = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "s", &string))
|
||||
if (!PyArg_ParseTuple (args, "ss", &string, &replacement))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("string_remove_color");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
result = weechat_string_remove_color (string);
|
||||
result = weechat_string_remove_color (string, replacement);
|
||||
|
||||
PYTHON_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
@@ -372,9 +372,10 @@ weechat_ruby_api_ngettext (VALUE class, VALUE single, VALUE plural,
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_string_remove_color (VALUE class, VALUE string)
|
||||
weechat_ruby_api_string_remove_color (VALUE class, VALUE string,
|
||||
VALUE replacement)
|
||||
{
|
||||
char *c_string, *result;
|
||||
char *c_string, *c_replacement, *result;
|
||||
VALUE return_value;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -387,18 +388,21 @@ weechat_ruby_api_string_remove_color (VALUE class, VALUE string)
|
||||
}
|
||||
|
||||
c_string = NULL;
|
||||
c_replacement = NULL;
|
||||
|
||||
if (NIL_P (string))
|
||||
if (NIL_P (string) || NIL_P (replacement))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("string_remove_color");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
Check_Type (string, T_STRING);
|
||||
Check_Type (replacement, T_STRING);
|
||||
|
||||
c_string = STR2CSTR (string);
|
||||
c_replacement = STR2CSTR (replacement);
|
||||
|
||||
result = weechat_string_remove_color (c_string);
|
||||
result = weechat_string_remove_color (c_string, c_replacement);
|
||||
|
||||
RUBY_RETURN_STRING_FREE(result);
|
||||
}
|
||||
@@ -6580,7 +6584,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
rb_define_module_function (ruby_mWeechat, "iconv_from_internal", &weechat_ruby_api_iconv_from_internal, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "gettext", &weechat_ruby_api_gettext, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "ngettext", &weechat_ruby_api_ngettext, 3);
|
||||
rb_define_module_function (ruby_mWeechat, "string_remove_color", &weechat_ruby_api_string_remove_color, 1);
|
||||
rb_define_module_function (ruby_mWeechat, "string_remove_color", &weechat_ruby_api_string_remove_color, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "mkdir_home", &weechat_ruby_api_mkdir_home, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "mkdir", &weechat_ruby_api_mkdir, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "mkdir_parents", &weechat_ruby_api_mkdir_parents, 2);
|
||||
|
||||
@@ -443,7 +443,7 @@ weechat_tcl_api_string_remove_color (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj* objp;
|
||||
char *result, *string;
|
||||
char *result, *replacement, *string;
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -455,14 +455,15 @@ weechat_tcl_api_string_remove_color (ClientData clientData, Tcl_Interp *interp,
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (objc < 2)
|
||||
if (objc < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("string_remove_color");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
string = Tcl_GetStringFromObj (objv[1], &i);
|
||||
result = weechat_string_remove_color (string);
|
||||
replacement = Tcl_GetStringFromObj (objv[2], &i);
|
||||
result = weechat_string_remove_color (string, replacement);
|
||||
|
||||
TCL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ struct t_weechat_plugin
|
||||
char **(*string_split_command) (const char *command, char separator);
|
||||
void (*string_free_splitted_command) (char **splitted_command);
|
||||
char *(*string_format_size) (unsigned long size);
|
||||
char *(*string_remove_color) (const char *string);
|
||||
char *(*string_remove_color) (const char *string, const char *replacement);
|
||||
|
||||
/* UTF-8 strings */
|
||||
int (*utf8_has_8bits) (const char *string);
|
||||
@@ -694,8 +694,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
|
||||
weechat_plugin->string_free_splitted_command(__splitted_command)
|
||||
#define weechat_string_format_size(__size) \
|
||||
weechat_plugin->string_format_size(__size)
|
||||
#define weechat_string_remove_color(__string) \
|
||||
weechat_plugin->string_remove_color(__string)
|
||||
#define weechat_string_remove_color(__string, __replacement) \
|
||||
weechat_plugin->string_remove_color(__string, __replacement)
|
||||
|
||||
/* UTF-8 strings */
|
||||
#define weechat_utf8_has_8bits(__string) \
|
||||
|
||||
Reference in New Issue
Block a user