1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-07 10:13:12 +02:00

api: allow negative value for y in function printf_y

This commit is contained in:
Sebastien Helleu
2014-03-16 17:21:35 +01:00
parent fa28d23c4d
commit 907e099f86
6 changed files with 28 additions and 5 deletions
+8 -1
View File
@@ -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