diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/gui-chat.c | 24 | ||||
-rw-r--r-- | src/gui/gui-line.c | 22 | ||||
-rw-r--r-- | src/gui/gui-line.h | 1 |
3 files changed, 41 insertions, 6 deletions
diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c index 9d95aebae..a12d127e7 100644 --- a/src/gui/gui-chat.c +++ b/src/gui/gui-chat.c @@ -35,7 +35,6 @@ #include "../core/weechat.h" #include "../core/wee-config.h" #include "../core/wee-hook.h" -#include "../core/wee-log.h" #include "../core/wee-string.h" #include "../core/wee-utf8.h" #include "../plugins/plugin.h" @@ -657,6 +656,7 @@ gui_chat_printf_y (struct t_gui_buffer *buffer, int y, const char *message, ...) va_list argptr; struct t_gui_line *ptr_line; char strbuf[8192]; + int i, num_lines_to_add; if (gui_init_ok) { @@ -689,7 +689,10 @@ gui_chat_printf_y (struct t_gui_buffer *buffer, int y, const char *message, ...) } if (ptr_line && (ptr_line->data->y == y)) { - gui_line_free (buffer, ptr_line); + if (ptr_line->next_line) + gui_line_clear (ptr_line); + else + gui_line_free (buffer, ptr_line); gui_buffer_ask_chat_refresh (buffer, 2); } } @@ -698,6 +701,23 @@ gui_chat_printf_y (struct t_gui_buffer *buffer, int y, const char *message, ...) { if (gui_init_ok) { + num_lines_to_add = 0; + 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, strbuf); gui_buffer_ask_chat_refresh (buffer, 1); } diff --git a/src/gui/gui-line.c b/src/gui/gui-line.c index bf4e6d121..bc060dfb9 100644 --- a/src/gui/gui-line.c +++ b/src/gui/gui-line.c @@ -896,9 +896,6 @@ gui_line_add_y (struct t_gui_buffer *buffer, int y, const char *message) struct t_gui_line *ptr_line, *new_line; struct t_gui_line_data *new_line_data; - if (!message || !message[0]) - return; - /* search if line exists for "y" */ for (ptr_line = buffer->own_lines->first_line; ptr_line; ptr_line = ptr_line->next_line) @@ -970,7 +967,7 @@ gui_line_add_y (struct t_gui_buffer *buffer, int y, const char *message) /* set message for line */ if (ptr_line->data->message) free (ptr_line->data->message); - ptr_line->data->message = strdup (message); + ptr_line->data->message = (message) ? strdup (message) : strdup (""); /* check if line is filtered or not */ ptr_line->data->displayed = gui_filter_check_line (buffer, ptr_line); @@ -988,6 +985,23 @@ gui_line_add_y (struct t_gui_buffer *buffer, int y, const char *message) } /* + * gui_line_clear: clear prefix and message on a line + * (used on buffers with free content only) + */ + +void +gui_line_clear (struct t_gui_line *line) +{ + if (line->data->prefix) + free (line->data->prefix); + line->data->prefix = strdup (""); + + if (line->data->message) + free (line->data->message); + line->data->message = strdup (""); +} + +/* * gui_line_mix_buffers: mix lines of a buffer (or group of buffers) with a new * buffer */ diff --git a/src/gui/gui-line.h b/src/gui/gui-line.h index 6555e64c0..c0c78bbcd 100644 --- a/src/gui/gui-line.h +++ b/src/gui/gui-line.h @@ -100,6 +100,7 @@ extern struct t_gui_line *gui_line_add (struct t_gui_buffer *buffer, const char *message); extern void gui_line_add_y (struct t_gui_buffer *buffer, int y, const char *message); +extern void gui_line_clear (struct t_gui_line *line); extern void gui_line_mix_buffers (struct t_gui_buffer *buffer); extern int gui_line_add_to_infolist (struct t_infolist *infolist, struct t_gui_lines *lines, |