1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

core: add support of date and tags in messages displayed in buffers with free content, add function printf_y_date_tags (closes #1746)

This commit is contained in:
Sébastien Helleu
2022-01-30 11:41:06 +01:00
parent bf3241208b
commit 9259442dbf
43 changed files with 752 additions and 60 deletions
+1
View File
@@ -20,6 +20,7 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
New features::
* core: add support of date and tags in messages displayed in buffers with free content, add function printf_y_date_tags (issue #1746)
* irc: add IRC message tags in messages displayed (issue #1680)
* relay: add `zstd` (https://facebook.github.io/zstd/[Zstandard]) compression in weechat protocol, remove option `compression` from `init` command, rename option relay.network.compression_level to relay.network.compression
* trigger: add variables `${tg_tag_irc_xxx}` containing IRC message tags (issue #1680)
+1
View File
@@ -660,6 +660,7 @@ Liste der Skript API Funktionen:
print (für Python: prnt) +
print_date_tags (für Python: prnt_date_tags) +
print_y (für Python: prnt_y) +
print_y_date_tags (für Python: prnt_y_date_tags) +
log_print
| Hooks |
+46
View File
@@ -8637,6 +8637,52 @@ weechat.prnt_y("", 2, "My message on third line")
[NOTE]
Function is called "print_y" in scripts ("prnt_y" in Python).
==== printf_y_date_tags
_WeeChat ≥ 3.5._
Display a message on a line of a buffer with free content, using a custom
date and tags.
Prototype:
[source,c]
----
void weechat_printf_y_date_tags (struct t_gui_buffer *buffer, int y, time_t date,
const char *tags, const char *message, ...);
----
Arguments:
* _buffer_: buffer pointer
* _y_: line number (first line is 0); a negative value adds a line after last
line displayed: absolute value of _y_ is the number of lines after last line
(for example -1 is immediately after last line, -2 is 2 lines after last line)
* _date_: date for message (0 means current date/time)
* _tags_: comma separated list of tags (NULL means no tags)
* _message_: message to display
C example:
[source,c]
----
weechat_printf_y_date_tags (buffer, 2, 0, "my_tag", "My message on third line with a tag");
----
Script (Python):
[source,python]
----
# prototype
def prnt_y_date_tags(buffer: str, y: int, date: int, tags: str, message: str) -> int: ...
# example
weechat.prnt_y_date_tags("", 2, 0, "my_tag", "My message on third line with a tag")
----
[NOTE]
Function is called "print_y_date_tags" in scripts ("prnt_y_date_tags" in Python).
==== log_printf
Write a message in WeeChat log file (weechat.log).
+1
View File
@@ -644,6 +644,7 @@ List of functions in script API:
print (for python: prnt) +
print_date_tags (for python: prnt_date_tags) +
print_y (for python: prnt_y) +
print_y_date_tags (for python: prnt_y_date_tags) +
log_print
| hooks |
+49
View File
@@ -8773,6 +8773,55 @@ weechat.prnt_y("", 2, "Mon message sur la 3ème ligne")
[NOTE]
La fonction s'appelle "print_y" dans les scripts ("prnt_y" en Python).
==== printf_y_date_tags
_WeeChat ≥ 3.5._
Afficher un message sur une ligne d'un tampon avec contenu libre, en utilisant
une date et des étiquettes personnalisées.
Prototype :
[source,c]
----
void weechat_printf_y_date_tags (struct t_gui_buffer *buffer, int y, time_t date,
const char *tags, const char *message, ...);
----
Paramètres :
* _buffer_ : pointeur vers le tampon
* _y_ : numéro de ligne (la première ligne est 0); une valeur négative affiche
une ligne après la dernière ligne affichée : la valeur absolue de _y_ est le
nombre de lignes après la dernière ligne (par exemple -1 est immédiatement
après la dernière ligne, -2 est 2 lignes après la dernière ligne)
* _date_ : date pour le message (0 signifie la date/heure courante)
* _tags_ : liste d'étiquettes séparées par des virgules (NULL signifie aucune
étiquette)
* _message_ : message à afficher
Exemple en C :
[source,c]
----
weechat_printf_y_date_tags (buffer, 2, 0, "mon_etiquette", "Mon message sur la 3ème ligne avec une étiquette");
----
Script (Python) :
[source,python]
----
# prototype
def prnt_y_date_tags(buffer: str, y: int, date: int, tags: str, message: str) -> int: ...
# exemple
weechat.prnt_y_date_tags("", 2, 0, "mon_etiquette", "Mon message sur la 3ème ligne avec une étiquette")
----
[NOTE]
La fonction s'appelle "print_y_date_tags" dans les scripts ("prnt_y_date_tags"
en Python).
==== log_printf
Écrire un message dans le fichier de log WeeChat (weechat.log).
+1
View File
@@ -663,6 +663,7 @@ Liste des fonctions de l'API script :
print (pour python : prnt) +
print_date_tags (pour python : prnt_date_tags) +
print_y (pour python : prnt_y) +
print_y_date_tags (pour python : prnt_y_date_tags) +
log_print
| hooks |
+50
View File
@@ -8910,6 +8910,56 @@ weechat.prnt_y("", 2, "Mio messaggio sulla terza riga")
[NOTE]
La funzione è chiamata "print_y" negli script ("prnt_y in Python).
==== printf_y_date_tags
_WeeChat ≥ 3.5._
// TRANSLATION MISSING
Display a message on a line of a buffer with free content, using a custom
date and tags.
Prototipo:
[source,c]
----
void weechat_printf_y_date_tags (struct t_gui_buffer *buffer, int y, time_t date,
const char *tags, const char *message, ...);
----
Argomenti:
* _buffer_: puntatore al buffer
// TRANSLATION MISSING
* _y_: numero di riga (la prima riga è 0); a negative value adds a line after
last line displayed: absolute value of _y_ is the number of lines after last
line (for example -1 is immediately after last line, -2 is 2 lines after last
line)
* _date_: data per il messaggio (0 indica data/ora corrente)
// TRANSLATION MISSING
* _tags_: lista di tag separati da virgole (NULL means no tags)
* _message_: messaggio da visualizzare
Esempio in C:
[source,c]
----
weechat_printf_y_date_tags (buffer, 2, 0, "my_tag", "My message on third line with a tag");
----
Script (Python):
[source,python]
----
# prototipo
def prnt_y_date_tags(buffer: str, y: int, date: int, tags: str, message: str) -> int: ...
# esempio
weechat.prnt_y_date_tags("", 2, 0, "my_tag", "My message on third line with a tag")
----
[NOTE]
La funzione è chiamata "print_y_date_tags" negli script ("prnt_y_date_tags in Python).
==== log_printf
Scrive un messaggio nel file di log di WeeChat (weechat.log).
+2
View File
@@ -676,6 +676,8 @@ Elenco di funzioni nelle API per gli script:
print_date_tags (for python: prnt_date_tags) +
// TRANSLATION MISSING
print_y (for python: prnt_y) +
// TRANSLATION MISSING
print_y_date_tags (for python: prnt_y_date_tags) +
log_print
| hook |
+47
View File
@@ -8659,6 +8659,53 @@ weechat.prnt_y("", 2, "My message on third line")
[NOTE]
この関数をスクリプトの中で実行するには "print_y" (Python の場合は "prnt_y") と書きます。
==== printf_y_date_tags
_WeeChat ≥ 3.5._
// TRANSLATION MISSING
Display a message on a line of a buffer with free content, using a custom
date and tags.
プロトタイプ:
[source,c]
----
void weechat_printf_y_date_tags (struct t_gui_buffer *buffer, int y, time_t date,
const char *tags, const char *message, ...);
----
引数:
* _buffer_: バッファへのポインタ
* _y_: 行番号 (1 行目は 0); 負数の場合は表示された最後の行の後に行を追加する:
_y_ の絶対値で最後の行の後に追加する行数を指定 (例えば
-1 は最後の行のすぐ後、-2 は 最後の行の 2 行後)
* _date_: メッセージの日付 (0 は現在の日付/時間を意味する)
* _tags_: タグのコンマ区切りリスト (タグを指定しない場合は NULL)
* _message_: 表示するメッセージ
C 言語での使用例:
[source,c]
----
weechat_printf_y_date_tags (buffer, 2, 0, "my_tag", "My message on third line with a tag");
----
スクリプト (Python) での使用例:
[source,python]
----
# プロトタイプ
def prnt_y_date_tags(buffer: str, y: int, date: int, tags: str, message: str) -> int: ...
# 例
weechat.prnt_y_date_tags("", 2, 0, "my_tag", "My message on third line with a tag")
----
[NOTE]
この関数をスクリプトの中で実行するには "print_y_date_tags" (Python の場合は "prnt_y_date_tags") と書きます。
==== log_printf
WeeChat ログファイル (weechat.log) にメッセージを書き込む。
+1
View File
@@ -665,6 +665,7 @@ link:weechat_plugin_api.ja.html[WeeChat プラグイン API リファレンス]
print (python では prnt) +
print_date_tags (python では prnt_date_tags) +
print_y (python では prnt_y) +
print_y_date_tags (python では prnt_y_date_tags) +
log_print
| フック |
+1
View File
@@ -649,6 +649,7 @@ Lista funkcji w API skryptów:
print (dla pythona: prnt) +
print_date_tags (dla pythona: prnt_date_tags) +
print_y (dla pythona: prnt_y) +
print_y_date_tags (dla pythona: prnt_y_date_tags) +
log_print
| hooks |
+45
View File
@@ -8377,6 +8377,51 @@ weechat.prnt_y("", 2, "My message on third line")
[NOTE]
У скриптама се функција зове „print_y” („prnt_y” у језику Python).
==== printf_y_date_tags
_WeeChat ≥ 3.5._
// TRANSLATION MISSING
Display a message on a line of a buffer with free content, using a custom
date and tags.
Прототип:
[source,c]
----
void weechat_printf_y_date_tags (struct t_gui_buffer *buffer, int y, time_t date,
const char *tags, const char *message, ...);
----
Аргументи:
* _buffer_: показивач на бафер
* _y_: број линије (прва линија је 0); негативна вредност додаје линију иза последње приказане линије: апсолутна вредност _y_ је број линија након последње линије (на пример -1 је непосредно након последње линије, -2 је 2 линије након последње линије)
* _date_: датум за поруку (0 значи текући датум/време)
* _tags_: листа ознака раздвојених запетама (NULL значи да нема ознака)
* _message_: порука која треба да се прикаже
C пример:
[source,c]
----
weechat_printf_y_date_tags (buffer, 2, 0, "my_tag", "My message on third line with a tag");
----
Скрипта (Python):
[source,python]
----
# прототип
def prnt_y_date_tags(buffer: str, y: int, date: int, tags: str, message: str) -> int: ...
# пример
weechat.prnt_y_date_tags("", 2, 0, "my_tag", "My message on third line with a tag")
----
[NOTE]
У скриптама се функција зове „print_y_date_tags” („prnt_y_date_tags” у језику Python).
==== log_printf
Уписује поруку у WeeChat лог фајл (weechat.log).
+1
View File
@@ -602,6 +602,7 @@ weechat_hook_timer(1000, 0, 1, $timer_cb, 'test');
print (за python: prnt) +
print_date_tags (за python: prnt_date_tags) +
print_y (за python: prnt_y) +
print_y_date_tags (за python: prnt_y_date_tags) +
log_print
| куке |
+4 -4
View File
@@ -5170,10 +5170,10 @@ COMMAND_CALLBACK(print)
{
if (free_content)
{
gui_chat_printf_y (ptr_buffer, y,
"%s%s",
(prefix) ? prefix : "",
text2);
gui_chat_printf_y_date_tags (ptr_buffer, y, date, tags,
"%s%s",
(prefix) ? prefix : "",
text2);
}
else
{
+4 -1
View File
@@ -659,7 +659,10 @@ upgrade_weechat_read_buffer_line (struct t_infolist *infolist)
case GUI_BUFFER_TYPE_FREE:
new_line = gui_line_new (upgrade_current_buffer,
infolist_integer (infolist, "y"),
0, 0, NULL, NULL,
infolist_time (infolist, "date"),
infolist_time (infolist, "date_printed"),
infolist_string (infolist, "tags"),
NULL,
infolist_string (infolist, "message"));
if (new_line)
gui_line_add_y (new_line);
+22 -4
View File
@@ -1421,7 +1421,9 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
if (line->data->message && line->data->message[0])
{
message_with_tags = (gui_chat_display_tags) ?
gui_line_build_string_message_tags (line) : NULL;
gui_line_build_string_message_tags (line->data->message,
line->data->tags_count,
line->data->tags_array) : NULL;
ptr_data = (message_with_tags) ?
message_with_tags : line->data->message;
message_with_search = NULL;
@@ -1639,7 +1641,10 @@ void
gui_chat_display_line_y (struct t_gui_window *window, struct t_gui_line *line,
int y)
{
char *ptr_data, *message_with_search;
char *ptr_data, *message_with_search, *message_with_tags;
message_with_search = NULL;
message_with_tags = NULL;
/* reset color & style for a new line */
gui_chat_reset_style (window, line, 0, 1,
@@ -1653,9 +1658,9 @@ gui_chat_display_line_y (struct t_gui_window *window, struct t_gui_line *line,
gui_chat_clrtoeol (window);
/* emphasize text (if searching text) */
ptr_data = line->data->message;
message_with_search = NULL;
/* emphasize text (if searching text) */
if ((window->buffer->text_search != GUI_TEXT_SEARCH_DISABLED)
&& (window->buffer->text_search_where & GUI_TEXT_SEARCH_IN_MESSAGE)
&& (!window->buffer->text_search_regex
@@ -1669,6 +1674,17 @@ gui_chat_display_line_y (struct t_gui_window *window, struct t_gui_line *line,
ptr_data = message_with_search;
}
/* add tags if debug of tags is enabled */
if (gui_chat_display_tags)
{
message_with_tags = gui_line_build_string_message_tags (
ptr_data,
line->data->tags_count,
line->data->tags_array);
if (message_with_tags)
ptr_data = message_with_tags;
}
/* display the line */
if (gui_chat_display_word_raw (window, line, ptr_data,
window->win_chat_width, 0,
@@ -1680,6 +1696,8 @@ gui_chat_display_line_y (struct t_gui_window *window, struct t_gui_line *line,
if (message_with_search)
free (message_with_search);
if (message_with_tags)
free (message_with_tags);
}
/*
+9 -2
View File
@@ -941,9 +941,11 @@ gui_chat_printf_date_tags (struct t_gui_buffer *buffer, time_t date,
*/
void
gui_chat_printf_y (struct t_gui_buffer *buffer, int y, const char *message, ...)
gui_chat_printf_y_date_tags (struct t_gui_buffer *buffer, int y, time_t date,
const char *tags, const char *message, ...)
{
struct t_gui_line *ptr_line, *new_line, *new_line_empty;
time_t date_printed;
int i, last_y, num_lines_to_add;
if (gui_init_ok && !gui_chat_buffer_valid (buffer, GUI_BUFFER_TYPE_FREE))
@@ -962,7 +964,12 @@ gui_chat_printf_y (struct t_gui_buffer *buffer, int y, const char *message, ...)
utf8_normalize (vbuffer, '?');
new_line = gui_line_new (buffer, y, 0, 0, NULL, NULL, vbuffer);
date_printed = time (NULL);
if (date <= 0)
date = date_printed;
new_line = gui_line_new (buffer, y, date, date_printed, tags,
NULL, vbuffer);
if (!new_line)
goto end;
+6 -2
View File
@@ -31,6 +31,9 @@ struct t_gui_line;
#define gui_chat_printf(buffer, argz...) \
gui_chat_printf_date_tags(buffer, 0, NULL, ##argz)
#define gui_chat_printf_y(buffer, y, argz...) \
gui_chat_printf_y_date_tags(buffer, y, 0, NULL, ##argz)
#define GUI_CHAT_TAG_NO_HIGHLIGHT "no_highlight"
#define GUI_CHAT_PREFIX_ERROR_DEFAULT "=!="
@@ -90,8 +93,9 @@ extern int gui_chat_buffer_valid (struct t_gui_buffer *buffer,
extern void gui_chat_printf_date_tags (struct t_gui_buffer *buffer,
time_t date, const char *tags,
const char *message, ...);
extern void gui_chat_printf_y (struct t_gui_buffer *buffer, int y,
const char *message, ...);
extern void gui_chat_printf_y_date_tags (struct t_gui_buffer *buffer, int y,
time_t date, const char *tags,
const char *message, ...);
extern void gui_chat_print_lines_waiting_buffer (FILE *f);
extern int gui_chat_hsignal_quote_line_cb (const void *pointer, void *data,
const char *signal,
+33 -17
View File
@@ -379,7 +379,7 @@ gui_line_get_align (struct t_gui_buffer *buffer, struct t_gui_line *line,
*/
char *
gui_line_build_string_prefix_message (struct t_gui_line *line)
gui_line_build_string_prefix_message (const char *prefix, const char *message)
{
char **string, *string_without_colors;
@@ -387,11 +387,11 @@ gui_line_build_string_prefix_message (struct t_gui_line *line)
if (!string)
return NULL;
if (line->data->prefix)
string_dyn_concat (string, line->data->prefix, -1);
if (prefix)
string_dyn_concat (string, prefix, -1);
string_dyn_concat (string, "\t", -1);
if (line->data->message)
string_dyn_concat (string, line->data->message, -1);
if (message)
string_dyn_concat (string, message, -1);
string_without_colors = gui_color_decode (*string, NULL);
@@ -407,24 +407,28 @@ gui_line_build_string_prefix_message (struct t_gui_line *line)
*/
char *
gui_line_build_string_message_tags (struct t_gui_line *line)
gui_line_build_string_message_tags (const char *message,
int tags_count, char **tags_array)
{
int i;
char **string, *result;
if ((tags_count < 0) || ((tags_count > 0) && !tags_array))
return NULL;
string = string_dyn_alloc (256);
if (!string)
return NULL;
if (line->data->message)
string_dyn_concat (string, line->data->message, -1);
if (message)
string_dyn_concat (string, message, -1);
string_dyn_concat (string, GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), -1);
string_dyn_concat (string, " [", -1);
string_dyn_concat (string, GUI_COLOR(GUI_COLOR_CHAT_TAGS), -1);
for (i = 0; i < line->data->tags_count; i++)
for (i = 0; i < tags_count; i++)
{
string_dyn_concat (string, line->data->tags_array[i], -1);
if (i < line->data->tags_count - 1)
string_dyn_concat (string, tags_array[i], -1);
if (i < tags_count - 1)
string_dyn_concat (string, ",", -1);
}
string_dyn_concat (string, GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), -1);
@@ -1434,11 +1438,10 @@ gui_line_new (struct t_gui_buffer *buffer, int y, time_t date,
else
{
new_line->data->y = y;
new_line->data->date = 0;
new_line->data->date_printed = 0;
new_line->data->date = date;
new_line->data->date_printed = date_printed;
new_line->data->str_time = NULL;
new_line->data->tags_count = 0;
new_line->data->tags_array = NULL;
gui_line_tags_alloc (new_line->data, tags);
new_line->data->refresh_needed = 1;
new_line->data->prefix = NULL;
new_line->data->prefix_length = 0;
@@ -1688,7 +1691,8 @@ gui_line_add (struct t_gui_line *line)
GUI_HOTLIST_HIGHLIGHT, NULL);
if (!weechat_upgrading)
{
message_for_signal = gui_line_build_string_prefix_message (line);
message_for_signal = gui_line_build_string_prefix_message (
line->data->prefix, line->data->message);
if (message_for_signal)
{
(void) hook_signal_send ("weechat_highlight",
@@ -1703,7 +1707,8 @@ gui_line_add (struct t_gui_line *line)
if (!weechat_upgrading
&& (line->data->notify_level == GUI_HOTLIST_PRIVATE))
{
message_for_signal = gui_line_build_string_prefix_message (line);
message_for_signal = gui_line_build_string_prefix_message (
line->data->prefix, line->data->message);
if (message_for_signal)
{
(void) hook_signal_send ("weechat_pv",
@@ -1852,11 +1857,22 @@ gui_line_add_y (struct t_gui_line *line)
void
gui_line_clear (struct t_gui_line *line)
{
line->data->date = 0;
line->data->date_printed = 0;
if (line->data->str_time)
{
free (line->data->str_time);
line->data->str_time = NULL;
}
gui_line_tags_free (line->data);
if (line->data->prefix)
{
string_shared_free (line->data->prefix);
line->data->prefix = NULL;
}
line->data->prefix_length = 0;
line->data->notify_level = 0;
line->data->highlight = 0;
if (line->data->message)
free (line->data->message);
line->data->message = strdup ("");
+5 -2
View File
@@ -80,8 +80,11 @@ extern void gui_line_get_prefix_for_display (struct t_gui_line *line,
extern int gui_line_get_align (struct t_gui_buffer *buffer,
struct t_gui_line *line,
int with_suffix, int first_line);
extern char *gui_line_build_string_prefix_message (struct t_gui_line *line);
extern char *gui_line_build_string_message_tags (struct t_gui_line *line);
extern char *gui_line_build_string_prefix_message (const char *prefix,
const char *message);
extern char *gui_line_build_string_message_tags (const char *message,
int tags_count,
char **tags_array);
extern int gui_line_is_displayed (struct t_gui_line *line);
extern struct t_gui_line *gui_line_get_first_displayed (struct t_gui_buffer *buffer);
extern struct t_gui_line *gui_line_get_last_displayed (struct t_gui_buffer *buffer);
+22
View File
@@ -1922,6 +1922,27 @@ weechat_guile_api_print_y (SCM buffer, SCM y, SCM message)
API_RETURN_OK;
}
SCM
weechat_guile_api_print_y_date_tags (SCM buffer, SCM y, SCM date, SCM tags,
SCM message)
{
API_INIT_FUNC(1, "print_y_date_tags", API_RETURN_ERROR);
if (!scm_is_string (buffer) || !scm_is_integer (y)
|| !scm_is_integer (date) || !scm_is_string (tags)
|| !scm_is_string (message))
API_WRONG_ARGS(API_RETURN_ERROR);
plugin_script_api_printf_y_date_tags (weechat_guile_plugin,
guile_current_script,
API_STR2PTR(API_SCM_TO_STRING(buffer)),
scm_to_int (y),
scm_to_int (date),
API_SCM_TO_STRING(tags),
"%s", API_SCM_TO_STRING(message));
API_RETURN_OK;
}
SCM
weechat_guile_api_log_print (SCM message)
{
@@ -5121,6 +5142,7 @@ weechat_guile_api_module_init (void *data)
API_DEF_FUNC(print, 2);
API_DEF_FUNC(print_date_tags, 4);
API_DEF_FUNC(print_y, 3);
API_DEF_FUNC(print_y_date_tags, 5);
API_DEF_FUNC(log_print, 1);
API_DEF_FUNC(hook_command, 7);
API_DEF_FUNC(hook_completion, 4);
+24
View File
@@ -1812,6 +1812,29 @@ API_FUNC(print_y)
API_RETURN_OK;
}
API_FUNC(print_y_date_tags)
{
int y, date;
API_INIT_FUNC(1, "print_y_date_tags", "siiss", API_RETURN_ERROR);
v8::String::Utf8Value buffer(args[0]);
y = args[1]->IntegerValue();
date = args[2]->IntegerValue();
v8::String::Utf8Value tags(args[3]);
v8::String::Utf8Value message(args[4]);
plugin_script_api_printf_y_date_tags (weechat_js_plugin,
js_current_script,
(struct t_gui_buffer *)API_STR2PTR(*buffer),
y,
date,
*tags,
"%s", *message);
API_RETURN_OK;
}
API_FUNC(log_print)
{
API_INIT_FUNC(1, "log_print", "s", API_RETURN_ERROR);
@@ -5051,6 +5074,7 @@ WeechatJsV8::loadLibs()
API_DEF_FUNC(print);
API_DEF_FUNC(print_date_tags);
API_DEF_FUNC(print_y);
API_DEF_FUNC(print_y_date_tags);
API_DEF_FUNC(log_print);
API_DEF_FUNC(hook_command);
API_DEF_FUNC(hook_completion);
+27
View File
@@ -2024,6 +2024,32 @@ API_FUNC(print_y)
API_RETURN_OK;
}
API_FUNC(print_y_date_tags)
{
const char *buffer, *tags, *message;
int y, date;
API_INIT_FUNC(1, "print_y_date_tags", API_RETURN_ERROR);
if (lua_gettop (L) < 5)
API_WRONG_ARGS(API_RETURN_ERROR);
buffer = lua_tostring (L, -5);
y = lua_tonumber (L, -4);
date = lua_tonumber (L, -3);
tags = lua_tostring (L, -2);
message = lua_tostring (L, -1);
plugin_script_api_printf_y_date_tags (weechat_lua_plugin,
lua_current_script,
API_STR2PTR(buffer),
y,
date,
tags,
"%s", message);
API_RETURN_OK;
}
API_FUNC(log_print)
{
const char *message;
@@ -5415,6 +5441,7 @@ const struct luaL_Reg weechat_lua_api_funcs[] = {
API_DEF_FUNC(print),
API_DEF_FUNC(print_date_tags),
API_DEF_FUNC(print_y),
API_DEF_FUNC(print_y_date_tags),
API_DEF_FUNC(log_print),
API_DEF_FUNC(hook_command),
API_DEF_FUNC(hook_completion),
+25
View File
@@ -1937,6 +1937,30 @@ API_FUNC(print_y)
API_RETURN_OK;
}
API_FUNC(print_y_date_tags)
{
char *buffer, *tags, *message;
dXSARGS;
API_INIT_FUNC(1, "print_y_date_tags", API_RETURN_ERROR);
if (items < 5)
API_WRONG_ARGS(API_RETURN_ERROR);
buffer = SvPV_nolen (ST (0));
tags = SvPV_nolen (ST (3));
message = SvPV_nolen (ST (4));
plugin_script_api_printf_y_date_tags (weechat_perl_plugin,
perl_current_script,
API_STR2PTR(buffer),
SvIV (ST (1)),
SvIV (ST (2)),
tags,
"%s", message);
API_RETURN_OK;
}
API_FUNC(log_print)
{
dXSARGS;
@@ -5370,6 +5394,7 @@ weechat_perl_api_init (pTHX)
API_DEF_FUNC(print);
API_DEF_FUNC(print_date_tags);
API_DEF_FUNC(print_y);
API_DEF_FUNC(print_y_date_tags);
API_DEF_FUNC(log_print);
API_DEF_FUNC(hook_command);
API_DEF_FUNC(hook_completion);
+32
View File
@@ -2097,6 +2097,38 @@ API_FUNC(print_y)
API_RETURN_OK;
}
API_FUNC(print_y_date_tags)
{
zend_string *z_buffer, *z_tags, *z_message;
zend_long z_y, z_date;
struct t_gui_buffer *buffer;
int y;
time_t date;
char *tags, *message;
API_INIT_FUNC(1, "print_y_date_tags", API_RETURN_ERROR);
if (zend_parse_parameters (ZEND_NUM_ARGS(), "SllSS", &z_buffer, &z_y,
&z_date, &z_tags, &z_message) == FAILURE)
API_WRONG_ARGS(API_RETURN_ERROR);
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
y = (int)z_y;
date = (time_t)z_date;
tags = ZSTR_VAL(z_tags);
message = ZSTR_VAL(z_message);
plugin_script_api_printf_y_date_tags (weechat_php_plugin,
php_current_script,
buffer,
y,
date,
(const char *)tags,
"%s",
message);
API_RETURN_OK;
}
API_FUNC(log_print)
{
zend_string *z_message;
+1
View File
@@ -126,6 +126,7 @@ PHP_FUNCTION(weechat_color);
PHP_FUNCTION(weechat_print);
PHP_FUNCTION(weechat_print_date_tags);
PHP_FUNCTION(weechat_print_y);
PHP_FUNCTION(weechat_print_y_date_tags);
PHP_FUNCTION(weechat_log_print);
PHP_FUNCTION(weechat_hook_command);
PHP_FUNCTION(weechat_hook_completion);
+1
View File
@@ -184,6 +184,7 @@ const zend_function_entry weechat_functions[] = {
PHP_FE(weechat_print, arginfo_weechat_print)
PHP_FE(weechat_print_date_tags, arginfo_weechat_print_date_tags)
PHP_FE(weechat_print_y, arginfo_weechat_print_y)
PHP_FE(weechat_print_y_date_tags, arginfo_weechat_print_y_date_tags)
PHP_FE(weechat_log_print, arginfo_weechat_log_print)
PHP_FE(weechat_hook_command, arginfo_weechat_hook_command)
PHP_FE(weechat_hook_completion, arginfo_weechat_hook_completion)
+1
View File
@@ -87,6 +87,7 @@ function weechat_color(): mixed {}
function weechat_print(): mixed {}
function weechat_print_date_tags(): mixed {}
function weechat_print_y(): mixed {}
function weechat_print_y_date_tags(): mixed {}
function weechat_log_print(): mixed {}
function weechat_hook_command(): mixed {}
function weechat_hook_completion(): mixed {}
+2
View File
@@ -164,6 +164,8 @@ ZEND_END_ARG_INFO()
#define arginfo_weechat_print_y arginfo_weechat_register
#define arginfo_weechat_print_y_date_tags arginfo_weechat_register
#define arginfo_weechat_log_print arginfo_weechat_register
#define arginfo_weechat_hook_command arginfo_weechat_register
@@ -164,6 +164,8 @@ ZEND_END_ARG_INFO()
#define arginfo_weechat_print_y arginfo_weechat_register
#define arginfo_weechat_print_y_date_tags arginfo_weechat_register
#define arginfo_weechat_log_print arginfo_weechat_register
#define arginfo_weechat_hook_command arginfo_weechat_register
+28 -1
View File
@@ -326,7 +326,7 @@ plugin_script_api_printf (struct t_weechat_plugin *weechat_plugin,
}
/*
* Prints a message with optional date and tags.
* Prints a message, with optional date and tags.
*/
void
@@ -377,6 +377,33 @@ plugin_script_api_printf_y (struct t_weechat_plugin *weechat_plugin,
free (vbuffer);
}
/*
* Prints a message on a buffer with free content, with optional date and tags.
*/
void
plugin_script_api_printf_y_date_tags (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_gui_buffer *buffer, int y,
time_t date, const char *tags,
const char *format, ...)
{
char *buf2;
weechat_va_format (format);
if (!vbuffer)
return;
buf2 = (script && script->charset && script->charset[0]) ?
weechat_iconv_to_internal (script->charset, vbuffer) : NULL;
weechat_printf_y_date_tags (buffer, y, date, tags,
"%s", (buf2) ? buf2 : vbuffer);
if (buf2)
free (buf2);
free (vbuffer);
}
/*
* Prints a message in WeeChat log file.
*/
+6
View File
@@ -119,6 +119,12 @@ extern void plugin_script_api_printf_y (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_gui_buffer *buffer,
int y, const char *format, ...);
extern void plugin_script_api_printf_y_date_tags (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_gui_buffer *buffer,
int y, time_t date,
const char *tags,
const char *format, ...);
extern void plugin_script_api_log_printf (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
const char *format, ...);
+1 -1
View File
@@ -772,7 +772,7 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv)
new_plugin->prefix = &plugin_api_prefix;
new_plugin->color = &plugin_api_color;
new_plugin->printf_date_tags = &gui_chat_printf_date_tags;
new_plugin->printf_y = &gui_chat_printf_y;
new_plugin->printf_y_date_tags = &gui_chat_printf_y_date_tags;
new_plugin->log_printf = &log_printf;
new_plugin->hook_command = &hook_command;
+26
View File
@@ -1930,6 +1930,31 @@ API_FUNC(prnt_y)
API_RETURN_OK;
}
API_FUNC(prnt_y_date_tags)
{
char *buffer, *tags, *message;
int y, date;
API_INIT_FUNC(1, "prnt_y_date_tags", API_RETURN_ERROR);
buffer = NULL;
y = 0;
date = 0;
tags = NULL;
message = NULL;
if (!PyArg_ParseTuple (args, "siiss", &buffer, &y, &date, &tags, &message))
API_WRONG_ARGS(API_RETURN_ERROR);
plugin_script_api_printf_y_date_tags (weechat_python_plugin,
python_current_script,
API_STR2PTR(buffer),
y,
date,
tags,
"%s", message);
API_RETURN_OK;
}
API_FUNC(log_print)
{
char *message;
@@ -5279,6 +5304,7 @@ PyMethodDef weechat_python_funcs[] =
API_DEF_FUNC(prnt),
API_DEF_FUNC(prnt_date_tags),
API_DEF_FUNC(prnt_y),
API_DEF_FUNC(prnt_y_date_tags),
API_DEF_FUNC(log_print),
API_DEF_FUNC(hook_command),
API_DEF_FUNC(hook_completion),
+5
View File
@@ -444,6 +444,11 @@ def prnt_y(buffer: str, y: int, message: str) -> int:
...
def prnt_y_date_tags(buffer: str, y: int, date: int, tags: str, message: str) -> int:
"""`prnt_y_date_tags in WeeChat plugin API reference <https://weechat.org/doc/api#_prnt_y_date_tags>`_"""
...
def log_print(message: str) -> int:
"""`log_print in WeeChat plugin API reference <https://weechat.org/doc/api#_log_print>`_"""
...
+37
View File
@@ -2387,6 +2387,42 @@ weechat_ruby_api_print_y (VALUE class, VALUE buffer, VALUE y, VALUE message)
API_RETURN_OK;
}
static VALUE
weechat_ruby_api_print_y_date_tags (VALUE class, VALUE buffer, VALUE y,
VALUE date, VALUE tags, VALUE message)
{
char *c_buffer, *c_tags, *c_message;
int c_y;
time_t c_date;
API_INIT_FUNC(1, "print_y_date_tags", API_RETURN_ERROR);
if (NIL_P (buffer) || NIL_P (y) || NIL_P (date) || NIL_P (tags)
|| NIL_P (message))
API_WRONG_ARGS(API_RETURN_ERROR);
Check_Type (buffer, T_STRING);
CHECK_INTEGER(y);
CHECK_INTEGER(date);
Check_Type (tags, T_STRING);
Check_Type (message, T_STRING);
c_buffer = StringValuePtr (buffer);
c_y = NUM2INT (y);
c_date = NUM2ULONG (date);
c_tags = StringValuePtr (tags);
c_message = StringValuePtr (message);
plugin_script_api_printf_y_date_tags (weechat_ruby_plugin,
ruby_current_script,
API_STR2PTR(c_buffer),
c_y,
c_date,
c_tags,
"%s", c_message);
API_RETURN_OK;
}
static VALUE
weechat_ruby_api_log_print (VALUE class, VALUE message)
{
@@ -6540,6 +6576,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
API_DEF_FUNC(print, 2);
API_DEF_FUNC(print_date_tags, 4);
API_DEF_FUNC(print_y, 3);
API_DEF_FUNC(print_y_date_tags, 5);
API_DEF_FUNC(log_print, 1);
API_DEF_FUNC(hook_command, 7);
API_DEF_FUNC(hook_completion, 4);
+35 -3
View File
@@ -2134,13 +2134,13 @@ API_FUNC(print_date_tags)
{
Tcl_Obj *objp;
char *buffer, *tags, *message;
int i, tdate;
int i, date;
API_INIT_FUNC(1, "print_date_tags", API_RETURN_ERROR);
if (objc < 5)
API_WRONG_ARGS(API_RETURN_ERROR);
if (Tcl_GetIntFromObj (interp, objv[2], &tdate) != TCL_OK)
if (Tcl_GetIntFromObj (interp, objv[2], &date) != TCL_OK)
API_WRONG_ARGS(API_RETURN_ERROR);
buffer = Tcl_GetStringFromObj (objv[1], &i);
@@ -2150,7 +2150,7 @@ API_FUNC(print_date_tags)
plugin_script_api_printf_date_tags (weechat_tcl_plugin,
tcl_current_script,
API_STR2PTR(buffer),
tdate,
date,
tags,
"%s", message);
@@ -2182,6 +2182,37 @@ API_FUNC(print_y)
API_RETURN_OK;
}
API_FUNC(print_y_date_tags)
{
Tcl_Obj *objp;
char *buffer, *tags, *message;
int i, y, date;
API_INIT_FUNC(1, "print_y_date_tags", API_RETURN_ERROR);
if (objc < 6)
API_WRONG_ARGS(API_RETURN_ERROR);
if (Tcl_GetIntFromObj (interp, objv[2], &y) != TCL_OK)
API_WRONG_ARGS(API_RETURN_ERROR);
if (Tcl_GetIntFromObj (interp, objv[3], &date) != TCL_OK)
API_WRONG_ARGS(API_RETURN_ERROR);
buffer = Tcl_GetStringFromObj (objv[1], &i);
tags = Tcl_GetStringFromObj (objv[4], &i);
message = Tcl_GetStringFromObj (objv[5], &i);
plugin_script_api_printf_y_date_tags (weechat_tcl_plugin,
tcl_current_script,
API_STR2PTR(buffer),
y,
date,
tags,
"%s", message);
API_RETURN_OK;
}
API_FUNC(log_print)
{
Tcl_Obj *objp;
@@ -5843,6 +5874,7 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
API_DEF_FUNC(print);
API_DEF_FUNC(print_date_tags);
API_DEF_FUNC(print_y);
API_DEF_FUNC(print_y_date_tags);
API_DEF_FUNC(log_print);
API_DEF_FUNC(hook_command);
API_DEF_FUNC(hook_completion);
+10 -4
View File
@@ -68,7 +68,7 @@ struct timeval;
* please change the date with current one; for a second change at same
* date, increment the 01, otherwise please keep 01.
*/
#define WEECHAT_PLUGIN_API_VERSION "20211106-01"
#define WEECHAT_PLUGIN_API_VERSION "20220130-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -653,8 +653,9 @@ struct t_weechat_plugin
const char *(*color) (const char *color_name);
void (*printf_date_tags) (struct t_gui_buffer *buffer, time_t date,
const char *tags, const char *message, ...);
void (*printf_y) (struct t_gui_buffer *buffer, int y,
const char *message, ...);
void (*printf_y_date_tags) (struct t_gui_buffer *buffer, int y,
time_t date, const char *tags,
const char *message, ...);
void (*log_printf) (const char *message, ...);
/* hooks */
@@ -1689,7 +1690,12 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
(weechat_plugin->printf_date_tags)(__buffer, __date, __tags, \
__message, ##__argz)
#define weechat_printf_y(__buffer, __y, __message, __argz...) \
(weechat_plugin->printf_y)(__buffer, __y, __message, ##__argz)
(weechat_plugin->printf_y_date_tags)(__buffer, __y, 0, NULL, \
__message, ##__argz)
#define weechat_printf_y_date_tags(__buffer, __y, __date, __tags, \
__message, __argz...) \
(weechat_plugin->printf_y_date_tags)(__buffer, __y, __date, __tags, \
__message, ##__argz)
#define weechat_log_printf(__message, __argz...) \
(weechat_plugin->log_printf)(__message, ##__argz)
+16
View File
@@ -148,6 +148,16 @@ def test_key():
check(weechat.key_unbind('mouse', 'quiet:area:chat(plugin.test)') == 3)
def buffer_input_cb(data, buffer, input_data):
"""Buffer input callback."""
return weechat.WEECHAT_RC_OK
def buffer_close_cb(data, buffer):
"""Buffer close callback."""
return weechat.WEECHAT_RC_OK
def test_display():
"""Test display functions."""
check(weechat.prefix('action') != '')
@@ -158,6 +168,12 @@ def test_display():
check(weechat.prefix('unknown') == '')
check(weechat.color('green') != '')
check(weechat.color('unknown') == '')
weechat.prnt('', '## test prnt')
weechat.prnt_date_tags('', 946681200, 'tag1,tag2', '## test prnt_date_tags')
buffer = weechat.buffer_new('test_free', 'buffer_input_cb', '', 'buffer_close_cb', '')
weechat.prnt_y(buffer, 0, '## test prnt_y')
weechat.prnt_y_date_tags(buffer, 0, 946681200, 'tag1,tag2', '## test prnt_y_date_tags')
weechat.buffer_close(buffer)
def completion_cb(data, completion_item, buf, completion):
+1
View File
@@ -111,6 +111,7 @@ class WeechatScript(object): # pylint: disable=too-many-instance-attributes
'prnt': 'print',
'prnt_date_tags': 'print_date_tags',
'prnt_y': 'print_y',
'prnt_y_date_tags': 'print_y_date_tags',
}
for node in ast.walk(self.tree):
if isinstance(node, ast.Call) and \
+4 -1
View File
@@ -89,8 +89,11 @@ TEST_GROUP(Scripts)
api_tests_errors++;
else if (strstr (message, "TESTS END"))
api_tests_end++;
else if ((message[0] != '>') && (message[0] != ' '))
else if ((message[0] != '>') && (message[0] != ' ')
&& (strncmp (message, "## ", 3) != 0))
{
api_tests_other++;
}
}
return WEECHAT_RC_OK;
+100 -16
View File
@@ -520,6 +520,27 @@ TEST(GuiChat, PrintDateTags)
LONGS_EQUAL(4, ptr_data->prefix_length);
STRCMP_EQUAL("this is a test", ptr_data->message);
/* message with empty tags */
ptr_last_line = gui_buffers->own_lines->last_line;
gui_chat_printf_date_tags (gui_buffers, 0, "", "nick\tthis is a test");
CHECK(ptr_last_line != gui_buffers->own_lines->last_line);
ptr_data = gui_buffers->own_lines->last_line->data;
CHECK(ptr_data);
POINTERS_EQUAL(gui_buffers, ptr_data->buffer);
LONGS_EQUAL(-1, ptr_data->y);
CHECK(ptr_data->date > 0);
CHECK(ptr_data->date == ptr_data->date_printed);
CHECK(ptr_data->str_time && ptr_data->str_time[0]);
LONGS_EQUAL(0, ptr_data->tags_count);
POINTERS_EQUAL(NULL, ptr_data->tags_array);
LONGS_EQUAL(1, ptr_data->displayed);
LONGS_EQUAL(0, ptr_data->notify_level);
LONGS_EQUAL(0, ptr_data->highlight);
LONGS_EQUAL(0, ptr_data->refresh_needed);
STRCMP_EQUAL("nick", ptr_data->prefix);
LONGS_EQUAL(4, ptr_data->prefix_length);
STRCMP_EQUAL("this is a test", ptr_data->message);
/* message with 3 tags */
ptr_last_line = gui_buffers->own_lines->last_line;
gui_chat_printf_date_tags (gui_buffers, 0, "tag1,tag2,tag3", "nick\tthis is a test");
@@ -547,10 +568,10 @@ TEST(GuiChat, PrintDateTags)
/*
* Tests functions:
* gui_chat_printf_y
* gui_chat_printf_y_date_tags
*/
TEST(GuiChat, PrintY)
TEST(GuiChat, PrintYDateTags)
{
struct t_gui_buffer *buffer;
struct t_gui_line_data *ptr_data;
@@ -560,30 +581,30 @@ TEST(GuiChat, PrintY)
gui_buffer_set (buffer, "type", "free");
/* invalid buffer pointer */
gui_chat_printf_y ((struct t_gui_buffer *)0x1, 0, "test");
gui_chat_printf_y_date_tags ((struct t_gui_buffer *)0x1, 0, 0, NULL, "test");
POINTERS_EQUAL(NULL, buffer->own_lines->last_line);
/* invalid buffer: not with free content */
gui_chat_printf_y (gui_buffers, 0, "test");
gui_chat_printf_y_date_tags (gui_buffers, 0, 0, NULL, "test");
POINTERS_EQUAL(NULL, buffer->own_lines->last_line);
/* NULL message */
gui_chat_printf_y (buffer, 0, NULL);
gui_chat_printf_y_date_tags (buffer, 0, 0, NULL, NULL);
POINTERS_EQUAL(NULL, buffer->own_lines->last_line);
/* empty message */
gui_chat_printf_y (buffer, 0, "");
gui_chat_printf_y_date_tags (buffer, 0, 0, NULL, "");
POINTERS_EQUAL(NULL, buffer->own_lines->last_line);
/* message on first line */
gui_chat_printf_y (buffer, 0, "this is a test on line 1");
gui_chat_printf_y_date_tags (buffer, 0, 0, NULL, "this is a test on line 1");
CHECK(buffer->own_lines->last_line);
ptr_data = buffer->own_lines->last_line->data;
CHECK(ptr_data);
POINTERS_EQUAL(buffer, ptr_data->buffer);
LONGS_EQUAL(0, ptr_data->y);
LONGS_EQUAL(0, ptr_data->date);
LONGS_EQUAL(0, ptr_data->date_printed);
CHECK(ptr_data->date > 0);
CHECK(ptr_data->date == ptr_data->date_printed);
POINTERS_EQUAL(NULL, ptr_data->str_time);
LONGS_EQUAL(0, ptr_data->tags_count);
POINTERS_EQUAL(NULL, ptr_data->tags_array);
@@ -595,15 +616,78 @@ TEST(GuiChat, PrintY)
LONGS_EQUAL(0, ptr_data->prefix_length);
STRCMP_EQUAL("this is a test on line 1", ptr_data->message);
/* message on first line with past date */
gui_chat_printf_y_date_tags (buffer, 0, 946681200, NULL, "this is a test on line 1");
CHECK(buffer->own_lines->last_line);
ptr_data = buffer->own_lines->last_line->data;
CHECK(ptr_data);
POINTERS_EQUAL(buffer, ptr_data->buffer);
LONGS_EQUAL(0, ptr_data->y);
LONGS_EQUAL(946681200, ptr_data->date);
CHECK(ptr_data->date < ptr_data->date_printed);
POINTERS_EQUAL(NULL, ptr_data->str_time);
LONGS_EQUAL(0, ptr_data->tags_count);
POINTERS_EQUAL(NULL, ptr_data->tags_array);
LONGS_EQUAL(1, ptr_data->displayed);
LONGS_EQUAL(0, ptr_data->notify_level);
LONGS_EQUAL(0, ptr_data->highlight);
LONGS_EQUAL(1, ptr_data->refresh_needed);
POINTERS_EQUAL(NULL, ptr_data->prefix);
LONGS_EQUAL(0, ptr_data->prefix_length);
STRCMP_EQUAL("this is a test on line 1", ptr_data->message);
/* message on first line with empty tags */
gui_chat_printf_y_date_tags (buffer, 0, 0, "", "this is a test on line 1");
CHECK(buffer->own_lines->last_line);
ptr_data = buffer->own_lines->last_line->data;
CHECK(ptr_data);
POINTERS_EQUAL(buffer, ptr_data->buffer);
LONGS_EQUAL(0, ptr_data->y);
CHECK(ptr_data->date > 0);
CHECK(ptr_data->date == ptr_data->date_printed);
POINTERS_EQUAL(NULL, ptr_data->str_time);
LONGS_EQUAL(0, ptr_data->tags_count);
POINTERS_EQUAL(NULL, ptr_data->tags_array);
LONGS_EQUAL(1, ptr_data->displayed);
LONGS_EQUAL(0, ptr_data->notify_level);
LONGS_EQUAL(0, ptr_data->highlight);
LONGS_EQUAL(1, ptr_data->refresh_needed);
POINTERS_EQUAL(NULL, ptr_data->prefix);
LONGS_EQUAL(0, ptr_data->prefix_length);
STRCMP_EQUAL("this is a test on line 1", ptr_data->message);
/* message on first line with 3 tags */
gui_chat_printf_y_date_tags (buffer, 0, 0, "tag1,tag2,tag3", "this is a test on line 1");
CHECK(buffer->own_lines->last_line);
ptr_data = buffer->own_lines->last_line->data;
CHECK(ptr_data);
POINTERS_EQUAL(buffer, ptr_data->buffer);
LONGS_EQUAL(0, ptr_data->y);
CHECK(ptr_data->date > 0);
CHECK(ptr_data->date == ptr_data->date_printed);
POINTERS_EQUAL(NULL, ptr_data->str_time);
LONGS_EQUAL(3, ptr_data->tags_count);
CHECK(ptr_data->tags_array);
STRCMP_EQUAL("tag1", ptr_data->tags_array[0]);
STRCMP_EQUAL("tag2", ptr_data->tags_array[1]);
STRCMP_EQUAL("tag3", ptr_data->tags_array[2]);
LONGS_EQUAL(1, ptr_data->displayed);
LONGS_EQUAL(0, ptr_data->notify_level);
LONGS_EQUAL(0, ptr_data->highlight);
LONGS_EQUAL(1, ptr_data->refresh_needed);
POINTERS_EQUAL(NULL, ptr_data->prefix);
LONGS_EQUAL(0, ptr_data->prefix_length);
STRCMP_EQUAL("this is a test on line 1", ptr_data->message);
/* message on third line */
gui_chat_printf_y (buffer, 2, "this is a test on line 3");
gui_chat_printf_y_date_tags (buffer, 2, 0, NULL, "this is a test on line 3");
CHECK(buffer->own_lines->last_line);
ptr_data = buffer->own_lines->last_line->data;
CHECK(ptr_data);
POINTERS_EQUAL(buffer, ptr_data->buffer);
LONGS_EQUAL(2, ptr_data->y);
LONGS_EQUAL(0, ptr_data->date);
LONGS_EQUAL(0, ptr_data->date_printed);
CHECK(ptr_data->date > 0);
CHECK(ptr_data->date == ptr_data->date_printed);
POINTERS_EQUAL(NULL, ptr_data->str_time);
LONGS_EQUAL(0, ptr_data->tags_count);
POINTERS_EQUAL(NULL, ptr_data->tags_array);
@@ -616,7 +700,7 @@ TEST(GuiChat, PrintY)
STRCMP_EQUAL("this is a test on line 3", ptr_data->message);
/* delete first line */
gui_chat_printf_y (buffer, 0, "");
gui_chat_printf_y_date_tags (buffer, 0, 0, NULL, "");
ptr_data = buffer->own_lines->first_line->data;
CHECK(ptr_data);
POINTERS_EQUAL(buffer, ptr_data->buffer);
@@ -635,13 +719,13 @@ TEST(GuiChat, PrintY)
STRCMP_EQUAL("", ptr_data->message);
/* delete third line */
gui_chat_printf_y (buffer, 2, "");
gui_chat_printf_y_date_tags (buffer, 2, 0, NULL, "");
CHECK(buffer->own_lines->first_line);
CHECK(buffer->own_lines->first_line->next_line);
POINTERS_EQUAL(NULL, buffer->own_lines->first_line->next_line->next_line);
/* delete secondline */
gui_chat_printf_y (buffer, 1, "");
/* delete second line */
gui_chat_printf_y_date_tags (buffer, 1, 0, NULL, "");
CHECK(buffer->own_lines->first_line);
POINTERS_EQUAL(NULL, buffer->own_lines->first_line->next_line);
+17 -2
View File
@@ -36,7 +36,8 @@ extern "C"
#define WEE_BUILD_STR_PREFIX_MSG(__result, __prefix, __message) \
line = gui_line_new (gui_buffers, -1, 0, 0, "tag1,tag2", \
__prefix, __message); \
str = gui_line_build_string_prefix_message (line); \
str = gui_line_build_string_prefix_message (line->data->prefix, \
line->data->message); \
STRCMP_EQUAL(__result, str); \
free (str); \
gui_line_free_data (line); \
@@ -45,7 +46,9 @@ extern "C"
#define WEE_BUILD_STR_MSG_TAGS(__tags, __message) \
line = gui_line_new (gui_buffers, -1, 0, 0, __tags, \
NULL, __message); \
str = gui_line_build_string_message_tags (line); \
str = gui_line_build_string_message_tags (line->data->message, \
line->data->tags_count, \
line->data->tags_array); \
STRCMP_EQUAL(str_result, str); \
free (str); \
gui_line_free_data (line); \
@@ -213,6 +216,18 @@ TEST(GuiLine, BuildStringMessageTags)
struct t_gui_line *line;
char *str, str_result[256];
line = gui_line_new (gui_buffers, -1, 0, 0, "tag1,tag2", NULL, "test");
POINTERS_EQUAL(NULL,
gui_line_build_string_message_tags (line->data->message,
-1,
line->data->tags_array));
POINTERS_EQUAL(NULL,
gui_line_build_string_message_tags (line->data->message,
1,
NULL));
gui_line_free_data (line);
free (line);
snprintf (str_result, sizeof (str_result),
"message%s [%s%s]",
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),