diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2008-11-11 13:36:31 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2008-11-11 13:36:31 +0100 |
commit | 1214f10526277d856816ce4fbb5a6caf7c4e2749 (patch) | |
tree | da9e2eee98bef0ee7c92bcb4d2f0c4e3d5426d55 /src/plugins/scripts | |
parent | 60f7b939bec9e07b1fd1d07afe6160aa7afa51e0 (diff) | |
download | weechat-1214f10526277d856816ce4fbb5a6caf7c4e2749.zip |
Add function "current_buffer" in script API
Diffstat (limited to 'src/plugins/scripts')
-rw-r--r-- | src/plugins/scripts/lua/weechat-lua-api.c | 24 | ||||
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl-api.c | 25 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python-api.c | 26 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby-api.c | 25 | ||||
-rw-r--r-- | src/plugins/scripts/tcl/weechat-tcl-api.c | 29 |
5 files changed, 129 insertions, 0 deletions
diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c index ce608643a..5f79c6e16 100644 --- a/src/plugins/scripts/lua/weechat-lua-api.c +++ b/src/plugins/scripts/lua/weechat-lua-api.c @@ -3737,6 +3737,29 @@ weechat_lua_api_buffer_search (lua_State *L) } /* + * weechat_lua_api_current_buffer: get current buffer + */ + +static int +weechat_lua_api_current_buffer (lua_State *L) +{ + char *result; + + /* make C compiler happy */ + (void) L; + + if (!lua_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("current_buffer"); + LUA_RETURN_EMPTY; + } + + result = script_ptr2str (weechat_current_buffer); + + LUA_RETURN_STRING_FREE(result); +} + +/* * weechat_lua_api_buffer_clear: clear a buffer */ @@ -5758,6 +5781,7 @@ 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 }, + { "current_buffer", &weechat_lua_api_current_buffer }, { "buffer_clear", &weechat_lua_api_buffer_clear }, { "buffer_close", &weechat_lua_api_buffer_close }, { "buffer_get_integer", &weechat_lua_api_buffer_get_integer }, diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c index 3c5fc77cb..7f63d19f4 100644 --- a/src/plugins/scripts/perl/weechat-perl-api.c +++ b/src/plugins/scripts/perl/weechat-perl-api.c @@ -3152,6 +3152,30 @@ static XS (XS_weechat_api_buffer_search) } /* + * weechat::current_buffer: get current buffer + */ + +static XS (XS_weechat_api_current_buffer) +{ + char *result; + dXSARGS; + + /* make C compiler happy */ + (void) items; + (void) cv; + + if (!perl_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("current_buffer"); + PERL_RETURN_EMPTY; + } + + result = script_ptr2str (weechat_current_buffer); + + PERL_RETURN_STRING_FREE(result); +} + +/* * weechat::buffer_clear: clear a buffer */ @@ -4503,6 +4527,7 @@ 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::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_get_integer", XS_weechat_api_buffer_get_integer, "weechat"); diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c index ee989cf6e..dd30e946a 100644 --- a/src/plugins/scripts/python/weechat-python-api.c +++ b/src/plugins/scripts/python/weechat-python-api.c @@ -3335,6 +3335,31 @@ weechat_python_api_buffer_search (PyObject *self, PyObject *args) } /* + * weechat_python_api_current_buffer: get current buffer + */ + +static PyObject * +weechat_python_api_current_buffer (PyObject *self, PyObject *args) +{ + char *result; + PyObject *object; + + /* make C compiler happy */ + (void) self; + (void) args; + + if (!python_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("current_buffer"); + PYTHON_RETURN_EMPTY; + } + + result = script_ptr2str (weechat_current_buffer); + + PYTHON_RETURN_STRING_FREE(result); +} + +/* * weechat_python_api_buffer_clear: clear a buffer */ @@ -4778,6 +4803,7 @@ 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, "" }, + { "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_get_integer", &weechat_python_api_buffer_get_integer, METH_VARARGS, "" }, diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c index 55cc44a6e..956cadbb9 100644 --- a/src/plugins/scripts/ruby/weechat-ruby-api.c +++ b/src/plugins/scripts/ruby/weechat-ruby-api.c @@ -3819,6 +3819,30 @@ weechat_ruby_api_buffer_search (VALUE class, VALUE plugin, VALUE name) } /* + * weechat_ruby_api_current_buffer: get current buffer + */ + +static VALUE +weechat_ruby_api_current_buffer (VALUE class) +{ + char *result; + VALUE return_value; + + /* make C compiler happy */ + (void) class; + + if (!ruby_current_script) + { + WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("current_buffer"); + RUBY_RETURN_EMPTY; + } + + result = script_ptr2str (weechat_current_buffer); + + RUBY_RETURN_STRING_FREE(result); +} + +/* * weechat_ruby_api_buffer_clear: clear a buffer */ @@ -5500,6 +5524,7 @@ 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, 3); rb_define_module_function (ruby_mWeechat, "buffer_search", &weechat_ruby_api_buffer_search, 2); + 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_get_integer", &weechat_ruby_api_buffer_get_integer, 2); diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c index 7c0f4da6c..e12dc4e44 100644 --- a/src/plugins/scripts/tcl/weechat-tcl-api.c +++ b/src/plugins/scripts/tcl/weechat-tcl-api.c @@ -3580,6 +3580,33 @@ weechat_tcl_api_buffer_search (ClientData clientData, Tcl_Interp *interp, } /* + * weechat_tcl_api_current_buffer: get current buffer + */ + +static int +weechat_tcl_api_current_buffer (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_INITIALIZED("current_buffer"); + TCL_RETURN_EMPTY; + } + + result = script_ptr2str (weechat_current_buffer); + + TCL_RETURN_STRING_FREE(result); +} + +/* * weechat_tcl_api_buffer_clear: clear a buffer */ @@ -5230,6 +5257,8 @@ 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::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", |