diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2020-04-27 00:14:36 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2020-04-27 22:15:42 +0200 |
commit | d3020976d59e5e329c851f104c633427eafe2cf3 (patch) | |
tree | 929a758b54fb388ea82b9bc5414dd78523789716 /src/plugins/lua | |
parent | 0f1cee08bf12aab377417d6d7077a4f5abdd08a3 (diff) | |
download | weechat-d3020976d59e5e329c851f104c633427eafe2cf3.zip |
api: add functions completion_new, completion_search and completion_free (issue #1484)
Diffstat (limited to 'src/plugins/lua')
-rw-r--r-- | src/plugins/lua/weechat-lua-api.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c index f6230a71a..0d16363b1 100644 --- a/src/plugins/lua/weechat-lua-api.c +++ b/src/plugins/lua/weechat-lua-api.c @@ -4337,6 +4337,57 @@ API_FUNC(command_options) API_RETURN_INT(rc); } +API_FUNC(completion_new) +{ + const char *buffer; + const char *result; + + API_INIT_FUNC(1, "completion_new", API_RETURN_EMPTY); + if (lua_gettop (L) < 1) + API_WRONG_ARGS(API_RETURN_EMPTY); + + buffer = lua_tostring (L, -1); + + result = API_PTR2STR(weechat_completion_new (API_STR2PTR(buffer))); + + API_RETURN_STRING(result); +} + +API_FUNC(completion_search) +{ + const char *completion, *data; + int position, direction; + + API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR); + if (lua_gettop (L) < 4) + API_WRONG_ARGS(API_RETURN_ERROR); + + completion = lua_tostring (L, -4); + data = lua_tostring (L, -3); + position = lua_tonumber (L, -2); + direction = lua_tonumber (L, -1); + + weechat_completion_search (API_STR2PTR(completion), data, position, + direction); + + API_RETURN_OK; +} + +API_FUNC(completion_free) +{ + const char *completion; + + API_INIT_FUNC(1, "completion_free", API_RETURN_ERROR); + if (lua_gettop (L) < 1) + API_WRONG_ARGS(API_RETURN_ERROR); + + completion = lua_tostring (L, -1); + + weechat_completion_free (API_STR2PTR(completion)); + + API_RETURN_OK; +} + API_FUNC(info_get) { const char *info_name, *arguments; @@ -5345,6 +5396,9 @@ const struct luaL_Reg weechat_lua_api_funcs[] = { API_DEF_FUNC(bar_remove), API_DEF_FUNC(command), API_DEF_FUNC(command_options), + API_DEF_FUNC(completion_new), + API_DEF_FUNC(completion_search), + API_DEF_FUNC(completion_free), API_DEF_FUNC(info_get), API_DEF_FUNC(info_get_hashtable), API_DEF_FUNC(infolist_new), |