diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2013-08-19 21:22:10 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2013-08-19 21:22:10 +0200 |
commit | eac1ca929bb23544fa98c7f11f7118e1925b27a3 (patch) | |
tree | 5f1b75a82af98a02a7de29808ace55f3b5d23347 /src/plugins/lua | |
parent | 9990917cc7380a92f59fbac2fec8d6a5fc91760c (diff) | |
download | weechat-eac1ca929bb23544fa98c7f11f7118e1925b27a3.zip |
core: add syntax "@buffer:item" in bar items to force the buffer used when displaying the bar item (task #12717)
Diffstat (limited to 'src/plugins/lua')
-rw-r--r-- | src/plugins/lua/weechat-lua-api.c | 57 |
1 files changed, 42 insertions, 15 deletions
diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c index ae13899ae..fd6d50b43 100644 --- a/src/plugins/lua/weechat-lua-api.c +++ b/src/plugins/lua/weechat-lua-api.c @@ -3997,29 +3997,56 @@ weechat_lua_api_bar_item_search (lua_State *L) char * weechat_lua_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item, - struct t_gui_window *window) + struct t_gui_window *window, + struct t_gui_buffer *buffer, + struct t_hashtable *extra_info) { struct t_plugin_script_cb *script_callback; - void *func_argv[3]; + void *func_argv[5]; char empty_arg[1] = { '\0' }, *ret; script_callback = (struct t_plugin_script_cb *)data; if (script_callback && script_callback->function && script_callback->function[0]) { - func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; - func_argv[1] = API_PTR2STR(item); - func_argv[2] = API_PTR2STR(window); - - ret = (char *)weechat_lua_exec (script_callback->script, NULL, - WEECHAT_SCRIPT_EXEC_STRING, - script_callback->function, - "sss", func_argv); - - if (func_argv[1]) - free (func_argv[1]); - if (func_argv[2]) - free (func_argv[2]); + if (strncmp (script_callback->function, "(extra)", 7) == 0) + { + /* new callback: data, item, window, buffer, extra_info */ + func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + func_argv[1] = API_PTR2STR(item); + func_argv[2] = API_PTR2STR(window); + func_argv[3] = API_PTR2STR(buffer); + func_argv[4] = extra_info; + + ret = (char *)weechat_lua_exec (script_callback->script, NULL, + WEECHAT_SCRIPT_EXEC_STRING, + script_callback->function + 7, + "ssssh", func_argv); + + if (func_argv[1]) + free (func_argv[1]); + if (func_argv[2]) + free (func_argv[2]); + if (func_argv[3]) + free (func_argv[3]); + } + else + { + /* old callback: data, item, window */ + func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg; + func_argv[1] = API_PTR2STR(item); + func_argv[2] = API_PTR2STR(window); + + ret = (char *)weechat_lua_exec (script_callback->script, NULL, + WEECHAT_SCRIPT_EXEC_STRING, + script_callback->function, + "sss", func_argv); + + if (func_argv[1]) + free (func_argv[1]); + if (func_argv[2]) + free (func_argv[2]); + } return ret; } |