summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2020-04-27 00:14:36 +0200
committerSébastien Helleu <flashcode@flashtux.org>2020-04-27 22:15:42 +0200
commitd3020976d59e5e329c851f104c633427eafe2cf3 (patch)
tree929a758b54fb388ea82b9bc5414dd78523789716
parent0f1cee08bf12aab377417d6d7077a4f5abdd08a3 (diff)
downloadweechat-d3020976d59e5e329c851f104c633427eafe2cf3.zip
api: add functions completion_new, completion_search and completion_free (issue #1484)
-rw-r--r--ChangeLog.adoc1
-rw-r--r--doc/de/autogen/plugin_api/hdata.adoc9
-rw-r--r--doc/de/weechat_scripting.de.adoc6
-rw-r--r--doc/en/autogen/plugin_api/hdata.adoc9
-rw-r--r--doc/en/weechat_plugin_api.en.adoc121
-rw-r--r--doc/en/weechat_scripting.en.adoc5
-rw-r--r--doc/fr/autogen/plugin_api/hdata.adoc9
-rw-r--r--doc/fr/weechat_plugin_api.fr.adoc121
-rw-r--r--doc/fr/weechat_scripting.fr.adoc5
-rw-r--r--doc/it/autogen/plugin_api/hdata.adoc9
-rw-r--r--doc/it/weechat_plugin_api.it.adoc125
-rw-r--r--doc/it/weechat_scripting.it.adoc6
-rw-r--r--doc/ja/autogen/plugin_api/hdata.adoc9
-rw-r--r--doc/ja/weechat_plugin_api.ja.adoc125
-rw-r--r--doc/ja/weechat_scripting.ja.adoc6
-rw-r--r--doc/pl/autogen/plugin_api/hdata.adoc9
-rw-r--r--doc/pl/weechat_scripting.pl.adoc6
-rw-r--r--src/core/wee-arraylist.c1
-rw-r--r--src/core/wee-debug.c2
-rw-r--r--src/gui/gui-buffer.c14
-rw-r--r--src/gui/gui-completion.c181
-rw-r--r--src/gui/gui-completion.h22
-rw-r--r--src/gui/gui-input.c12
-rw-r--r--src/plugins/guile/weechat-guile-api.c48
-rw-r--r--src/plugins/javascript/weechat-js-api.cpp48
-rw-r--r--src/plugins/lua/weechat-lua-api.c54
-rw-r--r--src/plugins/perl/weechat-perl-api.c53
-rw-r--r--src/plugins/php/weechat-php-api.c173
-rw-r--r--src/plugins/php/weechat-php-api.h3
-rw-r--r--src/plugins/php/weechat-php.c3
-rw-r--r--src/plugins/plugin.c8
-rw-r--r--src/plugins/python/weechat-python-api.c53
-rw-r--r--src/plugins/ruby/weechat-ruby-api.c68
-rw-r--r--src/plugins/tcl/weechat-tcl-api.c43
-rw-r--r--src/plugins/weechat-plugin.h19
35 files changed, 1305 insertions, 81 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index ddb6cab9b..af1dbd3fa 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -23,6 +23,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: add functions completion_new, completion_search and completion_free
* buflist: add default key kbd:[Alt+Shift+B] to toggle buflist
* buflist: add options enable/disable/toggle in command /buflist
* buflist: evaluate option buflist.look.sort so that sort can be customized for each of the three buflist bar items (issue #1465)
diff --git a/doc/de/autogen/plugin_api/hdata.adoc b/doc/de/autogen/plugin_api/hdata.adoc
index 5d315765e..cfb992f04 100644
--- a/doc/de/autogen/plugin_api/hdata.adoc
+++ b/doc/de/autogen/plugin_api/hdata.adoc
@@ -643,8 +643,11 @@ _next_buffer_   (pointer, hdata: "buffer_visited") +
| weechat
| [[hdata_completion]]<<hdata_completion,completion>>
| Struktur mit Vervollständigung
-| -
-| _buffer_   (pointer, hdata: "buffer") +
+| _weechat_completions_ +
+_last_weechat_completion_ +
+
+| _plugin_   (pointer, hdata: "plugin") +
+_buffer_   (pointer, hdata: "buffer") +
_context_   (integer) +
_base_command_   (string) +
_base_command_arg_index_   (integer) +
@@ -663,6 +666,8 @@ _position_replace_   (integer) +
_diff_size_   (integer) +
_diff_length_   (integer) +
_partial_list_   (pointer) +
+_prev_completion_   (pointer, hdata: "completion") +
+_next_completion_   (pointer, hdata: "completion") +
| weechat
diff --git a/doc/de/weechat_scripting.de.adoc b/doc/de/weechat_scripting.de.adoc
index 3e26996de..3fbeced3c 100644
--- a/doc/de/weechat_scripting.de.adoc
+++ b/doc/de/weechat_scripting.de.adoc
@@ -714,6 +714,12 @@ Liste der Skript API Funktionen:
command +
command_options
+// TRANSLATION MISSING
+| completion |
+ completion_new +
+ completion_search +
+ completion_free
+
| Informationen |
info_get +
info_get_hashtable
diff --git a/doc/en/autogen/plugin_api/hdata.adoc b/doc/en/autogen/plugin_api/hdata.adoc
index 12fe97861..f3b9338e5 100644
--- a/doc/en/autogen/plugin_api/hdata.adoc
+++ b/doc/en/autogen/plugin_api/hdata.adoc
@@ -643,8 +643,11 @@ _next_buffer_   (pointer, hdata: "buffer_visited") +
| weechat
| [[hdata_completion]]<<hdata_completion,completion>>
| structure with completion
-| -
-| _buffer_   (pointer, hdata: "buffer") +
+| _weechat_completions_ +
+_last_weechat_completion_ +
+
+| _plugin_   (pointer, hdata: "plugin") +
+_buffer_   (pointer, hdata: "buffer") +
_context_   (integer) +
_base_command_   (string) +
_base_command_arg_index_   (integer) +
@@ -663,6 +666,8 @@ _position_replace_   (integer) +
_diff_size_   (integer) +
_diff_length_   (integer) +
_partial_list_   (pointer) +
+_prev_completion_   (pointer, hdata: "completion") +
+_next_completion_   (pointer, hdata: "completion") +
| weechat
diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc
index 4f2703a66..17c73d182 100644
--- a/doc/en/weechat_plugin_api.en.adoc
+++ b/doc/en/weechat_plugin_api.en.adoc
@@ -14938,6 +14938,127 @@ weechat.command_options(buffer, command, options)
rc = weechat.command("", "/some_command arguments", {"commands": "*,!exec"})
----
+[[completion]]
+=== Completion
+
+Functions to complete a command line.
+
+==== completion_new
+
+_WeeChat ≥ 2.9._
+
+Create a new completion.
+
+Prototype:
+
+[source,C]
+----
+struct t_gui_completion *weechat_completion_new (struct t_gui_buffer *buffer);
+----
+
+Arguments:
+
+* _buffer_: buffer pointer
+
+Return value:
+
+* pointer to new completion
+
+C example:
+
+[source,C]
+----
+struct t_gui_completion *completion = weechat_completion_new (weechat_buffer_search_main ());
+----
+
+Script (Python):
+
+[source,python]
+----
+# prototype
+completion = weechat.completion_new(buffer)
+
+# example
+completion = weechat.completion_new(weechat.buffer_search_main())
+----
+
+==== completion_search
+
+_WeeChat ≥ 2.9._
+
+Search possible words at a given position of a string, in the completion
+context.
+
+Prototype:
+
+[source,C]
+----
+void weechat_completion_search (struct t_gui_completion *completion, const char *data,
+ int position, int direction);
+----
+
+Arguments:
+
+* _completion_: completion pointer
+* _data_: the string to complete
+* _position_: index of the char in string to complete (starts to 0)
+* _direction_: 1 for next completion, -1 for previous completion
+
+C example:
+
+[source,C]
+----
+struct t_gui_completion *completion = weechat_completion_new (weechat_buffer_search_main ());
+weechat_completion_search (completion, "/help filt", 10, 1);
+----
+
+Script (Python):
+
+[source,python]
+----
+# prototype
+weechat.completion_search(completion, data, position, direction)
+
+# example
+completion = weechat.completion_new(weechat.buffer_search_main())
+weechat.completion_search(completion, "/help filt", 10, 1);
+----
+
+==== completion_free
+
+_WeeChat ≥ 2.9._
+
+Free a completion.
+
+Prototype:
+
+[source,C]
+----
+void weechat_completion_free (struct t_gui_completion *completion);
+----
+
+Arguments:
+
+* _completion_: completion pointer
+
+C example:
+
+[source,C]
+----
+weechat_completion_free (completion);
+----
+
+Script (Python):
+
+[source,python]
+----
+# prototype
+weechat.completion_free(completion)
+
+# example
+weechat.completion_free(completion)
+----
+
[[network]]
=== Network
diff --git a/doc/en/weechat_scripting.en.adoc b/doc/en/weechat_scripting.en.adoc
index 35469e21f..23170fbdb 100644
--- a/doc/en/weechat_scripting.en.adoc
+++ b/doc/en/weechat_scripting.en.adoc
@@ -697,6 +697,11 @@ List of functions in script API:
command +
command_options
+| completion |
+ completion_new +
+ completion_search +
+ completion_free
+
| infos |
info_get +
info_get_hashtable
diff --git a/doc/fr/autogen/plugin_api/hdata.adoc b/doc/fr/autogen/plugin_api/hdata.adoc
index d78b8f9c1..38839bff2 100644
--- a/doc/fr/autogen/plugin_api/hdata.adoc
+++ b/doc/fr/autogen/plugin_api/hdata.adoc
@@ -643,8 +643,11 @@ _next_buffer_   (pointer, hdata: "buffer_visited") +
| weechat
| [[hdata_completion]]<<hdata_completion,completion>>
| structure avec une complétion
-| -
-| _buffer_   (pointer, hdata: "buffer") +
+| _weechat_completions_ +
+_last_weechat_completion_ +
+
+| _plugin_   (pointer, hdata: "plugin") +
+_buffer_   (pointer, hdata: "buffer") +
_context_   (integer) +
_base_command_   (string) +
_base_command_arg_index_   (integer) +
@@ -663,6 +666,8 @@ _position_replace_   (integer) +
_diff_size_   (integer) +
_diff_length_   (integer) +
_partial_list_   (pointer) +
+_prev_completion_   (pointer, hdata: "completion") +
+_next_completion_   (pointer, hdata: "completion") +
| weechat
diff --git a/doc/fr/weechat_plugin_api.fr.adoc b/doc/fr/weechat_plugin_api.fr.adoc
index 3e9ba2012..a4f482d34 100644
--- a/doc/fr/weechat_plugin_api.fr.adoc
+++ b/doc/fr/weechat_plugin_api.fr.adoc
@@ -15257,6 +15257,127 @@ weechat.command_options(buffer, command, options)
rc = weechat.command("", "/une_commande paramètres", {"commands": "*,!exec"})
----
+[[completion]]
+=== Completion
+
+Fonctions pour compléter une ligne de commande.
+
+==== completion_new
+
+_WeeChat ≥ 2.9._
+
+Créer une complétion.
+
+Prototype :
+
+[source,C]
+----
+struct t_gui_completion *weechat_completion_new (struct t_gui_buffer *buffer);
+----
+
+Paramètres :
+
+* _buffer_ : pointeur vers le tampon
+
+Valeur de retour :
+
+* pointer to new completion
+
+Exemple en C :
+
+[source,C]
+----
+struct t_gui_completion *completion = weechat_completion_new (weechat_buffer_search_main ());
+----
+
+Script (Python) :
+
+[source,python]
+----
+# prototype
+completion = weechat.completion_new(buffer)
+
+# exemple
+completion = weechat.completion_new(weechat.buffer_search_main())
+----
+
+==== completion_search
+
+_WeeChat ≥ 2.9._
+
+Chercher les mots possibles à une position donnée d'une chaîne, dans le contexte
+de la complétion.
+
+Prototype :
+
+[source,C]
+----
+void weechat_completion_search (struct t_gui_completion *completion, const char *data,
+ int position, int direction);
+----
+
+Paramètres :
+
+* _completion_ : pointeur vers la complétion
+* _data_ : la chaîne à compléter
+* _position_ : index du caractère dans la chaîne à compléter (commence à 0)
+* _direction_ : 1 pour la complétion suivante, -1 pour la complétion précédente
+
+Exemple en C :
+
+[source,C]
+----
+struct t_gui_completion *completion = weechat_completion_new (weechat_buffer_search_main ());
+weechat_completion_search (completion, "/help filt", 10, 1);
+----
+
+Script (Python) :
+
+[source,python]
+----
+# prototype
+weechat.completion_search(completion, data, position, direction)
+
+# exemple
+completion = weechat.completion_new(weechat.buffer_search_main())
+weechat.completion_search(completion, "/help filt", 10, 1);
+----
+
+==== completion_free
+
+_WeeChat ≥ 2.9._
+
+Supprimer une complétion.
+
+Prototype :
+
+[source,C]
+----
+void weechat_completion_free (struct t_gui_completion *completion);
+----
+
+Paramètres :
+
+* _completion_ : pointeur vers la complétion
+
+Exemple en C :
+
+[source,C]
+----
+weechat_completion_free (completion);
+----
+
+Script (Python) :
+
+[source,python]
+----
+# prototype
+weechat.completion_free(completion)
+
+# exemple
+weechat.completion_free(completion)
+----
+
[[network]]
=== Réseau
diff --git a/doc/fr/weechat_scripting.fr.adoc b/doc/fr/weechat_scripting.fr.adoc
index 53273dcad..cc749d9ee 100644
--- a/doc/fr/weechat_scripting.fr.adoc
+++ b/doc/fr/weechat_scripting.fr.adoc
@@ -716,6 +716,11 @@ Liste des fonctions de l'API script :
command +
command_options
+| complétion |
+ completion_new +
+ completion_search +
+ completion_free
+
| infos |
info_get +
info_get_hashtable
diff --git a/doc/it/autogen/plugin_api/hdata.adoc b/doc/it/autogen/plugin_api/hdata.adoc
index e8d5d0228..feab3455d 100644
--- a/doc/it/autogen/plugin_api/hdata.adoc
+++ b/doc/it/autogen/plugin_api/hdata.adoc
@@ -643,8 +643,11 @@ _next_buffer_   (pointer, hdata: "buffer_visited") +
| weechat
| [[hdata_completion]]<<hdata_completion,completion>>
| struttura con completamento
-| -
-| _buffer_   (pointer, hdata: "buffer") +
+| _weechat_completions_ +
+_last_weechat_completion_ +
+
+| _plugin_   (pointer, hdata: "plugin") +
+_buffer_   (pointer, hdata: "buffer") +
_context_   (integer) +
_base_command_   (string) +
_base_command_arg_index_   (integer) +
@@ -663,6 +666,8 @@ _position_replace_   (integer) +
_diff_size_   (integer) +
_diff_length_   (integer) +
_partial_list_   (pointer) +
+_prev_completion_   (pointer, hdata: "completion") +
+_next_completion_   (pointer, hdata: "completion") +
| weechat
diff --git a/doc/it/weechat_plugin_api.it.adoc b/doc/it/weechat_plugin_api.it.adoc
index 135370c92..6494b5c75 100644
--- a/doc/it/weechat_plugin_api.it.adoc
+++ b/doc/it/weechat_plugin_api.it.adoc
@@ -15535,6 +15535,131 @@ weechat.command_options(buffer, command, options)
rc = weechat.command("", "/some_command arguments", {"commands": "*,!exec"})
----
+// TRANSLATION MISSING
+[[completion]]
+=== Completion
+
+Functions to complete a command line.
+
+// TRANSLATION MISSING
+==== completion_new
+
+_WeeChat ≥ 2.9._
+
+Create a new completion.
+
+Prototipo:
+
+[source,C]
+----
+struct t_gui_completion *weechat_completion_new (struct t_gui_buffer *buffer);
+----
+
+Argomenti:
+
+* _buffer_: buffer pointer
+
+Valori restituiti:
+
+* pointer to new completion
+
+Esempio in C:
+
+[source,C]
+----
+struct t_gui_completion *completion = weechat_completion_new (weechat_buffer_search_main ());
+----
+
+Script (Python):
+
+[source,python]
+----
+# prototipo
+completion = weechat.completion_new(buffer)
+
+# esempio
+completion = weechat.completion_new(weechat.buffer_search_main())
+----
+
+// TRANSLATION MISSING
+==== completion_search
+
+_WeeChat ≥ 2.9._
+
+Search possible words at a given position of a string, in the completion
+context.
+
+Prototipo:
+
+[source,C]
+----
+void weechat_completion_search (struct t_gui_completion *completion, const char *data,
+ int position, int direction);
+----
+
+Argomenti:
+
+* _completion_: completion pointer
+* _data_: the string to complete
+* _position_: index of the char in string to complete (starts to 0)
+* _direction_: 1 for next completion, -1 for previous completion
+
+Esempio in C:
+
+[source,C]
+----
+struct t_gui_completion *completion = weechat_completion_new (weechat_buffer_search_main ());
+weechat_completion_search (completion, "/help filt", 10, 1);
+----
+
+Script (Python):
+
+[source,python]
+----
+# prototipo
+weechat.completion_search(completion, data, position, direction)
+
+# esempio
+completion = weechat.completion_new(weechat.buffer_search_main())
+weechat.completion_search(completion, "/help filt", 10, 1);
+----
+
+// TRANSLATION MISSING
+==== completion_free
+
+_WeeChat ≥ 2.9._
+
+Free a completion.
+
+Prototipo:
+
+[source,C]
+----
+void weechat_completion_free (struct t_gui_completion *completion);
+----
+
+Argomenti:
+
+* _completion_: completion pointer
+
+Esempio in C:
+
+[source,C]
+----
+weechat_completion_free (completion);
+----
+
+Script (Python):
+
+[source,python]
+----
+# prototipo
+weechat.completion_free(completion)
+
+# esempio
+weechat.completion_free(completion)
+----
+
[[network]]
=== Network
diff --git a/doc/it/weechat_scripting.it.adoc b/doc/it/weechat_scripting.it.adoc
index 6fad5a37b..5e9864087 100644
--- a/doc/it/weechat_scripting.it.adoc
+++ b/doc/it/weechat_scripting.it.adoc
@@ -728,6 +728,12 @@ Elenco di funzioni nelle API per gli script:
command +
command_options
+// TRANSLATION MISSING
+| completion |
+ completion_new +
+ completion_search +
+ completion_free
+
| info |
info_get +
info_get_hashtable
diff --git a/doc/ja/autogen/plugin_api/hdata.adoc b/doc/ja/autogen/plugin_api/hdata.adoc
index 2a076d869..4dce7fd19 100644
--- a/doc/ja/autogen/plugin_api/hdata.adoc
+++ b/doc/ja/autogen/plugin_api/hdata.adoc
@@ -643,8 +643,11 @@ _next_buffer_   (pointer, hdata: "buffer_visited") +
| weechat
| [[hdata_completion]]<<hdata_completion,completion>>
| 補完する構造
-| -
-| _buffer_   (pointer, hdata: "buffer") +
+| _weechat_completions_ +
+_last_weechat_completion_ +
+
+| _plugin_   (pointer, hdata: "plugin") +
+_buffer_   (pointer, hdata: "buffer") +
_context_   (integer) +
_base_command_   (string) +
_base_command_arg_index_   (integer) +
@@ -663,6 +666,8 @@ _position_replace_   (integer) +
_diff_size_   (integer) +
_diff_length_   (integer) +
_partial_list_   (pointer) +
+_prev_completion_   (pointer, hdata: "completion") +
+_next_completion_   (pointer, hdata: "completion") +
| weechat
diff --git a/doc/ja/weechat_plugin_api.ja.adoc b/doc/ja/weechat_plugin_api.ja.adoc
index 376c3106c..90bc27d07 100644
--- a/doc/ja/weechat_plugin_api.ja.adoc
+++ b/doc/ja/weechat_plugin_api.ja.adoc
@@ -14920,6 +14920,131 @@ weechat.command_options(buffer, command, options)
rc = weechat.command("", "/some_command arguments", {"commands": "*,!exec"})
----
+// TRANSLATION MISSING
+[[completion]]
+=== Completion
+
+Functions to complete a command line.
+
+// TRANSLATION MISSING
+==== completion_new
+
+_WeeChat ≥ 2.9._
+
+Create a new completion.
+
+プロトタイプ:
+
+[source,C]
+----
+struct t_gui_completion *weechat_completion_new (struct t_gui_buffer *buffer);
+----
+
+引数:
+
+* _buffer_: buffer pointer
+
+Return value:
+
+* pointer to new completion
+
+C 言語での使用例:
+
+[source,C]
+----
+struct t_gui_completion *completion = weechat_completion_new (weechat_buffer_search_main ());
+----
+
+スクリプト (Python) での使用例:
+
+[source,python]
+----
+# prototype
+completion = weechat.completion_new(buffer)
+
+# example
+completion = weechat.completion_new(weechat.buffer_search_main())
+----
+
+// TRANSLATION MISSING
+==== completion_search
+
+_WeeChat ≥ 2.9._
+
+Search possible words at a given position of a string, in the completion
+context.
+
+プロトタイプ:
+
+[source,C]
+----
+void weechat_completion_search (struct t_gui_completion *completion, const char *data,
+ int position, int direction);
+----
+
+引数:
+
+* _completion_: completion pointer
+* _data_: the string to complete
+* _position_: index of the char in string to complete (starts to 0)
+* _direction_: 1 for next completion, -1 for previous completion
+
+C 言語での使用例:
+
+[source,C]
+----
+struct t_gui_completion *completion = weechat_completion_new (weechat_buffer_search_main ());
+weechat_completion_search (completion, "/help filt", 10, 1);
+----
+
+スクリプト (Python) での使用例:
+
+[source,python]
+----
+# prototype
+weechat.completion_search(completion, data, position, direction)
+
+# example
+completion = weechat.completion_new(weechat.buffer_search_main())
+weechat.completion_search(completion, "/help filt", 10, 1);
+----
+
+// TRANSLATION MISSING
+==== completion_free
+
+_WeeChat ≥ 2.9._
+
+Free a completion.
+
+プロトタイプ:
+
+[source,C]
+----
+void weechat_completion_free (struct t_gui_completion *completion);
+----
+
+引数:
+
+* _completion_: completion pointer
+
+C 言語での使用例:
+
+[source,C]
+----
+weechat_completion_free (completion);
+----
+
+スクリプト (Python) での使用例:
+
+[source,python]
+----
+# prototype
+weechat.completion_free(completion)
+
+# example
+weechat.completion_free(completion)
+----
+
[[network]]
=== ネットワーク
diff --git a/doc/ja/weechat_scripting.ja.adoc b/doc/ja/weechat_scripting.ja.adoc
index a4027d979..07c9949bf 100644
--- a/doc/ja/weechat_scripting.ja.adoc
+++ b/doc/ja/weechat_scripting.ja.adoc
@@ -716,6 +716,12 @@ link:weechat_plugin_api.ja.html[WeeChat プラグイン API リファレンス]
command +
command_options
+// TRANSLATION MISSING
+| completion |
+ completion_new +
+ completion_search +
+ completion_free
+
| インフォ |
info_get +
info_get_hashtable
diff --git a/doc/pl/autogen/plugin_api/hdata.adoc b/doc/pl/autogen/plugin_api/hdata.adoc
index 107430bd2..14dc7f1ca 100644
--- a/doc/pl/autogen/plugin_api/hdata.adoc
+++ b/doc/pl/autogen/plugin_api/hdata.adoc
@@ -643,8 +643,11 @@ _next_buffer_   (pointer, hdata: "buffer_visited") +
| weechat
| [[hdata_completion]]<<hdata_completion,completion>>
| struktura z uzupełnianiem
-| -
-| _buffer_   (pointer, hdata: "buffer") +
+| _weechat_completions_ +
+_last_weechat_completion_ +
+
+| _plugin_   (pointer, hdata: "plugin") +
+_buffer_   (pointer, hdata: "buffer") +
_context_   (integer) +
_base_command_   (string) +
_base_command_arg_index_   (integer) +
@@ -663,6 +666,8 @@ _position_replace_   (integer) +
_diff_size_   (integer) +
_diff_length_   (integer) +
_partial_list_   (pointer) +
+_prev_completion_   (pointer, hdata: "completion") +
+_next_completion_   (pointer, hdata: "completion") +
| weechat
diff --git a/doc/pl/weechat_scripting.pl.adoc b/doc/pl/weechat_scripting.pl.adoc
index 54a9341a6..e4da12878 100644
--- a/doc/pl/weechat_scripting.pl.adoc
+++ b/doc/pl/weechat_scripting.pl.adoc
@@ -702,6 +702,12 @@ Lista funkcji w API skryptów:
command +
command_options
+// TRANSLATION MISSING
+| completion |
+ completion_new +
+ completion_search +
+ completion_free
+
| informacje |
info_get +
info_get_hashtable
diff --git a/src/core/wee-arraylist.c b/src/core/wee-arraylist.c
index bd5650996..0158bac18 100644
--- a/src/core/wee-arraylist.c
+++ b/src/core/wee-arraylist.c
@@ -703,7 +703,6 @@ arraylist_print_log (struct t_arraylist *arraylist, const char *name)
{
int i;
- log_printf ("");
log_printf ("[arraylist %s (addr:0x%lx)]", name, arraylist);
log_printf (" size . . . . . . . . . : %d", arraylist->size);
log_printf (" size_alloc . . . . . . : %d", arraylist->size_alloc);
diff --git a/src/core/wee-debug.c b/src/core/wee-debug.c
index a53c3500f..79d7e682e 100644
--- a/src/core/wee-debug.c
+++ b/src/core/wee-debug.c
@@ -52,6 +52,7 @@
#include "../gui/gui-bar-item.h"
#include "../gui/gui-buffer.h"
#include "../gui/gui-chat.h"
+#include "../gui/gui-completion.h"
#include "../gui/gui-filter.h"
#include "../gui/gui-hotlist.h"
#include "../gui/gui-key.h"
@@ -90,6 +91,7 @@ debug_dump (int crash)
gui_window_print_log ();
gui_buffer_print_log ();
+ gui_completion_print_log ();
gui_layout_print_log ();
gui_key_print_log (NULL);
gui_filter_print_log ();
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c
index a3998c5e5..00d254cf3 100644
--- a/src/gui/gui-buffer.c
+++ b/src/gui/gui-buffer.c
@@ -648,7 +648,6 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
void *close_callback_data)
{
struct t_gui_buffer *new_buffer;
- struct t_gui_completion *new_completion;
int first_buffer_creation;
if (!name || !name[0])
@@ -757,12 +756,7 @@ gui_buffer_new (struct t_weechat_plugin *plugin,
new_buffer->input_undo_count = 0;
/* init completion */
- new_completion = malloc (sizeof (*new_completion));
- if (new_completion)
- {
- new_buffer->completion = new_completion;
- gui_completion_buffer_init (new_completion, new_buffer);
- }
+ new_buffer->completion = gui_completion_new (NULL, new_buffer);
/* init history */
new_buffer->history = NULL;
@@ -4812,12 +4806,6 @@ gui_buffer_print_log ()
ptr_line = ptr_line->next_line;
}
-
- if (ptr_buffer->completion)
- {
- log_printf ("");
- gui_completion_print_log (ptr_buffer->completion);
- }
}
log_printf ("");
diff --git a/src/gui/gui-completion.c b/src/gui/gui-completion.c
index 2d9f43d10..615785eea 100644
--- a/src/gui/gui-completion.c
+++ b/src/gui/gui-completion.c
@@ -48,6 +48,9 @@
#include "gui-buffer.h"
+struct t_gui_completion *weechat_completions = NULL;
+struct t_gui_completion *last_weechat_completion = NULL;
+
int gui_completion_freeze = 0; /* 1 to freeze completions (do not */
/* stop partial completion on key) */
@@ -97,13 +100,15 @@ gui_completion_word_free_cb (void *data,
}
/*
- * Initializes completion for a buffer.
+ * Initializes completion.
*/
void
-gui_completion_buffer_init (struct t_gui_completion *completion,
- struct t_gui_buffer *buffer)
+gui_completion_init (struct t_gui_completion *completion,
+ struct t_weechat_plugin *plugin,
+ struct t_gui_buffer *buffer)
{
+ completion->plugin = plugin;
completion->buffer = buffer;
completion->context = GUI_COMPLETION_NULL;
completion->base_command = NULL;
@@ -135,6 +140,39 @@ gui_completion_buffer_init (struct t_gui_completion *completion,
}
/*
+ * Creates a new completion.
+ *
+ * Returns pointer to completion, NULL if error.
+ */
+
+struct t_gui_completion *
+gui_completion_new (struct t_weechat_plugin *plugin,
+ struct t_gui_buffer *buffer)
+{
+ struct t_gui_completion *completion;
+
+ if (!buffer)
+ return NULL;
+
+ completion = malloc (sizeof (*completion));
+ if (!completion)
+ return NULL;
+
+ gui_completion_init (completion, plugin, buffer);
+
+ /* add completion to the global list */
+ completion->prev_completion = last_weechat_completion;
+ completion->next_completion = NULL;
+ if (last_weechat_completion)
+ last_weechat_completion->next_completion = completion;
+ else
+ weechat_completions = completion;
+ last_weechat_completion = completion;
+
+ return completion;
+}
+
+/*
* Adds an item to partial completion list.
*
* Returns pointer to new item, NULL if error.
@@ -202,15 +240,51 @@ gui_completion_free_data (struct t_gui_completion *completion)
void
gui_completion_free (struct t_gui_completion *completion)
{
+ struct t_gui_completion *new_weechat_completions;
+
if (!completion)
return;
+ /* remove completion from global list */
+ if (last_weechat_completion == completion)
+ last_weechat_completion = completion->prev_completion;
+ if (completion->prev_completion)
+ {
+ (completion->prev_completion)->next_completion = completion->next_completion;
+ new_weechat_completions = weechat_completions;
+ }
+ else
+ new_weechat_completions = completion->next_completion;
+ if (completion->next_completion)
+ (completion->next_completion)->prev_completion = completion->prev_completion;
+ weechat_completions = new_weechat_completions;
+
+ /* free data */
gui_completion_free_data (completion);
free (completion);
}
/*
+ * Frees all completions created by a plugin.
+ */
+
+void
+gui_completion_free_all_plugin (struct t_weechat_plugin *plugin)
+{
+ struct t_gui_completion *ptr_completion, *next_completion;
+
+ ptr_completion = weechat_completions;
+ while (ptr_completion)
+ {
+ next_completion = ptr_completion->next_completion;
+ if (ptr_completion->plugin == plugin)
+ gui_completion_free (ptr_completion);
+ ptr_completion = next_completion;
+ }
+}
+
+/*
* Stops completion (for example after 1 argument of command with 1 argument).
*/
@@ -732,17 +806,19 @@ gui_completion_build_list (struct t_gui_completion *completion)
void
gui_completion_find_context (struct t_gui_completion *completion,
- const char *data, int size, int pos)
+ const char *data, int pos)
{
- int i, command_arg, pos_start, pos_end;
+ int i, size, command_arg, pos_start, pos_end;
const char *ptr_command, *ptr_data, *prev_char;
/* look for context */
gui_completion_free_data (completion);
- gui_completion_buffer_init (completion, completion->buffer);
+ gui_completion_init (completion, completion->plugin, completion->buffer);
ptr_command = NULL;
command_arg = 0;
+ size = (data) ? strlen (data) : 0;
+
/* check if data starts with a command */
ptr_data = data;
if (string_is_command_char (ptr_data))
@@ -1295,21 +1371,27 @@ gui_completion_auto (struct t_gui_completion *completion)
*/
void
-gui_completion_search (struct t_gui_completion *completion, int direction,
- const char *data, int size, int pos)
+gui_completion_search (struct t_gui_completion *completion, const char *data,
+ int position, int direction)
{
char *old_word_found;
+ int real_position;
+
+ if (!data)
+ return;
+
+ real_position = utf8_real_pos (data, position);
completion->direction = direction;
/* if new completion => look for base word */
- if (pos != completion->position)
+ if (real_position != completion->position)
{
if (completion->word_found)
free (completion->word_found);
completion->word_found = NULL;
completion->word_found_is_nick = 0;
- gui_completion_find_context (completion, data, size, pos);
+ gui_completion_find_context (completion, data, real_position);
completion->force_partial_completion = (direction < 0);
}
@@ -1395,9 +1477,11 @@ gui_completion_hdata_completion_cb (const void *pointer, void *data,
(void) pointer;
(void) data;
- hdata = hdata_new (NULL, hdata_name, NULL, NULL, 0, 0, NULL, NULL);
+ hdata = hdata_new (NULL, hdata_name, "prev_completion", "next_completion",
+ 0, 0, NULL, NULL);
if (hdata)
{
+ HDATA_VAR(struct t_gui_completion, plugin, POINTER, 0, NULL, "plugin");
HDATA_VAR(struct t_gui_completion, buffer, POINTER, 0, NULL, "buffer");
HDATA_VAR(struct t_gui_completion, context, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_completion, base_command, STRING, 0, NULL, NULL);
@@ -1417,6 +1501,10 @@ gui_completion_hdata_completion_cb (const void *pointer, void *data,
HDATA_VAR(struct t_gui_completion, diff_size, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_completion, diff_length, INTEGER, 0, NULL, NULL);
HDATA_VAR(struct t_gui_completion, partial_list, POINTER, 0, NULL, NULL);
+ HDATA_VAR(struct t_gui_completion, prev_completion, POINTER, 0, NULL, hdata_name);
+ HDATA_VAR(struct t_gui_completion, next_completion, POINTER, 0, NULL, hdata_name);
+ HDATA_LIST(weechat_completions, WEECHAT_HDATA_LIST_CHECK_POINTERS);
+ HDATA_LIST(last_weechat_completion, 0);
}
return hdata;
}
@@ -1447,37 +1535,48 @@ gui_completion_list_words_print_log (struct t_arraylist *list,
*/
void
-gui_completion_print_log (struct t_gui_completion *completion)
+gui_completion_print_log ()
{
- log_printf ("[completion (addr:0x%lx)]", completion);
- log_printf (" buffer. . . . . . . . . . : 0x%lx", completion->buffer);
- log_printf (" context . . . . . . . . . : %d", completion->context);
- log_printf (" base_command. . . . . . . : '%s'", completion->base_command);
- log_printf (" base_command_arg_index. . : %d", completion->base_command_arg_index);
- log_printf (" base_word . . . . . . . . : '%s'", completion->base_word);
- log_printf (" base_word_pos . . . . . . : %d", completion->base_word_pos);
- log_printf (" position. . . . . . . . . : %d", completion->position);
- log_printf (" args. . . . . . . . . . . : '%s'", completion->args);
- log_printf (" direction . . . . . . . . : %d", completion->direction);
- log_printf (" add_space . . . . . . . . : %d", completion->add_space);
- log_printf (" force_partial_completion. : %d", completion->force_partial_completion);
- log_printf (" reverse_partial_completion: %d", completion->reverse_partial_completion);
- log_printf (" list. . . . . . . . . . . : 0x%lx", completion->list);
- log_printf (" word_found. . . . . . . . : '%s'", completion->word_found);
- log_printf (" word_found_is_nick. . . . : %d", completion->word_found_is_nick);
- log_printf (" position_replace. . . . . : %d", completion->position_replace);
- log_printf (" diff_size . . . . . . . . : %d", completion->diff_size);
- log_printf (" diff_length . . . . . . . : %d", completion->diff_length);
- if (completion->list)
- {
- log_printf ("");
- gui_completion_list_words_print_log (completion->list,
- "completion word");
- }
- if (completion->partial_list)
+ struct t_gui_completion *ptr_completion;
+
+ for (ptr_completion = weechat_completions; ptr_completion;
+ ptr_completion = ptr_completion->next_completion)
{
- log_printf ("");
- arraylist_print_log (completion->partial_list,
- "partial completion word");
+ log_printf ("[completion (addr:0x%lx)]", ptr_completion);
+ log_printf (" plugin. . . . . . . . . . : 0x%lx", ptr_completion->plugin);
+ log_printf (" buffer. . . . . . . . . . : 0x%lx ('%s')",
+ ptr_completion->buffer,
+ ptr_completion->buffer->full_name);
+ log_printf (" context . . . . . . . . . : %d", ptr_completion->context);
+ log_printf (" base_command. . . . . . . : '%s'", ptr_completion->base_command);
+ log_printf (" base_command_arg_index. . : %d", ptr_completion->base_command_arg_index);
+ log_printf (" base_word . . . . . . . . : '%s'", ptr_completion->base_word);
+ log_printf (" base_word_pos . . . . . . : %d", ptr_completion->base_word_pos);
+ log_printf (" position. . . . . . . . . : %d", ptr_completion->position);
+ log_printf (" args. . . . . . . . . . . : '%s'", ptr_completion->args);
+ log_printf (" direction . . . . . . . . : %d", ptr_completion->direction);
+ log_printf (" add_space . . . . . . . . : %d", ptr_completion->add_space);
+ log_printf (" force_partial_completion. : %d", ptr_completion->force_partial_completion);
+ log_printf (" reverse_partial_completion: %d", ptr_completion->reverse_partial_completion);
+ log_printf (" list. . . . . . . . . . . : 0x%lx", ptr_completion->list);
+ log_printf (" word_found. . . . . . . . : '%s'", ptr_completion->word_found);
+ log_printf (" word_found_is_nick. . . . : %d", ptr_completion->word_found_is_nick);
+ log_printf (" position_replace. . . . . : %d", ptr_completion->position_replace);
+ log_printf (" diff_size . . . . . . . . : %d", ptr_completion->diff_size);
+ log_printf (" diff_length . . . . . . . : %d", ptr_completion->diff_length);
+ log_printf (" prev_completion . . . . . : 0x%lx", ptr_completion->prev_completion);
+ log_printf (" next_completion . . . . . : 0x%lx", ptr_completion->next_completion);
+ if (ptr_completion->list && (ptr_completion->list->size > 0))
+ {
+ log_printf ("");
+ gui_completion_list_words_print_log (ptr_completion->list,
+ "completion word");
+ }
+ if (ptr_completion->partial_list)
+ {
+ log_printf ("");
+ arraylist_print_log (ptr_completion->partial_list,
+ "partial completion word");
+ }
}
}
diff --git a/src/gui/gui-completion.h b/src/gui/gui-completion.h
index b04083599..6f5d85ae0 100644
--- a/src/gui/gui-completion.h
+++ b/src/gui/gui-completion.h
@@ -35,6 +35,13 @@ struct t_gui_completion_word
struct t_gui_completion
{
+ /* plugin */
+ struct t_weechat_plugin *plugin; /* plugin which created this completion */
+ /* with a call to API function */
+ /* "completion_new" (NULL for a buffer */
+ /* internal completion even if the . */
+ /* buffer belongs to a plugin) */
+
/* completion context */
struct t_gui_buffer *buffer; /* buffer where completion was asked */
int context; /* context: null, nick, command, cmd arg */
@@ -61,6 +68,10 @@ struct t_gui_completion
/* partial completion */
struct t_arraylist *partial_list;
+
+ /* previous/next completions in global list */
+ struct t_gui_completion *prev_completion; /* link to previous completion */
+ struct t_gui_completion *next_completion; /* link to next completion */
};
/* completion variables */
@@ -69,21 +80,22 @@ extern int gui_completion_freeze;
/* completion functions */
-extern void gui_completion_buffer_init (struct t_gui_completion *completion,
- struct t_gui_buffer *buffer);
+extern struct t_gui_completion *gui_completion_new (struct t_weechat_plugin *plugin,
+ struct t_gui_buffer *buffer);
extern void gui_completion_free (struct t_gui_completion *completion);
+extern void gui_completion_free_all_plugin (struct t_weechat_plugin *plugin);
extern void gui_completion_stop (struct t_gui_completion *completion);
extern void gui_completion_list_add (struct t_gui_completion *completion,
const char *word,
int nick_completion, const char *where);
extern void gui_completion_search (struct t_gui_completion *completion,
- int direction, const char *data, int size,
- int pos);
+ const char *data, int position,
+ int direction);
extern const char *gui_completion_get_string (struct t_gui_completion *completion,
const char *property);
extern struct t_hdata *gui_completion_hdata_completion_cb (const void *pointer,
void *data,
const char *hdata_name);
-extern void gui_completion_print_log (struct t_gui_completion *completion);
+extern void gui_completion_print_log ();
#endif /* WEECHAT_GUI_COMPLETION_H */
diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c
index 465913942..cab58f6f7 100644
--- a/src/gui/gui-input.c
+++ b/src/gui/gui-input.c
@@ -533,11 +533,9 @@ gui_input_complete_next (struct t_gui_buffer *buffer)
{
gui_buffer_undo_snap (buffer);
gui_completion_search (buffer->completion,
- 1,
buffer->input_buffer,
- buffer->input_buffer_size,
- utf8_real_pos (buffer->input_buffer,
- buffer->input_buffer_pos));
+ buffer->input_buffer_pos,
+ 1);
gui_input_complete (buffer);
gui_input_text_changed_modifier_and_signal (buffer,
1, /* save undo */
@@ -557,11 +555,9 @@ gui_input_complete_previous (struct t_gui_buffer *buffer)
{
gui_buffer_undo_snap (buffer);
gui_completion_search (buffer->completion,
- -1,
buffer->input_buffer,
- buffer->input_buffer_size,
- utf8_real_pos (buffer->input_buffer,
- buffer->input_buffer_pos));
+ buffer->input_buffer_pos,
+ -1);
gui_input_complete (buffer);
gui_input_text_changed_modifier_and_signal (buffer,
1, /* save undo */
diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c
index ec4c20e97..eff2bf22d 100644
--- a/src/plugins/guile/weechat-guile-api.c
+++ b/src/plugins/guile/weechat-guile-api.c
@@ -4103,6 +4103,51 @@ weechat_guile_api_command_options (SCM buffer, SCM command, SCM options)
}
SCM
+weechat_guile_api_completion_new (SCM buffer)
+{
+ const char *result;
+ SCM return_value;
+
+ API_INIT_FUNC(1, "completion_new", API_RETURN_EMPTY);
+ if (!scm_is_string (buffer))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = API_PTR2STR(
+ weechat_completion_new (API_STR2PTR(API_SCM_TO_STRING(buffer))));
+
+ API_RETURN_STRING(result);
+}
+
+SCM
+weechat_guile_api_completion_search (SCM completion, SCM data, SCM position,
+ SCM direction)
+{
+ API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR);
+ if (!scm_is_string (completion) || !scm_is_string (data)
+ || !scm_is_integer (position) || !scm_is_integer (direction))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_completion_search (API_STR2PTR(API_SCM_TO_STRING(completion)),
+ API_SCM_TO_STRING(data),
+ scm_to_int (position),
+ scm_to_int (direction));
+
+ API_RETURN_OK;
+}
+
+SCM
+weechat_guile_api_completion_free (SCM completion)
+{
+ API_INIT_FUNC(1, "completion_free", API_RETURN_ERROR);
+ if (!scm_is_string (completion))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_completion_free (API_STR2PTR(API_SCM_TO_STRING(completion)));
+
+ API_RETURN_OK;
+}
+
+SCM
weechat_guile_api_info_get (SCM info_name, SCM arguments)
{
char *result;
@@ -5054,6 +5099,9 @@ weechat_guile_api_module_init (void *data)
API_DEF_FUNC(bar_remove, 1);
API_DEF_FUNC(command, 2);
API_DEF_FUNC(command_options, 3);
+ API_DEF_FUNC(completion_new, 1);
+ API_DEF_FUNC(completion_search, 4);
+ API_DEF_FUNC(completion_free, 1);
API_DEF_FUNC(info_get, 2);
API_DEF_FUNC(info_get_hashtable, 2);
API_DEF_FUNC(infolist_new, 0);
diff --git a/src/plugins/javascript/weechat-js-api.cpp b/src/plugins/javascript/weechat-js-api.cpp
index 5c159387d..8935a17e7 100644
--- a/src/plugins/javascript/weechat-js-api.cpp
+++ b/src/plugins/javascript/weechat-js-api.cpp
@@ -3999,6 +3999,51 @@ API_FUNC(command_options)
API_RETURN_INT(rc);
}
+API_FUNC(completion_new)
+{
+ const char *result;
+
+ API_INIT_FUNC(1, "completion_new", "s", API_RETURN_EMPTY);
+
+ v8::String::Utf8Value buffer(args[0]);
+
+ result = API_PTR2STR(
+ weechat_completion_new ((struct t_gui_buffer *)API_STR2PTR(*buffer)));
+
+ API_RETURN_STRING(result);
+}
+
+API_FUNC(completion_search)
+{
+ int position, direction;
+
+ API_INIT_FUNC(1, "completion_search", "ssii", API_RETURN_ERROR);
+
+ v8::String::Utf8Value completion(args[0]);
+ v8::String::Utf8Value data(args[1]);
+ position = args[2]->IntegerValue();
+ direction = args[3]->IntegerValue();
+
+ weechat_completion_search (
+ (struct t_gui_completion *)API_STR2PTR(*completion),
+ (const char *)(*data),
+ position,
+ direction);
+
+ API_RETURN_OK;
+}
+
+API_FUNC(completion_free)
+{
+ API_INIT_FUNC(1, "completion_free", "s", API_RETURN_ERROR);
+
+ v8::String::Utf8Value completion(args[0]);
+
+ weechat_completion_free ((struct t_gui_completion *)API_STR2PTR(*completion));
+
+ API_RETURN_OK;
+}
+
API_FUNC(info_get)
{
const char *result;
@@ -4991,6 +5036,9 @@ WeechatJsV8::loadLibs()
API_DEF_FUNC(bar_remove);
API_DEF_FUNC(command);
API_DEF_FUNC(command_options);
+ API_DEF_FUNC(completion_new);
+ API_DEF_FUNC(completion_search);
+ API_DEF_FUNC(completion_free);
API_DEF_FUNC(info_get);
API_DEF_FUNC(info_get_hashtable);
API_DEF_FUNC(infolist_new);
diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c
index f6230a71a..0d16363b1 100644
--- a/src/plugins/lua/weechat-lua-api.c
+++ b/src/plugins/lua/weechat-lua-api.c
@@ -4337,6 +4337,57 @@ API_FUNC(command_options)
API_RETURN_INT(rc);
}
+API_FUNC(completion_new)
+{
+ const char *buffer;
+ const char *result;
+
+ API_INIT_FUNC(1, "completion_new", API_RETURN_EMPTY);
+ if (lua_gettop (L) < 1)
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ buffer = lua_tostring (L, -1);
+
+ result = API_PTR2STR(weechat_completion_new (API_STR2PTR(buffer)));
+
+ API_RETURN_STRING(result);
+}
+
+API_FUNC(completion_search)
+{
+ const char *completion, *data;
+ int position, direction;
+
+ API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR);
+ if (lua_gettop (L) < 4)
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ completion = lua_tostring (L, -4);
+ data = lua_tostring (L, -3);
+ position = lua_tonumber (L, -2);
+ direction = lua_tonumber (L, -1);
+
+ weechat_completion_search (API_STR2PTR(completion), data, position,
+ direction);
+
+ API_RETURN_OK;
+}
+
+API_FUNC(completion_free)
+{
+ const char *completion;
+
+ API_INIT_FUNC(1, "completion_free", API_RETURN_ERROR);
+ if (lua_gettop (L) < 1)
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ completion = lua_tostring (L, -1);
+
+ weechat_completion_free (API_STR2PTR(completion));
+
+ API_RETURN_OK;
+}
+
API_FUNC(info_get)
{
const char *info_name, *arguments;
@@ -5345,6 +5396,9 @@ const struct luaL_Reg weechat_lua_api_funcs[] = {
API_DEF_FUNC(bar_remove),
API_DEF_FUNC(command),
API_DEF_FUNC(command_options),
+ API_DEF_FUNC(completion_new),
+ API_DEF_FUNC(completion_search),
+ API_DEF_FUNC(completion_free),
API_DEF_FUNC(info_get),
API_DEF_FUNC(info_get_hashtable),
API_DEF_FUNC(infolist_new),
diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c
index 983564905..9526b5109 100644
--- a/src/plugins/perl/weechat-perl-api.c
+++ b/src/plugins/perl/weechat-perl-api.c
@@ -4258,6 +4258,56 @@ API_FUNC(command_options)
API_RETURN_INT(rc);
}
+API_FUNC(completion_new)
+{
+ char *buffer;
+ const char *result;
+ dXSARGS;
+
+ API_INIT_FUNC(1, "completion_new", API_RETURN_EMPTY);
+ if (items < 1)
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ buffer = SvPV_nolen (ST (0));
+
+ result = API_PTR2STR(weechat_completion_new (API_STR2PTR(buffer)));
+
+ API_RETURN_STRING(result);
+}
+
+API_FUNC(completion_search)
+{
+ char *completion, *data;
+ dXSARGS;
+
+ API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR);
+ if (items < 4)
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ completion = SvPV_nolen (ST (0));
+ data = SvPV_nolen (ST (1));
+
+ weechat_completion_search (API_STR2PTR(completion),
+ data,
+ SvIV (ST (2)), /* position */
+ SvIV (ST (3))); /* direction */
+
+ API_RETURN_OK;
+}
+
+API_FUNC(completion_free)
+{
+ dXSARGS;
+
+ API_INIT_FUNC(1, "completion_free", API_RETURN_ERROR);
+ if (items < 1)
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_completion_free (API_STR2PTR(SvPV_nolen (ST (0)))); /* completion */
+
+ API_RETURN_OK;
+}
+
API_FUNC(info_get)
{
char *info_name, *arguments, *result;
@@ -5302,6 +5352,9 @@ weechat_perl_api_init (pTHX)
API_DEF_FUNC(bar_remove);
API_DEF_FUNC(command);
API_DEF_FUNC(command_options);
+ API_DEF_FUNC(completion_new);
+ API_DEF_FUNC(completion_search);
+ API_DEF_FUNC(completion_free);
API_DEF_FUNC(info_get);
API_DEF_FUNC(info_get_hashtable);
API_DEF_FUNC(infolist_new);
diff --git a/src/plugins/php/weechat-php-api.c b/src/plugins/php/weechat-php-api.c
index a8cd4a79f..981f3f365 100644
--- a/src/plugins/php/weechat-php-api.c
+++ b/src/plugins/php/weechat-php-api.c
@@ -275,6 +275,7 @@ API_FUNC(charset_set)
API_WRONG_ARGS(API_RETURN_ERROR);
charset = ZSTR_VAL(z_charset);
+
plugin_script_api_charset_set (php_current_script, (const char *)charset);
API_RETURN_OK;
@@ -292,6 +293,7 @@ API_FUNC(iconv_to_internal)
charset = ZSTR_VAL(z_charset);
string = ZSTR_VAL(z_string);
+
result = weechat_iconv_to_internal ((const char *)charset,
(const char *)string);
@@ -310,6 +312,7 @@ API_FUNC(iconv_from_internal)
charset = ZSTR_VAL(z_charset);
string = ZSTR_VAL(z_string);
+
result = weechat_iconv_from_internal ((const char *)charset,
(const char *)string);
@@ -327,6 +330,7 @@ API_FUNC(gettext)
API_WRONG_ARGS(API_RETURN_EMPTY);
string = ZSTR_VAL(z_string);
+
result = weechat_gettext ((const char *)string);
API_RETURN_STRING(result);
@@ -348,6 +352,7 @@ API_FUNC(ngettext)
single = ZSTR_VAL(z_single);
plural = ZSTR_VAL(z_plural);
count = (int)z_count;
+
result = weechat_ngettext ((const char *)single,
(const char *)plural,
count);
@@ -367,6 +372,7 @@ API_FUNC(strlen_screen)
API_WRONG_ARGS(API_RETURN_INT(0));
string = ZSTR_VAL(z_string);
+
result = weechat_strlen_screen ((const char *)string);
API_RETURN_INT(result);
@@ -387,6 +393,7 @@ API_FUNC(string_match)
string = ZSTR_VAL(z_string);
mask = ZSTR_VAL(z_mask);
case_sensitive = (int)z_case_sensitive;
+
result = weechat_string_match ((const char *)string,
(const char *)mask,
case_sensitive);
@@ -409,6 +416,7 @@ API_FUNC(string_match_list)
string = ZSTR_VAL(z_string);
masks = ZSTR_VAL(z_masks);
case_sensitive = (int)z_case_sensitive;
+
result = plugin_script_api_string_match_list (weechat_php_plugin,
(const char *)string,
(const char *)masks,
@@ -431,6 +439,7 @@ API_FUNC(string_has_highlight)
string = ZSTR_VAL(z_string);
highlight_words = ZSTR_VAL(z_highlight_words);
+
result = weechat_string_has_highlight ((const char *)string,
(const char *)highlight_words);
@@ -450,6 +459,7 @@ API_FUNC(string_has_highlight_regex)
string = ZSTR_VAL(z_string);
regex = ZSTR_VAL(z_regex);
+
result = weechat_string_has_highlight_regex ((const char *)string,
(const char *)regex);
@@ -467,6 +477,7 @@ API_FUNC(string_mask_to_regex)
API_WRONG_ARGS(API_RETURN_EMPTY);
mask = ZSTR_VAL(z_mask);
+
result = weechat_string_mask_to_regex ((const char *)mask);
API_RETURN_STRING_FREE(result);
@@ -498,6 +509,7 @@ API_FUNC(string_remove_color)
string = ZSTR_VAL(z_string);
replacement = ZSTR_VAL(z_replacement);
+
result = weechat_string_remove_color ((const char *)string,
(const char *)replacement);
@@ -515,6 +527,7 @@ API_FUNC(string_is_command_char)
API_WRONG_ARGS(API_RETURN_INT(0));
string = ZSTR_VAL(z_string);
+
result = weechat_string_is_command_char ((const char *)string);
API_RETURN_INT(result);
@@ -531,6 +544,7 @@ API_FUNC(string_input_for_buffer)
API_WRONG_ARGS(API_RETURN_EMPTY);
string = ZSTR_VAL(z_string);
+
result = weechat_string_input_for_buffer ((const char *)string);
API_RETURN_STRING(result);
@@ -639,6 +653,7 @@ API_FUNC(mkdir_home)
directory = ZSTR_VAL(z_directory);
mode = (int)z_mode;
+
if (weechat_mkdir_home ((const char *)directory, mode))
API_RETURN_OK;
@@ -659,6 +674,7 @@ API_FUNC(mkdir)
directory = ZSTR_VAL(z_directory);
mode = (int)z_mode;
+
if (weechat_mkdir ((const char *)directory, mode))
API_RETURN_OK;
@@ -679,6 +695,7 @@ API_FUNC(mkdir_parents)
directory = ZSTR_VAL(z_directory);
mode = (int)z_mode;
+
if (weechat_mkdir_parents ((const char *)directory, mode))
API_RETURN_OK;
@@ -758,6 +775,7 @@ API_FUNC(list_search_pos)
weelist = (struct t_weelist *)API_STR2PTR(ZSTR_VAL(z_weelist));
data = ZSTR_VAL(z_data);
+
result = weechat_list_search_pos (weelist, (const char *)data);
API_RETURN_INT(result);
@@ -798,6 +816,7 @@ API_FUNC(list_casesearch_pos)
weelist = (struct t_weelist *)API_STR2PTR(ZSTR_VAL(z_weelist));
data = ZSTR_VAL(z_data);
+
result = weechat_list_casesearch_pos (weelist, (const char *)data);
API_RETURN_INT(result);
@@ -837,6 +856,7 @@ API_FUNC(list_set)
item = (struct t_weelist_item *)API_STR2PTR(ZSTR_VAL(z_item));
value = ZSTR_VAL(z_value);
+
weechat_list_set (item, (const char *)value);
API_RETURN_OK;
@@ -888,6 +908,7 @@ API_FUNC(list_string)
API_WRONG_ARGS(API_RETURN_EMPTY);
item = (struct t_weelist_item *)API_STR2PTR(ZSTR_VAL(z_item));
+
result = weechat_list_string (item);
API_RETURN_STRING(result);
@@ -904,6 +925,7 @@ API_FUNC(list_size)
API_WRONG_ARGS(API_RETURN_INT(0));
weelist = (struct t_weelist *)API_STR2PTR(ZSTR_VAL(z_weelist));
+
result = weechat_list_size (weelist);
API_RETURN_INT(result);
@@ -922,6 +944,7 @@ API_FUNC(list_remove)
weelist = (struct t_weelist *)API_STR2PTR(ZSTR_VAL(z_weelist));
item = (struct t_weelist_item *)API_STR2PTR(ZSTR_VAL(z_item));
+
weechat_list_remove (weelist, item);
API_RETURN_OK;
@@ -938,6 +961,7 @@ API_FUNC(list_remove_all)
API_WRONG_ARGS(API_RETURN_ERROR);
weelist = (struct t_weelist *)API_STR2PTR(ZSTR_VAL(z_weelist));
+
weechat_list_remove_all (weelist);
API_RETURN_OK;
@@ -953,6 +977,7 @@ API_FUNC(list_free)
API_WRONG_ARGS(API_RETURN_ERROR);
weelist = (struct t_weelist *)API_STR2PTR(ZSTR_VAL(z_weelist));
+
weechat_list_free (weelist);
API_RETURN_OK;
@@ -1344,6 +1369,7 @@ API_FUNC(config_string_to_boolean)
API_WRONG_ARGS(API_RETURN_INT(0));
text = ZSTR_VAL(z_text);
+
result = weechat_config_string_to_boolean ((const char *)text);
API_RETURN_INT(result);
@@ -1363,6 +1389,7 @@ API_FUNC(config_option_reset)
option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option));
run_callback = (int)z_run_callback;
+
result = weechat_config_option_reset (option, run_callback);
API_RETURN_INT(result);
@@ -1385,6 +1412,7 @@ API_FUNC(config_option_set)
option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option));
value = ZSTR_VAL(z_value);
run_callback = (int)z_run_callback;
+
result = weechat_config_option_set (option, (const char *)value,
run_callback);
@@ -1405,6 +1433,7 @@ API_FUNC(config_option_set_null)
option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option));
run_callback = (int)z_run_callback;
+
result = weechat_config_option_set_null (option, run_callback);
API_RETURN_INT(result);
@@ -1421,6 +1450,7 @@ API_FUNC(config_option_unset)
API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR));
option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option));
+
result = weechat_config_option_unset (option);
API_RETURN_INT(result);
@@ -1439,6 +1469,7 @@ API_FUNC(config_option_rename)
option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option));
new_name = ZSTR_VAL(z_new_name);
+
weechat_config_option_rename (option, (const char *)new_name);
API_RETURN_OK;
@@ -1455,6 +1486,7 @@ API_FUNC(config_option_is_null)
API_WRONG_ARGS(API_RETURN_INT(1));
option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option));
+
result = weechat_config_option_is_null (option);
API_RETURN_INT(result);
@@ -1471,6 +1503,7 @@ API_FUNC(config_option_default_is_null)
API_WRONG_ARGS(API_RETURN_INT(1));
option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option));
+
result = weechat_config_option_default_is_null (option);
API_RETURN_INT(result);
@@ -1487,6 +1520,7 @@ API_FUNC(config_boolean)
API_WRONG_ARGS(API_RETURN_INT(0));
option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option));
+
result = weechat_config_boolean (option);
API_RETURN_INT(result);
@@ -1503,6 +1537,7 @@ API_FUNC(config_boolean_default)
API_WRONG_ARGS(API_RETURN_INT(0));
option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option));
+
result = weechat_config_boolean_default (option);
API_RETURN_INT(result);
@@ -1519,6 +1554,7 @@ API_FUNC(config_integer)
API_WRONG_ARGS(API_RETURN_INT(0));
option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option));
+
result = weechat_config_integer (option);
API_RETURN_INT(result);
@@ -1535,6 +1571,7 @@ API_FUNC(config_integer_default)
API_WRONG_ARGS(API_RETURN_INT(0));
option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option));
+
result = weechat_config_integer_default (option);
API_RETURN_INT(result);
@@ -1551,6 +1588,7 @@ API_FUNC(config_string)
API_WRONG_ARGS(API_RETURN_EMPTY);
option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option));
+
result = weechat_config_string (option);
API_RETURN_STRING(result);
@@ -1567,6 +1605,7 @@ API_FUNC(config_string_default)
API_WRONG_ARGS(API_RETURN_EMPTY);
option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option));
+
result = weechat_config_string_default (option);
API_RETURN_STRING(result);
@@ -1583,6 +1622,7 @@ API_FUNC(config_color)
API_WRONG_ARGS(API_RETURN_EMPTY);
option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option));
+
result = weechat_config_color (option);
API_RETURN_STRING(result);
@@ -1599,6 +1639,7 @@ API_FUNC(config_color_default)
API_WRONG_ARGS(API_RETURN_EMPTY);
option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option));
+
result = weechat_config_color_default (option);
API_RETURN_STRING(result);
@@ -1657,6 +1698,7 @@ API_FUNC(config_write)
API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_WRITE_ERROR));
config_file = (struct t_config_file *)API_STR2PTR(ZSTR_VAL(z_config_file));
+
result = weechat_config_write (config_file);
API_RETURN_INT(result);
@@ -1674,6 +1716,7 @@ API_FUNC(config_read)
API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_READ_FILE_NOT_FOUND));
config_file = (struct t_config_file *)API_STR2PTR(ZSTR_VAL(z_config_file));
+
result = weechat_config_read (config_file);
API_RETURN_INT(result);
@@ -1691,6 +1734,7 @@ API_FUNC(config_reload)
API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_READ_FILE_NOT_FOUND));
config_file = (struct t_config_file *)API_STR2PTR(ZSTR_VAL(z_config_file));
+
result = weechat_config_reload (config_file);
API_RETURN_INT(result);
@@ -1706,6 +1750,7 @@ API_FUNC(config_option_free)
API_WRONG_ARGS(API_RETURN_ERROR);
option = (struct t_config_option *)API_STR2PTR(ZSTR_VAL(z_option));
+
weechat_config_option_free (option);
API_RETURN_OK;
@@ -1722,6 +1767,7 @@ API_FUNC(config_section_free_options)
API_WRONG_ARGS(API_RETURN_ERROR);
section = (struct t_config_section *)API_STR2PTR(ZSTR_VAL(z_section));
+
weechat_config_section_free_options (section);
API_RETURN_OK;
@@ -1738,6 +1784,7 @@ API_FUNC(config_section_free)
API_WRONG_ARGS(API_RETURN_ERROR);
section = (struct t_config_section *)API_STR2PTR(ZSTR_VAL(z_section));
+
weechat_config_section_free (section);
API_RETURN_OK;
@@ -1754,6 +1801,7 @@ API_FUNC(config_free)
API_WRONG_ARGS(API_RETURN_ERROR);
config_file = (struct t_config_file *)API_STR2PTR(ZSTR_VAL(z_config_file));
+
weechat_config_free (config_file);
API_RETURN_OK;
@@ -1788,6 +1836,7 @@ API_FUNC(config_get_plugin)
API_WRONG_ARGS(API_RETURN_EMPTY);
option = ZSTR_VAL(z_option);
+
result = plugin_script_api_config_get_plugin (weechat_php_plugin,
php_current_script,
(const char *)option);
@@ -1806,6 +1855,7 @@ API_FUNC(config_is_set_plugin)
API_WRONG_ARGS(API_RETURN_INT(0));
option = ZSTR_VAL(z_option);
+
result = plugin_script_api_config_is_set_plugin (weechat_php_plugin,
php_current_script,
(const char *)option);
@@ -1826,6 +1876,7 @@ API_FUNC(config_set_plugin)
option = ZSTR_VAL(z_option);
value = ZSTR_VAL(z_value);
+
result = plugin_script_api_config_set_plugin (weechat_php_plugin,
php_current_script,
(const char *)option,
@@ -1846,6 +1897,7 @@ API_FUNC(config_set_desc_plugin)
option = ZSTR_VAL(z_option);
description = ZSTR_VAL(z_description);
+
plugin_script_api_config_set_desc_plugin (weechat_php_plugin,
php_current_script,
(const char *)option,
@@ -1865,6 +1917,7 @@ API_FUNC(config_unset_plugin)
API_WRONG_ARGS(API_RETURN_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR));
option = ZSTR_VAL(z_option);
+
result = plugin_script_api_config_unset_plugin (weechat_php_plugin,
php_current_script,
(const char *)option);
@@ -1912,6 +1965,7 @@ API_FUNC(key_unbind)
context = ZSTR_VAL(z_context);
key = ZSTR_VAL(z_key);
+
result = weechat_key_unbind ((const char *)context, (const char *)key);
API_RETURN_INT(result);
@@ -1928,6 +1982,7 @@ API_FUNC(prefix)
API_WRONG_ARGS(API_RETURN_EMPTY);
prefix = ZSTR_VAL(z_prefix);
+
result = weechat_prefix ((const char *)prefix);
API_RETURN_STRING(result);
@@ -1944,6 +1999,7 @@ API_FUNC(color)
API_WRONG_ARGS(API_RETURN_EMPTY);
color_name = ZSTR_VAL(z_color_name);
+
result = weechat_color ((const char *)color_name);
API_RETURN_STRING(result);
@@ -1962,6 +2018,7 @@ API_FUNC(print)
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
message = ZSTR_VAL(z_message);
+
plugin_script_api_printf (weechat_php_plugin, php_current_script, buffer,
"%s", message);
@@ -1985,6 +2042,7 @@ API_FUNC(print_date_tags)
date = (time_t)z_date;
tags = ZSTR_VAL(z_tags);
message = ZSTR_VAL(z_message);
+
plugin_script_api_printf_date_tags (weechat_php_plugin,
php_current_script,
buffer,
@@ -2012,6 +2070,7 @@ API_FUNC(print_y)
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
y = (int)z_y;
message = ZSTR_VAL(z_message);
+
plugin_script_api_printf_y (weechat_php_plugin,
php_current_script,
buffer,
@@ -2032,6 +2091,7 @@ API_FUNC(log_print)
API_WRONG_ARGS(API_RETURN_ERROR);
message = ZSTR_VAL(z_message);
+
plugin_script_api_log_printf (weechat_php_plugin, php_current_script,
"%s", message);
@@ -2160,6 +2220,7 @@ API_FUNC(hook_completion_get_string)
completion = (struct t_gui_completion *)API_STR2PTR(ZSTR_VAL(z_completion));
property = ZSTR_VAL(z_property);
+
result = weechat_hook_completion_get_string (completion,
(const char *)property);
@@ -2183,6 +2244,7 @@ API_FUNC(hook_completion_list_add)
word = ZSTR_VAL(z_word);
nick_completion = (int)z_nick_completion;
where = ZSTR_VAL(z_where);
+
weechat_hook_completion_list_add (completion,
(const char *)word,
nick_completion,
@@ -2880,6 +2942,7 @@ API_FUNC(hook_modifier_exec)
modifier = ZSTR_VAL(z_modifier);
modifier_data = ZSTR_VAL(z_modifier_data);
string = ZSTR_VAL(z_string);
+
result = weechat_hook_modifier_exec ((const char *)modifier,
(const char *)modifier_data,
(const char *)string);
@@ -3107,6 +3170,7 @@ API_FUNC(hook_set)
hook = (struct t_hook *)API_STR2PTR(ZSTR_VAL(z_hook));
property = ZSTR_VAL(z_property);
value = ZSTR_VAL(z_value);
+
weechat_hook_set (hook, (const char *)property, (const char *)value);
API_RETURN_OK;
@@ -3122,6 +3186,7 @@ API_FUNC(unhook)
API_WRONG_ARGS(API_RETURN_ERROR);
hook = (struct t_hook *)API_STR2PTR(ZSTR_VAL(z_hook));
+
weechat_unhook (hook);
API_RETURN_OK;
@@ -3137,6 +3202,7 @@ API_FUNC(unhook_all)
API_WRONG_ARGS(API_RETURN_ERROR);
subplugin = ZSTR_VAL(z_subplugin);
+
weechat_unhook_all ((const char *)subplugin);
API_RETURN_OK;
@@ -3264,6 +3330,7 @@ API_FUNC(buffer_clear)
API_WRONG_ARGS(API_RETURN_ERROR);
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
+
weechat_buffer_clear (buffer);
API_RETURN_OK;
@@ -3279,6 +3346,7 @@ API_FUNC(buffer_close)
API_WRONG_ARGS(API_RETURN_ERROR);
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
+
weechat_buffer_close (buffer);
API_RETURN_OK;
@@ -3298,6 +3366,7 @@ API_FUNC(buffer_merge)
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
target_buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_target_buffer));
+
weechat_buffer_merge (buffer, target_buffer);
API_RETURN_OK;
@@ -3317,6 +3386,7 @@ API_FUNC(buffer_unmerge)
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
number = (int)z_number;
+
weechat_buffer_unmerge (buffer, number);
API_RETURN_OK;
@@ -3336,6 +3406,7 @@ API_FUNC(buffer_get_integer)
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
property = ZSTR_VAL(z_property);
+
result = weechat_buffer_get_integer (buffer, (const char *)property);
API_RETURN_INT(result);
@@ -3355,6 +3426,7 @@ API_FUNC(buffer_get_string)
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
property = ZSTR_VAL(z_property);
+
result = weechat_buffer_get_string (buffer, (const char *)property);
API_RETURN_STRING(result);
@@ -3395,6 +3467,7 @@ API_FUNC(buffer_set)
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
property = ZSTR_VAL(z_property);
value = ZSTR_VAL(z_value);
+
weechat_buffer_set (buffer, (const char *)property, (const char *)value);
API_RETURN_OK;
@@ -3413,6 +3486,7 @@ API_FUNC(buffer_string_replace_local_var)
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
string = ZSTR_VAL(z_string);
+
result = weechat_buffer_string_replace_local_var (buffer,
(const char *)string);
@@ -3433,6 +3507,7 @@ API_FUNC(buffer_match_list)
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
string = ZSTR_VAL(z_string);
+
result = weechat_buffer_match_list (buffer, (const char *)string);
API_RETURN_INT(result);
@@ -3482,6 +3557,7 @@ API_FUNC(window_get_integer)
window = (struct t_gui_window *)API_STR2PTR(ZSTR_VAL(z_window));
property = ZSTR_VAL(z_property);
+
result = weechat_window_get_integer (window, (const char *)property);
API_RETURN_INT(result);
@@ -3501,6 +3577,7 @@ API_FUNC(window_get_string)
window = (struct t_gui_window *)API_STR2PTR(ZSTR_VAL(z_window));
property = ZSTR_VAL(z_property);
+
result = weechat_window_get_string (window, (const char *)property);
API_RETURN_STRING(result);
@@ -3537,6 +3614,7 @@ API_FUNC(window_set_title)
API_WRONG_ARGS(API_RETURN_ERROR);
title = ZSTR_VAL(z_title);
+
weechat_window_set_title ((const char *)title);
API_RETURN_OK;
@@ -3672,6 +3750,7 @@ API_FUNC(nicklist_remove_group)
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
group = (struct t_gui_nick_group *)API_STR2PTR(ZSTR_VAL(z_group));
+
weechat_nicklist_remove_group (buffer, group);
API_RETURN_OK;
@@ -3690,6 +3769,7 @@ API_FUNC(nicklist_remove_nick)
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
nick = (struct t_gui_nick *)API_STR2PTR(ZSTR_VAL(z_nick));
+
weechat_nicklist_remove_nick (buffer, nick);
API_RETURN_OK;
@@ -3705,6 +3785,7 @@ API_FUNC(nicklist_remove_all)
API_WRONG_ARGS(API_RETURN_ERROR);
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
+
weechat_nicklist_remove_all (buffer);
API_RETURN_OK;
@@ -3726,6 +3807,7 @@ API_FUNC(nicklist_group_get_integer)
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
group = (struct t_gui_nick_group *)API_STR2PTR(ZSTR_VAL(z_group));
property = ZSTR_VAL(z_property);
+
result = weechat_nicklist_group_get_integer (buffer,
group,
(const char *)property);
@@ -3749,6 +3831,7 @@ API_FUNC(nicklist_group_get_string)
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
group = (struct t_gui_nick_group *)API_STR2PTR(ZSTR_VAL(z_group));
property = ZSTR_VAL(z_property);
+
result = weechat_nicklist_group_get_string (buffer,
group,
(const char *)property);
@@ -3797,6 +3880,7 @@ API_FUNC(nicklist_group_set)
group = (struct t_gui_nick_group *)API_STR2PTR(ZSTR_VAL(z_group));
property = ZSTR_VAL(z_property);
value = ZSTR_VAL(z_value);
+
weechat_nicklist_group_set (buffer,
group,
(const char *)property,
@@ -3821,6 +3905,7 @@ API_FUNC(nicklist_nick_get_integer)
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
nick = (struct t_gui_nick *)API_STR2PTR(ZSTR_VAL(z_nick));
property = ZSTR_VAL(z_property);
+
result = weechat_nicklist_nick_get_integer (buffer,
nick,
(const char *)property);
@@ -3844,6 +3929,7 @@ API_FUNC(nicklist_nick_get_string)
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
nick = (struct t_gui_nick *)API_STR2PTR(ZSTR_VAL(z_nick));
property = ZSTR_VAL(z_property);
+
result = weechat_nicklist_nick_get_string (buffer,
nick,
(const char *)property);
@@ -3892,6 +3978,7 @@ API_FUNC(nicklist_nick_set)
nick = (struct t_gui_nick *)API_STR2PTR(ZSTR_VAL(z_nick));
property = ZSTR_VAL(z_property);
value = ZSTR_VAL(z_value);
+
weechat_nicklist_nick_set (buffer,
nick,
(const char *)property,
@@ -3976,6 +4063,7 @@ API_FUNC(bar_item_update)
API_WRONG_ARGS(API_RETURN_ERROR);
name = ZSTR_VAL(z_name);
+
weechat_bar_item_update ((const char *)name);
API_RETURN_OK;
@@ -3991,6 +4079,7 @@ API_FUNC(bar_item_remove)
API_WRONG_ARGS(API_RETURN_ERROR);
item = (struct t_gui_bar_item *)API_STR2PTR(ZSTR_VAL(z_item));
+
weechat_bar_item_remove (item);
API_RETURN_OK;
@@ -4085,6 +4174,7 @@ API_FUNC(bar_set)
bar = (struct t_gui_bar *)API_STR2PTR(ZSTR_VAL(z_bar));
property = ZSTR_VAL(z_property);
value = ZSTR_VAL(z_value);
+
result = weechat_bar_set (bar, (const char *)property, (const char *)value);
API_RETURN_INT(result);
@@ -4115,6 +4205,7 @@ API_FUNC(bar_remove)
API_WRONG_ARGS(API_RETURN_ERROR);
bar = (struct t_gui_bar *)API_STR2PTR(ZSTR_VAL(z_bar));
+
weechat_bar_remove (bar);
API_RETURN_OK;
@@ -4134,6 +4225,7 @@ API_FUNC(command)
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
command = ZSTR_VAL(z_command);
+
result = plugin_script_api_command (weechat_php_plugin,
php_current_script,
buffer,
@@ -4176,6 +4268,62 @@ API_FUNC(command_options)
API_RETURN_INT(result);
}
+API_FUNC(completion_new)
+{
+ zend_string *z_buffer;
+ struct t_gui_buffer *buffer;
+ const char *result;
+
+ API_INIT_FUNC(1, "completion_new", API_RETURN_EMPTY);
+ if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_buffer) == FAILURE)
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
+
+ result = API_PTR2STR(weechat_completion_new (buffer));
+
+ API_RETURN_STRING(result);
+}
+
+API_FUNC(completion_search)
+{
+ zend_string *z_completion, *z_data;
+ zend_long z_position, z_direction;
+ char *data;
+ struct t_gui_completion *completion;
+ int position, direction;
+
+ API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR);
+ if (zend_parse_parameters (ZEND_NUM_ARGS(), "SSll", &z_completion, &z_data,
+ &z_position, &z_direction) == FAILURE)
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ completion = (struct t_gui_completion *)API_STR2PTR(ZSTR_VAL(z_completion));
+ data = ZSTR_VAL(z_data);
+ position = (int)z_position;
+ direction = (int)z_direction;
+
+ weechat_completion_search (completion, data, position, direction);
+
+ API_RETURN_OK;
+}
+
+API_FUNC(completion_free)
+{
+ zend_string *z_completion;
+ struct t_gui_completion *completion;
+
+ API_INIT_FUNC(1, "completion_free", API_RETURN_ERROR);
+ if (zend_parse_parameters (ZEND_NUM_ARGS(), "S", &z_completion) == FAILURE)
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ completion = (struct t_gui_completion *)API_STR2PTR(ZSTR_VAL(z_completion));
+
+ weechat_completion_free (completion);
+
+ API_RETURN_OK;
+}
+
API_FUNC(info_get)
{
zend_string *z_info_name, *z_arguments;
@@ -4188,6 +4336,7 @@ API_FUNC(info_get)
info_name = ZSTR_VAL(z_info_name);
arguments = ZSTR_VAL(z_arguments);
+
result = weechat_info_get ((const char *)info_name,
(const char *)arguments);
@@ -4405,6 +4554,7 @@ API_FUNC(infolist_next)
API_WRONG_ARGS(API_RETURN_INT(0));
infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist));
+
result = weechat_infolist_next (infolist);
API_RETURN_INT(result);
@@ -4421,6 +4571,7 @@ API_FUNC(infolist_prev)
API_WRONG_ARGS(API_RETURN_INT(0));
infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist));
+
result = weechat_infolist_prev (infolist);
API_RETURN_INT(result);
@@ -4436,6 +4587,7 @@ API_FUNC(infolist_reset_item_cursor)
API_WRONG_ARGS(API_RETURN_ERROR);
infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist));
+
weechat_infolist_reset_item_cursor (infolist);
API_RETURN_OK;
@@ -4452,6 +4604,7 @@ API_FUNC(infolist_fields)
API_WRONG_ARGS(API_RETURN_EMPTY);
infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist));
+
result = weechat_infolist_fields (infolist);
API_RETURN_STRING(result);
@@ -4471,6 +4624,7 @@ API_FUNC(infolist_integer)
infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist));
var = ZSTR_VAL(z_var);
+
result = weechat_infolist_integer (infolist, (const char *)var);
API_RETURN_INT(result);
@@ -4490,6 +4644,7 @@ API_FUNC(infolist_string)
infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist));
var = ZSTR_VAL(z_var);
+
result = weechat_infolist_string (infolist, (const char *)var);
API_RETURN_STRING(result);
@@ -4546,6 +4701,7 @@ API_FUNC(infolist_free)
API_WRONG_ARGS(API_RETURN_ERROR);
infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist));
+
weechat_infolist_free (infolist);
API_RETURN_OK;
@@ -4582,6 +4738,7 @@ API_FUNC(hdata_get_var_offset)
hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata));
name = ZSTR_VAL(z_name);
+
result = weechat_hdata_get_var_offset (hdata, (const char *)name);
API_RETURN_INT(result);
@@ -4601,6 +4758,7 @@ API_FUNC(hdata_get_var_type_string)
hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata));
name = ZSTR_VAL(z_name);
+
result = weechat_hdata_get_var_type_string (hdata, (const char *)name);
API_RETURN_STRING(result);
@@ -4622,6 +4780,7 @@ API_FUNC(hdata_get_var_array_size)
hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata));
pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer));
name = ZSTR_VAL(z_name);
+
result = weechat_hdata_get_var_array_size (hdata,
pointer,
(const char *)name);
@@ -4645,6 +4804,7 @@ API_FUNC(hdata_get_var_array_size_string)
hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata));
pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer));
name = ZSTR_VAL(z_name);
+
result = weechat_hdata_get_var_array_size_string (hdata,
pointer,
(const char *)name);
@@ -4666,6 +4826,7 @@ API_FUNC(hdata_get_var_hdata)
hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata));
name = ZSTR_VAL(z_name);
+
result = weechat_hdata_get_var_hdata (hdata, (const char *)name);
API_RETURN_STRING(result);
@@ -4707,6 +4868,7 @@ API_FUNC(hdata_check_pointer)
hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata));
list = (void *)API_STR2PTR(ZSTR_VAL(z_list));
pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer));
+
result = weechat_hdata_check_pointer (hdata, list, pointer);
API_RETURN_INT(result);
@@ -4776,6 +4938,7 @@ API_FUNC(hdata_char)
hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata));
pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer));
name = ZSTR_VAL(z_name);
+
result = weechat_hdata_char (hdata, pointer, (const char *)name);
API_RETURN_INT((int)result);
@@ -4797,6 +4960,7 @@ API_FUNC(hdata_integer)
hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata));
pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer));
name = ZSTR_VAL(z_name);
+
result = weechat_hdata_integer (hdata, pointer, (const char *)name);
API_RETURN_INT(result);
@@ -4818,6 +4982,7 @@ API_FUNC(hdata_long)
hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata));
pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer));
name = ZSTR_VAL(z_name);
+
result = weechat_hdata_long (hdata, pointer, (const char *)name);
API_RETURN_LONG(result);
@@ -4839,6 +5004,7 @@ API_FUNC(hdata_string)
hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata));
pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer));
name = ZSTR_VAL(z_name);
+
result = weechat_hdata_string (hdata, pointer, (const char *)name);
API_RETURN_STRING(result);
@@ -4883,6 +5049,7 @@ API_FUNC(hdata_time)
hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata));
pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer));
name = ZSTR_VAL(z_name);
+
result = weechat_hdata_time (hdata, pointer, (const char *)name);
API_RETURN_LONG(result);
@@ -4904,6 +5071,7 @@ API_FUNC(hdata_hashtable)
hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata));
pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer));
name = ZSTR_VAL(z_name);
+
result = weechat_hdata_hashtable (hdata, pointer, (const char *)name);
weechat_php_hashtable_to_array (result, return_value);
@@ -4929,6 +5097,7 @@ API_FUNC(hdata_compare)
pointer2 = (void *)API_STR2PTR(ZSTR_VAL(z_pointer2));
name = (void *)API_STR2PTR(ZSTR_VAL(z_name));
case_sensitive = (int)z_case_sensitive;
+
result = weechat_hdata_compare (hdata, pointer1, pointer2, name,
case_sensitive);
@@ -4979,6 +5148,7 @@ API_FUNC(hdata_get_string)
hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata));
property = ZSTR_VAL(z_property);
+
result = weechat_hdata_get_string (hdata, (const char *)property);
API_RETURN_STRING(result);
@@ -5049,6 +5219,7 @@ API_FUNC(upgrade_write_object)
upgrade_file = (struct t_upgrade_file *)API_STR2PTR(ZSTR_VAL(z_upgrade_file));
object_id = (int)z_object_id;
infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist));
+
result = weechat_upgrade_write_object (upgrade_file, object_id, infolist);
API_RETURN_INT(result);
@@ -5066,6 +5237,7 @@ API_FUNC(upgrade_read)
API_WRONG_ARGS(API_RETURN_INT(0));
upgrade_file = (struct t_upgrade_file *)API_STR2PTR(ZSTR_VAL(z_upgrade_file));
+
result = weechat_upgrade_read (upgrade_file);
API_RETURN_INT(result);
@@ -5082,6 +5254,7 @@ API_FUNC(upgrade_close)
API_WRONG_ARGS(API_RETURN_ERROR);
upgrade_file = (struct t_upgrade_file *)API_STR2PTR(ZSTR_VAL(z_upgrade_file));
+
weechat_upgrade_close (upgrade_file);
API_RETURN_OK;
diff --git a/src/plugins/php/weechat-php-api.h b/src/plugins/php/weechat-php-api.h
index 971a6d83f..303b30735 100644
--- a/src/plugins/php/weechat-php-api.h
+++ b/src/plugins/php/weechat-php-api.h
@@ -198,6 +198,9 @@ PHP_FUNCTION(weechat_bar_update);
PHP_FUNCTION(weechat_bar_remove);
PHP_FUNCTION(weechat_command);
PHP_FUNCTION(weechat_command_options);
+PHP_FUNCTION(weechat_completion_new);
+PHP_FUNCTION(weechat_completion_search);
+PHP_FUNCTION(weechat_completion_free);
PHP_FUNCTION(weechat_info_get);
PHP_FUNCTION(weechat_info_get_hashtable);
PHP_FUNCTION(weechat_infolist_new);
diff --git a/src/plugins/php/weechat-php.c b/src/plugins/php/weechat-php.c
index 189c51689..95e096b8f 100644
--- a/src/plugins/php/weechat-php.c
+++ b/src/plugins/php/weechat-php.c
@@ -251,6 +251,9 @@ const zend_function_entry weechat_functions[] = {
PHP_FE(weechat_bar_remove, NULL)
PHP_FE(weechat_command, NULL)
PHP_FE(weechat_command_options, NULL)
+ PHP_FE(weechat_completion_new, NULL)
+ PHP_FE(weechat_completion_search, NULL)
+ PHP_FE(weechat_completion_free, NULL)
PHP_FE(weechat_info_get, NULL)
PHP_FE(weechat_info_get_hashtable, NULL)
PHP_FE(weechat_infolist_new, NULL)
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index f2065f191..1b5cf78a1 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -55,6 +55,7 @@
#include "../gui/gui-buffer.h"
#include "../gui/gui-chat.h"
#include "../gui/gui-color.h"
+#include "../gui/gui-completion.h"
#include "../gui/gui-key.h"
#include "../gui/gui-nicklist.h"
#include "../gui/gui-window.h"
@@ -849,6 +850,10 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv)
new_plugin->command = &plugin_api_command;
new_plugin->command_options = &plugin_api_command_options;
+ new_plugin->completion_new = &gui_completion_new;
+ new_plugin->completion_search = &gui_completion_search;
+ new_plugin->completion_free = &gui_completion_free;
+
new_plugin->network_pass_proxy = &network_pass_proxy;
new_plugin->network_connect_to = &network_connect_to;
@@ -1133,6 +1138,9 @@ plugin_remove (struct t_weechat_plugin *plugin)
struct t_weechat_plugin *new_weechat_plugins;
struct t_gui_buffer *ptr_buffer, *next_buffer;
+ /* remove all completions (only those created by API) */
+ gui_completion_free_all_plugin (plugin);
+
/* close buffers created by this plugin */
ptr_buffer = gui_buffers;
while (ptr_buffer)
diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c
index e9e3235e8..9ed65c47a 100644
--- a/src/plugins/python/weechat-python-api.c
+++ b/src/plugins/python/weechat-python-api.c
@@ -4272,6 +4272,56 @@ API_FUNC(command_options)
API_RETURN_INT(rc);
}
+API_FUNC(completion_new)
+{
+ char *buffer;
+ const char *result;
+
+ API_INIT_FUNC(1, "completion_new", API_RETURN_EMPTY);
+ buffer = NULL;
+ if (!PyArg_ParseTuple (args, "s", &buffer))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = API_PTR2STR(weechat_completion_new (API_STR2PTR(buffer)));
+
+ API_RETURN_STRING(result);
+}
+
+API_FUNC(completion_search)
+{
+ char *completion, *data;
+ int position, direction;
+
+ API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR);
+ completion = NULL;
+ position = 0;
+ direction = 1;
+ if (!PyArg_ParseTuple (args, "ssii", &completion, &data, &position,
+ &direction))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_completion_search (API_STR2PTR(completion),
+ data,
+ position,
+ direction);
+
+ API_RETURN_OK;
+}
+
+API_FUNC(completion_free)
+{
+ char *completion;
+
+ API_INIT_FUNC(1, "completion_free", API_RETURN_ERROR);
+ completion = NULL;
+ if (!PyArg_ParseTuple (args, "s", &completion))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_completion_free (API_STR2PTR(completion));
+
+ API_RETURN_OK;
+}
+
API_FUNC(info_get)
{
char *info_name, *arguments, *result;
@@ -5253,6 +5303,9 @@ PyMethodDef weechat_python_funcs[] =
API_DEF_FUNC(bar_remove),
API_DEF_FUNC(command),
API_DEF_FUNC(command_options),
+ API_DEF_FUNC(completion_new),
+ API_DEF_FUNC(completion_search),
+ API_DEF_FUNC(completion_free),
API_DEF_FUNC(info_get),
API_DEF_FUNC(info_get_hashtable),
API_DEF_FUNC(infolist_new),
diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c
index 1137ea030..3788ba3d4 100644
--- a/src/plugins/ruby/weechat-ruby-api.c
+++ b/src/plugins/ruby/weechat-ruby-api.c
@@ -5151,6 +5151,71 @@ weechat_ruby_api_command_options (VALUE class, VALUE buffer, VALUE command,
}
static VALUE
+weechat_ruby_api_completion_new (VALUE class, VALUE buffer)
+{
+ char *c_buffer;
+ const char *result;
+
+ API_INIT_FUNC(1, "completion_new", API_RETURN_EMPTY);
+ if (NIL_P (buffer))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ Check_Type (buffer, T_STRING);
+
+ c_buffer = StringValuePtr (buffer);
+
+ result = API_PTR2STR(weechat_completion_new (API_STR2PTR(c_buffer)));
+
+ API_RETURN_STRING(result);
+}
+
+static VALUE
+weechat_ruby_api_completion_search (VALUE class, VALUE completion, VALUE data,
+ VALUE position, VALUE direction)
+{
+ char *c_completion, *c_data;
+ int c_position, c_direction;
+
+ API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR);
+ if (NIL_P (completion) || NIL_P (data) || NIL_P(position)
+ || NIL_P(direction))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ Check_Type (completion, T_STRING);
+ Check_Type (data, T_STRING);
+ CHECK_INTEGER(position);
+ CHECK_INTEGER(direction);
+
+ c_completion = StringValuePtr (completion);
+ c_data = StringValuePtr (data);
+ c_position = NUM2INT (position);
+ c_direction = NUM2INT (direction);
+
+ weechat_completion_search (API_STR2PTR(c_completion), c_data, c_position,
+ c_direction);
+
+ API_RETURN_OK;
+}
+
+static VALUE
+weechat_ruby_api_completion_free (VALUE class, VALUE completion)
+{
+ char *c_completion;
+
+ API_INIT_FUNC(1, "completion_free", API_RETURN_ERROR);
+ if (NIL_P (completion))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ Check_Type (completion, T_STRING);
+
+ c_completion = StringValuePtr (completion);
+
+ weechat_completion_free (API_STR2PTR(c_completion));
+
+ API_RETURN_OK;
+}
+
+static VALUE
weechat_ruby_api_info_get (VALUE class, VALUE info_name, VALUE arguments)
{
char *c_info_name, *c_arguments, *result;
@@ -6421,6 +6486,9 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
API_DEF_FUNC(bar_remove, 1);
API_DEF_FUNC(command, 2);
API_DEF_FUNC(command_options, 3);
+ API_DEF_FUNC(completion_new, 1);
+ API_DEF_FUNC(completion_search, 4);
+ API_DEF_FUNC(completion_free, 1);
API_DEF_FUNC(info_get, 2);
API_DEF_FUNC(info_get_hashtable, 2);
API_DEF_FUNC(infolist_new, 0);
diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c
index e75b44295..edd3bb63b 100644
--- a/src/plugins/tcl/weechat-tcl-api.c
+++ b/src/plugins/tcl/weechat-tcl-api.c
@@ -4624,6 +4624,47 @@ API_FUNC(command_options)
API_RETURN_INT(rc);
}
+API_FUNC(completion_new)
+{
+ Tcl_Obj *objp;
+ char *buffer;
+ const char *result;
+ int i;
+
+ API_INIT_FUNC(1, "completion_new", API_RETURN_EMPTY);
+ if (objc < 2)
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ buffer = Tcl_GetStringFromObj (objv[1], &i);
+
+ result = API_PTR2STR(weechat_completion_new (API_STR2PTR(buffer)));
+
+ API_RETURN_STRING(result);
+}
+
+API_FUNC(completion_search)
+{
+ Tcl_Obj *objp;
+ char *completion, *data;
+ int i, position, direction;
+
+ API_INIT_FUNC(1, "completion_search", API_RETURN_ERROR);
+ if (objc < 5)
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ completion = Tcl_GetStringFromObj (objv[1], &i);
+ data = Tcl_GetStringFromObj (objv[2], &i);
+
+ if ((Tcl_GetIntFromObj (interp, objv[3], &position) != TCL_OK)
+ || (Tcl_GetIntFromObj (interp, objv[4], &direction) != TCL_OK))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_completion_search (API_STR2PTR(completion), data, position,
+ direction);
+
+ API_RETURN_OK;
+}
+
API_FUNC(info_get)
{
Tcl_Obj *objp;
@@ -5780,6 +5821,8 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
API_DEF_FUNC(bar_remove);
API_DEF_FUNC(command);
API_DEF_FUNC(command_options);
+ API_DEF_FUNC(completion_new);
+ API_DEF_FUNC(completion_search);
API_DEF_FUNC(info_get);
API_DEF_FUNC(info_get_hashtable);
API_DEF_FUNC(infolist_new);
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index ca9f783cf..c76f33f01 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -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 "20200301-03"
+#define WEECHAT_PLUGIN_API_VERSION "20200426-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -1009,6 +1009,13 @@ struct t_weechat_plugin
struct t_gui_buffer *buffer, const char *command,
struct t_hashtable *options);
+ /* completion */
+ struct t_gui_completion *(*completion_new) (struct t_weechat_plugin *plugin,
+ struct t_gui_buffer *buffer);
+ void (*completion_search) (struct t_gui_completion *completion,
+ const char *data, int position, int direction);
+ void (*completion_free) (struct t_gui_completion *completion);
+
/* network */
int (*network_pass_proxy) (const char *proxy, int sock,
const char *address, int port);
@@ -1942,6 +1949,16 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
(weechat_plugin->command_options)(weechat_plugin, __buffer, \
__command, __options)
+/* completion */
+#define weechat_completion_new(__buffer) \
+ (weechat_plugin->completion_new)(weechat_plugin, __buffer)
+#define weechat_completion_search(__completion, __data, __position, \
+ __direction) \
+ (weechat_plugin->completion_search)(__completion, __data, \
+ __position, __direction)
+#define weechat_completion_free(__completion) \
+ (weechat_plugin->completion_free)(__completion)
+
/* network */
#define weechat_network_pass_proxy(__proxy, __sock, __address, __port) \
(weechat_plugin->network_pass_proxy)(__proxy, __sock, __address, \