From 907e099f86697ffce9da91f10ad4a2c6e21e851d Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 16 Mar 2014 17:21:35 +0100 Subject: [PATCH] api: allow negative value for y in function printf_y --- ChangeLog.asciidoc | 1 + doc/en/weechat_plugin_api.en.txt | 5 ++++- doc/fr/weechat_plugin_api.fr.txt | 6 +++++- doc/it/weechat_plugin_api.it.txt | 6 +++++- doc/ja/weechat_plugin_api.ja.txt | 6 +++++- src/gui/gui-chat.c | 9 ++++++++- 6 files changed, 28 insertions(+), 5 deletions(-) diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc index ec24a9df4..9050d3635 100644 --- a/ChangeLog.asciidoc +++ b/ChangeLog.asciidoc @@ -51,6 +51,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] * core: add signals "key_combo_{default|search|cursor}" * core: display a warning in case of inconsistency between the options weechat.look.save_{config|layout}_on_exit +* api: allow negative value for y in function printf_y * api: add support of case insensitive search and search by buffer full name in function buffer_search (bug #34318) * api: add option "detached" in function hook_process_hashtable diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt index 9812abc2e..7be917b19 100644 --- a/doc/en/weechat_plugin_api.en.txt +++ b/doc/en/weechat_plugin_api.en.txt @@ -6588,7 +6588,10 @@ void weechat_printf_y (struct t_gui_buffer *buffer, int y, Arguments: * 'buffer': buffer pointer -* 'y': line number (first line is 0) +* '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) + _(WeeChat ≥ 0.4.4)_ * 'message': message to display C example: diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt index b8b334994..36085b3ca 100644 --- a/doc/fr/weechat_plugin_api.fr.txt +++ b/doc/fr/weechat_plugin_api.fr.txt @@ -6689,7 +6689,11 @@ void weechat_printf_y (struct t_gui_buffer *buffer, int y, Paramètres : * 'buffer' : pointeur vers le tampon -* 'y' : numéro de ligne (la première ligne est 0) +* '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) + _(WeeChat ≥ 0.4.4)_ * 'message' : message à afficher Exemple en C : diff --git a/doc/it/weechat_plugin_api.it.txt b/doc/it/weechat_plugin_api.it.txt index 1ce753ae0..7bd7bc4a4 100644 --- a/doc/it/weechat_plugin_api.it.txt +++ b/doc/it/weechat_plugin_api.it.txt @@ -6685,7 +6685,11 @@ void weechat_printf_y (struct t_gui_buffer *buffer, int y, Argomenti: * 'buffer': puntatore al buffer -* 'y': numero di riga (la prima riga è 0) +// 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) _(WeeChat ≥ 0.4.4)_ * 'message': messaggio da visualizzare Esempio in C: diff --git a/doc/ja/weechat_plugin_api.ja.txt b/doc/ja/weechat_plugin_api.ja.txt index b610b8fe9..881e49d89 100644 --- a/doc/ja/weechat_plugin_api.ja.txt +++ b/doc/ja/weechat_plugin_api.ja.txt @@ -6594,7 +6594,11 @@ void weechat_printf_y (struct t_gui_buffer *buffer, int y, 引数: * 'buffer': バッファへのポインタ -* 'y': 行番号 (1 行目は 0) +// TRANSLATION MISSING +* 'y': 行番号 (1 行目は 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) + _(WeeChat バージョン 0.4.4 以上で利用可)_ * 'message': 表示するメッセージ C 言語での使用例: diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c index e9f078717..b14c896af 100644 --- a/src/gui/gui-chat.c +++ b/src/gui/gui-chat.c @@ -863,7 +863,7 @@ gui_chat_printf_y (struct t_gui_buffer *buffer, int y, const char *message, ...) /* no message: delete line */ if (!vbuffer[0]) { - if (gui_init_ok) + if (gui_init_ok && (y >= 0)) { for (ptr_line = buffer->own_lines->first_line; ptr_line; ptr_line = ptr_line->next_line) @@ -885,6 +885,13 @@ gui_chat_printf_y (struct t_gui_buffer *buffer, int y, const char *message, ...) { 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