Add function "buffer_string_replace_local_var" in script API (patch #7061)
This commit is contained in:
parent
c9b71fca2d
commit
63aaf9dc01
@ -5005,6 +5005,46 @@ weechat_lua_api_buffer_set (lua_State *L)
|
||||
LUA_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_buffer_string_replace_local_var: replace local variables ($var) in a string,
|
||||
* using value of local variables
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_buffer_string_replace_local_var (lua_State *L)
|
||||
{
|
||||
const char *buffer, *string;
|
||||
char *result;
|
||||
int n;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var");
|
||||
LUA_RETURN_ERROR;
|
||||
}
|
||||
|
||||
buffer = NULL;
|
||||
string = NULL;
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var");
|
||||
LUA_RETURN_ERROR;
|
||||
}
|
||||
|
||||
buffer = lua_tostring (lua_current_interpreter, -2);
|
||||
string = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
result = weechat_buffer_string_replace_local_var (script_str2ptr (buffer), string);
|
||||
|
||||
LUA_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_current_window: get current window
|
||||
*/
|
||||
@ -7267,6 +7307,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
|
||||
{ "buffer_get_string", &weechat_lua_api_buffer_get_string },
|
||||
{ "buffer_get_pointer", &weechat_lua_api_buffer_get_pointer },
|
||||
{ "buffer_set", &weechat_lua_api_buffer_set },
|
||||
{ "buffer_string_replace_local_var", &weechat_lua_api_buffer_string_replace_local_var },
|
||||
{ "current_window", &weechat_lua_api_current_window },
|
||||
{ "window_get_integer", &weechat_lua_api_window_get_integer },
|
||||
{ "window_get_string", &weechat_lua_api_window_get_string },
|
||||
|
@ -4265,6 +4265,39 @@ XS (XS_weechat_api_buffer_set)
|
||||
PERL_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::buffer_string_replace_local_var: replace local variables ($var) in a string,
|
||||
* using value of local variables
|
||||
*/
|
||||
|
||||
XS (XS_weechat_api_buffer_string_replace_local_var)
|
||||
{
|
||||
char *buffer, *string, *result;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var");
|
||||
PERL_RETURN_ERROR;
|
||||
}
|
||||
|
||||
if (items < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var");
|
||||
PERL_RETURN_ERROR;
|
||||
}
|
||||
|
||||
buffer = SvPV (ST (0), PL_na);
|
||||
string = SvPV (ST (1), PL_na);
|
||||
|
||||
result = weechat_buffer_string_replace_local_var (script_str2ptr (buffer), string);
|
||||
|
||||
PERL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::current_window: get current window
|
||||
*/
|
||||
@ -5837,6 +5870,7 @@ weechat_perl_api_init (pTHX)
|
||||
newXS ("weechat::buffer_get_string", XS_weechat_api_buffer_get_string, "weechat");
|
||||
newXS ("weechat::buffer_get_pointer", XS_weechat_api_buffer_get_pointer, "weechat");
|
||||
newXS ("weechat::buffer_set", XS_weechat_api_buffer_set, "weechat");
|
||||
newXS ("weechat::buffer_string_replace_local_var", XS_weechat_api_buffer_string_replace_local_var, "weechat");
|
||||
newXS ("weechat::current_window", XS_weechat_api_current_window, "weechat");
|
||||
newXS ("weechat::window_get_integer", XS_weechat_api_window_get_integer, "weechat");
|
||||
newXS ("weechat::window_get_string", XS_weechat_api_window_get_string, "weechat");
|
||||
|
@ -4482,6 +4482,40 @@ weechat_python_api_buffer_set (PyObject *self, PyObject *args)
|
||||
PYTHON_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_buffer_string_replace_local_var: replace local variables ($var) in a string,
|
||||
* using value of local variables
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_buffer_string_replace_local_var (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *buffer, *string, *result;
|
||||
PyObject *object;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
buffer = NULL;
|
||||
string = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "ss", &buffer, &string))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
|
||||
result = weechat_buffer_string_replace_local_var (script_str2ptr (buffer), string);
|
||||
|
||||
PYTHON_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_current_window: get current window
|
||||
*/
|
||||
@ -6126,6 +6160,7 @@ PyMethodDef weechat_python_funcs[] =
|
||||
{ "buffer_get_string", &weechat_python_api_buffer_get_string, METH_VARARGS, "" },
|
||||
{ "buffer_get_pointer", &weechat_python_api_buffer_get_pointer, METH_VARARGS, "" },
|
||||
{ "buffer_set", &weechat_python_api_buffer_set, METH_VARARGS, "" },
|
||||
{ "buffer_string_replace_local_var", &weechat_python_api_buffer_string_replace_local_var, METH_VARARGS, "" },
|
||||
{ "current_window", &weechat_python_api_current_window, METH_VARARGS, "" },
|
||||
{ "window_get_integer", &weechat_python_api_window_get_integer, METH_VARARGS, "" },
|
||||
{ "window_get_string", &weechat_python_api_window_get_string, METH_VARARGS, "" },
|
||||
|
@ -5154,6 +5154,46 @@ weechat_ruby_api_buffer_set (VALUE class, VALUE buffer, VALUE property,
|
||||
RUBY_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_buffer_string_replace_local_var: replace local variables ($var) in a string,
|
||||
* using value of local variables
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_buffer_string_replace_local_var (VALUE class, VALUE buffer, VALUE string)
|
||||
{
|
||||
char *c_buffer, *c_string, *result;
|
||||
VALUE return_value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var");
|
||||
RUBY_RETURN_ERROR;
|
||||
}
|
||||
|
||||
c_buffer = NULL;
|
||||
c_string = NULL;
|
||||
|
||||
if (NIL_P (buffer) || NIL_P (string))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var");
|
||||
RUBY_RETURN_ERROR;
|
||||
}
|
||||
|
||||
Check_Type (buffer, T_STRING);
|
||||
Check_Type (string, T_STRING);
|
||||
|
||||
c_buffer = STR2CSTR (buffer);
|
||||
c_string = STR2CSTR (string);
|
||||
|
||||
result = weechat_buffer_string_replace_local_var (script_str2ptr (c_buffer), c_string);
|
||||
|
||||
RUBY_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_current_window: get current window
|
||||
*/
|
||||
@ -7054,6 +7094,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
rb_define_module_function (ruby_mWeechat, "buffer_get_string", &weechat_ruby_api_buffer_get_string, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "buffer_get_pointer", &weechat_ruby_api_buffer_get_pointer, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "buffer_set", &weechat_ruby_api_buffer_set, 3);
|
||||
rb_define_module_function (ruby_mWeechat, "buffer_string_replace_local_var", &weechat_ruby_api_buffer_string_replace_local_var, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "current_window", &weechat_ruby_api_current_window, 0);
|
||||
rb_define_module_function (ruby_mWeechat, "window_get_integer", &weechat_ruby_api_window_get_integer, 2);
|
||||
rb_define_module_function (ruby_mWeechat, "window_get_string", &weechat_ruby_api_window_get_string, 2);
|
||||
|
@ -4777,6 +4777,42 @@ weechat_tcl_api_buffer_set (ClientData clientData, Tcl_Interp *interp,
|
||||
TCL_RETURN_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_buffer_string_replace_local_var: replace local variables ($var) in a string,
|
||||
* using value of local variables
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_buffer_string_replace_local_var (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *buffer, *string, *result;
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
|
||||
if (!tcl_current_script)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var");
|
||||
TCL_RETURN_ERROR;
|
||||
}
|
||||
|
||||
if (objc < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_string_replace_local_var");
|
||||
TCL_RETURN_ERROR;
|
||||
}
|
||||
|
||||
buffer = Tcl_GetStringFromObj (objv[1], &i);
|
||||
string = Tcl_GetStringFromObj (objv[2], &i);
|
||||
|
||||
result = weechat_buffer_string_replace_local_var (script_str2ptr (buffer), string);
|
||||
|
||||
TCL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_current_window: get current window
|
||||
*/
|
||||
@ -6683,6 +6719,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
|
||||
weechat_tcl_api_buffer_get_pointer, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::buffer_set",
|
||||
weechat_tcl_api_buffer_set, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::buffer_string_replace_local_var",
|
||||
weechat_tcl_api_buffer_string_replace_local_var, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::current_window",
|
||||
weechat_tcl_api_current_window, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::window_get_integer",
|
||||
|
Loading…
x
Reference in New Issue
Block a user