diff options
Diffstat (limited to 'src/plugins/scripts')
-rw-r--r-- | src/plugins/scripts/lua/weechat-lua-api.c | 104 | ||||
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl-api.c | 85 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python-api.c | 95 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby-api.c | 106 | ||||
-rw-r--r-- | src/plugins/scripts/tcl/weechat-tcl-api.c | 104 |
5 files changed, 494 insertions, 0 deletions
diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c index 5f3852128..2143fbfdc 100644 --- a/src/plugins/scripts/lua/weechat-lua-api.c +++ b/src/plugins/scripts/lua/weechat-lua-api.c @@ -4646,6 +4646,29 @@ weechat_lua_api_buffer_search (lua_State *L) } /* + * weechat_lua_api_buffer_search_main: search main buffer (WeeChat core buffer) + */ + +static int +weechat_lua_api_buffer_search_main (lua_State *L) +{ + char *result; + + /* make C compiler happy */ + (void) L; + + if (!lua_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "buffer_search_main"); + LUA_RETURN_EMPTY; + } + + result = script_ptr2str (weechat_buffer_search_main ()); + + LUA_RETURN_STRING_FREE(result); +} + +/* * weechat_lua_api_current_buffer: get current buffer */ @@ -4743,6 +4766,84 @@ weechat_lua_api_buffer_close (lua_State *L) } /* + * weechat_lua_api_buffer_merge: merge a buffer to another buffer + */ + +static int +weechat_lua_api_buffer_merge (lua_State *L) +{ + const char *buffer, *target_buffer; + int n; + + /* make C compiler happy */ + (void) L; + + if (!lua_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "buffer_merge"); + LUA_RETURN_ERROR; + } + + buffer = NULL; + target_buffer = NULL; + + n = lua_gettop (lua_current_interpreter); + + if (n < 2) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "buffer_merge"); + LUA_RETURN_ERROR; + } + + buffer = lua_tostring (lua_current_interpreter, -2); + target_buffer = lua_tostring (lua_current_interpreter, -1); + + weechat_buffer_merge (script_str2ptr (buffer), + script_str2ptr (target_buffer)); + + LUA_RETURN_OK; +} + +/* + * weechat_lua_api_buffer_unmerge: unmerge a buffer from a group of merged + * buffers + */ + +static int +weechat_lua_api_buffer_unmerge (lua_State *L) +{ + const char *buffer; + int n, number; + + /* make C compiler happy */ + (void) L; + + if (!lua_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "buffer_unmerge"); + LUA_RETURN_ERROR; + } + + buffer = NULL; + number = 0; + + n = lua_gettop (lua_current_interpreter); + + if (n < 2) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "buffer_unmerge"); + LUA_RETURN_ERROR; + } + + buffer = lua_tostring (lua_current_interpreter, -2); + number = lua_tonumber (lua_current_interpreter, -1); + + weechat_buffer_unmerge (script_str2ptr (buffer), number); + + LUA_RETURN_OK; +} + +/* * weechat_lua_api_buffer_get_integer: get a buffer property as integer */ @@ -7114,9 +7215,12 @@ const struct luaL_reg weechat_lua_api_funcs[] = { { "unhook_all", &weechat_lua_api_unhook_all }, { "buffer_new", &weechat_lua_api_buffer_new }, { "buffer_search", &weechat_lua_api_buffer_search }, + { "buffer_search_main", &weechat_lua_api_buffer_search_main }, { "current_buffer", &weechat_lua_api_current_buffer }, { "buffer_clear", &weechat_lua_api_buffer_clear }, { "buffer_close", &weechat_lua_api_buffer_close }, + { "buffer_merge", &weechat_lua_api_buffer_merge }, + { "buffer_unmerge", &weechat_lua_api_buffer_unmerge }, { "buffer_get_integer", &weechat_lua_api_buffer_get_integer }, { "buffer_get_string", &weechat_lua_api_buffer_get_string }, { "buffer_get_pointer", &weechat_lua_api_buffer_get_pointer }, diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c index f3fe2fe37..baf1c428e 100644 --- a/src/plugins/scripts/perl/weechat-perl-api.c +++ b/src/plugins/scripts/perl/weechat-perl-api.c @@ -3965,6 +3965,30 @@ static XS (XS_weechat_api_buffer_search) } /* + * weechat::buffer_search_main: search main buffer (WeeChat core buffer) + */ + +static XS (XS_weechat_api_buffer_search_main) +{ + char *result; + dXSARGS; + + /* make C compiler happy */ + (void) items; + (void) cv; + + if (!perl_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "buffer_search_main"); + PERL_RETURN_EMPTY; + } + + result = script_ptr2str (weechat_buffer_search_main ()); + + PERL_RETURN_STRING_FREE(result); +} + +/* * weechat::current_buffer: get current buffer */ @@ -4047,6 +4071,64 @@ static XS (XS_weechat_api_buffer_close) } /* + * weechat::buffer_merge: merge a buffer to another buffer + */ + +static XS (XS_weechat_api_buffer_merge) +{ + dXSARGS; + + /* make C compiler happy */ + (void) cv; + + if (!perl_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "buffer_merge"); + PERL_RETURN_ERROR; + } + + if (items < 2) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "buffer_merge"); + PERL_RETURN_ERROR; + } + + weechat_buffer_merge (script_str2ptr (SvPV (ST (0), PL_na)), /* buffer */ + script_str2ptr (SvPV (ST (1), PL_na))); /* target_buffer */ + + PERL_RETURN_OK; +} + +/* + * weechat::buffer_unmerge: unmerge a buffer from group of merged buffers + */ + +static XS (XS_weechat_api_buffer_unmerge) +{ + dXSARGS; + + /* make C compiler happy */ + (void) cv; + + if (!perl_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "buffer_unmerge"); + PERL_RETURN_ERROR; + } + + if (items < 2) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "buffer_unmerge"); + PERL_RETURN_ERROR; + } + + weechat_buffer_unmerge (script_str2ptr (SvPV (ST (0), PL_na)), /* buffer */ + SvIV (ST (1))); /* number */ + + PERL_RETURN_OK; +} + +/* * weechat::buffer_get_integer: get a buffer property as integer */ @@ -5709,9 +5791,12 @@ weechat_perl_api_init (pTHX) newXS ("weechat::unhook_all", XS_weechat_api_unhook_all, "weechat"); newXS ("weechat::buffer_new", XS_weechat_api_buffer_new, "weechat"); newXS ("weechat::buffer_search", XS_weechat_api_buffer_search, "weechat"); + newXS ("weechat::buffer_search_main", XS_weechat_api_buffer_search_main, "weechat"); newXS ("weechat::current_buffer", XS_weechat_api_current_buffer, "weechat"); newXS ("weechat::buffer_clear", XS_weechat_api_buffer_clear, "weechat"); newXS ("weechat::buffer_close", XS_weechat_api_buffer_close, "weechat"); + newXS ("weechat::buffer_merge", XS_weechat_api_buffer_merge, "weechat"); + newXS ("weechat::buffer_unmerge", XS_weechat_api_buffer_unmerge, "weechat"); newXS ("weechat::buffer_get_integer", XS_weechat_api_buffer_get_integer, "weechat"); newXS ("weechat::buffer_get_string", XS_weechat_api_buffer_get_string, "weechat"); newXS ("weechat::buffer_get_pointer", XS_weechat_api_buffer_get_pointer, "weechat"); diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c index 0c58130b1..b5919c97f 100644 --- a/src/plugins/scripts/python/weechat-python-api.c +++ b/src/plugins/scripts/python/weechat-python-api.c @@ -4162,6 +4162,31 @@ weechat_python_api_buffer_search (PyObject *self, PyObject *args) } /* + * weechat_python_api_buffer_search_main: search main buffer (WeeChat core buffer) + */ + +static PyObject * +weechat_python_api_buffer_search_main (PyObject *self, PyObject *args) +{ + char *result; + PyObject *object; + + /* make C compiler happy */ + (void) self; + (void) args; + + if (!python_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_search_main"); + PYTHON_RETURN_EMPTY; + } + + result = script_ptr2str (weechat_buffer_search_main ()); + + PYTHON_RETURN_STRING_FREE(result); +} + +/* * weechat_python_api_current_buffer: get current buffer */ @@ -4251,6 +4276,73 @@ weechat_python_api_buffer_close (PyObject *self, PyObject *args) } /* + * weechat_python_api_buffer_merge: merge a buffer to another buffer + */ + +static PyObject * +weechat_python_api_buffer_merge (PyObject *self, PyObject *args) +{ + char *buffer, *target_buffer; + + /* make C compiler happy */ + (void) self; + + if (!python_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_merge"); + PYTHON_RETURN_ERROR; + } + + buffer = NULL; + target_buffer = NULL; + + if (!PyArg_ParseTuple (args, "ss", &buffer, &target_buffer)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_merge"); + PYTHON_RETURN_ERROR; + } + + weechat_buffer_merge (script_str2ptr (buffer), + script_str2ptr (target_buffer)); + + PYTHON_RETURN_OK; +} + +/* + * weechat_python_api_buffer_unmerge: unmerge a buffer from group of merged + * buffers + */ + +static PyObject * +weechat_python_api_buffer_unmerge (PyObject *self, PyObject *args) +{ + char *buffer; + int number; + + /* make C compiler happy */ + (void) self; + + if (!python_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "buffer_unmerge"); + PYTHON_RETURN_ERROR; + } + + buffer = NULL; + number = 0; + + if (!PyArg_ParseTuple (args, "si", &buffer, &number)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "buffer_unmerge"); + PYTHON_RETURN_ERROR; + } + + weechat_buffer_unmerge (script_str2ptr (buffer), number); + + PYTHON_RETURN_OK; +} + +/* * weechat_python_api_buffer_get_integer get a buffer property as integer */ @@ -5987,9 +6079,12 @@ PyMethodDef weechat_python_funcs[] = { "unhook_all", &weechat_python_api_unhook_all, METH_VARARGS, "" }, { "buffer_new", &weechat_python_api_buffer_new, METH_VARARGS, "" }, { "buffer_search", &weechat_python_api_buffer_search, METH_VARARGS, "" }, + { "buffer_search_main", &weechat_python_api_buffer_search_main, METH_VARARGS, "" }, { "current_buffer", &weechat_python_api_current_buffer, METH_VARARGS, "" }, { "buffer_clear", &weechat_python_api_buffer_clear, METH_VARARGS, "" }, { "buffer_close", &weechat_python_api_buffer_close, METH_VARARGS, "" }, + { "buffer_merge", &weechat_python_api_buffer_merge, METH_VARARGS, "" }, + { "buffer_unmerge", &weechat_python_api_buffer_unmerge, METH_VARARGS, "" }, { "buffer_get_integer", &weechat_python_api_buffer_get_integer, METH_VARARGS, "" }, { "buffer_get_string", &weechat_python_api_buffer_get_string, METH_VARARGS, "" }, { "buffer_get_pointer", &weechat_python_api_buffer_get_pointer, METH_VARARGS, "" }, diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c index 266f45497..e7f49d004 100644 --- a/src/plugins/scripts/ruby/weechat-ruby-api.c +++ b/src/plugins/scripts/ruby/weechat-ruby-api.c @@ -4800,6 +4800,30 @@ weechat_ruby_api_buffer_search (VALUE class, VALUE plugin, VALUE name) } /* + * weechat_ruby_api_buffer_search_main: search main buffer (WeeChat core buffer) + */ + +static VALUE +weechat_ruby_api_buffer_search_main (VALUE class) +{ + char *result; + VALUE return_value; + + /* make C compiler happy */ + (void) class; + + if (!ruby_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "buffer_search_main"); + RUBY_RETURN_EMPTY; + } + + result = script_ptr2str (weechat_buffer_search_main ()); + + RUBY_RETURN_STRING_FREE(result); +} + +/* * weechat_ruby_api_current_buffer: get current buffer */ @@ -4896,6 +4920,85 @@ weechat_ruby_api_buffer_close (VALUE class, VALUE buffer) } /* + * weechat_ruby_api_buffer_merge: merge a buffer to another buffer + */ + +static VALUE +weechat_ruby_api_buffer_merge (VALUE class, VALUE buffer, VALUE target_buffer) +{ + char *c_buffer, *c_target_buffer; + + /* make C compiler happy */ + (void) class; + + if (!ruby_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "buffer_merge"); + RUBY_RETURN_ERROR; + } + + c_buffer = NULL; + c_target_buffer = NULL; + + if (NIL_P (buffer) || NIL_P (target_buffer)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "buffer_merge"); + RUBY_RETURN_ERROR; + } + + Check_Type (buffer, T_STRING); + Check_Type (target_buffer, T_STRING); + + c_buffer = STR2CSTR (buffer); + c_target_buffer = STR2CSTR (target_buffer); + + weechat_buffer_merge (script_str2ptr (c_buffer), + script_str2ptr (c_target_buffer)); + + RUBY_RETURN_OK; +} + +/* + * weechat_ruby_api_buffer_unmerge: unmerge a buffer from a group of merged + * buffers + */ + +static VALUE +weechat_ruby_api_buffer_unmerge (VALUE class, VALUE buffer, VALUE number) +{ + char *c_buffer; + int c_number; + + /* make C compiler happy */ + (void) class; + + if (!ruby_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "buffer_unmerge"); + RUBY_RETURN_ERROR; + } + + c_buffer = NULL; + c_number = 0; + + if (NIL_P (buffer) || NIL_P (number)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "buffer_unmerge"); + RUBY_RETURN_ERROR; + } + + Check_Type (buffer, T_STRING); + Check_Type (number, T_FIXNUM); + + c_buffer = STR2CSTR (buffer); + c_number = FIX2INT (number); + + weechat_buffer_unmerge (script_str2ptr (c_buffer), number); + + RUBY_RETURN_OK; +} + +/* * weechat_ruby_api_buffer_get_integer: get a buffer property as integer */ @@ -6902,9 +7005,12 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) rb_define_module_function (ruby_mWeechat, "unhook_all", &weechat_ruby_api_unhook_all, 0); rb_define_module_function (ruby_mWeechat, "buffer_new", &weechat_ruby_api_buffer_new, 5); rb_define_module_function (ruby_mWeechat, "buffer_search", &weechat_ruby_api_buffer_search, 2); + rb_define_module_function (ruby_mWeechat, "buffer_search_main", &weechat_ruby_api_buffer_search_main, 0); rb_define_module_function (ruby_mWeechat, "current_buffer", &weechat_ruby_api_current_buffer, 0); rb_define_module_function (ruby_mWeechat, "buffer_clear", &weechat_ruby_api_buffer_clear, 1); rb_define_module_function (ruby_mWeechat, "buffer_close", &weechat_ruby_api_buffer_close, 1); + rb_define_module_function (ruby_mWeechat, "buffer_merge", &weechat_ruby_api_buffer_merge, 2); + rb_define_module_function (ruby_mWeechat, "buffer_unmerge", &weechat_ruby_api_buffer_unmerge, 2); rb_define_module_function (ruby_mWeechat, "buffer_get_integer", &weechat_ruby_api_buffer_get_integer, 2); 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); diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c index afc4a388d..202710276 100644 --- a/src/plugins/scripts/tcl/weechat-tcl-api.c +++ b/src/plugins/scripts/tcl/weechat-tcl-api.c @@ -4440,6 +4440,33 @@ weechat_tcl_api_buffer_search (ClientData clientData, Tcl_Interp *interp, } /* + * weechat_tcl_api_buffer_search_main: search main buffer (WeeChat core buffer) + */ + +static int +weechat_tcl_api_buffer_search_main (ClientData clientData, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]) +{ + Tcl_Obj *objp; + char *result; + + /* make C compiler happy */ + (void) clientData; + (void) objc; + (void) objv; + + if (!tcl_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_search_main"); + TCL_RETURN_EMPTY; + } + + result = script_ptr2str (weechat_buffer_search_main ()); + + TCL_RETURN_STRING_FREE(result); +} + +/* * weechat_tcl_api_current_buffer: get current buffer */ @@ -4531,6 +4558,77 @@ weechat_tcl_api_buffer_close (ClientData clientData, Tcl_Interp *interp, } /* + * weechat_tcl_api_buffer_merge: merge a buffer to another buffer + */ + +static int +weechat_tcl_api_buffer_merge (ClientData clientData, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]) +{ + Tcl_Obj *objp; + int i; + + /* make C compiler happy */ + (void) clientData; + + if (!tcl_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_merge"); + TCL_RETURN_ERROR; + } + + if (objc < 3) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_merge"); + TCL_RETURN_ERROR; + } + + weechat_buffer_merge (script_str2ptr (Tcl_GetStringFromObj (objv[1], &i)), /* buffer */ + script_str2ptr (Tcl_GetStringFromObj (objv[2], &i))); /* target_buffer */ + + TCL_RETURN_OK; +} + +/* + * weechat_tcl_api_buffer_unmerge: unmerge a buffer from a group of merged + * buffers + */ + +static int +weechat_tcl_api_buffer_unmerge (ClientData clientData, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]) +{ + Tcl_Obj *objp; + int i, number; + + /* make C compiler happy */ + (void) clientData; + + if (!tcl_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "buffer_unmerge"); + TCL_RETURN_ERROR; + } + + if (objc < 3) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_unmerge"); + TCL_RETURN_ERROR; + } + + if (Tcl_GetIntFromObj (interp, objv[2], &number) != TCL_OK) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "buffer_unmerge"); + TCL_RETURN_ERROR; + } + + weechat_buffer_unmerge (script_str2ptr (Tcl_GetStringFromObj (objv[1], &i)), + number); + + TCL_RETURN_OK; +} + +/* * weechat_tcl_api_buffer_get_integer: get a buffer property as integer */ @@ -6528,12 +6626,18 @@ void weechat_tcl_api_init (Tcl_Interp *interp) weechat_tcl_api_buffer_new, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp, "weechat::buffer_search", weechat_tcl_api_buffer_search, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); + Tcl_CreateObjCommand (interp, "weechat::buffer_search_main", + weechat_tcl_api_buffer_search_main, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp, "weechat::current_buffer", weechat_tcl_api_current_buffer, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp, "weechat::buffer_clear", weechat_tcl_api_buffer_clear, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp, "weechat::buffer_close", weechat_tcl_api_buffer_close, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); + Tcl_CreateObjCommand (interp, "weechat::buffer_merge", + weechat_tcl_api_buffer_merge, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); + Tcl_CreateObjCommand (interp, "weechat::buffer_unmerge", + weechat_tcl_api_buffer_unmerge, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp, "weechat::buffer_get_integer", weechat_tcl_api_buffer_get_integer, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp, "weechat::buffer_get_string", |