mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 04:46:37 +02:00
Fix some display bugs with read marker line, history, max prefix length, and chat refresh (bug #23153)
Some info about bugs fixed: - when marker line (dotted) was on top of window (and not visible), this caused bug on last lines of buffer (not refreshed) - marker line is not set for a buffer after a switch, only if buffer it not displayed in other window - when we delete lines in a buffer (if lines > weechat.history.max_lines), we force a full refresh of chat if remaining lines is < to chat height and we compute again max prefix length for buffer (before max prefix length was always incremented, never decremented)
This commit is contained in:
@@ -142,7 +142,7 @@ gui_chat_get_real_width (struct t_gui_window *window)
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_chat_marker_for_line: return 1 if marker must be displayed before this
|
||||
* gui_chat_marker_for_line: return 1 if marker must be displayed after this
|
||||
* line, or 0 if it must not
|
||||
*/
|
||||
|
||||
@@ -158,7 +158,6 @@ gui_chat_marker_for_line (struct t_gui_buffer *buffer, struct t_gui_line *line)
|
||||
&& (CONFIG_INTEGER(config_look_read_marker) != CONFIG_LOOK_READ_MARKER_DOTTED_LINE))
|
||||
return 0;
|
||||
|
||||
line = line->prev_line;
|
||||
while (line)
|
||||
{
|
||||
if (buffer->last_read_line == line)
|
||||
@@ -167,7 +166,7 @@ gui_chat_marker_for_line (struct t_gui_buffer *buffer, struct t_gui_line *line)
|
||||
if (line->displayed)
|
||||
break;
|
||||
|
||||
line = line->prev_line;
|
||||
line = line->next_line;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -804,14 +803,6 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
|
||||
|
||||
marker_line = gui_chat_marker_for_line (window->buffer, line);
|
||||
|
||||
if (marker_line)
|
||||
{
|
||||
gui_chat_display_horizontal_line (window, simulate);
|
||||
gui_chat_display_new_line (window, num_lines, count,
|
||||
&lines_displayed, simulate);
|
||||
lines_displayed--;
|
||||
}
|
||||
|
||||
/* display time and prefix */
|
||||
gui_chat_display_time_and_prefix (window, line, num_lines, count,
|
||||
&lines_displayed, simulate);
|
||||
@@ -904,6 +895,13 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
|
||||
}
|
||||
}
|
||||
|
||||
if (marker_line && gui_chat_get_next_line_displayed (line))
|
||||
{
|
||||
gui_chat_display_horizontal_line (window, simulate);
|
||||
gui_chat_display_new_line (window, num_lines, count,
|
||||
&lines_displayed, simulate);
|
||||
}
|
||||
|
||||
if (simulate)
|
||||
{
|
||||
window->win_chat_cursor_x = x;
|
||||
@@ -940,9 +938,6 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line,
|
||||
}
|
||||
}
|
||||
|
||||
if (marker_line)
|
||||
lines_displayed++;
|
||||
|
||||
return lines_displayed;
|
||||
}
|
||||
|
||||
|
||||
@@ -633,7 +633,8 @@ gui_window_switch_to_buffer (struct t_gui_window *window,
|
||||
{
|
||||
window->start_line = NULL;
|
||||
window->start_line_pos = 0;
|
||||
window->buffer->last_read_line = window->buffer->last_line;
|
||||
if (window->buffer->num_displayed == 0)
|
||||
window->buffer->last_read_line = window->buffer->last_line;
|
||||
if (buffer->last_read_line == buffer->last_line)
|
||||
buffer->last_read_line = NULL;
|
||||
gui_previous_buffer = window->buffer;
|
||||
|
||||
@@ -652,8 +652,12 @@ gui_chat_line_has_highlight (struct t_gui_buffer *buffer,
|
||||
void
|
||||
gui_chat_line_free (struct t_gui_buffer *buffer, struct t_gui_line *line)
|
||||
{
|
||||
int update_prefix_max_length;
|
||||
struct t_gui_line *ptr_line;
|
||||
struct t_gui_window *ptr_win;
|
||||
|
||||
update_prefix_max_length = (line->prefix_length == buffer->prefix_max_length);
|
||||
|
||||
/* reset scroll for any window starting with this line */
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
@@ -689,6 +693,17 @@ gui_chat_line_free (struct t_gui_buffer *buffer, struct t_gui_line *line)
|
||||
free (line);
|
||||
|
||||
buffer->lines_count--;
|
||||
|
||||
if (update_prefix_max_length)
|
||||
{
|
||||
buffer->prefix_max_length = 0;
|
||||
for (ptr_line = buffer->lines; ptr_line;
|
||||
ptr_line = ptr_line->next_line)
|
||||
{
|
||||
if (ptr_line->prefix_length > buffer->prefix_max_length)
|
||||
buffer->prefix_max_length = ptr_line->prefix_length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -739,6 +754,7 @@ gui_chat_line_add (struct t_gui_buffer *buffer, time_t date,
|
||||
const char *prefix, const char *message)
|
||||
{
|
||||
struct t_gui_line *new_line;
|
||||
struct t_gui_window *ptr_win;
|
||||
|
||||
new_line = malloc (sizeof (*new_line));
|
||||
if (!new_line)
|
||||
@@ -811,6 +827,15 @@ gui_chat_line_add (struct t_gui_buffer *buffer, time_t date,
|
||||
&& (buffer->lines_count > CONFIG_INTEGER(config_history_max_lines)))
|
||||
{
|
||||
gui_chat_line_free (buffer, buffer->lines);
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
if ((ptr_win->buffer == buffer)
|
||||
&& (buffer->lines_count < ptr_win->win_chat_height))
|
||||
{
|
||||
gui_buffer_ask_chat_refresh (buffer, 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user