mirror of
https://github.com/weechat/weechat.git
synced 2026-06-29 14:26:39 +02:00
Add function "buffer_match_list" in plugin API
This commit is contained in:
@@ -5243,6 +5243,42 @@ weechat_lua_api_buffer_string_replace_local_var (lua_State *L)
|
||||
LUA_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_buffer_match_list: return 1 if buffer matches list of buffers
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_buffer_match_list (lua_State *L)
|
||||
{
|
||||
const char *buffer, *string;
|
||||
int n, value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) L;
|
||||
|
||||
if (!lua_current_script || !lua_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "buffer_match_list");
|
||||
LUA_RETURN_INT(0);
|
||||
}
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "buffer_match_list");
|
||||
LUA_RETURN_INT(0);
|
||||
}
|
||||
|
||||
buffer = lua_tostring (lua_current_interpreter, -2);
|
||||
string = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
value = weechat_buffer_match_list (script_str2ptr (buffer),
|
||||
string);
|
||||
|
||||
LUA_RETURN_INT(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_current_window: get current window
|
||||
*/
|
||||
@@ -7769,6 +7805,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
|
||||
{ "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 },
|
||||
{ "buffer_match_list", &weechat_lua_api_buffer_match_list },
|
||||
{ "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 },
|
||||
|
||||
@@ -4765,6 +4765,39 @@ XS (XS_weechat_api_buffer_string_replace_local_var)
|
||||
PERL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::buffer_match_list: return 1 if buffer matches list of buffers
|
||||
*/
|
||||
|
||||
XS (XS_weechat_api_buffer_match_list)
|
||||
{
|
||||
char *buffer, *string;
|
||||
int value;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script || !perl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "buffer_match_list");
|
||||
PERL_RETURN_INT(0);
|
||||
}
|
||||
|
||||
if (items < 2)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "buffer_match_list");
|
||||
PERL_RETURN_INT(0);
|
||||
}
|
||||
|
||||
buffer = SvPV (ST (0), PL_na);
|
||||
string = SvPV (ST (1), PL_na);
|
||||
|
||||
value = weechat_buffer_match_list (script_str2ptr (buffer), string);
|
||||
|
||||
PERL_RETURN_INT(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::current_window: get current window
|
||||
*/
|
||||
@@ -6707,6 +6740,7 @@ weechat_perl_api_init (pTHX)
|
||||
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::buffer_match_list", XS_weechat_api_buffer_match_list, "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");
|
||||
|
||||
@@ -4853,7 +4853,7 @@ weechat_python_api_buffer_unmerge (PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_buffer_get_integer get a buffer property as integer
|
||||
* weechat_python_api_buffer_get_integer: get a buffer property as integer
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
@@ -5021,6 +5021,40 @@ weechat_python_api_buffer_string_replace_local_var (PyObject *self, PyObject *ar
|
||||
PYTHON_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_buffer_match_list: return 1 if buffer matches list of
|
||||
* buffers
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_buffer_match_list (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *buffer, *string;
|
||||
int value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) self;
|
||||
|
||||
if (!python_current_script || !python_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_match_list");
|
||||
PYTHON_RETURN_INT(0);
|
||||
}
|
||||
|
||||
buffer = NULL;
|
||||
string = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "ss", &buffer, &string))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_match_list");
|
||||
PYTHON_RETURN_INT(0);
|
||||
}
|
||||
|
||||
value = weechat_buffer_match_list (script_str2ptr (buffer), string);
|
||||
|
||||
PYTHON_RETURN_INT(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_current_window: get current window
|
||||
*/
|
||||
@@ -7040,6 +7074,7 @@ PyMethodDef weechat_python_funcs[] =
|
||||
{ "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, "" },
|
||||
{ "buffer_match_list", &weechat_python_api_buffer_match_list, 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, "" },
|
||||
|
||||
@@ -5436,6 +5436,43 @@ weechat_ruby_api_buffer_string_replace_local_var (VALUE class, VALUE buffer, VAL
|
||||
RUBY_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_buffer_match_list: return 1 if buffer matches list of buffers
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_buffer_match_list (VALUE class, VALUE buffer, VALUE string)
|
||||
{
|
||||
char *c_buffer, *c_string;
|
||||
int value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) class;
|
||||
|
||||
if (!ruby_current_script || !ruby_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "buffer_match_list");
|
||||
RUBY_RETURN_INT(0);
|
||||
}
|
||||
|
||||
if (NIL_P (buffer) || NIL_P (string))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "buffer_match_list");
|
||||
RUBY_RETURN_INT(0);
|
||||
}
|
||||
|
||||
Check_Type (buffer, T_STRING);
|
||||
Check_Type (string, T_STRING);
|
||||
|
||||
c_buffer = StringValuePtr (buffer);
|
||||
c_string = StringValuePtr (string);
|
||||
|
||||
value = weechat_buffer_match_list (script_str2ptr (c_buffer),
|
||||
c_string);
|
||||
|
||||
RUBY_RETURN_INT(value);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_current_window: get current window
|
||||
*/
|
||||
@@ -7706,6 +7743,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
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, "buffer_match_list", &weechat_ruby_api_buffer_match_list, 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);
|
||||
|
||||
@@ -5327,6 +5327,42 @@ weechat_tcl_api_buffer_string_replace_local_var (ClientData clientData, Tcl_Inte
|
||||
TCL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_buffer_match_list: return 1 if buffers matches list of buffers
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_buffer_match_list (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *buffer, *string;
|
||||
int result;
|
||||
int i;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) clientData;
|
||||
|
||||
if (!tcl_current_script || !tcl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_match_list");
|
||||
TCL_RETURN_INT(0);
|
||||
}
|
||||
|
||||
if (objc < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_match_list");
|
||||
TCL_RETURN_INT(0);
|
||||
}
|
||||
|
||||
buffer = Tcl_GetStringFromObj (objv[1], &i);
|
||||
string = Tcl_GetStringFromObj (objv[2], &i);
|
||||
|
||||
result = weechat_buffer_match_list (script_str2ptr (buffer), string);
|
||||
|
||||
TCL_RETURN_INT(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_current_window: get current window
|
||||
*/
|
||||
@@ -7650,6 +7686,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
|
||||
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::buffer_match_list",
|
||||
weechat_tcl_api_buffer_match_list, (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",
|
||||
|
||||
Reference in New Issue
Block a user