1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-30 23:06:38 +02:00

Fix scroll problem on buffers with free content and non-allocated lines (bug #32039)

This commit is contained in:
Sebastien Helleu
2011-01-05 14:58:17 +01:00
parent ccc6d52e3a
commit 25fe7a53a1
4 changed files with 44 additions and 7 deletions
+3 -1
View File
@@ -1,7 +1,7 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
v0.3.4-rc3, 2011-01-04
v0.3.4-rc3, 2011-01-05
Version 0.3.4 (under dev!)
@@ -9,6 +9,8 @@ Version 0.3.4 (under dev!)
* core: add 256 colors support, new command /color, new section "palette" in
weechat.conf (task #6834)
* core: fix scroll problem on buffers with free content and non-allocated lines
(bug #32039)
* core: add info "weechat_upgrading", signal "upgrade_ended", display duration
of upgrade
* core: replace the 10 nick color options and number of nick colors by a single
+22 -2
View File
@@ -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);
}
+18 -4
View File
@@ -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);
@@ -987,6 +984,23 @@ gui_line_add_y (struct t_gui_buffer *buffer, int y, const char *message)
ptr_line->data->refresh_needed = 1;
}
/*
* 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
+1
View File
@@ -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,