diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/plugin.c | 1 | ||||
-rw-r--r-- | src/plugins/scripts/lua/weechat-lua-api.c | 37 | ||||
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl-api.c | 31 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python-api.c | 34 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby-api.c | 36 | ||||
-rw-r--r-- | src/plugins/scripts/tcl/weechat-tcl-api.c | 37 | ||||
-rw-r--r-- | src/plugins/weechat-plugin.h | 5 |
7 files changed, 180 insertions, 1 deletions
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index 771488656..a17088f96 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -621,6 +621,7 @@ plugin_load (const char *filename) new_plugin->buffer_string_replace_local_var = &gui_buffer_string_replace_local_var; new_plugin->buffer_match_list = &gui_buffer_match_list; + new_plugin->window_search_with_buffer = &gui_window_search_with_buffer; new_plugin->window_get_integer = &gui_window_get_integer; new_plugin->window_get_string = &gui_window_get_string; new_plugin->window_get_pointer = &gui_window_get_pointer; diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c index f0b64af5d..286b4509b 100644 --- a/src/plugins/scripts/lua/weechat-lua-api.c +++ b/src/plugins/scripts/lua/weechat-lua-api.c @@ -5303,6 +5303,42 @@ weechat_lua_api_current_window (lua_State *L) } /* + * weechat_lua_api_window_search_with_buffer: search a window with buffer + * pointer + */ + +static int +weechat_lua_api_window_search_with_buffer (lua_State *L) +{ + const char *buffer; + char *result; + int n; + + /* make C compiler happy */ + (void) L; + + if (!lua_current_script || !lua_current_script->name) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "window_search_with_buffer"); + LUA_RETURN_EMPTY; + } + + n = lua_gettop (lua_current_interpreter); + + if (n < 1) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "window_search_with_buffer"); + LUA_RETURN_EMPTY; + } + + buffer = lua_tostring (lua_current_interpreter, -1); + + result = script_ptr2str (weechat_window_search_with_buffer (script_str2ptr (buffer))); + + LUA_RETURN_STRING_FREE(result); +} + +/* * weechat_lua_api_window_get_integer: get a window property as integer */ @@ -7807,6 +7843,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = { { "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_search_with_buffer", &weechat_lua_api_window_search_with_buffer }, { "window_get_integer", &weechat_lua_api_window_get_integer }, { "window_get_string", &weechat_lua_api_window_get_string }, { "window_get_pointer", &weechat_lua_api_window_get_pointer }, diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c index 6ea96f1bc..0219a8e08 100644 --- a/src/plugins/scripts/perl/weechat-perl-api.c +++ b/src/plugins/scripts/perl/weechat-perl-api.c @@ -4823,6 +4823,36 @@ XS (XS_weechat_api_current_window) } /* + * weechat::window_search_with_buffer: search a window with buffer pointer + */ + +XS (XS_weechat_api_window_search_with_buffer) +{ + char *result; + dXSARGS; + + /* make C compiler happy */ + (void) cv; + + if (!perl_current_script || !perl_current_script->name) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "window_search_with_buffer"); + PERL_RETURN_EMPTY; + } + + if (items < 1) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "window_search_with_buffer"); + PERL_RETURN_EMPTY; + } + + result = script_ptr2str (weechat_window_search_with_buffer (script_str2ptr (SvPV (ST (0), PL_na)))); + + PERL_RETURN_STRING_FREE(result); +} + + +/* * weechat::window_get_integer: get a window property as integer */ @@ -6742,6 +6772,7 @@ weechat_perl_api_init (pTHX) 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_search_with_buffer", XS_weechat_api_window_search_with_buffer, "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"); newXS ("weechat::window_get_pointer", XS_weechat_api_window_get_pointer, "weechat"); diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c index 58dd89af1..9a3924fc4 100644 --- a/src/plugins/scripts/python/weechat-python-api.c +++ b/src/plugins/scripts/python/weechat-python-api.c @@ -5081,6 +5081,39 @@ weechat_python_api_current_window (PyObject *self, PyObject *args) } /* + * weechat_python_api_window_search_with_buffer: search a window with buffer + * pointer + */ + +static PyObject * +weechat_python_api_window_search_with_buffer (PyObject *self, PyObject *args) +{ + char *buffer, *result; + PyObject *object; + + /* make C compiler happy */ + (void) self; + + if (!python_current_script || !python_current_script->name) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "window_search_with_buffer"); + PYTHON_RETURN_EMPTY; + } + + buffer = NULL; + + if (!PyArg_ParseTuple (args, "s", &buffer)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "window_search_with_buffer"); + PYTHON_RETURN_EMPTY; + } + + result = script_ptr2str (weechat_window_search_with_buffer (script_str2ptr (buffer))); + + PYTHON_RETURN_STRING_FREE(result); +} + +/* * weechat_python_api_window_get_integer get a window property as integer */ @@ -7076,6 +7109,7 @@ PyMethodDef weechat_python_funcs[] = { "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_search_with_buffer", &weechat_python_api_window_search_with_buffer, METH_VARARGS, "" }, { "window_get_integer", &weechat_python_api_window_get_integer, METH_VARARGS, "" }, { "window_get_string", &weechat_python_api_window_get_string, METH_VARARGS, "" }, { "window_get_pointer", &weechat_python_api_window_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 af75cad78..cfa82cf88 100644 --- a/src/plugins/scripts/ruby/weechat-ruby-api.c +++ b/src/plugins/scripts/ruby/weechat-ruby-api.c @@ -5498,6 +5498,41 @@ weechat_ruby_api_current_window (VALUE class) } /* + * weechat_ruby_api_window_search_with_buffer: search a window with buffer + * pointer + */ + +static VALUE +weechat_ruby_api_window_search_with_buffer (VALUE class, VALUE buffer) +{ + char *c_buffer, *result; + VALUE return_value; + + /* make C compiler happy */ + (void) class; + + if (!ruby_current_script || !ruby_current_script->name) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "window_search_with_buffer"); + RUBY_RETURN_EMPTY; + } + + if (NIL_P (buffer)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "window_search_with_buffer"); + RUBY_RETURN_EMPTY; + } + + Check_Type (buffer, T_STRING); + + c_buffer = StringValuePtr (buffer); + + result = script_ptr2str (weechat_window_search_with_buffer (script_str2ptr (c_buffer))); + + RUBY_RETURN_STRING_FREE(result); +} + +/* * weechat_ruby_api_window_get_integer: get a window property as integer */ @@ -7745,6 +7780,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) 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_search_with_buffer", &weechat_ruby_api_window_search_with_buffer, 1); 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); rb_define_module_function (ruby_mWeechat, "window_get_pointer", &weechat_ruby_api_window_get_pointer, 2); diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c index 9f870efb9..b36d72ad3 100644 --- a/src/plugins/scripts/tcl/weechat-tcl-api.c +++ b/src/plugins/scripts/tcl/weechat-tcl-api.c @@ -5391,6 +5391,41 @@ weechat_tcl_api_current_window (ClientData clientData, Tcl_Interp *interp, } /* + * weechat_tcl_api_window_search_with_buffer: search a window with buffer + * pointer + */ + +static int +weechat_tcl_api_window_search_with_buffer (ClientData clientData, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]) +{ + Tcl_Obj *objp; + char *buffer, *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, "window_search_with_buffer"); + TCL_RETURN_EMPTY; + } + + if (objc < 2) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "window_search_with_buffer"); + TCL_RETURN_EMPTY; + } + + buffer = Tcl_GetStringFromObj (objv[1], &i); + + result = script_ptr2str (weechat_window_search_with_buffer (script_str2ptr (buffer))); + + TCL_RETURN_STRING_FREE(result); +} + +/* * weechat_tcl_api_window_get_integer: get a window property as integer */ @@ -7690,6 +7725,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp) 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_search_with_buffer", + weechat_tcl_api_window_search_with_buffer, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp, "weechat::window_get_integer", weechat_tcl_api_window_get_integer, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp, "weechat::window_get_string", diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index 92b6c40b2..e580aa230 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -45,7 +45,7 @@ struct timeval; */ /* API version (used to check that plugin has same API and can be loaded) */ -#define WEECHAT_PLUGIN_API_VERSION "20110311-01" +#define WEECHAT_PLUGIN_API_VERSION "20110413-01" /* macros for defining plugin infos */ #define WEECHAT_PLUGIN_NAME(__name) \ @@ -600,6 +600,7 @@ struct t_weechat_plugin int (*buffer_match_list) (struct t_gui_buffer *buffer, const char *string); /* windows */ + struct t_gui_window *(*window_search_with_buffer) (struct t_gui_buffer *buffer); int (*window_get_integer) (struct t_gui_window *window, const char *property); const char *(*window_get_string) (struct t_gui_window *window, @@ -1260,6 +1261,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); weechat_plugin->buffer_match_list(__buffer, __string) /* windows */ +#define weechat_window_search_with_buffer(__buffer) \ + weechat_plugin->window_search_with_buffer(__buffer) #define weechat_window_get_integer(__window, __property) \ weechat_plugin->window_get_integer(__window, __property) #define weechat_window_get_string(__window, __property) \ |