1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 07:16:37 +02:00

api: add function completion_set

This commit is contained in:
Sébastien Helleu
2025-02-15 23:22:44 +01:00
parent 1b54cd24ed
commit c7d21a3ea6
25 changed files with 577 additions and 16 deletions
+16
View File
@@ -4566,6 +4566,21 @@ weechat_guile_api_completion_get_string (SCM completion, SCM property)
API_RETURN_STRING(result);
}
SCM
weechat_guile_api_completion_set (SCM completion, SCM property, SCM value)
{
API_INIT_FUNC(1, "completion_set", API_RETURN_ERROR);
if (!scm_is_string (completion) || !scm_is_string (property)
|| !scm_is_string (value))
API_WRONG_ARGS(API_RETURN_ERROR);
weechat_completion_set (API_STR2PTR(API_SCM_TO_STRING(completion)),
API_SCM_TO_STRING(property),
API_SCM_TO_STRING(value));
API_RETURN_OK;
}
SCM
weechat_guile_api_completion_list_add (SCM completion, SCM word,
SCM nick_completion, SCM where)
@@ -5609,6 +5624,7 @@ weechat_guile_api_module_init (void *data)
API_DEF_FUNC(completion_new, 1);
API_DEF_FUNC(completion_search, 4);
API_DEF_FUNC(completion_get_string, 2);
API_DEF_FUNC(completion_set, 3);
API_DEF_FUNC(completion_list_add, 4);
API_DEF_FUNC(completion_free, 1);
API_DEF_FUNC(info_get, 2);
+17
View File
@@ -4482,6 +4482,22 @@ API_FUNC(completion_get_string)
API_RETURN_STRING(result);
}
API_FUNC(completion_set)
{
API_INIT_FUNC(1, "completion_set", "sss", API_RETURN_ERROR);
v8::String::Utf8Value completion(args[0]);
v8::String::Utf8Value property(args[1]);
v8::String::Utf8Value value(args[2]);
weechat_completion_set (
(struct t_gui_completion *)API_STR2PTR(*completion),
*property,
*value);
API_RETURN_OK;
}
API_FUNC(completion_list_add)
{
int nick_completion;
@@ -5539,6 +5555,7 @@ WeechatJsV8::loadLibs()
API_DEF_FUNC(completion_new);
API_DEF_FUNC(completion_search);
API_DEF_FUNC(completion_get_string);
API_DEF_FUNC(completion_set);
API_DEF_FUNC(completion_list_add);
API_DEF_FUNC(completion_free);
API_DEF_FUNC(info_get);
+18
View File
@@ -4831,6 +4831,23 @@ API_FUNC(completion_get_string)
API_RETURN_STRING(result);
}
API_FUNC(completion_set)
{
const char *completion, *property, *value;
API_INIT_FUNC(1, "completion_set", API_RETURN_ERROR);
if (lua_gettop (L) < 3)
API_WRONG_ARGS(API_RETURN_ERROR);
completion = lua_tostring (L, -3);
property = lua_tostring (L, -2);
value = lua_tostring (L, -1);
weechat_completion_set (API_STR2PTR(completion), property, value);
API_RETURN_OK;
}
API_FUNC(completion_list_add)
{
const char *completion, *word, *where;
@@ -5932,6 +5949,7 @@ const struct luaL_Reg weechat_lua_api_funcs[] = {
API_DEF_FUNC(completion_new),
API_DEF_FUNC(completion_search),
API_DEF_FUNC(completion_get_string),
API_DEF_FUNC(completion_set),
API_DEF_FUNC(completion_list_add),
API_DEF_FUNC(completion_free),
API_DEF_FUNC(info_get),
+19
View File
@@ -4733,6 +4733,24 @@ API_FUNC(completion_get_string)
API_RETURN_STRING(result);
}
API_FUNC(completion_set)
{
char *completion, *property, *value;
dXSARGS;
API_INIT_FUNC(1, "completion_set", API_RETURN_ERROR);
if (items < 3)
API_WRONG_ARGS(API_RETURN_ERROR);
completion = SvPV_nolen (ST (0));
property = SvPV_nolen (ST (1));
value = SvPV_nolen (ST (2));
weechat_completion_set (API_STR2PTR(completion), property, value);
API_RETURN_OK;
}
API_FUNC(completion_list_add)
{
char *completion, *word, *where;
@@ -5870,6 +5888,7 @@ weechat_perl_api_init (pTHX)
API_DEF_FUNC(completion_new);
API_DEF_FUNC(completion_search);
API_DEF_FUNC(completion_get_string);
API_DEF_FUNC(completion_set);
API_DEF_FUNC(completion_list_add);
API_DEF_FUNC(completion_free);
API_DEF_FUNC(info_get);
+20
View File
@@ -4814,6 +4814,26 @@ API_FUNC(completion_get_string)
API_RETURN_STRING(result);
}
API_FUNC(completion_set)
{
zend_string *z_completion, *z_property, *z_value;
struct t_gui_completion *completion;
char *property, *value;
API_INIT_FUNC(1, "completion_set", API_RETURN_ERROR);
if (zend_parse_parameters (ZEND_NUM_ARGS(), "SSS", &z_completion,
&z_property, &z_value) == FAILURE)
API_WRONG_ARGS(API_RETURN_ERROR);
completion = (struct t_gui_completion *)API_STR2PTR(ZSTR_VAL(z_completion));
property = ZSTR_VAL(z_property);
value = ZSTR_VAL(z_value);
weechat_completion_set (completion, (const char *)property, (const char *)value);
API_RETURN_OK;
}
API_FUNC(completion_list_add)
{
zend_string *z_completion, *z_word, *z_where;
+1
View File
@@ -219,6 +219,7 @@ PHP_FUNCTION(weechat_command_options);
PHP_FUNCTION(weechat_completion_new);
PHP_FUNCTION(weechat_completion_search);
PHP_FUNCTION(weechat_completion_get_string);
PHP_FUNCTION(weechat_completion_set);
PHP_FUNCTION(weechat_completion_list_add);
PHP_FUNCTION(weechat_completion_free);
PHP_FUNCTION(weechat_info_get);
+1
View File
@@ -277,6 +277,7 @@ const zend_function_entry weechat_functions[] = {
PHP_FE(weechat_completion_new, arginfo_weechat_completion_new)
PHP_FE(weechat_completion_search, arginfo_weechat_completion_search)
PHP_FE(weechat_completion_get_string, arginfo_weechat_completion_get_string)
PHP_FE(weechat_completion_set, arginfo_weechat_completion_set)
PHP_FE(weechat_completion_list_add, arginfo_weechat_completion_list_add)
PHP_FE(weechat_completion_free, arginfo_weechat_completion_free)
PHP_FE(weechat_info_get, arginfo_weechat_info_get)
+1
View File
@@ -185,6 +185,7 @@ function weechat_command_options(string $p0, string $p1, array $p2): int {}
function weechat_completion_new(string $p0): string {}
function weechat_completion_search(string $p0, string $p1, int $p2, int $p3): int {}
function weechat_completion_get_string(string $p0, string $p1): string {}
function weechat_completion_set(string $p0, string $p1, string $p2): int {}
function weechat_completion_list_add(string $p0, string $p1, int $p2, string $p3): int {}
function weechat_completion_free(string $p0): int {}
function weechat_info_get(string $p0, string $p1): string {}
+3 -1
View File
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: ac17ccd00483eea80bd3dc22ec07ab3bf41dec88 */
* Stub hash: b20e387bfdf7c5496a25b4a07f5d3eed456f7992 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_register, 0, 7, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, p0, IS_STRING, 0)
@@ -539,6 +539,8 @@ ZEND_END_ARG_INFO()
#define arginfo_weechat_completion_get_string arginfo_weechat_iconv_to_internal
#define arginfo_weechat_completion_set arginfo_weechat_config_write_line
#define arginfo_weechat_completion_list_add arginfo_weechat_hook_completion_list_add
#define arginfo_weechat_completion_free arginfo_weechat_charset_set
+3 -1
View File
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: ac17ccd00483eea80bd3dc22ec07ab3bf41dec88 */
* Stub hash: b20e387bfdf7c5496a25b4a07f5d3eed456f7992 */
ZEND_BEGIN_ARG_INFO_EX(arginfo_weechat_register, 0, 0, 7)
ZEND_ARG_INFO(0, p0)
@@ -385,6 +385,8 @@ ZEND_END_ARG_INFO()
#define arginfo_weechat_completion_get_string arginfo_weechat_iconv_to_internal
#define arginfo_weechat_completion_set arginfo_weechat_ngettext
#define arginfo_weechat_completion_list_add arginfo_weechat_string_eval_expression
#define arginfo_weechat_completion_free arginfo_weechat_plugin_get_name
+1
View File
@@ -888,6 +888,7 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv)
new_plugin->completion_new = &gui_completion_new;
new_plugin->completion_search = &gui_completion_search;
new_plugin->completion_get_string = &gui_completion_get_string;
new_plugin->completion_set = &gui_completion_set;
new_plugin->completion_list_add = &gui_completion_list_add;
new_plugin->completion_free = &gui_completion_free;
+19
View File
@@ -4718,6 +4718,24 @@ API_FUNC(completion_get_string)
API_RETURN_STRING(result);
}
API_FUNC(completion_set)
{
char *completion, *property, *value;
API_INIT_FUNC(1, "completion_set", API_RETURN_ERROR);
completion = NULL;
property = NULL;
value = NULL;
if (!PyArg_ParseTuple (args, "sss", &completion, &property, &value))
API_WRONG_ARGS(API_RETURN_ERROR);
weechat_completion_set (API_STR2PTR(completion),
property,
value);
API_RETURN_OK;
}
API_FUNC(completion_list_add)
{
char *completion, *word, *where;
@@ -5798,6 +5816,7 @@ PyMethodDef weechat_python_funcs[] =
API_DEF_FUNC(completion_new),
API_DEF_FUNC(completion_search),
API_DEF_FUNC(completion_get_string),
API_DEF_FUNC(completion_set),
API_DEF_FUNC(completion_list_add),
API_DEF_FUNC(completion_free),
API_DEF_FUNC(info_get),
+14
View File
@@ -2339,6 +2339,20 @@ def completion_get_string(completion: str, property: str) -> str:
...
def completion_set(completion: str, property: str, value: str) -> int:
"""`completion_set in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_completion_set>`_
::
# example
def my_completion_cb(data: str, completion_item: str, buffer: str, completion: str) -> int:
# do not add space after completion
weechat.completion_set(completion, "add_space", "0")
# ...
return weechat.WEECHAT_RC_OK
"""
...
def completion_list_add(completion: str, word: str, nick_completion: int, where: str) -> int:
"""`completion_list_add in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_completion_list_add>`_
::
+26
View File
@@ -5785,6 +5785,31 @@ weechat_ruby_api_completion_get_string (VALUE class, VALUE completion,
API_RETURN_STRING(result);
}
static VALUE
weechat_ruby_api_completion_set (VALUE class, VALUE completion, VALUE property,
VALUE value)
{
char *c_completion, *c_property, *c_value;
API_INIT_FUNC(1, "completion_set", API_RETURN_ERROR);
if (NIL_P (completion) || NIL_P (property) || NIL_P (value))
API_WRONG_ARGS(API_RETURN_ERROR);
Check_Type (completion, T_STRING);
Check_Type (property, T_STRING);
Check_Type (value, T_STRING);
c_completion = StringValuePtr (completion);
c_property = StringValuePtr (property);
c_value = StringValuePtr (value);
weechat_completion_set (API_STR2PTR(c_completion),
c_property,
c_value);
API_RETURN_OK;
}
static VALUE
weechat_ruby_api_completion_list_add (VALUE class, VALUE completion,
VALUE word, VALUE nick_completion,
@@ -7140,6 +7165,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
API_DEF_FUNC(completion_new, 1);
API_DEF_FUNC(completion_search, 4);
API_DEF_FUNC(completion_get_string, 2);
API_DEF_FUNC(completion_set, 3);
API_DEF_FUNC(completion_list_add, 4);
API_DEF_FUNC(completion_free, 1);
API_DEF_FUNC(info_get, 2);
+18
View File
@@ -4780,6 +4780,23 @@ API_FUNC(completion_get_string)
API_RETURN_STRING(result);
}
API_FUNC(completion_set)
{
char *completion, *property, *value;
API_INIT_FUNC(1, "completion_set", API_RETURN_ERROR);
if (objc < 4)
API_WRONG_ARGS(API_RETURN_ERROR);
completion = Tcl_GetString (objv[1]);
property = Tcl_GetString (objv[2]);
value = Tcl_GetString (objv[3]);
weechat_completion_set (API_STR2PTR(completion), property, value);
API_RETURN_OK;
}
API_FUNC(completion_list_add)
{
char *completion, *word, *where;
@@ -5876,6 +5893,7 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
API_DEF_FUNC(completion_new);
API_DEF_FUNC(completion_search);
API_DEF_FUNC(completion_get_string);
API_DEF_FUNC(completion_set);
API_DEF_FUNC(completion_list_add);
API_DEF_FUNC(info_get);
API_DEF_FUNC(info_get_hashtable);
+5 -1
View File
@@ -74,7 +74,7 @@ struct t_weelist_item;
* please change the date with current one; for a second change at same
* date, increment the 01, otherwise please keep 01.
*/
#define WEECHAT_PLUGIN_API_VERSION "20241124-01"
#define WEECHAT_PLUGIN_API_VERSION "20250215-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -1133,6 +1133,8 @@ struct t_weechat_plugin
const char *data, int position, int direction);
const char *(*completion_get_string) (struct t_gui_completion *completion,
const char *property);
void (*completion_set) (struct t_gui_completion *completion,
const char *property, const char *value);
void (*completion_list_add) (struct t_gui_completion *completion,
const char *word,
int nick_completion,
@@ -2204,6 +2206,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
__position, __direction)
#define weechat_completion_get_string(__completion, __property) \
(weechat_plugin->completion_get_string)(__completion, __property)
#define weechat_completion_set(__completion, __property, __value) \
(weechat_plugin->completion_set)(__completion, __property, __value)
#define weechat_completion_list_add(__completion, __word, \
__nick_completion, __where) \
(weechat_plugin->completion_list_add)(__completion, __word, \