api: add function hook_line
This commit is contained in:
parent
12a6f74ec0
commit
42be1a74a0
@ -21,6 +21,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
|
||||
New features::
|
||||
|
||||
* core: allow partial buffer name in command /buffer close (issue #1226)
|
||||
* api: add function hook_line
|
||||
|
||||
Bug fixes::
|
||||
|
||||
|
@ -530,6 +530,7 @@ Liste der Skript API Funktionen:
|
||||
hook_process +
|
||||
hook_process_hashtable +
|
||||
hook_connect +
|
||||
hook_line +
|
||||
hook_print +
|
||||
hook_signal +
|
||||
hook_signal_send +
|
||||
|
@ -3619,8 +3619,8 @@ Ein Trigger hat folgende Optionen (Benennung ist
|
||||
| enabled | `on`, `off` |
|
||||
Wenn die Option auf `off` gesetzt ist, dann ist der Trigger deaktiviert und die Ausführung ist gestoppt.
|
||||
|
||||
| hook | `signal`, `hsignal`, `modifier`, `print`, `command`, `command_run`,
|
||||
`timer`, `config`, `focus` |
|
||||
| hook | `signal`, `hsignal`, `modifier`, `line`, `print`, `command`,
|
||||
`command_run`, `timer`, `config`, `focus` |
|
||||
Der hook welcher durch Trigger genutzt werden soll. Für weitere Informationen siehe
|
||||
link:weechat_plugin_api.en.html#hooks[Anleitung für API Erweiterung / Hooks] (Englisch).
|
||||
|
||||
@ -3710,6 +3710,18 @@ ein Semikolon getrennt.
|
||||
`+5000\|input_text_display;5000\|history_add+` |
|
||||
link:weechat_plugin_api.en.html#_hook_modifier[hook_modifier] (Englisch)
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| line |
|
||||
1. buffer type +
|
||||
2. buffer name +
|
||||
3. tags |
|
||||
`+formatted+` +
|
||||
`+free+` +
|
||||
`+*;irc.freenode.*+` +
|
||||
`+*;irc.freenode.#weechat+` +
|
||||
`+formatted;irc.freenode.#weechat;irc_notice+` |
|
||||
link:weechat_plugin_api.en.html#_hook_line[hook_line]
|
||||
|
||||
| print |
|
||||
1. Buffername +
|
||||
2. Tags +
|
||||
@ -3795,6 +3807,7 @@ welche abhängig von dem genutzten Hook ist:
|
||||
| signal | tg_signal_data
|
||||
| hsignal |
|
||||
| modifier | tg_string
|
||||
| line | message
|
||||
| print | tg_message
|
||||
| command | tg_argv_eol1
|
||||
| command_run | tg_command
|
||||
@ -3962,6 +3975,46 @@ vorhanden sind (siehe <<trigger_data_print,hook print>> weiter unten), und nachf
|
||||
Sollte das Signal eine IRC Nachricht beinhalten, wird die Nachricht analysiert
|
||||
und die Daten in einer Hashtable gesichert (siehe <<trigger_data_signal,hook signal>>).
|
||||
|
||||
[[trigger_data_line]]
|
||||
===== Line
|
||||
|
||||
Der Callback von "line" legt folgende Variablen in der Hashtable an:
|
||||
|
||||
// TRANSLATION MISSING
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
| Variable | Typ | Beschreibung
|
||||
| buffer | pointer | Buffer.
|
||||
| buffer_name | string | Buffer name.
|
||||
| buffer_type | string | Buffer type ("formatted" or "free").
|
||||
| y | string | Line number for a buffer with free content (≥ 0), -1 for a buffer with formatted content.
|
||||
| date | string | Line date (timestamp).
|
||||
| date_printed | string | Date when line was displayed (timestamp).
|
||||
| str_time | string | Date for display. It may contain color codes.
|
||||
| displayed | string | "1" if displayed, "0" if line filtered.
|
||||
| notify_level | string | "0" = low level, "1" = message, "2" = private message, "3" = highlight
|
||||
| highlight | string | "1" if highlight, otherwise "0".
|
||||
| prefix | string | Prefix.
|
||||
| message | string | Message.
|
||||
|===
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Variables set using tags in message (they are also set in _print_ callback and
|
||||
modifier _weechat_print_):
|
||||
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
| Variable | Typ | Beschreibung
|
||||
| tg_tags | string | Tags einer Nachricht (Komma wird automatisch zu Beginn und Ende den Tags hinzugefügt).
|
||||
| tg_tags_count | string | Anzahl an Tags der Nachricht.
|
||||
| tg_tag_nick | string | Nick (extrahiert aus Tag "nick_xxx").
|
||||
| tg_tag_prefix_nick | string | Nickfarbe für Präfix (extrahier aus Tag "prefix_nick_ccc").
|
||||
| tg_tag_host | string | Username und Host, Format: username@host (extrahiert aus Tag "host_xxx").
|
||||
| tg_tag_notify | string | Benachrichtigungsstufe (_none_, _message_, _private_, _highlight_).
|
||||
| tg_notify | string | Benachrichtigungsstufe, falls von _none_ abweichend.
|
||||
| tg_msg_pv | string | "1" für eine private Nachricht, andernfalls "0".
|
||||
|===
|
||||
|
||||
[[trigger_data_print]]
|
||||
===== Print
|
||||
|
||||
@ -3980,8 +4033,9 @@ Der Callback von "print" legt folgende Variablen in der Hashtable an:
|
||||
| tg_message_nocolor | string | Nachricht ohne Farbcodes.
|
||||
|===
|
||||
|
||||
Variablen welche gesetzt werden, aufgrund der Nutzung von Tags in einer Nachricht
|
||||
(_weechat_print_ nutzt ebenso diese Tag-Variablen):
|
||||
// TRANSLATION MISSING
|
||||
Variables set using tags in message (they are also set in _line_ callback and
|
||||
modifier _weechat_print_):
|
||||
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
|
@ -9110,6 +9110,271 @@ hook = weechat.hook_connect("", "my.server.org", 1234, 1, 0, "",
|
||||
"my_connect_cb", "")
|
||||
----
|
||||
|
||||
==== hook_line
|
||||
|
||||
_WeeChat ≥ 2.3._
|
||||
|
||||
Hook a line printed in a buffer.
|
||||
|
||||
When a line is printed in a buffer, hooks are called in this order:
|
||||
|
||||
* <<_hook_line,hook line>> (this hook)
|
||||
* <<_hook_modifier,hook modifier>>: <<hook_modifier_weechat_print,weechat_print>>
|
||||
* <<_hook_print,hook print>>
|
||||
|
||||
Prototype:
|
||||
|
||||
[source,C]
|
||||
----
|
||||
struct t_hook *weechat_hook_line (const char *buffer_type,
|
||||
const char *buffer_name,
|
||||
const char *tags,
|
||||
struct t_hashtable *(*callback)(const void *pointer,
|
||||
void *data,
|
||||
struct t_hashtable *line),
|
||||
const void *callback_pointer,
|
||||
void *callback_data);
|
||||
----
|
||||
|
||||
Arguments:
|
||||
|
||||
* _buffer_type_: catch lines on the given buffer type (if NULL or empty string,
|
||||
_formatted_ is the default):
|
||||
** _formatted_: catch lines on formatted buffers only (default)
|
||||
** _free_: catch lines on buffers with free content only
|
||||
** _*_: catch lines on all buffer types
|
||||
* _buffer_name_: comma-separated list of buffer masks
|
||||
(see <<_buffer_match_list,buffer_match_list>>); NULL, empty string or "*"
|
||||
matches any buffer
|
||||
* _tags_: catch only messages with these tags (optional): comma-separated list
|
||||
of tags that must be in message (logical "or"); it is possible to combine
|
||||
many tags as a logical "and" with separator `+++`; wildcard `+*+` is allowed
|
||||
in tags
|
||||
* _callback_: function called when a line is added in a buffer, arguments and
|
||||
return value:
|
||||
** _const void *pointer_: pointer
|
||||
** _void *data_: pointer
|
||||
** _struct t_hashtable *line_: hashtable with the line info, keys and values are
|
||||
strings (see table below)
|
||||
** return value: hashtable with new values (see table below)
|
||||
* _callback_pointer_: pointer given to callback when it is called by WeeChat
|
||||
* _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 hook is deleted
|
||||
|
||||
Return value:
|
||||
|
||||
* pointer to new hook, NULL if error occurred
|
||||
|
||||
Line data sent to the callback is a hashtable, with following values
|
||||
(keys and values are strings):
|
||||
|
||||
[width="100%",cols="^1,3,3,2",options="header"]
|
||||
|===
|
||||
| Key | Value (formatted buffer) | Value (free buffer) | Examples
|
||||
|
||||
| buffer |
|
||||
Buffer pointer. |
|
||||
Buffer pointer. |
|
||||
`+0x12345678+`
|
||||
|
||||
| buffer_name |
|
||||
Buffer name. |
|
||||
Buffer name. |
|
||||
`+core.weechat+` +
|
||||
`+irc.server.freenode+` +
|
||||
`+irc.freenode.#weechat+`
|
||||
|
||||
| buffer_type |
|
||||
"formatted" |
|
||||
"free" |
|
||||
`+formatted+` +
|
||||
`+free+`
|
||||
|
||||
| y |
|
||||
N/A ("-1"). |
|
||||
Line number (≥ "0"). |
|
||||
`+-1+` +
|
||||
`+8+`
|
||||
|
||||
| date |
|
||||
Line date (timestamp). |
|
||||
N/A ("0"). |
|
||||
`+1533792000+`
|
||||
|
||||
| date_printed |
|
||||
Date when line was displayed (timestamp). |
|
||||
N/A ("0"). |
|
||||
`+1533792012+`
|
||||
|
||||
| str_time |
|
||||
Date for display (possible color codes inside). |
|
||||
N/A (empty string). |
|
||||
`+09:07:20+`
|
||||
|
||||
| tags_count |
|
||||
Number of tags in the line (≥ "0"). |
|
||||
N/A ("0"). |
|
||||
`+2+`
|
||||
|
||||
| tags |
|
||||
Comma-separated list of tags. |
|
||||
N/A (empty string). |
|
||||
`+irc_join,nick_test+`
|
||||
|
||||
| displayed |
|
||||
"0" = line is filtered (hidden) +
|
||||
"1" = line is not filtered (displayed). |
|
||||
"0" = line is filtered (hidden) +
|
||||
"1" = line is not filtered (displayed). |
|
||||
`+0+` +
|
||||
`+1+`
|
||||
|
||||
| notify_level |
|
||||
"0" = low level +
|
||||
"1" = message +
|
||||
"2" = private message +
|
||||
"3" = highlight |
|
||||
N/A ("0"). |
|
||||
`+2+`
|
||||
|
||||
| highlight |
|
||||
"0" = no highlight +
|
||||
"1" = line has highlight. |
|
||||
N/A ("0"). |
|
||||
`+0+` +
|
||||
`+1+`
|
||||
|
||||
| prefix |
|
||||
Prefix of the line. |
|
||||
N/A (empty string). |
|
||||
`+-->+`
|
||||
|
||||
| message |
|
||||
Message of the line. |
|
||||
Message of the line. |
|
||||
`+test (~test@example.com) has joined #channel+`
|
||||
|===
|
||||
|
||||
The callback can return a hashtable with some fields to update the line.
|
||||
Any invalid value in a field is silently ignored by WeeChat.
|
||||
|
||||
The following keys can be set in the hashtable (keys and values are strings
|
||||
in this hashtable):
|
||||
|
||||
[width="100%",cols="^1,2,2,5",options="header"]
|
||||
|===
|
||||
| Key | Allowed value (formatted buffer) | Allowed value (free buffer) | Result
|
||||
|
||||
| buffer |
|
||||
Pointer of a buffer with formatted content. |
|
||||
Pointer of a buffer with free content. |
|
||||
The line is displayed on this buffer. +
|
||||
If the value is empty, the line is deleted (anything else in the hashtable
|
||||
is then ignored); the next hooks of type "line" are not called.
|
||||
|
||||
| buffer_name |
|
||||
Name of a buffer with formatted content. |
|
||||
Name of a buffer with free content. |
|
||||
The line is displayed on this buffer. +
|
||||
If `buffer` is also set, the value of `buffer_name` has higher priority and is used. +
|
||||
If the value is empty, the line is deleted (anything else in the hashtable
|
||||
is then ignored); the next hooks of type "line" are not called.
|
||||
|
||||
| y |
|
||||
N/A. |
|
||||
Integer (≥ "0"). |
|
||||
The line number is set to this value.
|
||||
|
||||
| date |
|
||||
Timestamp. |
|
||||
N/A. |
|
||||
The date is set to this value. +
|
||||
The value of `str_time` is updated accordingly.
|
||||
|
||||
| date_printed |
|
||||
Timestamp. |
|
||||
N/A. |
|
||||
The printed date is set to this timestamp (not displayed).
|
||||
|
||||
| str_time |
|
||||
String. |
|
||||
N/A. |
|
||||
This string is used to display the date line. +
|
||||
If `date` is also set, the value of `str_time` has higher priority and is used.
|
||||
|
||||
| tags |
|
||||
String. |
|
||||
N/A. |
|
||||
The line tags are replaced with this comma-separated list of tags. +
|
||||
The values of `notify_level` and `highlight` are updated accordingly.
|
||||
|
||||
| notify_level |
|
||||
Integer ("0" to "3"). |
|
||||
N/A. |
|
||||
The notify level is set to this value. The hotlist will be updated
|
||||
accordingly once the line is added in the buffer. +
|
||||
The value of `highlight` is updated accordingly. +
|
||||
If `tags` is also set, the value of `notify_level` has higher priority and is used.
|
||||
|
||||
| highlight |
|
||||
Integer ("0" or "1"). |
|
||||
N/A. |
|
||||
"0" disables highlight on the line, "1" forces a highlight on the line. +
|
||||
If `tags` or `notify_level` are set, the value of `highlight` has higher
|
||||
priority and is used.
|
||||
|
||||
| prefix |
|
||||
String. |
|
||||
N/A. |
|
||||
The line prefix is set to this value.
|
||||
|
||||
| message |
|
||||
String. |
|
||||
String. |
|
||||
The line message is set to this value.
|
||||
|===
|
||||
|
||||
C example:
|
||||
|
||||
[source,C]
|
||||
----
|
||||
int
|
||||
my_line_cb (const void *pointer, void *data, struct t_hasbtable *line)
|
||||
{
|
||||
struct t_hashtable *hashtable;
|
||||
|
||||
hashtable = weechat_hashtable_new (8,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
NULL,
|
||||
NULL);
|
||||
/* force a highlight on the line */
|
||||
weechat_hashtable_set (hashtable, "highlight", "1");
|
||||
return hashtable;
|
||||
}
|
||||
|
||||
/* catch lines with tag "irc_join" */
|
||||
struct t_hook *my_line_hook =
|
||||
weechat_hook_line ("", "", "irc_join", &my_line_cb, NULL, NULL);
|
||||
----
|
||||
|
||||
Script (Python):
|
||||
|
||||
[source,python]
|
||||
----
|
||||
# prototype
|
||||
hook = weechat.hook_line(buffer_type, buffer_name, tags, callback, callback_data)
|
||||
|
||||
# example
|
||||
def my_line_cb(data, line):
|
||||
# force a highlight on the line
|
||||
return {"highlight": "1"}
|
||||
|
||||
# catch lines with tag "irc_join"
|
||||
hook = weechat.hook_line("", "", "irc_join", "my_line_cb", "")
|
||||
----
|
||||
|
||||
==== hook_print
|
||||
|
||||
_Updated in 0.4.3, 1.0, 1.5._
|
||||
@ -10668,107 +10933,107 @@ List of modifiers used by WeeChat and plugins:
|
||||
|===
|
||||
| Modifier | Modifier data | String | Output
|
||||
|
||||
| charset_decode |
|
||||
| [[hook_modifier_charset_decode]] charset_decode |
|
||||
plugin.buffer_name |
|
||||
Any string. |
|
||||
String decoded from charset found for plugin/buffer to UTF-8.
|
||||
|
||||
| charset_encode |
|
||||
| [[hook_modifier_charset_encode]] charset_encode |
|
||||
plugin.buffer_name |
|
||||
Any string. |
|
||||
String encoded from UTF-8 to charset found for plugin/buffer.
|
||||
|
||||
| irc_color_decode |
|
||||
| [[hook_modifier_irc_color_decode]] irc_color_decode |
|
||||
"1" to keep colors, "0" to remove colors |
|
||||
Any string. |
|
||||
String with IRC colors converted to WeeChat colors (or IRC colors removed).
|
||||
|
||||
| irc_color_encode |
|
||||
| [[hook_modifier_irc_color_encode]] irc_color_encode |
|
||||
"1" to keep colors, "0" to remove colors |
|
||||
Any string. |
|
||||
String with IRC colors (or IRC colors removed).
|
||||
|
||||
| irc_color_decode_ansi +
|
||||
| [[hook_modifier_irc_color_decode_ansi]] irc_color_decode_ansi +
|
||||
_(WeeChat ≥ 1.0)_ |
|
||||
"1" to keep colors, "0" to remove colors |
|
||||
Any string. |
|
||||
String with ANSI colors converted to IRC colors (or ANSI colors removed).
|
||||
|
||||
| irc_command_auth +
|
||||
| [[hook_modifier_irc_command_auth]] irc_command_auth +
|
||||
_(WeeChat ≥ 0.4.1)_ |
|
||||
Server name |
|
||||
Authentication command (for example: `+/msg nickserv identify password+`). |
|
||||
command with hidden password (for example: `+/msg nickserv identify ********+`).
|
||||
|
||||
| irc_message_auth +
|
||||
| [[hook_modifier_irc_message_auth]] irc_message_auth +
|
||||
_(WeeChat ≥ 0.4.1)_ |
|
||||
Server name |
|
||||
Message displayed after `/msg` sent to nickserv. |
|
||||
Message with hidden password.
|
||||
|
||||
| irc_in_xxx ^(1)^ |
|
||||
| [[hook_modifier_irc_in_xxx]] irc_in_xxx ^(1)^ |
|
||||
Server name |
|
||||
Content of message received from IRC server (before charset decoding). |
|
||||
New content of message.
|
||||
|
||||
| irc_in2_xxx ^(1)^ +
|
||||
| [[hook_modifier_irc_in2_xxx]] irc_in2_xxx ^(1)^ +
|
||||
_(WeeChat ≥ 0.3.5)_ |
|
||||
Server name |
|
||||
Content of message received from IRC server (after charset decoding). |
|
||||
New content of message.
|
||||
|
||||
| irc_out1_xxx ^(1)^ +
|
||||
| [[hook_modifier_irc_out1_xxx]] irc_out1_xxx ^(1)^ +
|
||||
_(WeeChat ≥ 0.3.7)_ |
|
||||
Server name |
|
||||
Content of message about to be sent to IRC server before automatic split
|
||||
(to fit in 512 bytes by default). |
|
||||
New content of message.
|
||||
|
||||
| irc_out_xxx ^(1)^ |
|
||||
| [[hook_modifier_irc_out_xxx]] irc_out_xxx ^(1)^ |
|
||||
Server name |
|
||||
Content of message about to be sent to IRC server after automatic split
|
||||
(to fit in 512 bytes by default). |
|
||||
New content of message.
|
||||
|
||||
| color_decode_ansi +
|
||||
| [[hook_modifier_color_decode_ansi]] color_decode_ansi +
|
||||
_(WeeChat ≥ 1.0)_ |
|
||||
"1" to keep colors, "0" to remove colors |
|
||||
Any string. |
|
||||
String with ANSI colors converted to WeeChat colors (or ANSI colors removed).
|
||||
|
||||
| bar_condition_yyy ^(2)^ |
|
||||
| [[hook_modifier_bar_condition_yyy]] bar_condition_yyy ^(2)^ |
|
||||
String with window pointer ("0x123..") |
|
||||
Empty string. |
|
||||
"1" to display bar, "0" to hide it.
|
||||
|
||||
| history_add +
|
||||
| [[hook_modifier_history_add]] history_add +
|
||||
_(WeeChat ≥ 0.3.2)_ |
|
||||
String with buffer pointer ("0x123..") |
|
||||
Content of command line to add in command history (buffer and global). |
|
||||
String added to command history.
|
||||
|
||||
| input_text_content |
|
||||
| [[hook_modifier_input_text_content]] input_text_content |
|
||||
String with buffer pointer ("0x123..") |
|
||||
Content of command line. |
|
||||
New content of command line.
|
||||
|
||||
| input_text_display |
|
||||
| [[hook_modifier_input_text_display]] input_text_display |
|
||||
String with buffer pointer ("0x123..") |
|
||||
Content of command line, without cursor tag. |
|
||||
New string, for display only (command line is not changed).
|
||||
|
||||
| input_text_display_with_cursor |
|
||||
| [[hook_modifier_input_text_display_with_cursor]] input_text_display_with_cursor |
|
||||
String with buffer pointer ("0x123..") |
|
||||
Content of command line, with cursor tag. |
|
||||
New string, for display only (command line is not changed).
|
||||
|
||||
| input_text_for_buffer +
|
||||
| [[hook_modifier_input_text_for_buffer]] input_text_for_buffer +
|
||||
_(WeeChat ≥ 0.3.7)_ |
|
||||
String with buffer pointer ("0x123..") |
|
||||
Content of command line sent to buffer (text or command). |
|
||||
New content of command line sent to buffer.
|
||||
|
||||
| weechat_print |
|
||||
| [[hook_modifier_weechat_print]] weechat_print |
|
||||
plugin + ";" + buffer_name + ";" + tags |
|
||||
Message printed. |
|
||||
New message printed.
|
||||
|
@ -517,6 +517,7 @@ List of functions in script API:
|
||||
hook_process +
|
||||
hook_process_hashtable +
|
||||
hook_connect +
|
||||
hook_line +
|
||||
hook_print +
|
||||
hook_signal +
|
||||
hook_signal_send +
|
||||
|
@ -3539,8 +3539,8 @@ A trigger has the following options (names are
|
||||
When option is `off`, the trigger is disabled and actions are not executed
|
||||
any more.
|
||||
|
||||
| hook | `signal`, `hsignal`, `modifier`, `print`, `command`, `command_run`,
|
||||
`timer`, `config`, `focus` |
|
||||
| hook | `signal`, `hsignal`, `modifier`, `line`, `print`, `command`,
|
||||
`command_run`, `timer`, `config`, `focus` |
|
||||
The hook used in trigger. For more information, see
|
||||
link:weechat_plugin_api.en.html#hooks[WeeChat plugin API reference / Hooks].
|
||||
|
||||
@ -3627,6 +3627,17 @@ The arguments depend on the hook used. They are separated by semicolons.
|
||||
`+5000\|input_text_display;5000\|history_add+` |
|
||||
link:weechat_plugin_api.en.html#_hook_modifier[hook_modifier]
|
||||
|
||||
| line |
|
||||
1. buffer type +
|
||||
2. buffer name +
|
||||
3. tags |
|
||||
`+formatted+` +
|
||||
`+free+` +
|
||||
`+*;irc.freenode.*+` +
|
||||
`+*;irc.freenode.#weechat+` +
|
||||
`+formatted;irc.freenode.#weechat;irc_notice+` |
|
||||
link:weechat_plugin_api.en.html#_hook_line[hook_line]
|
||||
|
||||
| print |
|
||||
1. buffer name +
|
||||
2. tags +
|
||||
@ -3710,6 +3721,7 @@ type:
|
||||
| signal | tg_signal_data
|
||||
| hsignal |
|
||||
| modifier | tg_string
|
||||
| line | message
|
||||
| print | tg_message
|
||||
| command | tg_argv_eol1
|
||||
| command_run | tg_command
|
||||
@ -3872,6 +3884,44 @@ For the _weechat_print_ modifier, variables using message tags are added (see
|
||||
If the modifier contains an IRC message, the message is parsed and extra data is
|
||||
added in hashtable (see <<trigger_data_signal,hook signal>>).
|
||||
|
||||
[[trigger_data_line]]
|
||||
===== Line
|
||||
|
||||
The "line" callback sets following variables in hashtable:
|
||||
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
| Variable | Type | Description
|
||||
| buffer | pointer | Buffer.
|
||||
| buffer_name | string | Buffer name.
|
||||
| buffer_type | string | Buffer type ("formatted" or "free").
|
||||
| y | string | Line number for a buffer with free content (≥ 0), -1 for a buffer with formatted content.
|
||||
| date | string | Line date (timestamp).
|
||||
| date_printed | string | Date when line was displayed (timestamp).
|
||||
| str_time | string | Date for display. It may contain color codes.
|
||||
| displayed | string | "1" if displayed, "0" if line filtered.
|
||||
| notify_level | string | "0" = low level, "1" = message, "2" = private message, "3" = highlight
|
||||
| highlight | string | "1" if highlight, otherwise "0".
|
||||
| prefix | string | Prefix.
|
||||
| message | string | Message.
|
||||
|===
|
||||
|
||||
Variables set using tags in message (they are also set in _print_ callback and
|
||||
modifier _weechat_print_):
|
||||
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
| Variable | Type | Description
|
||||
| tg_tags | string | Tags of message (with comma added at beginning/end of string).
|
||||
| tg_tags_count | string | Number of tags in message.
|
||||
| tg_tag_nick | string | Nick (from tag "nick_xxx").
|
||||
| tg_tag_prefix_nick | string | Color of nick in prefix (from tag "prefix_nick_ccc").
|
||||
| tg_tag_host | string | User name and host, format: username@host (from tag "host_xxx").
|
||||
| tg_tag_notify | string | Notify level (_none_, _message_, _private_, _highlight_).
|
||||
| tg_notify | string | Notify level, if different from _none_.
|
||||
| tg_msg_pv | string | "1" for a private message, otherwise "0".
|
||||
|===
|
||||
|
||||
[[trigger_data_print]]
|
||||
===== Print
|
||||
|
||||
@ -3890,8 +3940,8 @@ The "print" callback sets following variables in hashtable:
|
||||
| tg_message_nocolor | string | Message without color codes.
|
||||
|===
|
||||
|
||||
Variables set using tags in message (they are set in modifier _weechat_print_
|
||||
too):
|
||||
Variables set using tags in message (they are also set in _line_ callback and
|
||||
modifier _weechat_print_):
|
||||
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
|
@ -1419,7 +1419,7 @@ Paramètres :
|
||||
* _reference_char_ : le caractère utilisé pour les références aux
|
||||
correspondances (en général `+$+`)
|
||||
* _callback_ : une fonction de rappel optionnelle appelé pour chaque référence
|
||||
dans _replace_ (sauf pour les correspondances remplacées par un caractère);
|
||||
dans _replace_ (sauf pour les correspondances remplacées par un caractère) ;
|
||||
la fonction de rappel doit retourner :
|
||||
** une chaîne nouvellement allouée : elle est utilisée en texte de remplacement
|
||||
(elle est libérée après utilisation)
|
||||
@ -2035,7 +2035,7 @@ Paramètres :
|
||||
* _expr_ : l'expression à évaluer (voir les <<eval_conditions,conditions>> et
|
||||
<<eval_variables,variables>>)
|
||||
* _pointers_ : table de hachage avec les pointeurs (les clés doivent être des
|
||||
chaînes, les valeurs doivent être des pointeurs); les pointeurs "window" et
|
||||
chaînes, les valeurs doivent être des pointeurs) ; les pointeurs "window" et
|
||||
"buffer" sont automatiquement ajoutés s'ils ne sont pas dans la table de
|
||||
hachage (avec le pointer vers fenêtre/tampon courants) (peut être NULL) :
|
||||
** _regex_ : pointeur vers une expression régulière (structure _regex_t_)
|
||||
@ -9286,6 +9286,282 @@ hook = weechat.hook_connect("", "my.server.org", 1234, 1, 0, "",
|
||||
"my_connect_cb", "")
|
||||
----
|
||||
|
||||
==== hook_line
|
||||
|
||||
_WeeChat ≥ 2.3._
|
||||
|
||||
Intercepter une ligne affichée dans un tampon.
|
||||
|
||||
Lorsqu'une ligne est affichée dans un tampon, les "hooks" suivants sont
|
||||
appelés dans cet ordre :
|
||||
|
||||
* <<_hook_line,hook line>> (ce "hook")
|
||||
* <<_hook_modifier,hook modifier>>: <<hook_modifier_weechat_print,weechat_print>>
|
||||
* <<_hook_print,hook print>>
|
||||
|
||||
Prototype :
|
||||
|
||||
[source,C]
|
||||
----
|
||||
struct t_hook *weechat_hook_line (const char *buffer_type,
|
||||
const char *buffer_name,
|
||||
const char *tags,
|
||||
struct t_hashtable *(*callback)(const void *pointer,
|
||||
void *data,
|
||||
struct t_hashtable *line),
|
||||
const void *callback_pointer,
|
||||
void *callback_data);
|
||||
----
|
||||
|
||||
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) :
|
||||
** _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
|
||||
** _*_ : intercepter les lignes sur tous les types de tampons
|
||||
* _buffer_name_ : liste de masques de tampons séparés par des virgules
|
||||
(voir <<_buffer_match_list,buffer_match_list>>); NULL, chaîne vide ou "*"
|
||||
correspondent à n'importe quel tampon
|
||||
* _tags_ : intercepter seulement les messages avec ces étiquettes (optionnel) :
|
||||
liste d'étiquettes (séparées par des virgules) qui doivent être dans le message
|
||||
("ou" logique); il est possible de combiner plusieurs étiquettes sous forme
|
||||
d'un "et" logique avec le séparateur `+++`; le caractère joker `+*+` est
|
||||
autorisé dans les étiquettes
|
||||
* _callback_ : fonction appelée lorsqu'une ligne est ajoutée dans un tampon,
|
||||
paramètres et valeur de retour :
|
||||
** _const void *pointer_ : pointeur
|
||||
** _void *data_ : pointeur
|
||||
** _struct t_hashtable *line_ : table de hachage avec les informations sur la ligne,
|
||||
les clés et valeurs sont des chaînes (voir le tableau ci-dessous)
|
||||
** valeur de retour : table de hachage avec les nouvelles valeurs
|
||||
(voir le tableau ci-dessous)
|
||||
* _callback_pointer_ : pointeur donné à la fonction de rappel lorsqu'elle est
|
||||
appelée par WeeChat
|
||||
* _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
|
||||
"hook" est supprimé
|
||||
|
||||
Valeur de retour :
|
||||
|
||||
* pointeur vers le nouveau "hook", NULL en cas d'erreur
|
||||
|
||||
Les données de la ligne envoyées à la fonction de rappel sont dans une table
|
||||
de hachage, avec les valeurs suivantes (les clés et valeurs sont des chaînes) :
|
||||
|
||||
[width="100%",cols="^1,3,3,2",options="header"]
|
||||
|===
|
||||
| Clé | Valeur (tampon formaté) | Valeur (tampon libre) | Exemples
|
||||
|
||||
| buffer |
|
||||
Pointeur vers le tampon. |
|
||||
Pointeur vers le tampon. |
|
||||
`+0x12345678+`
|
||||
|
||||
| buffer_name |
|
||||
Nom du tampon. |
|
||||
Nom du tampon. |
|
||||
`+core.weechat+` +
|
||||
`+irc.server.freenode+` +
|
||||
`+irc.freenode.#weechat+`
|
||||
|
||||
| buffer_type |
|
||||
"formatted" |
|
||||
"free" |
|
||||
`+formatted+` +
|
||||
`+free+`
|
||||
|
||||
| y |
|
||||
N/A ("-1"). |
|
||||
Numéro de ligne (≥ "0"). |
|
||||
`+-1+` +
|
||||
`+8+`
|
||||
|
||||
| date |
|
||||
Date de la ligne (horodatage). |
|
||||
N/A ("0"). |
|
||||
`+1533792000+`
|
||||
|
||||
| date_printed |
|
||||
Date d'affichage de la ligne (horodatage). |
|
||||
N/A ("0"). |
|
||||
`+1533792012+`
|
||||
|
||||
| str_time |
|
||||
Date pour l'affichage (elle peut contenir des codes couleur). |
|
||||
N/A (chaîne vide). |
|
||||
`+09:07:20+`
|
||||
|
||||
| tags_count |
|
||||
Nombre d'étiquettes dans la ligne (≥ "0"). |
|
||||
N/A ("0"). |
|
||||
`+2+`
|
||||
|
||||
| tags |
|
||||
Liste des étiquettes séparées par des virgules. |
|
||||
N/A (chaîne vide). |
|
||||
`+irc_join,nick_test+`
|
||||
|
||||
| displayed |
|
||||
"0" = la ligne est filtrée (cachée) +
|
||||
"1" = la ligne n'est pas filtrée (affichée). |
|
||||
"0" = la ligne est filtrée (cachée) +
|
||||
"1" = la ligne n'est pas filtrée (affichée). |
|
||||
`+0+` +
|
||||
`+1+`
|
||||
|
||||
| notify_level |
|
||||
"0" = niveau bas +
|
||||
"1" = message +
|
||||
"2" = message privé +
|
||||
"3" = highlight |
|
||||
N/A ("0"). |
|
||||
`+2+`
|
||||
|
||||
| highlight |
|
||||
"0" = pas de highlight +
|
||||
"1" = la ligne a un highlight. |
|
||||
N/A ("0"). |
|
||||
`+0+` +
|
||||
`+1+`
|
||||
|
||||
| prefix |
|
||||
Préfixe de la ligne. |
|
||||
N/A (chaîne vide). |
|
||||
`+-->+`
|
||||
|
||||
| message |
|
||||
Message de la ligne. |
|
||||
Message de la ligne. |
|
||||
`+test (~test@example.com) a rejoint #canal+`
|
||||
|===
|
||||
|
||||
La fonction de retour peut retourner une table de hachage avec quelques champs
|
||||
pour mettre à jour la ligne.
|
||||
Toute valeur invalide dans un champ est silencieusement ignorée par WeeChat.
|
||||
|
||||
Les clés suivantes peuvent être définies dans la table de hachage (les clés et
|
||||
valeurs sont des chaînes dans cette table de hachage) :
|
||||
|
||||
[width="100%",cols="^1,2,2,5",options="header"]
|
||||
|===
|
||||
| Clé | Valeur autorisée (tampon formaté) | Valeur autorisée (tampon libre) | Résultat
|
||||
|
||||
| buffer |
|
||||
Pointeur vers un tampon avec contenu formaté. |
|
||||
Pointeur vers un tampon avec contenu libre. |
|
||||
La ligne est affichée sur ce tampon. +
|
||||
Si la valeur est vide, la ligne est supprimée (le reste de la table de hachage
|
||||
est alors ignoré) ; les "hooks" suivants de type "line" ne sont pas appelés.
|
||||
|
||||
| buffer_name |
|
||||
Nom d'un tampon avec contenu formaté. |
|
||||
Nom d'un tampon avec contenu libre. |
|
||||
La ligne est affichée sur ce tampon. +
|
||||
Si `buffer` est également défini, la valeur de `buffer_name` a une priorité
|
||||
plus haute est est utilisée. +
|
||||
Si la valeur est vide, la ligne est supprimée (le reste de la table de hachage
|
||||
est alors ignoré) ; les "hooks" suivants de type "line" ne sont pas appelés.
|
||||
|
||||
| y |
|
||||
N/A. |
|
||||
Entier (≥ "0"). |
|
||||
Le numéro de ligne est positionné à cette valeur.
|
||||
|
||||
| date |
|
||||
Horodatage. |
|
||||
N/A. |
|
||||
La date est positionnée à cet horodatage. +
|
||||
La valeur de `str_time` est mise à jour en conséquence.
|
||||
|
||||
| date_printed |
|
||||
Horodatage. |
|
||||
N/A. |
|
||||
La date d'affichage est positionnée à cet horodatage (non affichée).
|
||||
|
||||
| str_time |
|
||||
Chaîne. |
|
||||
N/A. |
|
||||
Cette chaîne est utilisée pour afficher la date de la ligne. +
|
||||
Si `date` est également défini, la valeur de `str_time` a une priorité plus
|
||||
haute et est utilisée.
|
||||
|
||||
| tags |
|
||||
Chaîne. |
|
||||
N/A. |
|
||||
Les étiquettes de la ligne sont remplacées avec cette liste d'étiquettes
|
||||
(séparées par des virgules). +
|
||||
Les valeurs de `notify_level` et `highlight` sont mises à jour en conséquence.
|
||||
|
||||
| notify_level |
|
||||
Entier ("0" à "3"). |
|
||||
N/A. |
|
||||
Le niveau de notification est positionné à cette valeur. La hotlist sera mise
|
||||
à jour en conséquence une fois que la ligne sera ajoutée dans la tampon. +
|
||||
La valeur de `highlight` est mise à jours en conséquence. +
|
||||
Si `tags` est également défini, la valeur de `notify_level` a une priorité
|
||||
plus haute et est utilisée.
|
||||
|
||||
| highlight |
|
||||
Entier ("0" ou "1"). |
|
||||
N/A. |
|
||||
"0" désactive le highlight sur la ligne, "1" force un highlight sur la ligne. +
|
||||
Si `tags` ou `notify_level` sont définis, la valeur de `highlight` a une
|
||||
priorité plus haute et est utilisée.
|
||||
|
||||
| prefix |
|
||||
Chaîne. |
|
||||
N/A. |
|
||||
Le préfixe de la ligne est positionné à cette valeur.
|
||||
|
||||
| message |
|
||||
Chaîne. |
|
||||
Chaîne. |
|
||||
Le message de la ligne est positionné à cette valeur.
|
||||
|===
|
||||
|
||||
Exemple en C :
|
||||
|
||||
[source,C]
|
||||
----
|
||||
int
|
||||
my_line_cb (const void *pointer, void *data, struct t_hasbtable *line)
|
||||
{
|
||||
struct t_hashtable *hashtable;
|
||||
|
||||
hashtable = weechat_hashtable_new (8,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
NULL,
|
||||
NULL);
|
||||
/* forcer un highlight sur la ligne */
|
||||
weechat_hashtable_set (hashtable, "highlight", "1");
|
||||
return hashtable;
|
||||
}
|
||||
|
||||
/* intercepter les lignes avec l'étiquette "irc_join" */
|
||||
struct t_hook *my_line_hook =
|
||||
weechat_hook_line ("", "", "irc_join", &my_line_cb, NULL, NULL);
|
||||
----
|
||||
|
||||
Script (Python) :
|
||||
|
||||
[source,python]
|
||||
----
|
||||
# prototype
|
||||
hook = weechat.hook_line(buffer_type, buffer_name, tags, callback, callback_data)
|
||||
|
||||
# exemple
|
||||
def my_line_cb(data, line):
|
||||
# forcer un highlight sur la ligne
|
||||
return {"highlight": "1"}
|
||||
|
||||
# intercepter les lignes avec l'étiquette "irc_join"
|
||||
hook = weechat.hook_line("", "", "irc_join", "my_line_cb", "")
|
||||
----
|
||||
|
||||
==== hook_print
|
||||
|
||||
_Mis à jour dans la 0.4.3, 1.0, 1.5._
|
||||
@ -10885,115 +11161,115 @@ Liste des modificateurs utilisés par WeeChat et les extensions :
|
||||
|===
|
||||
| Modificateur | Données du modificateur | Chaîne | Sortie
|
||||
|
||||
| charset_decode |
|
||||
| [[hook_modifier_charset_decode]] charset_decode |
|
||||
extension.nom_tampon |
|
||||
Toute chaîne. |
|
||||
Chaîne décodée depuis le jeu de caractères trouvé pour l'extension/tampon
|
||||
vers UTF-8.
|
||||
|
||||
| charset_encode |
|
||||
| [[hook_modifier_charset_encode]] charset_encode |
|
||||
extension.nom_tampon |
|
||||
Toute chaîne. |
|
||||
Chaîne encodée depuis UTF-8 vers le jeu de caractères trouvé pour
|
||||
l'extension/tampon.
|
||||
|
||||
| irc_color_decode |
|
||||
| [[hook_modifier_irc_color_decode]] irc_color_decode |
|
||||
"1" pour garder les couleurs, "0" pour les supprimer |
|
||||
Toute chaîne. |
|
||||
Chaîne avec les couleurs IRC converties en couleurs WeeChat (ou avec les
|
||||
couleurs IRC supprimées).
|
||||
|
||||
| irc_color_encode |
|
||||
| [[hook_modifier_irc_color_encode]] irc_color_encode |
|
||||
"1" pour garder les couleurs, "0" pour les supprimer |
|
||||
Toute chaîne. |
|
||||
Chaîne avec les couleurs IRC (ou avec les couleurs IRC supprimées).
|
||||
|
||||
| irc_color_decode_ansi +
|
||||
| [[hook_modifier_irc_color_decode_ansi]] irc_color_decode_ansi +
|
||||
_(WeeChat ≥ 1.0)_ |
|
||||
"1" pour garder les couleurs, "0" pour les supprimer |
|
||||
Toute chaîne. |
|
||||
Chaîne avec les couleurs ANSI converties en couleurs IRC (ou avec les couleurs
|
||||
ANSI supprimées).
|
||||
|
||||
| irc_command_auth +
|
||||
| [[hook_modifier_irc_command_auth]] irc_command_auth +
|
||||
_(WeeChat ≥ 0.4.1)_ |
|
||||
Nom du serveur |
|
||||
Commande d'authentification (par exemple : `+/msg nickserv identify password+`). |
|
||||
Commande avec le mot de passe caché (par exemple : `+/msg nickserv identify ********+`).
|
||||
|
||||
| irc_message_auth +
|
||||
| [[hook_modifier_irc_message_auth]] irc_message_auth +
|
||||
_(WeeChat ≥ 0.4.1)_ |
|
||||
Nom du serveur |
|
||||
Message affiché après `msg` envoyé à nickserv. |
|
||||
Message avec le mot de passe caché.
|
||||
|
||||
| irc_in_xxx ^(1)^ |
|
||||
| [[hook_modifier_irc_in_xxx]] irc_in_xxx ^(1)^ |
|
||||
Nom de serveur |
|
||||
Contenu du message reçu du serveur IRC (avant décodage du jeu de caractères). |
|
||||
Nouveau contenu du message.
|
||||
|
||||
| irc_in2_xxx ^(1)^ +
|
||||
| [[hook_modifier_irc_in2_xxx]] irc_in2_xxx ^(1)^ +
|
||||
_(WeeChat ≥ 0.3.5)_ |
|
||||
Nom de serveur |
|
||||
Contenu du message reçu du serveur IRC (après décodage du jeu de caractères). |
|
||||
Nouveau contenu du message.
|
||||
|
||||
| irc_out1_xxx ^(1)^ +
|
||||
| [[hook_modifier_irc_out1_xxx]] irc_out1_xxx ^(1)^ +
|
||||
_(WeeChat ≥ 0.3.7)_ |
|
||||
Nom de serveur |
|
||||
Contenu du message qui va être envoyé au serveur IRC avant découpage automatique
|
||||
(pour tenir dans les 512 octets par défaut). |
|
||||
Nouveau contenu du message.
|
||||
|
||||
| irc_out_xxx ^(1)^ |
|
||||
| [[hook_modifier_irc_out_xxx]] irc_out_xxx ^(1)^ |
|
||||
Nom de serveur |
|
||||
Contenu du message qui va être envoyé au serveur IRC après découpage automatique
|
||||
(pour tenir dans les 512 octets par défaut). |
|
||||
Nouveau contenu du message.
|
||||
|
||||
| color_decode_ansi +
|
||||
| [[hook_modifier_color_decode_ansi]] color_decode_ansi +
|
||||
_(WeeChat ≥ 1.0)_ |
|
||||
"1" pour garder les couleurs, "0" pour les supprimer |
|
||||
Toute chaîne. |
|
||||
Chaîne avec les couleurs ANSI converties en couleurs WeeChat (ou avec les
|
||||
couleurs ANSI supprimées).
|
||||
|
||||
| bar_condition_yyy ^(2)^ |
|
||||
| [[hook_modifier_bar_condition_yyy]] bar_condition_yyy ^(2)^ |
|
||||
Chaîne avec un pointeur vers la fenêtre ("0x123..") |
|
||||
Chaîne vide. |
|
||||
"1" pour afficher la barre, "0" pour la cacher.
|
||||
|
||||
| history_add +
|
||||
| [[hook_modifier_history_add]] history_add +
|
||||
_(WeeChat ≥ 0.3.2)_ |
|
||||
Chaîne avec un pointeur vers le tampon ("0x123..") |
|
||||
Contenu de la ligne de commande à ajouter à l'historique des commandes
|
||||
(tampon et global). |
|
||||
Chaîne ajoutée à l'historique des commandes.
|
||||
|
||||
| input_text_content |
|
||||
| [[hook_modifier_input_text_content]] input_text_content |
|
||||
Chaîne avec un pointeur vers le tampon ("0x123..") |
|
||||
Contenu de la ligne de commande. |
|
||||
Nouvelle chaîne pour la ligne de commande.
|
||||
|
||||
| input_text_display |
|
||||
| [[hook_modifier_input_text_display]] input_text_display |
|
||||
Chaîne avec un pointeur vers le tampon ("0x123..") |
|
||||
Contenu de la ligne de commande, sans le code du curseur dedans. |
|
||||
Nouvelle chaîne, pour affichage seulement (la ligne de commande n'est pas
|
||||
modifiée).
|
||||
|
||||
| input_text_display_with_cursor |
|
||||
| [[hook_modifier_input_text_display_with_cursor]] input_text_display_with_cursor |
|
||||
Chaîne avec un pointeur vers le tampon ("0x123..") |
|
||||
Contenu de la ligne de commande, avec le code du curseur dedans. |
|
||||
Nouvelle chaîne, pour affichage seulement (la ligne de commande n'est pas
|
||||
modifiée).
|
||||
|
||||
| input_text_for_buffer +
|
||||
| [[hook_modifier_input_text_for_buffer]] input_text_for_buffer +
|
||||
_(WeeChat ≥ 0.3.7)_ |
|
||||
Chaîne avec un pointeur vers le tampon ("0x123..") |
|
||||
Contenu de la ligne de commande envoyée au tampon (texte ou commande). |
|
||||
Nouveau contenu de la ligne de commande envoyée au tampon.
|
||||
|
||||
| weechat_print |
|
||||
| [[hook_modifier_weechat_print]] weechat_print |
|
||||
extension + ";" + nom_tampon + ";" + étiquettes |
|
||||
Message affiché. |
|
||||
Nouveau message affiché.
|
||||
|
@ -529,6 +529,7 @@ Liste des fonctions de l'API script :
|
||||
hook_process +
|
||||
hook_process_hashtable +
|
||||
hook_connect +
|
||||
hook_line +
|
||||
hook_print +
|
||||
hook_signal +
|
||||
hook_signal_send +
|
||||
|
@ -3650,8 +3650,8 @@ Un trigger a les options suivantes (les noms sont
|
||||
Lorsque l'option est `off`, le trigger est désactivé et les actions ne sont
|
||||
plus exécutées.
|
||||
|
||||
| hook | `signal`, `hsignal`, `modifier`, `print`, `command`, `command_run`,
|
||||
`timer`, `config`, `focus` |
|
||||
| hook | `signal`, `hsignal`, `modifier`, `line`, `print`, `command`,
|
||||
`command_run`, `timer`, `config`, `focus` |
|
||||
Le "hook" utilisé dans le trigger. Pour plus d'information, voir la
|
||||
link:weechat_plugin_api.fr.html#hooks[Référence API extension WeeChat / Hooks].
|
||||
|
||||
@ -3743,6 +3743,17 @@ points-virgules.
|
||||
`+5000\|input_text_display;5000\|history_add+` |
|
||||
link:weechat_plugin_api.fr.html#_hook_modifier[hook_modifier]
|
||||
|
||||
| line |
|
||||
1. type de tampon +
|
||||
2. nom de tampon +
|
||||
3. étiquettes |
|
||||
`+formatted+` +
|
||||
`+free+` +
|
||||
`+*;irc.freenode.*+` +
|
||||
`+*;irc.freenode.#weechat+` +
|
||||
`+formatted;irc.freenode.#weechat;irc_notice+` |
|
||||
link:weechat_plugin_api.en.html#_hook_line[hook_line]
|
||||
|
||||
| print |
|
||||
1. nom de tampon +
|
||||
2. étiquettes +
|
||||
@ -3829,6 +3840,7 @@ du type de hook :
|
||||
| signal | tg_signal_data
|
||||
| hsignal |
|
||||
| modifier | tg_string
|
||||
| line | message
|
||||
| print | tg_message
|
||||
| command | tg_argv_eol1
|
||||
| command_run | tg_command
|
||||
@ -4001,6 +4013,45 @@ Si le modificateur contient un message IRC, le message est analysé et des
|
||||
données supplémentaires sont ajoutées dans la table de hachage (voir le
|
||||
<<trigger_data_signal,"hook" signal>>).
|
||||
|
||||
[[trigger_data_line]]
|
||||
===== Line
|
||||
|
||||
La fonction de rappel "line" définit les variables suivantes dans la table
|
||||
de hachage :
|
||||
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
| Variable | Type | Description
|
||||
| buffer | pointeur | Tampon.
|
||||
| buffer_name | chaîne | Nom du tampon.
|
||||
| buffer_type | chaîne | Type de tampon ("formatted" ou "free").
|
||||
| y | chaîne | Numéro de ligne pour un tampon avec contenu libre (≥ 0), -1 pour un tampon avec contenu formaté.
|
||||
| date | chaîne | Date de la ligne (horodatage).
|
||||
| date_printed | chaîne | Date d'affichage de la ligne (horodatage).
|
||||
| str_time | chaîne | Date pour l'affichage. Elle peut contenir des codes couleur.
|
||||
| displayed | chaîne | "1" si affichée, "0" si la ligne est filtrée.
|
||||
| notify_level | chaîne | "0" = niveau bas, "1" = message, "2" = message privé, "3" = highlight
|
||||
| highlight | chaîne | "1" si highlight, sinon "0".
|
||||
| prefix | chaîne | Préfixe.
|
||||
| message | chaîne | Message.
|
||||
|===
|
||||
|
||||
Variables définies avec les étiquettes du message (elles sont définies aussi
|
||||
pour fonction de rappel "print" et pour le modificateur _weechat_print_) :
|
||||
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
| Variable | Type | Description
|
||||
| tg_tags | chaîne | Étiquettes du message (avec une virgule en début/fin de chaîne).
|
||||
| tg_tags_count | chaîne | Nombre d'étiquettes dans le message.
|
||||
| tg_tag_nick | chaîne | Pseudo (depuis l'étiquette "nick_xxx").
|
||||
| tg_tag_prefix_nick | chaîne | Couleur du pseudo dans le préfixe (depuis l'étiquette "prefix_nick_ccc").
|
||||
| tg_tag_host | chaîne | Nom d'utilisateur et hôte, format : utilisateur@hôte (depuis l'étiquette "host_xxx").
|
||||
| tg_tag_notify | chaîne | Niveau de notification (_none_, _message_, _private_, _highlight_).
|
||||
| tg_notify | chaîne | Niveau de notification, si différent de _none_.
|
||||
| tg_msg_pv | chaîne | "1" pour un message privé, sinon "0".
|
||||
|===
|
||||
|
||||
[[trigger_data_print]]
|
||||
===== Print
|
||||
|
||||
@ -4021,7 +4072,7 @@ hachage :
|
||||
|===
|
||||
|
||||
Variables définies avec les étiquettes du message (elles sont définies aussi
|
||||
pour le modificateur _weechat_print_) :
|
||||
pour la fonction de rappel "line" et pour le modificateur _weechat_print_) :
|
||||
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
|
@ -9402,6 +9402,271 @@ hook = weechat.hook_connect("", "my.server.org", 1234, 1, 0, "",
|
||||
"my_connect_cb", "")
|
||||
----
|
||||
|
||||
==== hook_line
|
||||
|
||||
_WeeChat ≥ 2.3._
|
||||
|
||||
Hook a line printed in a buffer.
|
||||
|
||||
When a line is printed in a buffer, hooks are called in this order:
|
||||
|
||||
* <<_hook_line,hook line>> (this hook)
|
||||
* <<_hook_modifier,hook modifier>>: <<hook_modifier_weechat_print,weechat_print>>
|
||||
* <<_hook_print,hook print>>
|
||||
|
||||
Prototipo:
|
||||
|
||||
[source,C]
|
||||
----
|
||||
struct t_hook *weechat_hook_line (const char *buffer_type,
|
||||
const char *buffer_name,
|
||||
const char *tags,
|
||||
struct t_hashtable *(*callback)(const void *pointer,
|
||||
void *data,
|
||||
struct t_hashtable *line),
|
||||
const void *callback_pointer,
|
||||
void *callback_data);
|
||||
----
|
||||
|
||||
Argomenti:
|
||||
|
||||
* _buffer_type_: catch lines on the given buffer type (if NULL or empty string,
|
||||
_formatted_ is the default):
|
||||
** _formatted_: catch lines on formatted buffers only (default)
|
||||
** _free_: catch lines on buffers with free content only
|
||||
** _*_: catch lines on all buffer types
|
||||
* _buffer_name_: comma-separated list of buffer masks
|
||||
(see <<_buffer_match_list,buffer_match_list>>); NULL, empty string or "*"
|
||||
matches any buffer
|
||||
* _tags_: catch only messages with these tags (optional): comma-separated list
|
||||
of tags that must be in message (logical "or"); it is possible to combine
|
||||
many tags as a logical "and" with separator `+++`; wildcard `+*+` is allowed
|
||||
in tags
|
||||
* _callback_: function called when a line is added in a buffer, arguments and
|
||||
return value:
|
||||
** _const void *pointer_: pointer
|
||||
** _void *data_: pointer
|
||||
** _struct t_hashtable *line_: hashtable with the line info, keys and values are
|
||||
strings (see table below)
|
||||
** return value: hashtable with new values (see table below)
|
||||
* _callback_pointer_: pointer given to callback when it is called by WeeChat
|
||||
* _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 hook is deleted
|
||||
|
||||
Valore restituito:
|
||||
|
||||
* puntatore al nuovo hook, NULL in caso di errore
|
||||
|
||||
Line data sent to the callback is a hashtable, with following values
|
||||
(keys and values are strings):
|
||||
|
||||
[width="100%",cols="^1,3,3,2",options="header"]
|
||||
|===
|
||||
| Key | Value (formatted buffer) | Value (free buffer) | Examples
|
||||
|
||||
| buffer |
|
||||
Buffer pointer. |
|
||||
Buffer pointer. |
|
||||
`+0x12345678+`
|
||||
|
||||
| buffer_name |
|
||||
Buffer name. |
|
||||
Buffer name. |
|
||||
`+core.weechat+` +
|
||||
`+irc.server.freenode+` +
|
||||
`+irc.freenode.#weechat+`
|
||||
|
||||
| buffer_type |
|
||||
"formatted" |
|
||||
"free" |
|
||||
`+formatted+` +
|
||||
`+free+`
|
||||
|
||||
| y |
|
||||
N/A ("-1"). |
|
||||
Line number (≥ "0"). |
|
||||
`+-1+` +
|
||||
`+8+`
|
||||
|
||||
| date |
|
||||
Line date (timestamp). |
|
||||
N/A ("0"). |
|
||||
`+1533792000+`
|
||||
|
||||
| date_printed |
|
||||
Date when line was displayed (timestamp). |
|
||||
N/A ("0"). |
|
||||
`+1533792012+`
|
||||
|
||||
| str_time |
|
||||
Date for display (possible color codes inside). |
|
||||
N/A (empty string). |
|
||||
`+09:07:20+`
|
||||
|
||||
| tags_count |
|
||||
Number of tags in the line (≥ "0"). |
|
||||
N/A ("0"). |
|
||||
`+2+`
|
||||
|
||||
| tags |
|
||||
Comma-separated list of tags. |
|
||||
N/A (empty string). |
|
||||
`+irc_join,nick_test+`
|
||||
|
||||
| displayed |
|
||||
"0" = line is filtered (hidden) +
|
||||
"1" = line is not filtered (displayed). |
|
||||
"0" = line is filtered (hidden) +
|
||||
"1" = line is not filtered (displayed). |
|
||||
`+0+` +
|
||||
`+1+`
|
||||
|
||||
| notify_level |
|
||||
"0" = low level +
|
||||
"1" = message +
|
||||
"2" = private message +
|
||||
"3" = highlight |
|
||||
N/A ("0"). |
|
||||
`+2+`
|
||||
|
||||
| highlight |
|
||||
"0" = no highlight +
|
||||
"1" = line has highlight. |
|
||||
N/A ("0"). |
|
||||
`+0+` +
|
||||
`+1+`
|
||||
|
||||
| prefix |
|
||||
Prefix of the line. |
|
||||
N/A (empty string). |
|
||||
`+-->+`
|
||||
|
||||
| message |
|
||||
Message of the line. |
|
||||
Message of the line. |
|
||||
`+test (~test@example.com) has joined #channel+`
|
||||
|===
|
||||
|
||||
The callback can return a hashtable with some fields to update the line.
|
||||
Any invalid value in a field is silently ignored by WeeChat.
|
||||
|
||||
The following keys can be set in the hashtable (keys and values are strings
|
||||
in this hashtable):
|
||||
|
||||
[width="100%",cols="^1,2,2,5",options="header"]
|
||||
|===
|
||||
| Key | Allowed value (formatted buffer) | Allowed value (free buffer) | Result
|
||||
|
||||
| buffer |
|
||||
Pointer of a buffer with formatted content. |
|
||||
Pointer of a buffer with free content. |
|
||||
The line is displayed on this buffer. +
|
||||
If the value is empty, the line is deleted (anything else in the hashtable
|
||||
is then ignored); the next hooks of type "line" are not called.
|
||||
|
||||
| buffer_name |
|
||||
Name of a buffer with formatted content. |
|
||||
Name of a buffer with free content. |
|
||||
The line is displayed on this buffer. +
|
||||
If `buffer` is also set, the value of `buffer_name` has higher priority and is used. +
|
||||
If the value is empty, the line is deleted (anything else in the hashtable
|
||||
is then ignored); the next hooks of type "line" are not called.
|
||||
|
||||
| y |
|
||||
N/A. |
|
||||
Integer (≥ "0"). |
|
||||
The line number is set to this value.
|
||||
|
||||
| date |
|
||||
Timestamp. |
|
||||
N/A. |
|
||||
The date is set to this value. +
|
||||
The value of `str_time` is updated accordingly.
|
||||
|
||||
| date_printed |
|
||||
Timestamp. |
|
||||
N/A. |
|
||||
The printed date is set to this timestamp (not displayed).
|
||||
|
||||
| str_time |
|
||||
String. |
|
||||
N/A. |
|
||||
This string is used to display the date line. +
|
||||
If `date` is also set, the value of `str_time` has higher priority and is used.
|
||||
|
||||
| tags |
|
||||
String. |
|
||||
N/A. |
|
||||
The line tags are replaced with this comma-separated list of tags. +
|
||||
The values of `notify_level` and `highlight` are updated accordingly.
|
||||
|
||||
| notify_level |
|
||||
Integer ("0" to "3"). |
|
||||
N/A. |
|
||||
The notify level is set to this value. The hotlist will be updated
|
||||
accordingly once the line is added in the buffer. +
|
||||
The value of `highlight` is updated accordingly. +
|
||||
If `tags` is also set, the value of `notify_level` has higher priority and is used.
|
||||
|
||||
| highlight |
|
||||
Integer ("0" or "1"). |
|
||||
N/A. |
|
||||
"0" disables highlight on the line, "1" forces a highlight on the line. +
|
||||
If `tags` or `notify_level` are set, the value of `highlight` has higher
|
||||
priority and is used.
|
||||
|
||||
| prefix |
|
||||
String. |
|
||||
N/A. |
|
||||
The line prefix is set to this value.
|
||||
|
||||
| message |
|
||||
String. |
|
||||
String. |
|
||||
The line message is set to this value.
|
||||
|===
|
||||
|
||||
Esempio in C:
|
||||
|
||||
[source,C]
|
||||
----
|
||||
int
|
||||
my_line_cb (const void *pointer, void *data, struct t_hasbtable *line)
|
||||
{
|
||||
struct t_hashtable *hashtable;
|
||||
|
||||
hashtable = weechat_hashtable_new (8,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
NULL,
|
||||
NULL);
|
||||
/* force a highlight on the line */
|
||||
weechat_hashtable_set (hashtable, "highlight", "1");
|
||||
return hashtable;
|
||||
}
|
||||
|
||||
/* catch lines with tag "irc_join" */
|
||||
struct t_hook *my_line_hook =
|
||||
weechat_hook_line ("", "", "irc_join", &my_line_cb, NULL, NULL);
|
||||
----
|
||||
|
||||
Script (Python):
|
||||
|
||||
[source,python]
|
||||
----
|
||||
# prototipo
|
||||
hook = weechat.hook_line(buffer_type, buffer_name, tags, callback, callback_data)
|
||||
|
||||
# esempio
|
||||
def my_line_cb(data, line):
|
||||
# force a highlight on the line
|
||||
return {"highlight": "1"}
|
||||
|
||||
# catch lines with tag "irc_join"
|
||||
hook = weechat.hook_line("", "", "irc_join", "my_line_cb", "")
|
||||
----
|
||||
|
||||
==== hook_print
|
||||
|
||||
// TRANSLATION MISSING
|
||||
@ -11099,62 +11364,62 @@ List of modifiers used by WeeChat and plugins:
|
||||
|===
|
||||
| Modificatore | Dati modificatore | Stringa | Output
|
||||
|
||||
| charset_decode |
|
||||
| [[hook_modifier_charset_decode]] charset_decode |
|
||||
plugin.buffer_name |
|
||||
Qualsiasi stringa. |
|
||||
Stringa codificata dal set caratteri trovato per plugin/buffer in UTF-8.
|
||||
|
||||
| charset_encode |
|
||||
| [[hook_modifier_charset_encode]] charset_encode |
|
||||
plugin.buffer_name |
|
||||
Qualsiasi stringa. |
|
||||
Stringa codificata da UTF-8 al set caratteri trovato per il plugin/buffer.
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| irc_color_decode |
|
||||
| [[hook_modifier_irc_color_decode]] irc_color_decode |
|
||||
"1" per mantenere i colori, "0" per rimuovere i colori |
|
||||
Qualsiasi stringa. |
|
||||
String with IRC colors converted to WeeChat colors (or IRC colors removed).
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| irc_color_encode |
|
||||
| [[hook_modifier_irc_color_encode]] irc_color_encode |
|
||||
"1" per mantenere i colori, "0" per rimuovere i colori |
|
||||
Qualsiasi stringa. |
|
||||
String with IRC colors (or IRC colors removed).
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| irc_color_decode_ansi +
|
||||
| [[hook_modifier_irc_color_decode_ansi]] irc_color_decode_ansi +
|
||||
_(WeeChat ≥ 1.0)_ |
|
||||
"1" per mantenere i colori, "0" per rimuovere i colori |
|
||||
Qualsiasi stringa. |
|
||||
String with ANSI colors converted to IRC colors (or ANSI colors removed).
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| irc_command_auth +
|
||||
| [[hook_modifier_irc_command_auth]] irc_command_auth +
|
||||
_(WeeChat ≥ 0.4.1)_ |
|
||||
Nome server |
|
||||
Authentication command (for example: `+/msg nickserv identify password+`). |
|
||||
Command with hidden password (for example: `+/msg nickserv identify ********+`).
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| irc_message_auth +
|
||||
| [[hook_modifier_irc_message_auth]] irc_message_auth +
|
||||
_(WeeChat ≥ 0.4.1)_ |
|
||||
Nome server |
|
||||
Message displayed after `/msg` sent to nickserv. |
|
||||
Message with hidden password.
|
||||
|
||||
| irc_in_xxx ^(1)^ |
|
||||
| [[hook_modifier_irc_in_xxx]] irc_in_xxx ^(1)^ |
|
||||
Nome server |
|
||||
Contenuto del messaggio ricevuto dal server IRC (prima della codifica del set caratteri). |
|
||||
Nuovo contenuto del messaggio.
|
||||
|
||||
| irc_in2_xxx ^(1)^ +
|
||||
| [[hook_modifier_irc_in2_xxx]] irc_in2_xxx ^(1)^ +
|
||||
_(WeeChat ≥ 0.3.5)_ |
|
||||
Nome server |
|
||||
Contenuto del messaggio ricevuto dal server IRC (dopo la codifica del set caratteri). |
|
||||
Nuovo contenuto del messaggio.
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| irc_out1_xxx ^(1)^ +
|
||||
| [[hook_modifier_irc_out1_xxx]] irc_out1_xxx ^(1)^ +
|
||||
_(WeeChat ≥ 0.3.7)_ |
|
||||
Nome server |
|
||||
Content of message about to be sent to IRC server before automatic split
|
||||
@ -11162,52 +11427,52 @@ List of modifiers used by WeeChat and plugins:
|
||||
Nuovo contenuto del messaggio.
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| irc_out_xxx ^(1)^ |
|
||||
| [[hook_modifier_irc_out_xxx]] irc_out_xxx ^(1)^ |
|
||||
Nome server |
|
||||
Content of message about to be sent to IRC server after automatic split
|
||||
(to fit in 512 bytes by default). |
|
||||
Nuovo contenuto del messaggio.
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| color_decode_ansi +
|
||||
| [[hook_modifier_color_decode_ansi]] color_decode_ansi +
|
||||
_(WeeChat ≥ 1.0)_ |
|
||||
"1" per mantenere i colori, "0" per rimuovere i colori |
|
||||
Qualsiasi stringa. |
|
||||
String with ANSI colors converted to WeeChat colors (or ANSI colors removed).
|
||||
|
||||
| bar_condition_yyy ^(2)^ |
|
||||
| [[hook_modifier_bar_condition_yyy]] bar_condition_yyy ^(2)^ |
|
||||
Stringa con puntatore alla finestra ("0x123..") |
|
||||
Stringa vuota. |
|
||||
"1" per visualizzare la barra, "0" per nasconderla.
|
||||
|
||||
| history_add +
|
||||
| [[hook_modifier_history_add]] history_add +
|
||||
_(WeeChat ≥ 0.3.2)_ |
|
||||
Stringa con puntatore al buffer ("0x123..") |
|
||||
Contenuto della riga di comando da aggiungere nella cronologia comandi (buffer e globale). |
|
||||
Stringa aggiunta alla cronologia comandi.
|
||||
|
||||
| input_text_content |
|
||||
| [[hook_modifier_input_text_content]] input_text_content |
|
||||
Stringa con puntatore al buffer ("0x123..") |
|
||||
Contenuto della riga di comando. |
|
||||
Nuovo contenuto della riga di comando.
|
||||
|
||||
| input_text_display |
|
||||
| [[hook_modifier_input_text_display]] input_text_display |
|
||||
Stringa con puntatore al buffer ("0x123..") |
|
||||
Contenuto della riga di comando, senza tag al cursore. |
|
||||
Nuova stringa, solo da mostrare (la riga di comando non viene modificata).
|
||||
|
||||
| input_text_display_with_cursor |
|
||||
| [[hook_modifier_input_text_display_with_cursor]] input_text_display_with_cursor |
|
||||
Stringa con puntatore al buffer ("0x123..") |
|
||||
Contenuto della riga di comando, con tag al cursore. |
|
||||
Nuova stringa, solo da mostrare (la riga di comando non viene modificata).
|
||||
|
||||
| input_text_for_buffer +
|
||||
| [[hook_modifier_input_text_for_buffer]] input_text_for_buffer +
|
||||
_(WeeChat ≥ 0.3.7)_ |
|
||||
Stringa con puntatore al buffer ("0x123..") |
|
||||
Contenuto della riga di comando inviata al buffer (testo o comando). |
|
||||
Nuovo contenuto della riga di comando inviata al buffer.
|
||||
|
||||
| weechat_print |
|
||||
| [[hook_modifier_weechat_print]] weechat_print |
|
||||
plugin + ";" + buffer_name + ";" + tags |
|
||||
Messaggio stampato. |
|
||||
Nuovo messaggio stampato.
|
||||
|
@ -537,6 +537,7 @@ Elenco di funzioni nelle API per gli script:
|
||||
hook_process +
|
||||
hook_process_hashtable +
|
||||
hook_connect +
|
||||
hook_line +
|
||||
hook_print +
|
||||
hook_signal +
|
||||
hook_signal_send +
|
||||
|
@ -3748,7 +3748,6 @@ Using triggers require you to know how the signals, modifiers, ... are working.
|
||||
So you might consider reading the
|
||||
link:weechat_plugin_api.it.html#hooks[WeeChat plugin API reference / Hooks].
|
||||
|
||||
// TRANSLATION MISSING
|
||||
[[trigger_default]]
|
||||
==== Default triggers
|
||||
|
||||
@ -3800,8 +3799,8 @@ A trigger has the following options (names are
|
||||
When option is `off`, the trigger is disabled and actions are not executed
|
||||
any more.
|
||||
|
||||
| hook | `signal`, `hsignal`, `modifier`, `print`, `command`, `command_run`,
|
||||
`timer`, `config`, `focus` |
|
||||
| hook | `signal`, `hsignal`, `modifier`, `line`, `print`, `command`,
|
||||
`command_run`, `timer`, `config`, `focus` |
|
||||
The hook used in trigger. For more information, see
|
||||
link:weechat_plugin_api.it.html#hooks[WeeChat plugin API reference / Hooks].
|
||||
|
||||
@ -3888,6 +3887,17 @@ The arguments depend on the hook used. They are separated by semicolons.
|
||||
`+5000\|input_text_display;5000\|history_add+` |
|
||||
link:weechat_plugin_api.it.html#_hook_modifier[hook_modifier]
|
||||
|
||||
| line |
|
||||
1. buffer type +
|
||||
2. buffer name +
|
||||
3. tags |
|
||||
`+formatted+` +
|
||||
`+free+` +
|
||||
`+*;irc.freenode.*+` +
|
||||
`+*;irc.freenode.#weechat+` +
|
||||
`+formatted;irc.freenode.#weechat;irc_notice+` |
|
||||
link:weechat_plugin_api.en.html#_hook_line[hook_line]
|
||||
|
||||
| print |
|
||||
1. buffer name +
|
||||
2. tags +
|
||||
@ -3971,6 +3981,7 @@ type:
|
||||
| signal | tg_signal_data
|
||||
| hsignal |
|
||||
| modifier | tg_string
|
||||
| line | message
|
||||
| print | tg_message
|
||||
| command | tg_argv_eol1
|
||||
| command_run | tg_command
|
||||
@ -4133,6 +4144,44 @@ For the _weechat_print_ modifier, variables using message tags are added (see
|
||||
If the modifier contains an IRC message, the message is parsed and extra data is
|
||||
added in hashtable (see <<trigger_data_signal,hook signal>>).
|
||||
|
||||
[[trigger_data_line]]
|
||||
===== Line
|
||||
|
||||
The "line" callback sets following variables in hashtable:
|
||||
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
| Variable | Type | Description
|
||||
| buffer | pointer | Buffer.
|
||||
| buffer_name | string | Buffer name.
|
||||
| buffer_type | string | Buffer type ("formatted" or "free").
|
||||
| y | string | Line number for a buffer with free content (≥ 0), -1 for a buffer with formatted content.
|
||||
| date | string | Line date (timestamp).
|
||||
| date_printed | string | Date when line was displayed (timestamp).
|
||||
| str_time | string | Date for display. It may contain color codes.
|
||||
| displayed | string | "1" if displayed, "0" if line filtered.
|
||||
| notify_level | string | "0" = low level, "1" = message, "2" = private message, "3" = highlight
|
||||
| highlight | string | "1" if highlight, otherwise "0".
|
||||
| prefix | string | Prefix.
|
||||
| message | string | Message.
|
||||
|===
|
||||
|
||||
Variables set using tags in message (they are also set in _print_ callback and
|
||||
modifier _weechat_print_):
|
||||
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
| Variable | Type | Description
|
||||
| tg_tags | string | Tags of message (with comma added at beginning/end of string).
|
||||
| tg_tags_count | string | Number of tags in message.
|
||||
| tg_tag_nick | string | Nick (from tag "nick_xxx").
|
||||
| tg_tag_prefix_nick | string | Color of nick in prefix (from tag "prefix_nick_ccc").
|
||||
| tg_tag_host | string | User name and host, format: username@host (from tag "host_xxx").
|
||||
| tg_tag_notify | string | Notify level (_none_, _message_, _private_, _highlight_).
|
||||
| tg_notify | string | Notify level, if different from _none_.
|
||||
| tg_msg_pv | string | "1" for a private message, otherwise "0".
|
||||
|===
|
||||
|
||||
[[trigger_data_print]]
|
||||
===== Print
|
||||
|
||||
@ -4151,8 +4200,8 @@ The "print" callback sets following variables in hashtable:
|
||||
| tg_message_nocolor | string | Message without color codes.
|
||||
|===
|
||||
|
||||
Variables set using tags in message (they are set in modifier _weechat_print_
|
||||
too):
|
||||
Variables set using tags in message (they are also set in _line_ callback and
|
||||
modifier _weechat_print_):
|
||||
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
@ -4161,7 +4210,6 @@ too):
|
||||
| tg_tags_count | string | Number of tags in message.
|
||||
| tg_tag_nick | string | Nick (from tag "nick_xxx").
|
||||
| tg_tag_prefix_nick | string | Color of nick in prefix (from tag "prefix_nick_ccc").
|
||||
// TRANSLATION MISSING
|
||||
| tg_tag_host | string | User name and host, format: username@host (from tag "host_xxx").
|
||||
| tg_tag_notify | string | Notify level (_none_, _message_, _private_, _highlight_).
|
||||
| tg_notify | string | Notify level, if different from _none_.
|
||||
@ -4305,7 +4353,6 @@ include::autogen/user/trigger_commands.adoc[]
|
||||
[[trigger_options]]
|
||||
==== Opzioni
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Sections in file _trigger.conf_:
|
||||
|
||||
[width="100%",cols="3m,6m,16",options="header"]
|
||||
|
@ -9070,6 +9070,281 @@ hook = weechat.hook_connect("", "my.server.org", 1234, 1, 0, "",
|
||||
"my_connect_cb", "")
|
||||
----
|
||||
|
||||
==== hook_line
|
||||
|
||||
_WeeChat ≥ 2.3._
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Hook a line printed in a buffer.
|
||||
|
||||
// TRANSLATION MISSING
|
||||
When a line is printed in a buffer, hooks are called in this order:
|
||||
|
||||
* <<_hook_line,hook line>> (this hook)
|
||||
* <<_hook_modifier,hook modifier>>: <<hook_modifier_weechat_print,weechat_print>>
|
||||
* <<_hook_print,hook print>>
|
||||
|
||||
プロトタイプ:
|
||||
|
||||
[source,C]
|
||||
----
|
||||
struct t_hook *weechat_hook_line (const char *buffer_type,
|
||||
const char *buffer_name,
|
||||
const char *tags,
|
||||
struct t_hashtable *(*callback)(const void *pointer,
|
||||
void *data,
|
||||
struct t_hashtable *line),
|
||||
const void *callback_pointer,
|
||||
void *callback_data);
|
||||
----
|
||||
|
||||
// TRANSLATION MISSING
|
||||
引数:
|
||||
|
||||
* _buffer_type_: catch lines on the given buffer type (if NULL or empty string,
|
||||
_formatted_ is the default):
|
||||
** _formatted_: catch lines on formatted buffers only (default)
|
||||
** _free_: catch lines on buffers with free content only
|
||||
** _*_: catch lines on all buffer types
|
||||
* _buffer_name_: comma-separated list of buffer masks
|
||||
(see <<_buffer_match_list,buffer_match_list>>); NULL, empty string or "*"
|
||||
matches any buffer
|
||||
* _tags_: catch only messages with these tags (optional): comma-separated list
|
||||
of tags that must be in message (logical "or"); it is possible to combine
|
||||
many tags as a logical "and" with separator `+++`; wildcard `+*+` is allowed
|
||||
in tags
|
||||
* _callback_: function called when a line is added in a buffer, arguments and
|
||||
return value:
|
||||
** _const void *pointer_: pointer
|
||||
** _void *data_: pointer
|
||||
** _struct t_hashtable *line_: hashtable with the line info, keys and values are
|
||||
strings (see table below)
|
||||
** return value: hashtable with new values (see table below)
|
||||
* _callback_pointer_: pointer given to callback when it is called by WeeChat
|
||||
* _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 hook is deleted
|
||||
|
||||
戻り値:
|
||||
|
||||
* 新しいフックへのポインタ、エラーが起きた場合は NULL
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Line data sent to the callback is a hashtable, with following values
|
||||
(keys and values are strings):
|
||||
|
||||
// TRANSLATION MISSING
|
||||
[width="100%",cols="^1,3,3,2",options="header"]
|
||||
|===
|
||||
| Key | Value (formatted buffer) | Value (free buffer) | Examples
|
||||
|
||||
| buffer |
|
||||
Buffer pointer. |
|
||||
Buffer pointer. |
|
||||
`+0x12345678+`
|
||||
|
||||
| buffer_name |
|
||||
Buffer name. |
|
||||
Buffer name. |
|
||||
`+core.weechat+` +
|
||||
`+irc.server.freenode+` +
|
||||
`+irc.freenode.#weechat+`
|
||||
|
||||
| buffer_type |
|
||||
"formatted" |
|
||||
"free" |
|
||||
`+formatted+` +
|
||||
`+free+`
|
||||
|
||||
| y |
|
||||
N/A ("-1"). |
|
||||
Line number (≥ "0"). |
|
||||
`+-1+` +
|
||||
`+8+`
|
||||
|
||||
| date |
|
||||
Line date (timestamp). |
|
||||
N/A ("0"). |
|
||||
`+1533792000+`
|
||||
|
||||
| date_printed |
|
||||
Date when line was displayed (timestamp). |
|
||||
N/A ("0"). |
|
||||
`+1533792012+`
|
||||
|
||||
| str_time |
|
||||
Date for display (possible color codes inside). |
|
||||
N/A (empty string). |
|
||||
`+09:07:20+`
|
||||
|
||||
| tags_count |
|
||||
Number of tags in the line (≥ "0"). |
|
||||
N/A ("0"). |
|
||||
`+2+`
|
||||
|
||||
| tags |
|
||||
Comma-separated list of tags. |
|
||||
N/A (empty string). |
|
||||
`+irc_join,nick_test+`
|
||||
|
||||
| displayed |
|
||||
"0" = line is filtered (hidden) +
|
||||
"1" = line is not filtered (displayed). |
|
||||
"0" = line is filtered (hidden) +
|
||||
"1" = line is not filtered (displayed). |
|
||||
`+0+` +
|
||||
`+1+`
|
||||
|
||||
| notify_level |
|
||||
"0" = low level +
|
||||
"1" = message +
|
||||
"2" = private message +
|
||||
"3" = highlight |
|
||||
N/A ("0"). |
|
||||
`+2+`
|
||||
|
||||
| highlight |
|
||||
"0" = no highlight +
|
||||
"1" = line has highlight. |
|
||||
N/A ("0"). |
|
||||
`+0+` +
|
||||
`+1+`
|
||||
|
||||
| prefix |
|
||||
Prefix of the line. |
|
||||
N/A (empty string). |
|
||||
`+-->+`
|
||||
|
||||
| message |
|
||||
Message of the line. |
|
||||
Message of the line. |
|
||||
`+test (~test@example.com) has joined #channel+`
|
||||
|===
|
||||
|
||||
// TRANSLATION MISSING
|
||||
The callback can return a hashtable with some fields to update the line.
|
||||
Any invalid value in a field is silently ignored by WeeChat.
|
||||
|
||||
// TRANSLATION MISSING
|
||||
The following keys can be set in the hashtable (keys and values are strings
|
||||
in this hashtable):
|
||||
|
||||
// TRANSLATION MISSING
|
||||
[width="100%",cols="^1,2,2,5",options="header"]
|
||||
|===
|
||||
| Key | Allowed value (formatted buffer) | Allowed value (free buffer) | Result
|
||||
|
||||
| buffer |
|
||||
Pointer of a buffer with formatted content. |
|
||||
Pointer of a buffer with free content. |
|
||||
The line is displayed on this buffer. +
|
||||
If the value is empty, the line is deleted (anything else in the hashtable
|
||||
is then ignored); the next hooks of type "line" are not called.
|
||||
|
||||
| buffer_name |
|
||||
Name of a buffer with formatted content. |
|
||||
Name of a buffer with free content. |
|
||||
The line is displayed on this buffer. +
|
||||
If `buffer` is also set, the value of `buffer_name` has higher priority and is used. +
|
||||
If the value is empty, the line is deleted (anything else in the hashtable
|
||||
is then ignored); the next hooks of type "line" are not called.
|
||||
|
||||
| y |
|
||||
N/A. |
|
||||
Integer (≥ "0"). |
|
||||
The line number is set to this value.
|
||||
|
||||
| date |
|
||||
Timestamp. |
|
||||
N/A. |
|
||||
The date is set to this value. +
|
||||
The value of `str_time` is updated accordingly.
|
||||
|
||||
| date_printed |
|
||||
Timestamp. |
|
||||
N/A. |
|
||||
The printed date is set to this timestamp (not displayed).
|
||||
|
||||
| str_time |
|
||||
String. |
|
||||
N/A. |
|
||||
This string is used to display the date line. +
|
||||
If `date` is also set, the value of `str_time` has higher priority and is used.
|
||||
|
||||
| tags |
|
||||
String. |
|
||||
N/A. |
|
||||
The line tags are replaced with this comma-separated list of tags. +
|
||||
The values of `notify_level` and `highlight` are updated accordingly.
|
||||
|
||||
| notify_level |
|
||||
Integer ("0" to "3"). |
|
||||
N/A. |
|
||||
The notify level is set to this value. The hotlist will be updated
|
||||
accordingly once the line is added in the buffer. +
|
||||
The value of `highlight` is updated accordingly. +
|
||||
If `tags` is also set, the value of `notify_level` has higher priority and is used.
|
||||
|
||||
| highlight |
|
||||
Integer ("0" or "1"). |
|
||||
N/A. |
|
||||
"0" disables highlight on the line, "1" forces a highlight on the line. +
|
||||
If `tags` or `notify_level` are set, the value of `highlight` has higher
|
||||
priority and is used.
|
||||
|
||||
| prefix |
|
||||
String. |
|
||||
N/A. |
|
||||
The line prefix is set to this value.
|
||||
|
||||
| message |
|
||||
String. |
|
||||
String. |
|
||||
The line message is set to this value.
|
||||
|===
|
||||
|
||||
// TRANSLATION MISSING
|
||||
C 言語での使用例:
|
||||
|
||||
[source,C]
|
||||
----
|
||||
int
|
||||
my_line_cb (const void *pointer, void *data, struct t_hasbtable *line)
|
||||
{
|
||||
struct t_hashtable *hashtable;
|
||||
|
||||
hashtable = weechat_hashtable_new (8,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
NULL,
|
||||
NULL);
|
||||
/* force a highlight on the line */
|
||||
weechat_hashtable_set (hashtable, "highlight", "1");
|
||||
return hashtable;
|
||||
}
|
||||
|
||||
/* catch lines with tag "irc_join" */
|
||||
struct t_hook *my_line_hook =
|
||||
weechat_hook_line ("", "", "irc_join", &my_line_cb, NULL, NULL);
|
||||
----
|
||||
|
||||
// TRANSLATION MISSING
|
||||
スクリプト (Python) での使用例:
|
||||
|
||||
[source,python]
|
||||
----
|
||||
# プロトタイプ
|
||||
hook = weechat.hook_line(buffer_type, buffer_name, tags, callback, callback_data)
|
||||
|
||||
# 例
|
||||
def my_line_cb(data, line):
|
||||
# force a highlight on the line
|
||||
return {"highlight": "1"}
|
||||
|
||||
# catch lines with tag "irc_join"
|
||||
hook = weechat.hook_line("", "", "irc_join", "my_line_cb", "")
|
||||
----
|
||||
|
||||
==== hook_print
|
||||
|
||||
_WeeChat バージョン 0.4.3、1.0、1.5 で更新。_
|
||||
@ -10628,107 +10903,107 @@ WeeChat とプラグインが使う修飾子のリスト:
|
||||
|===
|
||||
| 修飾子 | 修飾子データ | 文字列 | 出力
|
||||
|
||||
| charset_decode |
|
||||
| [[hook_modifier_charset_decode]] charset_decode |
|
||||
plugin.buffer_name |
|
||||
任意の文字列 |
|
||||
プラグインおよびバッファの文字セットから UTF-8 にデコードされた文字列
|
||||
|
||||
| charset_encode |
|
||||
| [[hook_modifier_charset_encode]] charset_encode |
|
||||
plugin.buffer_name |
|
||||
任意の文字列 |
|
||||
UTF-8 からプラグインおよびバッファの文字セットにエンコードされた文字列
|
||||
|
||||
| irc_color_decode |
|
||||
| [[hook_modifier_irc_color_decode]] irc_color_decode |
|
||||
色を保持する場合は "1"、削除する場合は "0" |
|
||||
任意の文字列 |
|
||||
WeeChat 色コードに変換された IRC 色コードを含む (または IRC 色コードを削除された) 文字列
|
||||
|
||||
| irc_color_encode |
|
||||
| [[hook_modifier_irc_color_encode]] irc_color_encode |
|
||||
色を保持する場合は "1"、削除する場合は "0" |
|
||||
任意の文字列 |
|
||||
IRC 色コードを含む (または IRC 色コードを削除された) 文字列
|
||||
|
||||
| irc_color_decode_ansi +
|
||||
| [[hook_modifier_irc_color_decode_ansi]] irc_color_decode_ansi +
|
||||
_(WeeChat バージョン 1.0 以上で利用可)_ |
|
||||
色を保持する場合は "1"、削除する場合は "0" |
|
||||
任意の文字列 |
|
||||
IRC 色コードに変換された ANSI 色コードを含む (または ANSI 色コードを削除された) 文字列
|
||||
|
||||
| irc_command_auth +
|
||||
| [[hook_modifier_irc_command_auth]] irc_command_auth +
|
||||
_(WeeChat バージョン 0.4.1 以上で利用可)_ |
|
||||
サーバ名 |
|
||||
認証コマンド (例: `+/msg nickserv identify password+`) |
|
||||
パスワードを隠したコマンド (例: `+/msg nickserv identify ********+`)
|
||||
|
||||
| irc_message_auth +
|
||||
| [[hook_modifier_irc_message_auth]] irc_message_auth +
|
||||
_(WeeChat バージョン 0.4.1 以上で利用可)_ |
|
||||
サーバ名 |
|
||||
`/msg` をサーバに送信した後に表示されるメッセージ |
|
||||
パスワードを隠したメッセージ
|
||||
|
||||
| irc_in_xxx ^(1)^ |
|
||||
| [[hook_modifier_irc_in_xxx]] irc_in_xxx ^(1)^ |
|
||||
サーバ名 |
|
||||
IRC サーバから受信したメッセージの内容 (文字セットをデコードする前) |
|
||||
メッセージの新しい内容
|
||||
|
||||
| irc_in2_xxx ^(1)^ +
|
||||
| [[hook_modifier_irc_in2_xxx]] irc_in2_xxx ^(1)^ +
|
||||
_(WeeChat バージョン 0.3.5 以上で利用可)_ |
|
||||
サーバ名 |
|
||||
IRC サーバから受信したメッセージの内容 (文字セットをデコードした後) |
|
||||
メッセージの新しい内容
|
||||
|
||||
| irc_out1_xxx ^(1)^ +
|
||||
| [[hook_modifier_irc_out1_xxx]] irc_out1_xxx ^(1)^ +
|
||||
_(WeeChat バージョン 0.3.7 以上で利用可)_ |
|
||||
サーバ名 |
|
||||
IRC サーバに送信するメッセージの内容
|
||||
(自動分割前、自動分割はデフォルトでメッセージを 512 バイト内に収まるように分割します)。|
|
||||
メッセージの新しい内容
|
||||
|
||||
| irc_out_xxx ^(1)^ |
|
||||
| [[hook_modifier_irc_out_xxx]] irc_out_xxx ^(1)^ |
|
||||
サーバ名 |
|
||||
IRC サーバに送信するメッセージの内容
|
||||
(自動分割後、自動分割はデフォルトでメッセージを 512 バイト内に収まるように分割します)。|
|
||||
メッセージの新しい内容
|
||||
|
||||
| color_decode_ansi +
|
||||
| [[hook_modifier_color_decode_ansi]] color_decode_ansi +
|
||||
_(WeeChat バージョン 1.0 以上で利用可)_ |
|
||||
色を保持する場合は "1"、削除する場合は "0" |
|
||||
任意の文字列 |
|
||||
WeeChat 色コードに変換された ANSI 色コードを含む (または ANSI 色コードを削除された) 文字列
|
||||
|
||||
| bar_condition_yyy ^(2)^ |
|
||||
| [[hook_modifier_bar_condition_yyy]] bar_condition_yyy ^(2)^ |
|
||||
ウィンドウへのポインタの文字列 ("0x123..") |
|
||||
空文字列 |
|
||||
バーを表示する場合は "1"、隠す場合は "0"
|
||||
|
||||
| history_add +
|
||||
| [[hook_modifier_history_add]] history_add +
|
||||
_(WeeChat バージョン 0.3.2 以上で利用可)_ |
|
||||
バッファへのポインタの文字列 ("0x123..") |
|
||||
コマンド履歴に追加するコマンドラインの内容 (バッファとグローバル履歴) |
|
||||
コマンド履歴に追加した文字列
|
||||
|
||||
| input_text_content |
|
||||
| [[hook_modifier_input_text_content]] input_text_content |
|
||||
バッファへのポインタの文字列 ("0x123..") |
|
||||
コマンドラインの内容 |
|
||||
コマンドラインの新しい内容
|
||||
|
||||
| input_text_display |
|
||||
| [[hook_modifier_input_text_display]] input_text_display |
|
||||
バッファへのポインタの文字列 ("0x123..") |
|
||||
カーソルタグを含まないコマンドラインの内容 |
|
||||
新しい文字列、表示のみ (コマンドラインは変化しない)
|
||||
|
||||
| input_text_display_with_cursor |
|
||||
| [[hook_modifier_input_text_display_with_cursor]] input_text_display_with_cursor |
|
||||
バッファへのポインタの文字列 ("0x123..") |
|
||||
カーソルタグを含むコマンドラインの内容 |
|
||||
新しい文字列、表示のみ (コマンドラインは変化しない)
|
||||
|
||||
| input_text_for_buffer +
|
||||
| [[hook_modifier_input_text_for_buffer]] input_text_for_buffer +
|
||||
_(WeeChat バージョン 0.3.7 以上で利用可)_ |
|
||||
バッファへのポインタの文字列 ("0x123..") |
|
||||
バッファに送信するコマンドラインの内容 (テキストまたはコマンド) |
|
||||
バッファに送信するコマンドラインの新しい内容
|
||||
|
||||
| weechat_print |
|
||||
| [[hook_modifier_weechat_print]] weechat_print |
|
||||
plugin + ";" + buffer_name + ";" + tags |
|
||||
表示されたメッセージ |
|
||||
表示される新しいメッセージ
|
||||
|
@ -525,6 +525,7 @@ link:weechat_plugin_api.ja.html[WeeChat プラグイン API リファレンス]
|
||||
hook_process +
|
||||
hook_process_hashtable +
|
||||
hook_connect +
|
||||
hook_line +
|
||||
hook_print +
|
||||
hook_signal +
|
||||
hook_signal_send +
|
||||
|
@ -3535,7 +3535,8 @@ WeeChat はデフォルトで 5
|
||||
オプションが `off`
|
||||
の場合、トリガは無効化され、アクションは実行されません。
|
||||
|
||||
| hook | `signal`、`hsignal`、`modifier`、`print`、`command`、`command_run`、`timer`、`config`、`focus` |
|
||||
| hook | `signal`、`hsignal`、`modifier`、`line`, `print`、`command`、
|
||||
`command_run`、`timer`、`config`、`focus` |
|
||||
トリガの中で使われるフック。より詳しい情報は
|
||||
link:weechat_plugin_api.ja.html#hooks[WeeChat プラグイン API リファレンス / フック]を参照してください。
|
||||
|
||||
@ -3621,6 +3622,18 @@ trigger.trigger.beep.post_action = none
|
||||
`+5000\|input_text_display;5000\|history_add+` |
|
||||
link:weechat_plugin_api.ja.html#_hook_modifier[hook_modifier]
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| line |
|
||||
1. buffer type +
|
||||
2. buffer name +
|
||||
3. tags |
|
||||
`+formatted+` +
|
||||
`+free+` +
|
||||
`+*;irc.freenode.*+` +
|
||||
`+*;irc.freenode.#weechat+` +
|
||||
`+formatted;irc.freenode.#weechat;irc_notice+` |
|
||||
link:weechat_plugin_api.en.html#_hook_line[hook_line]
|
||||
|
||||
| print |
|
||||
1. バッファ名 +
|
||||
2. タグ +
|
||||
@ -3704,6 +3717,7 @@ _var_
|
||||
| signal | tg_signal_data
|
||||
| hsignal |
|
||||
| modifier | tg_string
|
||||
| line | message
|
||||
| print | tg_message
|
||||
| command | tg_argv_eol1
|
||||
| command_run | tg_command
|
||||
@ -3864,6 +3878,47 @@ _weechat_print_ 修飾子では、メッセージタグを使う変数 (下の
|
||||
修飾子が IRC メッセージを含む場合、メッセージは解析され追加のデータがハッシュテーブルに追加されます
|
||||
(<<trigger_data_signal,Signal>> を参照)。
|
||||
|
||||
[[trigger_data_line]]
|
||||
===== Line
|
||||
|
||||
"line" コールバックは以下の変数をハッシュテーブルに格納します:
|
||||
|
||||
// TRANSLATION MISSING
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
| 変数 | 型 | 説明
|
||||
| Variable | Type | Description
|
||||
| buffer | pointer | Buffer.
|
||||
| buffer_name | string | Buffer name.
|
||||
| buffer_type | string | Buffer type ("formatted" or "free").
|
||||
| y | string | Line number for a buffer with free content (≥ 0), -1 for a buffer with formatted content.
|
||||
| date | string | Line date (timestamp).
|
||||
| date_printed | string | Date when line was displayed (timestamp).
|
||||
| str_time | string | Date for display. It may contain color codes.
|
||||
| displayed | string | "1" if displayed, "0" if line filtered.
|
||||
| notify_level | string | "0" = low level, "1" = message, "2" = private message, "3" = highlight
|
||||
| highlight | string | "1" if highlight, otherwise "0".
|
||||
| prefix | string | Prefix.
|
||||
| message | string | Message.
|
||||
|===
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Variables set using tags in message (they are also set in _print_ callback and
|
||||
modifier _weechat_print_):
|
||||
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
| 変数 | 型 | 説明
|
||||
| tg_tags | string | メッセージのタグ (文字列の最初と最後にコンマが追加されます)
|
||||
| tg_tags_count | string | メッセージのタグの個数
|
||||
| tg_tag_nick | string | ニックネーム ("nick_xxx" タグから)
|
||||
| tg_tag_prefix_nick | string | プレフィックスで使うニックネームの色 ("prefix_nick_ccc" タグから)
|
||||
| tg_tag_host | string | ユーザ名とホスト名、書式: username@host ("host_xxx" タグから)
|
||||
| tg_tag_notify | string | 通知レベル (_none_、_message_、_private_、_highlight_)
|
||||
| tg_notify | string | 通知レベルが _none_ 以外の場合、その通知レベル
|
||||
| tg_msg_pv | string | プライベートメッセージの場合 "1"、それ以外は "0"
|
||||
|===
|
||||
|
||||
[[trigger_data_print]]
|
||||
===== Print
|
||||
|
||||
@ -3882,8 +3937,9 @@ _weechat_print_ 修飾子では、メッセージタグを使う変数 (下の
|
||||
| tg_message_nocolor | string | 色コードを削除したメッセージ
|
||||
|===
|
||||
|
||||
メッセージのタグをもとにして変数が格納されます
|
||||
(変数は _weechat_print_ 修飾子でも格納されます):
|
||||
// TRANSLATION MISSING
|
||||
Variables set using tags in message (they are also set in _line_ callback and
|
||||
modifier _weechat_print_):
|
||||
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
|
@ -523,6 +523,7 @@ Lista funkcji w API skryptów:
|
||||
hook_process +
|
||||
hook_process_hashtable +
|
||||
hook_connect +
|
||||
hook_line +
|
||||
hook_print +
|
||||
hook_signal +
|
||||
hook_signal_send +
|
||||
|
@ -3567,8 +3567,8 @@ Trigger posiada następujące opcje (nazwy to `trigger.trigger.<nazwa>.<opcja>`)
|
||||
Kiedy wartość ustawiona jest na `off`, trigger jest wyłączony i akcje nie będą
|
||||
więcej wykonywane.
|
||||
|
||||
| hook | `signal`, `hsignal`, `modifier`, `print`, `command`, `command_run`,
|
||||
`timer`, `config`, `focus` |
|
||||
| hook | `signal`, `hsignal`, `modifier`, `line`, `print`, `command`,
|
||||
`command_run`, `timer`, `config`, `focus` |
|
||||
Zdarzenia używane przez trigger. Więcej informacji można znaleźć w
|
||||
link:weechat_plugin_api.en.html#hooks[WeeChat Plugin API Reference / Hooks] (Angielski).
|
||||
|
||||
@ -3655,6 +3655,18 @@ Argumenty zależą od rodzaju uchwytu. Są oddzielane średnikami.
|
||||
`+5000\|input_text_display;5000\|history_add+` |
|
||||
link:weechat_plugin_api.en.html#_hook_modifier[hook_modifier] (Angielski)
|
||||
|
||||
// TRANSLATION MISSING
|
||||
| line |
|
||||
1. buffer type +
|
||||
2. buffer name +
|
||||
3. tags |
|
||||
`+formatted+` +
|
||||
`+free+` +
|
||||
`+*;irc.freenode.*+` +
|
||||
`+*;irc.freenode.#weechat+` +
|
||||
`+formatted;irc.freenode.#weechat;irc_notice+` |
|
||||
link:weechat_plugin_api.en.html#_hook_line[hook_line]
|
||||
|
||||
| print |
|
||||
1. nazwa buforu +
|
||||
2. tagi +
|
||||
@ -3739,6 +3751,7 @@ od typu uchwytu:
|
||||
| signal | tg_signal_data
|
||||
| hsignal |
|
||||
| modifier | tg_string
|
||||
| line | message
|
||||
| print | tg_message
|
||||
| command | tg_argv_eol1
|
||||
| command_run | tg_command
|
||||
@ -3899,6 +3912,46 @@ zobacz <<trigger_data_print,hook print>> poniżej), oraz następujące zmienne:
|
||||
Jeśli modyfikator zawiera wiadomość IRC, wiadomość jest parsowana i dodawane są
|
||||
dodatkowe dane do tablicy hashy (zobacz <<trigger_data_signal,hook signal>>).
|
||||
|
||||
[[trigger_data_line]]
|
||||
===== Line
|
||||
|
||||
Callback "line" ustawia następujące zmienne w tablicy hashy:
|
||||
|
||||
// TRANSLATION MISSING
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
| Zmienna | Typ | Opis
|
||||
| buffer | wskaźnik | Buffer.
|
||||
| buffer_name | ciąg | Buffer name.
|
||||
| buffer_type | ciąg | Buffer type ("formatted" or "free").
|
||||
| y | ciąg | Line number for a buffer with free content (≥ 0), -1 for a buffer with formatted content.
|
||||
| date | ciąg | Line date (timestamp).
|
||||
| date_printed | ciąg | Date when line was displayed (timestamp).
|
||||
| str_time | ciąg | Date for display. It may contain color codes.
|
||||
| displayed | ciąg | "1" if displayed, "0" if line filtered.
|
||||
| notify_level | ciąg | "0" = low level, "1" = message, "2" = private message, "3" = highlight
|
||||
| highlight | ciąg | "1" if highlight, otherwise "0".
|
||||
| prefix | ciąg | Prefix.
|
||||
| message | ciąg | Message.
|
||||
|===
|
||||
|
||||
// TRANSLATION MISSING
|
||||
Variables set using tags in message (they are also set in _print_ callback and
|
||||
modifier _weechat_print_):
|
||||
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
| Zmienna | Typ | Opis
|
||||
| tg_tags | ciąg | Tagi wiadomości (z przecinkiem dodanym na początku/końcu ciągu).
|
||||
| tg_tags_count | ciąg | Liczba tagów w wiadomości.
|
||||
| tg_tag_nick | ciąg | Nick (z tagu "nick_xxx").
|
||||
| tg_tag_prefix_nick | ciąg | Kolor nicka w prefiksie (z tagu "prefix_nick_ccc").
|
||||
| tg_tag_host | ciąg | Nazwa użytkownika i host, format: username@host (z tagu "host_xxx").
|
||||
| tg_tag_notify | ciąg | Poziom powiadomień (_none_, _message_, _private_, _highlight_).
|
||||
| tg_notify | ciąg | Poziom powiadomień, jeśli różny od _none_.
|
||||
| tg_msg_pv | ciąg | "1" dla prywatnej wiadomości, inaczej "0".
|
||||
|===
|
||||
|
||||
[[trigger_data_print]]
|
||||
===== Print
|
||||
|
||||
@ -3917,8 +3970,9 @@ Callback "print" ustawia następujące zmienne w tablicy hashy:
|
||||
| tg_message_nocolor | ciąg | Wiadomość bez kodów kolorów.
|
||||
|===
|
||||
|
||||
Zmienne ustawiane przez tagi w wiadomości (są ustawiane też przez modyfikator
|
||||
_weechat_print_):
|
||||
// TRANSLATION MISSING
|
||||
Variables set using tags in message (they are also set in _line_ callback and
|
||||
modifier _weechat_print_):
|
||||
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
|
@ -24,6 +24,34 @@ struct t_hashtable;
|
||||
struct t_infolist;
|
||||
struct t_infolist_item;
|
||||
|
||||
/*
|
||||
* Macros to set various values as string value in the hashtable;
|
||||
* variable hashtable must be defined and str_value must be a static
|
||||
* area where the value as string will be put (the size must be large enough
|
||||
* for any value stored with these macros).
|
||||
*/
|
||||
#define HASHTABLE_SET_STR(__name, __string) \
|
||||
hashtable_set (hashtable, __name, __string);
|
||||
#define HASHTABLE_SET_STR_NOT_NULL(__name, __string) \
|
||||
hashtable_set (hashtable, __name, (__string) ? __string : "");
|
||||
#define HASHTABLE_SET_INT(__name, __int) \
|
||||
snprintf (str_value, sizeof (str_value), "%d", __int); \
|
||||
hashtable_set (hashtable, __name, str_value);
|
||||
#define HASHTABLE_SET_TIME(__name, __time) \
|
||||
snprintf (str_value, sizeof (str_value), "%lld", (long long)__time); \
|
||||
hashtable_set (hashtable, __name, str_value);
|
||||
#define HASHTABLE_SET_PTR(__name, __pointer) \
|
||||
if (__pointer) \
|
||||
{ \
|
||||
snprintf (str_value, sizeof (str_value), \
|
||||
"0x%lx", (long unsigned int)__pointer); \
|
||||
hashtable_set (hashtable, __name, str_value); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
hashtable_set (hashtable, __name, ""); \
|
||||
}
|
||||
|
||||
typedef unsigned long long (t_hashtable_hash_key)(struct t_hashtable *hashtable,
|
||||
const void *key);
|
||||
typedef int (t_hashtable_keycmp)(struct t_hashtable *hashtable,
|
||||
|
@ -65,8 +65,8 @@
|
||||
|
||||
|
||||
char *hook_type_string[HOOK_NUM_TYPES] =
|
||||
{ "command", "command_run", "timer", "fd", "process", "connect", "print",
|
||||
"signal", "hsignal", "config", "completion", "modifier",
|
||||
{ "command", "command_run", "timer", "fd", "process", "connect", "line",
|
||||
"print", "signal", "hsignal", "config", "completion", "modifier",
|
||||
"info", "info_hashtable", "infolist", "hdata", "focus" };
|
||||
struct t_hook *weechat_hooks[HOOK_NUM_TYPES]; /* list of hooks */
|
||||
struct t_hook *last_weechat_hook[HOOK_NUM_TYPES]; /* last hook */
|
||||
@ -984,6 +984,9 @@ hook_command_run_exec (struct t_gui_buffer *buffer, const char *command)
|
||||
char *command2;
|
||||
const char *ptr_command;
|
||||
|
||||
if (!weechat_hooks[HOOK_TYPE_COMMAND_RUN])
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
ptr_command = command;
|
||||
command2 = NULL;
|
||||
|
||||
@ -1279,6 +1282,9 @@ hook_timer_exec ()
|
||||
struct timeval tv_time;
|
||||
struct t_hook *ptr_hook, *next_hook;
|
||||
|
||||
if (!weechat_hooks[HOOK_TYPE_TIMER])
|
||||
return;
|
||||
|
||||
hook_timer_check_system_clock ();
|
||||
|
||||
gettimeofday (&tv_time, NULL);
|
||||
@ -1409,6 +1415,9 @@ hook_fd_exec ()
|
||||
int i, num_fd, timeout, ready, found;
|
||||
struct t_hook *ptr_hook, *next_hook;
|
||||
|
||||
if (!weechat_hooks[HOOK_TYPE_FD])
|
||||
return;
|
||||
|
||||
/* build an array of "struct pollfd" for poll() */
|
||||
num_fd = 0;
|
||||
for (ptr_hook = weechat_hooks[HOOK_TYPE_FD]; ptr_hook;
|
||||
@ -2404,6 +2413,146 @@ hook_connect_gnutls_set_certificates (gnutls_session_t tls_session,
|
||||
}
|
||||
#endif /* HAVE_GNUTLS */
|
||||
|
||||
/*
|
||||
* Hooks a line added in a buffer.
|
||||
*
|
||||
* Returns pointer to new hook, NULL if error.
|
||||
*/
|
||||
|
||||
struct t_hook *
|
||||
hook_line (struct t_weechat_plugin *plugin, const char *buffer_type,
|
||||
const char *buffer_name, const char *tags,
|
||||
t_hook_callback_line *callback, const void *callback_pointer,
|
||||
void *callback_data)
|
||||
{
|
||||
struct t_hook *new_hook;
|
||||
struct t_hook_line *new_hook_line;
|
||||
|
||||
if (!callback)
|
||||
return NULL;
|
||||
|
||||
new_hook = malloc (sizeof (*new_hook));
|
||||
if (!new_hook)
|
||||
return NULL;
|
||||
new_hook_line = malloc (sizeof (*new_hook_line));
|
||||
if (!new_hook_line)
|
||||
{
|
||||
free (new_hook);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
hook_init_data (new_hook, plugin, HOOK_TYPE_LINE, HOOK_PRIORITY_DEFAULT,
|
||||
callback_pointer, callback_data);
|
||||
|
||||
new_hook->hook_data = new_hook_line;
|
||||
new_hook_line->callback = callback;
|
||||
if (!buffer_type || !buffer_type[0])
|
||||
new_hook_line->buffer_type = GUI_BUFFER_TYPE_FORMATTED;
|
||||
else if (strcmp (buffer_type, "*") == 0)
|
||||
new_hook_line->buffer_type = -1;
|
||||
else
|
||||
new_hook_line->buffer_type = gui_buffer_search_type (buffer_type);
|
||||
new_hook_line->buffers = string_split (
|
||||
(buffer_name && buffer_name[0]) ? buffer_name : "*",
|
||||
",", 0, 0, &new_hook_line->num_buffers);
|
||||
new_hook_line->tags_array = string_split_tags (tags,
|
||||
&new_hook_line->tags_count);
|
||||
|
||||
hook_add_to_list (new_hook);
|
||||
|
||||
return new_hook;
|
||||
}
|
||||
|
||||
/*
|
||||
* Executes a line hook and updates the line data.
|
||||
*/
|
||||
|
||||
void
|
||||
hook_line_exec (struct t_gui_line *line)
|
||||
{
|
||||
struct t_hook *ptr_hook, *next_hook;
|
||||
struct t_hashtable *hashtable, *hashtable2;
|
||||
char str_value[128], *str_tags;
|
||||
|
||||
if (!weechat_hooks[HOOK_TYPE_LINE])
|
||||
return;
|
||||
|
||||
hashtable = NULL;
|
||||
|
||||
hook_exec_start ();
|
||||
|
||||
ptr_hook = weechat_hooks[HOOK_TYPE_LINE];
|
||||
while (ptr_hook)
|
||||
{
|
||||
next_hook = ptr_hook->next_hook;
|
||||
|
||||
if (!ptr_hook->deleted && !ptr_hook->running
|
||||
&& ((HOOK_LINE(ptr_hook, buffer_type) == -1)
|
||||
|| ((int)(line->data->buffer->type) == (HOOK_LINE(ptr_hook, buffer_type))))
|
||||
&& gui_buffer_match_list_split (line->data->buffer,
|
||||
HOOK_LINE(ptr_hook, num_buffers),
|
||||
HOOK_LINE(ptr_hook, buffers))
|
||||
&& (!HOOK_LINE(ptr_hook, tags_array)
|
||||
|| gui_line_match_tags (line->data,
|
||||
HOOK_LINE(ptr_hook, tags_count),
|
||||
HOOK_LINE(ptr_hook, tags_array))))
|
||||
{
|
||||
/* create the hashtable that will be sent to callback */
|
||||
if (!hashtable)
|
||||
{
|
||||
hashtable = hashtable_new (32,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
NULL, NULL);
|
||||
if (!hashtable)
|
||||
break;
|
||||
}
|
||||
HASHTABLE_SET_PTR("buffer", line->data->buffer);
|
||||
HASHTABLE_SET_PTR("buffer_name", line->data->buffer->full_name);
|
||||
HASHTABLE_SET_PTR("buffer_type",
|
||||
gui_buffer_type_string[line->data->buffer->type]);
|
||||
HASHTABLE_SET_INT("y", line->data->y);
|
||||
HASHTABLE_SET_TIME("date", line->data->date);
|
||||
HASHTABLE_SET_TIME("date_printed", line->data->date_printed);
|
||||
HASHTABLE_SET_STR_NOT_NULL("str_time", line->data->str_time);
|
||||
HASHTABLE_SET_INT("tags_count", line->data->tags_count);
|
||||
str_tags = string_build_with_split_string (
|
||||
(const char **)line->data->tags_array, ",");
|
||||
HASHTABLE_SET_STR_NOT_NULL("tags", str_tags);
|
||||
if (str_tags)
|
||||
free (str_tags);
|
||||
HASHTABLE_SET_INT("displayed", line->data->displayed);
|
||||
HASHTABLE_SET_INT("notify_level", line->data->notify_level);
|
||||
HASHTABLE_SET_INT("highlight", line->data->highlight);
|
||||
HASHTABLE_SET_STR_NOT_NULL("prefix", line->data->prefix);
|
||||
HASHTABLE_SET_STR_NOT_NULL("message", line->data->message);
|
||||
|
||||
/* run callback */
|
||||
ptr_hook->running = 1;
|
||||
hashtable2 = (HOOK_LINE(ptr_hook, callback))
|
||||
(ptr_hook->callback_pointer,
|
||||
ptr_hook->callback_data,
|
||||
hashtable);
|
||||
ptr_hook->running = 0;
|
||||
|
||||
if (hashtable2)
|
||||
{
|
||||
gui_line_hook_update (line, hashtable, hashtable2);
|
||||
hashtable_free (hashtable2);
|
||||
if (!line->data->buffer)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ptr_hook = next_hook;
|
||||
}
|
||||
|
||||
hook_exec_end ();
|
||||
|
||||
if (hashtable)
|
||||
hashtable_free (hashtable);
|
||||
}
|
||||
|
||||
/*
|
||||
* Hooks a message printed by WeeChat.
|
||||
*
|
||||
@ -2459,6 +2608,9 @@ hook_print_exec (struct t_gui_buffer *buffer, struct t_gui_line *line)
|
||||
struct t_hook *ptr_hook, *next_hook;
|
||||
char *prefix_no_color, *message_no_color;
|
||||
|
||||
if (!weechat_hooks[HOOK_TYPE_PRINT])
|
||||
return;
|
||||
|
||||
if (!line->data->message || !line->data->message[0])
|
||||
return;
|
||||
|
||||
@ -2487,26 +2639,25 @@ hook_print_exec (struct t_gui_buffer *buffer, struct t_gui_line *line)
|
||||
&& (!HOOK_PRINT(ptr_hook, message)
|
||||
|| !HOOK_PRINT(ptr_hook, message)[0]
|
||||
|| string_strcasestr (prefix_no_color, HOOK_PRINT(ptr_hook, message))
|
||||
|| string_strcasestr (message_no_color, HOOK_PRINT(ptr_hook, message))))
|
||||
{
|
||||
/* check if tags match */
|
||||
if (!HOOK_PRINT(ptr_hook, tags_array)
|
||||
|| string_strcasestr (message_no_color, HOOK_PRINT(ptr_hook, message)))
|
||||
&& (!HOOK_PRINT(ptr_hook, tags_array)
|
||||
|| gui_line_match_tags (line->data,
|
||||
HOOK_PRINT(ptr_hook, tags_count),
|
||||
HOOK_PRINT(ptr_hook, tags_array)))
|
||||
{
|
||||
/* run callback */
|
||||
ptr_hook->running = 1;
|
||||
(void) (HOOK_PRINT(ptr_hook, callback))
|
||||
(ptr_hook->callback_pointer,
|
||||
ptr_hook->callback_data, buffer, line->data->date,
|
||||
line->data->tags_count,
|
||||
(const char **)line->data->tags_array,
|
||||
(int)line->data->displayed, (int)line->data->highlight,
|
||||
(HOOK_PRINT(ptr_hook, strip_colors)) ? prefix_no_color : line->data->prefix,
|
||||
(HOOK_PRINT(ptr_hook, strip_colors)) ? message_no_color : line->data->message);
|
||||
ptr_hook->running = 0;
|
||||
}
|
||||
HOOK_PRINT(ptr_hook, tags_array))))
|
||||
{
|
||||
/* run callback */
|
||||
ptr_hook->running = 1;
|
||||
(void) (HOOK_PRINT(ptr_hook, callback))
|
||||
(ptr_hook->callback_pointer,
|
||||
ptr_hook->callback_data,
|
||||
buffer,
|
||||
line->data->date,
|
||||
line->data->tags_count,
|
||||
(const char **)line->data->tags_array,
|
||||
(int)line->data->displayed, (int)line->data->highlight,
|
||||
(HOOK_PRINT(ptr_hook, strip_colors)) ? prefix_no_color : line->data->prefix,
|
||||
(HOOK_PRINT(ptr_hook, strip_colors)) ? message_no_color : line->data->message);
|
||||
ptr_hook->running = 0;
|
||||
}
|
||||
|
||||
ptr_hook = next_hook;
|
||||
@ -2861,6 +3012,9 @@ hook_completion_exec (struct t_weechat_plugin *plugin,
|
||||
/* make C compiler happy */
|
||||
(void) plugin;
|
||||
|
||||
if (!weechat_hooks[HOOK_TYPE_COMPLETION])
|
||||
return;
|
||||
|
||||
hook_exec_start ();
|
||||
|
||||
pos = strchr (completion_item, ':');
|
||||
@ -3991,6 +4145,13 @@ unhook (struct t_hook *hook)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case HOOK_TYPE_LINE:
|
||||
if (HOOK_LINE(hook, tags_array))
|
||||
{
|
||||
string_free_split_tags (HOOK_LINE(hook, tags_array));
|
||||
HOOK_LINE(hook, tags_array) = NULL;
|
||||
}
|
||||
break;
|
||||
case HOOK_TYPE_PRINT:
|
||||
if (HOOK_PRINT(hook, tags_array))
|
||||
{
|
||||
@ -4251,349 +4412,318 @@ hook_add_to_infolist_pointer (struct t_infolist *infolist, struct t_hook *hook)
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback_data", (void *)hook->callback_data))
|
||||
return 0;
|
||||
|
||||
/* hook deleted? return only hook info above */
|
||||
if (hook->deleted)
|
||||
return 1;
|
||||
|
||||
/* hook not deleted: add extra hook info */
|
||||
switch (hook->type)
|
||||
{
|
||||
case HOOK_TYPE_COMMAND:
|
||||
if (!hook->deleted)
|
||||
{
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_COMMAND(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "command", HOOK_COMMAND(hook, command)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description",
|
||||
HOOK_COMMAND(hook, description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description_nls",
|
||||
(HOOK_COMMAND(hook, description)
|
||||
&& HOOK_COMMAND(hook, description)[0]) ?
|
||||
_(HOOK_COMMAND(hook, description)) : ""))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args",
|
||||
HOOK_COMMAND(hook, args)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args_nls",
|
||||
(HOOK_COMMAND(hook, args)
|
||||
&& HOOK_COMMAND(hook, args)[0]) ?
|
||||
_(HOOK_COMMAND(hook, args)) : ""))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args_description",
|
||||
HOOK_COMMAND(hook, args_description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args_description_nls",
|
||||
(HOOK_COMMAND(hook, args_description)
|
||||
&& HOOK_COMMAND(hook, args_description)[0]) ?
|
||||
_(HOOK_COMMAND(hook, args_description)) : ""))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "completion", HOOK_COMMAND(hook, completion)))
|
||||
return 0;
|
||||
}
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_COMMAND(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "command", HOOK_COMMAND(hook, command)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description",
|
||||
HOOK_COMMAND(hook, description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description_nls",
|
||||
(HOOK_COMMAND(hook, description)
|
||||
&& HOOK_COMMAND(hook, description)[0]) ?
|
||||
_(HOOK_COMMAND(hook, description)) : ""))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args",
|
||||
HOOK_COMMAND(hook, args)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args_nls",
|
||||
(HOOK_COMMAND(hook, args)
|
||||
&& HOOK_COMMAND(hook, args)[0]) ?
|
||||
_(HOOK_COMMAND(hook, args)) : ""))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args_description",
|
||||
HOOK_COMMAND(hook, args_description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args_description_nls",
|
||||
(HOOK_COMMAND(hook, args_description)
|
||||
&& HOOK_COMMAND(hook, args_description)[0]) ?
|
||||
_(HOOK_COMMAND(hook, args_description)) : ""))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "completion", HOOK_COMMAND(hook, completion)))
|
||||
return 0;
|
||||
break;
|
||||
case HOOK_TYPE_COMMAND_RUN:
|
||||
if (!hook->deleted)
|
||||
{
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_COMMAND_RUN(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "command", HOOK_COMMAND_RUN(hook, command)))
|
||||
return 0;
|
||||
}
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_COMMAND_RUN(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "command", HOOK_COMMAND_RUN(hook, command)))
|
||||
return 0;
|
||||
break;
|
||||
case HOOK_TYPE_TIMER:
|
||||
if (!hook->deleted)
|
||||
{
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_TIMER(hook, callback)))
|
||||
return 0;
|
||||
snprintf (value, sizeof (value), "%ld", HOOK_TIMER(hook, interval));
|
||||
if (!infolist_new_var_string (ptr_item, "interval", value))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "align_second", HOOK_TIMER(hook, align_second)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "remaining_calls", HOOK_TIMER(hook, remaining_calls)))
|
||||
return 0;
|
||||
if (!infolist_new_var_buffer (ptr_item, "last_exec",
|
||||
&(HOOK_TIMER(hook, last_exec)),
|
||||
sizeof (HOOK_TIMER(hook, last_exec))))
|
||||
return 0;
|
||||
if (!infolist_new_var_buffer (ptr_item, "next_exec",
|
||||
&(HOOK_TIMER(hook, next_exec)),
|
||||
sizeof (HOOK_TIMER(hook, next_exec))))
|
||||
return 0;
|
||||
}
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_TIMER(hook, callback)))
|
||||
return 0;
|
||||
snprintf (value, sizeof (value), "%ld", HOOK_TIMER(hook, interval));
|
||||
if (!infolist_new_var_string (ptr_item, "interval", value))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "align_second", HOOK_TIMER(hook, align_second)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "remaining_calls", HOOK_TIMER(hook, remaining_calls)))
|
||||
return 0;
|
||||
if (!infolist_new_var_buffer (ptr_item, "last_exec",
|
||||
&(HOOK_TIMER(hook, last_exec)),
|
||||
sizeof (HOOK_TIMER(hook, last_exec))))
|
||||
return 0;
|
||||
if (!infolist_new_var_buffer (ptr_item, "next_exec",
|
||||
&(HOOK_TIMER(hook, next_exec)),
|
||||
sizeof (HOOK_TIMER(hook, next_exec))))
|
||||
return 0;
|
||||
break;
|
||||
case HOOK_TYPE_FD:
|
||||
if (!hook->deleted)
|
||||
{
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_FD(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "fd", HOOK_FD(hook, fd)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "flags", HOOK_FD(hook, flags)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "error", HOOK_FD(hook, error)))
|
||||
return 0;
|
||||
}
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_FD(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "fd", HOOK_FD(hook, fd)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "flags", HOOK_FD(hook, flags)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "error", HOOK_FD(hook, error)))
|
||||
return 0;
|
||||
break;
|
||||
case HOOK_TYPE_PROCESS:
|
||||
if (!hook->deleted)
|
||||
{
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_PROCESS(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "command", HOOK_PROCESS(hook, command)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "options", hashtable_get_string (HOOK_PROCESS(hook, options), "keys_values")))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "detached", HOOK_PROCESS(hook, detached)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "timeout", (int)(HOOK_PROCESS(hook, timeout))))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_read_stdin", HOOK_PROCESS(hook, child_read[HOOK_PROCESS_STDIN])))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_write_stdin", HOOK_PROCESS(hook, child_write[HOOK_PROCESS_STDIN])))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_read_stdout", HOOK_PROCESS(hook, child_read[HOOK_PROCESS_STDOUT])))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_write_stdout", HOOK_PROCESS(hook, child_write[HOOK_PROCESS_STDOUT])))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_read_stderr", HOOK_PROCESS(hook, child_read[HOOK_PROCESS_STDERR])))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_write_stderr", HOOK_PROCESS(hook, child_write[HOOK_PROCESS_STDERR])))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_pid", HOOK_PROCESS(hook, child_pid)))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "hook_fd_stdin", HOOK_PROCESS(hook, hook_fd[HOOK_PROCESS_STDIN])))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "hook_fd_stdout", HOOK_PROCESS(hook, hook_fd[HOOK_PROCESS_STDOUT])))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "hook_fd_stderr", HOOK_PROCESS(hook, hook_fd[HOOK_PROCESS_STDERR])))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "hook_timer", HOOK_PROCESS(hook, hook_timer)))
|
||||
return 0;
|
||||
}
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_PROCESS(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "command", HOOK_PROCESS(hook, command)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "options", hashtable_get_string (HOOK_PROCESS(hook, options), "keys_values")))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "detached", HOOK_PROCESS(hook, detached)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "timeout", (int)(HOOK_PROCESS(hook, timeout))))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_read_stdin", HOOK_PROCESS(hook, child_read[HOOK_PROCESS_STDIN])))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_write_stdin", HOOK_PROCESS(hook, child_write[HOOK_PROCESS_STDIN])))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_read_stdout", HOOK_PROCESS(hook, child_read[HOOK_PROCESS_STDOUT])))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_write_stdout", HOOK_PROCESS(hook, child_write[HOOK_PROCESS_STDOUT])))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_read_stderr", HOOK_PROCESS(hook, child_read[HOOK_PROCESS_STDERR])))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_write_stderr", HOOK_PROCESS(hook, child_write[HOOK_PROCESS_STDERR])))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_pid", HOOK_PROCESS(hook, child_pid)))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "hook_fd_stdin", HOOK_PROCESS(hook, hook_fd[HOOK_PROCESS_STDIN])))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "hook_fd_stdout", HOOK_PROCESS(hook, hook_fd[HOOK_PROCESS_STDOUT])))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "hook_fd_stderr", HOOK_PROCESS(hook, hook_fd[HOOK_PROCESS_STDERR])))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "hook_timer", HOOK_PROCESS(hook, hook_timer)))
|
||||
return 0;
|
||||
break;
|
||||
case HOOK_TYPE_CONNECT:
|
||||
if (!hook->deleted)
|
||||
{
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_CONNECT(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "address", HOOK_CONNECT(hook, address)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "port", HOOK_CONNECT(hook, port)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "sock", HOOK_CONNECT(hook, sock)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "ipv6", HOOK_CONNECT(hook, ipv6)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "retry", HOOK_CONNECT(hook, retry)))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_CONNECT(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "address", HOOK_CONNECT(hook, address)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "port", HOOK_CONNECT(hook, port)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "sock", HOOK_CONNECT(hook, sock)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "ipv6", HOOK_CONNECT(hook, ipv6)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "retry", HOOK_CONNECT(hook, retry)))
|
||||
return 0;
|
||||
#ifdef HAVE_GNUTLS
|
||||
if (!infolist_new_var_pointer (ptr_item, "gnutls_sess", HOOK_CONNECT(hook, gnutls_sess)))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "gnutls_cb", HOOK_CONNECT(hook, gnutls_cb)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "gnutls_dhkey_size", HOOK_CONNECT(hook, gnutls_dhkey_size)))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "gnutls_sess", HOOK_CONNECT(hook, gnutls_sess)))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "gnutls_cb", HOOK_CONNECT(hook, gnutls_cb)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "gnutls_dhkey_size", HOOK_CONNECT(hook, gnutls_dhkey_size)))
|
||||
return 0;
|
||||
#endif /* HAVE_GNUTLS */
|
||||
if (!infolist_new_var_string (ptr_item, "local_hostname", HOOK_CONNECT(hook, local_hostname)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_read", HOOK_CONNECT(hook, child_read)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_write", HOOK_CONNECT(hook, child_write)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_recv", HOOK_CONNECT(hook, child_recv)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_send", HOOK_CONNECT(hook, child_send)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_pid", HOOK_CONNECT(hook, child_pid)))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "hook_child_timer", HOOK_CONNECT(hook, hook_child_timer)))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "hook_fd", HOOK_CONNECT(hook, hook_fd)))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "handshake_hook_fd", HOOK_CONNECT(hook, handshake_hook_fd)))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "handshake_hook_timer", HOOK_CONNECT(hook, handshake_hook_timer)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "handshake_fd_flags", HOOK_CONNECT(hook, handshake_fd_flags)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "handshake_ip_address", HOOK_CONNECT(hook, handshake_ip_address)))
|
||||
return 0;
|
||||
}
|
||||
if (!infolist_new_var_string (ptr_item, "local_hostname", HOOK_CONNECT(hook, local_hostname)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_read", HOOK_CONNECT(hook, child_read)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_write", HOOK_CONNECT(hook, child_write)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_recv", HOOK_CONNECT(hook, child_recv)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_send", HOOK_CONNECT(hook, child_send)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "child_pid", HOOK_CONNECT(hook, child_pid)))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "hook_child_timer", HOOK_CONNECT(hook, hook_child_timer)))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "hook_fd", HOOK_CONNECT(hook, hook_fd)))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "handshake_hook_fd", HOOK_CONNECT(hook, handshake_hook_fd)))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "handshake_hook_timer", HOOK_CONNECT(hook, handshake_hook_timer)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "handshake_fd_flags", HOOK_CONNECT(hook, handshake_fd_flags)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "handshake_ip_address", HOOK_CONNECT(hook, handshake_ip_address)))
|
||||
return 0;
|
||||
break;
|
||||
case HOOK_TYPE_LINE:
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_LINE(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "buffer_type", HOOK_LINE(hook, buffer_type)))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "buffers", HOOK_LINE(hook, buffers)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "num_buffers", HOOK_LINE(hook, num_buffers)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "tags_count", HOOK_LINE(hook, tags_count)))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "tags_array", HOOK_LINE(hook, tags_array)))
|
||||
return 0;
|
||||
break;
|
||||
case HOOK_TYPE_PRINT:
|
||||
if (!hook->deleted)
|
||||
{
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_PRINT(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "buffer", HOOK_PRINT(hook, buffer)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "tags_count", HOOK_PRINT(hook, tags_count)))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "tags_array", HOOK_PRINT(hook, tags_array)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "message", HOOK_PRINT(hook, message)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "strip_colors", HOOK_PRINT(hook, strip_colors)))
|
||||
return 0;
|
||||
}
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_PRINT(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "buffer", HOOK_PRINT(hook, buffer)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "tags_count", HOOK_PRINT(hook, tags_count)))
|
||||
return 0;
|
||||
if (!infolist_new_var_pointer (ptr_item, "tags_array", HOOK_PRINT(hook, tags_array)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "message", HOOK_PRINT(hook, message)))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "strip_colors", HOOK_PRINT(hook, strip_colors)))
|
||||
return 0;
|
||||
break;
|
||||
case HOOK_TYPE_SIGNAL:
|
||||
if (!hook->deleted)
|
||||
{
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_SIGNAL(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "signal", HOOK_SIGNAL(hook, signal)))
|
||||
return 0;
|
||||
}
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_SIGNAL(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "signal", HOOK_SIGNAL(hook, signal)))
|
||||
return 0;
|
||||
break;
|
||||
case HOOK_TYPE_HSIGNAL:
|
||||
if (!hook->deleted)
|
||||
{
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_HSIGNAL(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "signal", HOOK_HSIGNAL(hook, signal)))
|
||||
return 0;
|
||||
}
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_HSIGNAL(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "signal", HOOK_HSIGNAL(hook, signal)))
|
||||
return 0;
|
||||
break;
|
||||
case HOOK_TYPE_CONFIG:
|
||||
if (!hook->deleted)
|
||||
{
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_CONFIG(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "option", HOOK_CONFIG(hook, option)))
|
||||
return 0;
|
||||
}
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_CONFIG(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "option", HOOK_CONFIG(hook, option)))
|
||||
return 0;
|
||||
break;
|
||||
case HOOK_TYPE_COMPLETION:
|
||||
if (!hook->deleted)
|
||||
{
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_COMPLETION(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "completion_item", HOOK_COMPLETION(hook, completion_item)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description", HOOK_COMPLETION(hook, description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description_nls",
|
||||
(HOOK_COMPLETION(hook, description)
|
||||
&& HOOK_COMPLETION(hook, description)[0]) ?
|
||||
_(HOOK_COMPLETION(hook, description)) : ""))
|
||||
return 0;
|
||||
}
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_COMPLETION(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "completion_item", HOOK_COMPLETION(hook, completion_item)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description", HOOK_COMPLETION(hook, description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description_nls",
|
||||
(HOOK_COMPLETION(hook, description)
|
||||
&& HOOK_COMPLETION(hook, description)[0]) ?
|
||||
_(HOOK_COMPLETION(hook, description)) : ""))
|
||||
return 0;
|
||||
break;
|
||||
case HOOK_TYPE_MODIFIER:
|
||||
if (!hook->deleted)
|
||||
{
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_MODIFIER(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "modifier", HOOK_MODIFIER(hook, modifier)))
|
||||
return 0;
|
||||
}
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_MODIFIER(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "modifier", HOOK_MODIFIER(hook, modifier)))
|
||||
return 0;
|
||||
break;
|
||||
case HOOK_TYPE_INFO:
|
||||
if (!hook->deleted)
|
||||
{
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_INFO(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "info_name", HOOK_INFO(hook, info_name)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description", HOOK_INFO(hook, description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description_nls",
|
||||
(HOOK_INFO(hook, description)
|
||||
&& HOOK_INFO(hook, description)[0]) ?
|
||||
_(HOOK_INFO(hook, description)) : ""))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args_description", HOOK_INFO(hook, args_description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args_description_nls",
|
||||
(HOOK_INFO(hook, args_description)
|
||||
&& HOOK_INFO(hook, args_description)[0]) ?
|
||||
_(HOOK_INFO(hook, args_description)) : ""))
|
||||
return 0;
|
||||
}
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_INFO(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "info_name", HOOK_INFO(hook, info_name)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description", HOOK_INFO(hook, description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description_nls",
|
||||
(HOOK_INFO(hook, description)
|
||||
&& HOOK_INFO(hook, description)[0]) ?
|
||||
_(HOOK_INFO(hook, description)) : ""))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args_description", HOOK_INFO(hook, args_description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args_description_nls",
|
||||
(HOOK_INFO(hook, args_description)
|
||||
&& HOOK_INFO(hook, args_description)[0]) ?
|
||||
_(HOOK_INFO(hook, args_description)) : ""))
|
||||
return 0;
|
||||
break;
|
||||
case HOOK_TYPE_INFO_HASHTABLE:
|
||||
if (!hook->deleted)
|
||||
{
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_INFO_HASHTABLE(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "info_name", HOOK_INFO_HASHTABLE(hook, info_name)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description", HOOK_INFO_HASHTABLE(hook, description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description_nls",
|
||||
(HOOK_INFO_HASHTABLE(hook, description)
|
||||
&& HOOK_INFO_HASHTABLE(hook, description)[0]) ?
|
||||
_(HOOK_INFO_HASHTABLE(hook, description)) : ""))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args_description", HOOK_INFO_HASHTABLE(hook, args_description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args_description_nls",
|
||||
(HOOK_INFO_HASHTABLE(hook, args_description)
|
||||
&& HOOK_INFO_HASHTABLE(hook, args_description)[0]) ?
|
||||
_(HOOK_INFO_HASHTABLE(hook, args_description)) : ""))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "output_description", HOOK_INFO_HASHTABLE(hook, output_description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "output_description_nls",
|
||||
(HOOK_INFO_HASHTABLE(hook, output_description)
|
||||
&& HOOK_INFO_HASHTABLE(hook, output_description)[0]) ?
|
||||
_(HOOK_INFO_HASHTABLE(hook, output_description)) : ""))
|
||||
return 0;
|
||||
}
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_INFO_HASHTABLE(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "info_name", HOOK_INFO_HASHTABLE(hook, info_name)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description", HOOK_INFO_HASHTABLE(hook, description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description_nls",
|
||||
(HOOK_INFO_HASHTABLE(hook, description)
|
||||
&& HOOK_INFO_HASHTABLE(hook, description)[0]) ?
|
||||
_(HOOK_INFO_HASHTABLE(hook, description)) : ""))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args_description", HOOK_INFO_HASHTABLE(hook, args_description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args_description_nls",
|
||||
(HOOK_INFO_HASHTABLE(hook, args_description)
|
||||
&& HOOK_INFO_HASHTABLE(hook, args_description)[0]) ?
|
||||
_(HOOK_INFO_HASHTABLE(hook, args_description)) : ""))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "output_description", HOOK_INFO_HASHTABLE(hook, output_description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "output_description_nls",
|
||||
(HOOK_INFO_HASHTABLE(hook, output_description)
|
||||
&& HOOK_INFO_HASHTABLE(hook, output_description)[0]) ?
|
||||
_(HOOK_INFO_HASHTABLE(hook, output_description)) : ""))
|
||||
return 0;
|
||||
break;
|
||||
case HOOK_TYPE_INFOLIST:
|
||||
if (!hook->deleted)
|
||||
{
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_INFOLIST(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "infolist_name", HOOK_INFOLIST(hook, infolist_name)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description", HOOK_INFOLIST(hook, description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description_nls",
|
||||
(HOOK_INFOLIST(hook, description)
|
||||
&& HOOK_INFOLIST(hook, description)[0]) ?
|
||||
_(HOOK_INFOLIST(hook, description)) : ""))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "pointer_description", HOOK_INFOLIST(hook, pointer_description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "pointer_description_nls",
|
||||
(HOOK_INFOLIST(hook, pointer_description)
|
||||
&& HOOK_INFOLIST(hook, pointer_description)[0]) ?
|
||||
_(HOOK_INFOLIST(hook, pointer_description)) : ""))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args_description", HOOK_INFOLIST(hook, args_description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args_description_nls",
|
||||
(HOOK_INFOLIST(hook, args_description)
|
||||
&& HOOK_INFOLIST(hook, args_description)[0]) ?
|
||||
_(HOOK_INFOLIST(hook, args_description)) : ""))
|
||||
return 0;
|
||||
}
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_INFOLIST(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "infolist_name", HOOK_INFOLIST(hook, infolist_name)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description", HOOK_INFOLIST(hook, description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description_nls",
|
||||
(HOOK_INFOLIST(hook, description)
|
||||
&& HOOK_INFOLIST(hook, description)[0]) ?
|
||||
_(HOOK_INFOLIST(hook, description)) : ""))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "pointer_description", HOOK_INFOLIST(hook, pointer_description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "pointer_description_nls",
|
||||
(HOOK_INFOLIST(hook, pointer_description)
|
||||
&& HOOK_INFOLIST(hook, pointer_description)[0]) ?
|
||||
_(HOOK_INFOLIST(hook, pointer_description)) : ""))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args_description", HOOK_INFOLIST(hook, args_description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "args_description_nls",
|
||||
(HOOK_INFOLIST(hook, args_description)
|
||||
&& HOOK_INFOLIST(hook, args_description)[0]) ?
|
||||
_(HOOK_INFOLIST(hook, args_description)) : ""))
|
||||
return 0;
|
||||
break;
|
||||
case HOOK_TYPE_HDATA:
|
||||
if (!hook->deleted)
|
||||
{
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_HDATA(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "hdata_name", HOOK_HDATA(hook, hdata_name)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description", HOOK_HDATA(hook, description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description_nls",
|
||||
(HOOK_HDATA(hook, description)
|
||||
&& HOOK_HDATA(hook, description)[0]) ?
|
||||
_(HOOK_HDATA(hook, description)) : ""))
|
||||
return 0;
|
||||
}
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_HDATA(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "hdata_name", HOOK_HDATA(hook, hdata_name)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description", HOOK_HDATA(hook, description)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "description_nls",
|
||||
(HOOK_HDATA(hook, description)
|
||||
&& HOOK_HDATA(hook, description)[0]) ?
|
||||
_(HOOK_HDATA(hook, description)) : ""))
|
||||
return 0;
|
||||
break;
|
||||
case HOOK_TYPE_FOCUS:
|
||||
if (!hook->deleted)
|
||||
{
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_FOCUS(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "area", HOOK_FOCUS(hook, area)))
|
||||
return 0;
|
||||
}
|
||||
if (!infolist_new_var_pointer (ptr_item, "callback", HOOK_FOCUS(hook, callback)))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "area", HOOK_FOCUS(hook, area)))
|
||||
return 0;
|
||||
break;
|
||||
case HOOK_NUM_TYPES:
|
||||
/*
|
||||
@ -4865,6 +4995,33 @@ hook_print_log ()
|
||||
}
|
||||
}
|
||||
break;
|
||||
case HOOK_TYPE_LINE:
|
||||
log_printf (" line data:");
|
||||
log_printf (" callback. . . . . . . : 0x%lx", HOOK_LINE(ptr_hook, callback));
|
||||
log_printf (" buffer_type . . . . . : %d", HOOK_LINE(ptr_hook, buffer_type));
|
||||
log_printf (" buffers . . . . . . . : 0x%lx", HOOK_LINE(ptr_hook, buffers));
|
||||
log_printf (" num_buffers . . . . . : %d", HOOK_LINE(ptr_hook, num_buffers));
|
||||
for (i = 0; i < HOOK_LINE(ptr_hook, num_buffers); i++)
|
||||
{
|
||||
log_printf (" buffers[%03d]. . . : '%s'",
|
||||
i, HOOK_LINE(ptr_hook, buffers)[i]);
|
||||
}
|
||||
log_printf (" tags_count. . . . . . : %d", HOOK_LINE(ptr_hook, tags_count));
|
||||
log_printf (" tags_array. . . . . . : 0x%lx", HOOK_LINE(ptr_hook, tags_array));
|
||||
if (HOOK_LINE(ptr_hook, tags_array))
|
||||
{
|
||||
for (i = 0; i < HOOK_LINE(ptr_hook, tags_count); i++)
|
||||
{
|
||||
for (j = 0; HOOK_LINE(ptr_hook, tags_array)[i][j]; j++)
|
||||
{
|
||||
log_printf (" tags_array[%03d][%03d]: '%s'",
|
||||
i,
|
||||
j,
|
||||
HOOK_LINE(ptr_hook, tags_array)[i][j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case HOOK_TYPE_PRINT:
|
||||
log_printf (" print data:");
|
||||
log_printf (" callback. . . . . . . : 0x%lx", HOOK_PRINT(ptr_hook, callback));
|
||||
|
@ -50,6 +50,7 @@ enum t_hook_type
|
||||
HOOK_TYPE_FD, /* socket of file descriptor */
|
||||
HOOK_TYPE_PROCESS, /* sub-process (fork) */
|
||||
HOOK_TYPE_CONNECT, /* connect to peer with fork */
|
||||
HOOK_TYPE_LINE, /* new line in a buffer */
|
||||
HOOK_TYPE_PRINT, /* printed message */
|
||||
HOOK_TYPE_SIGNAL, /* signal */
|
||||
HOOK_TYPE_HSIGNAL, /* signal (using hashtable) */
|
||||
@ -100,6 +101,7 @@ enum t_hook_type
|
||||
#define HOOK_FD(hook, var) (((struct t_hook_fd *)hook->hook_data)->var)
|
||||
#define HOOK_PROCESS(hook, var) (((struct t_hook_process *)hook->hook_data)->var)
|
||||
#define HOOK_CONNECT(hook, var) (((struct t_hook_connect *)hook->hook_data)->var)
|
||||
#define HOOK_LINE(hook, var) (((struct t_hook_line *)hook->hook_data)->var)
|
||||
#define HOOK_PRINT(hook, var) (((struct t_hook_print *)hook->hook_data)->var)
|
||||
#define HOOK_SIGNAL(hook, var) (((struct t_hook_signal *)hook->hook_data)->var)
|
||||
#define HOOK_HSIGNAL(hook, var) (((struct t_hook_hsignal *)hook->hook_data)->var)
|
||||
@ -282,6 +284,24 @@ struct t_hook_connect
|
||||
int sock_v6[HOOK_CONNECT_MAX_SOCKETS]; /* IPv6 sockets for connecting */
|
||||
};
|
||||
|
||||
/* hook line */
|
||||
|
||||
typedef struct t_hashtable *(t_hook_callback_line)(const void *pointer,
|
||||
void *data,
|
||||
struct t_hashtable *line);
|
||||
|
||||
struct t_hook_line
|
||||
{
|
||||
t_hook_callback_line *callback; /* line callback */
|
||||
int buffer_type; /* -1 = any type, ≥ 0: only this type*/
|
||||
char **buffers; /* list of buffer masks where the */
|
||||
/* hook is executed (see the */
|
||||
/* function "buffer_match_list") */
|
||||
int num_buffers; /* number of buffers in list */
|
||||
int tags_count; /* number of tags selected */
|
||||
char ***tags_array; /* tags selected (NULL = any) */
|
||||
};
|
||||
|
||||
/* hook print */
|
||||
|
||||
typedef int (t_hook_callback_print)(const void *pointer, void *data,
|
||||
@ -520,6 +540,14 @@ extern int hook_connect_gnutls_set_certificates (gnutls_session_t tls_session,
|
||||
gnutls_retr_st *answer);
|
||||
#endif /* LIBGNUTLS_VERSION_NUMBER >= 0x020b00 */
|
||||
#endif /* HAVE_GNUTLS */
|
||||
extern struct t_hook *hook_line (struct t_weechat_plugin *plugin,
|
||||
const char *buffer_type,
|
||||
const char *buffer_name,
|
||||
const char *tags,
|
||||
t_hook_callback_line *callback,
|
||||
const void *callback_pointer,
|
||||
void *callback_data);
|
||||
extern void hook_line_exec (struct t_gui_line *line);
|
||||
extern struct t_hook *hook_print (struct t_weechat_plugin *plugin,
|
||||
struct t_gui_buffer *buffer,
|
||||
const char *tags, const char *message,
|
||||
|
@ -631,7 +631,8 @@ upgrade_weechat_read_buffer_line (struct t_infolist *infolist)
|
||||
switch (upgrade_current_buffer->type)
|
||||
{
|
||||
case GUI_BUFFER_TYPE_FORMATTED:
|
||||
new_line = gui_line_add (upgrade_current_buffer,
|
||||
new_line = gui_line_new (upgrade_current_buffer,
|
||||
-1,
|
||||
infolist_time (infolist, "date"),
|
||||
infolist_time (infolist, "date_printed"),
|
||||
infolist_string (infolist, "tags"),
|
||||
@ -639,6 +640,7 @@ upgrade_weechat_read_buffer_line (struct t_infolist *infolist)
|
||||
infolist_string (infolist, "message"));
|
||||
if (new_line)
|
||||
{
|
||||
gui_line_add (new_line);
|
||||
new_line->data->highlight = infolist_integer (infolist,
|
||||
"highlight");
|
||||
if (infolist_integer (infolist, "last_read_line"))
|
||||
@ -646,9 +648,12 @@ upgrade_weechat_read_buffer_line (struct t_infolist *infolist)
|
||||
}
|
||||
break;
|
||||
case GUI_BUFFER_TYPE_FREE:
|
||||
gui_line_add_y (upgrade_current_buffer,
|
||||
infolist_integer (infolist, "y"),
|
||||
infolist_string (infolist, "message"));
|
||||
new_line = gui_line_new (upgrade_current_buffer,
|
||||
infolist_integer (infolist, "y"),
|
||||
0, 0, NULL, NULL,
|
||||
infolist_string (infolist, "message"));
|
||||
if (new_line)
|
||||
gui_line_add_y (new_line);
|
||||
break;
|
||||
case GUI_BUFFER_NUM_TYPES:
|
||||
break;
|
||||
|
@ -79,6 +79,9 @@ char *gui_buffer_reserved_names[] =
|
||||
NULL
|
||||
};
|
||||
|
||||
char *gui_buffer_type_string[GUI_BUFFER_NUM_TYPES] =
|
||||
{ "formatted", "free" };
|
||||
|
||||
char *gui_buffer_notify_string[GUI_BUFFER_NUM_NOTIFY] =
|
||||
{ "none", "highlight", "message", "all" };
|
||||
|
||||
@ -118,6 +121,26 @@ char *gui_buffer_properties_set[] =
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Searches for buffer type.
|
||||
*
|
||||
* Returns pointer to hotlist found, NULL if not found.
|
||||
*/
|
||||
|
||||
int
|
||||
gui_buffer_search_type (const char *type)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < GUI_BUFFER_NUM_TYPES; i++)
|
||||
{
|
||||
if (string_strcasecmp (gui_buffer_type_string[i], type) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Gets plugin name of buffer.
|
||||
*
|
||||
|
@ -236,6 +236,7 @@ extern int gui_buffers_visited_count;
|
||||
extern int gui_buffers_visited_frozen;
|
||||
extern struct t_gui_buffer *gui_buffer_last_displayed;
|
||||
extern char *gui_buffer_reserved_names[];
|
||||
extern char *gui_buffer_type_string[];
|
||||
extern char *gui_buffer_notify_string[];
|
||||
extern char *gui_buffer_properties_get_integer[];
|
||||
extern char *gui_buffer_properties_get_string[];
|
||||
@ -244,6 +245,7 @@ extern char *gui_buffer_properties_set[];
|
||||
|
||||
/* buffer functions */
|
||||
|
||||
extern int gui_buffer_search_type (const char *type);
|
||||
extern const char *gui_buffer_get_plugin_name (struct t_gui_buffer *buffer);
|
||||
extern const char *gui_buffer_get_short_name (struct t_gui_buffer *buffer);
|
||||
extern void gui_buffer_build_full_name (struct t_gui_buffer *buffer);
|
||||
|
@ -55,7 +55,7 @@ int gui_chat_time_length = 0; /* length of time for each line (in chars) */
|
||||
int gui_chat_mute = GUI_CHAT_MUTE_DISABLED; /* mute mode */
|
||||
struct t_gui_buffer *gui_chat_mute_buffer = NULL; /* mute buffer */
|
||||
int gui_chat_display_tags = 0; /* display tags? */
|
||||
char *gui_chat_lines_waiting_buffer = NULL; /* lines waiting for core */
|
||||
char **gui_chat_lines_waiting_buffer = NULL; /* lines waiting for core */
|
||||
/* buffer */
|
||||
|
||||
|
||||
@ -635,304 +635,233 @@ gui_chat_build_string_message_tags (struct t_gui_line *line)
|
||||
}
|
||||
|
||||
/*
|
||||
* Displays a message in a buffer with optional date and tags.
|
||||
* Checks if the buffer pointer is valid for printing a chat message,
|
||||
* according to buffer type.
|
||||
*
|
||||
* Note: this function works only with formatted buffers (not buffers with free
|
||||
* content).
|
||||
* Returns:
|
||||
* 1: buffer is valid
|
||||
* 0: buffer is not valid
|
||||
*/
|
||||
|
||||
int
|
||||
gui_chat_buffer_valid (struct t_gui_buffer *buffer,
|
||||
int buffer_type)
|
||||
{
|
||||
/* check buffer pointer, closing and type */
|
||||
if (!buffer || !gui_buffer_valid (buffer)
|
||||
|| buffer->closing
|
||||
|| ((int)(buffer->type) != buffer_type))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* check if mute is enabled */
|
||||
if ((buffer_type == GUI_BUFFER_TYPE_FORMATTED)
|
||||
&& ((gui_chat_mute == GUI_CHAT_MUTE_ALL_BUFFERS)
|
||||
|| ((gui_chat_mute == GUI_CHAT_MUTE_BUFFER)
|
||||
&& (gui_chat_mute_buffer == buffer))))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Displays a message in a buffer with optional date and tags.
|
||||
* This function is called internally by the function
|
||||
* gui_chat_printf_date_tags.
|
||||
*/
|
||||
|
||||
void
|
||||
gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
|
||||
const char *tags, const char *message, ...)
|
||||
gui_chat_printf_date_tags_internal (struct t_gui_buffer *buffer,
|
||||
time_t date,
|
||||
time_t date_printed,
|
||||
const char *tags,
|
||||
char *message)
|
||||
{
|
||||
time_t date_printed;
|
||||
int display_time, length, at_least_one_message_printed, msg_discarded;
|
||||
char *pos, *pos_prefix, *pos_tab, *pos_end, *pos_lines;
|
||||
char *modifier_data, *new_msg, *ptr_msg, *lines_waiting;
|
||||
struct t_gui_line *ptr_line;
|
||||
int display_time, length_data, length_str;
|
||||
char *ptr_msg, *pos_prefix, *pos_tab;
|
||||
char *modifier_data, *string, *new_string;
|
||||
struct t_gui_line *new_line;
|
||||
|
||||
if (!message)
|
||||
return;
|
||||
new_line = NULL;
|
||||
string = NULL;
|
||||
modifier_data = NULL;
|
||||
new_string = NULL;
|
||||
|
||||
if (!gui_buffer_valid (buffer))
|
||||
return;
|
||||
display_time = 1;
|
||||
|
||||
if (gui_init_ok)
|
||||
pos_prefix = NULL;
|
||||
ptr_msg = message;
|
||||
|
||||
/* space followed by tab => prefix ignored */
|
||||
if ((ptr_msg[0] == ' ') && (ptr_msg[1] == '\t'))
|
||||
{
|
||||
if (!buffer)
|
||||
buffer = gui_buffer_search_main ();
|
||||
|
||||
if (!buffer || buffer->closing)
|
||||
return;
|
||||
|
||||
if (buffer->type != GUI_BUFFER_TYPE_FORMATTED)
|
||||
buffer = gui_buffers;
|
||||
|
||||
if (buffer->type != GUI_BUFFER_TYPE_FORMATTED)
|
||||
return;
|
||||
ptr_msg += 2;
|
||||
}
|
||||
|
||||
/* if mute is enabled for buffer (or all buffers), then just return */
|
||||
if ((gui_chat_mute == GUI_CHAT_MUTE_ALL_BUFFERS)
|
||||
|| ((gui_chat_mute == GUI_CHAT_MUTE_BUFFER)
|
||||
&& (gui_chat_mute_buffer == buffer)))
|
||||
return;
|
||||
|
||||
weechat_va_format (message);
|
||||
if (!vbuffer)
|
||||
return;
|
||||
|
||||
utf8_normalize (vbuffer, '?');
|
||||
|
||||
date_printed = time (NULL);
|
||||
if (date <= 0)
|
||||
date = date_printed;
|
||||
|
||||
at_least_one_message_printed = 0;
|
||||
|
||||
pos = vbuffer;
|
||||
while (pos)
|
||||
else
|
||||
{
|
||||
/* display until next end of line */
|
||||
pos_end = strchr (pos, '\n');
|
||||
if (pos_end)
|
||||
pos_end[0] = '\0';
|
||||
|
||||
/* call modifier for message printed ("weechat_print") */
|
||||
new_msg = NULL;
|
||||
msg_discarded = 0;
|
||||
if (buffer)
|
||||
/* if two first chars are tab, then do not display time */
|
||||
if ((ptr_msg[0] == '\t') && (ptr_msg[1] == '\t'))
|
||||
{
|
||||
length = strlen (gui_buffer_get_plugin_name (buffer)) + 1 +
|
||||
strlen (buffer->name) + 1 + ((tags) ? strlen (tags) : 0) + 1;
|
||||
modifier_data = malloc (length);
|
||||
if (modifier_data)
|
||||
display_time = 0;
|
||||
ptr_msg += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if tab found, use prefix (before tab) */
|
||||
pos_tab = strchr (ptr_msg, '\t');
|
||||
if (pos_tab)
|
||||
{
|
||||
snprintf (modifier_data, length, "%s;%s;%s",
|
||||
gui_buffer_get_plugin_name (buffer),
|
||||
buffer->name,
|
||||
(tags) ? tags : "");
|
||||
new_msg = hook_modifier_exec (NULL,
|
||||
"weechat_print",
|
||||
modifier_data,
|
||||
pos);
|
||||
free (modifier_data);
|
||||
if (new_msg)
|
||||
{
|
||||
if (!new_msg[0] && pos[0])
|
||||
{
|
||||
/*
|
||||
* modifier returned empty message, then we'll not
|
||||
* print anything
|
||||
*/
|
||||
free (new_msg);
|
||||
new_msg = NULL;
|
||||
msg_discarded = 1;
|
||||
}
|
||||
else if (strcmp (message, new_msg) == 0)
|
||||
{
|
||||
/* no changes in new message */
|
||||
free (new_msg);
|
||||
new_msg = NULL;
|
||||
}
|
||||
}
|
||||
pos_tab[0] = '\0';
|
||||
pos_prefix = ptr_msg;
|
||||
ptr_msg = pos_tab + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!msg_discarded)
|
||||
new_line = gui_line_new (buffer,
|
||||
-1,
|
||||
(display_time) ? date : 0,
|
||||
date_printed,
|
||||
tags,
|
||||
pos_prefix,
|
||||
ptr_msg);
|
||||
if (!new_line)
|
||||
goto no_print;
|
||||
|
||||
hook_line_exec (new_line);
|
||||
|
||||
if (!new_line->data->buffer)
|
||||
goto no_print;
|
||||
|
||||
/* call modifier for message printed ("weechat_print") */
|
||||
if (buffer)
|
||||
{
|
||||
length_data = strlen (gui_buffer_get_plugin_name (new_line->data->buffer)) +
|
||||
1 +
|
||||
strlen (new_line->data->buffer->name) +
|
||||
1 +
|
||||
((tags) ? strlen (tags) : 0) +
|
||||
1;
|
||||
modifier_data = malloc (length_data);
|
||||
length_str = ((new_line->data->prefix) ? strlen (new_line->data->prefix) + 1 : 0) +
|
||||
(new_line->data->message ? strlen (new_line->data->message) : 0) +
|
||||
1;
|
||||
string = malloc (length_str);
|
||||
if (modifier_data && string)
|
||||
{
|
||||
pos_prefix = NULL;
|
||||
display_time = 1;
|
||||
ptr_msg = (new_msg) ? new_msg : pos;
|
||||
|
||||
/* space followed by tab => prefix ignored */
|
||||
if ((ptr_msg[0] == ' ') && (ptr_msg[1] == '\t'))
|
||||
snprintf (modifier_data, length_data,
|
||||
"%s;%s;%s",
|
||||
gui_buffer_get_plugin_name (new_line->data->buffer),
|
||||
new_line->data->buffer->name,
|
||||
(tags) ? tags : "");
|
||||
snprintf (string, length_str,
|
||||
"%s%s%s",
|
||||
(new_line->data->prefix) ? new_line->data->prefix : "",
|
||||
(new_line->data->prefix) ? "\t" : "",
|
||||
(new_line->data->message) ? new_line->data->message : "");
|
||||
new_string = hook_modifier_exec (NULL,
|
||||
"weechat_print",
|
||||
modifier_data,
|
||||
string);
|
||||
if (new_string)
|
||||
{
|
||||
ptr_msg += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if two first chars are tab, then do not display time */
|
||||
if ((ptr_msg[0] == '\t') && (ptr_msg[1] == '\t'))
|
||||
if (!new_string[0] && message[0])
|
||||
{
|
||||
display_time = 0;
|
||||
ptr_msg += 2;
|
||||
/*
|
||||
* modifier returned empty message, then we'll not
|
||||
* print anything
|
||||
*/
|
||||
goto no_print;
|
||||
}
|
||||
else
|
||||
else if (strcmp (message, new_string) != 0)
|
||||
{
|
||||
/* if tab found, use prefix (before tab) */
|
||||
pos_tab = strchr (ptr_msg, '\t');
|
||||
/* use new message if there are changes */
|
||||
pos_prefix = NULL;
|
||||
ptr_msg = new_string;
|
||||
pos_tab = strchr (new_string, '\t');
|
||||
if (pos_tab)
|
||||
{
|
||||
pos_tab[0] = '\0';
|
||||
pos_prefix = ptr_msg;
|
||||
ptr_msg = pos_tab + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gui_init_ok)
|
||||
{
|
||||
ptr_line = gui_line_add (buffer, (display_time) ? date : 0,
|
||||
date_printed, tags, pos_prefix, ptr_msg);
|
||||
if (ptr_line)
|
||||
{
|
||||
if (buffer && buffer->print_hooks_enabled)
|
||||
hook_print_exec (buffer, ptr_line);
|
||||
if (ptr_line->data->displayed)
|
||||
at_least_one_message_printed = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
length = ((pos_prefix) ? strlen (pos_prefix) + 1 : 0) +
|
||||
strlen (ptr_msg) + 1;
|
||||
if (gui_chat_lines_waiting_buffer)
|
||||
{
|
||||
length += strlen (gui_chat_lines_waiting_buffer) + 1;
|
||||
lines_waiting = realloc (gui_chat_lines_waiting_buffer, length);
|
||||
if (lines_waiting)
|
||||
if (pos_prefix)
|
||||
{
|
||||
gui_chat_lines_waiting_buffer = lines_waiting;
|
||||
if (new_line->data->prefix)
|
||||
string_shared_free (new_line->data->prefix);
|
||||
new_line->data->prefix = (char *)string_shared_get (pos_prefix);
|
||||
new_line->data->prefix_length = gui_chat_strlen_screen (pos_prefix);
|
||||
}
|
||||
else
|
||||
{
|
||||
free (gui_chat_lines_waiting_buffer);
|
||||
gui_chat_lines_waiting_buffer = NULL;
|
||||
if (new_line->data->prefix)
|
||||
{
|
||||
free (new_line->data->prefix);
|
||||
new_line->data->prefix = NULL;
|
||||
}
|
||||
new_line->data->prefix_length = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_chat_lines_waiting_buffer = malloc (length);
|
||||
if (gui_chat_lines_waiting_buffer)
|
||||
gui_chat_lines_waiting_buffer[0] = '\0';
|
||||
}
|
||||
if (gui_chat_lines_waiting_buffer)
|
||||
{
|
||||
pos_lines = gui_chat_lines_waiting_buffer +
|
||||
strlen (gui_chat_lines_waiting_buffer);
|
||||
if (pos_lines > gui_chat_lines_waiting_buffer)
|
||||
{
|
||||
pos_lines[0] = '\n';
|
||||
pos_lines++;
|
||||
}
|
||||
if (pos_prefix)
|
||||
{
|
||||
memcpy (pos_lines, pos_prefix, strlen (pos_prefix));
|
||||
pos_lines += strlen (pos_prefix);
|
||||
pos_lines[0] = '\t';
|
||||
pos_lines++;
|
||||
}
|
||||
memcpy (pos_lines, ptr_msg, strlen (ptr_msg) + 1);
|
||||
if (new_line->data->message)
|
||||
free (new_line->data->message);
|
||||
new_line->data->message = strdup (ptr_msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (new_msg)
|
||||
free (new_msg);
|
||||
|
||||
pos = (pos_end && pos_end[1]) ? pos_end + 1 : NULL;
|
||||
}
|
||||
|
||||
if (gui_init_ok && at_least_one_message_printed)
|
||||
gui_buffer_ask_chat_refresh (buffer, 1);
|
||||
gui_line_add (new_line);
|
||||
if (new_line->data->buffer && buffer->print_hooks_enabled)
|
||||
hook_print_exec (new_line->data->buffer, new_line);
|
||||
|
||||
free (vbuffer);
|
||||
gui_buffer_ask_chat_refresh (new_line->data->buffer, 1);
|
||||
|
||||
if (string)
|
||||
free (string);
|
||||
if (modifier_data)
|
||||
free (modifier_data);
|
||||
if (new_string)
|
||||
free (new_string);
|
||||
|
||||
return;
|
||||
|
||||
no_print:
|
||||
if (new_line)
|
||||
{
|
||||
gui_line_free_data (new_line);
|
||||
free (new_line);
|
||||
}
|
||||
if (string)
|
||||
free (string);
|
||||
if (modifier_data)
|
||||
free (modifier_data);
|
||||
if (new_string)
|
||||
free (new_string);
|
||||
}
|
||||
|
||||
/*
|
||||
* Displays a message on a line in a buffer with free content.
|
||||
* Adds a line when WeeChat is waiting for the core buffer.
|
||||
*
|
||||
* Note: this function works only with free content buffers (not formatted
|
||||
* buffers).
|
||||
* The line is stored in an internal buffer area and will be displayed later
|
||||
* in the core buffer.
|
||||
*/
|
||||
|
||||
void
|
||||
gui_chat_printf_y (struct t_gui_buffer *buffer, int y, const char *message, ...)
|
||||
gui_chat_add_line_waiting_buffer (const char *message)
|
||||
{
|
||||
struct t_gui_line *ptr_line;
|
||||
int i, num_lines_to_add;
|
||||
|
||||
if (!gui_buffer_valid (buffer))
|
||||
return;
|
||||
|
||||
if (gui_init_ok)
|
||||
if (!gui_chat_lines_waiting_buffer)
|
||||
{
|
||||
if (!buffer)
|
||||
buffer = gui_buffer_search_main ();
|
||||
|
||||
if (!buffer || buffer->closing)
|
||||
return;
|
||||
|
||||
if (buffer->type != GUI_BUFFER_TYPE_FREE)
|
||||
buffer = gui_buffers;
|
||||
|
||||
if (buffer->type != GUI_BUFFER_TYPE_FREE)
|
||||
gui_chat_lines_waiting_buffer = string_dyn_alloc (1024);
|
||||
if (!gui_chat_lines_waiting_buffer)
|
||||
return;
|
||||
}
|
||||
|
||||
weechat_va_format (message);
|
||||
if (!vbuffer)
|
||||
return;
|
||||
if (*gui_chat_lines_waiting_buffer[0])
|
||||
string_dyn_concat (gui_chat_lines_waiting_buffer, "\n");
|
||||
|
||||
utf8_normalize (vbuffer, '?');
|
||||
|
||||
/* no message: delete line */
|
||||
if (!vbuffer[0])
|
||||
{
|
||||
if (gui_init_ok && (y >= 0))
|
||||
{
|
||||
for (ptr_line = buffer->own_lines->first_line; ptr_line;
|
||||
ptr_line = ptr_line->next_line)
|
||||
{
|
||||
if (ptr_line->data->y >= y)
|
||||
break;
|
||||
}
|
||||
if (ptr_line && (ptr_line->data->y == y))
|
||||
{
|
||||
if (ptr_line->next_line)
|
||||
gui_line_clear (ptr_line);
|
||||
else
|
||||
gui_line_free (buffer, ptr_line);
|
||||
gui_buffer_ask_chat_refresh (buffer, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gui_init_ok)
|
||||
{
|
||||
/* if y is negative, add a line -N lines after the last line */
|
||||
if (y < 0)
|
||||
{
|
||||
y = (buffer->own_lines && buffer->own_lines->last_line) ?
|
||||
buffer->own_lines->last_line->data->y - y : (-1 * y) - 1;
|
||||
}
|
||||
/* compute the number of lines to add before y */
|
||||
if (buffer->own_lines && buffer->own_lines->last_line)
|
||||
num_lines_to_add = y - buffer->own_lines->last_line->data->y - 1;
|
||||
else
|
||||
num_lines_to_add = y;
|
||||
if (num_lines_to_add > 0)
|
||||
{
|
||||
/*
|
||||
* add empty line(s) before asked line, to ensure there is at
|
||||
* least "y" lines in buffer, and then be able to scroll
|
||||
* properly buffer page by page
|
||||
*/
|
||||
for (i = y - num_lines_to_add; i < y; i++)
|
||||
{
|
||||
gui_line_add_y (buffer, i, "");
|
||||
}
|
||||
}
|
||||
gui_line_add_y (buffer, y, vbuffer);
|
||||
gui_buffer_ask_chat_refresh (buffer, 1);
|
||||
}
|
||||
else
|
||||
string_fprintf (stdout, "%s\n", vbuffer);
|
||||
}
|
||||
|
||||
free (vbuffer);
|
||||
string_dyn_concat (gui_chat_lines_waiting_buffer, message);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -952,7 +881,7 @@ gui_chat_print_lines_waiting_buffer (FILE *f)
|
||||
|
||||
if (gui_chat_lines_waiting_buffer)
|
||||
{
|
||||
lines = string_split (gui_chat_lines_waiting_buffer, "\n", 0, 0,
|
||||
lines = string_split (*gui_chat_lines_waiting_buffer, "\n", 0, 0,
|
||||
&num_lines);
|
||||
if (lines)
|
||||
{
|
||||
@ -972,11 +901,178 @@ gui_chat_print_lines_waiting_buffer (FILE *f)
|
||||
}
|
||||
if (gui_chat_lines_waiting_buffer)
|
||||
{
|
||||
free (gui_chat_lines_waiting_buffer);
|
||||
string_dyn_free (gui_chat_lines_waiting_buffer, 1);
|
||||
gui_chat_lines_waiting_buffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Displays a message in a buffer with optional date and tags.
|
||||
*
|
||||
* Note: this function works only with formatted buffers (not buffers with free
|
||||
* content).
|
||||
*/
|
||||
|
||||
void
|
||||
gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
|
||||
const char *tags, const char *message, ...)
|
||||
{
|
||||
time_t date_printed;
|
||||
char *pos, *pos_end;
|
||||
|
||||
if (!message)
|
||||
return;
|
||||
|
||||
if (gui_init_ok)
|
||||
{
|
||||
if (!buffer)
|
||||
buffer = gui_buffer_search_main ();
|
||||
if (!gui_chat_buffer_valid (buffer, GUI_BUFFER_TYPE_FORMATTED))
|
||||
return;
|
||||
}
|
||||
|
||||
weechat_va_format (message);
|
||||
if (!vbuffer)
|
||||
return;
|
||||
|
||||
utf8_normalize (vbuffer, '?');
|
||||
|
||||
date_printed = time (NULL);
|
||||
if (date <= 0)
|
||||
date = date_printed;
|
||||
|
||||
pos = vbuffer;
|
||||
while (pos)
|
||||
{
|
||||
/* display until next end of line */
|
||||
pos_end = strchr (pos, '\n');
|
||||
if (pos_end)
|
||||
pos_end[0] = '\0';
|
||||
|
||||
if (gui_init_ok)
|
||||
{
|
||||
gui_chat_printf_date_tags_internal (buffer, date, date_printed,
|
||||
tags, pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
gui_chat_add_line_waiting_buffer (pos);
|
||||
}
|
||||
|
||||
pos = (pos_end && pos_end[1]) ? pos_end + 1 : NULL;
|
||||
}
|
||||
|
||||
free (vbuffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Displays a message on a line in a buffer with free content.
|
||||
*
|
||||
* Note: this function works only with free content buffers (not formatted
|
||||
* buffers).
|
||||
*/
|
||||
|
||||
void
|
||||
gui_chat_printf_y (struct t_gui_buffer *buffer, int y, const char *message, ...)
|
||||
{
|
||||
struct t_gui_line *ptr_line, *new_line, *new_line_empty;
|
||||
int i, last_y, num_lines_to_add;
|
||||
|
||||
if (gui_init_ok && !gui_chat_buffer_valid (buffer, GUI_BUFFER_TYPE_FREE))
|
||||
return;
|
||||
|
||||
/* if y is negative, add a line -N lines after the last line */
|
||||
if (y < 0)
|
||||
{
|
||||
y = (buffer->own_lines && buffer->own_lines->last_line) ?
|
||||
buffer->own_lines->last_line->data->y - y : (-1 * y) - 1;
|
||||
}
|
||||
|
||||
weechat_va_format (message);
|
||||
if (!vbuffer)
|
||||
return;
|
||||
|
||||
utf8_normalize (vbuffer, '?');
|
||||
|
||||
new_line = gui_line_new (buffer, y, 0, 0, NULL, NULL, vbuffer);
|
||||
if (!new_line)
|
||||
goto end;
|
||||
|
||||
hook_line_exec (new_line);
|
||||
|
||||
if (!new_line->data->buffer)
|
||||
{
|
||||
gui_line_free_data (new_line);
|
||||
free (new_line);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (new_line->data->message && new_line->data->message[0])
|
||||
{
|
||||
if (gui_init_ok)
|
||||
{
|
||||
/* compute the number of lines to add before y */
|
||||
if (new_line->data->buffer->own_lines
|
||||
&& new_line->data->buffer->own_lines->last_line)
|
||||
{
|
||||
num_lines_to_add = y - new_line->data->buffer->own_lines->last_line->data->y - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
num_lines_to_add = y;
|
||||
}
|
||||
if (num_lines_to_add > 0)
|
||||
{
|
||||
/*
|
||||
* add empty line(s) before asked line, to ensure there is at
|
||||
* least "y" lines in buffer, and then be able to scroll
|
||||
* properly buffer page by page
|
||||
*/
|
||||
for (i = y - num_lines_to_add; i < y; i++)
|
||||
{
|
||||
new_line_empty = gui_line_new (new_line->data->buffer,
|
||||
i, 0, 0, NULL, NULL, "");
|
||||
if (new_line_empty)
|
||||
gui_line_add_y (new_line_empty);
|
||||
}
|
||||
}
|
||||
gui_line_add_y (new_line);
|
||||
}
|
||||
else
|
||||
{
|
||||
string_fprintf (stdout, "%s\n", new_line->data->message);
|
||||
gui_line_free_data (new_line);
|
||||
free (new_line);
|
||||
}
|
||||
}
|
||||
else if (gui_init_ok)
|
||||
{
|
||||
/* delete line */
|
||||
last_y = (new_line->data->buffer->own_lines->last_line) ?
|
||||
new_line->data->buffer->own_lines->last_line->data->y : 0;
|
||||
if (y <= last_y)
|
||||
{
|
||||
for (ptr_line = new_line->data->buffer->own_lines->first_line;
|
||||
ptr_line; ptr_line = ptr_line->next_line)
|
||||
{
|
||||
if (ptr_line->data->y >= y)
|
||||
break;
|
||||
}
|
||||
if (ptr_line && (ptr_line->data->y == y))
|
||||
{
|
||||
if (ptr_line->next_line)
|
||||
gui_line_clear (ptr_line);
|
||||
else
|
||||
gui_line_free (new_line->data->buffer, ptr_line);
|
||||
gui_buffer_ask_chat_refresh (new_line->data->buffer, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
free (vbuffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Quotes a line.
|
||||
*/
|
||||
@ -1106,7 +1202,7 @@ gui_chat_end ()
|
||||
/* free lines waiting for buffer (should always be NULL here) */
|
||||
if (gui_chat_lines_waiting_buffer)
|
||||
{
|
||||
free (gui_chat_lines_waiting_buffer);
|
||||
string_dyn_free (gui_chat_lines_waiting_buffer, 1);
|
||||
gui_chat_lines_waiting_buffer = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -86,6 +86,8 @@ extern int gui_chat_get_time_length ();
|
||||
extern void gui_chat_change_time_format ();
|
||||
extern char *gui_chat_build_string_prefix_message (struct t_gui_line *line);
|
||||
extern char *gui_chat_build_string_message_tags (struct t_gui_line *line);
|
||||
extern int gui_chat_buffer_valid (struct t_gui_buffer *buffer,
|
||||
int buffer_type);
|
||||
extern void gui_chat_printf_date_tags (struct t_gui_buffer *buffer,
|
||||
time_t date, const char *tags,
|
||||
const char *message, ...);
|
||||
|
@ -39,29 +39,6 @@
|
||||
#include "gui-window.h"
|
||||
|
||||
|
||||
#define FOCUS_STR(__name, __string) \
|
||||
hashtable_set (hashtable, __name, __string);
|
||||
#define FOCUS_STR_VAR(__name, __var) \
|
||||
hashtable_set (hashtable, __name, (__var) ? __var : "");
|
||||
#define FOCUS_INT(__name, __int) \
|
||||
snprintf (str_value, sizeof (str_value), "%d", __int); \
|
||||
hashtable_set (hashtable, __name, str_value);
|
||||
#define FOCUS_TIME(__name, __time) \
|
||||
snprintf (str_value, sizeof (str_value), "%lld", (long long)__time); \
|
||||
hashtable_set (hashtable, __name, str_value);
|
||||
#define FOCUS_PTR(__name, __pointer) \
|
||||
if (__pointer) \
|
||||
{ \
|
||||
snprintf (str_value, sizeof (str_value), \
|
||||
"0x%lx", (long unsigned int)__pointer); \
|
||||
hashtable_set (hashtable, __name, str_value); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
hashtable_set (hashtable, __name, ""); \
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Gets info about what is pointed by cursor at (x,y).
|
||||
*
|
||||
@ -177,45 +154,45 @@ gui_focus_to_hashtable (struct t_gui_focus_info *focus_info, const char *key)
|
||||
return NULL;
|
||||
|
||||
/* key (key from keyboard or mouse event) */
|
||||
FOCUS_STR("_key", key);
|
||||
HASHTABLE_SET_STR("_key", key);
|
||||
|
||||
/* x,y */
|
||||
FOCUS_INT("_x", focus_info->x);
|
||||
FOCUS_INT("_y", focus_info->y);
|
||||
HASHTABLE_SET_INT("_x", focus_info->x);
|
||||
HASHTABLE_SET_INT("_y", focus_info->y);
|
||||
|
||||
/* window */
|
||||
FOCUS_PTR("_window", focus_info->window);
|
||||
HASHTABLE_SET_PTR("_window", focus_info->window);
|
||||
if (focus_info->window)
|
||||
{
|
||||
FOCUS_INT("_window_number", (focus_info->window)->number);
|
||||
HASHTABLE_SET_INT("_window_number", (focus_info->window)->number);
|
||||
}
|
||||
else
|
||||
{
|
||||
FOCUS_STR("_window_number", "*");
|
||||
HASHTABLE_SET_STR("_window_number", "*");
|
||||
}
|
||||
|
||||
/* buffer */
|
||||
FOCUS_PTR("_buffer", focus_info->buffer);
|
||||
HASHTABLE_SET_PTR("_buffer", focus_info->buffer);
|
||||
if (focus_info->buffer)
|
||||
{
|
||||
FOCUS_INT("_buffer_number", (focus_info->buffer)->number);
|
||||
FOCUS_STR("_buffer_plugin", plugin_get_name ((focus_info->buffer)->plugin));
|
||||
FOCUS_STR("_buffer_name", (focus_info->buffer)->name);
|
||||
FOCUS_STR("_buffer_full_name", (focus_info->buffer)->full_name);
|
||||
HASHTABLE_SET_INT("_buffer_number", (focus_info->buffer)->number);
|
||||
HASHTABLE_SET_STR("_buffer_plugin", plugin_get_name ((focus_info->buffer)->plugin));
|
||||
HASHTABLE_SET_STR("_buffer_name", (focus_info->buffer)->name);
|
||||
HASHTABLE_SET_STR("_buffer_full_name", (focus_info->buffer)->full_name);
|
||||
hashtable_map ((focus_info->buffer)->local_variables,
|
||||
&gui_focus_buffer_localvar_map_cb, hashtable);
|
||||
}
|
||||
else
|
||||
{
|
||||
FOCUS_PTR("_buffer", NULL);
|
||||
FOCUS_STR("_buffer_number", "-1");
|
||||
FOCUS_STR("_buffer_plugin", "");
|
||||
FOCUS_STR("_buffer_name", "");
|
||||
FOCUS_STR("_buffer_full_name", "");
|
||||
HASHTABLE_SET_PTR("_buffer", NULL);
|
||||
HASHTABLE_SET_STR("_buffer_number", "-1");
|
||||
HASHTABLE_SET_STR("_buffer_plugin", "");
|
||||
HASHTABLE_SET_STR("_buffer_name", "");
|
||||
HASHTABLE_SET_STR("_buffer_full_name", "");
|
||||
}
|
||||
|
||||
/* chat area */
|
||||
FOCUS_INT("_chat", focus_info->chat);
|
||||
HASHTABLE_SET_INT("_chat", focus_info->chat);
|
||||
str_time = NULL;
|
||||
str_prefix = NULL;
|
||||
if (focus_info->chat_line)
|
||||
@ -225,16 +202,16 @@ gui_focus_to_hashtable (struct t_gui_focus_info *focus_info, const char *key)
|
||||
str_tags = string_build_with_split_string ((const char **)((focus_info->chat_line)->data)->tags_array, ",");
|
||||
str_message = gui_color_decode (((focus_info->chat_line)->data)->message, NULL);
|
||||
nick = gui_line_get_nick_tag (focus_info->chat_line);
|
||||
FOCUS_PTR("_chat_line", focus_info->chat_line);
|
||||
FOCUS_INT("_chat_line_x", focus_info->chat_line_x);
|
||||
FOCUS_INT("_chat_line_y", ((focus_info->chat_line)->data)->y);
|
||||
FOCUS_TIME("_chat_line_date", ((focus_info->chat_line)->data)->date);
|
||||
FOCUS_TIME("_chat_line_date_printed", ((focus_info->chat_line)->data)->date_printed);
|
||||
FOCUS_STR_VAR("_chat_line_time", str_time);
|
||||
FOCUS_STR_VAR("_chat_line_tags", str_tags);
|
||||
FOCUS_STR_VAR("_chat_line_nick", nick);
|
||||
FOCUS_STR_VAR("_chat_line_prefix", str_prefix);
|
||||
FOCUS_STR_VAR("_chat_line_message", str_message);
|
||||
HASHTABLE_SET_PTR("_chat_line", focus_info->chat_line);
|
||||
HASHTABLE_SET_INT("_chat_line_x", focus_info->chat_line_x);
|
||||
HASHTABLE_SET_INT("_chat_line_y", ((focus_info->chat_line)->data)->y);
|
||||
HASHTABLE_SET_TIME("_chat_line_date", ((focus_info->chat_line)->data)->date);
|
||||
HASHTABLE_SET_TIME("_chat_line_date_printed", ((focus_info->chat_line)->data)->date_printed);
|
||||
HASHTABLE_SET_STR_NOT_NULL("_chat_line_time", str_time);
|
||||
HASHTABLE_SET_STR_NOT_NULL("_chat_line_tags", str_tags);
|
||||
HASHTABLE_SET_STR_NOT_NULL("_chat_line_nick", nick);
|
||||
HASHTABLE_SET_STR_NOT_NULL("_chat_line_prefix", str_prefix);
|
||||
HASHTABLE_SET_STR_NOT_NULL("_chat_line_message", str_message);
|
||||
if (str_time)
|
||||
free (str_time);
|
||||
if (str_prefix)
|
||||
@ -246,35 +223,35 @@ gui_focus_to_hashtable (struct t_gui_focus_info *focus_info, const char *key)
|
||||
}
|
||||
else
|
||||
{
|
||||
FOCUS_PTR("_chat_line", NULL);
|
||||
FOCUS_STR("_chat_line_x", "-1");
|
||||
FOCUS_STR("_chat_line_y", "-1");
|
||||
FOCUS_STR("_chat_line_date", "-1");
|
||||
FOCUS_STR("_chat_line_date_printed", "-1");
|
||||
FOCUS_STR("_chat_line_time", "");
|
||||
FOCUS_STR("_chat_line_tags", "");
|
||||
FOCUS_STR("_chat_line_nick", "");
|
||||
FOCUS_STR("_chat_line_prefix", "");
|
||||
FOCUS_STR("_chat_line_message", "");
|
||||
HASHTABLE_SET_PTR("_chat_line", NULL);
|
||||
HASHTABLE_SET_STR("_chat_line_x", "-1");
|
||||
HASHTABLE_SET_STR("_chat_line_y", "-1");
|
||||
HASHTABLE_SET_STR("_chat_line_date", "-1");
|
||||
HASHTABLE_SET_STR("_chat_line_date_printed", "-1");
|
||||
HASHTABLE_SET_STR("_chat_line_time", "");
|
||||
HASHTABLE_SET_STR("_chat_line_tags", "");
|
||||
HASHTABLE_SET_STR("_chat_line_nick", "");
|
||||
HASHTABLE_SET_STR("_chat_line_prefix", "");
|
||||
HASHTABLE_SET_STR("_chat_line_message", "");
|
||||
}
|
||||
FOCUS_STR_VAR("_chat_word", focus_info->chat_word);
|
||||
FOCUS_STR_VAR("_chat_bol", focus_info->chat_bol);
|
||||
FOCUS_STR_VAR("_chat_eol", focus_info->chat_eol);
|
||||
HASHTABLE_SET_STR_NOT_NULL("_chat_word", focus_info->chat_word);
|
||||
HASHTABLE_SET_STR_NOT_NULL("_chat_bol", focus_info->chat_bol);
|
||||
HASHTABLE_SET_STR_NOT_NULL("_chat_eol", focus_info->chat_eol);
|
||||
|
||||
/* bar/item */
|
||||
if (focus_info->bar_window)
|
||||
{
|
||||
FOCUS_STR("_bar_name", ((focus_info->bar_window)->bar)->name);
|
||||
FOCUS_STR("_bar_filling", gui_bar_filling_string[gui_bar_get_filling ((focus_info->bar_window)->bar)]);
|
||||
HASHTABLE_SET_STR("_bar_name", ((focus_info->bar_window)->bar)->name);
|
||||
HASHTABLE_SET_STR("_bar_filling", gui_bar_filling_string[gui_bar_get_filling ((focus_info->bar_window)->bar)]);
|
||||
}
|
||||
else
|
||||
{
|
||||
FOCUS_STR("_bar_name", "");
|
||||
FOCUS_STR("_bar_filling", "");
|
||||
HASHTABLE_SET_STR("_bar_name", "");
|
||||
HASHTABLE_SET_STR("_bar_filling", "");
|
||||
}
|
||||
FOCUS_STR_VAR("_bar_item_name", focus_info->bar_item);
|
||||
FOCUS_INT("_bar_item_line", focus_info->bar_item_line);
|
||||
FOCUS_INT("_bar_item_col", focus_info->bar_item_col);
|
||||
HASHTABLE_SET_STR_NOT_NULL("_bar_item_name", focus_info->bar_item);
|
||||
HASHTABLE_SET_INT("_bar_item_line", focus_info->bar_item_line);
|
||||
HASHTABLE_SET_INT("_bar_item_col", focus_info->bar_item_col);
|
||||
|
||||
return hashtable;
|
||||
}
|
||||
|
@ -976,6 +976,25 @@ gui_line_add_to_list (struct t_gui_lines *lines,
|
||||
lines->lines_count++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Frees data in a line.
|
||||
*/
|
||||
|
||||
void
|
||||
gui_line_free_data (struct t_gui_line *line)
|
||||
{
|
||||
if (line->data->str_time)
|
||||
free (line->data->str_time);
|
||||
gui_line_tags_free (line->data);
|
||||
if (line->data->prefix)
|
||||
string_shared_free (line->data->prefix);
|
||||
if (line->data->message)
|
||||
free (line->data->message);
|
||||
free (line->data);
|
||||
|
||||
line->data = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Removes a line from a "t_gui_lines" structure.
|
||||
*/
|
||||
@ -1041,16 +1060,7 @@ gui_line_remove_from_list (struct t_gui_buffer *buffer,
|
||||
|
||||
/* free data */
|
||||
if (free_data)
|
||||
{
|
||||
if (line->data->str_time)
|
||||
free (line->data->str_time);
|
||||
gui_line_tags_free (line->data);
|
||||
if (line->data->prefix)
|
||||
string_shared_free (line->data->prefix);
|
||||
if (line->data->message)
|
||||
free (line->data->message);
|
||||
free (line->data);
|
||||
}
|
||||
gui_line_free_data (line);
|
||||
|
||||
/* remove line from list */
|
||||
if (line->prev_line)
|
||||
@ -1189,37 +1199,323 @@ gui_line_free_all (struct t_gui_buffer *buffer)
|
||||
int
|
||||
gui_line_get_notify_level (struct t_gui_line *line)
|
||||
{
|
||||
int i;
|
||||
int i, notify_level, *max_notify_level;
|
||||
const char *nick;
|
||||
|
||||
notify_level = GUI_HOTLIST_LOW;
|
||||
|
||||
for (i = 0; i < line->data->tags_count; i++)
|
||||
{
|
||||
if (string_strcasecmp (line->data->tags_array[i], "notify_none") == 0)
|
||||
return -1;
|
||||
notify_level = -1;
|
||||
if (string_strcasecmp (line->data->tags_array[i], "notify_highlight") == 0)
|
||||
return GUI_HOTLIST_HIGHLIGHT;
|
||||
notify_level = GUI_HOTLIST_HIGHLIGHT;
|
||||
if (string_strcasecmp (line->data->tags_array[i], "notify_private") == 0)
|
||||
return GUI_HOTLIST_PRIVATE;
|
||||
notify_level = GUI_HOTLIST_PRIVATE;
|
||||
if (string_strcasecmp (line->data->tags_array[i], "notify_message") == 0)
|
||||
return GUI_HOTLIST_MESSAGE;
|
||||
notify_level = GUI_HOTLIST_MESSAGE;
|
||||
}
|
||||
return GUI_HOTLIST_LOW;
|
||||
|
||||
max_notify_level = NULL;
|
||||
nick = gui_line_get_nick_tag (line);
|
||||
if (nick)
|
||||
{
|
||||
max_notify_level = hashtable_get (line->data->buffer->hotlist_max_level_nicks,
|
||||
nick);
|
||||
}
|
||||
if (max_notify_level && (*max_notify_level < notify_level))
|
||||
notify_level = *max_notify_level;
|
||||
|
||||
return notify_level;
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds a new line for a buffer.
|
||||
* Gets highlight flag for a line, using the notify level in the line.
|
||||
*
|
||||
* Returns 1 for highlight otherwise 0.
|
||||
*/
|
||||
|
||||
int
|
||||
gui_line_get_highlight (struct t_gui_line *line)
|
||||
{
|
||||
int highlight, *max_notify_level;
|
||||
const char *nick;
|
||||
|
||||
highlight = 0;
|
||||
|
||||
if (line->data->notify_level == GUI_HOTLIST_HIGHLIGHT)
|
||||
{
|
||||
highlight = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
max_notify_level = NULL;
|
||||
nick = gui_line_get_nick_tag (line);
|
||||
if (nick)
|
||||
{
|
||||
max_notify_level = hashtable_get (line->data->buffer->hotlist_max_level_nicks,
|
||||
nick);
|
||||
}
|
||||
if (max_notify_level && (*max_notify_level < GUI_HOTLIST_HIGHLIGHT))
|
||||
highlight = 0;
|
||||
else
|
||||
highlight = gui_line_has_highlight (line);
|
||||
}
|
||||
|
||||
return highlight;
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates a new line for a buffer.
|
||||
*/
|
||||
|
||||
struct t_gui_line *
|
||||
gui_line_add (struct t_gui_buffer *buffer, time_t date,
|
||||
gui_line_new (struct t_gui_buffer *buffer, int y, time_t date,
|
||||
time_t date_printed, const char *tags,
|
||||
const char *prefix, const char *message)
|
||||
{
|
||||
struct t_gui_line *new_line;
|
||||
struct t_gui_line_data *new_line_data;
|
||||
|
||||
/* create new line */
|
||||
new_line = malloc (sizeof (*new_line));
|
||||
if (!new_line)
|
||||
return NULL;
|
||||
|
||||
/* create data for line */
|
||||
new_line_data = malloc (sizeof (*new_line_data));
|
||||
if (!new_line_data)
|
||||
{
|
||||
free (new_line);
|
||||
return NULL;
|
||||
}
|
||||
new_line->data = new_line_data;
|
||||
|
||||
/* fill data in new line */
|
||||
new_line->data->buffer = buffer;
|
||||
new_line->data->message = (message) ? strdup (message) : strdup ("");
|
||||
|
||||
if (buffer->type == GUI_BUFFER_TYPE_FORMATTED)
|
||||
{
|
||||
new_line->data->y = -1;
|
||||
new_line->data->date = date;
|
||||
new_line->data->date_printed = date_printed;
|
||||
new_line->data->str_time = gui_chat_get_time_string (date);
|
||||
gui_line_tags_alloc (new_line->data, tags);
|
||||
new_line->data->refresh_needed = 0;
|
||||
new_line->data->prefix = (prefix) ?
|
||||
(char *)string_shared_get (prefix) : ((date != 0) ? (char *)string_shared_get ("") : NULL);
|
||||
new_line->data->prefix_length = (prefix) ?
|
||||
gui_chat_strlen_screen (prefix) : 0;
|
||||
new_line->data->notify_level = gui_line_get_notify_level (new_line);
|
||||
new_line->data->highlight = gui_line_get_highlight (new_line);
|
||||
}
|
||||
else
|
||||
{
|
||||
new_line->data->y = y;
|
||||
new_line->data->date = 0;
|
||||
new_line->data->date_printed = 0;
|
||||
new_line->data->str_time = NULL;
|
||||
new_line->data->tags_count = 0;
|
||||
new_line->data->tags_array = NULL;
|
||||
new_line->data->refresh_needed = 1;
|
||||
new_line->data->prefix = NULL;
|
||||
new_line->data->prefix_length = 0;
|
||||
new_line->data->notify_level = 0;
|
||||
new_line->data->highlight = 0;
|
||||
}
|
||||
|
||||
/* set display flag (check if line is filtered or not) */
|
||||
new_line->data->displayed = gui_filter_check_line (new_line->data);
|
||||
|
||||
new_line->prev_line = NULL;
|
||||
new_line->next_line = NULL;
|
||||
|
||||
return new_line;
|
||||
}
|
||||
|
||||
/*
|
||||
* Updates data in a line via the hook_line.
|
||||
*/
|
||||
|
||||
void
|
||||
gui_line_hook_update (struct t_gui_line *line,
|
||||
struct t_hashtable *hashtable,
|
||||
struct t_hashtable *hashtable2)
|
||||
{
|
||||
const char *ptr_value, *ptr_value2;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
long unsigned int value_pointer;
|
||||
long value;
|
||||
char *error;
|
||||
int rc, tags_updated, notify_level_updated, highlight_updated;
|
||||
|
||||
tags_updated = 0;
|
||||
notify_level_updated = 0;
|
||||
highlight_updated = 0;
|
||||
|
||||
ptr_value2 = hashtable_get (hashtable2, "buffer_name");
|
||||
if (ptr_value2)
|
||||
{
|
||||
if (ptr_value2[0])
|
||||
{
|
||||
ptr_buffer = gui_buffer_search_by_full_name (ptr_value2);
|
||||
if (gui_chat_buffer_valid (ptr_buffer, line->data->buffer->type))
|
||||
line->data->buffer = ptr_buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
line->data->buffer = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr_value2 = hashtable_get (hashtable2, "buffer");
|
||||
if (ptr_value2)
|
||||
{
|
||||
if (ptr_value2[0])
|
||||
{
|
||||
if ((ptr_value2[0] == '0') && (ptr_value2[1] == 'x'))
|
||||
{
|
||||
rc = sscanf (ptr_value2 + 2, "%lx", &value_pointer);
|
||||
ptr_buffer = (struct t_gui_buffer *)value_pointer;
|
||||
if ((rc != EOF) && (rc >= 1)
|
||||
&& gui_chat_buffer_valid (ptr_buffer, line->data->buffer->type))
|
||||
{
|
||||
line->data->buffer = ptr_buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
line->data->buffer = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (line->data->buffer->type == GUI_BUFFER_TYPE_FREE)
|
||||
{
|
||||
/* the field "y" can be changed on buffer with free content */
|
||||
ptr_value = hashtable_get (hashtable2, "y");
|
||||
if (ptr_value)
|
||||
{
|
||||
error = NULL;
|
||||
value = strtol (ptr_value, &error, 10);
|
||||
if (error && !error[0] && (value >= 0))
|
||||
line->data->y = value;
|
||||
}
|
||||
}
|
||||
|
||||
ptr_value2 = hashtable_get (hashtable2, "date");
|
||||
if (ptr_value2)
|
||||
{
|
||||
error = NULL;
|
||||
value = strtol (ptr_value2, &error, 10);
|
||||
if (error && !error[0] && (value >= 0))
|
||||
{
|
||||
line->data->date = (time_t)value;
|
||||
if (line->data->str_time)
|
||||
free (line->data->str_time);
|
||||
line->data->str_time = gui_chat_get_time_string (line->data->date);
|
||||
}
|
||||
}
|
||||
|
||||
ptr_value2 = hashtable_get (hashtable2, "date_printed");
|
||||
if (ptr_value2)
|
||||
{
|
||||
error = NULL;
|
||||
value = strtol (ptr_value2, &error, 10);
|
||||
if (error && !error[0] && (value >= 0))
|
||||
line->data->date_printed = (time_t)value;
|
||||
}
|
||||
|
||||
ptr_value = hashtable_get (hashtable, "str_time");
|
||||
ptr_value2 = hashtable_get (hashtable2, "str_time");
|
||||
if (ptr_value2 && (!ptr_value || (strcmp (ptr_value, ptr_value2) != 0)))
|
||||
{
|
||||
if (line->data->str_time)
|
||||
free (line->data->str_time);
|
||||
line->data->str_time = (ptr_value2) ? strdup (ptr_value2) : NULL;
|
||||
}
|
||||
|
||||
ptr_value = hashtable_get (hashtable, "tags");
|
||||
ptr_value2 = hashtable_get (hashtable2, "tags");
|
||||
if (ptr_value2 && (!ptr_value || (strcmp (ptr_value, ptr_value2) != 0)))
|
||||
{
|
||||
tags_updated = 1;
|
||||
gui_line_tags_free (line->data);
|
||||
gui_line_tags_alloc (line->data, ptr_value2);
|
||||
}
|
||||
|
||||
ptr_value2 = hashtable_get (hashtable2, "notify_level");
|
||||
if (ptr_value2)
|
||||
{
|
||||
error = NULL;
|
||||
value = strtol (ptr_value2, &error, 10);
|
||||
if (error && !error[0] && (value >= -1) && (value <= GUI_HOTLIST_MAX))
|
||||
{
|
||||
notify_level_updated = 1;
|
||||
line->data->notify_level = value;
|
||||
}
|
||||
}
|
||||
|
||||
ptr_value2 = hashtable_get (hashtable2, "highlight");
|
||||
if (ptr_value2)
|
||||
{
|
||||
error = NULL;
|
||||
value = strtol (ptr_value2, &error, 10);
|
||||
if (error && !error[0])
|
||||
{
|
||||
highlight_updated = 1;
|
||||
line->data->highlight = (value) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
ptr_value = hashtable_get (hashtable, "prefix");
|
||||
ptr_value2 = hashtable_get (hashtable2, "prefix");
|
||||
if (ptr_value2 && (!ptr_value || (strcmp (ptr_value, ptr_value2) != 0)))
|
||||
{
|
||||
if (line->data->prefix)
|
||||
string_shared_free (line->data->prefix);
|
||||
line->data->prefix = (char *)string_shared_get (
|
||||
(ptr_value2) ? ptr_value2 : "");
|
||||
line->data->prefix_length = (line->data->prefix) ?
|
||||
gui_chat_strlen_screen (line->data->prefix) : 0;
|
||||
}
|
||||
|
||||
ptr_value = hashtable_get (hashtable, "message");
|
||||
ptr_value2 = hashtable_get (hashtable2, "message");
|
||||
if (ptr_value2 && (!ptr_value || (strcmp (ptr_value, ptr_value2) != 0)))
|
||||
{
|
||||
if (line->data->message)
|
||||
free (line->data->message);
|
||||
line->data->message = (ptr_value2) ? strdup (ptr_value2) : NULL;
|
||||
}
|
||||
|
||||
/* if tags were updated but not notify_level, adjust notify level */
|
||||
if (tags_updated && !notify_level_updated)
|
||||
line->data->notify_level = gui_line_get_notify_level (line);
|
||||
|
||||
/* adjust flag "displayed" if tags were updated */
|
||||
if (tags_updated)
|
||||
line->data->displayed = gui_filter_check_line (line->data);
|
||||
|
||||
if ((tags_updated || notify_level_updated) && !highlight_updated)
|
||||
line->data->highlight = gui_line_get_highlight (line);
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds a new line in a buffer with formatted content.
|
||||
*/
|
||||
|
||||
void
|
||||
gui_line_add (struct t_gui_line *line)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
char *message_for_signal;
|
||||
const char *nick;
|
||||
int notify_level, *max_notify_level, lines_removed;
|
||||
int lines_removed;
|
||||
time_t current_time;
|
||||
|
||||
/*
|
||||
@ -1229,82 +1525,32 @@ gui_line_add (struct t_gui_buffer *buffer, time_t date,
|
||||
*/
|
||||
lines_removed = 0;
|
||||
current_time = time (NULL);
|
||||
while (buffer->own_lines->first_line
|
||||
while (line->data->buffer->own_lines->first_line
|
||||
&& (((CONFIG_INTEGER(config_history_max_buffer_lines_number) > 0)
|
||||
&& (buffer->own_lines->lines_count + 1 >
|
||||
&& (line->data->buffer->own_lines->lines_count + 1 >
|
||||
CONFIG_INTEGER(config_history_max_buffer_lines_number)))
|
||||
|| ((CONFIG_INTEGER(config_history_max_buffer_lines_minutes) > 0)
|
||||
&& (current_time - buffer->own_lines->first_line->data->date_printed >
|
||||
&& (current_time - line->data->buffer->own_lines->first_line->data->date_printed >
|
||||
CONFIG_INTEGER(config_history_max_buffer_lines_minutes) * 60))))
|
||||
{
|
||||
gui_line_free (buffer, buffer->own_lines->first_line);
|
||||
gui_line_free (line->data->buffer,
|
||||
line->data->buffer->own_lines->first_line);
|
||||
lines_removed++;
|
||||
}
|
||||
|
||||
/* create new line */
|
||||
new_line = malloc (sizeof (*new_line));
|
||||
if (!new_line)
|
||||
{
|
||||
log_printf (_("Not enough memory for new line"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* create data for line */
|
||||
new_line_data = malloc (sizeof (*new_line_data));
|
||||
if (!new_line_data)
|
||||
{
|
||||
free (new_line);
|
||||
log_printf (_("Not enough memory for new line"));
|
||||
return NULL;
|
||||
}
|
||||
new_line->data = new_line_data;
|
||||
|
||||
/* fill data in new line */
|
||||
new_line->data->buffer = buffer;
|
||||
new_line->data->y = -1;
|
||||
new_line->data->date = date;
|
||||
new_line->data->date_printed = date_printed;
|
||||
new_line->data->str_time = gui_chat_get_time_string (date);
|
||||
gui_line_tags_alloc (new_line->data, tags);
|
||||
new_line->data->refresh_needed = 0;
|
||||
new_line->data->prefix = (prefix) ?
|
||||
(char *)string_shared_get (prefix) : ((date != 0) ? (char *)string_shared_get ("") : NULL);
|
||||
new_line->data->prefix_length = (prefix) ?
|
||||
gui_chat_strlen_screen (prefix) : 0;
|
||||
new_line->data->message = (message) ? strdup (message) : strdup ("");
|
||||
|
||||
/* get notify level and max notify level for nick in buffer */
|
||||
notify_level = gui_line_get_notify_level (new_line);
|
||||
max_notify_level = NULL;
|
||||
nick = gui_line_get_nick_tag (new_line);
|
||||
if (nick)
|
||||
max_notify_level = hashtable_get (buffer->hotlist_max_level_nicks, nick);
|
||||
if (max_notify_level
|
||||
&& (*max_notify_level < notify_level))
|
||||
notify_level = *max_notify_level;
|
||||
|
||||
if (notify_level == GUI_HOTLIST_HIGHLIGHT)
|
||||
new_line->data->highlight = 1;
|
||||
else if (max_notify_level && (*max_notify_level < GUI_HOTLIST_HIGHLIGHT))
|
||||
new_line->data->highlight = 0;
|
||||
else
|
||||
new_line->data->highlight = gui_line_has_highlight (new_line);
|
||||
|
||||
/* check if line is filtered or not */
|
||||
new_line->data->displayed = gui_filter_check_line (new_line->data);
|
||||
|
||||
/* add line to lines list */
|
||||
gui_line_add_to_list (buffer->own_lines, new_line);
|
||||
gui_line_add_to_list (line->data->buffer->own_lines, line);
|
||||
|
||||
/* update hotlist and/or send signals for line */
|
||||
if (new_line->data->displayed)
|
||||
if (line->data->displayed)
|
||||
{
|
||||
if (new_line->data->highlight)
|
||||
if (line->data->highlight)
|
||||
{
|
||||
(void) gui_hotlist_add (buffer, GUI_HOTLIST_HIGHLIGHT, NULL);
|
||||
(void) gui_hotlist_add (line->data->buffer,
|
||||
GUI_HOTLIST_HIGHLIGHT, NULL);
|
||||
if (!weechat_upgrading)
|
||||
{
|
||||
message_for_signal = gui_chat_build_string_prefix_message (new_line);
|
||||
message_for_signal = gui_chat_build_string_prefix_message (line);
|
||||
if (message_for_signal)
|
||||
{
|
||||
(void) hook_signal_send ("weechat_highlight",
|
||||
@ -1316,9 +1562,10 @@ gui_line_add (struct t_gui_buffer *buffer, time_t date,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!weechat_upgrading && (notify_level == GUI_HOTLIST_PRIVATE))
|
||||
if (!weechat_upgrading
|
||||
&& (line->data->notify_level == GUI_HOTLIST_PRIVATE))
|
||||
{
|
||||
message_for_signal = gui_chat_build_string_prefix_message (new_line);
|
||||
message_for_signal = gui_chat_build_string_prefix_message (line);
|
||||
if (message_for_signal)
|
||||
{
|
||||
(void) hook_signal_send ("weechat_pv",
|
||||
@ -1327,20 +1574,24 @@ gui_line_add (struct t_gui_buffer *buffer, time_t date,
|
||||
free (message_for_signal);
|
||||
}
|
||||
}
|
||||
if (notify_level >= GUI_HOTLIST_MIN)
|
||||
(void) gui_hotlist_add (buffer, notify_level, NULL);
|
||||
if (line->data->notify_level >= GUI_HOTLIST_MIN)
|
||||
{
|
||||
(void) gui_hotlist_add (line->data->buffer,
|
||||
line->data->notify_level, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
(void) hook_signal_send ("buffer_lines_hidden",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
|
||||
WEECHAT_HOOK_SIGNAL_POINTER,
|
||||
line->data->buffer);
|
||||
}
|
||||
|
||||
/* add mixed line, if buffer is attached to at least one other buffer */
|
||||
if (buffer->mixed_lines)
|
||||
if (line->data->buffer->mixed_lines)
|
||||
{
|
||||
gui_line_mixed_add (buffer->mixed_lines, new_line->data);
|
||||
gui_line_mixed_add (line->data->buffer->mixed_lines, line->data);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1352,125 +1603,108 @@ gui_line_add (struct t_gui_buffer *buffer, time_t date,
|
||||
{
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if ((ptr_win->buffer == buffer)
|
||||
&& (buffer->own_lines->lines_count < ptr_win->win_chat_height))
|
||||
if ((ptr_win->buffer == line->data->buffer)
|
||||
&& (line->data->buffer->own_lines->lines_count < ptr_win->win_chat_height))
|
||||
{
|
||||
gui_buffer_ask_chat_refresh (buffer, 2);
|
||||
gui_buffer_ask_chat_refresh (line->data->buffer, 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(void) hook_signal_send ("buffer_line_added",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, new_line);
|
||||
|
||||
return new_line;
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, line);
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds or updates a line for a buffer with free content.
|
||||
* Adds or updates a line in a buffer with free content.
|
||||
*
|
||||
* Ba careful: when replacing an existing line in the buffer, the "line"
|
||||
* pointer received as parameter is freed and then becomes invalid.
|
||||
* So this pointer must not be used after the call to this function.
|
||||
*/
|
||||
|
||||
void
|
||||
gui_line_add_y (struct t_gui_buffer *buffer, int y, const char *message)
|
||||
gui_line_add_y (struct t_gui_line *line)
|
||||
{
|
||||
struct t_gui_line *ptr_line, *new_line;
|
||||
struct t_gui_line_data *new_line_data;
|
||||
struct t_gui_line *ptr_line;
|
||||
struct t_gui_window *ptr_win;
|
||||
int old_line_displayed;
|
||||
|
||||
/* search if line exists for "y" */
|
||||
for (ptr_line = buffer->own_lines->first_line; ptr_line;
|
||||
for (ptr_line = line->data->buffer->own_lines->first_line; ptr_line;
|
||||
ptr_line = ptr_line->next_line)
|
||||
{
|
||||
if (ptr_line->data->y >= y)
|
||||
if (ptr_line->data->y >= line->data->y)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ptr_line || (ptr_line->data->y > y))
|
||||
if (ptr_line && (ptr_line->data->y == line->data->y))
|
||||
{
|
||||
new_line = malloc (sizeof (*new_line));
|
||||
if (!new_line)
|
||||
/* replace line data with the new data */
|
||||
old_line_displayed = ptr_line->data->displayed;
|
||||
if (ptr_line->data->message)
|
||||
{
|
||||
log_printf (_("Not enough memory for new line"));
|
||||
return;
|
||||
/* remove line from coords if the content is changing */
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
gui_window_coords_remove_line (ptr_win, ptr_line);
|
||||
}
|
||||
}
|
||||
|
||||
new_line_data = malloc (sizeof (*new_line_data));
|
||||
if (!new_line_data)
|
||||
{
|
||||
free (new_line);
|
||||
log_printf (_("Not enough memory for new line"));
|
||||
return;
|
||||
}
|
||||
new_line->data = new_line_data;
|
||||
|
||||
buffer->own_lines->lines_count++;
|
||||
|
||||
/* fill data in new line */
|
||||
new_line->data->buffer = buffer;
|
||||
new_line->data->y = y;
|
||||
new_line->data->date = 0;
|
||||
new_line->data->date_printed = 0;
|
||||
new_line->data->str_time = NULL;
|
||||
new_line->data->tags_count = 0;
|
||||
new_line->data->tags_array = NULL;
|
||||
new_line->data->refresh_needed = 1;
|
||||
new_line->data->prefix = NULL;
|
||||
new_line->data->prefix_length = 0;
|
||||
new_line->data->message = NULL;
|
||||
new_line->data->highlight = 0;
|
||||
|
||||
/* replace ptr_line by line in list */
|
||||
gui_line_free_data (ptr_line);
|
||||
ptr_line->data = line->data;
|
||||
free (line);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* add line to lines list */
|
||||
old_line_displayed = 1;
|
||||
if (ptr_line)
|
||||
{
|
||||
/* add before line found */
|
||||
new_line->prev_line = ptr_line->prev_line;
|
||||
new_line->next_line = ptr_line;
|
||||
line->prev_line = ptr_line->prev_line;
|
||||
line->next_line = ptr_line;
|
||||
if (ptr_line->prev_line)
|
||||
(ptr_line->prev_line)->next_line = new_line;
|
||||
(ptr_line->prev_line)->next_line = line;
|
||||
else
|
||||
buffer->own_lines->first_line = new_line;
|
||||
ptr_line->prev_line = new_line;
|
||||
line->data->buffer->own_lines->first_line = line;
|
||||
ptr_line->prev_line = line;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* add at end of list */
|
||||
new_line->prev_line = buffer->own_lines->last_line;
|
||||
if (buffer->own_lines->first_line)
|
||||
buffer->own_lines->last_line->next_line = new_line;
|
||||
line->prev_line = line->data->buffer->own_lines->last_line;
|
||||
if (line->data->buffer->own_lines->first_line)
|
||||
line->data->buffer->own_lines->last_line->next_line = line;
|
||||
else
|
||||
buffer->own_lines->first_line = new_line;
|
||||
buffer->own_lines->last_line = new_line;
|
||||
new_line->next_line = NULL;
|
||||
line->data->buffer->own_lines->first_line = line;
|
||||
line->data->buffer->own_lines->last_line = line;
|
||||
line->next_line = NULL;
|
||||
}
|
||||
ptr_line = line;
|
||||
|
||||
ptr_line = new_line;
|
||||
line->data->buffer->own_lines->lines_count++;
|
||||
}
|
||||
|
||||
/* set message for line */
|
||||
if (ptr_line->data->message)
|
||||
{
|
||||
/* remove line from coords if the content is changing */
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
gui_window_coords_remove_line (ptr_win, ptr_line);
|
||||
}
|
||||
|
||||
/* free message in line */
|
||||
free (ptr_line->data->message);
|
||||
}
|
||||
ptr_line->data->message = (message) ? strdup (message) : strdup ("");
|
||||
|
||||
/* check if line is filtered or not */
|
||||
ptr_line->data->displayed = gui_filter_check_line (ptr_line->data);
|
||||
if (!ptr_line->data->displayed)
|
||||
if (old_line_displayed && !ptr_line->data->displayed)
|
||||
{
|
||||
buffer->own_lines->lines_hidden++;
|
||||
(ptr_line->data->buffer->own_lines->lines_hidden)++;
|
||||
(void) hook_signal_send ("buffer_lines_hidden",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
|
||||
WEECHAT_HOOK_SIGNAL_POINTER,
|
||||
ptr_line->data->buffer);
|
||||
}
|
||||
else if (!old_line_displayed && ptr_line->data->displayed)
|
||||
{
|
||||
if (ptr_line->data->buffer->own_lines->lines_hidden > 0)
|
||||
(ptr_line->data->buffer->own_lines->lines_hidden)--;
|
||||
}
|
||||
|
||||
ptr_line->data->refresh_needed = 1;
|
||||
|
||||
gui_buffer_ask_chat_refresh (ptr_line->data->buffer, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1754,6 +1988,7 @@ gui_line_hdata_line_data_cb (const void *pointer, void *data,
|
||||
HDATA_VAR(struct t_gui_line_data, tags_count, INTEGER, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_gui_line_data, tags_array, SHARED_STRING, 1, "tags_count", NULL);
|
||||
HDATA_VAR(struct t_gui_line_data, displayed, CHAR, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_gui_line_data, notify_level, CHAR, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_gui_line_data, highlight, CHAR, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_gui_line_data, refresh_needed, CHAR, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_gui_line_data, prefix, SHARED_STRING, 1, NULL, NULL);
|
||||
@ -1827,6 +2062,8 @@ gui_line_add_to_infolist (struct t_infolist *infolist,
|
||||
|
||||
if (!infolist_new_var_integer (ptr_item, "displayed", line->data->displayed))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "notify_level", line->data->notify_level))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "highlight", line->data->highlight))
|
||||
return 0;
|
||||
if (!infolist_new_var_string (ptr_item, "prefix", line->data->prefix))
|
||||
|
@ -37,6 +37,7 @@ struct t_gui_line_data
|
||||
int tags_count; /* number of tags for line */
|
||||
char **tags_array; /* tags for line */
|
||||
char displayed; /* 1 if line is displayed */
|
||||
char notify_level; /* notify level for the line */
|
||||
char highlight; /* 1 if line has highlight */
|
||||
char refresh_needed; /* 1 if refresh asked (free buffer) */
|
||||
char *prefix; /* prefix for line (may be NULL) */
|
||||
@ -102,18 +103,23 @@ extern void gui_line_compute_buffer_max_length (struct t_gui_buffer *buffer,
|
||||
extern void gui_line_compute_prefix_max_length (struct t_gui_lines *lines);
|
||||
extern void gui_line_mixed_free_buffer (struct t_gui_buffer *buffer);
|
||||
extern void gui_line_mixed_free_all (struct t_gui_buffer *buffer);
|
||||
extern void gui_line_free_data (struct t_gui_line *line);
|
||||
extern void gui_line_free (struct t_gui_buffer *buffer,
|
||||
struct t_gui_line *line);
|
||||
extern void gui_line_free_all (struct t_gui_buffer *buffer);
|
||||
extern int gui_line_get_notify_level (struct t_gui_line *line);
|
||||
extern struct t_gui_line *gui_line_add (struct t_gui_buffer *buffer,
|
||||
extern struct t_gui_line *gui_line_new (struct t_gui_buffer *buffer,
|
||||
int y,
|
||||
time_t date,
|
||||
time_t date_printed,
|
||||
const char *tags,
|
||||
const char *prefix,
|
||||
const char *message);
|
||||
extern void gui_line_add_y (struct t_gui_buffer *buffer, int y,
|
||||
const char *message);
|
||||
extern void gui_line_hook_update (struct t_gui_line *line,
|
||||
struct t_hashtable *hashtable,
|
||||
struct t_hashtable *hashtable2);
|
||||
extern void gui_line_add (struct t_gui_line *line);
|
||||
extern void gui_line_add_y (struct t_gui_line *line);
|
||||
extern void gui_line_clear (struct t_gui_line *line);
|
||||
extern void gui_line_mix_buffers (struct t_gui_buffer *buffer);
|
||||
extern struct t_hdata *gui_line_hdata_lines_cb (const void *pointer,
|
||||
|
@ -2454,6 +2454,58 @@ weechat_guile_api_hook_connect (SCM proxy, SCM address, SCM port, SCM ipv6,
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
struct t_hashtable *
|
||||
weechat_guile_api_hook_line_cb (const void *pointer, void *data,
|
||||
struct t_hashtable *line)
|
||||
{
|
||||
struct t_plugin_script *script;
|
||||
void *func_argv[2];
|
||||
char empty_arg[1] = { '\0' };
|
||||
const char *ptr_function, *ptr_data;
|
||||
|
||||
script = (struct t_plugin_script *)pointer;
|
||||
plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
|
||||
|
||||
if (ptr_function && ptr_function[0])
|
||||
{
|
||||
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
|
||||
func_argv[1] = line;
|
||||
|
||||
return (struct t_hashtable *)weechat_guile_exec (
|
||||
script,
|
||||
WEECHAT_SCRIPT_EXEC_HASHTABLE,
|
||||
ptr_function,
|
||||
"sh", func_argv);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SCM
|
||||
weechat_guile_api_hook_line (SCM buffer_type, SCM buffer_name, SCM tags,
|
||||
SCM function, SCM data)
|
||||
{
|
||||
const char *result;
|
||||
SCM return_value;
|
||||
|
||||
API_INIT_FUNC(1, "hook_line", API_RETURN_EMPTY);
|
||||
if (!scm_is_string (buffer_type) || !scm_is_string (buffer_name)
|
||||
|| !scm_is_string (tags) || !scm_is_string (function)
|
||||
|| !scm_is_string (data))
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
result = API_PTR2STR(plugin_script_api_hook_line (weechat_guile_plugin,
|
||||
guile_current_script,
|
||||
API_SCM_TO_STRING(buffer_type),
|
||||
API_SCM_TO_STRING(buffer_name),
|
||||
API_SCM_TO_STRING(tags),
|
||||
&weechat_guile_api_hook_line_cb,
|
||||
API_SCM_TO_STRING(function),
|
||||
API_SCM_TO_STRING(data)));
|
||||
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
int
|
||||
weechat_guile_api_hook_print_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
@ -4884,6 +4936,7 @@ weechat_guile_api_module_init (void *data)
|
||||
API_DEF_FUNC(hook_process, 4);
|
||||
API_DEF_FUNC(hook_process_hashtable, 5);
|
||||
API_DEF_FUNC(hook_connect, 8);
|
||||
API_DEF_FUNC(hook_line, 5);
|
||||
API_DEF_FUNC(hook_print, 6);
|
||||
API_DEF_FUNC(hook_signal, 3);
|
||||
API_DEF_FUNC(hook_signal_send, 3);
|
||||
|
@ -2361,6 +2361,62 @@ API_FUNC(hook_connect)
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
struct t_hashtable *
|
||||
weechat_js_api_hook_line_cb (const void *pointer, void *data,
|
||||
struct t_hashtable *line)
|
||||
{
|
||||
struct t_plugin_script *script;
|
||||
void *func_argv[2];
|
||||
char empty_arg[1] = { '\0' };
|
||||
const char *ptr_function, *ptr_data;
|
||||
struct t_hashtable *ret_hashtable;
|
||||
|
||||
script = (struct t_plugin_script *)pointer;
|
||||
plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
|
||||
|
||||
if (ptr_function && ptr_function[0])
|
||||
{
|
||||
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
|
||||
func_argv[1] = line;
|
||||
|
||||
ret_hashtable = (struct t_hashtable *)weechat_js_exec (
|
||||
script,
|
||||
WEECHAT_SCRIPT_EXEC_HASHTABLE,
|
||||
ptr_function,
|
||||
"sh", func_argv);
|
||||
|
||||
return ret_hashtable;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
API_FUNC(hook_line)
|
||||
{
|
||||
const char *result;
|
||||
|
||||
API_INIT_FUNC(1, "hook_line", "sssss", API_RETURN_EMPTY);
|
||||
|
||||
v8::String::Utf8Value buffer_type(args[0]);
|
||||
v8::String::Utf8Value buffer_name(args[1]);
|
||||
v8::String::Utf8Value tags(args[2]);
|
||||
v8::String::Utf8Value function(args[3]);
|
||||
v8::String::Utf8Value data(args[4]);
|
||||
|
||||
result = API_PTR2STR(
|
||||
plugin_script_api_hook_line (
|
||||
weechat_js_plugin,
|
||||
js_current_script,
|
||||
*buffer_type,
|
||||
*buffer_name,
|
||||
*tags,
|
||||
&weechat_js_api_hook_line_cb,
|
||||
*function,
|
||||
*data));
|
||||
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
int
|
||||
weechat_js_api_hook_print_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
@ -4831,6 +4887,7 @@ WeechatJsV8::loadLibs()
|
||||
API_DEF_FUNC(hook_process);
|
||||
API_DEF_FUNC(hook_process_hashtable);
|
||||
API_DEF_FUNC(hook_connect);
|
||||
API_DEF_FUNC(hook_line);
|
||||
API_DEF_FUNC(hook_print);
|
||||
API_DEF_FUNC(hook_signal);
|
||||
API_DEF_FUNC(hook_signal_send);
|
||||
|
@ -2583,6 +2583,60 @@ API_FUNC(hook_connect)
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
struct t_hashtable *
|
||||
weechat_lua_api_hook_line_cb (const void *pointer, void *data,
|
||||
struct t_hashtable *line)
|
||||
{
|
||||
struct t_plugin_script *script;
|
||||
void *func_argv[2];
|
||||
char empty_arg[1] = { '\0' };
|
||||
const char *ptr_function, *ptr_data;
|
||||
|
||||
script = (struct t_plugin_script *)pointer;
|
||||
plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
|
||||
|
||||
if (ptr_function && ptr_function[0])
|
||||
{
|
||||
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
|
||||
func_argv[1] = line;
|
||||
|
||||
return (struct t_hashtable *)weechat_lua_exec (
|
||||
script,
|
||||
WEECHAT_SCRIPT_EXEC_HASHTABLE,
|
||||
ptr_function,
|
||||
"sh", func_argv);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
API_FUNC(hook_line)
|
||||
{
|
||||
const char *buffer_type, *buffer_name, *tags, *function, *data;
|
||||
const char *result;
|
||||
|
||||
API_INIT_FUNC(1, "hook_line", API_RETURN_EMPTY);
|
||||
if (lua_gettop (L) < 5)
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
buffer_type = lua_tostring (L, -5);
|
||||
buffer_name = lua_tostring (L, -4);
|
||||
tags = lua_tostring (L, -3);
|
||||
function = lua_tostring (L, -2);
|
||||
data = lua_tostring (L, -1);
|
||||
|
||||
result = API_PTR2STR(plugin_script_api_hook_line (weechat_lua_plugin,
|
||||
lua_current_script,
|
||||
buffer_type,
|
||||
buffer_name,
|
||||
tags,
|
||||
&weechat_lua_api_hook_line_cb,
|
||||
function,
|
||||
data));
|
||||
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
int
|
||||
weechat_lua_api_hook_print_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
@ -5181,6 +5235,7 @@ const struct luaL_Reg weechat_lua_api_funcs[] = {
|
||||
API_DEF_FUNC(hook_process),
|
||||
API_DEF_FUNC(hook_process_hashtable),
|
||||
API_DEF_FUNC(hook_connect),
|
||||
API_DEF_FUNC(hook_line),
|
||||
API_DEF_FUNC(hook_print),
|
||||
API_DEF_FUNC(hook_signal),
|
||||
API_DEF_FUNC(hook_signal_send),
|
||||
|
@ -2484,6 +2484,61 @@ API_FUNC(hook_connect)
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
struct t_hashtable *
|
||||
weechat_perl_api_hook_line_cb (const void *pointer, void *data,
|
||||
struct t_hashtable *line)
|
||||
{
|
||||
struct t_plugin_script *script;
|
||||
void *func_argv[2];
|
||||
char empty_arg[1] = { '\0' };
|
||||
const char *ptr_function, *ptr_data;
|
||||
|
||||
script = (struct t_plugin_script *)pointer;
|
||||
plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
|
||||
|
||||
if (ptr_function && ptr_function[0])
|
||||
{
|
||||
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
|
||||
func_argv[1] = line;
|
||||
|
||||
return (struct t_hashtable *)weechat_perl_exec (
|
||||
script,
|
||||
WEECHAT_SCRIPT_EXEC_HASHTABLE,
|
||||
ptr_function,
|
||||
"sh", func_argv);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
API_FUNC(hook_line)
|
||||
{
|
||||
char *buffer_type, *buffer_name, *tags, *function, *data;
|
||||
const char *result;
|
||||
dXSARGS;
|
||||
|
||||
API_INIT_FUNC(1, "hook_line", API_RETURN_EMPTY);
|
||||
if (items < 5)
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
buffer_type = SvPV_nolen (ST (0));
|
||||
buffer_name = SvPV_nolen (ST (1));
|
||||
tags = SvPV_nolen (ST (2));
|
||||
function = SvPV_nolen (ST (3));
|
||||
data = SvPV_nolen (ST (4));
|
||||
|
||||
result = API_PTR2STR(plugin_script_api_hook_line (weechat_perl_plugin,
|
||||
perl_current_script,
|
||||
buffer_type,
|
||||
buffer_name,
|
||||
tags,
|
||||
&weechat_perl_api_hook_line_cb,
|
||||
function,
|
||||
data));
|
||||
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
int
|
||||
weechat_perl_api_hook_print_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
@ -5142,6 +5197,7 @@ weechat_perl_api_init (pTHX)
|
||||
API_DEF_FUNC(hook_process);
|
||||
API_DEF_FUNC(hook_process_hashtable);
|
||||
API_DEF_FUNC(hook_connect);
|
||||
API_DEF_FUNC(hook_line);
|
||||
API_DEF_FUNC(hook_print);
|
||||
API_DEF_FUNC(hook_signal);
|
||||
API_DEF_FUNC(hook_signal_send);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -135,6 +135,7 @@ PHP_FUNCTION(weechat_hook_fd);
|
||||
PHP_FUNCTION(weechat_hook_process);
|
||||
PHP_FUNCTION(weechat_hook_process_hashtable);
|
||||
PHP_FUNCTION(weechat_hook_connect);
|
||||
PHP_FUNCTION(weechat_hook_line);
|
||||
PHP_FUNCTION(weechat_hook_print);
|
||||
PHP_FUNCTION(weechat_hook_signal);
|
||||
PHP_FUNCTION(weechat_hook_signal_send);
|
||||
|
@ -189,6 +189,7 @@ const zend_function_entry weechat_functions[] = {
|
||||
PHP_FE(weechat_hook_process, NULL)
|
||||
PHP_FE(weechat_hook_process_hashtable, NULL)
|
||||
PHP_FE(weechat_hook_connect, NULL)
|
||||
PHP_FE(weechat_hook_line, NULL)
|
||||
PHP_FE(weechat_hook_print, NULL)
|
||||
PHP_FE(weechat_hook_signal, NULL)
|
||||
PHP_FE(weechat_hook_signal_send, NULL)
|
||||
|
@ -657,6 +657,48 @@ plugin_script_api_hook_connect (struct t_weechat_plugin *weechat_plugin,
|
||||
return new_hook;
|
||||
}
|
||||
|
||||
/*
|
||||
* Hooks a line.
|
||||
*
|
||||
* Returns pointer to new hook, NULL if error.
|
||||
*/
|
||||
|
||||
struct t_hook *
|
||||
plugin_script_api_hook_line (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *buffer_type,
|
||||
const char *buffer_name,
|
||||
const char *tags,
|
||||
struct t_hashtable *(*callback)(const void *pointer,
|
||||
void *data,
|
||||
struct t_hashtable *line),
|
||||
const char *function,
|
||||
const char *data)
|
||||
{
|
||||
char *function_and_data;
|
||||
struct t_hook *new_hook;
|
||||
|
||||
if (!script)
|
||||
return NULL;
|
||||
|
||||
function_and_data = plugin_script_build_function_and_data (function, data);
|
||||
|
||||
new_hook = weechat_hook_line (buffer_type, buffer_name, tags, callback,
|
||||
script, function_and_data);
|
||||
|
||||
if (new_hook)
|
||||
{
|
||||
weechat_hook_set (new_hook, "subplugin", script->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (function_and_data)
|
||||
free (function_and_data);
|
||||
}
|
||||
|
||||
return new_hook;
|
||||
}
|
||||
|
||||
/*
|
||||
* Hooks a message printed by WeeChat.
|
||||
*
|
||||
|
@ -203,6 +203,16 @@ extern struct t_hook *plugin_script_api_hook_connect (struct t_weechat_plugin *w
|
||||
const char *ip_address),
|
||||
const char *function,
|
||||
const char *data);
|
||||
extern struct t_hook *plugin_script_api_hook_line (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *buffer_type,
|
||||
const char *buffer_name,
|
||||
const char *tags,
|
||||
struct t_hashtable *(*callback)(const void *pointer,
|
||||
void *data,
|
||||
struct t_hashtable *line),
|
||||
const char *function,
|
||||
const char *data);
|
||||
extern struct t_hook *plugin_script_api_hook_print (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer,
|
||||
|
@ -777,6 +777,7 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv)
|
||||
new_plugin->hook_process = &hook_process;
|
||||
new_plugin->hook_process_hashtable = &hook_process_hashtable;
|
||||
new_plugin->hook_connect = &hook_connect;
|
||||
new_plugin->hook_line = &hook_line;
|
||||
new_plugin->hook_print = &hook_print;
|
||||
new_plugin->hook_signal = &hook_signal;
|
||||
new_plugin->hook_signal_send = &hook_signal_send;
|
||||
|
@ -2510,6 +2510,67 @@ API_FUNC(hook_connect)
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
struct t_hashtable *
|
||||
weechat_python_api_hook_line_cb (const void *pointer, void *data,
|
||||
struct t_hashtable *line)
|
||||
{
|
||||
struct t_plugin_script *script;
|
||||
void *func_argv[2];
|
||||
char empty_arg[1] = { '\0' };
|
||||
const char *ptr_function, *ptr_data;
|
||||
struct t_hashtable *ret_hashtable;
|
||||
|
||||
script = (struct t_plugin_script *)pointer;
|
||||
plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
|
||||
|
||||
if (ptr_function && ptr_function[0])
|
||||
{
|
||||
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
|
||||
func_argv[1] = weechat_python_hashtable_to_dict (line);
|
||||
|
||||
ret_hashtable = weechat_python_exec (script,
|
||||
WEECHAT_SCRIPT_EXEC_HASHTABLE,
|
||||
ptr_function,
|
||||
"sO", func_argv);
|
||||
|
||||
if (func_argv[1])
|
||||
{
|
||||
Py_XDECREF((PyObject *)func_argv[1]);
|
||||
}
|
||||
|
||||
return ret_hashtable;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
API_FUNC(hook_line)
|
||||
{
|
||||
char *buffer_type, *buffer_name, *tags, *function, *data;
|
||||
const char *result;
|
||||
|
||||
API_INIT_FUNC(1, "hook_line", API_RETURN_EMPTY);
|
||||
buffer_type = NULL;
|
||||
buffer_name = NULL;
|
||||
tags = NULL;
|
||||
function = NULL;
|
||||
data = NULL;
|
||||
if (!PyArg_ParseTuple (args, "sssss", &buffer_type, &buffer_name, &tags,
|
||||
&function, &data))
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
result = API_PTR2STR(plugin_script_api_hook_line (weechat_python_plugin,
|
||||
python_current_script,
|
||||
buffer_type,
|
||||
buffer_name,
|
||||
tags,
|
||||
&weechat_python_api_hook_line_cb,
|
||||
function,
|
||||
data));
|
||||
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
int
|
||||
weechat_python_api_hook_print_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
@ -5084,6 +5145,7 @@ PyMethodDef weechat_python_funcs[] =
|
||||
API_DEF_FUNC(hook_process),
|
||||
API_DEF_FUNC(hook_process_hashtable),
|
||||
API_DEF_FUNC(hook_connect),
|
||||
API_DEF_FUNC(hook_line),
|
||||
API_DEF_FUNC(hook_print),
|
||||
API_DEF_FUNC(hook_signal),
|
||||
API_DEF_FUNC(hook_signal_send),
|
||||
|
@ -3033,6 +3033,69 @@ weechat_ruby_api_hook_connect (VALUE class, VALUE proxy, VALUE address,
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
struct t_hashtable *
|
||||
weechat_ruby_api_hook_line_cb (const void *pointer, void *data,
|
||||
struct t_hashtable *line)
|
||||
{
|
||||
struct t_plugin_script *script;
|
||||
void *func_argv[2];
|
||||
char empty_arg[1] = { '\0' };
|
||||
const char *ptr_function, *ptr_data;
|
||||
|
||||
script = (struct t_plugin_script *)pointer;
|
||||
plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
|
||||
|
||||
if (ptr_function && ptr_function[0])
|
||||
{
|
||||
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
|
||||
func_argv[1] = line;
|
||||
|
||||
return (struct t_hashtable *)weechat_ruby_exec (
|
||||
script,
|
||||
WEECHAT_SCRIPT_EXEC_HASHTABLE,
|
||||
ptr_function,
|
||||
"sh", func_argv);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_hook_line (VALUE class, VALUE buffer_type, VALUE buffer_name,
|
||||
VALUE tags, VALUE function, VALUE data)
|
||||
{
|
||||
char *c_buffer_type, *c_buffer_name, *c_tags, *c_function, *c_data;
|
||||
const char *result;
|
||||
|
||||
API_INIT_FUNC(1, "hook_line", API_RETURN_EMPTY);
|
||||
if (NIL_P (buffer_type) || NIL_P (buffer_name) || NIL_P (tags)
|
||||
|| NIL_P (function) || NIL_P (data))
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
Check_Type (buffer_type, T_STRING);
|
||||
Check_Type (buffer_name, T_STRING);
|
||||
Check_Type (tags, T_STRING);
|
||||
Check_Type (function, T_STRING);
|
||||
Check_Type (data, T_STRING);
|
||||
|
||||
c_buffer_type = StringValuePtr (buffer_type);
|
||||
c_buffer_name = StringValuePtr (buffer_name);
|
||||
c_tags = StringValuePtr (tags);
|
||||
c_function = StringValuePtr (function);
|
||||
c_data = StringValuePtr (data);
|
||||
|
||||
result = API_PTR2STR(plugin_script_api_hook_line (weechat_ruby_plugin,
|
||||
ruby_current_script,
|
||||
c_buffer_type,
|
||||
c_buffer_name,
|
||||
c_tags,
|
||||
&weechat_ruby_api_hook_line_cb,
|
||||
c_function,
|
||||
c_data));
|
||||
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
int
|
||||
weechat_ruby_api_hook_print_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
@ -6236,6 +6299,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
API_DEF_FUNC(hook_process, 4);
|
||||
API_DEF_FUNC(hook_process_hashtable, 5);
|
||||
API_DEF_FUNC(hook_connect, 8);
|
||||
API_DEF_FUNC(hook_line, 5);
|
||||
API_DEF_FUNC(hook_print, 6);
|
||||
API_DEF_FUNC(hook_signal, 3);
|
||||
API_DEF_FUNC(hook_signal_send, 3);
|
||||
|
@ -2763,6 +2763,62 @@ API_FUNC(hook_connect)
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
struct t_hashtable *
|
||||
weechat_tcl_api_hook_line_cb (const void *pointer, void *data,
|
||||
struct t_hashtable *line)
|
||||
{
|
||||
struct t_plugin_script *script;
|
||||
void *func_argv[2];
|
||||
char empty_arg[1] = { '\0' };
|
||||
const char *ptr_function, *ptr_data;
|
||||
|
||||
script = (struct t_plugin_script *)pointer;
|
||||
plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
|
||||
|
||||
if (ptr_function && ptr_function[0])
|
||||
{
|
||||
func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
|
||||
func_argv[1] = line;
|
||||
|
||||
return (struct t_hashtable *)weechat_tcl_exec (
|
||||
script,
|
||||
WEECHAT_SCRIPT_EXEC_HASHTABLE,
|
||||
ptr_function,
|
||||
"sh", func_argv);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
API_FUNC(hook_line)
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *buffer_type, *buffer_name, *tags, *function, *data;
|
||||
const char *result;
|
||||
int i;
|
||||
|
||||
API_INIT_FUNC(1, "hook_line", API_RETURN_EMPTY);
|
||||
if (objc < 6)
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
buffer_type = Tcl_GetStringFromObj (objv[1], &i);
|
||||
buffer_name = Tcl_GetStringFromObj (objv[2], &i);
|
||||
tags = Tcl_GetStringFromObj (objv[3], &i);
|
||||
function = Tcl_GetStringFromObj (objv[4], &i);
|
||||
data = Tcl_GetStringFromObj (objv[5], &i);
|
||||
|
||||
result = API_PTR2STR(plugin_script_api_hook_line (weechat_tcl_plugin,
|
||||
tcl_current_script,
|
||||
buffer_type,
|
||||
buffer_name,
|
||||
tags,
|
||||
&weechat_tcl_api_hook_line_cb,
|
||||
function,
|
||||
data));
|
||||
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
int
|
||||
weechat_tcl_api_hook_print_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
@ -5611,6 +5667,7 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
|
||||
API_DEF_FUNC(hook_process);
|
||||
API_DEF_FUNC(hook_process_hashtable);
|
||||
API_DEF_FUNC(hook_connect);
|
||||
API_DEF_FUNC(hook_line);
|
||||
API_DEF_FUNC(hook_print);
|
||||
API_DEF_FUNC(hook_signal);
|
||||
API_DEF_FUNC(hook_signal_send);
|
||||
|
@ -227,6 +227,7 @@ void
|
||||
trigger_callback_replace_regex (struct t_trigger *trigger,
|
||||
struct t_hashtable *pointers,
|
||||
struct t_hashtable *extra_vars,
|
||||
struct t_weelist *vars_updated,
|
||||
int display_monitor)
|
||||
{
|
||||
char *value;
|
||||
@ -312,6 +313,11 @@ trigger_callback_replace_regex (struct t_trigger *trigger,
|
||||
weechat_color ("chat_delimiters"));
|
||||
}
|
||||
weechat_hashtable_set (extra_vars, ptr_key, value);
|
||||
if (vars_updated)
|
||||
{
|
||||
weechat_list_add (vars_updated, ptr_key, WEECHAT_LIST_POS_END,
|
||||
NULL);
|
||||
}
|
||||
free (value);
|
||||
}
|
||||
}
|
||||
@ -392,7 +398,8 @@ void
|
||||
trigger_callback_execute (struct t_trigger *trigger,
|
||||
struct t_gui_buffer *buffer,
|
||||
struct t_hashtable *pointers,
|
||||
struct t_hashtable *extra_vars)
|
||||
struct t_hashtable *extra_vars,
|
||||
struct t_weelist *vars_updated)
|
||||
{
|
||||
int display_monitor;
|
||||
|
||||
@ -409,7 +416,7 @@ trigger_callback_execute (struct t_trigger *trigger,
|
||||
{
|
||||
/* replace text with regex */
|
||||
trigger_callback_replace_regex (trigger, pointers, extra_vars,
|
||||
display_monitor);
|
||||
vars_updated, display_monitor);
|
||||
|
||||
/* execute command(s) */
|
||||
trigger_callback_run_command (trigger, buffer, pointers, extra_vars,
|
||||
@ -521,7 +528,7 @@ trigger_callback_signal_cb (const void *pointer, void *data,
|
||||
weechat_hashtable_set (extra_vars, "tg_signal_data", ptr_signal_data);
|
||||
|
||||
/* execute the trigger (conditions, regex, command) */
|
||||
trigger_callback_execute (trigger, NULL, pointers, extra_vars);
|
||||
trigger_callback_execute (trigger, NULL, pointers, extra_vars, NULL);
|
||||
|
||||
end:
|
||||
TRIGGER_CALLBACK_CB_END(trigger_rc);
|
||||
@ -569,7 +576,7 @@ trigger_callback_hsignal_cb (const void *pointer, void *data,
|
||||
weechat_hashtable_set (extra_vars, "tg_signal", signal);
|
||||
|
||||
/* execute the trigger (conditions, regex, command) */
|
||||
trigger_callback_execute (trigger, NULL, pointers, extra_vars);
|
||||
trigger_callback_execute (trigger, NULL, pointers, extra_vars, NULL);
|
||||
|
||||
end:
|
||||
TRIGGER_CALLBACK_CB_END(trigger_rc);
|
||||
@ -753,7 +760,7 @@ trigger_callback_modifier_cb (const void *pointer, void *data,
|
||||
}
|
||||
|
||||
/* execute the trigger (conditions, regex, command) */
|
||||
trigger_callback_execute (trigger, buffer, pointers, extra_vars);
|
||||
trigger_callback_execute (trigger, buffer, pointers, extra_vars, NULL);
|
||||
|
||||
end:
|
||||
ptr_string = weechat_hashtable_get (extra_vars, "tg_string");
|
||||
@ -768,6 +775,126 @@ end:
|
||||
TRIGGER_CALLBACK_CB_END(string_modified);
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for a line hooked.
|
||||
*/
|
||||
|
||||
struct t_hashtable *
|
||||
trigger_callback_line_cb (const void *pointer, void *data,
|
||||
struct t_hashtable *line)
|
||||
{
|
||||
struct t_hashtable *hashtable;
|
||||
struct t_gui_buffer *buffer;
|
||||
struct t_weelist_item *ptr_item;
|
||||
long unsigned int value;
|
||||
const char *ptr_key, *ptr_value;
|
||||
char **tags, *str_tags;
|
||||
int rc, num_tags, length;
|
||||
|
||||
TRIGGER_CALLBACK_CB_INIT(NULL);
|
||||
|
||||
hashtable = NULL;
|
||||
|
||||
TRIGGER_CALLBACK_CB_NEW_POINTERS;
|
||||
TRIGGER_CALLBACK_CB_NEW_VARS_UPDATED;
|
||||
|
||||
extra_vars = weechat_hashtable_dup (line);
|
||||
|
||||
weechat_hashtable_remove (extra_vars, "buffer");
|
||||
weechat_hashtable_remove (extra_vars, "tags_count");
|
||||
weechat_hashtable_remove (extra_vars, "tags");
|
||||
|
||||
/* add data in hashtables used for conditions/replace/command */
|
||||
ptr_value = weechat_hashtable_get (line, "buffer");
|
||||
if (!ptr_value || (ptr_value[0] != '0') || (ptr_value[1] != 'x'))
|
||||
goto end;
|
||||
rc = sscanf (ptr_value + 2, "%lx", &value);
|
||||
if ((rc == EOF) || (rc < 1))
|
||||
goto end;
|
||||
buffer = (void *)value;
|
||||
|
||||
weechat_hashtable_set (pointers, "buffer", buffer);
|
||||
ptr_value = weechat_hashtable_get (line, "tags");
|
||||
tags = weechat_string_split ((ptr_value) ? ptr_value : "", ",", 0, 0,
|
||||
&num_tags);
|
||||
|
||||
/* build string with tags and commas around: ",tag1,tag2,tag3," */
|
||||
length = 1 + strlen ((ptr_value) ? ptr_value : "") + 1 + 1;
|
||||
str_tags = malloc (length);
|
||||
if (str_tags)
|
||||
{
|
||||
snprintf (str_tags, length, ",%s,",
|
||||
(ptr_value) ? ptr_value : "");
|
||||
weechat_hashtable_set (extra_vars, "tg_tags", str_tags);
|
||||
free (str_tags);
|
||||
}
|
||||
|
||||
if (!trigger_callback_set_tags (buffer, (const char **)tags, num_tags,
|
||||
extra_vars))
|
||||
{
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* execute the trigger (conditions, regex, command) */
|
||||
trigger_callback_execute (trigger, buffer, pointers, extra_vars,
|
||||
vars_updated);
|
||||
|
||||
hashtable = weechat_hashtable_new (32,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
NULL, NULL);
|
||||
if (hashtable)
|
||||
{
|
||||
/* copy updated variables into the result "hashtable" */
|
||||
for (ptr_item = weechat_list_get (vars_updated, 0); ptr_item;
|
||||
ptr_item = weechat_list_next (ptr_item))
|
||||
{
|
||||
ptr_key = weechat_list_string (ptr_item);
|
||||
if (weechat_hashtable_has_key (extra_vars, ptr_key))
|
||||
{
|
||||
if (strcmp (ptr_key, "tg_tags") == 0)
|
||||
{
|
||||
/*
|
||||
* remove commas at the beginning/end of tg_tags and
|
||||
* rename the key to "tags"
|
||||
*/
|
||||
ptr_value = weechat_hashtable_get (extra_vars, ptr_key);
|
||||
if (ptr_value && ptr_value[0])
|
||||
{
|
||||
str_tags = strdup (
|
||||
(ptr_value[0] == ',') ? ptr_value + 1 : ptr_value);
|
||||
if (str_tags)
|
||||
{
|
||||
if (str_tags[0]
|
||||
&& (str_tags[strlen (str_tags) - 1] == ','))
|
||||
{
|
||||
str_tags[strlen (str_tags) - 1] = '\0';
|
||||
}
|
||||
weechat_hashtable_set (hashtable,
|
||||
"tags", str_tags);
|
||||
free (str_tags);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_hashtable_set (hashtable, "tags", ptr_value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_hashtable_set (
|
||||
hashtable,
|
||||
ptr_key,
|
||||
weechat_hashtable_get (extra_vars, ptr_key));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
TRIGGER_CALLBACK_CB_END(hashtable);
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for a print hooked.
|
||||
*/
|
||||
@ -840,7 +967,7 @@ trigger_callback_print_cb (const void *pointer, void *data,
|
||||
goto end;
|
||||
|
||||
/* execute the trigger (conditions, regex, command) */
|
||||
trigger_callback_execute (trigger, buffer, pointers, extra_vars);
|
||||
trigger_callback_execute (trigger, buffer, pointers, extra_vars, NULL);
|
||||
|
||||
end:
|
||||
TRIGGER_CALLBACK_CB_END(trigger_rc);
|
||||
@ -874,7 +1001,7 @@ trigger_callback_command_cb (const void *pointer, void *data,
|
||||
}
|
||||
|
||||
/* execute the trigger (conditions, regex, command) */
|
||||
trigger_callback_execute (trigger, buffer, pointers, extra_vars);
|
||||
trigger_callback_execute (trigger, buffer, pointers, extra_vars, NULL);
|
||||
|
||||
end:
|
||||
TRIGGER_CALLBACK_CB_END(trigger_rc);
|
||||
@ -899,7 +1026,7 @@ trigger_callback_command_run_cb (const void *pointer, void *data,
|
||||
weechat_hashtable_set (extra_vars, "tg_command", command);
|
||||
|
||||
/* execute the trigger (conditions, regex, command) */
|
||||
trigger_callback_execute (trigger, buffer, pointers, extra_vars);
|
||||
trigger_callback_execute (trigger, buffer, pointers, extra_vars, NULL);
|
||||
|
||||
end:
|
||||
TRIGGER_CALLBACK_CB_END(trigger_rc);
|
||||
@ -949,7 +1076,7 @@ trigger_callback_timer_cb (const void *pointer, void *data,
|
||||
}
|
||||
|
||||
/* execute the trigger (conditions, regex, command) */
|
||||
trigger_callback_execute (trigger, NULL, pointers, extra_vars);
|
||||
trigger_callback_execute (trigger, NULL, pointers, extra_vars, NULL);
|
||||
|
||||
end:
|
||||
TRIGGER_CALLBACK_CB_END(trigger_rc);
|
||||
@ -972,7 +1099,7 @@ trigger_callback_config_cb (const void *pointer, void *data,
|
||||
weechat_hashtable_set (extra_vars, "tg_value", value);
|
||||
|
||||
/* execute the trigger (conditions, regex, command) */
|
||||
trigger_callback_execute (trigger, NULL, pointers, extra_vars);
|
||||
trigger_callback_execute (trigger, NULL, pointers, extra_vars, NULL);
|
||||
|
||||
end:
|
||||
TRIGGER_CALLBACK_CB_END(trigger_rc);
|
||||
@ -1011,7 +1138,7 @@ trigger_callback_focus_cb (const void *pointer, void *data,
|
||||
}
|
||||
|
||||
/* execute the trigger (conditions, regex, command) */
|
||||
trigger_callback_execute (trigger, NULL, pointers, info);
|
||||
trigger_callback_execute (trigger, NULL, pointers, info, NULL);
|
||||
|
||||
end:
|
||||
TRIGGER_CALLBACK_CB_END(info);
|
||||
|
@ -25,10 +25,13 @@
|
||||
#define TRIGGER_CALLBACK_CB_INIT(__rc) \
|
||||
struct t_trigger *trigger; \
|
||||
struct t_hashtable *pointers, *extra_vars; \
|
||||
struct t_weelist *vars_updated; \
|
||||
int trigger_rc; \
|
||||
pointers = NULL; \
|
||||
extra_vars = NULL; \
|
||||
vars_updated = NULL; \
|
||||
(void) data; \
|
||||
(void) vars_updated; \
|
||||
(void) trigger_rc; \
|
||||
if (!trigger_enabled) \
|
||||
return __rc; \
|
||||
@ -59,11 +62,18 @@
|
||||
if (!extra_vars) \
|
||||
goto end;
|
||||
|
||||
#define TRIGGER_CALLBACK_CB_NEW_VARS_UPDATED \
|
||||
vars_updated = weechat_list_new (); \
|
||||
if (!vars_updated) \
|
||||
goto end;
|
||||
|
||||
#define TRIGGER_CALLBACK_CB_END(__rc) \
|
||||
if (pointers) \
|
||||
weechat_hashtable_free (pointers); \
|
||||
if (extra_vars) \
|
||||
weechat_hashtable_free (extra_vars); \
|
||||
if (vars_updated) \
|
||||
weechat_list_free (vars_updated); \
|
||||
trigger->hook_running = 0; \
|
||||
switch (weechat_config_integer ( \
|
||||
trigger->options[TRIGGER_OPTION_POST_ACTION])) \
|
||||
@ -93,6 +103,8 @@ extern char *trigger_callback_modifier_cb (const void *pointer, void *data,
|
||||
const char *modifier,
|
||||
const char *modifier_data,
|
||||
const char *string);
|
||||
extern struct t_hashtable *trigger_callback_line_cb (const void *pointer, void *data,
|
||||
struct t_hashtable *line);
|
||||
extern int trigger_callback_print_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
time_t date, int tags_count,
|
||||
|
@ -1153,13 +1153,14 @@ trigger_command_init ()
|
||||
" addoff: add a trigger (disabled)\n"
|
||||
" addreplace: add or replace an existing trigger\n"
|
||||
" name: name of trigger\n"
|
||||
" hook: signal, hsignal, modifier, print, command, command_run, "
|
||||
"timer, config, focus\n"
|
||||
" hook: signal, hsignal, modifier, line, print, command, "
|
||||
"command_run, timer, config, focus\n"
|
||||
" arguments: arguments for the hook, depending on hook (separated "
|
||||
"by semicolons):\n"
|
||||
" signal: name(s) of signal (required)\n"
|
||||
" hsignal: name(s) of hsignal (required)\n"
|
||||
" modifier: name(s) of modifier (required)\n"
|
||||
" line: list of buffer masks, tags\n"
|
||||
" print: buffer, tags, message, strip colors\n"
|
||||
" command: command (required), description, arguments, "
|
||||
"description of arguments, completion\n"
|
||||
@ -1212,7 +1213,7 @@ trigger_command_init ()
|
||||
" 2. replace text using POSIX extended regular expression(s) (if "
|
||||
"defined in trigger)\n"
|
||||
" 3. execute command(s) (if defined in trigger)\n"
|
||||
" 4. exit with a return code (except for modifiers and focus)\n"
|
||||
" 4. exit with a return code (except for modifier, line and focus)\n"
|
||||
" 5. perform post action\n"
|
||||
"\n"
|
||||
"Examples (you can also look at default triggers with /trigger "
|
||||
|
@ -49,10 +49,11 @@ char *trigger_option_default[TRIGGER_NUM_OPTIONS] =
|
||||
{ "on", "signal", "", "", "", "", "ok", "none" };
|
||||
|
||||
char *trigger_hook_type_string[TRIGGER_NUM_HOOK_TYPES] =
|
||||
{ "signal", "hsignal", "modifier", "print", "command", "command_run", "timer",
|
||||
"config", "focus" };
|
||||
{ "signal", "hsignal", "modifier", "line", "print", "command", "command_run",
|
||||
"timer", "config", "focus" };
|
||||
char *trigger_hook_option_values =
|
||||
"signal|hsignal|modifier|print|command|command_run|timer|config|focus";
|
||||
"signal|hsignal|modifier|line|print|command|command_run|timer|config|"
|
||||
"focus";
|
||||
char *trigger_hook_default_arguments[TRIGGER_NUM_HOOK_TYPES] =
|
||||
{ "xxx", "xxx", "xxx", "", "cmd;desc;args;args_desc;%(buffers_names)", "/cmd",
|
||||
"60000;0;0", "xxx", "chat" };
|
||||
@ -262,7 +263,8 @@ trigger_unhook (struct t_trigger *trigger)
|
||||
void
|
||||
trigger_hook (struct t_trigger *trigger)
|
||||
{
|
||||
char **argv, **argv_eol, *tags, *message, *error1, *error2, *error3;
|
||||
char **argv, **argv_eol, *buffer_type, *buffer_name, *tags, *message;
|
||||
char *error1, *error2, *error3;
|
||||
int i, argc, strip_colors;
|
||||
long interval, align_second, max_calls;
|
||||
|
||||
@ -329,6 +331,30 @@ trigger_hook (struct t_trigger *trigger)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TRIGGER_HOOK_LINE:
|
||||
buffer_type = NULL;
|
||||
buffer_name = NULL;
|
||||
tags = NULL;
|
||||
if (argv && (argc >= 1))
|
||||
{
|
||||
buffer_type = argv[0];
|
||||
if ((argc >= 2) && (strcmp (argv[1], "*") != 0))
|
||||
buffer_name = argv[1];
|
||||
if ((argc >= 3) && (strcmp (argv[2], "*") != 0))
|
||||
tags = argv[2];
|
||||
}
|
||||
trigger->hooks = malloc (sizeof (trigger->hooks[0]));
|
||||
if (trigger->hooks)
|
||||
{
|
||||
trigger->hooks_count = 1;
|
||||
trigger->hooks[0] = weechat_hook_line (
|
||||
buffer_type,
|
||||
buffer_name,
|
||||
tags,
|
||||
&trigger_callback_line_cb,
|
||||
trigger, NULL);
|
||||
}
|
||||
break;
|
||||
case TRIGGER_HOOK_PRINT:
|
||||
tags = NULL;
|
||||
message = NULL;
|
||||
|
@ -48,6 +48,7 @@ enum t_trigger_hook_type
|
||||
TRIGGER_HOOK_SIGNAL = 0,
|
||||
TRIGGER_HOOK_HSIGNAL,
|
||||
TRIGGER_HOOK_MODIFIER,
|
||||
TRIGGER_HOOK_LINE,
|
||||
TRIGGER_HOOK_PRINT,
|
||||
TRIGGER_HOOK_COMMAND,
|
||||
TRIGGER_HOOK_COMMAND_RUN,
|
||||
|
@ -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 "20180520-01"
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20180812-01"
|
||||
|
||||
/* macros for defining plugin infos */
|
||||
#define WEECHAT_PLUGIN_NAME(__name) \
|
||||
@ -709,6 +709,15 @@ struct t_weechat_plugin
|
||||
const char *ip_address),
|
||||
const void *callback_pointer,
|
||||
void *callback_data);
|
||||
struct t_hook *(*hook_line) (struct t_weechat_plugin *plugin,
|
||||
const char *buffer_type,
|
||||
const char *buffer_name,
|
||||
const char *tags,
|
||||
struct t_hashtable *(*callback)(const void *pointer,
|
||||
void *data,
|
||||
struct t_hashtable *line),
|
||||
const void *callback_pointer,
|
||||
void *callback_data);
|
||||
struct t_hook *(*hook_print) (struct t_weechat_plugin *plugin,
|
||||
struct t_gui_buffer *buffer,
|
||||
const char *tags,
|
||||
@ -1645,6 +1654,11 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
|
||||
__gnutls_priorities, \
|
||||
__local_hostname, \
|
||||
__callback, __pointer, __data)
|
||||
#define weechat_hook_line(_buffer_type, __buffer_name, __tags, \
|
||||
__callback, __pointer, __data) \
|
||||
(weechat_plugin->hook_line)(weechat_plugin, _buffer_type, \
|
||||
__buffer_name, __tags, __callback, \
|
||||
__pointer, __data)
|
||||
#define weechat_hook_print(__buffer, __tags, __msg, __strip__colors, \
|
||||
__callback, __pointer, __data) \
|
||||
(weechat_plugin->hook_print)(weechat_plugin, __buffer, __tags, \
|
||||
|
Loading…
x
Reference in New Issue
Block a user