mirror of
https://github.com/weechat/weechat.git
synced 2026-06-25 20:36:38 +02:00
core: add mouse support (task #5435), free cursor movement, hook_focus, fix bugs with key "^" (bug #32072, bug #21381), fix bugs with bar windows, completion and /buffer
New features and bugs fixed: - mouse support: new command /mouse, new option weechat.look.mouse, new key context "mouse" - free movement of cursor: new command /cursor, new key context "cursor" - new hook_focus (used by cursor and mouse) - info "cursor_mode" - bugs fixed with key "^" - allow plugin name in /buffer name - fix bugs with bar windows: do not create bar windows for hidden bars - fix completion bug when two words for completion are equal but with different case - automatic scroll direction in /bar scroll (x/y is now optional)
This commit is contained in:
@@ -4692,6 +4692,76 @@ weechat_lua_api_hook_infolist (lua_State *L)
|
||||
LUA_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_hook_focus_cb: callback for focus hooked
|
||||
*/
|
||||
|
||||
struct t_hashtable *
|
||||
weechat_lua_api_hook_focus_cb (void *data,
|
||||
struct t_hashtable *info)
|
||||
{
|
||||
struct t_script_callback *script_callback;
|
||||
void *lua_argv[2];
|
||||
char empty_arg[1] = { '\0' };
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
lua_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
|
||||
lua_argv[1] = info;
|
||||
|
||||
return (struct t_hashtable *)weechat_lua_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_HASHTABLE,
|
||||
script_callback->function,
|
||||
"sh", lua_argv);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_hook_focus: hook a focus
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_lua_api_hook_focus (lua_State *L)
|
||||
{
|
||||
const char *area, *function, *data;
|
||||
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, "hook_focus");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
n = lua_gettop (lua_current_interpreter);
|
||||
|
||||
if (n < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "hook_focus");
|
||||
LUA_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
area = lua_tostring (lua_current_interpreter, -3);
|
||||
function = lua_tostring (lua_current_interpreter, -2);
|
||||
data = lua_tostring (lua_current_interpreter, -1);
|
||||
|
||||
result = script_ptr2str (script_api_hook_focus (weechat_lua_plugin,
|
||||
lua_current_script,
|
||||
area,
|
||||
&weechat_lua_api_hook_focus_cb,
|
||||
function,
|
||||
data));
|
||||
|
||||
LUA_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_lua_api_unhook: unhook something
|
||||
*/
|
||||
@@ -8322,6 +8392,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
|
||||
{ "hook_info", &weechat_lua_api_hook_info },
|
||||
{ "hook_info_hashtable", &weechat_lua_api_hook_info_hashtable },
|
||||
{ "hook_infolist", &weechat_lua_api_hook_infolist },
|
||||
{ "hook_focus", &weechat_lua_api_hook_focus },
|
||||
{ "unhook", &weechat_lua_api_unhook },
|
||||
{ "unhook_all", &weechat_lua_api_unhook_all },
|
||||
{ "buffer_new", &weechat_lua_api_buffer_new },
|
||||
|
||||
@@ -4266,6 +4266,72 @@ XS (XS_weechat_api_hook_infolist)
|
||||
PERL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_perl_api_hook_focus_cb: callback for focus hooked
|
||||
*/
|
||||
|
||||
struct t_hashtable *
|
||||
weechat_perl_api_hook_focus_cb (void *data,
|
||||
struct t_hashtable *info)
|
||||
{
|
||||
struct t_script_callback *script_callback;
|
||||
void *perl_argv[2];
|
||||
char empty_arg[1] = { '\0' };
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
perl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
|
||||
perl_argv[1] = info;
|
||||
|
||||
return (struct t_hashtable *)weechat_perl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_HASHTABLE,
|
||||
script_callback->function,
|
||||
"sh", perl_argv);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::hook_focus: hook a focus
|
||||
*/
|
||||
|
||||
XS (XS_weechat_api_hook_focus)
|
||||
{
|
||||
char *result, *area, *function, *data;
|
||||
dXSARGS;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) cv;
|
||||
|
||||
if (!perl_current_script || !perl_current_script->name)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "hook_focus");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (items < 3)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "hook_focus");
|
||||
PERL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
area = SvPV (ST (0), PL_na);
|
||||
function = SvPV (ST (1), PL_na);
|
||||
data = SvPV (ST (2), PL_na);
|
||||
|
||||
result = script_ptr2str (script_api_hook_focus (weechat_perl_plugin,
|
||||
perl_current_script,
|
||||
area,
|
||||
&weechat_perl_api_hook_focus_cb,
|
||||
function,
|
||||
data));
|
||||
|
||||
PERL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat::unhook: unhook something
|
||||
*/
|
||||
@@ -7213,6 +7279,7 @@ weechat_perl_api_init (pTHX)
|
||||
newXS ("weechat::hook_info", XS_weechat_api_hook_info, "weechat");
|
||||
newXS ("weechat::hook_info_hashtable", XS_weechat_api_hook_info_hashtable, "weechat");
|
||||
newXS ("weechat::hook_infolist", XS_weechat_api_hook_infolist, "weechat");
|
||||
newXS ("weechat::hook_focus", XS_weechat_api_hook_focus, "weechat");
|
||||
newXS ("weechat::unhook", XS_weechat_api_unhook, "weechat");
|
||||
newXS ("weechat::unhook_all", XS_weechat_api_unhook_all, "weechat");
|
||||
newXS ("weechat::buffer_new", XS_weechat_api_buffer_new, "weechat");
|
||||
|
||||
@@ -3656,15 +3656,15 @@ weechat_python_api_hook_print (PyObject *self, PyObject *args)
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
result = script_ptr2str(script_api_hook_print (weechat_python_plugin,
|
||||
python_current_script,
|
||||
script_str2ptr (buffer),
|
||||
tags,
|
||||
message,
|
||||
strip_colors,
|
||||
&weechat_python_api_hook_print_cb,
|
||||
function,
|
||||
data));
|
||||
result = script_ptr2str (script_api_hook_print (weechat_python_plugin,
|
||||
python_current_script,
|
||||
script_str2ptr (buffer),
|
||||
tags,
|
||||
message,
|
||||
strip_colors,
|
||||
&weechat_python_api_hook_print_cb,
|
||||
function,
|
||||
data));
|
||||
|
||||
PYTHON_RETURN_STRING_FREE(result);
|
||||
}
|
||||
@@ -4012,12 +4012,12 @@ weechat_python_api_hook_config (PyObject *self, PyObject *args)
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
result = script_ptr2str(script_api_hook_config (weechat_python_plugin,
|
||||
python_current_script,
|
||||
option,
|
||||
&weechat_python_api_hook_config_cb,
|
||||
function,
|
||||
data));
|
||||
result = script_ptr2str (script_api_hook_config (weechat_python_plugin,
|
||||
python_current_script,
|
||||
option,
|
||||
&weechat_python_api_hook_config_cb,
|
||||
function,
|
||||
data));
|
||||
|
||||
PYTHON_RETURN_STRING_FREE(result);
|
||||
}
|
||||
@@ -4099,13 +4099,13 @@ weechat_python_api_hook_completion (PyObject *self, PyObject *args)
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
result = script_ptr2str(script_api_hook_completion (weechat_python_plugin,
|
||||
python_current_script,
|
||||
completion,
|
||||
description,
|
||||
&weechat_python_api_hook_completion_cb,
|
||||
function,
|
||||
data));
|
||||
result = script_ptr2str (script_api_hook_completion (weechat_python_plugin,
|
||||
python_current_script,
|
||||
completion,
|
||||
description,
|
||||
&weechat_python_api_hook_completion_cb,
|
||||
function,
|
||||
data));
|
||||
|
||||
PYTHON_RETURN_STRING_FREE(result);
|
||||
}
|
||||
@@ -4208,12 +4208,12 @@ weechat_python_api_hook_modifier (PyObject *self, PyObject *args)
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
result = script_ptr2str(script_api_hook_modifier (weechat_python_plugin,
|
||||
python_current_script,
|
||||
modifier,
|
||||
&weechat_python_api_hook_modifier_cb,
|
||||
function,
|
||||
data));
|
||||
result = script_ptr2str (script_api_hook_modifier (weechat_python_plugin,
|
||||
python_current_script,
|
||||
modifier,
|
||||
&weechat_python_api_hook_modifier_cb,
|
||||
function,
|
||||
data));
|
||||
|
||||
PYTHON_RETURN_STRING_FREE(result);
|
||||
}
|
||||
@@ -4313,14 +4313,14 @@ weechat_python_api_hook_info (PyObject *self, PyObject *args)
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
result = script_ptr2str(script_api_hook_info (weechat_python_plugin,
|
||||
python_current_script,
|
||||
info_name,
|
||||
description,
|
||||
args_description,
|
||||
&weechat_python_api_hook_info_cb,
|
||||
function,
|
||||
data));
|
||||
result = script_ptr2str (script_api_hook_info (weechat_python_plugin,
|
||||
python_current_script,
|
||||
info_name,
|
||||
description,
|
||||
args_description,
|
||||
&weechat_python_api_hook_info_cb,
|
||||
function,
|
||||
data));
|
||||
|
||||
PYTHON_RETURN_STRING_FREE(result);
|
||||
}
|
||||
@@ -4397,15 +4397,15 @@ weechat_python_api_hook_info_hashtable (PyObject *self, PyObject *args)
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
result = script_ptr2str(script_api_hook_info_hashtable (weechat_python_plugin,
|
||||
python_current_script,
|
||||
info_name,
|
||||
description,
|
||||
args_description,
|
||||
output_description,
|
||||
&weechat_python_api_hook_info_hashtable_cb,
|
||||
function,
|
||||
data));
|
||||
result = script_ptr2str (script_api_hook_info_hashtable (weechat_python_plugin,
|
||||
python_current_script,
|
||||
info_name,
|
||||
description,
|
||||
args_description,
|
||||
output_description,
|
||||
&weechat_python_api_hook_info_hashtable_cb,
|
||||
function,
|
||||
data));
|
||||
|
||||
PYTHON_RETURN_STRING_FREE(result);
|
||||
}
|
||||
@@ -4481,15 +4481,82 @@ weechat_python_api_hook_infolist (PyObject *self, PyObject *args)
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
result = script_ptr2str(script_api_hook_infolist (weechat_python_plugin,
|
||||
python_current_script,
|
||||
infolist_name,
|
||||
description,
|
||||
pointer_description,
|
||||
args_description,
|
||||
&weechat_python_api_hook_infolist_cb,
|
||||
function,
|
||||
data));
|
||||
result = script_ptr2str (script_api_hook_infolist (weechat_python_plugin,
|
||||
python_current_script,
|
||||
infolist_name,
|
||||
description,
|
||||
pointer_description,
|
||||
args_description,
|
||||
&weechat_python_api_hook_infolist_cb,
|
||||
function,
|
||||
data));
|
||||
|
||||
PYTHON_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_hook_focus_cb: callback for focus hooked
|
||||
*/
|
||||
|
||||
struct t_hashtable *
|
||||
weechat_python_api_hook_focus_cb (void *data,
|
||||
struct t_hashtable *info)
|
||||
{
|
||||
struct t_script_callback *script_callback;
|
||||
void *python_argv[2];
|
||||
char empty_arg[1] = { '\0' };
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
python_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
|
||||
python_argv[1] = info;
|
||||
|
||||
return (struct t_hashtable *)weechat_python_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_HASHTABLE,
|
||||
script_callback->function,
|
||||
"sh", python_argv);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_python_api_hook_focus: hook a focus
|
||||
*/
|
||||
|
||||
static PyObject *
|
||||
weechat_python_api_hook_focus (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *area, *function, *data, *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, "hook_focus");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
area = NULL;
|
||||
function = NULL;
|
||||
data = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "sss", &area, &function, &data))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "hook_focus");
|
||||
PYTHON_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
result = script_ptr2str (script_api_hook_focus (weechat_python_plugin,
|
||||
python_current_script,
|
||||
area,
|
||||
&weechat_python_api_hook_focus_cb,
|
||||
function,
|
||||
data));
|
||||
|
||||
PYTHON_RETURN_STRING_FREE(result);
|
||||
}
|
||||
@@ -7555,6 +7622,7 @@ PyMethodDef weechat_python_funcs[] =
|
||||
{ "hook_info", &weechat_python_api_hook_info, METH_VARARGS, "" },
|
||||
{ "hook_info_hashtable", &weechat_python_api_hook_info_hashtable, METH_VARARGS, "" },
|
||||
{ "hook_infolist", &weechat_python_api_hook_infolist, METH_VARARGS, "" },
|
||||
{ "hook_focus", &weechat_python_api_hook_focus, METH_VARARGS, "" },
|
||||
{ "unhook", &weechat_python_api_unhook, METH_VARARGS, "" },
|
||||
{ "unhook_all", &weechat_python_api_unhook_all, METH_VARARGS, "" },
|
||||
{ "buffer_new", &weechat_python_api_buffer_new, METH_VARARGS, "" },
|
||||
|
||||
@@ -4873,6 +4873,78 @@ weechat_ruby_api_hook_infolist (VALUE class, VALUE infolist_name,
|
||||
RUBY_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_hook_focus_cb: callback for focus hooked
|
||||
*/
|
||||
|
||||
struct t_hashtable *
|
||||
weechat_ruby_api_hook_focus_cb (void *data,
|
||||
struct t_hashtable *info)
|
||||
{
|
||||
struct t_script_callback *script_callback;
|
||||
void *ruby_argv[2];
|
||||
char empty_arg[1] = { '\0' };
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
ruby_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
|
||||
ruby_argv[1] = info;
|
||||
|
||||
return (struct t_hashtable *)weechat_ruby_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_HASHTABLE,
|
||||
script_callback->function,
|
||||
"sh", ruby_argv);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_hook_focus: hook a focus
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hook_focus (VALUE class, VALUE area, VALUE function,
|
||||
VALUE data)
|
||||
{
|
||||
char *c_area, *c_function, *c_data, *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, "hook_focus");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (NIL_P (area) || NIL_P (function) || NIL_P (data))
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "hook_focus");
|
||||
RUBY_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
Check_Type (area, T_STRING);
|
||||
Check_Type (function, T_STRING);
|
||||
Check_Type (data, T_STRING);
|
||||
|
||||
c_area = StringValuePtr (area);
|
||||
c_function = StringValuePtr (function);
|
||||
c_data = StringValuePtr (data);
|
||||
|
||||
result = script_ptr2str (script_api_hook_focus (weechat_ruby_plugin,
|
||||
ruby_current_script,
|
||||
c_area,
|
||||
&weechat_ruby_api_hook_focus_cb,
|
||||
c_function,
|
||||
c_data));
|
||||
|
||||
RUBY_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_ruby_api_unhook: unhook something
|
||||
*/
|
||||
@@ -8279,6 +8351,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
rb_define_module_function (ruby_mWeechat, "hook_info", &weechat_ruby_api_hook_info, 5);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_info_hashtable", &weechat_ruby_api_hook_info_hashtable, 6);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_infolist", &weechat_ruby_api_hook_infolist, 6);
|
||||
rb_define_module_function (ruby_mWeechat, "hook_focus", &weechat_ruby_api_hook_focus, 3);
|
||||
rb_define_module_function (ruby_mWeechat, "unhook", &weechat_ruby_api_unhook, 1);
|
||||
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);
|
||||
|
||||
@@ -1328,6 +1328,43 @@ script_api_hook_infolist (struct t_weechat_plugin *weechat_plugin,
|
||||
return new_hook;
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_hook_focus: hook a focus
|
||||
* return new hook, NULL if error
|
||||
*/
|
||||
|
||||
struct t_hook *
|
||||
script_api_hook_focus (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *area,
|
||||
struct t_hashtable *(*callback)(void *data,
|
||||
struct t_hashtable *info),
|
||||
const char *function,
|
||||
const char *data)
|
||||
{
|
||||
struct t_script_callback *new_script_callback;
|
||||
struct t_hook *new_hook;
|
||||
|
||||
new_script_callback = script_callback_alloc ();
|
||||
if (!new_script_callback)
|
||||
return NULL;
|
||||
|
||||
new_hook = weechat_hook_focus (area, callback, new_script_callback);
|
||||
if (!new_hook)
|
||||
{
|
||||
script_callback_free_data (new_script_callback);
|
||||
free (new_script_callback);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
script_callback_init (new_script_callback, script, function, data);
|
||||
new_script_callback->hook = new_hook;
|
||||
|
||||
script_callback_add (script, new_script_callback);
|
||||
|
||||
return new_hook;
|
||||
}
|
||||
|
||||
/*
|
||||
* script_api_unhook: unhook something
|
||||
*/
|
||||
|
||||
@@ -276,6 +276,13 @@ extern struct t_hook *script_api_hook_infolist (struct t_weechat_plugin *weechat
|
||||
const char *arguments),
|
||||
const char *function,
|
||||
const char *data);
|
||||
extern struct t_hook *script_api_hook_focus (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *area,
|
||||
struct t_hashtable *(*callback)(void *data,
|
||||
struct t_hashtable *info),
|
||||
const char *function,
|
||||
const char *data);
|
||||
extern void script_api_unhook (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_hook *hook);
|
||||
|
||||
@@ -4791,6 +4791,75 @@ weechat_tcl_api_hook_infolist (ClientData clientData, Tcl_Interp *interp,
|
||||
TCL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_hook_focus_cb: callback for focus hooked
|
||||
*/
|
||||
|
||||
struct t_hashtable *
|
||||
weechat_tcl_api_hook_focus_cb (void *data,
|
||||
struct t_hashtable *info)
|
||||
{
|
||||
struct t_script_callback *script_callback;
|
||||
void *tcl_argv[2];
|
||||
char empty_arg[1] = { '\0' };
|
||||
|
||||
script_callback = (struct t_script_callback *)data;
|
||||
|
||||
if (script_callback && script_callback->function && script_callback->function[0])
|
||||
{
|
||||
tcl_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
|
||||
tcl_argv[1] = info;
|
||||
|
||||
return (struct t_hashtable *)weechat_tcl_exec (script_callback->script,
|
||||
WEECHAT_SCRIPT_EXEC_HASHTABLE,
|
||||
script_callback->function,
|
||||
"sh", tcl_argv);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_hook_focus: hook a focus
|
||||
*/
|
||||
|
||||
static int
|
||||
weechat_tcl_api_hook_focus (ClientData clientData, Tcl_Interp *interp,
|
||||
int objc, Tcl_Obj *CONST objv[])
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *result, *area, *function, *data;
|
||||
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, "hook_focus");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
if (objc < 4)
|
||||
{
|
||||
WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "hook_focus");
|
||||
TCL_RETURN_EMPTY;
|
||||
}
|
||||
|
||||
area = Tcl_GetStringFromObj (objv[1], &i);
|
||||
function = Tcl_GetStringFromObj (objv[2], &i);
|
||||
data = Tcl_GetStringFromObj (objv[3], &i);
|
||||
|
||||
result = script_ptr2str (script_api_hook_focus (weechat_tcl_plugin,
|
||||
tcl_current_script,
|
||||
area,
|
||||
&weechat_tcl_api_hook_focus_cb,
|
||||
function,
|
||||
data));
|
||||
|
||||
TCL_RETURN_STRING_FREE(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* weechat_tcl_api_unhook: unhook something
|
||||
*/
|
||||
@@ -8205,6 +8274,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
|
||||
weechat_tcl_api_hook_info_hashtable, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::hook_infolist",
|
||||
weechat_tcl_api_hook_infolist, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::hook_focus",
|
||||
weechat_tcl_api_hook_focus, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::unhook",
|
||||
weechat_tcl_api_unhook, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateObjCommand (interp, "weechat::unhook_all",
|
||||
|
||||
Reference in New Issue
Block a user