summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.adoc1
-rw-r--r--doc/de/weechat_scripting.de.adoc1
-rw-r--r--doc/en/weechat_plugin_api.en.adoc132
-rw-r--r--doc/en/weechat_scripting.en.adoc1
-rw-r--r--doc/fr/weechat_plugin_api.fr.adoc135
-rw-r--r--doc/fr/weechat_scripting.fr.adoc1
-rw-r--r--doc/it/weechat_plugin_api.it.adoc139
-rw-r--r--doc/it/weechat_scripting.it.adoc1
-rw-r--r--doc/ja/weechat_plugin_api.ja.adoc136
-rw-r--r--doc/ja/weechat_scripting.ja.adoc1
-rw-r--r--doc/pl/weechat_scripting.pl.adoc1
-rw-r--r--doc/sr/weechat_plugin_api.sr.adoc129
-rw-r--r--doc/sr/weechat_scripting.sr.adoc1
-rw-r--r--src/plugins/guile/weechat-guile-api.c40
-rw-r--r--src/plugins/javascript/weechat-js-api.cpp38
-rw-r--r--src/plugins/lua/weechat-lua-api.c41
-rw-r--r--src/plugins/perl/weechat-perl-api.c41
-rw-r--r--src/plugins/php/weechat-php-api.c44
-rw-r--r--src/plugins/php/weechat-php-api.h1
-rw-r--r--src/plugins/php/weechat-php.c1
-rw-r--r--src/plugins/php/weechat-php.stub.php1
-rw-r--r--src/plugins/php/weechat-php_arginfo.h2
-rw-r--r--src/plugins/php/weechat-php_legacy_arginfo.h2
-rw-r--r--src/plugins/plugin-script-api.c67
-rw-r--r--src/plugins/plugin-script-api.h15
-rw-r--r--src/plugins/plugin.c1
-rw-r--r--src/plugins/python/weechat-python-api.c43
-rw-r--r--src/plugins/ruby/weechat-ruby-api.c53
-rw-r--r--src/plugins/tcl/weechat-tcl-api.c42
-rw-r--r--src/plugins/weechat-plugin.h39
30 files changed, 1131 insertions, 19 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index 9a414f6a7..42613b13e 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -33,6 +33,7 @@ Bug fixes::
* core: remove obsolete option weechat.plugin.debug (issue #1744)
* core: fix search of commands with UTF-8 chars in name when option weechat.look.command_incomplete is on (issue #1739)
* core: fix display of hotlist in buflist after changing value of option weechat.look.hotlist_sort (issue #1733)
+ * api: add function buffer_new_props (issue #1759)
* api: fix add of infolist items in hashtable when prefix contains UTF-8 chars in function hashtable_add_from_infolist (issue #1739)
* guile: remove disabling of guile gmp allocator with Guile ≥ 3.0.8
* irc: fix completion of channel topic with UTF-8 chars (issue #1739)
diff --git a/doc/de/weechat_scripting.de.adoc b/doc/de/weechat_scripting.de.adoc
index 066084bee..0bb78ab85 100644
--- a/doc/de/weechat_scripting.de.adoc
+++ b/doc/de/weechat_scripting.de.adoc
@@ -698,6 +698,7 @@ Liste der Skript API Funktionen:
| Buffer |
buffer_new +
+ buffer_new_props +
current_buffer +
buffer_search +
buffer_search_main +
diff --git a/doc/en/weechat_plugin_api.en.adoc b/doc/en/weechat_plugin_api.en.adoc
index 70bdda8fa..e94a84537 100644
--- a/doc/en/weechat_plugin_api.en.adoc
+++ b/doc/en/weechat_plugin_api.en.adoc
@@ -12579,6 +12579,12 @@ _Updated in 1.5._
Open a new buffer.
+[NOTE]
+If you want to immediately set buffer properties (buffer type, local variables,
+key bindings, etc.), then better use the function <<_buffer_new_props,buffer_new_props>>
+which sets these properties during the buffer creation, before sending signal
+<<hook_signal_buffer_opened,buffer_opened>>.
+
Prototype:
[source,c]
@@ -12677,6 +12683,132 @@ def my_close_cb(data, buffer):
buffer = weechat.buffer_new("my_buffer", "my_input_cb", "", "my_close_cb", "")
----
+==== buffer_new_props
+
+_WeeChat ≥ 3.5._
+
+Open a new buffer and apply properties.
+
+Prototype:
+
+[source,c]
+----
+struct t_gui_buffer *weechat_buffer_new_props (const char *name,
+ struct t_hashtable *properties,
+ int (*input_callback)(const void *pointer,
+ void *data,
+ struct t_gui_buffer *buffer,
+ const char *input_data),
+ const void *input_callback_pointer,
+ void *input_callback_data,
+ int (*close_callback)(const void *pointer,
+ void *data,
+ struct t_gui_buffer *buffer),
+ const void *close_callback_pointer,
+ void *close_callback_data);
+----
+
+Arguments:
+
+* _name_: name of buffer (must be unique for plugin)
+* _properties_: properties to apply
+ (see function <<_buffer_set,buffer_set>> for the allowed properties)
+* _input_callback_: function called when input text is entered on buffer,
+ arguments and return value:
+** _const void *pointer_: pointer
+** _void *data_: pointer
+** _struct t_gui_buffer *buffer_: buffer pointer
+** _const char *input_data_: input data
+** return value:
+*** _WEECHAT_RC_OK_
+*** _WEECHAT_RC_ERROR_
+* _input_callback_pointer_: pointer given to callback when it is called by
+ WeeChat
+* _input_callback_data_: pointer given to callback when it is called by
+ WeeChat; if not NULL, it must have been allocated with malloc (or similar
+ function) and it is automatically freed when the buffer is closed
+* _close_callback_: function called when buffer is closed, arguments and return
+ value:
+** _const void *pointer_: pointer
+** _void *data_: pointer
+** _struct t_gui_buffer *buffer_: buffer pointer
+** return value:
+*** _WEECHAT_RC_OK_
+*** _WEECHAT_RC_ERROR_
+* _close_callback_pointer_: pointer given to callback when it is called by
+ WeeChat
+* _close_callback_data_: pointer given to callback when it is called by
+ WeeChat; if not NULL, it must have been allocated with malloc (or similar
+ function) and it is automatically freed when the buffer is closed
+
+Return value:
+
+* pointer to new buffer, NULL if error occurred
+
+C example:
+
+[source,c]
+----
+int
+my_input_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer, const char *input_data)
+{
+ weechat_printf (buffer, "Text: %s", input_data);
+ return WEECHAT_RC_OK;
+}
+
+int
+my_close_cb (const void *pointer, void *data, struct t_gui_buffer *buffer)
+{
+ weechat_printf (NULL, "Buffer '%s' will be closed!",
+ weechat_buffer_get_string (buffer, "name"));
+ return WEECHAT_RC_OK;
+}
+
+struct t_hashtable *properties = weechat_hashtable_new (8,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL,
+ NULL);
+/* buffer with free content */
+weechat_hashtable_set (properties, "type", "free");
+/* no logging on this buffer */
+weechat_hashtable_set (properties, "localvar_set_no_log", "1");
+/* bind key alt-c on this buffer */
+weechat_hashtable_set (properties, "key_bind_meta-c", "/my_command");
+
+struct t_gui_buffer *my_buffer = weechat_buffer_new_props ("my_buffer",
+ properties,
+ &my_input_cb, NULL, NULL,
+ &my_close_cb, NULL, NULL);
+----
+
+Script (Python):
+
+[source,python]
+----
+# prototype
+def buffer_new_props(name: str, properties: Dict[str, str],
+ input_callback: str, input_callback_data: str,
+ close_callback: str, close_callback_data: str) -> str: ...
+
+# example
+def my_input_cb(data, buffer, input_data):
+ weechat.prnt(buffer, "Text: %s" % input_data)
+ return weechat.WEECHAT_RC_OK
+
+def my_close_cb(data, buffer):
+ weechat.prnt("", "Buffer '%s' will be closed!" % weechat.buffer_get_string(buffer, "name"))
+ return weechat.WEECHAT_RC_OK
+
+properties = {
+ "type": "free", # buffer with free content
+ "localvar_set_no_log": "1", # no logging on this buffer
+ "key_bind_meta-c": "/my_command", # bind key alt-c on this buffer
+}
+buffer = weechat.buffer_new_props("my_buffer", properties, "my_input_cb", "", "my_close_cb", "")
+----
+
==== current_buffer
Return pointer to current buffer (buffer displayed by current window).
diff --git a/doc/en/weechat_scripting.en.adoc b/doc/en/weechat_scripting.en.adoc
index f310d1de3..269ff368d 100644
--- a/doc/en/weechat_scripting.en.adoc
+++ b/doc/en/weechat_scripting.en.adoc
@@ -681,6 +681,7 @@ List of functions in script API:
| buffers |
buffer_new +
+ buffer_new_props +
current_buffer +
buffer_search +
buffer_search_main +
diff --git a/doc/fr/weechat_plugin_api.fr.adoc b/doc/fr/weechat_plugin_api.fr.adoc
index 708859d91..86b393124 100644
--- a/doc/fr/weechat_plugin_api.fr.adoc
+++ b/doc/fr/weechat_plugin_api.fr.adoc
@@ -12856,6 +12856,13 @@ _Mis à jour dans la 1.5._
Ouvrir un nouveau tampon.
+[NOTE]
+Si vous souhaitez définir immédiatement des propriétés du tampon (type de tampon,
+variables locales, touches de raccourci, etc.), alors il vaut mieux utiliser
+la fonction <<_buffer_new_props,buffer_new_props>> qui définit ces propriétés
+durant la création du tampon, avant d'envoyer le signal
+<<hook_signal_buffer_opened,buffer_opened>>.
+
Prototype :
[source,c]
@@ -12956,6 +12963,134 @@ def my_close_cb(data, buffer):
buffer = weechat.buffer_new("mon_buffer", "my_input_cb", "", "my_close_cb", "")
----
+==== buffer_new_props
+
+_WeeChat ≥ 3.5._
+
+Ouvrir un nouveau tampon et appliquer des propriétés.
+
+Prototype :
+
+[source,c]
+----
+struct t_gui_buffer *weechat_buffer_new_props (const char *name,
+ struct t_hashtable *properties,
+ int (*input_callback)(const void *pointer,
+ void *data,
+ struct t_gui_buffer *buffer,
+ const char *input_data),
+ const void *input_callback_pointer,
+ void *input_callback_data,
+ int (*close_callback)(const void *pointer,
+ void *data,
+ struct t_gui_buffer *buffer),
+ const void *close_callback_pointer,
+ void *close_callback_data);
+----
+
+Paramètres :
+
+* _name_ : nom du tampon (doit être unique pour l'extension)
+* _properties_ : propriétés à appliquer
+ (voir la fonction <<_buffer_set,buffer_set>> pour les propriétés autorisées)
+* _input_callback_ : fonction appelée lorsque du texte saisi est envoyé au
+ tampon, paramètres et valeur de retour :
+** _const void *pointer_ : pointeur
+** _void *data_ : pointeur
+** _struct t_gui_buffer *buffer_ : pointeur vers le tampon
+** _const char *input_data_ : données en entrée
+** valeur de retour :
+*** _WEECHAT_RC_OK_
+*** _WEECHAT_RC_ERROR_
+* _input_callback_pointer_ : pointeur donné à la fonction de rappel lorsqu'elle
+ est appelée par WeeChat
+* _input_callback_data_ : pointeur donné à la fonction de rappel lorsqu'elle
+ est appelée par WeeChat; si non NULL, doit avoir été alloué par malloc (ou
+ une fonction similaire) et est automatiquement libéré (par free) lorsque le
+ tampon est fermé
+* _close_callback_ : fonction appelée lorsque le tampon est fermé, paramètres et
+ valeur de retour :
+** _const void *pointer_ : pointeur
+** _void *data_ : pointeur
+** _struct t_gui_buffer *buffer_ : pointeur vers le tampon
+** valeur de retour :
+*** _WEECHAT_RC_OK_
+*** _WEECHAT_RC_ERROR_
+* _close_callback_pointer_ : pointeur donné à la fonction de rappel lorsqu'elle
+ est appelée par WeeChat
+* _close_callback_data_ : pointeur donné à la fonction de rappel lorsqu'elle
+ est appelée par WeeChat; si non NULL, doit avoir été alloué par malloc (ou
+ une fonction similaire) et est automatiquement libéré (par free) lorsque le
+ tampon est fermé
+
+Valeur de retour :
+
+* pointeur vers le nouveau tampon, NULL en cas d'erreur
+
+Exemple en C :
+
+[source,c]
+----
+int
+my_input_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer, const char *input_data)
+{
+ weechat_printf (buffer, "Texte : %s", input_data);
+ return WEECHAT_RC_OK;
+}
+
+int
+my_close_cb (const void *pointer, void *data, struct t_gui_buffer *buffer)
+{
+ weechat_printf (NULL, "Le tampon '%s' va être fermé !",
+ weechat_buffer_get_string (buffer, "name"));
+ return WEECHAT_RC_OK;
+}
+
+struct t_hashtable *properties = weechat_hashtable_new (8,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL,
+ NULL);
+/* tampon avec contenu libre */
+weechat_hashtable_set (properties, "type", "free");
+/* pas d'enregistrement sur ce tampon */
+weechat_hashtable_set (properties, "localvar_set_no_log", "1");
+/* associer la touche alt-c sur ce tampon */
+weechat_hashtable_set (properties, "key_bind_meta-c", "/ma_commande");
+
+struct t_gui_buffer *my_buffer = weechat_buffer_new_props ("mon_buffer",
+ properties,
+ &my_input_cb, NULL, NULL,
+ &my_close_cb, NULL, NULL);
+----
+
+Script (Python) :
+
+[source,python]
+----
+# prototype
+def buffer_new_props(name: str, properties: Dict[str, str],
+ input_callback: str, input_callback_data: str,
+ close_callback: str, close_callback_data: str) -> str: ...
+
+# exemple
+def my_input_cb(data, buffer, input_data):
+ weechat.prnt(buffer, "Texte : %s" % input_data)
+ return weechat.WEECHAT_RC_OK
+
+def my_close_cb(data, buffer):
+ weechat.prnt("", "Le tampon '%s' va être fermé !" % weechat.buffer_get_string(buffer, "name"))
+ return weechat.WEECHAT_RC_OK
+
+properties = {
+ "type": "free", # tampon avec contenu libre
+ "localvar_set_no_log": "1", # pas d'enregistrement sur ce tampon
+ "key_bind_meta-c": "/ma_commande", # associer la touche alt-c sur ce tampon
+}
+buffer = weechat.buffer_new_props("mon_buffer", properties, "my_input_cb", "", "my_close_cb", "")
+----
+
==== current_buffer
Retourner un pointeur vers le tampon courant (le tampon affiché par la fenêtre
diff --git a/doc/fr/weechat_scripting.fr.adoc b/doc/fr/weechat_scripting.fr.adoc
index b7243d182..e037a45e3 100644
--- a/doc/fr/weechat_scripting.fr.adoc
+++ b/doc/fr/weechat_scripting.fr.adoc
@@ -701,6 +701,7 @@ Liste des fonctions de l'API script :
| tampons |
buffer_new +
+ buffer_new_props +
current_buffer +
buffer_search +
buffer_search_main +
diff --git a/doc/it/weechat_plugin_api.it.adoc b/doc/it/weechat_plugin_api.it.adoc
index 17acdda9e..9d844fb9b 100644
--- a/doc/it/weechat_plugin_api.it.adoc
+++ b/doc/it/weechat_plugin_api.it.adoc
@@ -13108,6 +13108,13 @@ _Updated in 1.5._
Apre un nuovo buffer.
+// TRANSLATION MISSING
+[NOTE]
+If you want to immediately set buffer properties (buffer type, local variables,
+key bindings, etc.), then better use the function <<_buffer_new_props,buffer_new_props>>
+which sets these properties during the buffer creation, before sending signal
+<<hook_signal_buffer_opened,buffer_opened>>.
+
Prototipo:
[source,c]
@@ -13208,6 +13215,138 @@ def my_close_cb(data, buffer):
buffer = weechat.buffer_new("my_buffer", "my_input_cb", "", "my_close_cb", "")
----
+==== buffer_new_props
+
+_WeeChat ≥ 3.5._
+
+// TRANSLATION MISSING
+Open a new buffer and apply properties.
+
+Prototipo:
+
+[source,c]
+----
+struct t_gui_buffer *weechat_buffer_new_props (const char *name,
+ struct t_hashtable *properties,
+ int (*input_callback)(const void *pointer,
+ void *data,
+ struct t_gui_buffer *buffer,
+ const char *input_data),
+ const void *input_callback_pointer,
+ void *input_callback_data,
+ int (*close_callback)(const void *pointer,
+ void *data,
+ struct t_gui_buffer *buffer),
+ const void *close_callback_pointer,
+ void *close_callback_data);
+----
+
+Argomenti:
+
+* _name_: nome del buffer (deve essere unico per il plugin)
+// TRANSLATION MISSING
+* _properties_: properties to apply
+ (see function <<_buffer_set,buffer_set>> for the allowed properties)
+* _input_callback_: funzione chiamata quando il testo in input è stato
+ inserito nel buffer, argomenti e valore restituito:
+** _const void *pointer_: puntatore
+** _void *data_: puntatore
+** _struct t_gui_buffer *buffer_: puntatore al buffer
+** _const char *input_data_: dati in input
+** valore restituito:
+*** _WEECHAT_RC_OK_
+*** _WEECHAT_RC_ERROR_
+* _input_callback_pointer_: puntatore fornito alla callback quando chiamata da
+ WeeChat
+// TRANSLATION MISSING
+* _input_callback_data_: puntatore fornito dalla callback quando chiamata da
+ WeeChat; if not NULL, it must have been allocated with malloc (or similar
+ function) and it is automatically freed when the buffer is closed
+* _close_callback_: funzione chiamata alla chiusura del buffer, argomenti e
+ valore restituito:
+** _const void *pointer_: puntatore
+** _void *data_: puntatore
+** _struct t_gui_buffer *buffer_: puntatore al buffer
+** valore restituito:
+*** _WEECHAT_RC_OK_
+*** _WEECHAT_RC_ERROR_
+* _close_callback_pointer_: puntatore fornito alla callback quando chiamata da
+ WeeChat
+// TRANSLATION MISSING
+* _close_callback_data_: puntatore fornito dalla callback quando chiamata da
+ WeeChat; if not NULL, it must have been allocated with malloc (or similar
+ function) and it is automatically freed when the buffer is closed
+
+Valore restituito:
+
+* puntatore al nuovo buffer, NULL in caso di errore
+
+Esempio in C:
+
+// TRANSLATION MISSING
+[source,c]
+----
+int
+my_input_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer, const char *input_data)
+{
+ weechat_printf (buffer, "Testo: %s", input_data);
+ return WEECHAT_RC_OK;
+}
+
+int
+my_close_cb (const void *pointer, void *data, struct t_gui_buffer *buffer)
+{
+ weechat_printf (NULL, "Il buffer '%s' verrà chiuso!",
+ weechat_buffer_get_string (buffer, "name"));
+ return WEECHAT_RC_OK;
+}
+
+struct t_hashtable *properties = weechat_hashtable_new (8,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL,
+ NULL);
+/* buffer with free content */
+weechat_hashtable_set (properties, "type", "free");
+/* no logging on this buffer */
+weechat_hashtable_set (properties, "localvar_set_no_log", "1");
+/* bind key alt-c on this buffer */
+weechat_hashtable_set (properties, "key_bind_meta-c", "/my_command");
+
+struct t_gui_buffer *my_buffer = weechat_buffer_new_props ("my_buffer",
+ properties,
+ &my_input_cb, NULL, NULL,
+ &my_close_cb, NULL, NULL);
+----
+
+Script (Python):
+
+// TRANSLATION MISSING
+[source,python]
+----
+# prototipo
+def buffer_new_props(name: str, properties: Dict[str, str],
+ input_callback: str, input_callback_data: str,
+ close_callback: str, close_callback_data: str) -> str: ...
+
+# esempio
+def my_input_cb(data, buffer, input_data):
+ weechat.prnt(buffer, "Testo: %s" % input_data)
+ return weechat.WEECHAT_RC_OK
+
+def my_close_cb(data, buffer):
+ weechat.prnt("", "Il buffer '%s' verrà chiuso!" % weechat.buffer_get_string(buffer, "name"))
+ return weechat.WEECHAT_RC_OK
+
+properties = {
+ "type": "free", # buffer with free content
+ "localvar_set_no_log": "1", # no logging on this buffer
+ "key_bind_meta-c": "/my_command", # bind key alt-c on this buffer
+}
+buffer = weechat.buffer_new_props("my_buffer", properties, "my_input_cb", "", "my_close_cb", "")
+----
+
==== current_buffer
Restituisce il puntatore al buffer corrente (buffer visualizzato nella
diff --git a/doc/it/weechat_scripting.it.adoc b/doc/it/weechat_scripting.it.adoc
index d01c6754f..6fe2a50b4 100644
--- a/doc/it/weechat_scripting.it.adoc
+++ b/doc/it/weechat_scripting.it.adoc
@@ -714,6 +714,7 @@ Elenco di funzioni nelle API per gli script:
| buffer |
buffer_new +
+ buffer_new_props +
current_buffer +
buffer_search +
buffer_search_main +
diff --git a/doc/ja/weechat_plugin_api.ja.adoc b/doc/ja/weechat_plugin_api.ja.adoc
index 46144f537..71d4ada63 100644
--- a/doc/ja/weechat_plugin_api.ja.adoc
+++ b/doc/ja/weechat_plugin_api.ja.adoc
@@ -12638,6 +12638,13 @@ _WeeChat バージョン 1.5 で更新。_
新しいバッファを開く。
+// TRANSLATION MISSING
+[NOTE]
+If you want to immediately set buffer properties (buffer type, local variables,
+key bindings, etc.), then better use the function <<_buffer_new_props,buffer_new_props>>
+which sets these properties during the buffer creation, before sending signal
+<<hook_signal_buffer_opened,buffer_opened>>.
+
プロトタイプ:
[source,c]
@@ -12735,6 +12742,135 @@ def my_close_cb(data, buffer):
buffer = weechat.buffer_new("my_buffer", "my_input_cb", "", "my_close_cb", "")
----
+==== buffer_new_props
+
+_WeeChat ≥ 3.5_
+
+// TRANSLATION MISSING
+Open a new buffer and apply properties.
+
+プロトタイプ:
+
+[source,c]
+----
+struct t_gui_buffer *weechat_buffer_new_props (const char *name,
+ struct t_hashtable *properties,
+ int (*input_callback)(const void *pointer,
+ void *data,
+ struct t_gui_buffer *buffer,
+ const char *input_data),
+ const void *input_callback_pointer,
+ void *input_callback_data,
+ int (*close_callback)(const void *pointer,
+ void *data,
+ struct t_gui_buffer *buffer),
+ const void *close_callback_pointer,
+ void *close_callback_data);
+----
+
+引数:
+
+* _name_: バッファの名前 (プラグインに対して固有)
+// TRANSLATION MISSING
+* _properties_: properties to apply
+ (see function <<_buffer_set,buffer_set>> for the allowed properties)
+* _input_callback_:
+ 入力テキストをバッファに挿入する際に呼び出すコールバック関数、引数と戻り値:
+** _const void *pointer_: ポインタ
+** _void *data_: ポインタ
+** _struct t_gui_buffer *buffer_: バッファポインタ
+** _const char *input_data_: 入力データ
+** 戻り値:
+*** _WEECHAT_RC_OK_
+*** _WEECHAT_RC_ERROR_
+* _input_callback_pointer_: WeeChat が _input_callback_ コールバックを呼び出す際にコールバックに渡すポインタ
+* _input_callback_data_: WeeChat が _input_callback_ コールバックを呼び出す際にコールバックに渡すポインタ;
+ このポインタが NULL でない場合、このポインタは malloc (または類似の関数)
+ によって割り当てられたものでなければいけません。さらに、このポインタはここで作成したバッファが閉じられた時点で自動的に開放されます
+* _close_callback_:
+ バッファを閉じる際に呼び出すコールバック関数、引数と戻り値:
+** _const void *pointer_: ポインタ
+** _void *data_: ポインタ
+** _struct t_gui_buffer *buffer_: バッファポインタ
+** 戻り値:
+*** _WEECHAT_RC_OK_
+*** _WEECHAT_RC_ERROR_
+* _close_callback_pointer_: WeeChat が _close_callback_
+ コールバックを呼び出す際にコールバックに渡すポインタ
+* _close_callback_data_: WeeChat が _close_callback_ コールバックを呼び出す際にコールバックに渡すポインタ;
+ このポインタが NULL でない場合、このポインタは malloc (または類似の関数)
+ によって割り当てられたものでなければいけません。さらに、このポインタはここで作成したバッファが閉じられた時点で自動的に開放されます
+
+戻り値:
+
+* 新しいバッファへのポインタ、エラーが起きた場合は NULL
+
+C 言語での使用例:
+
+// TRANSLATION MISSING
+[source,c]
+----
+int
+my_input_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer, const char *input_data)
+{
+ weechat_printf (buffer, "Text: %s", input_data);
+ return WEECHAT_RC_OK;
+}
+
+int
+my_close_cb (const void *pointer, void *data, struct t_gui_buffer *buffer)
+{
+ weechat_printf (NULL, "Buffer _%s_ will be closed!",
+ weechat_buffer_get_string (buffer, "name"));
+ return WEECHAT_RC_OK;
+}
+
+struct t_hashtable *properties = weechat_hashtable_new (8,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL,
+ NULL);
+/* buffer with free content */
+weechat_hashtable_set (properties, "type", "free");
+/* no logging on this buffer */
+weechat_hashtable_set (properties, "localvar_set_no_log", "1");
+/* bind key alt-c on this buffer */
+weechat_hashtable_set (properties, "key_bind_meta-c", "/my_command");
+
+struct t_gui_buffer *my_buffer = weechat_buffer_new_props ("my_buffer",
+ properties,
+ &my_input_cb, NULL, NULL,
+ &my_close_cb, NULL, NULL);
+----
+
+スクリプト (Python) での使用例:
+
+// TRANSLATION MISSING
+[source,python]
+----
+# プロトタイプ
+def buffer_new_props(name: str, properties: Dict[str, str],
+ input_callback: str, input_callback_data: str,
+ close_callback: str, close_callback_data: str) -> str: ...
+
+# 例
+def my_input_cb(data, buffer, input_data):
+ weechat.prnt(buffer, "Text: %s" % input_data)
+ return weechat.WEECHAT_RC_OK
+
+def my_close_cb(data, buffer):
+ weechat.prnt("", "Buffer _%s_ will be closed!" % weechat.buffer_get_string(buffer, "name"))
+ return weechat.WEECHAT_RC_OK
+
+properties = {
+ "type": "free", # buffer with free content
+ "localvar_set_no_log": "1", # no logging on this buffer
+ "key_bind_meta-c": "/my_command", # bind key alt-c on this buffer
+}
+buffer = weechat.buffer_new_props("my_buffer", properties, "my_input_cb", "", "my_close_cb", "")
+----
+
==== current_buffer
現在のバッファへのポインタを返す (現在のウィンドウに表示されているバッファ)。
diff --git a/doc/ja/weechat_scripting.ja.adoc b/doc/ja/weechat_scripting.ja.adoc
index de2c7fa01..3226c5ea2 100644
--- a/doc/ja/weechat_scripting.ja.adoc
+++ b/doc/ja/weechat_scripting.ja.adoc
@@ -703,6 +703,7 @@ link:weechat_plugin_api.ja.html[WeeChat プラグイン API リファレンス]
| バッファ |
buffer_new +
+ buffer_new_props +
current_buffer +
buffer_search +
buffer_search_main +
diff --git a/doc/pl/weechat_scripting.pl.adoc b/doc/pl/weechat_scripting.pl.adoc
index 549810c75..3b5ca8efb 100644
--- a/doc/pl/weechat_scripting.pl.adoc
+++ b/doc/pl/weechat_scripting.pl.adoc
@@ -687,6 +687,7 @@ Lista funkcji w API skryptów:
| bufory |
buffer_new +
+ buffer_new_props +
current_buffer +
buffer_search +
buffer_search_main +
diff --git a/doc/sr/weechat_plugin_api.sr.adoc b/doc/sr/weechat_plugin_api.sr.adoc
index 467aec068..7367fb7ea 100644
--- a/doc/sr/weechat_plugin_api.sr.adoc
+++ b/doc/sr/weechat_plugin_api.sr.adoc
@@ -12124,6 +12124,13 @@ _Ажурирано у верзији 1.5._
Отвара нови бафер.
+// TRANSLATION MISSING
+[NOTE]
+If you want to immediately set buffer properties (buffer type, local variables,
+key bindings, etc.), then better use the function <<_buffer_new_props,buffer_new_props>>
+which sets these properties during the buffer creation, before sending signal
+<<hook_signal_buffer_opened,buffer_opened>>.
+
Прототип:
[source,c]
@@ -12214,6 +12221,128 @@ def my_close_cb(data, buffer):
buffer = weechat.buffer_new("my_buffer", "my_input_cb", "", "my_close_cb", "")
----
+==== buffer_new_props
+
+_WeeChat ≥ 3.5._
+
+// TRANSLATION MISSING
+Open a new buffer and apply properties.
+
+Прототип:
+
+[source,c]
+----
+struct t_gui_buffer *weechat_buffer_new_props (const char *name,
+ struct t_hashtable *properties,
+ int (*input_callback)(const void *pointer,
+ void *data,
+ struct t_gui_buffer *buffer,
+ const char *input_data),
+ const void *input_callback_pointer,
+ void *input_callback_data,
+ int (*close_callback)(const void *pointer,
+ void *data,
+ struct t_gui_buffer *buffer),
+ const void *close_callback_pointer,
+ void *close_callback_data);
+----
+
+Аргументи:
+
+* _name_: име бафера (мора бити јединствено за додатак)
+// TRANSLATION MISSING
+* _properties_: properties to apply
+ (see function <<_buffer_set,buffer_set>> for the allowed properties)
+* _input_callback_: функција која се позива када се унесе текст уноса за бафер, аргументи и повратна вредност су:
+** _const void *pointer_: показивач
+** _void *data_: показивач
+** _struct t_gui_buffer *buffer_: показивач на бафер
+** _const char *input_data_: подаци уноса
+** повратна вредност:
+*** _WEECHAT_RC_OK_
+*** _WEECHAT_RC_ERROR_
+* _input_callback_pointer_: показивач који се прослеђује функцији повратног позива када је позове програм WeeChat
+* _input_callback_data_: показивач који се прослеђује функцији повратног позива када је позове програм WeeChat; ако није NULL, алоцирала га је malloc (или нека слична функција) и аутоматски се ослобађа када се бафер затвори
+* _close_callback_: функција која се позива када се затвори бафер, аргументи и повратна вредност су:
+** _const void *pointer_: показивач
+** _void *data_: показивач
+** _struct t_gui_buffer *buffer_: показивач на бафер
+** повратна вредност:
+*** _WEECHAT_RC_OK_
+*** _WEECHAT_RC_ERROR_
+* _close_callback_pointer_: показивач који се прослеђује функцији повратног позива када је позове програм WeeChat
+* _close_callback_data_: показивач који се прослеђује функцији повратног позива када је позове програм WeeChat; ако није NULL, алоцирала га је malloc (или нека слична функција) и аутоматски се ослобађа када се затвори бафер
+
+Повратна вредност:
+
+* показивач на нови бафер, NULL у случају грешке
+
+C пример:
+
+// TRANSLATION MISSING
+[source,c]
+----
+int
+my_input_cb (const void *pointer, void *data,
+ struct t_gui_buffer *buffer, const char *input_data)
+{
+ weechat_printf (buffer, "Текст: %s", input_data);
+ return WEECHAT_RC_OK;
+}
+
+int
+my_close_cb (const void *pointer, void *data, struct t_gui_buffer *buffer)
+{
+ weechat_printf (NULL, "Затвориће се бафер ’%s’!",
+ weechat_buffer_get_string (buffer, "name"));
+ return WEECHAT_RC_OK;
+}
+
+struct t_hashtable *properties = weechat_hashtable_new (8,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL,
+ NULL);
+/* buffer with free content */
+weechat_hashtable_set (properties, "type", "free");
+/* no logging on this buffer */
+weechat_hashtable_set (properties, "localvar_set_no_log", "1");
+/* bind key alt-c on this buffer */
+weechat_hashtable_set (properties, "key_bind_meta-c", "/my_command");
+
+struct t_gui_buffer *my_buffer = weechat_buffer_new_props ("my_buffer",
+ properties,
+ &my_input_cb, NULL, NULL,
+ &my_close_cb, NULL, NULL);
+----
+
+Скрипта (Python):
+
+// TRANSLATION MISSING
+[source,python]
+----
+# прототип
+def buffer_new_props(name: str, properties: Dict[str, str],
+ input_callback: str, input_callback_data: str,
+ close_callback: str, close_callback_data: str) -> str: ...
+
+# пример
+def my_input_cb(data, buffer, input_data):
+ weechat.prnt(buffer, "Текст: %s" % input_data)
+ return weechat.WEECHAT_RC_OK
+
+def my_close_cb(data, buffer):
+ weechat.prnt("", "Затвориће се бафер ’%s’!" % weechat.buffer_get_string(buffer, "name"))
+ return weechat.WEECHAT_RC_OK
+
+properties = {
+ "type": "free", # buffer with free content
+ "localvar_set_no_log": "1", # no logging on this buffer
+ "key_bind_meta-c": "/my_command", # bind key alt-c on this buffer
+}
+buffer = weechat.buffer_new_props("my_buffer", properties, "my_input_cb", "", "my_close_cb", "")
+----
+
==== current_buffer
Враћа показивач на текући бафер (бафер који се приказује у текућем прозору).
diff --git a/doc/sr/weechat_scripting.sr.adoc b/doc/sr/weechat_scripting.sr.adoc
index 782117d4b..c0c96fbee 100644
--- a/doc/sr/weechat_scripting.sr.adoc
+++ b/doc/sr/weechat_scripting.sr.adoc
@@ -640,6 +640,7 @@ weechat_hook_timer(1000, 0, 1, $timer_cb, 'test');
| бафери |
buffer_new +
+ buffer_new_props +
current_buffer +
buffer_search +
buffer_search_main +
diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c
index 85f8561a3..fc176f60f 100644
--- a/src/plugins/guile/weechat-guile-api.c
+++ b/src/plugins/guile/weechat-guile-api.c
@@ -3347,6 +3347,45 @@ weechat_guile_api_buffer_new (SCM name, SCM function_input, SCM data_input,
}
SCM
+weechat_guile_api_buffer_new_props (SCM name, SCM properties,
+ SCM function_input, SCM data_input,
+ SCM function_close, SCM data_close)
+{
+ struct t_hashtable *c_properties;
+ const char *result;
+ SCM return_value;
+
+ API_INIT_FUNC(1, "buffer_new_props", API_RETURN_EMPTY);
+ if (!scm_is_string (name) || !scm_list_p (properties)
+ || !scm_is_string (function_input) || !scm_is_string (data_input)
+ || !scm_is_string (function_close) || !scm_is_string (data_close))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ c_properties = weechat_guile_alist_to_hashtable (properties,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+
+ result = API_PTR2STR(
+ plugin_script_api_buffer_new_props (
+ weechat_guile_plugin,
+ guile_current_script,
+ API_SCM_TO_STRING(name),
+ c_properties,
+ &weechat_guile_api_buffer_input_data_cb,
+ API_SCM_TO_STRING(function_input),
+ API_SCM_TO_STRING(data_input),
+ &weechat_guile_api_buffer_close_cb,
+ API_SCM_TO_STRING(function_close),
+ API_SCM_TO_STRING(data_close)));
+
+ if (c_properties)
+ weechat_hashtable_free (c_properties);
+
+ API_RETURN_STRING(result);
+}
+
+SCM
weechat_guile_api_buffer_search (SCM plugin, SCM name)
{
const char *result;
@@ -5175,6 +5214,7 @@ weechat_guile_api_module_init (void *data)
API_DEF_FUNC(unhook, 1);
API_DEF_FUNC(unhook_all, 0);
API_DEF_FUNC(buffer_new, 5);
+ API_DEF_FUNC(buffer_new_props, 6);
API_DEF_FUNC(buffer_search, 2);
API_DEF_FUNC(buffer_search_main, 0);
API_DEF_FUNC(current_buffer, 0);
diff --git a/src/plugins/javascript/weechat-js-api.cpp b/src/plugins/javascript/weechat-js-api.cpp
index caf992c5f..93e6a2c2c 100644
--- a/src/plugins/javascript/weechat-js-api.cpp
+++ b/src/plugins/javascript/weechat-js-api.cpp
@@ -3270,6 +3270,43 @@ API_FUNC(buffer_new)
API_RETURN_STRING(result);
}
+API_FUNC(buffer_new_props)
+{
+ struct t_hashtable *properties;
+ const char *result;
+
+ API_INIT_FUNC(1, "buffer_new_props", "shssss", API_RETURN_EMPTY);
+
+ v8::String::Utf8Value name(args[0]);
+ properties = weechat_js_object_to_hashtable (
+ args[1]->ToObject(),
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+ v8::String::Utf8Value function_input(args[2]);
+ v8::String::Utf8Value data_input(args[3]);
+ v8::String::Utf8Value function_close(args[4]);
+ v8::String::Utf8Value data_close(args[5]);
+
+ result = API_PTR2STR(
+ plugin_script_api_buffer_new_props (
+ weechat_js_plugin,
+ js_current_script,
+ *name,
+ properties,
+ &weechat_js_api_buffer_input_data_cb,
+ *function_input,
+ *data_input,
+ &weechat_js_api_buffer_close_cb,
+ *function_close,
+ *data_close));
+
+ if (properties)
+ weechat_hashtable_free (properties);
+
+ API_RETURN_STRING(result);
+}
+
API_FUNC(buffer_search)
{
const char *result;
@@ -5117,6 +5154,7 @@ WeechatJsV8::loadLibs()
API_DEF_FUNC(unhook);
API_DEF_FUNC(unhook_all);
API_DEF_FUNC(buffer_new);
+ API_DEF_FUNC(buffer_new_props);
API_DEF_FUNC(buffer_search);
API_DEF_FUNC(buffer_search_main);
API_DEF_FUNC(current_buffer);
diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c
index ee26fbe10..f03c99ffe 100644
--- a/src/plugins/lua/weechat-lua-api.c
+++ b/src/plugins/lua/weechat-lua-api.c
@@ -3505,6 +3505,46 @@ API_FUNC(buffer_new)
API_RETURN_STRING(result);
}
+API_FUNC(buffer_new_props)
+{
+ const char *name, *function_input, *data_input, *function_close;
+ const char *data_close;
+ struct t_hashtable *properties;
+ const char *result;
+
+ API_INIT_FUNC(1, "buffer_new_props", API_RETURN_EMPTY);
+ if (lua_gettop (L) < 6)
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ name = lua_tostring (L, -6);
+ properties = weechat_lua_tohashtable (L, -5,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+ function_input = lua_tostring (L, -4);
+ data_input = lua_tostring (L, -3);
+ function_close = lua_tostring (L, -2);
+ data_close = lua_tostring (L, -1);
+
+ result = API_PTR2STR(
+ plugin_script_api_buffer_new_props (
+ weechat_lua_plugin,
+ lua_current_script,
+ name,
+ properties,
+ &weechat_lua_api_buffer_input_data_cb,
+ function_input,
+ data_input,
+ &weechat_lua_api_buffer_close_cb,
+ function_close,
+ data_close));
+
+ if (properties)
+ weechat_hashtable_free (properties);
+
+ API_RETURN_STRING(result);
+}
+
API_FUNC(buffer_search)
{
const char *plugin, *name;
@@ -5470,6 +5510,7 @@ const struct luaL_Reg weechat_lua_api_funcs[] = {
API_DEF_FUNC(unhook),
API_DEF_FUNC(unhook_all),
API_DEF_FUNC(buffer_new),
+ API_DEF_FUNC(buffer_new_props),
API_DEF_FUNC(buffer_search),
API_DEF_FUNC(buffer_search_main),
API_DEF_FUNC(current_buffer),
diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c
index 27438b3ee..791c276ce 100644
--- a/src/plugins/perl/weechat-perl-api.c
+++ b/src/plugins/perl/weechat-perl-api.c
@@ -3412,6 +3412,46 @@ API_FUNC(buffer_new)
API_RETURN_STRING(result);
}
+API_FUNC(buffer_new_props)
+{
+ char *name, *function_input, *data_input, *function_close, *data_close;
+ struct t_hashtable *properties;
+ const char *result;
+ dXSARGS;
+
+ API_INIT_FUNC(1, "buffer_new_props", API_RETURN_EMPTY);
+ if (items < 6)
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ name = SvPV_nolen (ST (0));
+ properties = weechat_perl_hash_to_hashtable (ST (1),
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+ function_input = SvPV_nolen (ST (2));
+ data_input = SvPV_nolen (ST (3));
+ function_close = SvPV_nolen (ST (4));
+ data_close = SvPV_nolen (ST (5));
+
+ result = API_PTR2STR(
+ plugin_script_api_buffer_new_props (
+ weechat_perl_plugin,
+ perl_current_script,
+ name,
+ properties,
+ &weechat_perl_api_buffer_input_data_cb,
+ function_input,
+ data_input,
+ &weechat_perl_api_buffer_close_cb,
+ function_close,
+ data_close));
+
+ if (properties)
+ weechat_hashtable_free (properties);
+
+ API_RETURN_STRING(result);
+}
+
API_FUNC(buffer_search)
{
char *plugin, *name;
@@ -5423,6 +5463,7 @@ weechat_perl_api_init (pTHX)
API_DEF_FUNC(unhook);
API_DEF_FUNC(unhook_all);
API_DEF_FUNC(buffer_new);
+ API_DEF_FUNC(buffer_new_props);
API_DEF_FUNC(buffer_search);
API_DEF_FUNC(buffer_search_main);
API_DEF_FUNC(current_buffer);
diff --git a/src/plugins/php/weechat-php-api.c b/src/plugins/php/weechat-php-api.c
index b92580b38..f365bfa1e 100644
--- a/src/plugins/php/weechat-php-api.c
+++ b/src/plugins/php/weechat-php-api.c
@@ -3332,6 +3332,50 @@ API_FUNC(buffer_new)
API_RETURN_STRING(result);
}
+API_FUNC(buffer_new_props)
+{
+ zend_string *z_name, *z_data_input, *z_data_close;
+ zval *z_properties, *z_input_callback, *z_close_callback;
+ char *name, *data_input, *data_close;
+ struct t_hashtable *properties;
+ const char *result;
+
+ API_INIT_FUNC(1, "buffer_new_props", API_RETURN_EMPTY);
+ if (zend_parse_parameters (ZEND_NUM_ARGS(), "SazSzS", &z_name,
+ &z_properties, &z_input_callback, &z_data_input,
+ &z_close_callback, &z_data_close) == FAILURE)
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ name = ZSTR_VAL(z_name);
+ properties = weechat_php_array_to_hashtable (
+ z_properties,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+ weechat_php_get_function_name (z_input_callback, input_callback_name);
+ data_input = ZSTR_VAL(z_data_input);
+ weechat_php_get_function_name (z_close_callback, close_callback_name);
+ data_close = ZSTR_VAL(z_data_close);
+
+ result = API_PTR2STR(
+ plugin_script_api_buffer_new_props (
+ weechat_php_plugin,
+ php_current_script,
+ (const char *)name,
+ properties,
+ &weechat_php_api_buffer_input_data_cb,
+ (const char *)input_callback_name,
+ (const char *)data_input,
+ &weechat_php_api_buffer_close_cb,
+ (const char *)close_callback_name,
+ (const char *)data_close));
+
+ if (properties)
+ weechat_hashtable_free (properties);
+
+ API_RETURN_STRING(result);
+}
+
API_FUNC(buffer_search)
{
zend_string *z_plugin, *z_name;
diff --git a/src/plugins/php/weechat-php-api.h b/src/plugins/php/weechat-php-api.h
index 283e4baed..563e09c1a 100644
--- a/src/plugins/php/weechat-php-api.h
+++ b/src/plugins/php/weechat-php-api.h
@@ -155,6 +155,7 @@ PHP_FUNCTION(weechat_hook_set);
PHP_FUNCTION(weechat_unhook);
PHP_FUNCTION(weechat_unhook_all);
PHP_FUNCTION(weechat_buffer_new);
+PHP_FUNCTION(weechat_buffer_new_props);
PHP_FUNCTION(weechat_buffer_search);
PHP_FUNCTION(weechat_buffer_search_main);
PHP_FUNCTION(weechat_current_buffer);
diff --git a/src/plugins/php/weechat-php.c b/src/plugins/php/weechat-php.c
index 89ebdd7e9..115d821ff 100644
--- a/src/plugins/php/weechat-php.c
+++ b/src/plugins/php/weechat-php.c
@@ -213,6 +213,7 @@ const zend_function_entry weechat_functions[] = {
PHP_FE(weechat_unhook, arginfo_weechat_unhook)
PHP_FE(weechat_unhook_all, arginfo_weechat_unhook_all)
PHP_FE(weechat_buffer_new, arginfo_weechat_buffer_new)
+ PHP_FE(weechat_buffer_new_props, arginfo_weechat_buffer_new_props)
PHP_FE(weechat_buffer_search, arginfo_weechat_buffer_search)
PHP_FE(weechat_buffer_search_main, arginfo_weechat_buffer_search_main)
PHP_FE(weechat_current_buffer, arginfo_weechat_current_buffer)
diff --git a/src/plugins/php/weechat-php.stub.php b/src/plugins/php/weechat-php.stub.php
index b5488d14f..ba3a365fb 100644
--- a/src/plugins/php/weechat-php.stub.php
+++ b/src/plugins/php/weechat-php.stub.php
@@ -116,6 +116,7 @@ function weechat_hook_set(): mixed {}
function weechat_unhook(): mixed {}
function weechat_unhook_all(): mixed {}
function weechat_buffer_new(): mixed {}
+function weechat_buffer_new_props(): mixed {}
function weechat_buffer_search(): mixed {}
function weechat_buffer_search_main(): mixed {}
function weechat_current_buffer(): mixed {}
diff --git a/src/plugins/php/weechat-php_arginfo.h b/src/plugins/php/weechat-php_arginfo.h
index 8067b169b..b963c6e08 100644
--- a/src/plugins/php/weechat-php_arginfo.h
+++ b/src/plugins/php/weechat-php_arginfo.h
@@ -222,6 +222,8 @@ ZEND_END_ARG_INFO()
#define arginfo_weechat_buffer_new arginfo_weechat_register
+#define arginfo_weechat_buffer_new_props arginfo_weechat_register
+
#define arginfo_weechat_buffer_search arginfo_weechat_register
#define arginfo_weechat_buffer_search_main arginfo_weechat_register
diff --git a/src/plugins/php/weechat-php_legacy_arginfo.h b/src/plugins/php/weechat-php_legacy_arginfo.h
index c96907041..846fbeee5 100644
--- a/src/plugins/php/weechat-php_legacy_arginfo.h
+++ b/src/plugins/php/weechat-php_legacy_arginfo.h
@@ -222,6 +222,8 @@ ZEND_END_ARG_INFO()
#define arginfo_weechat_buffer_new arginfo_weechat_register
+#define arginfo_weechat_buffer_new_props arginfo_weechat_register
+
#define arginfo_weechat_buffer_search arginfo_weechat_register
#define arginfo_weechat_buffer_search_main arginfo_weechat_register
diff --git a/src/plugins/plugin-script-api.c b/src/plugins/plugin-script-api.c
index 157d0b181..9ae37e4a0 100644
--- a/src/plugins/plugin-script-api.c
+++ b/src/plugins/plugin-script-api.c
@@ -1192,24 +1192,25 @@ plugin_script_api_hook_focus (struct t_weechat_plugin *weechat_plugin,
}
/*
- * Creates a new buffer.
+ * Creates a new buffer with optional properties.
*/
struct t_gui_buffer *
-plugin_script_api_buffer_new (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script *script,
- const char *name,
- int (*input_callback)(const void *pointer,
- void *data,
- struct t_gui_buffer *buffer,
- const char *input_data),
- const char *function_input,
- const char *data_input,
- int (*close_callback)(const void *pointer,
- void *data,
- struct t_gui_buffer *buffer),
- const char *function_close,
- const char *data_close)
+plugin_script_api_buffer_new_props (struct t_weechat_plugin *weechat_plugin,
+ struct t_plugin_script *script,
+ const char *name,
+ struct t_hashtable *properties,
+ int (*input_callback)(const void *pointer,
+ void *data,
+ struct t_gui_buffer *buffer,
+ const char *input_data),
+ const char *function_input,
+ const char *data_input,
+ int (*close_callback)(const void *pointer,
+ void *data,
+ struct t_gui_buffer *buffer),
+ const char *function_close,
+ const char *data_close)
{
char *function_and_data_input, *function_and_data_close;
struct t_gui_buffer *new_buffer;
@@ -1222,8 +1223,9 @@ plugin_script_api_buffer_new (struct t_weechat_plugin *weechat_plugin,
function_and_data_close = plugin_script_build_function_and_data (
function_close, data_close);
- new_buffer = weechat_buffer_new (
+ new_buffer = weechat_buffer_new_props (
name,
+ properties,
(function_and_data_input) ? input_callback : NULL,
script,
function_and_data_input,
@@ -1257,6 +1259,39 @@ plugin_script_api_buffer_new (struct t_weechat_plugin *weechat_plugin,
}
/*
+ * Creates a new buffer.
+ */
+
+struct t_gui_buffer *
+plugin_script_api_buffer_new (struct t_weechat_plugin *weechat_plugin,
+ struct t_plugin_script *script,
+ const char *name,
+ int (*input_callback)(const void *pointer,
+ void *data,
+ struct t_gui_buffer *buffer,
+ const char *input_data),
+ const char *function_input,
+ const char *data_input,
+ int (*close_callback)(const void *pointer,
+ void *data,
+ struct t_gui_buffer *buffer),
+ const char *function_close,
+ const char *data_close)
+{
+ return plugin_script_api_buffer_new_props (
+ weechat_plugin,
+ script,
+ name,
+ NULL, /* properties */
+ input_callback,
+ function_input,
+ data_input,
+ close_callback,
+ function_close,
+ data_close);
+}
+
+/*
* Adds a new bar item.
*
* Returns pointer to new bar item, NULL if error.
diff --git a/src/plugins/plugin-script-api.h b/src/plugins/plugin-script-api.h
index 0c01db775..b7a369dea 100644
--- a/src/plugins/plugin-script-api.h
+++ b/src/plugins/plugin-script-api.h
@@ -334,6 +334,21 @@ extern struct t_hook *plugin_script_api_hook_focus (struct t_weechat_plugin *wee
struct t_hashtable *info),
const char *function,
const char *data);
+extern struct t_gui_buffer *plugin_script_api_buffer_new_props (struct t_weechat_plugin *weechat_plugin,
+ struct t_plugin_script *script,
+ const char *name,
+ struct t_hashtable *properties,
+ int (*input_callback)(const void *pointer,
+ void *data,
+ struct t_gui_buffer *buffer,
+ const char *input_data),
+ const char *function_input,
+ const char *data_input,
+ int (*close_callback)(const void *pointer,
+ void *data,
+ struct t_gui_buffer *buffer),
+ const char *function_close,
+ const char *data_close);
extern struct t_gui_buffer *plugin_script_api_buffer_new (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *name,
diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c
index e1c4cde0b..1e326f3c5 100644
--- a/src/plugins/plugin.c
+++ b/src/plugins/plugin.c
@@ -804,6 +804,7 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv)
new_plugin->unhook_all = &unhook_all_plugin;
new_plugin->buffer_new = &gui_buffer_new;
+ new_plugin->buffer_new_props = &gui_buffer_new_props;
new_plugin->buffer_search = &gui_buffer_search_by_name;
new_plugin->buffer_search_main = &gui_buffer_search_main;
new_plugin->buffer_clear = &gui_buffer_clear;
diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c
index 6398e7d2e..90ffdaa47 100644
--- a/src/plugins/python/weechat-python-api.c
+++ b/src/plugins/python/weechat-python-api.c
@@ -3413,6 +3413,48 @@ API_FUNC(buffer_new)
API_RETURN_STRING(result);
}
+API_FUNC(buffer_new_props)
+{
+ char *name, *function_input, *data_input, *function_close, *data_close;
+ struct t_hashtable *properties;
+ PyObject *dict;
+ const char *result;
+
+ API_INIT_FUNC(1, "buffer_new_props", API_RETURN_EMPTY);
+ name = NULL;
+ dict = NULL;
+ function_input = NULL;
+ data_input = NULL;
+ function_close = NULL;
+ data_close = NULL;
+ if (!PyArg_ParseTuple (args, "sOssss", &name, &dict,
+ &function_input, &data_input,
+ &function_close, &data_close))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ properties = weechat_python_dict_to_hashtable (dict,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+ result = API_PTR2STR(
+ plugin_script_api_buffer_new_props (
+ weechat_python_plugin,
+ python_current_script,
+ name,
+ properties,
+ &weechat_python_api_buffer_input_data_cb,
+ function_input,
+ data_input,
+ &weechat_python_api_buffer_close_cb,
+ function_close,
+ data_close));
+
+ if (properties)
+ weechat_hashtable_free (properties);
+
+ API_RETURN_STRING(result);
+}
+
API_FUNC(buffer_search)
{
char *plugin, *name;
@@ -5333,6 +5375,7 @@ PyMethodDef weechat_python_funcs[] =
API_DEF_FUNC(unhook),
API_DEF_FUNC(unhook_all),
API_DEF_FUNC(buffer_new),
+ API_DEF_FUNC(buffer_new_props),
API_DEF_FUNC(buffer_search),
API_DEF_FUNC(buffer_search_main),
API_DEF_FUNC(current_buffer),
diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c
index d1883f49f..b55c13321 100644
--- a/src/plugins/ruby/weechat-ruby-api.c
+++ b/src/plugins/ruby/weechat-ruby-api.c
@@ -4102,6 +4102,58 @@ weechat_ruby_api_buffer_new (VALUE class, VALUE name, VALUE function_input,
}
static VALUE
+weechat_ruby_api_buffer_new_props (VALUE class, VALUE name, VALUE properties,
+ VALUE function_input,
+ VALUE data_input, VALUE function_close,
+ VALUE data_close)
+{
+ char *c_name, *c_function_input, *c_data_input, *c_function_close;
+ char *c_data_close;
+ struct t_hashtable *c_properties;
+ const char *result;
+
+ API_INIT_FUNC(1, "buffer_new_props", API_RETURN_EMPTY);
+ if (NIL_P (name) || NIL_P (properties) || NIL_P (function_input)
+ || NIL_P (data_input) || NIL_P (function_close) || NIL_P (data_close))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ Check_Type (name, T_STRING);
+ Check_Type (properties, T_HASH);
+ Check_Type (function_input, T_STRING);
+ Check_Type (data_input, T_STRING);
+ Check_Type (function_close, T_STRING);
+ Check_Type (data_close, T_STRING);
+
+ c_name = StringValuePtr (name);
+ c_properties = weechat_ruby_hash_to_hashtable (properties,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+ c_function_input = StringValuePtr (function_input);
+ c_data_input = StringValuePtr (data_input);
+ c_function_close = StringValuePtr (function_close);
+ c_data_close = StringValuePtr (data_close);
+
+ result = API_PTR2STR(
+ plugin_script_api_buffer_new_props (
+ weechat_ruby_plugin,
+ ruby_current_script,
+ c_name,
+ c_properties,
+ &weechat_ruby_api_buffer_input_data_cb,
+ c_function_input,
+ c_data_input,
+ &weechat_ruby_api_buffer_close_cb,
+ c_function_close,
+ c_data_close));
+
+ if (c_properties)
+ weechat_hashtable_free (c_properties);
+
+ API_RETURN_STRING(result);
+}
+
+static VALUE
weechat_ruby_api_buffer_search (VALUE class, VALUE plugin, VALUE name)
{
char *c_plugin, *c_name;
@@ -6606,6 +6658,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
API_DEF_FUNC(unhook, 1);
API_DEF_FUNC(unhook_all, 0);
API_DEF_FUNC(buffer_new, 5);
+ API_DEF_FUNC(buffer_new_props, 6);
API_DEF_FUNC(buffer_search, 2);
API_DEF_FUNC(buffer_search_main, 0);
API_DEF_FUNC(current_buffer, 0);
diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c
index a82aa4725..6d8fe6c0a 100644
--- a/src/plugins/tcl/weechat-tcl-api.c
+++ b/src/plugins/tcl/weechat-tcl-api.c
@@ -3738,6 +3738,47 @@ API_FUNC(buffer_new)
API_RETURN_STRING(result);
}
+API_FUNC(buffer_new_props)
+{
+ Tcl_Obj *objp;
+ char *name, *function_input, *data_input, *function_close, *data_close;
+ struct t_hashtable *properties;
+ const char *result;
+ int i;
+
+ API_INIT_FUNC(1, "buffer_new_props", API_RETURN_EMPTY);
+ if (objc < 7)
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ name = Tcl_GetStringFromObj (objv[1], &i);
+ properties = weechat_tcl_dict_to_hashtable (interp, objv[2],
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING);
+ function_input = Tcl_GetStringFromObj (objv[3], &i);
+ data_input = Tcl_GetStringFromObj (objv[4], &i);
+ function_close = Tcl_GetStringFromObj (objv[5], &i);
+ data_close = Tcl_GetStringFromObj (objv[6], &i);
+
+ result = API_PTR2STR(
+ plugin_script_api_buffer_new_props (
+ weechat_tcl_plugin,
+ tcl_current_script,
+ name,
+ properties,
+ &weechat_tcl_api_buffer_input_data_cb,
+ function_input,
+ data_input,
+ &weechat_tcl_api_buffer_close_cb,
+ function_close,
+ data_close));
+
+ if (properties)
+ weechat_hashtable_free (properties);
+
+ API_RETURN_STRING(result);
+}
+
API_FUNC(buffer_search)
{
Tcl_Obj *objp;
@@ -5918,6 +5959,7 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
API_DEF_FUNC(unhook);
API_DEF_FUNC(unhook_all);
API_DEF_FUNC(buffer_new);
+ API_DEF_FUNC(buffer_new_props);
API_DEF_FUNC(buffer_search);
API_DEF_FUNC(buffer_search_main);
API_DEF_FUNC(current_buffer);
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index c45ad250a..ff892c737 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -68,7 +68,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 "20220130-01"
+#define WEECHAT_PLUGIN_API_VERSION "20220312-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -893,6 +893,20 @@ struct t_weechat_plugin
struct t_gui_buffer *buffer),
const void *close_callback_pointer,
void *close_callback_data);
+ struct t_gui_buffer *(*buffer_new_props) (struct t_weechat_plugin *plugin,
+ const char *name,
+ struct t_hashtable *properties,
+ int (*input_callback)(const void *pointer,
+ void *data,
+ struct t_gui_buffer *buffer,
+ const char *input_data),
+ const void *input_callback_pointer,
+ void *input_callback_data,
+ int (*close_callback)(const void *pointer,
+ void *data,
+ struct t_gui_buffer *buffer),
+ const void *close_callback_pointer,
+ void *close_callback_data);
struct t_gui_buffer *(*buffer_search) (const char *plugin, const char *name);
struct t_gui_buffer *(*buffer_search_main) ();
void (*buffer_clear) (struct t_gui_buffer *buffer);
@@ -1835,19 +1849,38 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
(weechat_plugin->unhook_all)(weechat_plugin, __subplugin)
/* buffers */
-#define weechat_buffer_new(__name, __input_callback, \
+#define weechat_buffer_new(__name, \
+ __input_callback, \
__input_callback_pointer, \
__input_callback_data, \
__close_callback, \
__close_callback_pointer, \
__close_callback_data) \
- (weechat_plugin->buffer_new)(weechat_plugin, __name, \
+ (weechat_plugin->buffer_new)(weechat_plugin, \
+ __name, \
__input_callback, \
__input_callback_pointer, \
__input_callback_data, \
__close_callback, \
__close_callback_pointer, \
__close_callback_data)
+#define weechat_buffer_new_props(__name, \
+ __properties, \
+ __input_callback, \
+ __input_callback_pointer, \
+ __input_callback_data, \
+ __close_callback, \
+ __close_callback_pointer, \
+ __close_callback_data) \
+ (weechat_plugin->buffer_new_props)(weechat_plugin, \
+ __name, \
+ __properties, \
+ __input_callback, \
+ __input_callback_pointer, \
+ __input_callback_data, \
+ __close_callback, \
+ __close_callback_pointer, \
+ __close_callback_data)
#define weechat_buffer_search(__plugin, __name) \
(weechat_plugin->buffer_search)(__plugin, __name)
#define weechat_buffer_search_main() \