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

core: add option weechat.look.prefix_same_nick (hide or change prefix on messages whose nick is the same as previous message) (task #11965)

This commit is contained in:
Sebastien Helleu
2012-03-28 18:07:15 +02:00
parent 272046d012
commit 67115edf3d
22 changed files with 248 additions and 47 deletions
+49 -10
View File
@@ -136,6 +136,7 @@ struct t_config_option *config_look_prefix_align_more;
struct t_config_option *config_look_prefix_buffer_align;
struct t_config_option *config_look_prefix_buffer_align_max;
struct t_config_option *config_look_prefix_buffer_align_more;
struct t_config_option *config_look_prefix_same_nick;
struct t_config_option *config_look_prefix_suffix;
struct t_config_option *config_look_read_marker;
struct t_config_option *config_look_read_marker_always_show;
@@ -241,6 +242,7 @@ struct t_config_option *config_plugin_save_config_on_unload;
/* other */
int config_length_prefix_same_nick = 0;
struct t_hook *config_day_change_timer = NULL;
int config_day_change_old_day = -1;
regex_t *config_highlight_regex = NULL;
@@ -365,6 +367,44 @@ config_change_buffer_time_format (void *data, struct t_config_option *option)
gui_window_ask_refresh (1);
}
/*
* config_compute_prefix_max_length_all_buffers: compute the "prefix_max_length"
* on all buffers
*/
void
config_compute_prefix_max_length_all_buffers ()
{
struct t_gui_buffer *ptr_buffer;
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
if (ptr_buffer->own_lines)
gui_line_compute_prefix_max_length (ptr_buffer->own_lines);
if (ptr_buffer->mixed_lines)
gui_line_compute_prefix_max_length (ptr_buffer->mixed_lines);
}
}
/*
* config_change_prefix_same_nick: called when "prefix for same nick" changes
*/
void
config_change_prefix_same_nick (void *data, struct t_config_option *option)
{
/* make C compiler happy */
(void) data;
(void) option;
config_length_prefix_same_nick =
gui_chat_strlen_screen (CONFIG_STRING(config_look_prefix_same_nick));
config_compute_prefix_max_length_all_buffers ();
gui_window_ask_refresh (1);
}
/*
* config_change_eat_newline_glitch: called when eat_newline_glitch changes
*/
@@ -516,20 +556,11 @@ config_change_prefix (void *data, struct t_config_option *option)
void
config_change_prefix_align_min (void *data, struct t_config_option *option)
{
struct t_gui_buffer *ptr_buffer;
/* make C compiler happy */
(void) data;
(void) option;
for (ptr_buffer = gui_buffers; ptr_buffer;
ptr_buffer = ptr_buffer->next_buffer)
{
if (ptr_buffer->own_lines)
gui_line_compute_prefix_max_length (ptr_buffer->own_lines);
if (ptr_buffer->mixed_lines)
gui_line_compute_prefix_max_length (ptr_buffer->mixed_lines);
}
config_compute_prefix_max_length_all_buffers ();
gui_window_ask_refresh (1);
}
@@ -2059,6 +2090,14 @@ config_weechat_init_options ()
N_("display '+' if buffer name is truncated (when many buffers are "
"merged with same number)"),
NULL, 0, 0, "on", NULL, 0, NULL, NULL, &config_change_buffers, NULL, NULL, NULL);
config_look_prefix_same_nick = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_same_nick", "string",
N_("prefix displayed for a message with same nick as previous "
"message: use a space \" \" to hide prefix, another string to "
"display this string instead of prefix, or an empty string to "
"disable feature (display prefix)"),
NULL, 0, 0, "", NULL, 0, NULL, NULL, &config_change_prefix_same_nick, NULL, NULL, NULL);
config_look_prefix_suffix = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_suffix", "string",
+2
View File
@@ -160,6 +160,7 @@ extern struct t_config_option *config_look_prefix_align_more;
extern struct t_config_option *config_look_prefix_buffer_align;
extern struct t_config_option *config_look_prefix_buffer_align_max;
extern struct t_config_option *config_look_prefix_buffer_align_more;
extern struct t_config_option *config_look_prefix_same_nick;
extern struct t_config_option *config_look_prefix_suffix;
extern struct t_config_option *config_look_read_marker;
extern struct t_config_option *config_look_read_marker_always_show;
@@ -253,6 +254,7 @@ extern struct t_config_option *config_plugin_extension;
extern struct t_config_option *config_plugin_path;
extern struct t_config_option *config_plugin_save_config_on_unload;
extern int config_length_prefix_same_nick;
extern regex_t *config_highlight_regex;
extern char **config_highlight_tags;
extern int config_num_highlight_tags;