mirror of
https://github.com/weechat/weechat.git
synced 2026-06-12 14:14:48 +02:00
api: add support of priority in function hook_line (closes #1821)
This commit is contained in:
@@ -25,6 +25,7 @@ New features::
|
||||
* api: rename function string_build_with_split_string to string_rebuild_split_string, add arguments "index_start" and "index_end"
|
||||
* api: add info "uptime_current"
|
||||
* api: add function crypto_hash_file
|
||||
* api: add support of priority in function hook_line (issue #1821)
|
||||
* buflist: add variable `${hotlist_priority_number}` (integer version of `${hotlist_priority}`)
|
||||
* irc: display SETNAME command in channels and private buffers, add options irc.color.message_setname and irc.look.smart_filter_setname (issue #1805)
|
||||
* irc: add option irc.look.display_pv_nick_change
|
||||
|
||||
@@ -8808,10 +8808,16 @@ C examples:
|
||||
[source,c]
|
||||
----
|
||||
/* hook modifier with priority = 2000 */
|
||||
/* high priority: called before other modifier calbacks */
|
||||
weechat_hook_modifier ("2000|input_text_display", &modifier_cb, NULL, NULL);
|
||||
|
||||
/* hook two signals with priority = 3000 */
|
||||
/* high priority: called before other signal callbacks */
|
||||
weechat_hook_signal ("3000|quit;upgrade", &signal_cb, NULL, NULL);
|
||||
|
||||
/* hook lines printed in formatted buffers with priority = 500 */
|
||||
/* low priority: called after other line callbacks */
|
||||
weechat_hook_line ("500|formatted", "*", NULL, &line_cb, NULL, NULL);
|
||||
----
|
||||
|
||||
Following hook types allow priority:
|
||||
@@ -8819,6 +8825,7 @@ Following hook types allow priority:
|
||||
* <<_hook_command,command>>
|
||||
* <<_hook_completion,completion>>
|
||||
* <<_hook_command_run,command_run>>
|
||||
* <<_hook_line,line>>
|
||||
* <<_hook_signal,signal>>
|
||||
* <<_hook_hsignal,hsignal>>
|
||||
* <<_hook_config,config>>
|
||||
@@ -9967,7 +9974,7 @@ hook = weechat.hook_connect("", "my.server.org", 1234, 1, 0, "",
|
||||
|
||||
==== hook_line
|
||||
|
||||
_WeeChat ≥ 2.3._
|
||||
_WeeChat ≥ 2.3, updated in 3.7._
|
||||
|
||||
Hook a line to be printed in a buffer.
|
||||
|
||||
@@ -10001,7 +10008,8 @@ struct t_hook *weechat_hook_line (const char *buffer_type,
|
||||
Arguments:
|
||||
|
||||
* _buffer_type_: catch lines on the given buffer type (if NULL or empty string,
|
||||
_formatted_ is the default):
|
||||
_formatted_ is the default)
|
||||
(a priority is allowed before the buffer type, see note about <<hook_priority,priority>>):
|
||||
** _formatted_: catch lines on formatted buffers only (default)
|
||||
** _free_: catch lines on buffers with free content only
|
||||
** _*_: catch lines on all buffer types
|
||||
|
||||
@@ -8949,10 +8949,16 @@ Exemples en C :
|
||||
[source,c]
|
||||
----
|
||||
/* accrocher un modificateur avec priorité = 2000 */
|
||||
/* haute priorité : appelé avant les autres fonctions de rappel "modifier" */
|
||||
weechat_hook_modifier ("2000|input_text_display", &modifier_cb, NULL, NULL);
|
||||
|
||||
/* accrocher deux signaux avec priorité = 3000 */
|
||||
/* haute priorité : appelé avant les autres fonctions de rappel "signal" */
|
||||
weechat_hook_signal ("3000|quit;upgrade", &signal_cb, NULL, NULL);
|
||||
|
||||
/* accrocher les lignes affichées dans les tampons formatés avec priorité = 500 */
|
||||
/* basse priorité : appelé après les autres fonctions de rappel "line" */
|
||||
weechat_hook_line ("500|formatted", "*", NULL, &line_cb, NULL, NULL);
|
||||
----
|
||||
|
||||
Les types de "hooks" suivants autorisent une priorité :
|
||||
@@ -8960,6 +8966,7 @@ Les types de "hooks" suivants autorisent une priorité :
|
||||
* <<_hook_command,command>>
|
||||
* <<_hook_completion,completion>>
|
||||
* <<_hook_command_run,command_run>>
|
||||
* <<_hook_line,line>>
|
||||
* <<_hook_signal,signal>>
|
||||
* <<_hook_hsignal,hsignal>>
|
||||
* <<_hook_config,config>>
|
||||
@@ -10154,7 +10161,7 @@ hook = weechat.hook_connect("", "my.server.org", 1234, 1, 0, "",
|
||||
|
||||
==== hook_line
|
||||
|
||||
_WeeChat ≥ 2.3._
|
||||
_WeeChat ≥ 2.3, mis à jour dans la 3.7._
|
||||
|
||||
Intercepter une ligne sur le point d'être affichée dans un tampon.
|
||||
|
||||
@@ -10170,8 +10177,8 @@ appelés dans cet ordre :
|
||||
"hook").
|
||||
|
||||
[NOTE]
|
||||
The "line" hook is the only one among these three hooks that can work on
|
||||
buffers with free content.
|
||||
Le "hook" "line" est le seul parmi ces trois "hooks" qui peut fonctionner sur
|
||||
un tampon avec contenu libre.
|
||||
|
||||
Prototype :
|
||||
|
||||
@@ -10190,7 +10197,8 @@ struct t_hook *weechat_hook_line (const char *buffer_type,
|
||||
Paramètres :
|
||||
|
||||
* _buffer_type_ : intercepter les lignes affichées sur ce type de tampon
|
||||
(si NULL ou chaîne vide, _formatted_ est utilisé par défaut) :
|
||||
(si NULL ou chaîne vide, _formatted_ est utilisé par défaut)
|
||||
(une priorité est autorisée avant le type de tampon, voir la note sur la <<hook_priority,priorité>>) :
|
||||
** _formatted_ : intercepter les lignes sur un tampon avec contenu formaté
|
||||
seulement (par défaut)
|
||||
** _free_ : intercepter les lignes sur un tampon avec contenu libre seulement
|
||||
|
||||
@@ -9098,10 +9098,16 @@ C examples:
|
||||
[source,c]
|
||||
----
|
||||
/* hook per il modificatore con priorità = 2000 */
|
||||
/* high priority: called before other modifier calbacks */
|
||||
weechat_hook_modifier ("2000|input_text_display", &modifier_cb, NULL, NULL);
|
||||
|
||||
/* hook two signals with priority = 3000 */
|
||||
/* high priority: called before other signal callbacks */
|
||||
weechat_hook_signal ("3000|quit;upgrade", &signal_cb, NULL, NULL);
|
||||
|
||||
/* hook lines printed in formatted buffers with priority = 500 */
|
||||
/* low priority: called after other line callbacks */
|
||||
weechat_hook_line ("500|formatted", "*", NULL, &line_cb, NULL, NULL);
|
||||
----
|
||||
|
||||
I tipi di hook che seguono consentono la priorità:
|
||||
@@ -9109,6 +9115,7 @@ I tipi di hook che seguono consentono la priorità:
|
||||
* <<_hook_command,command>>
|
||||
* <<_hook_completion,completion>>
|
||||
* <<_hook_command_run,command_run>>
|
||||
* <<_hook_line,line>>
|
||||
* <<_hook_signal,signal>>
|
||||
* <<_hook_hsignal,hsignal>>
|
||||
* <<_hook_config,config>>
|
||||
@@ -10294,7 +10301,7 @@ hook = weechat.hook_connect("", "my.server.org", 1234, 1, 0, "",
|
||||
// TRANSLATION MISSING
|
||||
==== hook_line
|
||||
|
||||
_WeeChat ≥ 2.3._
|
||||
_WeeChat ≥ 2.3, updated in 3.7._
|
||||
|
||||
Hook a line to be printed in a buffer.
|
||||
|
||||
@@ -10328,7 +10335,8 @@ struct t_hook *weechat_hook_line (const char *buffer_type,
|
||||
Argomenti:
|
||||
|
||||
* _buffer_type_: catch lines on the given buffer type (if NULL or empty string,
|
||||
_formatted_ is the default):
|
||||
_formatted_ is the default)
|
||||
(a priority is allowed before the buffer type, see note about <<hook_priority,priority>>):
|
||||
** _formatted_: catch lines on formatted buffers only (default)
|
||||
** _free_: catch lines on buffers with free content only
|
||||
** _*_: catch lines on all buffer types
|
||||
|
||||
@@ -8841,10 +8841,16 @@ C examples:
|
||||
[source,c]
|
||||
----
|
||||
/* hook modifier with priority = 2000 */
|
||||
/* high priority: called before other modifier calbacks */
|
||||
weechat_hook_modifier ("2000|input_text_display", &modifier_cb, NULL, NULL);
|
||||
|
||||
/* hook two signals with priority = 3000 */
|
||||
/* high priority: called before other signal callbacks */
|
||||
weechat_hook_signal ("3000|quit;upgrade", &signal_cb, NULL, NULL);
|
||||
|
||||
/* hook lines printed in formatted buffers with priority = 500 */
|
||||
/* low priority: called after other line callbacks */
|
||||
weechat_hook_line ("500|formatted", "*", NULL, &line_cb, NULL, NULL);
|
||||
----
|
||||
|
||||
以下のフック型に対して優先度を設定できます:
|
||||
@@ -8852,6 +8858,7 @@ weechat_hook_signal ("3000|quit;upgrade", &signal_cb, NULL, NULL);
|
||||
* <<_hook_command,command>>
|
||||
* <<_hook_completion,completion>>
|
||||
* <<_hook_command_run,command_run>>
|
||||
* <<_hook_line,line>>
|
||||
* <<_hook_signal,signal>>
|
||||
* <<_hook_hsignal,hsignal>>
|
||||
* <<_hook_config,config>>
|
||||
@@ -10010,7 +10017,8 @@ hook = weechat.hook_connect("", "my.server.org", 1234, 1, 0, "",
|
||||
|
||||
==== hook_line
|
||||
|
||||
_WeeChat バージョン 2.3 以上で利用可_
|
||||
// TRANSLATION MISSING
|
||||
_WeeChat ≥ 2.3, updated in 3.7._
|
||||
|
||||
バッファに対する行表示をフックする。
|
||||
|
||||
@@ -10044,7 +10052,8 @@ struct t_hook *weechat_hook_line (const char *buffer_type,
|
||||
引数:
|
||||
|
||||
* _buffer_type_: ここで指定したバッファ型の行をフックします (NULL または空文字列の場合、
|
||||
_formatted_ を指定したことになります):
|
||||
_formatted_ を指定したことになります)
|
||||
(a priority is allowed before the buffer type, see note about <<hook_priority,priority>>):
|
||||
** _formatted_: フォーマット済み内容バッファの行のみをフックします (デフォルト)
|
||||
** _free_: 自由内容バッファの行のみをフックします
|
||||
** _*_: すべてのバッファの行をフックします
|
||||
|
||||
@@ -8545,10 +8545,16 @@ C examples:
|
||||
[source,c]
|
||||
----
|
||||
/* модификатор кука са приоритетом = 2000 */
|
||||
/* high priority: called before other modifier calbacks */
|
||||
weechat_hook_modifier ("2000|input_text_display", &modifier_cb, NULL, NULL);
|
||||
|
||||
/* hook two signals with priority = 3000 */
|
||||
/* high priority: called before other signal callbacks */
|
||||
weechat_hook_signal ("3000|quit;upgrade", &signal_cb, NULL, NULL);
|
||||
|
||||
/* hook lines printed in formatted buffers with priority = 500 */
|
||||
/* low priority: called after other line callbacks */
|
||||
weechat_hook_line ("500|formatted", "*", NULL, &line_cb, NULL, NULL);
|
||||
----
|
||||
|
||||
Приоритет дозвољавају следећи типови кука:
|
||||
@@ -8556,6 +8562,7 @@ weechat_hook_signal ("3000|quit;upgrade", &signal_cb, NULL, NULL);
|
||||
* <<_hook_command,command>>
|
||||
* <<_hook_completion,completion>>
|
||||
* <<_hook_command_run,command_run>>
|
||||
* <<_hook_line,line>>
|
||||
* <<_hook_signal,signal>>
|
||||
* <<_hook_hsignal,hsignal>>
|
||||
* <<_hook_config,config>>
|
||||
@@ -9632,7 +9639,8 @@ hook = weechat.hook_connect("", "my.server.org", 1234, 1, 0, "",
|
||||
|
||||
==== hook_line
|
||||
|
||||
_WeeChat ≥ 2.3._
|
||||
// TRANSLATION MISSING
|
||||
_WeeChat ≥ 2.3, updated in 3.7._
|
||||
|
||||
Качи се на линију која треба да се испише у бафер.
|
||||
|
||||
@@ -9661,7 +9669,9 @@ struct t_hook *weechat_hook_line (const char *buffer_type,
|
||||
|
||||
Аргументи:
|
||||
|
||||
* _buffer_type_: хвата линије у наведеном типу бафера (ако је NULL или празан стринг, подразумева се _formatted_):
|
||||
// TRANSLATION MISSING
|
||||
* _buffer_type_: хвата линије у наведеном типу бафера (ако је NULL или празан стринг, подразумева се _formatted_)
|
||||
(a priority is allowed before the buffer type, see note about <<hook_priority,приоритетима>>):
|
||||
** _formatted_: хвата линије само у форматираним баферима (подразумевано)
|
||||
** _free_: хвата линије само у баферима са слободним садржајем
|
||||
** _*_: хвата линије у баферима свих типова
|
||||
|
||||
@@ -71,6 +71,8 @@ hook_line (struct t_weechat_plugin *plugin, const char *buffer_type,
|
||||
{
|
||||
struct t_hook *new_hook;
|
||||
struct t_hook_line *new_hook_line;
|
||||
int priority;
|
||||
const char *ptr_buffer_type;
|
||||
|
||||
if (!callback)
|
||||
return NULL;
|
||||
@@ -85,17 +87,18 @@ hook_line (struct t_weechat_plugin *plugin, const char *buffer_type,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hook_init_data (new_hook, plugin, HOOK_TYPE_LINE, HOOK_PRIORITY_DEFAULT,
|
||||
hook_get_priority_and_name (buffer_type, &priority, &ptr_buffer_type);
|
||||
hook_init_data (new_hook, plugin, HOOK_TYPE_LINE, priority,
|
||||
callback_pointer, callback_data);
|
||||
|
||||
new_hook->hook_data = new_hook_line;
|
||||
new_hook_line->callback = callback;
|
||||
if (!buffer_type || !buffer_type[0])
|
||||
if (!ptr_buffer_type || !ptr_buffer_type[0])
|
||||
new_hook_line->buffer_type = GUI_BUFFER_TYPE_DEFAULT;
|
||||
else if (strcmp (buffer_type, "*") == 0)
|
||||
else if (strcmp (ptr_buffer_type, "*") == 0)
|
||||
new_hook_line->buffer_type = -1;
|
||||
else
|
||||
new_hook_line->buffer_type = gui_buffer_search_type (buffer_type);
|
||||
new_hook_line->buffer_type = gui_buffer_search_type (ptr_buffer_type);
|
||||
new_hook_line->buffers = string_split (
|
||||
(buffer_name && buffer_name[0]) ? buffer_name : "*",
|
||||
",",
|
||||
|
||||
@@ -362,6 +362,9 @@ hook_get_priority_and_name (const char *string,
|
||||
if (name)
|
||||
*name = string;
|
||||
|
||||
if (!string)
|
||||
return;
|
||||
|
||||
pos = strchr (string, '|');
|
||||
if (pos)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user