core: fix refresh of line after changes with hdata_update (update flag "displayed" according to filters)

This commit is contained in:
Sebastien Helleu 2013-02-04 08:29:57 +01:00
parent 95687e8057
commit 1cdbc27abf
5 changed files with 88 additions and 67 deletions

View File

@ -1,12 +1,14 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
v0.4.1-dev, 2013-02-03
v0.4.1-dev, 2013-02-04
Version 0.4.1 (under dev!)
--------------------------
* core: fix refresh of line after changes with hdata_update (update flag
"displayed" according to filters)
* core: fix detection of python on Ubuntu Raring
* core: fix hidden lines for messages without date when option
weechat.history.max_buffer_lines_minutes is set (bug #38197)

View File

@ -57,13 +57,13 @@ int gui_filters_enabled = 1; /* filters enabled? */
*/
int
gui_filter_line_has_tag_no_filter (struct t_gui_line *line)
gui_filter_line_has_tag_no_filter (struct t_gui_line_data *line_data)
{
int i;
for (i = 0; i < line->data->tags_count; i++)
for (i = 0; i < line_data->tags_count; i++)
{
if (strcmp (line->data->tags_array[i], GUI_FILTER_TAG_NO_FILTER) == 0)
if (strcmp (line_data->tags_array[i], GUI_FILTER_TAG_NO_FILTER) == 0)
return 1;
}
@ -80,7 +80,7 @@ gui_filter_line_has_tag_no_filter (struct t_gui_line *line)
*/
int
gui_filter_check_line (struct t_gui_line *line)
gui_filter_check_line (struct t_gui_line_data *line_data)
{
struct t_gui_filter *ptr_filter;
int rc;
@ -89,7 +89,7 @@ gui_filter_check_line (struct t_gui_line *line)
if (!gui_filters_enabled)
return 1;
if (gui_filter_line_has_tag_no_filter (line))
if (gui_filter_line_has_tag_no_filter (line_data))
return 1;
for (ptr_filter = gui_filters; ptr_filter;
@ -98,12 +98,12 @@ gui_filter_check_line (struct t_gui_line *line)
if (ptr_filter->enabled)
{
/* check buffer */
if (gui_buffer_match_list_split (line->data->buffer,
if (gui_buffer_match_list_split (line_data->buffer,
ptr_filter->num_buffers,
ptr_filter->buffers))
{
if ((strcmp (ptr_filter->tags, "*") == 0)
|| (gui_line_match_tags (line,
|| (gui_line_match_tags (line_data,
ptr_filter->tags_count,
ptr_filter->tags_array)))
{
@ -111,7 +111,7 @@ gui_filter_check_line (struct t_gui_line *line)
rc = 1;
if (!ptr_filter->regex_prefix && !ptr_filter->regex_message)
rc = 0;
if (gui_line_match_regex (line,
if (gui_line_match_regex (line_data,
ptr_filter->regex_prefix,
ptr_filter->regex_message))
{
@ -132,44 +132,56 @@ gui_filter_check_line (struct t_gui_line *line)
/*
* Filters a buffer, using message filters.
*
* If line_data is NULL, filters all lines in buffer.
* If line_data is not NULL, filters only this line_data.
*/
void
gui_filter_buffer (struct t_gui_buffer *buffer)
gui_filter_buffer (struct t_gui_buffer *buffer,
struct t_gui_line_data *line_data)
{
struct t_gui_line *ptr_line;
struct t_gui_line_data *ptr_line_data;
struct t_gui_window *ptr_window;
int lines_changed, line_displayed, lines_hidden;
lines_changed = 0;
lines_hidden = 0;
lines_hidden = buffer->lines->lines_hidden;
buffer->lines->prefix_max_length = CONFIG_INTEGER(config_look_prefix_align_min);
if (!line_data)
buffer->lines->prefix_max_length = CONFIG_INTEGER(config_look_prefix_align_min);
for (ptr_line = buffer->lines->first_line; ptr_line;
ptr_line = ptr_line->next_line)
ptr_line = buffer->lines->first_line;
while (ptr_line || line_data)
{
line_displayed = gui_filter_check_line (ptr_line);
ptr_line_data = (line_data) ? line_data : ptr_line->data;
line_displayed = gui_filter_check_line (ptr_line_data);
if (line_displayed
&& (ptr_line->data->prefix_length > buffer->lines->prefix_max_length))
&& (ptr_line_data->prefix_length > buffer->lines->prefix_max_length))
{
buffer->lines->prefix_max_length = ptr_line->data->prefix_length;
buffer->lines->prefix_max_length = ptr_line_data->prefix_length;
}
/* force chat refresh if at least one line changed */
if (ptr_line->data->displayed != line_displayed)
if (ptr_line_data->displayed != line_displayed)
{
gui_buffer_ask_chat_refresh (buffer, 2);
lines_changed = 1;
lines_hidden += (line_displayed) ? -1 : 1;
}
ptr_line->data->displayed = line_displayed;
ptr_line_data->displayed = line_displayed;
if (!line_displayed)
lines_hidden = 1;
if (line_data)
break;
ptr_line = ptr_line->next_line;
}
if (line_data)
gui_line_compute_prefix_max_length (line_data->buffer->lines);
if (buffer->lines->lines_hidden != lines_hidden)
{
buffer->lines->lines_hidden = lines_hidden;
@ -177,13 +189,16 @@ gui_filter_buffer (struct t_gui_buffer *buffer)
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
}
/*
* if status of at least one line has changed, check that a scroll in a
* window displaying this buffer is not on a hidden line (if this happens,
* use the previous displayed line as scroll)
*/
if (lines_changed)
{
/* force a full refresh of buffer */
gui_buffer_ask_chat_refresh (buffer, 2);
/*
* check that a scroll in a window displaying this buffer is not on a
* hidden line (if this happens, use the previous displayed line as
* scroll)
*/
for (ptr_window = gui_windows; ptr_window;
ptr_window = ptr_window->next_window)
{
@ -211,7 +226,7 @@ gui_filter_all_buffers ()
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
gui_filter_buffer (ptr_buffer);
gui_filter_buffer (ptr_buffer, NULL);
}
}

View File

@ -26,7 +26,7 @@
/* filter structures */
struct t_gui_line;
struct t_gui_line_data;
struct t_gui_filter
{
@ -53,7 +53,9 @@ extern int gui_filters_enabled;
/* filter functions */
extern int gui_filter_check_line (struct t_gui_line *line);
extern int gui_filter_check_line (struct t_gui_line_data *line_data);
extern void gui_filter_buffer (struct t_gui_buffer *buffer,
struct t_gui_line_data *line_data);
extern void gui_filter_all_buffers ();
extern void gui_filter_global_enable ();
extern void gui_filter_global_disable ();

View File

@ -431,13 +431,13 @@ gui_line_search_text (struct t_gui_line *line, const char *text,
*/
int
gui_line_match_regex (struct t_gui_line *line, regex_t *regex_prefix,
gui_line_match_regex (struct t_gui_line_data *line_data, regex_t *regex_prefix,
regex_t *regex_message)
{
char *prefix, *message;
int match_prefix, match_message;
if (!line || (!regex_prefix && !regex_message))
if (!line_data || (!regex_prefix && !regex_message))
return 0;
prefix = NULL;
@ -446,9 +446,9 @@ gui_line_match_regex (struct t_gui_line *line, regex_t *regex_prefix,
match_prefix = 1;
match_message = 1;
if (line->data->prefix)
if (line_data->prefix)
{
prefix = gui_color_decode (line->data->prefix, NULL);
prefix = gui_color_decode (line_data->prefix, NULL);
if (!prefix
|| (regex_prefix && (regexec (regex_prefix, prefix, 0, NULL, 0) != 0)))
match_prefix = 0;
@ -459,9 +459,9 @@ gui_line_match_regex (struct t_gui_line *line, regex_t *regex_prefix,
match_prefix = 0;
}
if (line->data->message)
if (line_data->message)
{
message = gui_color_decode (line->data->message, NULL);
message = gui_color_decode (line_data->message, NULL);
if (!message
|| (regex_message && (regexec (regex_message, message, 0, NULL, 0) != 0)))
match_message = 0;
@ -489,23 +489,23 @@ gui_line_match_regex (struct t_gui_line *line, regex_t *regex_prefix,
*/
int
gui_line_match_tags (struct t_gui_line *line, int tags_count,
char **tags_array)
gui_line_match_tags (struct t_gui_line_data *line_data,
int tags_count, char **tags_array)
{
int i, j;
if (!line)
if (!line_data)
return 0;
if (line->data->tags_count == 0)
if (line_data->tags_count == 0)
return 0;
for (i = 0; i < tags_count; i++)
{
for (j = 0; j < line->data->tags_count; j++)
for (j = 0; j < line_data->tags_count; j++)
{
/* check tag */
if (string_match (line->data->tags_array[j],
if (string_match (line_data->tags_array[j],
tags_array[i],
0))
return 1;
@ -606,7 +606,7 @@ gui_line_has_highlight (struct t_gui_line *line)
*/
if (line->data->buffer->highlight_tags_count > 0)
{
if (!gui_line_match_tags (line,
if (!gui_line_match_tags (line->data,
line->data->buffer->highlight_tags_count,
line->data->buffer->highlight_tags_array))
return 0;
@ -723,12 +723,16 @@ gui_line_compute_prefix_max_length (struct t_gui_lines *lines)
int prefix_length;
lines->prefix_max_length = CONFIG_INTEGER(config_look_prefix_align_min);
for (ptr_line = lines->first_line; ptr_line;
ptr_line = ptr_line->next_line)
{
gui_line_get_prefix_for_display (ptr_line, NULL, &prefix_length, NULL);
if (prefix_length > lines->prefix_max_length)
lines->prefix_max_length = prefix_length;
if (ptr_line->data->displayed)
{
gui_line_get_prefix_for_display (ptr_line, NULL, &prefix_length, NULL);
if (prefix_length > lines->prefix_max_length)
lines->prefix_max_length = prefix_length;
}
}
}
@ -1071,7 +1075,7 @@ gui_line_add (struct t_gui_buffer *buffer, time_t date,
new_line->data->highlight = gui_line_has_highlight (new_line);
/* check if line is filtered or not */
new_line->data->displayed = gui_filter_check_line (new_line);
new_line->data->displayed = gui_filter_check_line (new_line->data);
/* add line to lines list */
gui_line_add_to_list (buffer->own_lines, new_line);
@ -1113,14 +1117,11 @@ gui_line_add (struct t_gui_buffer *buffer, time_t date,
}
else
{
if (!buffer->own_lines->lines_hidden)
{
buffer->own_lines->lines_hidden = 1;
if (buffer->mixed_lines)
buffer->mixed_lines->lines_hidden = 1;
hook_signal_send ("buffer_lines_hidden",
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
}
buffer->own_lines->lines_hidden++;
if (buffer->mixed_lines)
buffer->mixed_lines->lines_hidden++;
hook_signal_send ("buffer_lines_hidden",
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
}
/* add mixed line, if buffer is attched to at least one other buffer */
@ -1238,15 +1239,12 @@ gui_line_add_y (struct t_gui_buffer *buffer, int y, const char *message)
ptr_line->data->message = (message) ? strdup (message) : strdup ("");
/* check if line is filtered or not */
ptr_line->data->displayed = gui_filter_check_line (ptr_line);
ptr_line->data->displayed = gui_filter_check_line (ptr_line->data);
if (!ptr_line->data->displayed)
{
if (!buffer->own_lines->lines_hidden)
{
buffer->own_lines->lines_hidden = 1;
hook_signal_send ("buffer_lines_hidden",
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
}
buffer->own_lines->lines_hidden++;
hook_signal_send ("buffer_lines_hidden",
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
}
ptr_line->data->refresh_needed = 1;
@ -1492,7 +1490,11 @@ gui_line_hdata_line_data_update_cb (void *data,
rc++;
}
gui_buffer_ask_chat_refresh (line_data->buffer, 1);
if (rc > 0)
{
gui_filter_buffer (line_data->buffer, line_data);
gui_buffer_ask_chat_refresh (line_data->buffer, 1);
}
return rc;
}

View File

@ -80,11 +80,11 @@ extern struct t_gui_line *gui_line_get_prev_displayed (struct t_gui_line *line);
extern struct t_gui_line *gui_line_get_next_displayed (struct t_gui_line *line);
extern int gui_line_search_text (struct t_gui_line *line, const char *text,
int case_sensitive);
extern int gui_line_match_regex (struct t_gui_line *line,
extern int gui_line_match_regex (struct t_gui_line_data *line_data,
regex_t *regex_prefix,
regex_t *regex_message);
extern int gui_line_match_tags (struct t_gui_line *line, int tags_count,
char **tags_array);
extern int gui_line_match_tags (struct t_gui_line_data *line_data,
int tags_count, char **tags_array);
extern const char *gui_line_search_tag_starting_with (struct t_gui_line *line,
const char *tag);
extern const char *gui_line_get_nick_tag (struct t_gui_line *line);