core: rename functions hook_completion_{get_string|list_add} to completion_{get_string|list_add}

Old functions are kept for compatibility reasons.
This commit is contained in:
Sébastien Helleu 2020-05-08 10:49:20 +02:00
parent b7765ed960
commit 88bef0b1b1
38 changed files with 1118 additions and 638 deletions

View File

@ -24,6 +24,7 @@ New features::
* core: add default key kbd:[Alt+Shift+N] to toggle nicklist bar
* core: add command line option "--stdout" in weechat-headless binary to log to stdout rather than ~/.weechat/weechat.log (issue #1475, issue #1477)
* core: reload configuration files on SIGHUP (issue #1476)
* api: rename function hook_completion_get_string to completion_get_string and hook_completion_list_add to completion_list_add
* api: add functions completion_new, completion_search and completion_free
* api: add hdata "completion_word"
* buflist: add default key kbd:[Alt+Shift+B] to toggle buflist

View File

@ -20,6 +20,22 @@ https://weechat.org/files/changelog/ChangeLog-devel.html[ChangeLog]
[[v2.9]]
== Version 2.9 (under dev)
[[v2.9_api_completion_functions]]
=== Move of API completion functions
Completion functions have been added in WeeChat 2.9, to allow relay clients or
plugins/scripts to complete a string, without using the buffer input.
Therefore two functions have been renamed in API and moved to the new
"completion" category:
* function _hook_completion_get_string_ renamed to _completion_get_string_
* function _hook_completion_list_add_ renamed to _completion_list_add_
[NOTE]
The old names are still valid for compatibility reasons, but it is recommended
to use only the new names as the old ones may be removed in an upcoming release.
[[v2.9_remove_gnutls_build_option]]
=== GnuTLS is not optional any more

View File

@ -646,8 +646,6 @@ Liste der Skript API Funktionen:
hook_hsignal_send +
hook_config +
hook_completion +
hook_completion_get_string +
hook_completion_list_add +
hook_modifier +
hook_modifier_exec +
hook_info +
@ -717,6 +715,8 @@ Liste der Skript API Funktionen:
| Vervollständigung |
completion_new +
completion_search +
completion_get_string +
completion_list_add +
completion_free
| Informationen |

View File

@ -823,8 +823,8 @@ def docgen_cmd_cb(data, buf, args):
def docgen_completion_cb(data, completion_item, buf, completion):
"""Callback for completion."""
for locale in LOCALE_LIST:
weechat.hook_completion_list_add(completion, locale, 0,
weechat.WEECHAT_LIST_POS_SORT)
weechat.completion_list_add(completion, locale, 0,
weechat.WEECHAT_LIST_POS_SORT)
return weechat.WEECHAT_RC_OK

View File

@ -8509,8 +8509,7 @@ Arguments:
can include arguments, with the format: _name:arguments_)
** _struct t_gui_buffer *buffer_: buffer where completion is made
** _struct t_gui_completion *completion_: structure used to add words for
completion (see
<<_hook_completion_list_add,hook_completion_list_add>>)
completion (see <<_completion_list_add,completion_list_add>>)
** return value:
*** _WEECHAT_RC_OK_
*** _WEECHAT_RC_ERROR_
@ -8525,8 +8524,8 @@ recommended to choose a name with a unique prefix, like "plugin_xxx" (where
"xxx" is your item name).
[IMPORTANT]
The callback must only call function <<_hook_completion_list_add,hook_completion_list_add>>
and must *NOT* update the command line. +
The callback must only call completion functions like
<<_completion_list_add,completion_list_add>> and must *NOT* update the command line. +
To update the command line when kbd:[Tab] is pressed, you can use the function
<<_hook_command_run,hook_command_run>> with command: `+/input complete_next+`
(and you must return _WEECHAT_RC_OK_EAT_ if your callback has updated the command line,
@ -8545,10 +8544,8 @@ my_completion_cb (const void *pointer, void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
weechat_hook_completion_list_add (completion, "word1",
0, WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion, "test_word2",
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, "word1", 0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, "test_word2", 0, WEECHAT_LIST_POS_SORT);
return WEECHAT_RC_OK;
}
@ -8566,8 +8563,8 @@ hook = weechat.hook_completion(completion_item, description, callback, callback_
# example
def my_completion_cb(data, completion_item, buffer, completion):
weechat.hook_completion_list_add(completion, "word1", 0, weechat.WEECHAT_LIST_POS_SORT)
weechat.hook_completion_list_add(completion, "test_word2", 0, weechat.WEECHAT_LIST_POS_SORT)
weechat.completion_list_add(completion, "word1", 0, weechat.WEECHAT_LIST_POS_SORT)
weechat.completion_list_add(completion, "test_word2", 0, weechat.WEECHAT_LIST_POS_SORT)
return weechat.WEECHAT_RC_OK
hook = weechat.hook_completion("plugin_item", "my custom completion!",
@ -8578,94 +8575,13 @@ hook = weechat.hook_completion("plugin_item", "my custom completion!",
_WeeChat ≥ 0.3.4._
Get a completion property as string.
Prototype:
[source,C]
----
const char *weechat_hook_completion_get_string (struct t_gui_completion *completion,
const char *property);
----
Arguments:
* _completion_: completion pointer
* _property_: property name:
** _base_command_: command used for completion
** _base_word_: word being completed
** _args_: command arguments (including base word)
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)
{
/* get arguments of command */
const char *args = weechat_hook_completion_get_string (completion, "args");
/* completion depending on args */
/* ... */
return WEECHAT_RC_OK;
}
----
Script (Python):
[source,python]
----
# prototype
value = weechat.hook_completion_get_string(completion, property)
# example
def my_completion_cb(data, completion_item, buffer, completion):
# get arguments of command
args = weechat.hook_completion_get_string(completion, "args")
# completion depending on args
# ...
return weechat.WEECHAT_RC_OK
----
*Deprecated since WeeChat 2.9* (still there for compatibility). +
This function has been replaced by <<_completion_get_string,completion_get_string>>.
==== hook_completion_list_add
Add a word for a completion.
Prototype:
[source,C]
----
void weechat_hook_completion_list_add (struct t_gui_completion *completion,
const char *word,
int nick_completion,
const char *where);
----
Arguments:
* _completion_: completion pointer
* _word_: word to add
* _nick_completion_: 1 if word is a nick, otherwise 0
* _where_: position where word will be inserted in list:
** _WEECHAT_LIST_POS_SORT_: any position, to keep list sorted
** _WEECHAT_LIST_POS_BEGINNING_: beginning of list
** _WEECHAT_LIST_POS_END_: end of list
C example: see <<_hook_completion,hook_completion>>.
Script (Python):
[source,python]
----
# prototype
weechat.hook_completion_list_add(completion, word, nick_completion, where)
# example: see function hook_completion above
----
*Deprecated since WeeChat 2.9* (still there for compatibility). +
This function has been replaced by <<_completion_list_add,completion_list_add>>.
==== hook_command_run
@ -15081,6 +14997,101 @@ if weechat.completion_search(completion, "/help filt", 10, 1):
# ...
----
==== completion_get_string
_WeeChat ≥ 2.9._
Get a completion property as string.
Prototype:
[source,C]
----
const char *weechat_completion_get_string (struct t_gui_completion *completion,
const char *property);
----
Arguments:
* _completion_: completion pointer
* _property_: property name:
** _base_command_: command used for completion
** _base_word_: word being completed
** _args_: command arguments (including base word)
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)
{
/* get arguments of command */
const char *args = weechat_completion_get_string (completion, "args");
/* completion depending on args */
/* ... */
return WEECHAT_RC_OK;
}
----
Script (Python):
[source,python]
----
# prototype
value = weechat.completion_get_string(completion, property)
# example
def my_completion_cb(data, completion_item, buffer, completion):
# get arguments of command
args = weechat.completion_get_string(completion, "args")
# completion depending on args
# ...
return weechat.WEECHAT_RC_OK
----
==== completion_list_add
_WeeChat ≥ 2.9._
Add a word for a completion.
Prototype:
[source,C]
----
void weechat_completion_list_add (struct t_gui_completion *completion,
const char *word,
int nick_completion,
const char *where);
----
Arguments:
* _completion_: completion pointer
* _word_: word to add
* _nick_completion_: 1 if word is a nick, otherwise 0
* _where_: position where word will be inserted in list:
** _WEECHAT_LIST_POS_SORT_: any position, to keep list sorted
** _WEECHAT_LIST_POS_BEGINNING_: beginning of list
** _WEECHAT_LIST_POS_END_: end of list
C example: see <<_hook_completion,hook_completion>>.
Script (Python):
[source,python]
----
# prototype
weechat.completion_list_add(completion, word, nick_completion, where)
# example: see function hook_completion
----
==== completion_free
_WeeChat ≥ 2.9._

View File

@ -629,8 +629,6 @@ List of functions in script API:
hook_hsignal_send +
hook_config +
hook_completion +
hook_completion_get_string +
hook_completion_list_add +
hook_modifier +
hook_modifier_exec +
hook_info +
@ -700,6 +698,8 @@ List of functions in script API:
| completion |
completion_new +
completion_search +
completion_get_string +
completion_list_add +
completion_free
| infos |

View File

@ -8650,8 +8650,7 @@ Paramètres :
peut inclure des paramètres, avec le format : _nom:paramètres_)
** _struct t_gui_buffer *buffer_ : tampon où la complétion est effectuée
** _struct t_gui_completion *completion_ : structure utilisée pour ajouter
les mots pour la complétion (voir
<<_hook_completion_list_add,hook_completion_list_add>>)
les mots pour la complétion (voir <<_completion_list_add,completion_list_add>>)
** valeur de retour :
*** _WEECHAT_RC_OK_
*** _WEECHAT_RC_ERROR_
@ -8668,9 +8667,9 @@ Il est donc recommandé de choisir un nom avec un préfixe unique, comme
"monextension_xxx" (où "xxx" est le nom de votre complétion).
[IMPORTANT]
La fonction de rappel doit seulement appeler la fonction
<<_hook_completion_list_add,hook_completion_list_add>>
et ne doit *PAS* mettre à jour la ligne de commande. +
La fonction de rappel doit seulement appeler des fonction de complétion comme
<<_completion_list_add,completion_list_add>> et ne doit *PAS* mettre à jour
la ligne de commande. +
Pour mettre à jour la ligne de commande quand kbd:[Tab] est pressé, vous pouvez
utiliser la fonction <<_hook_command_run,hook_command_run>>
avec la commande : `+/input complete_next+` (et vous devez retourner
@ -8690,10 +8689,8 @@ my_completion_cb (const void *pointer, void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
weechat_hook_completion_list_add (completion, "mot1",
0, WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion, "test_mot2",
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, "mot1", 0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, "test_mot2", 0, WEECHAT_LIST_POS_SORT);
return WEECHAT_RC_OK;
}
@ -8711,8 +8708,8 @@ hook = weechat.hook_completion(completion_item, description, callback, callback_
# exemple
def my_completion_cb(data, completion_item, buffer, completion):
weechat.hook_completion_list_add(completion, "mot1", 0, weechat.WEECHAT_LIST_POS_SORT)
weechat.hook_completion_list_add(completion, "test_mot2", 0, weechat.WEECHAT_LIST_POS_SORT)
weechat.completion_list_add(completion, "mot1", 0, weechat.WEECHAT_LIST_POS_SORT)
weechat.completion_list_add(completion, "test_mot2", 0, weechat.WEECHAT_LIST_POS_SORT)
return weechat.WEECHAT_RC_OK
hook = weechat.hook_completion("extension_item", "ma complétion !",
@ -8723,94 +8720,13 @@ hook = weechat.hook_completion("extension_item", "ma complétion !",
_WeeChat ≥ 0.3.4._
Retourner la valeur d'une propriété de la complétion sous forme de chaîne.
Prototype :
[source,C]
----
const char *weechat_hook_completion_get_string (struct t_gui_completion *completion,
const char *property);
----
Paramètres :
* _completion_ : pointeur vers la complétion
* _property_ : nom de la propriété :
** _base_command_ : commande utilisée pour la complétion
** _base_word_ : le mot qui va être complété
** _args_ : paramètres de la commande (incluant le mot de base "base_word")
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)
{
/* récupère les paramètres de la commande */
const char *args = weechat_hook_completion_get_string (completion, "args");
/* complétion selon les paramètres */
/* ... */
return WEECHAT_RC_OK;
}
----
Script (Python) :
[source,python]
----
# prototype
value = weechat.hook_completion_get_string(completion, property)
# exemple
def my_completion_cb(data, completion_item, buffer, completion):
# récupère les paramètres de la commande
args = weechat.hook_completion_get_string(completion, "args")
# complétion selon les paramètres
# ...
return weechat.WEECHAT_RC_OK
----
*Obsolète depuis WeeChat 2.9* (toujours là pour des raisons de compatibilité). +
Cette fonction a été remplacée par <<_completion_get_string,completion_get_string>>.
==== hook_completion_list_add
Ajouter un mot pour une complétion.
Prototype :
[source,C]
----
void weechat_hook_completion_list_add (struct t_gui_completion *completion,
const char *word,
int nick_completion,
const char *where);
----
Paramètres :
* _completion_ : pointeur vers la complétion
* _word_ : mot à ajouter
* _nick_completion_ : 1 si le mot est un pseudo, sinon 0
* _where_ : position où sera inséré le mot dans la liste :
** _WEECHAT_LIST_POS_SORT_ : n'importe où, pour maintenir la liste triée
** _WEECHAT_LIST_POS_BEGINNING_ : au début de la liste
** _WEECHAT_LIST_POS_END_ : à la fin de la liste
Exemple en C : voir <<_hook_completion,hook_completion>>.
Script (Python) :
[source,python]
----
# prototype
weechat.hook_completion_list_add(completion, word, nick_completion, where)
# exemple : voir la fonction hook_completion ci-dessus
----
*Obsolète depuis WeeChat 2.9* (toujours là pour des raisons de compatibilité). +
Cette fonction a été remplacée par <<_completion_list_add,completion_list_add>>.
==== hook_command_run
@ -15400,6 +15316,101 @@ if weechat.completion_search(completion, "/help filt", 10, 1):
# ...
----
==== completion_get_string
_WeeChat ≥ 2.9._
Retourner la valeur d'une propriété de la complétion sous forme de chaîne.
Prototype :
[source,C]
----
const char *weechat_completion_get_string (struct t_gui_completion *completion,
const char *property);
----
Paramètres :
* _completion_ : pointeur vers la complétion
* _property_ : nom de la propriété :
** _base_command_ : commande utilisée pour la complétion
** _base_word_ : le mot qui va être complété
** _args_ : paramètres de la commande (incluant le mot de base "base_word")
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)
{
/* récupère les paramètres de la commande */
const char *args = weechat_completion_get_string (completion, "args");
/* complétion selon les paramètres */
/* ... */
return WEECHAT_RC_OK;
}
----
Script (Python) :
[source,python]
----
# prototype
value = weechat.completion_get_string(completion, property)
# exemple
def my_completion_cb(data, completion_item, buffer, completion):
# récupère les paramètres de la commande
args = weechat.completion_get_string(completion, "args")
# complétion selon les paramètres
# ...
return weechat.WEECHAT_RC_OK
----
==== completion_list_add
_WeeChat ≥ 2.9._
Ajouter un mot pour une complétion.
Prototype :
[source,C]
----
void weechat_completion_list_add (struct t_gui_completion *completion,
const char *word,
int nick_completion,
const char *where);
----
Paramètres :
* _completion_ : pointeur vers la complétion
* _word_ : mot à ajouter
* _nick_completion_ : 1 si le mot est un pseudo, sinon 0
* _where_ : position où sera inséré le mot dans la liste :
** _WEECHAT_LIST_POS_SORT_ : n'importe où, pour maintenir la liste triée
** _WEECHAT_LIST_POS_BEGINNING_ : au début de la liste
** _WEECHAT_LIST_POS_END_ : à la fin de la liste
Exemple en C : voir <<_hook_completion,hook_completion>>.
Script (Python) :
[source,python]
----
# prototype
weechat.completion_list_add(completion, word, nick_completion, where)
# exemple : voir la fonction hook_completion
----
==== completion_free
_WeeChat ≥ 2.9._

View File

@ -648,8 +648,6 @@ Liste des fonctions de l'API script :
hook_hsignal_send +
hook_config +
hook_completion +
hook_completion_get_string +
hook_completion_list_add +
hook_modifier +
hook_modifier_exec +
hook_info +
@ -719,6 +717,8 @@ Liste des fonctions de l'API script :
| complétion |
completion_new +
completion_search +
completion_get_string +
completion_list_add +
completion_free
| infos |

View File

@ -8773,8 +8773,7 @@ Argomenti:
** _const char *completion_item_: nome dell'elemento del completamento
** _struct t_gui_buffer *buffer_: buffer dove viene eseguito il completamento
** _struct t_gui_completion *completion_: struttura usata per aggiungere
parole per il completamento (consultare
<<_hook_completion_list_add,hook_completion_list_add>>)
parole per il completamento (consultare <<_completion_list_add,completion_list_add>>)
** valore restituito:
*** _WEECHAT_RC_OK_
*** _WEECHAT_RC_ERROR_
@ -8791,9 +8790,8 @@ raccomanda pertanto di scegliere un nome con un prefisso unico, come
// TRANSLATION MISSING
[IMPORTANT]
The callback must only call function
<<_hook_completion_list_add,hook_completion_list_add>>
and must *NOT* update the command line. +
The callback must only call completion functions like
<<_completion_list_add,completion_list_add>> and must *NOT* update the command line. +
To update the command line when kbd:[Tab] is pressed, you can use the function
<<_hook_command_run,hook_command_run>> with command:
`+/input complete_next+` (and you must return _WEECHAT_RC_OK_EAT_ if your callback
@ -8812,10 +8810,8 @@ my_completion_cb (const void *pointer, void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
weechat_hook_completion_list_add (completion, "word1",
0, WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion, "test_word2",
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, "word1", 0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, "test_word2", 0, WEECHAT_LIST_POS_SORT);
return WEECHAT_RC_OK;
}
@ -8833,107 +8829,27 @@ hook = weechat.hook_completion(completion_item, description, callback, callback_
# esempio
def my_completion_cb(data, completion_item, buffer, completion):
weechat.hook_completion_list_add(completion, "word1", 0, weechat.WEECHAT_LIST_POS_SORT)
weechat.hook_completion_list_add(completion, "test_word2", 0, weechat.WEECHAT_LIST_POS_SORT)
weechat.completion_list_add(completion, "word1", 0, weechat.WEECHAT_LIST_POS_SORT)
weechat.completion_list_add(completion, "test_word2", 0, weechat.WEECHAT_LIST_POS_SORT)
return weechat.WEECHAT_RC_OK
hook = weechat.hook_completion("plugin_item", "my custom completion!",
"my_completion_cb", "")
----
// TRANSLATION MISSING
==== hook_completion_get_string
_Novità nella versioe 0.3.4._
Ottiene il completamento di una proprietà come stringa.
Prototipo:
[source,C]
----
const char *weechat_hook_completion_get_string (struct t_gui_completion *completion,
const char *property);
----
Argomenti:
* _completion_: puntatore al completamento
* _property_: nome della proprietà:
** _base_command_: comando usato per il completamento
** _base_word_: parola che viene completata
** _args_: argomenti del comando (inclusa la parola base)
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)
{
/* ottiene l'argomento del comando */
const char *args = weechat_hook_completion_get_string (completion, "args");
/* completamento che dipende dagli argomenti */
/* ... */
return WEECHAT_RC_OK;
}
----
Script (Python):
[source,python]
----
# prototipo
value = weechat.hook_completion_get_string(completion, property)
# esempio
def my_completion_cb(data, completion_item, buffer, completion):
# ottiene l'argomento del comando
args = weechat.hook_completion_get_string(completion, "args")
# completamento che dipende dagli argomenti
# ...
return weechat.WEECHAT_RC_OK
----
*Deprecated since WeeChat 2.9* (still there for compatibility). +
This function has been replaced by <<_completion_get_string,completion_get_string>>.
// TRANSLATION MISSING
==== hook_completion_list_add
Aggiunge una parola per il completamento.
Prototipo:
[source,C]
----
void weechat_hook_completion_list_add (struct t_gui_completion *completion,
const char *word,
int nick_completion,
const char *where);
----
Argomenti:
* _completion_: puntatore al completamento
* _word_: parola da aggiungere
* _nick_completion_: 1 se la parola è un nick, altrimenti 0
* _where_: posizione in cui la parola sarà inserita nella lista:
** _WEECHAT_LIST_POS_SORT_: qualunque posizione, per mantenere
la lista ordinata
** _WEECHAT_LIST_POS_BEGINNING_: inizio della lista
** _WEECHAT_LIST_POS_END_: fine della lista
Esempio in C: consultare <<_hook_completion,hook_completion>>.
Script (Python):
[source,python]
----
# prototipo
weechat.hook_completion_list_add(completion, word, nick_completion, where)
# esempio: consultare function hook_completion precedente
----
*Deprecated since WeeChat 2.9* (still there for compatibility). +
This function has been replaced by <<_completion_list_add,completion_list_add>>.
==== hook_command_run
@ -15682,6 +15598,102 @@ if weechat.completion_search(completion, "/help filt", 10, 1):
# ...
----
==== completion_get_string
_Novità nella versioe 2.9._
Ottiene il completamento di una proprietà come stringa.
Prototipo:
[source,C]
----
const char *weechat_completion_get_string (struct t_gui_completion *completion,
const char *property);
----
Argomenti:
* _completion_: puntatore al completamento
* _property_: nome della proprietà:
** _base_command_: comando usato per il completamento
** _base_word_: parola che viene completata
** _args_: argomenti del comando (inclusa la parola base)
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)
{
/* ottiene l'argomento del comando */
const char *args = weechat_completion_get_string (completion, "args");
/* completamento che dipende dagli argomenti */
/* ... */
return WEECHAT_RC_OK;
}
----
Script (Python):
[source,python]
----
# prototipo
value = weechat.completion_get_string(completion, property)
# esempio
def my_completion_cb(data, completion_item, buffer, completion):
# ottiene l'argomento del comando
args = weechat.completion_get_string(completion, "args")
# completamento che dipende dagli argomenti
# ...
return weechat.WEECHAT_RC_OK
----
==== completion_list_add
_Novità nella versioe 2.9._
Aggiunge una parola per il completamento.
Prototipo:
[source,C]
----
void weechat_completion_list_add (struct t_gui_completion *completion,
const char *word,
int nick_completion,
const char *where);
----
Argomenti:
* _completion_: puntatore al completamento
* _word_: parola da aggiungere
* _nick_completion_: 1 se la parola è un nick, altrimenti 0
* _where_: posizione in cui la parola sarà inserita nella lista:
** _WEECHAT_LIST_POS_SORT_: qualunque posizione, per mantenere
la lista ordinata
** _WEECHAT_LIST_POS_BEGINNING_: inizio della lista
** _WEECHAT_LIST_POS_END_: fine della lista
Esempio in C: consultare <<_hook_completion,hook_completion>>.
Script (Python):
[source,python]
----
# prototipo
weechat.completion_list_add(completion, word, nick_completion, where)
# esempio: consultare function hook_completion
----
// TRANSLATION MISSING
==== completion_free

View File

@ -660,8 +660,6 @@ Elenco di funzioni nelle API per gli script:
hook_hsignal_send +
hook_config +
hook_completion +
hook_completion_get_string +
hook_completion_list_add +
hook_modifier +
hook_modifier_exec +
hook_info +
@ -732,6 +730,8 @@ Elenco di funzioni nelle API per gli script:
| completion |
completion_new +
completion_search +
completion_get_string +
completion_list_add +
completion_free
| info |

View File

@ -8495,7 +8495,7 @@ struct t_hook *weechat_hook_completion (const char *completion_item,
** _struct t_gui_buffer *buffer_: 補完が行われたバッファ
** _struct t_gui_completion *completion_:
補完に際して単語を追加するために使われる構造体
(<<_hook_completion_list_add,hook_completion_list_add>> を参照)
(<<_completion_list_add,completion_list_add>> を参照)
** 戻り値:
*** _WEECHAT_RC_OK_
*** _WEECHAT_RC_ERROR_
@ -8509,10 +8509,10 @@ struct t_hook *weechat_hook_completion (const char *completion_item,
とプラグインで共有されます)。このため、"plugin_xxx" (ここで "xxx" は要素の名前)
などの一意的なプレフィックスをつけた名前を使うことをおすすめします。
// TRANSLATION MISSING
[IMPORTANT]
コールバックは
<<_hook_completion_list_add,hook_completion_list_add>>
関数を呼び出すだけで、コマンドラインをコールバックで絶対に *変更しない* でください。 +
The callback must only call completion functions like
<<_completion_list_add,completion_list_add>> and must *NOT* update the command line. +
kbd:[Tab] が押された時にコマンドラインを更新するためには、関数
<<_hook_command_run,hook_command_run>> を使ってコマンド
`+/input complete_next+` をフックしてください (コールバックがコマンドラインを更新する場合は必ず
@ -8531,10 +8531,8 @@ my_completion_cb (const void *pointer, void *data, const char *completion_item,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
weechat_hook_completion_list_add (completion, "word1",
0, WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion, "test_word2",
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, "word1", 0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, "test_word2", 0, WEECHAT_LIST_POS_SORT);
return WEECHAT_RC_OK;
}
@ -8552,106 +8550,27 @@ hook = weechat.hook_completion(completion_item, description, callback, callback_
# 例
def my_completion_cb(data, completion_item, buffer, completion):
weechat.hook_completion_list_add(completion, "word1", 0, weechat.WEECHAT_LIST_POS_SORT)
weechat.hook_completion_list_add(completion, "test_word2", 0, weechat.WEECHAT_LIST_POS_SORT)
weechat.completion_list_add(completion, "word1", 0, weechat.WEECHAT_LIST_POS_SORT)
weechat.completion_list_add(completion, "test_word2", 0, weechat.WEECHAT_LIST_POS_SORT)
return weechat.WEECHAT_RC_OK
hook = weechat.hook_completion("plugin_item", "my custom completion!",
"my_completion_cb", "")
----
// TRANSLATION MISSING
==== hook_completion_get_string
_WeeChat バージョン 0.3.4 以上で利用可。_
補完プロパティを文字列で取得。
プロトタイプ:
[source,C]
----
const char *weechat_hook_completion_get_string (struct t_gui_completion *completion,
const char *property);
----
引数:
* _completion_: 補完へのポインタ
* _property_: プロパティ名:
** _base_command_: 補完に使ったコマンド
** _base_word_: 補完された単語
** _args_: コマンド引数 (元の単語を含む)
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)
{
/* get arguments of command */
const char *args = weechat_hook_completion_get_string (completion, "args");
/* completion depending on args */
/* ... */
return WEECHAT_RC_OK;
}
----
スクリプト (Python) での使用例:
[source,python]
----
# プロトタイプ
value = weechat.hook_completion_get_string(completion, property)
# 例
def my_completion_cb(data, completion_item, buffer, completion):
# get arguments of command
args = weechat.hook_completion_get_string(completion, "args")
# completion depending on args
# ...
return weechat.WEECHAT_RC_OK
----
*Deprecated since WeeChat 2.9* (still there for compatibility). +
This function has been replaced by <<_completion_get_string,completion_get_string>>.
// TRANSLATION MISSING
==== hook_completion_list_add
補完用に単語を追加。
プロトタイプ:
[source,C]
----
void weechat_hook_completion_list_add (struct t_gui_completion *completion,
const char *word,
int nick_completion,
const char *where);
----
引数:
* _completion_: 補完へのポインタ
* _word_: 追加する単語
* _nick_completion_: 単語がニックネームの場合は 1、そうでなければ 0
* _where_: 単語を追加するリスト上での位置:
** _WEECHAT_LIST_POS_SORT_: リストがソートされた状態になるような位置
** _WEECHAT_LIST_POS_BEGINNING_: リストの最初
** _WEECHAT_LIST_POS_END_: リストの最後
C 言語での使用例: <<_hook_completion,hook_completion>> を参照。
スクリプト (Python) での使用例:
[source,python]
----
# プロトタイプ
weechat.hook_completion_list_add(completion, word, nick_completion, where)
# 例: 前の hook_completion 関数を参照
----
*Deprecated since WeeChat 2.9* (still there for compatibility). +
This function has been replaced by <<_completion_list_add,completion_list_add>>.
==== hook_command_run
@ -15074,6 +14993,102 @@ if weechat.completion_search(completion, "/help filt", 10, 1):
# ...
----
==== completion_get_string
_WeeChat バージョン 2.9 以上で利用可。_
補完プロパティを文字列で取得。
プロトタイプ:
[source,C]
----
const char *weechat_completion_get_string (struct t_gui_completion *completion,
const char *property);
----
引数:
* _completion_: 補完へのポインタ
* _property_: プロパティ名:
** _base_command_: 補完に使ったコマンド
** _base_word_: 補完された単語
** _args_: コマンド引数 (元の単語を含む)
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)
{
/* get arguments of command */
const char *args = weechat_completion_get_string (completion, "args");
/* completion depending on args */
/* ... */
return WEECHAT_RC_OK;
}
----
スクリプト (Python) での使用例:
[source,python]
----
# プロトタイプ
value = weechat.completion_get_string(completion, property)
# 例
def my_completion_cb(data, completion_item, buffer, completion):
# get arguments of command
args = weechat.completion_get_string(completion, "args")
# completion depending on args
# ...
return weechat.WEECHAT_RC_OK
----
==== completion_list_add
_WeeChat バージョン 2.9 以上で利用可。_
補完用に単語を追加。
プロトタイプ:
[source,C]
----
void weechat_completion_list_add (struct t_gui_completion *completion,
const char *word,
int nick_completion,
const char *where);
----
引数:
* _completion_: 補完へのポインタ
* _word_: 追加する単語
* _nick_completion_: 単語がニックネームの場合は 1、そうでなければ 0
* _where_: 単語を追加するリスト上での位置:
** _WEECHAT_LIST_POS_SORT_: リストがソートされた状態になるような位置
** _WEECHAT_LIST_POS_BEGINNING_: リストの最初
** _WEECHAT_LIST_POS_END_: リストの最後
C 言語での使用例: <<_hook_completion,hook_completion>> を参照。
スクリプト (Python) での使用例:
// TRANSLATION MISSING
[source,python]
----
# プロトタイプ
weechat.completion_list_add(completion, word, nick_completion, where)
# 例: see function hook_completion
----
// TRANSLATION MISSING
==== completion_free

View File

@ -648,8 +648,6 @@ link:weechat_plugin_api.ja.html[WeeChat プラグイン API リファレンス]
hook_hsignal_send +
hook_config +
hook_completion +
hook_completion_get_string +
hook_completion_list_add +
hook_modifier +
hook_modifier_exec +
hook_info +
@ -720,6 +718,8 @@ link:weechat_plugin_api.ja.html[WeeChat プラグイン API リファレンス]
| completion |
completion_new +
completion_search +
completion_get_string +
completion_list_add +
completion_free
| インフォ |

View File

@ -634,8 +634,6 @@ Lista funkcji w API skryptów:
hook_hsignal_send +
hook_config +
hook_completion +
hook_completion_get_string +
hook_completion_list_add +
hook_modifier +
hook_modifier_exec +
hook_info +
@ -706,6 +704,8 @@ Lista funkcji w API skryptów:
| completion |
completion_new +
completion_search +
completion_get_string +
completion_list_add +
completion_free
| informacje |

View File

@ -82,29 +82,6 @@ hook_completion (struct t_weechat_plugin *plugin, const char *completion_item,
return new_hook;
}
/*
* Gets a completion property as string.
*/
const char *
hook_completion_get_string (struct t_gui_completion *completion,
const char *property)
{
return gui_completion_get_string (completion, property);
}
/*
* Adds a word for a completion.
*/
void
hook_completion_list_add (struct t_gui_completion *completion,
const char *word, int nick_completion,
const char *where)
{
gui_completion_list_add (completion, word, nick_completion, where);
}
/*
* Executes a completion hook.
*/

View File

@ -45,11 +45,6 @@ extern struct t_hook *hook_completion (struct t_weechat_plugin *plugin,
t_hook_callback_completion *callback,
const void *callback_pointer,
void *callback_data);
extern const char *hook_completion_get_string (struct t_gui_completion *completion,
const char *property);
extern void hook_completion_list_add (struct t_gui_completion *completion,
const char *word, int nick_completion,
const char *where);
extern void hook_completion_exec (struct t_weechat_plugin *plugin,
const char *completion_item,
struct t_gui_buffer *buffer,

View File

@ -48,8 +48,8 @@ alias_completion_alias_cb (const void *pointer, void *data,
for (ptr_alias = alias_list; ptr_alias;
ptr_alias = ptr_alias->next_alias)
{
weechat_hook_completion_list_add (completion, ptr_alias->name,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, ptr_alias->name,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
@ -76,7 +76,7 @@ alias_completion_alias_value_cb (const void *pointer, void *data,
(void) completion_item;
(void) buffer;
args = weechat_hook_completion_get_string (completion, "args");
args = weechat_completion_get_string (completion, "args");
if (args)
{
argv = weechat_string_split (args, " ", NULL,
@ -96,10 +96,10 @@ alias_completion_alias_value_cb (const void *pointer, void *data,
ptr_alias = alias_search (alias_name);
if (ptr_alias)
{
weechat_hook_completion_list_add (completion,
ptr_alias->command,
0,
WEECHAT_LIST_POS_BEGINNING);
weechat_completion_list_add (completion,
ptr_alias->command,
0,
WEECHAT_LIST_POS_BEGINNING);
}
free (alias_name);
}

View File

@ -51,12 +51,12 @@ exec_completion_commands_ids_cb (const void *pointer, void *data,
{
snprintf (str_number, sizeof (str_number),
"%ld", ptr_exec_cmd->number);
weechat_hook_completion_list_add (completion, str_number,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, str_number,
0, WEECHAT_LIST_POS_SORT);
if (ptr_exec_cmd->name)
{
weechat_hook_completion_list_add (completion, ptr_exec_cmd->name,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, ptr_exec_cmd->name,
0, WEECHAT_LIST_POS_SORT);
}
}

View File

@ -62,19 +62,19 @@ fset_completion_option_cb (const void *pointer, void *data,
{
if (!config_section_added)
{
weechat_hook_completion_list_add (
weechat_completion_list_add (
completion,
weechat_config_option_get_string (ptr_option,
"config_name"),
0, WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (
weechat_completion_list_add (
completion,
weechat_config_option_get_string (ptr_option,
"section_name"),
0, WEECHAT_LIST_POS_SORT);
config_section_added = 1;
}
weechat_hook_completion_list_add (
weechat_completion_list_add (
completion,
weechat_config_option_get_string (ptr_option, "name"),
0,
@ -92,7 +92,7 @@ fset_completion_option_cb (const void *pointer, void *data,
{
for (i = 0; i < num_words; i++)
{
weechat_hook_completion_list_add (
weechat_completion_list_add (
completion, words[i], 0, WEECHAT_LIST_POS_SORT);
}
}

View File

@ -2057,6 +2057,11 @@ weechat_guile_api_hook_completion (SCM completion, SCM description,
API_RETURN_STRING(result);
}
/*
* This function deprecated since WeeChat 2.9, kept for compatibility.
* It is replaced by completion_get_string.
*/
SCM
weechat_guile_api_hook_completion_get_string (SCM completion, SCM property)
{
@ -2074,6 +2079,11 @@ weechat_guile_api_hook_completion_get_string (SCM completion, SCM property)
API_RETURN_STRING(result);
}
/*
* This function deprecated since WeeChat 2.9, kept for compatibility.
* It is replaced by completion_list_add.
*/
SCM
weechat_guile_api_hook_completion_list_add (SCM completion, SCM word,
SCM nick_completion, SCM where)
@ -4137,6 +4147,40 @@ weechat_guile_api_completion_search (SCM completion, SCM data, SCM position,
API_RETURN_INT(rc);
}
SCM
weechat_guile_api_completion_get_string (SCM completion, SCM property)
{
const char *result;
SCM return_value;
API_INIT_FUNC(1, "completion_get_string", API_RETURN_EMPTY);
if (!scm_is_string (completion) || !scm_is_string (property))
API_WRONG_ARGS(API_RETURN_EMPTY);
result = weechat_completion_get_string (
API_STR2PTR(API_SCM_TO_STRING(completion)),
API_SCM_TO_STRING(property));
API_RETURN_STRING(result);
}
SCM
weechat_guile_api_completion_list_add (SCM completion, SCM word,
SCM nick_completion, SCM where)
{
API_INIT_FUNC(1, "completion_list_add", API_RETURN_ERROR);
if (!scm_is_string (completion) || !scm_is_string (word)
|| !scm_is_integer (nick_completion) || !scm_is_string (where))
API_WRONG_ARGS(API_RETURN_ERROR);
weechat_completion_list_add (API_STR2PTR(API_SCM_TO_STRING(completion)),
API_SCM_TO_STRING(word),
scm_to_int (nick_completion),
API_SCM_TO_STRING(where));
API_RETURN_OK;
}
SCM
weechat_guile_api_completion_free (SCM completion)
{
@ -5103,6 +5147,8 @@ weechat_guile_api_module_init (void *data)
API_DEF_FUNC(command_options, 3);
API_DEF_FUNC(completion_new, 1);
API_DEF_FUNC(completion_search, 4);
API_DEF_FUNC(completion_get_string, 2);
API_DEF_FUNC(completion_list_add, 4);
API_DEF_FUNC(completion_free, 1);
API_DEF_FUNC(info_get, 2);
API_DEF_FUNC(info_get_hashtable, 2);

View File

@ -56,8 +56,8 @@ irc_completion_server_cb (const void *pointer, void *data,
if (ptr_server)
{
weechat_hook_completion_list_add (completion, ptr_server->name,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, ptr_server->name,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
@ -82,8 +82,8 @@ irc_completion_server_nick_cb (const void *pointer, void *data,
if (ptr_server && ptr_server->nick)
{
weechat_hook_completion_list_add (completion, ptr_server->nick,
1, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, ptr_server->nick,
1, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
@ -115,16 +115,16 @@ irc_completion_server_channels_cb (const void *pointer, void *data,
{
if (ptr_channel2->type == IRC_CHANNEL_TYPE_CHANNEL)
{
weechat_hook_completion_list_add (completion, ptr_channel2->name,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, ptr_channel2->name,
0, WEECHAT_LIST_POS_SORT);
}
}
/* add current channel first in list */
if (ptr_channel)
{
weechat_hook_completion_list_add (completion, ptr_channel->name,
0, WEECHAT_LIST_POS_BEGINNING);
weechat_completion_list_add (completion, ptr_channel->name,
0, WEECHAT_LIST_POS_BEGINNING);
}
}
@ -157,8 +157,8 @@ irc_completion_server_privates_cb (const void *pointer, void *data,
{
if (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE)
{
weechat_hook_completion_list_add (completion, ptr_channel->name,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, ptr_channel->name,
0, WEECHAT_LIST_POS_SORT);
}
}
}
@ -196,15 +196,15 @@ irc_completion_server_nicks_cb (const void *pointer, void *data,
for (ptr_nick = ptr_channel2->nicks; ptr_nick;
ptr_nick = ptr_nick->next_nick)
{
weechat_hook_completion_list_add (completion, ptr_nick->name,
1, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, ptr_nick->name,
1, WEECHAT_LIST_POS_SORT);
}
}
}
/* add self nick at the end */
weechat_hook_completion_list_add (completion, ptr_server->nick,
1, WEECHAT_LIST_POS_END);
weechat_completion_list_add (completion, ptr_server->nick,
1, WEECHAT_LIST_POS_END);
}
return WEECHAT_RC_OK;
@ -231,8 +231,8 @@ irc_completion_servers_cb (const void *pointer, void *data,
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
weechat_hook_completion_list_add (completion, ptr_server->name,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, ptr_server->name,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
@ -257,8 +257,8 @@ irc_completion_channel_cb (const void *pointer, void *data,
if (ptr_channel)
{
weechat_hook_completion_list_add (completion, ptr_channel->name,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, ptr_channel->name,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
@ -286,10 +286,10 @@ irc_completion_channel_nicks_add_speakers (struct t_gui_completion *completion,
weechat_list_get (channel->nicks_speaking[highlight], i));
if (nick && irc_nick_search (server, channel, nick))
{
weechat_hook_completion_list_add (completion,
nick,
1,
WEECHAT_LIST_POS_BEGINNING);
weechat_completion_list_add (completion,
nick,
1,
WEECHAT_LIST_POS_BEGINNING);
}
}
}
@ -322,10 +322,10 @@ irc_completion_channel_nicks_cb (const void *pointer, void *data,
for (ptr_nick = ptr_channel->nicks; ptr_nick;
ptr_nick = ptr_nick->next_nick)
{
weechat_hook_completion_list_add (completion,
ptr_nick->name,
1,
WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion,
ptr_nick->name,
1,
WEECHAT_LIST_POS_SORT);
}
/* add recent speakers on channel */
if (weechat_config_integer (irc_config_look_nick_completion_smart) == IRC_CONFIG_NICK_COMPLETION_SMART_SPEAKERS)
@ -338,22 +338,22 @@ irc_completion_channel_nicks_cb (const void *pointer, void *data,
irc_completion_channel_nicks_add_speakers (completion, ptr_server, ptr_channel, 1);
}
/* add self nick at the end */
weechat_hook_completion_list_add (completion,
ptr_server->nick,
1,
WEECHAT_LIST_POS_END);
weechat_completion_list_add (completion,
ptr_server->nick,
1,
WEECHAT_LIST_POS_END);
break;
case IRC_CHANNEL_TYPE_PRIVATE:
/* remote nick */
weechat_hook_completion_list_add (completion,
ptr_channel->name,
1,
WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion,
ptr_channel->name,
1,
WEECHAT_LIST_POS_SORT);
/* add self nick at the end */
weechat_hook_completion_list_add (completion,
ptr_server->nick,
1,
WEECHAT_LIST_POS_END);
weechat_completion_list_add (completion,
ptr_server->nick,
1,
WEECHAT_LIST_POS_END);
break;
}
ptr_channel->nick_completion_reset = 0;
@ -391,10 +391,10 @@ irc_completion_channel_nicks_hosts_cb (const void *pointer, void *data,
for (ptr_nick = ptr_channel->nicks; ptr_nick;
ptr_nick = ptr_nick->next_nick)
{
weechat_hook_completion_list_add (completion,
ptr_nick->name,
1,
WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion,
ptr_nick->name,
1,
WEECHAT_LIST_POS_SORT);
if (ptr_nick->host)
{
length = strlen (ptr_nick->name) + 1 +
@ -404,7 +404,7 @@ irc_completion_channel_nicks_hosts_cb (const void *pointer, void *data,
{
snprintf (buf, length, "%s!%s",
ptr_nick->name, ptr_nick->host);
weechat_hook_completion_list_add (
weechat_completion_list_add (
completion, buf, 0, WEECHAT_LIST_POS_SORT);
free (buf);
}
@ -412,7 +412,7 @@ irc_completion_channel_nicks_hosts_cb (const void *pointer, void *data,
}
break;
case IRC_CHANNEL_TYPE_PRIVATE:
weechat_hook_completion_list_add (
weechat_completion_list_add (
completion, ptr_channel->name, 1, WEECHAT_LIST_POS_SORT);
break;
}
@ -453,9 +453,9 @@ irc_completion_modelist_masks_cb (const void *pointer, void *data,
for (ptr_item = ptr_modelist->items; ptr_item;
ptr_item = ptr_item->next_item)
{
weechat_hook_completion_list_add (completion,
ptr_item->mask,
0, WEECHAT_LIST_POS_END);
weechat_completion_list_add (completion,
ptr_item->mask,
0, WEECHAT_LIST_POS_END);
}
}
}
@ -497,9 +497,9 @@ irc_completion_modelist_numbers_cb (const void *pointer, void *data,
{
snprintf (str_number, sizeof (str_number),
"%d", ptr_item->number + 1);
weechat_hook_completion_list_add (completion,
str_number,
0, WEECHAT_LIST_POS_END);
weechat_completion_list_add (completion,
str_number,
0, WEECHAT_LIST_POS_END);
}
}
}
@ -551,9 +551,9 @@ irc_completion_channel_topic_cb (const void *pointer, void *data,
else
topic = strdup (ptr_channel->topic);
weechat_hook_completion_list_add (completion,
(topic) ? topic : ptr_channel->topic,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion,
(topic) ? topic : ptr_channel->topic,
0, WEECHAT_LIST_POS_SORT);
if (topic)
free (topic);
}
@ -603,10 +603,10 @@ irc_completion_channels_cb (const void *pointer, void *data,
}
else
{
weechat_hook_completion_list_add (completion,
ptr_channel2->name,
0,
WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion,
ptr_channel2->name,
0,
WEECHAT_LIST_POS_SORT);
}
}
}
@ -615,7 +615,7 @@ irc_completion_channels_cb (const void *pointer, void *data,
/* add channels of current server first in list */
for (i = weechat_list_size (channels_current_server) - 1; i >= 0; i--)
{
weechat_hook_completion_list_add (
weechat_completion_list_add (
completion,
weechat_list_string (
weechat_list_get (channels_current_server, i)),
@ -627,8 +627,8 @@ irc_completion_channels_cb (const void *pointer, void *data,
/* add current channel first in list */
if (ptr_channel)
{
weechat_hook_completion_list_add (completion, ptr_channel->name,
0, WEECHAT_LIST_POS_BEGINNING);
weechat_completion_list_add (completion, ptr_channel->name,
0, WEECHAT_LIST_POS_BEGINNING);
}
return WEECHAT_RC_OK;
@ -661,8 +661,8 @@ irc_completion_privates_cb (const void *pointer, void *data,
{
if (ptr_channel->type == IRC_CHANNEL_TYPE_PRIVATE)
{
weechat_hook_completion_list_add (completion, ptr_channel->name,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, ptr_channel->name,
0, WEECHAT_LIST_POS_SORT);
}
}
}
@ -695,8 +695,8 @@ irc_completion_msg_kick_cb (const void *pointer, void *data,
IRC_SERVER_OPTION_MSG_KICK);
if (msg_kick && msg_kick[0])
{
weechat_hook_completion_list_add (completion, msg_kick,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, msg_kick,
0, WEECHAT_LIST_POS_SORT);
}
}
@ -728,8 +728,8 @@ irc_completion_msg_part_cb (const void *pointer, void *data,
IRC_SERVER_OPTION_MSG_PART);
if (msg_part && msg_part[0])
{
weechat_hook_completion_list_add (completion, msg_part,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, msg_part,
0, WEECHAT_LIST_POS_SORT);
}
}
@ -759,8 +759,8 @@ irc_completion_ignores_numbers_cb (const void *pointer, void *data,
ptr_ignore = ptr_ignore->next_ignore)
{
snprintf (str_number, sizeof (str_number), "%d", ptr_ignore->number);
weechat_hook_completion_list_add (completion, str_number,
0, WEECHAT_LIST_POS_END);
weechat_completion_list_add (completion, str_number,
0, WEECHAT_LIST_POS_END);
}
return WEECHAT_RC_OK;
@ -790,8 +790,8 @@ irc_completion_notify_nicks_cb (const void *pointer, void *data,
for (ptr_notify = ptr_server->notify_list; ptr_notify;
ptr_notify = ptr_notify->next_notify)
{
weechat_hook_completion_list_add (completion, ptr_notify->nick,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, ptr_notify->nick,
0, WEECHAT_LIST_POS_SORT);
}
}
else
@ -802,8 +802,8 @@ irc_completion_notify_nicks_cb (const void *pointer, void *data,
for (ptr_notify = ptr_server->notify_list; ptr_notify;
ptr_notify = ptr_notify->next_notify)
{
weechat_hook_completion_list_add (completion, ptr_notify->nick,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, ptr_notify->nick,
0, WEECHAT_LIST_POS_SORT);
}
}
}
@ -831,37 +831,37 @@ irc_completion_raw_filters_cb (const void *pointer, void *data,
(void) completion_item;
/* all messages */
weechat_hook_completion_list_add (completion, "*",
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, "*",
0, WEECHAT_LIST_POS_SORT);
/* condition */
weechat_hook_completion_list_add (completion,
"c:${recv} && ${command}==PRIVMSG",
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion,
"c:${recv} && ${command}==PRIVMSG",
0, WEECHAT_LIST_POS_SORT);
/* message flag */
weechat_hook_completion_list_add (completion, "f:modified",
0, WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion, "f:recv",
0, WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion, "f:redirected",
0, WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion, "f:sent",
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, "f:modified",
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, "f:recv",
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, "f:redirected",
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, "f:sent",
0, WEECHAT_LIST_POS_SORT);
/* IRC command */
weechat_hook_completion_list_add (completion, "m:notice",
0, WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion, "m:privmsg",
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, "m:notice",
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, "m:privmsg",
0, WEECHAT_LIST_POS_SORT);
/* server */
for (ptr_server = irc_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
snprintf (str_filter, sizeof (str_filter), "s:%s", ptr_server->name);
weechat_hook_completion_list_add (completion, str_filter,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, str_filter,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;

View File

@ -1948,6 +1948,11 @@ API_FUNC(hook_completion)
API_RETURN_STRING(result);
}
/*
* This function deprecated since WeeChat 2.9, kept for compatibility.
* It is replaced by completion_get_string.
*/
API_FUNC(hook_completion_get_string)
{
const char *result;
@ -1964,6 +1969,11 @@ API_FUNC(hook_completion_get_string)
API_RETURN_STRING(result);
}
/*
* This function deprecated since WeeChat 2.9, kept for compatibility.
* It is replaced by completion_list_add.
*/
API_FUNC(hook_completion_list_add)
{
int nick_completion;
@ -4033,6 +4043,42 @@ API_FUNC(completion_search)
API_RETURN_INT(rc);
}
API_FUNC(completion_get_string)
{
const char *result;
API_INIT_FUNC(1, "completion_get_string", "ss", API_RETURN_EMPTY);
v8::String::Utf8Value completion(args[0]);
v8::String::Utf8Value property(args[1]);
result = weechat_completion_get_string (
(struct t_gui_completion *)API_STR2PTR(*completion),
*property);
API_RETURN_STRING(result);
}
API_FUNC(completion_list_add)
{
int nick_completion;
API_INIT_FUNC(1, "completion_list_add", "ssis", API_RETURN_ERROR);
v8::String::Utf8Value completion(args[0]);
v8::String::Utf8Value word(args[1]);
nick_completion = args[2]->IntegerValue();
v8::String::Utf8Value where(args[3]);
weechat_completion_list_add (
(struct t_gui_completion *)API_STR2PTR(*completion),
*word,
nick_completion,
*where);
API_RETURN_OK;
}
API_FUNC(completion_free)
{
API_INIT_FUNC(1, "completion_free", "s", API_RETURN_ERROR);
@ -5038,6 +5084,8 @@ WeechatJsV8::loadLibs()
API_DEF_FUNC(command_options);
API_DEF_FUNC(completion_new);
API_DEF_FUNC(completion_search);
API_DEF_FUNC(completion_get_string);
API_DEF_FUNC(completion_list_add);
API_DEF_FUNC(completion_free);
API_DEF_FUNC(info_get);
API_DEF_FUNC(info_get_hashtable);

View File

@ -2165,6 +2165,11 @@ API_FUNC(hook_completion)
API_RETURN_STRING(result);
}
/*
* This function deprecated since WeeChat 2.9, kept for compatibility.
* It is replaced by completion_get_string.
*/
API_FUNC(hook_completion_get_string)
{
const char *completion, *property, *result;
@ -2182,6 +2187,11 @@ API_FUNC(hook_completion_get_string)
API_RETURN_STRING(result);
}
/*
* This function deprecated since WeeChat 2.9, kept for compatibility.
* It is replaced by completion_list_add.
*/
API_FUNC(hook_completion_list_add)
{
const char *completion, *word, *where;
@ -4373,6 +4383,45 @@ API_FUNC(completion_search)
API_RETURN_INT(rc);
}
API_FUNC(completion_get_string)
{
const char *completion, *property, *result;
API_INIT_FUNC(1, "completion_get_string", API_RETURN_EMPTY);
if (lua_gettop (L) < 2)
API_WRONG_ARGS(API_RETURN_EMPTY);
completion = lua_tostring (L, -2);
property = lua_tostring (L, -1);
result = weechat_completion_get_string (API_STR2PTR(completion),
property);
API_RETURN_STRING(result);
}
API_FUNC(completion_list_add)
{
const char *completion, *word, *where;
int nick_completion;
API_INIT_FUNC(1, "completion_list_add", API_RETURN_ERROR);
if (lua_gettop (L) < 4)
API_WRONG_ARGS(API_RETURN_ERROR);
completion = lua_tostring (L, -4);
word = lua_tostring (L, -3);
nick_completion = lua_tonumber (L, -2);
where = lua_tostring (L, -1);
weechat_completion_list_add (API_STR2PTR(completion),
word,
nick_completion,
where);
API_RETURN_OK;
}
API_FUNC(completion_free)
{
const char *completion;
@ -5398,6 +5447,8 @@ const struct luaL_Reg weechat_lua_api_funcs[] = {
API_DEF_FUNC(command_options),
API_DEF_FUNC(completion_new),
API_DEF_FUNC(completion_search),
API_DEF_FUNC(completion_get_string),
API_DEF_FUNC(completion_list_add),
API_DEF_FUNC(completion_free),
API_DEF_FUNC(info_get),
API_DEF_FUNC(info_get_hashtable),

View File

@ -2081,6 +2081,11 @@ API_FUNC(hook_completion)
API_RETURN_STRING(result);
}
/*
* This function deprecated since WeeChat 2.9, kept for compatibility.
* It is replaced by completion_get_string.
*/
API_FUNC(hook_completion_get_string)
{
char *completion, *property;
@ -2100,6 +2105,11 @@ API_FUNC(hook_completion_get_string)
API_RETURN_STRING(result);
}
/*
* This function deprecated since WeeChat 2.9, kept for compatibility.
* It is replaced by completion_list_add.
*/
API_FUNC(hook_completion_list_add)
{
char *completion, *word, *where;
@ -4296,6 +4306,46 @@ API_FUNC(completion_search)
API_RETURN_INT(rc);
}
API_FUNC(completion_get_string)
{
char *completion, *property;
const char *result;
dXSARGS;
API_INIT_FUNC(1, "completion_get_string", API_RETURN_EMPTY);
if (items < 2)
API_WRONG_ARGS(API_RETURN_EMPTY);
completion = SvPV_nolen (ST (0));
property = SvPV_nolen (ST (1));
result = weechat_completion_get_string (API_STR2PTR(completion),
property);
API_RETURN_STRING(result);
}
API_FUNC(completion_list_add)
{
char *completion, *word, *where;
dXSARGS;
API_INIT_FUNC(1, "completion_list_add", API_RETURN_ERROR);
if (items < 4)
API_WRONG_ARGS(API_RETURN_ERROR);
completion = SvPV_nolen (ST (0));
word = SvPV_nolen (ST (1));
where = SvPV_nolen (ST (3));
weechat_completion_list_add (API_STR2PTR(completion),
word,
SvIV (ST (2)), /* nick_completion */
where);
API_RETURN_OK;
}
API_FUNC(completion_free)
{
dXSARGS;
@ -5355,6 +5405,8 @@ weechat_perl_api_init (pTHX)
API_DEF_FUNC(command_options);
API_DEF_FUNC(completion_new);
API_DEF_FUNC(completion_search);
API_DEF_FUNC(completion_get_string);
API_DEF_FUNC(completion_list_add);
API_DEF_FUNC(completion_free);
API_DEF_FUNC(info_get);
API_DEF_FUNC(info_get_hashtable);

View File

@ -2206,6 +2206,11 @@ API_FUNC(hook_completion)
API_RETURN_STRING(result);
}
/*
* This function deprecated since WeeChat 2.9, kept for compatibility.
* It is replaced by completion_get_string.
*/
API_FUNC(hook_completion_get_string)
{
zend_string *z_completion, *z_property;
@ -2227,6 +2232,11 @@ API_FUNC(hook_completion_get_string)
API_RETURN_STRING(result);
}
/*
* This function deprecated since WeeChat 2.9, kept for compatibility.
* It is replaced by completion_list_add.
*/
API_FUNC(hook_completion_list_add)
{
zend_string *z_completion, *z_word, *z_where;
@ -4308,6 +4318,53 @@ API_FUNC(completion_search)
API_RETURN_INT(rc);
}
API_FUNC(completion_get_string)
{
zend_string *z_completion, *z_property;
struct t_gui_completion *completion;
char *property;
const char *result;
API_INIT_FUNC(1, "completion_get_string", API_RETURN_EMPTY);
if (zend_parse_parameters (ZEND_NUM_ARGS(), "SS", &z_completion,
&z_property) == FAILURE)
API_WRONG_ARGS(API_RETURN_EMPTY);
completion = (struct t_gui_completion *)API_STR2PTR(ZSTR_VAL(z_completion));
property = ZSTR_VAL(z_property);
result = weechat_completion_get_string (completion,
(const char *)property);
API_RETURN_STRING(result);
}
API_FUNC(completion_list_add)
{
zend_string *z_completion, *z_word, *z_where;
zend_long z_nick_completion;
struct t_gui_completion *completion;
char *word, *where;
int nick_completion;
API_INIT_FUNC(1, "completion_list_add", API_RETURN_ERROR);
if (zend_parse_parameters (ZEND_NUM_ARGS(), "SSlS", &z_completion,
&z_word, &z_nick_completion, &z_where) == FAILURE)
API_WRONG_ARGS(API_RETURN_ERROR);
completion = (struct t_gui_completion *)API_STR2PTR(ZSTR_VAL(z_completion));
word = ZSTR_VAL(z_word);
nick_completion = (int)z_nick_completion;
where = ZSTR_VAL(z_where);
weechat_completion_list_add (completion,
(const char *)word,
nick_completion,
(const char *)where);
API_RETURN_OK;
}
API_FUNC(completion_free)
{
zend_string *z_completion;

View File

@ -200,6 +200,8 @@ PHP_FUNCTION(weechat_command);
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_list_add);
PHP_FUNCTION(weechat_completion_free);
PHP_FUNCTION(weechat_info_get);
PHP_FUNCTION(weechat_info_get_hashtable);

View File

@ -253,6 +253,8 @@ const zend_function_entry weechat_functions[] = {
PHP_FE(weechat_command_options, NULL)
PHP_FE(weechat_completion_new, NULL)
PHP_FE(weechat_completion_search, NULL)
PHP_FE(weechat_completion_get_string, NULL)
PHP_FE(weechat_completion_list_add, NULL)
PHP_FE(weechat_completion_free, NULL)
PHP_FE(weechat_info_get, NULL)
PHP_FE(weechat_info_get_hashtable, NULL)

View File

@ -1087,8 +1087,8 @@ plugin_script_completion (struct t_weechat_plugin *weechat_plugin,
for (ptr_script = scripts; ptr_script;
ptr_script = ptr_script->next_script)
{
weechat_hook_completion_list_add (completion, ptr_script->name,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, ptr_script->name,
0, WEECHAT_LIST_POS_SORT);
}
}

View File

@ -786,8 +786,8 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv)
new_plugin->hook_hsignal_send = &hook_hsignal_send;
new_plugin->hook_config = &hook_config;
new_plugin->hook_completion = &hook_completion;
new_plugin->hook_completion_get_string = &hook_completion_get_string;
new_plugin->hook_completion_list_add = &hook_completion_list_add;
new_plugin->hook_completion_get_string = &gui_completion_get_string;
new_plugin->hook_completion_list_add = &gui_completion_list_add;
new_plugin->hook_modifier = &hook_modifier;
new_plugin->hook_modifier_exec = &hook_modifier_exec;
new_plugin->hook_info = &hook_info;
@ -852,6 +852,8 @@ 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_list_add = &gui_completion_list_add;
new_plugin->completion_free = &gui_completion_free;
new_plugin->network_pass_proxy = &network_pass_proxy;

View File

@ -2071,6 +2071,11 @@ API_FUNC(hook_completion)
API_RETURN_STRING(result);
}
/*
* This function deprecated since WeeChat 2.9, kept for compatibility.
* It is replaced by completion_get_string.
*/
API_FUNC(hook_completion_get_string)
{
char *completion, *property;
@ -2088,6 +2093,11 @@ API_FUNC(hook_completion_get_string)
API_RETURN_STRING(result);
}
/*
* This function deprecated since WeeChat 2.9, kept for compatibility.
* It is replaced by completion_list_add.
*/
API_FUNC(hook_completion_list_add)
{
char *completion, *word, *where;
@ -4308,6 +4318,45 @@ API_FUNC(completion_search)
API_RETURN_INT(rc);
}
API_FUNC(completion_get_string)
{
char *completion, *property;
const char *result;
API_INIT_FUNC(1, "completion_get_string", API_RETURN_EMPTY);
completion = NULL;
property = NULL;
if (!PyArg_ParseTuple (args, "ss", &completion, &property))
API_WRONG_ARGS(API_RETURN_EMPTY);
result = weechat_completion_get_string (API_STR2PTR(completion),
property);
API_RETURN_STRING(result);
}
API_FUNC(completion_list_add)
{
char *completion, *word, *where;
int nick_completion;
API_INIT_FUNC(1, "completion_list_add", API_RETURN_ERROR);
completion = NULL;
word = NULL;
nick_completion = 0;
where = NULL;
if (!PyArg_ParseTuple (args, "ssis", &completion, &word, &nick_completion,
&where))
API_WRONG_ARGS(API_RETURN_ERROR);
weechat_completion_list_add (API_STR2PTR(completion),
word,
nick_completion,
where);
API_RETURN_OK;
}
API_FUNC(completion_free)
{
char *completion;
@ -5305,6 +5354,8 @@ PyMethodDef weechat_python_funcs[] =
API_DEF_FUNC(command_options),
API_DEF_FUNC(completion_new),
API_DEF_FUNC(completion_search),
API_DEF_FUNC(completion_get_string),
API_DEF_FUNC(completion_list_add),
API_DEF_FUNC(completion_free),
API_DEF_FUNC(info_get),
API_DEF_FUNC(info_get_hashtable),

View File

@ -55,36 +55,36 @@ relay_completion_protocol_name_cb (const void *pointer, void *data,
/* TCP socket */
snprintf (protocol_name, sizeof (protocol_name), "irc.%s",
weechat_infolist_string (infolist, "name"));
weechat_hook_completion_list_add (completion, protocol_name,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, protocol_name,
0, WEECHAT_LIST_POS_SORT);
snprintf (protocol_name, sizeof (protocol_name), "ssl.irc.%s",
weechat_infolist_string (infolist, "name"));
weechat_hook_completion_list_add (completion, protocol_name,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, protocol_name,
0, WEECHAT_LIST_POS_SORT);
/* UNIX domain socket */
snprintf (protocol_name, sizeof (protocol_name), "unix.irc.%s",
weechat_infolist_string (infolist, "name"));
weechat_hook_completion_list_add (completion, protocol_name,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, protocol_name,
0, WEECHAT_LIST_POS_SORT);
snprintf (protocol_name, sizeof (protocol_name), "unix.ssl.irc.%s",
weechat_infolist_string (infolist, "name"));
weechat_hook_completion_list_add (completion, protocol_name,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, protocol_name,
0, WEECHAT_LIST_POS_SORT);
}
weechat_infolist_free (infolist);
}
/* TCP socket */
weechat_hook_completion_list_add (completion, "weechat",
0, WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion, "ssl.weechat",
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, "weechat",
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, "ssl.weechat",
0, WEECHAT_LIST_POS_SORT);
/* UNIX domain socket */
weechat_hook_completion_list_add (completion, "unix.weechat",
0, WEECHAT_LIST_POS_SORT);
weechat_hook_completion_list_add (completion, "unix.ssl.weechat",
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, "unix.weechat",
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, "unix.ssl.weechat",
0, WEECHAT_LIST_POS_SORT);
return WEECHAT_RC_OK;
}
@ -110,9 +110,9 @@ relay_completion_relays_cb (const void *pointer, void *data,
for (ptr_server = relay_servers; ptr_server;
ptr_server = ptr_server->next_server)
{
weechat_hook_completion_list_add (completion,
ptr_server->protocol_string,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion,
ptr_server->protocol_string,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
@ -149,8 +149,8 @@ relay_completion_free_port_cb (const void *pointer, void *data,
port_max = 8000 - 1;
snprintf (str_port, sizeof (str_port), "%d", port_max + 1);
weechat_hook_completion_list_add (completion, str_port,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, str_port,
0, WEECHAT_LIST_POS_SORT);
return WEECHAT_RC_OK;
}

View File

@ -2550,6 +2550,11 @@ weechat_ruby_api_hook_completion (VALUE class, VALUE completion,
API_RETURN_STRING(result);
}
/*
* This function deprecated since WeeChat 2.9, kept for compatibility.
* It is replaced by completion_get_string.
*/
static VALUE
weechat_ruby_api_hook_completion_get_string (VALUE class, VALUE completion,
VALUE property)
@ -2573,6 +2578,11 @@ weechat_ruby_api_hook_completion_get_string (VALUE class, VALUE completion,
API_RETURN_STRING(result);
}
/*
* This function deprecated since WeeChat 2.9, kept for compatibility.
* It is replaced by completion_list_add.
*/
static VALUE
weechat_ruby_api_hook_completion_list_add (VALUE class, VALUE completion,
VALUE word, VALUE nick_completion,
@ -5197,6 +5207,60 @@ weechat_ruby_api_completion_search (VALUE class, VALUE completion, VALUE data,
API_RETURN_INT(rc);
}
static VALUE
weechat_ruby_api_completion_get_string (VALUE class, VALUE completion,
VALUE property)
{
char *c_completion, *c_property;
const char *result;
API_INIT_FUNC(1, "completion_get_string", API_RETURN_EMPTY);
if (NIL_P (completion) || NIL_P (property))
API_WRONG_ARGS(API_RETURN_EMPTY);
Check_Type (completion, T_STRING);
Check_Type (property, T_STRING);
c_completion = StringValuePtr (completion);
c_property = StringValuePtr (property);
result = weechat_completion_get_string (API_STR2PTR(c_completion),
c_property);
API_RETURN_STRING(result);
}
static VALUE
weechat_ruby_api_completion_list_add (VALUE class, VALUE completion,
VALUE word, VALUE nick_completion,
VALUE where)
{
char *c_completion, *c_word, *c_where;
int c_nick_completion;
API_INIT_FUNC(1, "completion_list_add", API_RETURN_ERROR);
if (NIL_P (completion) || NIL_P (word) || NIL_P (nick_completion)
|| NIL_P (where))
API_WRONG_ARGS(API_RETURN_ERROR);
Check_Type (completion, T_STRING);
Check_Type (word, T_STRING);
CHECK_INTEGER(nick_completion);
Check_Type (where, T_STRING);
c_completion = StringValuePtr (completion);
c_word = StringValuePtr (word);
c_nick_completion = NUM2INT (nick_completion);
c_where = StringValuePtr (where);
weechat_completion_list_add (API_STR2PTR(c_completion),
c_word,
c_nick_completion,
c_where);
API_RETURN_OK;
}
static VALUE
weechat_ruby_api_completion_free (VALUE class, VALUE completion)
{
@ -6488,6 +6552,8 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
API_DEF_FUNC(command_options, 3);
API_DEF_FUNC(completion_new, 1);
API_DEF_FUNC(completion_search, 4);
API_DEF_FUNC(completion_get_string, 2);
API_DEF_FUNC(completion_list_add, 4);
API_DEF_FUNC(completion_free, 1);
API_DEF_FUNC(info_get, 2);
API_DEF_FUNC(info_get_hashtable, 2);

View File

@ -49,9 +49,9 @@ script_completion_languages_cb (const void *pointer, void *data,
for (i = 0; i < SCRIPT_NUM_LANGUAGES; i++)
{
weechat_hook_completion_list_add (completion,
script_language[i],
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion,
script_language[i],
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
@ -77,9 +77,9 @@ script_completion_extensions_cb (const void *pointer, void *data,
for (i = 0; i < SCRIPT_NUM_LANGUAGES; i++)
{
weechat_hook_completion_list_add (completion,
script_extension[i],
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion,
script_extension[i],
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
@ -106,9 +106,9 @@ script_completion_scripts_cb (const void *pointer, void *data,
for (ptr_script = scripts_repo; ptr_script;
ptr_script = ptr_script->next_script)
{
weechat_hook_completion_list_add (completion,
ptr_script->name_with_extension,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion,
ptr_script->name_with_extension,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
@ -137,9 +137,9 @@ script_completion_scripts_installed_cb (const void *pointer, void *data,
{
if (ptr_script->status & SCRIPT_STATUS_INSTALLED)
{
weechat_hook_completion_list_add (completion,
ptr_script->name_with_extension,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion,
ptr_script->name_with_extension,
0, WEECHAT_LIST_POS_SORT);
}
}
@ -172,9 +172,9 @@ script_completion_exec_file_cb (void *data, const char *filename)
if (filename2)
{
ptr_base_name = basename (filename2);
weechat_hook_completion_list_add (completion,
ptr_base_name,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion,
ptr_base_name,
0, WEECHAT_LIST_POS_SORT);
free (filename2);
}
}
@ -271,9 +271,9 @@ script_completion_tags_cb (const void *pointer, void *data,
{
for (i = 0; i < num_tags; i++)
{
weechat_hook_completion_list_add (completion,
list_tags[i],
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion,
list_tags[i],
0, WEECHAT_LIST_POS_SORT);
}
weechat_string_free_split (list_tags);
}

View File

@ -48,9 +48,9 @@ spell_completion_langs_cb (const void *pointer, void *data,
for (i = 0; spell_langs[i].code; i++)
{
weechat_hook_completion_list_add (completion,
spell_langs[i].code,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion,
spell_langs[i].code,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
@ -73,8 +73,8 @@ spell_completion_enchant_add_dict_cb (const char *lang_tag,
(void) provider_desc;
(void) provider_file;
weechat_hook_completion_list_add ((struct t_gui_completion *)user_data,
lang_tag, 0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add ((struct t_gui_completion *)user_data,
lang_tag, 0, WEECHAT_LIST_POS_SORT);
}
#endif /* USE_ENCHANT */
@ -112,8 +112,8 @@ spell_completion_dicts_cb (const void *pointer, void *data,
while ((dict = aspell_dict_info_enumeration_next (elements)) != NULL)
{
weechat_hook_completion_list_add (completion, dict->name,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, dict->name,
0, WEECHAT_LIST_POS_SORT);
}
delete_aspell_dict_info_enumeration (elements);

View File

@ -2332,6 +2332,11 @@ API_FUNC(hook_completion)
API_RETURN_STRING(result);
}
/*
* This function deprecated since WeeChat 2.9, kept for compatibility.
* It is replaced by completion_get_string.
*/
API_FUNC(hook_completion_get_string)
{
Tcl_Obj *objp;
@ -2352,6 +2357,11 @@ API_FUNC(hook_completion_get_string)
API_RETURN_STRING(result);
}
/*
* This function deprecated since WeeChat 2.9, kept for compatibility.
* It is replaced by completion_list_add.
*/
API_FUNC(hook_completion_list_add)
{
Tcl_Obj *objp;
@ -4665,6 +4675,51 @@ API_FUNC(completion_search)
API_RETURN_INT(rc);
}
API_FUNC(completion_get_string)
{
Tcl_Obj *objp;
char *completion, *property;
const char *result;
int i;
API_INIT_FUNC(1, "completion_get_string", API_RETURN_EMPTY);
if (objc < 3)
API_WRONG_ARGS(API_RETURN_EMPTY);
completion = Tcl_GetStringFromObj (objv[1], &i);
property = Tcl_GetStringFromObj (objv[2], &i);
result = weechat_completion_get_string (API_STR2PTR(completion),
property);
API_RETURN_STRING(result);
}
API_FUNC(completion_list_add)
{
Tcl_Obj *objp;
char *completion, *word, *where;
int i, nick_completion;
API_INIT_FUNC(1, "completion_list_add", API_RETURN_ERROR);
if (objc < 5)
API_WRONG_ARGS(API_RETURN_ERROR);
if (Tcl_GetIntFromObj (interp, objv[3], &nick_completion) != TCL_OK)
API_WRONG_ARGS(API_RETURN_ERROR);
completion = Tcl_GetStringFromObj (objv[1], &i);
word = Tcl_GetStringFromObj (objv[2], &i);
where = Tcl_GetStringFromObj (objv[4], &i);
weechat_completion_list_add (API_STR2PTR(completion),
word,
nick_completion, /* nick_completion */
where);
API_RETURN_OK;
}
API_FUNC(info_get)
{
Tcl_Obj *objp;
@ -5823,6 +5878,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
API_DEF_FUNC(command_options);
API_DEF_FUNC(completion_new);
API_DEF_FUNC(completion_search);
API_DEF_FUNC(completion_get_string);
API_DEF_FUNC(completion_list_add);
API_DEF_FUNC(info_get);
API_DEF_FUNC(info_get_hashtable);
API_DEF_FUNC(infolist_new);

View File

@ -49,8 +49,8 @@ trigger_completion_triggers_cb (const void *pointer, void *data,
for (ptr_trigger = triggers; ptr_trigger;
ptr_trigger = ptr_trigger->next_trigger)
{
weechat_hook_completion_list_add (completion, ptr_trigger->name,
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion, ptr_trigger->name,
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
@ -77,9 +77,9 @@ trigger_completion_triggers_default_cb (const void *pointer, void *data,
for (i = 0; trigger_config_default_list[i][0]; i++)
{
weechat_hook_completion_list_add (completion,
trigger_config_default_list[i][0],
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion,
trigger_config_default_list[i][0],
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
@ -105,9 +105,9 @@ trigger_completion_options_cb (const void *pointer, void *data,
for (i = 0; i < TRIGGER_NUM_OPTIONS; i++)
{
weechat_hook_completion_list_add (completion,
trigger_option_string[i],
0, WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion,
trigger_option_string[i],
0, WEECHAT_LIST_POS_SORT);
}
return WEECHAT_RC_OK;
@ -134,7 +134,7 @@ trigger_completion_option_value_cb (const void *pointer, void *data,
(void) completion_item;
(void) buffer;
args = weechat_hook_completion_get_string (completion, "args");
args = weechat_completion_get_string (completion, "args");
if (!args)
return WEECHAT_RC_OK;
@ -153,20 +153,21 @@ trigger_completion_option_value_cb (const void *pointer, void *data,
{
if (weechat_strcasecmp (argv[2], "name") == 0)
{
weechat_hook_completion_list_add (completion,
ptr_trigger->name,
0,
WEECHAT_LIST_POS_BEGINNING);
weechat_completion_list_add (completion,
ptr_trigger->name,
0,
WEECHAT_LIST_POS_BEGINNING);
}
else
{
index_option = trigger_search_option (argv[2]);
if (index_option >= 0)
{
weechat_hook_completion_list_add (completion,
weechat_config_string (ptr_trigger->options[index_option]),
0,
WEECHAT_LIST_POS_BEGINNING);
weechat_completion_list_add (
completion,
weechat_config_string (ptr_trigger->options[index_option]),
0,
WEECHAT_LIST_POS_BEGINNING);
}
}
}
@ -197,9 +198,9 @@ trigger_completion_hooks_cb (const void *pointer, void *data,
for (i = 0; i < TRIGGER_NUM_HOOK_TYPES; i++)
{
weechat_hook_completion_list_add (completion,
trigger_hook_type_string[i],
0, WEECHAT_LIST_POS_END);
weechat_completion_list_add (completion,
trigger_hook_type_string[i],
0, WEECHAT_LIST_POS_END);
}
return WEECHAT_RC_OK;
@ -228,8 +229,8 @@ trigger_completion_hooks_filter_cb (const void *pointer, void *data,
{
snprintf (str_hook, sizeof (str_hook),
"@%s", trigger_hook_type_string[i]);
weechat_hook_completion_list_add (completion, str_hook,
0, WEECHAT_LIST_POS_END);
weechat_completion_list_add (completion, str_hook,
0, WEECHAT_LIST_POS_END);
}
return WEECHAT_RC_OK;
@ -252,8 +253,7 @@ trigger_completion_add_quoted_word (struct t_gui_completion *completion,
return;
snprintf (temp, length, "\"%s\"", word);
weechat_hook_completion_list_add (completion, temp, 0,
WEECHAT_LIST_POS_END);
weechat_completion_list_add (completion, temp, 0, WEECHAT_LIST_POS_END);
free (temp);
}
@ -273,7 +273,7 @@ trigger_completion_add_default_for_hook (struct t_gui_completion *completion,
char **argv, **items;
int argc, num_items, type, i;
args = weechat_hook_completion_get_string (completion, "args");
args = weechat_completion_get_string (completion, "args");
if (!args)
return;
@ -341,8 +341,7 @@ trigger_completion_hook_arguments_cb (const void *pointer, void *data,
trigger_completion_add_default_for_hook (completion,
trigger_hook_default_arguments,
NULL);
weechat_hook_completion_list_add (completion, "\"\"", 0,
WEECHAT_LIST_POS_END);
weechat_completion_list_add (completion, "\"\"", 0, WEECHAT_LIST_POS_END);
return WEECHAT_RC_OK;
}
@ -363,12 +362,11 @@ trigger_completion_hook_conditions_cb (const void *pointer, void *data,
(void) completion_item;
(void) buffer;
weechat_hook_completion_list_add (completion,
"\"" TRIGGER_HOOK_DEFAULT_CONDITIONS "\"",
0,
WEECHAT_LIST_POS_END);
weechat_hook_completion_list_add (completion, "\"\"", 0,
WEECHAT_LIST_POS_END);
weechat_completion_list_add (completion,
"\"" TRIGGER_HOOK_DEFAULT_CONDITIONS "\"",
0,
WEECHAT_LIST_POS_END);
weechat_completion_list_add (completion, "\"\"", 0, WEECHAT_LIST_POS_END);
return WEECHAT_RC_OK;
}
@ -389,12 +387,11 @@ trigger_completion_hook_regex_cb (const void *pointer, void *data,
(void) completion_item;
(void) buffer;
weechat_hook_completion_list_add (completion,
"\"" TRIGGER_HOOK_DEFAULT_REGEX "\"",
0,
WEECHAT_LIST_POS_END);
weechat_hook_completion_list_add (completion, "\"\"", 0,
WEECHAT_LIST_POS_END);
weechat_completion_list_add (completion,
"\"" TRIGGER_HOOK_DEFAULT_REGEX "\"",
0,
WEECHAT_LIST_POS_END);
weechat_completion_list_add (completion, "\"\"", 0, WEECHAT_LIST_POS_END);
return WEECHAT_RC_OK;
}
@ -415,12 +412,11 @@ trigger_completion_hook_command_cb (const void *pointer, void *data,
(void) completion_item;
(void) buffer;
weechat_hook_completion_list_add (completion,
"\"" TRIGGER_HOOK_DEFAULT_COMMAND "\"",
0,
WEECHAT_LIST_POS_END);
weechat_hook_completion_list_add (completion, "\"\"", 0,
WEECHAT_LIST_POS_END);
weechat_completion_list_add (completion,
"\"" TRIGGER_HOOK_DEFAULT_COMMAND "\"",
0,
WEECHAT_LIST_POS_END);
weechat_completion_list_add (completion, "\"\"", 0, WEECHAT_LIST_POS_END);
return WEECHAT_RC_OK;
}

View File

@ -67,7 +67,7 @@ struct timeval;
* 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 "20200428-01"
#define WEECHAT_PLUGIN_API_VERSION "20200508-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@ -1014,6 +1014,12 @@ struct t_weechat_plugin
struct t_gui_buffer *buffer);
int (*completion_search) (struct t_gui_completion *completion,
const char *data, int position, int direction);
const char *(*completion_get_string) (struct t_gui_completion *completion,
const char *property);
void (*completion_list_add) (struct t_gui_completion *completion,
const char *word,
int nick_completion,
const char *where);
void (*completion_free) (struct t_gui_completion *completion);
/* network */
@ -1956,6 +1962,12 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
__direction) \
(weechat_plugin->completion_search)(__completion, __data, \
__position, __direction)
#define weechat_completion_get_string(__completion, __property) \
(weechat_plugin->completion_get_string)(__completion, __property)
#define weechat_completion_list_add(__completion, __word, \
__nick_completion, __where) \
(weechat_plugin->completion_list_add)(__completion, __word, \
__nick_completion, __where)
#define weechat_completion_free(__completion) \
(weechat_plugin->completion_free)(__completion)

View File

@ -49,15 +49,15 @@ xfer_completion_nick_cb (const void *pointer, void *data,
if (ptr_xfer)
{
/* remote nick */
weechat_hook_completion_list_add (completion,
ptr_xfer->remote_nick,
0,
WEECHAT_LIST_POS_SORT);
weechat_completion_list_add (completion,
ptr_xfer->remote_nick,
0,
WEECHAT_LIST_POS_SORT);
/* add self nick at the end */
weechat_hook_completion_list_add (completion,
ptr_xfer->local_nick,
1,
WEECHAT_LIST_POS_END);
weechat_completion_list_add (completion,
ptr_xfer->local_nick,
1,
WEECHAT_LIST_POS_END);
}
return WEECHAT_RC_OK;

View File

@ -160,9 +160,9 @@ def completion_cb(data, completion_item, buf, completion):
"""Completion callback."""
check(data == 'completion_data')
check(completion_item == 'SCRIPT_NAME')
check(weechat.hook_completion_get_string(completion, 'args') == 'w')
weechat.hook_completion_list_add(completion, 'word_completed',
0, weechat.WEECHAT_LIST_POS_END)
check(weechat.completion_get_string(completion, 'args') == 'w')
weechat.completion_list_add(completion, 'word_completed',
0, weechat.WEECHAT_LIST_POS_END)
return weechat.WEECHAT_RC_OK