1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-25 20:36:38 +02:00

core: use buffer pointer instead of window in input functions, add new function window_search_with_buffer in plugin API

This commit is contained in:
Sebastien Helleu
2011-04-13 20:25:26 +02:00
parent 7d7eeceb89
commit 7673a700b3
16 changed files with 789 additions and 407 deletions
+37
View File
@@ -5302,6 +5302,42 @@ weechat_lua_api_current_window (lua_State *L)
LUA_RETURN_STRING_FREE(result);
}
/*
* 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 },
@@ -4822,6 +4822,36 @@ XS (XS_weechat_api_current_window)
PERL_RETURN_STRING_FREE(result);
}
/*
* 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");
@@ -5080,6 +5080,39 @@ weechat_python_api_current_window (PyObject *self, PyObject *args)
PYTHON_RETURN_STRING_FREE(result);
}
/*
* 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, "" },
@@ -5497,6 +5497,41 @@ weechat_ruby_api_current_window (VALUE class)
RUBY_RETURN_STRING_FREE(result);
}
/*
* 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);
+37
View File
@@ -5390,6 +5390,41 @@ weechat_tcl_api_current_window (ClientData clientData, Tcl_Interp *interp,
TCL_RETURN_STRING_FREE(result);
}
/*
* 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",