mirror of
https://github.com/weechat/weechat.git
synced 2026-06-12 14:14:48 +02:00
api: add function completion_set
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
- core: add command `/pipe`
|
||||
- core: add option `whitespace` in command `/debug`, add options weechat.look.whitespace_char and weechat.look.tab_whitespace_char ([#947](https://github.com/weechat/weechat/issues/947))
|
||||
- api: add function completion_set
|
||||
- relay/api: add resource `POST /api/completion` ([#2207](https://github.com/weechat/weechat/issues/2207))
|
||||
- relay/api: add default key `Alt`+`Ctrl`+`l` (L) to toggle between remote and local commands on remote buffers, add option `togglecmd` in command `/remote`, add options relay.api.remote_input_cmd_local and relay.api.remote_input_cmd_remote ([#2148](https://github.com/weechat/weechat/issues/2148))
|
||||
|
||||
|
||||
@@ -17087,6 +17087,71 @@ def my_completion_cb(data: str, completion_item: str, buffer: str, completion: s
|
||||
return weechat.WEECHAT_RC_OK
|
||||
----
|
||||
|
||||
==== completion_set
|
||||
|
||||
_WeeChat ≥ 4.6.0._
|
||||
|
||||
Set a completion property.
|
||||
|
||||
Prototype:
|
||||
|
||||
[source,c]
|
||||
----
|
||||
void weechat_completion_get_string (struct t_gui_completion *completion,
|
||||
const char *property,
|
||||
const char *value);
|
||||
----
|
||||
|
||||
Arguments:
|
||||
|
||||
* _completion_: completion pointer
|
||||
* _property_: property name (see table below)
|
||||
* _value_: new value for property
|
||||
|
||||
Properties:
|
||||
|
||||
[width="100%",cols="^2,^1,4,8",options="header"]
|
||||
|===
|
||||
| Name | Min WeeChat | Value | Description
|
||||
|
||||
| add_space | 4.6.0 | "0" or "1"
|
||||
| "0": do not add space after completion +
|
||||
"1": add space after completion (default).
|
||||
|===
|
||||
|
||||
C example:
|
||||
|
||||
[source,c]
|
||||
----
|
||||
int
|
||||
my_completion_cb (const void *pointer, void *data, const char *completion_item,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
/* do not add space after completion */
|
||||
weechat_completion_set (completion, "add_space", "0");
|
||||
|
||||
/* ... */
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
----
|
||||
|
||||
Script (Python):
|
||||
|
||||
[source,python]
|
||||
----
|
||||
# prototype
|
||||
def completion_set(completion: str, property: str, value: str) -> int: ...
|
||||
|
||||
# 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
|
||||
----
|
||||
|
||||
==== completion_list_add
|
||||
|
||||
_WeeChat ≥ 2.9._
|
||||
|
||||
@@ -17451,6 +17451,71 @@ def my_completion_cb(data: str, completion_item: str, buffer: str, completion: s
|
||||
return weechat.WEECHAT_RC_OK
|
||||
----
|
||||
|
||||
==== completion_set
|
||||
|
||||
_WeeChat ≥ 4.6.0._
|
||||
|
||||
Affecter une valeur à une propriété d'une complétion.
|
||||
|
||||
Prototype :
|
||||
|
||||
[source,c]
|
||||
----
|
||||
void weechat_completion_get_string (struct t_gui_completion *completion,
|
||||
const char *property,
|
||||
const char *value);
|
||||
----
|
||||
|
||||
Paramètres :
|
||||
|
||||
* _completion_ : pointeur vers la complétion
|
||||
* _property_ : nom de la propriété (voir le tableau ci-dessous)
|
||||
* _value_ : nouvelle valeur pour la propriété
|
||||
|
||||
Properties:
|
||||
|
||||
[width="100%",cols="^2,^1,4,8",options="header"]
|
||||
|===
|
||||
| Name | Min WeeChat | Value | Description
|
||||
|
||||
| add_space | 4.6.0 | "0" or "1"
|
||||
| "0": do not add space after completion +
|
||||
"1": add space after completion (default).
|
||||
|===
|
||||
|
||||
Exemple en C :
|
||||
|
||||
[source,c]
|
||||
----
|
||||
int
|
||||
my_completion_cb (const void *pointer, void *data, const char *completion_item,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
/* ne pas ajouter d'espace après la complétion */
|
||||
weechat_completion_set (completion, "add_space", "0");
|
||||
|
||||
/* ... */
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
----
|
||||
|
||||
Script (Python) :
|
||||
|
||||
[source,python]
|
||||
----
|
||||
# prototype
|
||||
def completion_set(completion: str, property: str, value: str) -> int: ...
|
||||
|
||||
# exemple
|
||||
def my_completion_cb(data: str, completion_item: str, buffer: str, completion: str) -> int:
|
||||
# ne pas ajouter d'espace après la complétion
|
||||
weechat.completion_set(completion, "add_space", "0")
|
||||
# ...
|
||||
return weechat.WEECHAT_RC_OK
|
||||
----
|
||||
|
||||
==== completion_list_add
|
||||
|
||||
_WeeChat ≥ 2.9._
|
||||
|
||||
@@ -17924,6 +17924,77 @@ def my_completion_cb(data: str, completion_item: str, buffer: str, completion: s
|
||||
return weechat.WEECHAT_RC_OK
|
||||
----
|
||||
|
||||
==== completion_set
|
||||
|
||||
_Novità nella versioe 4.6.0._
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Set a completion property.
|
||||
|
||||
Prototipo:
|
||||
|
||||
[source,c]
|
||||
----
|
||||
void weechat_completion_get_string (struct t_gui_completion *completion,
|
||||
const char *property,
|
||||
const char *value);
|
||||
----
|
||||
|
||||
Argomenti:
|
||||
|
||||
* _completion_: puntatore al completamento
|
||||
// TRANSLATION MISSING
|
||||
* _property_: nome della proprietà (see table below)
|
||||
// TRANSLATION MISSING
|
||||
* _value_: new value for property
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Properties:
|
||||
|
||||
[width="100%",cols="^2,^1,4,8",options="header"]
|
||||
|===
|
||||
// TRANSLATION MISSING
|
||||
| Name | Min WeeChat | Value | Description
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| add_space | 4.6.0 | "0" or "1"
|
||||
| "0": do not add space after completion +
|
||||
"1": add space after completion (default).
|
||||
|===
|
||||
|
||||
Esempio in C:
|
||||
|
||||
[source,c]
|
||||
----
|
||||
int
|
||||
my_completion_cb (const void *pointer, void *data, const char *completion_item,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
/* do not add space after completion */
|
||||
weechat_completion_set (completion, "add_space", "0");
|
||||
|
||||
/* ... */
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
----
|
||||
|
||||
Script (Python):
|
||||
|
||||
[source,python]
|
||||
----
|
||||
# prototipo
|
||||
def completion_set(completion: str, property: str, value: str) -> int: ...
|
||||
|
||||
# esempio
|
||||
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
|
||||
----
|
||||
|
||||
==== completion_list_add
|
||||
|
||||
_Novità nella versioe 2.9._
|
||||
|
||||
@@ -17382,6 +17382,74 @@ def my_completion_cb(data: str, completion_item: str, buffer: str, completion: s
|
||||
return weechat.WEECHAT_RC_OK
|
||||
----
|
||||
|
||||
==== completion_set
|
||||
|
||||
_WeeChat バージョン 4.6.0 以上で利用可。_
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Set a completion property.
|
||||
|
||||
プロトタイプ:
|
||||
|
||||
[source,c]
|
||||
----
|
||||
void weechat_completion_get_string (struct t_gui_completion *completion,
|
||||
const char *property,
|
||||
const char *value);
|
||||
----
|
||||
|
||||
引数:
|
||||
|
||||
* _completion_: 補完へのポインタ
|
||||
* _property_: プロパティ名 (以下の表を参照)
|
||||
* _value_: プロパティの新しい値
|
||||
|
||||
プロパティ:
|
||||
|
||||
[width="100%",cols="^2,^1,4,8",options="header"]
|
||||
|===
|
||||
// TRANSLATION MISSING
|
||||
| Name | Min WeeChat | Value | Description
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| add_space | 4.6.0 | "0" or "1"
|
||||
| "0": do not add space after completion +
|
||||
"1": add space after completion (default).
|
||||
|===
|
||||
|
||||
C 言語での使用例:
|
||||
|
||||
[source,c]
|
||||
----
|
||||
int
|
||||
my_completion_cb (const void *pointer, void *data, const char *completion_item,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
/* do not add space after completion */
|
||||
weechat_completion_set (completion, "add_space", "0");
|
||||
|
||||
/* ... */
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
----
|
||||
|
||||
スクリプト (Python) での使用例:
|
||||
|
||||
[source,python]
|
||||
----
|
||||
# prototype
|
||||
def completion_set(completion: str, property: str, value: str) -> int: ...
|
||||
|
||||
# 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
|
||||
----
|
||||
|
||||
==== completion_list_add
|
||||
|
||||
_WeeChat バージョン 2.9 以上で利用可。_
|
||||
|
||||
@@ -16629,6 +16629,73 @@ def my_completion_cb(data: str, completion_item: str, buffer: str, completion: s
|
||||
return weechat.WEECHAT_RC_OK
|
||||
----
|
||||
|
||||
==== completion_set
|
||||
|
||||
_WeeChat ≥ 4.6.0._
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Set a completion property.
|
||||
|
||||
Прототип:
|
||||
|
||||
[source,c]
|
||||
----
|
||||
void weechat_completion_get_string (struct t_gui_completion *completion,
|
||||
const char *property,
|
||||
const char *value);
|
||||
----
|
||||
|
||||
Аргументи:
|
||||
|
||||
* _completion_: показивач на довршавање
|
||||
* _property_: име особине (погледајте табелу испод)
|
||||
* _value_: нова вредност за особину
|
||||
|
||||
Особине:
|
||||
|
||||
[width="100%",cols="^2,^1,4,8",options="header"]
|
||||
|===
|
||||
| Име | Мин WeeChat | Вредност | Опис
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| add_space | 4.6.0 | "0" or "1"
|
||||
| "0": do not add space after completion +
|
||||
"1": add space after completion (default).
|
||||
|===
|
||||
|
||||
C пример:
|
||||
|
||||
[source,c]
|
||||
----
|
||||
int
|
||||
my_completion_cb (const void *pointer, void *data, const char *completion_item,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_gui_completion *completion)
|
||||
{
|
||||
/* do not add space after completion */
|
||||
weechat_completion_set (completion, "add_space", "0");
|
||||
|
||||
/* ... */
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
----
|
||||
|
||||
Скрипта (Python):
|
||||
|
||||
[source,python]
|
||||
----
|
||||
# прототип
|
||||
def completion_set(completion: str, property: str, value: str) -> int: ...
|
||||
|
||||
# пример
|
||||
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
|
||||
----
|
||||
|
||||
==== completion_list_add
|
||||
|
||||
_WeeChat ≥ 2.9._
|
||||
|
||||
@@ -1561,6 +1561,23 @@ gui_completion_get_string (struct t_gui_completion *completion,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets a completion property.
|
||||
*/
|
||||
|
||||
void
|
||||
gui_completion_set (struct t_gui_completion *completion,
|
||||
const char *property, const char *value)
|
||||
{
|
||||
if (!completion || !property || !value)
|
||||
return;
|
||||
|
||||
if (strcmp (property, "add_space") == 0)
|
||||
{
|
||||
completion->add_space = (strcmp (value, "1") == 0) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns hdata for completion.
|
||||
*/
|
||||
|
||||
@@ -94,6 +94,8 @@ extern int gui_completion_search (struct t_gui_completion *completion,
|
||||
int direction);
|
||||
extern const char *gui_completion_get_string (struct t_gui_completion *completion,
|
||||
const char *property);
|
||||
extern void gui_completion_set (struct t_gui_completion *completion,
|
||||
const char *property, const char *value);
|
||||
extern struct t_hdata *gui_completion_hdata_completion_cb (const void *pointer,
|
||||
void *data,
|
||||
const char *hdata_name);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 {}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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>`_
|
||||
::
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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, \
|
||||
|
||||
@@ -578,10 +578,21 @@ def test_display():
|
||||
weechat.buffer_close(buffer)
|
||||
|
||||
|
||||
def completion_cb(data, completion_item, buf, completion):
|
||||
def completion1_cb(data, completion_item, buf, completion):
|
||||
"""Completion callback."""
|
||||
check(data == 'completion_data')
|
||||
check(completion_item == '{SCRIPT_NAME}')
|
||||
check(completion_item == '{SCRIPT_NAME}1')
|
||||
check(weechat.completion_get_string(completion, 'args') == 'w')
|
||||
weechat.completion_set(completion, 'add_space', '0')
|
||||
weechat.completion_list_add(completion, 'word_completed',
|
||||
0, weechat.WEECHAT_LIST_POS_END)
|
||||
return weechat.WEECHAT_RC_OK
|
||||
|
||||
|
||||
def completion2_cb(data, completion_item, buf, completion):
|
||||
"""Completion callback."""
|
||||
check(data == 'completion_data')
|
||||
check(completion_item == '{SCRIPT_NAME}2')
|
||||
check(weechat.completion_get_string(completion, 'args') == 'w')
|
||||
weechat.completion_list_add(completion, 'word_completed',
|
||||
0, weechat.WEECHAT_LIST_POS_END)
|
||||
@@ -598,7 +609,7 @@ def command_cb(data, buf, args):
|
||||
def command_run_cb(data, buf, command):
|
||||
"""Command_run callback."""
|
||||
check(data == 'command_run_data')
|
||||
check(command == '/cmd' + '{SCRIPT_NAME}' + ' word_completed')
|
||||
check(command == '/cmd2' + '{SCRIPT_NAME}' + ' word_completed')
|
||||
return weechat.WEECHAT_RC_OK
|
||||
|
||||
|
||||
@@ -609,22 +620,37 @@ def timer_cb(data, remaining_calls):
|
||||
|
||||
def test_hooks():
|
||||
"""Test hook functions."""
|
||||
buffer = weechat.buffer_search_main()
|
||||
# hook_completion / hook_completion_args / and hook_command
|
||||
hook_cmplt = weechat.hook_completion('{SCRIPT_NAME}', 'description',
|
||||
'completion_cb', 'completion_data')
|
||||
hook_cmd = weechat.hook_command('cmd' + '{SCRIPT_NAME}', 'description',
|
||||
'arguments', 'description arguments',
|
||||
'%(' + '{SCRIPT_NAME}' + ')',
|
||||
'command_cb', 'command_data')
|
||||
weechat.command('', '/input insert /cmd' + '{SCRIPT_NAME}' + ' w')
|
||||
hook_cmplt1 = weechat.hook_completion('{SCRIPT_NAME}1', 'description',
|
||||
'completion1_cb', 'completion_data')
|
||||
hook_cmd1 = weechat.hook_command('cmd1' + '{SCRIPT_NAME}', 'description',
|
||||
'arguments', 'description arguments',
|
||||
'%(' + '{SCRIPT_NAME}1' + ')',
|
||||
'command_cb', 'command_data')
|
||||
hook_cmplt2 = weechat.hook_completion('{SCRIPT_NAME}2', 'description',
|
||||
'completion2_cb', 'completion_data')
|
||||
hook_cmd2 = weechat.hook_command('cmd2' + '{SCRIPT_NAME}', 'description',
|
||||
'arguments', 'description arguments',
|
||||
'%(' + '{SCRIPT_NAME}2' + ')',
|
||||
'command_cb', 'command_data')
|
||||
weechat.command('', '/input insert /cmd1' + '{SCRIPT_NAME}' + ' w')
|
||||
weechat.command('', '/input complete_next')
|
||||
check(weechat.buffer_get_string(buffer, 'input') == '/cmd1' + '{SCRIPT_NAME}' + ' word_completed')
|
||||
weechat.command('', '/input delete_line')
|
||||
weechat.command('', '/input insert /cmd2' + '{SCRIPT_NAME}' + ' w')
|
||||
weechat.command('', '/input complete_next')
|
||||
check(weechat.buffer_get_string(buffer, 'input') == '/cmd2' + '{SCRIPT_NAME}' + ' word_completed ')
|
||||
# hook_command_run
|
||||
hook_cmd_run = weechat.hook_command_run('/cmd' + '{SCRIPT_NAME}' + '*',
|
||||
hook_cmd_run = weechat.hook_command_run('/cmd2' + '{SCRIPT_NAME}' + '*',
|
||||
'command_run_cb', 'command_run_data')
|
||||
weechat.command('', '/input return')
|
||||
weechat.unhook(hook_cmd_run)
|
||||
weechat.unhook(hook_cmd)
|
||||
weechat.unhook(hook_cmplt)
|
||||
weechat.unhook(hook_cmd1)
|
||||
weechat.unhook(hook_cmplt1)
|
||||
weechat.unhook(hook_cmd2)
|
||||
weechat.unhook(hook_cmplt2)
|
||||
# weechat.unhook(hook_cmplt2)
|
||||
# hook_timer
|
||||
hook_timer = weechat.hook_timer(2000111000, 0, 1,
|
||||
'timer_cb', 'timer_cb_data')
|
||||
|
||||
Reference in New Issue
Block a user