diff --git a/ChangeLog b/ChangeLog index 24ac41d81..af243639d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,12 +1,14 @@ WeeChat ChangeLog ================= Sébastien Helleu -v0.3.8-dev, 2012-03-26 +v0.3.8-dev, 2012-03-28 Version 0.3.8 (under dev!) -------------------------- +* core: add option weechat.look.prefix_same_nick (hide or change prefix on + messages whose nick is the same as previous message) (task #11965) * core: convert tabs to spaces in text pasted (bug #25028) * core: add a connection timeout for child process in hook_connect (bug #35966) * core: follow symbolic links when writing configuration files (.conf) diff --git a/doc/de/autogen/user/weechat_options.txt b/doc/de/autogen/user/weechat_options.txt index ed2e27b12..a67bb7b29 100644 --- a/doc/de/autogen/user/weechat_options.txt +++ b/doc/de/autogen/user/weechat_options.txt @@ -653,6 +653,11 @@ ** Typ: Zeichenkette ** Werte: beliebige Zeichenkette (Standardwert: `"<--"`) +* [[option_weechat.look.prefix_same_nick]] *weechat.look.prefix_same_nick* +** Beschreibung: `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)` +** Typ: Zeichenkette +** Werte: beliebige Zeichenkette (Standardwert: `""`) + * [[option_weechat.look.prefix_suffix]] *weechat.look.prefix_suffix* ** Beschreibung: `Nach dem Präfix anzufügende Zeichenfolge` ** Typ: Zeichenkette diff --git a/doc/en/autogen/user/weechat_options.txt b/doc/en/autogen/user/weechat_options.txt index ccc52e773..ed3748358 100644 --- a/doc/en/autogen/user/weechat_options.txt +++ b/doc/en/autogen/user/weechat_options.txt @@ -653,6 +653,11 @@ ** type: string ** values: any string (default value: `"<--"`) +* [[option_weechat.look.prefix_same_nick]] *weechat.look.prefix_same_nick* +** description: `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)` +** type: string +** values: any string (default value: `""`) + * [[option_weechat.look.prefix_suffix]] *weechat.look.prefix_suffix* ** description: `string displayed after prefix` ** type: string diff --git a/doc/fr/autogen/user/weechat_options.txt b/doc/fr/autogen/user/weechat_options.txt index 082c2ad3e..12fc20b03 100644 --- a/doc/fr/autogen/user/weechat_options.txt +++ b/doc/fr/autogen/user/weechat_options.txt @@ -653,6 +653,11 @@ ** type: chaîne ** valeurs: toute chaîne (valeur par défaut: `"<--"`) +* [[option_weechat.look.prefix_same_nick]] *weechat.look.prefix_same_nick* +** description: `préfixe affiché pour un message avec le même pseudo que le précédent message: utiliser un espace " " pour cacher le préfixe, une autre chaîne pour l'afficher à la place du préfixe, ou une chaîne vide pour désactiver cette fonctionnalité (afficher le préfixe)` +** type: chaîne +** valeurs: toute chaîne (valeur par défaut: `""`) + * [[option_weechat.look.prefix_suffix]] *weechat.look.prefix_suffix* ** description: `chaîne affichée après le préfixe` ** type: chaîne diff --git a/doc/it/autogen/user/weechat_options.txt b/doc/it/autogen/user/weechat_options.txt index 2e58e0046..2566dcb2c 100644 --- a/doc/it/autogen/user/weechat_options.txt +++ b/doc/it/autogen/user/weechat_options.txt @@ -653,6 +653,11 @@ ** tipo: stringa ** valori: qualsiasi stringa (valore predefinito: `"<--"`) +* [[option_weechat.look.prefix_same_nick]] *weechat.look.prefix_same_nick* +** descrizione: `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)` +** tipo: stringa +** valori: qualsiasi stringa (valore predefinito: `""`) + * [[option_weechat.look.prefix_suffix]] *weechat.look.prefix_suffix* ** descrizione: `stringa visualizzata dopo il prefisso` ** tipo: stringa diff --git a/po/cs.po b/po/cs.po index f83f71a30..ead6c25db 100644 --- a/po/cs.po +++ b/po/cs.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.8-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-03-26 13:41+0200\n" +"POT-Creation-Date: 2012-03-28 15:03+0200\n" "PO-Revision-Date: 2012-02-26 09:16+0100\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -2580,6 +2580,12 @@ msgstr "" "zobrazit '+' pokud je jméno bufferu zkráceno (při spojení vice bufferů se " "stejným číslem)" +msgid "" +"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)" +msgstr "" + msgid "string displayed after prefix" msgstr "řetězec zobrazený za prefixem" diff --git a/po/de.po b/po/de.po index 4ef7d7a0a..dda79525e 100644 --- a/po/de.po +++ b/po/de.po @@ -23,7 +23,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-03-26 13:41+0200\n" +"POT-Creation-Date: 2012-03-28 15:03+0200\n" "PO-Revision-Date: 2012-03-13 16:36+0100\n" "Last-Translator: Nils Görs \n" "Language-Team: German \n" @@ -2834,6 +2834,12 @@ msgstr "" "Stellt das Symbol '+' dar falls der Buffername gekürzt wurde (wenn mehrere " "Buffer zusammengefügt wurden und diese somit die selbe Nummer besitzen)" +msgid "" +"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)" +msgstr "" + msgid "string displayed after prefix" msgstr "Nach dem Präfix anzufügende Zeichenfolge" diff --git a/po/es.po b/po/es.po index e1e500f42..8c0cb00ff 100644 --- a/po/es.po +++ b/po/es.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.8-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-03-26 13:41+0200\n" +"POT-Creation-Date: 2012-03-28 15:03+0200\n" "PO-Revision-Date: 2012-02-26 09:16+0100\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -2721,6 +2721,12 @@ msgstr "" "muestra '+' si el nombre es truncado (cuando varios buffers están fusionados " "con el mismo número)" +msgid "" +"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)" +msgstr "" + msgid "string displayed after prefix" msgstr "cadena mostrada después del prefijo" diff --git a/po/fr.po b/po/fr.po index 48a3f6684..0111dcc0f 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.8-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-03-26 13:41+0200\n" -"PO-Revision-Date: 2012-03-26 09:16+0200\n" +"POT-Creation-Date: 2012-03-28 15:03+0200\n" +"PO-Revision-Date: 2012-03-28 15:03+0200\n" "Last-Translator: Sebastien Helleu \n" "Language-Team: weechat-dev \n" "Language: French\n" @@ -2738,6 +2738,16 @@ msgstr "" "afficher '+' si le nom du tampon est tronqué (quand plusieurs tampons sont " "mélangés avec le même numéro)" +msgid "" +"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)" +msgstr "" +"préfixe affiché pour un message avec le même pseudo que le précédent " +"message: utiliser un espace \" \" pour cacher le préfixe, une autre chaîne " +"pour l'afficher à la place du préfixe, ou une chaîne vide pour désactiver " +"cette fonctionnalité (afficher le préfixe)" + msgid "string displayed after prefix" msgstr "chaîne affichée après le préfixe" diff --git a/po/hu.po b/po/hu.po index 330367139..88b48f79a 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.8-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-03-26 13:41+0200\n" +"POT-Creation-Date: 2012-03-28 15:03+0200\n" "PO-Revision-Date: 2012-02-26 09:16+0100\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -2220,6 +2220,12 @@ msgid "" "same number)" msgstr "" +msgid "" +"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)" +msgstr "" + #, fuzzy msgid "string displayed after prefix" msgstr "névkiegészítés után beszúrt szöveg" diff --git a/po/it.po b/po/it.po index 5008d088c..47f9a8334 100644 --- a/po/it.po +++ b/po/it.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.8-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-03-26 13:41+0200\n" +"POT-Creation-Date: 2012-03-28 15:03+0200\n" "PO-Revision-Date: 2012-02-26 09:16+0100\n" "Last-Translator: Marco Paolone \n" "Language-Team: weechat-dev \n" @@ -2712,6 +2712,12 @@ msgstr "" "visualizza '+' se il nome del buffer è troncato (quando più buffer sono " "uniti con lo stesso numero)" +msgid "" +"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)" +msgstr "" + msgid "string displayed after prefix" msgstr "stringa visualizzata dopo il prefisso" diff --git a/po/ja.po b/po/ja.po index 8189c2577..4b595af62 100644 --- a/po/ja.po +++ b/po/ja.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.8-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-03-26 13:41+0200\n" +"POT-Creation-Date: 2012-03-28 15:03+0200\n" "PO-Revision-Date: 2012-02-26 09:16+0100\n" "Last-Translator: \"AYANOKOUZI, Ryuunosuke\" \n" "Language-Team: Japanese\n" @@ -2659,6 +2659,12 @@ msgstr "" "バッファ名が切り詰められた場合は '+' を表示 (多くのバッファが同じ番号を持つよ" "うにマージされた場合)" +msgid "" +"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)" +msgstr "" + msgid "string displayed after prefix" msgstr "プレフィックスの後ろに表示される文字列" diff --git a/po/pl.po b/po/pl.po index 1aa28b468..81f7cef28 100644 --- a/po/pl.po +++ b/po/pl.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.8-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-03-26 13:41+0200\n" +"POT-Creation-Date: 2012-03-28 15:03+0200\n" "PO-Revision-Date: 2012-02-26 09:16+0100\n" "Last-Translator: Krzysztof Korościk \n" "Language-Team: weechat-dev \n" @@ -2719,6 +2719,12 @@ msgstr "" "wyświetl '+' jeśli nazwa bufora została obcięta (kiedy wiele buforów jest " "scalonych z takim samym numerem)" +msgid "" +"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)" +msgstr "" + msgid "string displayed after prefix" msgstr "ciąg wyświetlany po przedrostku" diff --git a/po/pt_BR.po b/po/pt_BR.po index 75795a666..708987d51 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.8-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-03-26 13:41+0200\n" +"POT-Creation-Date: 2012-03-28 15:03+0200\n" "PO-Revision-Date: 2012-02-26 09:16+0100\n" "Last-Translator: Sergio Durigan Junior \n" "Language-Team: weechat-dev \n" @@ -2661,6 +2661,12 @@ msgstr "" "mostra '+' se o nome do buffer está truncado (quando muitos buffers estão " "mesclados com o mesmo número)" +msgid "" +"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)" +msgstr "" + # Find a better translation to "string" #, fuzzy msgid "string displayed after prefix" diff --git a/po/ru.po b/po/ru.po index b3fb3c78e..ae097944b 100644 --- a/po/ru.po +++ b/po/ru.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.8-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-03-26 13:41+0200\n" +"POT-Creation-Date: 2012-03-28 15:03+0200\n" "PO-Revision-Date: 2012-02-26 09:16+0100\n" "Last-Translator: Aleksey V Zapparov AKA ixti \n" "Language-Team: weechat-dev \n" @@ -2248,6 +2248,12 @@ msgid "" "same number)" msgstr "" +msgid "" +"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)" +msgstr "" + #, fuzzy msgid "string displayed after prefix" msgstr "строка, вставляемая после автодополнения ника" diff --git a/po/weechat.pot b/po/weechat.pot index 4fa7e5c6c..e0fa5e684 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2012-03-26 13:41+0200\n" +"POT-Creation-Date: 2012-03-28 15:03+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1959,6 +1959,12 @@ msgid "" "same number)" msgstr "" +msgid "" +"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)" +msgstr "" + msgid "string displayed after prefix" msgstr "" diff --git a/src/core/wee-config.c b/src/core/wee-config.c index 8d6970f21..08e126da7 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -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", diff --git a/src/core/wee-config.h b/src/core/wee-config.h index c08dfb1f0..a38b19255 100644 --- a/src/core/wee-config.h +++ b/src/core/wee-config.h @@ -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; diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c index 50a9881a1..37560cb06 100644 --- a/src/gui/curses/gui-curses-chat.c +++ b/src/gui/curses/gui-curses-chat.c @@ -559,9 +559,9 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, int simulate) { char str_space[] = " ", str_plus[] = "+"; - char *prefix_no_color, *prefix_highlighted; + char *prefix_no_color, *prefix_highlighted, *ptr_prefix; const char *short_name; - int i, length, length_allowed, num_spaces; + int i, length, length_allowed, num_spaces, prefix_length; struct t_gui_lines *mixed_lines; if (!simulate) @@ -722,8 +722,9 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, } /* display prefix */ - if (line->data->prefix - && (line->data->prefix[0] + gui_line_get_prefix_for_display (line, &ptr_prefix, &prefix_length); + if (ptr_prefix + && (ptr_prefix[0] || (CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE))) { if (!simulate) @@ -743,7 +744,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, else length_allowed = window->buffer->lines->prefix_max_length; - num_spaces = length_allowed - line->data->prefix_length; + num_spaces = length_allowed - prefix_length; if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_RIGHT) { @@ -759,7 +760,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, prefix_highlighted = NULL; if (line->data->highlight) { - prefix_no_color = gui_color_decode (line->data->prefix, NULL); + prefix_no_color = gui_color_decode (ptr_prefix, NULL); if (prefix_no_color) { length = strlen (prefix_no_color) + 32; @@ -807,12 +808,12 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, && (num_spaces < 0)) { gui_chat_display_word (window, line, - (prefix_highlighted) ? prefix_highlighted : line->data->prefix, + (prefix_highlighted) ? prefix_highlighted : ptr_prefix, (prefix_highlighted) ? prefix_highlighted + gui_chat_string_real_pos (prefix_highlighted, length_allowed) : - line->data->prefix + gui_chat_string_real_pos (line->data->prefix, - length_allowed), + ptr_prefix + gui_chat_string_real_pos (ptr_prefix, + length_allowed), 1, num_lines, count, lines_displayed, simulate, CONFIG_BOOLEAN(config_look_color_inactive_prefix)); @@ -820,7 +821,7 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, else { gui_chat_display_word (window, line, - (prefix_highlighted) ? prefix_highlighted : line->data->prefix, + (prefix_highlighted) ? prefix_highlighted : ptr_prefix, NULL, 1, num_lines, count, lines_displayed, simulate, CONFIG_BOOLEAN(config_look_color_inactive_prefix)); diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index 4b7ea0d9e..1e1ee32a8 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -3364,8 +3364,11 @@ gui_buffer_dump_hexa (struct t_gui_buffer *buffer) free (message_without_colors); tags = string_build_with_split_string ((const char **)ptr_line->data->tags_array, ","); - log_printf (" tags: %s, highlight: %d", - (tags) ? tags : "(none)", ptr_line->data->highlight); + log_printf (" tags: %s, displayed: %d, highlight: %d, prefix_same_nick: %d", + (tags) ? tags : "(none)", + ptr_line->data->displayed, + ptr_line->data->highlight, + ptr_line->data->prefix_same_nick); if (tags) free (tags); snprintf (buf, sizeof (buf), "%s", ctime (&ptr_line->data->date)); @@ -3551,11 +3554,13 @@ gui_buffer_print_log () tags = string_build_with_split_string ((const char **)ptr_line->data->tags_array, ","); log_printf (" line N-%05d: y:%d, str_time:'%s', tags:'%s', " - "displayed:%d, highlight:%d, refresh_needed:%d, prefix:'%s'", + "displayed:%d, highlight:%d, prefix_same_nick:%d, " + "refresh_needed:%d, prefix:'%s'", num, ptr_line->data->y, ptr_line->data->str_time, (tags) ? tags : "", (int)(ptr_line->data->displayed), (int)(ptr_line->data->highlight), + (int)(ptr_line->data->prefix_same_nick), (int)(ptr_line->data->refresh_needed), ptr_line->data->prefix); log_printf (" data: '%s'", diff --git a/src/gui/gui-line.c b/src/gui/gui-line.c index c4fab0c7b..47deef906 100644 --- a/src/gui/gui-line.c +++ b/src/gui/gui-line.c @@ -83,6 +83,43 @@ gui_lines_free (struct t_gui_lines *lines) free (lines); } +/* + * gui_line_get_prefix_for_display: get prefix and its length (for display only) + * if the prefix can be hidden (same nick as + * previous message), and if the option is + * enabled (not empty string), then this + * this function will return empty prefix or + * prefix from option + */ + +void +gui_line_get_prefix_for_display (struct t_gui_line *line, + char **prefix, int *length) +{ + if (line->data->prefix_same_nick + && CONFIG_STRING(config_look_prefix_same_nick) + && CONFIG_STRING(config_look_prefix_same_nick)[0]) + { + /* same nick: return empty prefix or value from option */ + if (strcmp (CONFIG_STRING(config_look_prefix_same_nick), " ") == 0) + { + *prefix = gui_chat_prefix_empty; + *length = 0; + } + else + { + *prefix = CONFIG_STRING(config_look_prefix_same_nick); + *length = config_length_prefix_same_nick; + } + } + else + { + /* not same nick: return prefix from line */ + *prefix = line->data->prefix; + *length = line->data->prefix_length; + } +} + /* * gui_line_get_align: get alignment for a line */ @@ -91,7 +128,8 @@ int gui_line_get_align (struct t_gui_buffer *buffer, struct t_gui_line *line, int with_suffix, int first_line) { - int length_time, length_buffer, length_suffix; + int length_time, length_buffer, length_suffix, prefix_length; + char *ptr_prefix; /* return immediately if alignment for end of lines is "time" */ if (!first_line @@ -141,10 +179,11 @@ gui_line_get_align (struct t_gui_buffer *buffer, struct t_gui_line *line, return length_time + length_buffer; } + gui_line_get_prefix_for_display (line, &ptr_prefix, &prefix_length); + if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_NONE) { - return length_time + length_buffer + line->data->prefix_length - + ((line->data->prefix_length > 0) ? 1 : 0); + return length_time + length_buffer + prefix_length + ((prefix_length > 0) ? 1 : 0); } length_suffix = 0; @@ -533,13 +572,16 @@ void gui_line_compute_prefix_max_length (struct t_gui_lines *lines) { struct t_gui_line *ptr_line; + char *ptr_prefix; + 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) { - if (ptr_line->data->prefix_length > lines->prefix_max_length) - lines->prefix_max_length = ptr_line->data->prefix_length; + gui_line_get_prefix_for_display (ptr_line, &ptr_prefix, &prefix_length); + if (prefix_length > lines->prefix_max_length) + lines->prefix_max_length = prefix_length; } } @@ -551,6 +593,9 @@ void gui_line_add_to_list (struct t_gui_lines *lines, struct t_gui_line *line) { + char *ptr_prefix; + int prefix_length; + if (!lines->first_line) lines->first_line = line; else @@ -559,8 +604,9 @@ gui_line_add_to_list (struct t_gui_lines *lines, line->next_line = NULL; lines->last_line = line; - if (line->data->prefix_length > lines->prefix_max_length) - lines->prefix_max_length = line->data->prefix_length; + gui_line_get_prefix_for_display (line, &ptr_prefix, &prefix_length); + if (prefix_length > lines->prefix_max_length) + lines->prefix_max_length = prefix_length; lines->lines_count++; } @@ -577,7 +623,8 @@ gui_line_remove_from_list (struct t_gui_buffer *buffer, { struct t_gui_window *ptr_win; struct t_gui_window_scroll *ptr_scroll; - int i, update_prefix_max_length; + int i, update_prefix_max_length, prefix_length; + char *ptr_prefix; for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) { @@ -603,8 +650,9 @@ gui_line_remove_from_list (struct t_gui_buffer *buffer, } } + gui_line_get_prefix_for_display (line, &ptr_prefix, &prefix_length); update_prefix_max_length = - (line->data->prefix_length == lines->prefix_max_length); + (prefix_length == lines->prefix_max_length); /* move read marker if it was on line we are removing */ if (lines->last_read_line == line) @@ -794,7 +842,7 @@ gui_line_add (struct t_gui_buffer *buffer, time_t date, struct t_gui_line_data *new_line_data; struct t_gui_window *ptr_win; char *message_for_signal; - const char *nick; + const char *nick, *nick_previous; int notify_level, *max_notify_level, lines_removed; time_t current_time; @@ -859,9 +907,17 @@ gui_line_add (struct t_gui_buffer *buffer, time_t date, gui_chat_strlen_screen (prefix) : 0; new_line->data->message = (message) ? strdup (message) : strdup (""); + /* + * check if prefix can be hidden: if nick is the same as previous message + * on this buffer + */ + nick = gui_line_get_nick_tag (new_line); + nick_previous = (buffer->own_lines->last_line) ? + gui_line_get_nick_tag (buffer->own_lines->last_line) : NULL; + new_line->data->prefix_same_nick = (nick && nick_previous && (strcmp (nick, nick_previous) == 0)) ? 1 : 0; + /* get notify level and max notify level for nick in buffer */ notify_level = gui_line_get_notify_level (new_line); - nick = gui_line_get_nick_tag (new_line); max_notify_level = NULL; if (nick) max_notify_level = hashtable_get (buffer->hotlist_max_level_nicks, nick); @@ -1313,6 +1369,8 @@ gui_line_add_to_infolist (struct t_infolist *infolist, return 0; if (!infolist_new_var_integer (ptr_item, "highlight", line->data->highlight)) return 0; + if (!infolist_new_var_integer (ptr_item, "prefix_same_nick", line->data->prefix_same_nick)) + return 0; if (!infolist_new_var_string (ptr_item, "prefix", line->data->prefix)) return 0; if (!infolist_new_var_string (ptr_item, "message", line->data->message)) diff --git a/src/gui/gui-line.h b/src/gui/gui-line.h index b4a745887..8c1d49253 100644 --- a/src/gui/gui-line.h +++ b/src/gui/gui-line.h @@ -37,6 +37,8 @@ struct t_gui_line_data char **tags_array; /* tags for line */ char displayed; /* 1 if line is displayed */ char highlight; /* 1 if line has highlight */ + char prefix_same_nick; /* 1 if prefix can be hidden */ + /* (same nick as previous message) */ char refresh_needed; /* 1 if refresh asked (free buffer) */ char *prefix; /* prefix for line (may be NULL) */ int prefix_length; /* prefix length (on screen) */ @@ -67,6 +69,8 @@ struct t_gui_lines extern struct t_gui_lines *gui_lines_alloc (); extern void gui_lines_free (struct t_gui_lines *lines); +extern void gui_line_get_prefix_for_display (struct t_gui_line *line, + char **prefix, int *length); extern int gui_line_get_align (struct t_gui_buffer *buffer, struct t_gui_line *line, int with_suffix, int first_line);