From 54468b8ef3d1b79e8cef6b77dd4892f7203723d9 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sat, 17 Jul 2010 10:21:25 +0200 Subject: [PATCH] Add new option irc.look.nick_color_stop_chars --- ChangeLog | 3 +- po/cs.po | 27 ++++++----- po/de.po | 27 ++++++----- po/es.po | 27 ++++++----- po/fr.po | 33 +++++++++----- po/hu.po | 25 +++++++---- po/it.po | 27 ++++++----- po/pl.po | 27 ++++++----- po/ru.po | 25 +++++++---- po/weechat.pot | 23 ++++++---- src/plugins/irc/irc-config.c | 81 ++++++++++++++++++++++++--------- src/plugins/irc/irc-config.h | 1 + src/plugins/irc/irc-nick.c | 87 ++++++++++++++++++++++++++++-------- 13 files changed, 285 insertions(+), 128 deletions(-) diff --git a/ChangeLog b/ChangeLog index 354587609..094a7ced5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,7 @@ WeeChat ChangeLog ================= Sébastien Helleu -v0.3.3-dev, 2010-07-16 +v0.3.3-dev, 2010-07-17 Version 0.3.3 (under dev!) @@ -24,6 +24,7 @@ Version 0.3.3 (under dev!) (bug #30296) * api: add function "string_expand_home", fix bug with replacement of home in paths +* irc: add new option irc.look.nick_color_stop_chars * irc: fix display of local SSL certificate when it is sent to server (patch #7218) * irc: improve lag indicator: two colors (counting and finished), update item diff --git a/po/cs.po b/po/cs.po index 05ac4f84f..761d32f65 100644 --- a/po/cs.po +++ b/po/cs.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.3-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-07-16 15:42+0200\n" +"POT-Creation-Date: 2010-07-17 10:15+0200\n" "PO-Revision-Date: 2010-06-20 21:24+0200\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -4515,6 +4515,22 @@ msgstr "" "výchozí cílový buffer pro volby msgbuffer, když je cíl soukromý a příslušný " "soukromý buffer není nalezen" +msgid "" +"chars used to stop in nick when computing color with letters of nick (at " +"least one char outside this list must be in string before stopping) " +"(example: nick \"_nick_away\" with \"_\" in chars will return color of nick " +"\"_nick\")" +msgstr "" + +msgid "" +"display notices as private messages (if auto, use private buffer if found)" +msgstr "" +"zobrazovat upozornění jako soukromé zprávy (pokud je automaticky, použije se " +"soukromý buffer, kdy existuje)" + +msgid "close buffer when /part is issued on a channel" +msgstr "zavřít buffer, když je na kanálu spuštěn /part" + msgid "" "number of IRC raw messages to save in memory when raw data buffer is closed " "(messages will be displayed when opening raw data buffer)" @@ -4538,15 +4554,6 @@ msgstr "povolit chytrý filter pro \"join\" zprávy" msgid "enable smart filter for \"part\" and \"quit\" messages" msgstr "povolit chytrý filter pro \"part\" a \"quit\" zprávy" -msgid "" -"display notices as private messages (if auto, use private buffer if found)" -msgstr "" -"zobrazovat upozornění jako soukromé zprávy (pokud je automaticky, použije se " -"soukromý buffer, kdy existuje)" - -msgid "close buffer when /part is issued on a channel" -msgstr "zavřít buffer, když je na kanálu spuštěn /part" - msgid "strip colors in topic (used only when displaying buffer title)" msgstr "" "ořezávat barvy z tématu rozhovoru (použito pouze při zobrazování titulku " diff --git a/po/de.po b/po/de.po index 500f2a622..b5b7d05e0 100644 --- a/po/de.po +++ b/po/de.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.3-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-07-16 15:42+0200\n" +"POT-Creation-Date: 2010-07-17 10:15+0200\n" "PO-Revision-Date: 2010-07-12 11:04+0100\n" "Last-Translator: Nils G.\n" "Language-Team: weechat-dev \n" @@ -4696,6 +4696,22 @@ msgstr "" "Standardbuffer der für Ausgaben genutzt werden soll falls ein privater " "Buffer nicht gefunden wird." +msgid "" +"chars used to stop in nick when computing color with letters of nick (at " +"least one char outside this list must be in string before stopping) " +"(example: nick \"_nick_away\" with \"_\" in chars will return color of nick " +"\"_nick\")" +msgstr "" + +msgid "" +"display notices as private messages (if auto, use private buffer if found)" +msgstr "" +"Zeigt Notizen als private Nachricht an (wird die \"auto\" Option verwendet " +"dann wird ein privater Buffer genutzt, falls vorhanden)" + +msgid "close buffer when /part is issued on a channel" +msgstr "Schließt den Buffer wenn \"/part\" im Channel ausgeführt wird" + msgid "" "number of IRC raw messages to save in memory when raw data buffer is closed " "(messages will be displayed when opening raw data buffer)" @@ -4722,15 +4738,6 @@ msgstr "aktiviert einen Filter für \"join\" Nachrichten" msgid "enable smart filter for \"part\" and \"quit\" messages" msgstr "aktiviert einen Filter für \"part\" und \"quit\" Nachrichten" -msgid "" -"display notices as private messages (if auto, use private buffer if found)" -msgstr "" -"Zeigt Notizen als private Nachricht an (wird die \"auto\" Option verwendet " -"dann wird ein privater Buffer genutzt, falls vorhanden)" - -msgid "close buffer when /part is issued on a channel" -msgstr "Schließt den Buffer wenn \"/part\" im Channel ausgeführt wird" - msgid "strip colors in topic (used only when displaying buffer title)" msgstr "" "Farben werden im Topic gestrippt (wird nur genutzt wenn der Buffer-Titel " diff --git a/po/es.po b/po/es.po index 22d597087..00dfa2331 100644 --- a/po/es.po +++ b/po/es.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.3-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-07-16 15:42+0200\n" +"POT-Creation-Date: 2010-07-17 10:15+0200\n" "PO-Revision-Date: 2010-06-20 21:24+0200\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -4579,6 +4579,22 @@ msgstr "" "buffer destino por defecto para las opciones msgbuffer cuando el destino es " "privado y no hay un buffer privado disponible" +msgid "" +"chars used to stop in nick when computing color with letters of nick (at " +"least one char outside this list must be in string before stopping) " +"(example: nick \"_nick_away\" with \"_\" in chars will return color of nick " +"\"_nick\")" +msgstr "" + +msgid "" +"display notices as private messages (if auto, use private buffer if found)" +msgstr "" +"mostrar avisos como mensajes privados (si es auto, usa un buffer privado si " +"lo encuentra)" + +msgid "close buffer when /part is issued on a channel" +msgstr "cerrar el buffer cuando /part es usado en un canal" + msgid "" "number of IRC raw messages to save in memory when raw data buffer is closed " "(messages will be displayed when opening raw data buffer)" @@ -4604,15 +4620,6 @@ msgstr "habilitar el filtro inteligente para mensajes de unión" msgid "enable smart filter for \"part\" and \"quit\" messages" msgstr "habilitar el filtro inteligente para mensajes de abandono y salida" -msgid "" -"display notices as private messages (if auto, use private buffer if found)" -msgstr "" -"mostrar avisos como mensajes privados (si es auto, usa un buffer privado si " -"lo encuentra)" - -msgid "close buffer when /part is issued on a channel" -msgstr "cerrar el buffer cuando /part es usado en un canal" - msgid "strip colors in topic (used only when displaying buffer title)" msgstr "" "remover colores en el tema (usado solamente cuando se esté mostrando el " diff --git a/po/fr.po b/po/fr.po index c0ed2f7dd..b59ec2df2 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.3-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-07-16 15:42+0200\n" -"PO-Revision-Date: 2010-07-16 14:57+0200\n" +"POT-Creation-Date: 2010-07-17 10:15+0200\n" +"PO-Revision-Date: 2010-07-17 10:07+0200\n" "Last-Translator: Sebastien Helleu \n" "Language-Team: weechat-dev \n" "Language: French\n" @@ -4627,6 +4627,26 @@ msgstr "" "tampon cible par défaut pour les options msgbuffer quand la cible est " "\"private\" et que le tampon privé n'est pas trouvé" +msgid "" +"chars used to stop in nick when computing color with letters of nick (at " +"least one char outside this list must be in string before stopping) " +"(example: nick \"_nick_away\" with \"_\" in chars will return color of nick " +"\"_nick\")" +msgstr "" +"caractères utilisés pour l'arrêt dans le pseudo lors du calcul de la couleur " +"avec les lettres du pseudo (au moins un caractère en dehors de cette liste " +"doit être dans la chaîne avant de s'arrêter) (exemple: le pseudo \"_nick_away" +"\" avec \"_\" dans les caractères retournera la couleur du pseudo \"_nick\")" + +msgid "" +"display notices as private messages (if auto, use private buffer if found)" +msgstr "" +"afficher les notices comme des messages privés (si auto, utilise le tampon " +"privé s'il est trouvé)" + +msgid "close buffer when /part is issued on a channel" +msgstr "fermer le tampon lorsque /part est exécuté sur un canal" + msgid "" "number of IRC raw messages to save in memory when raw data buffer is closed " "(messages will be displayed when opening raw data buffer)" @@ -4652,15 +4672,6 @@ msgstr "activer le filtre intelligent pour les messages \"join\"" msgid "enable smart filter for \"part\" and \"quit\" messages" msgstr "activer le filtre intelligent pour les messages \"part\" et \"quit\"" -msgid "" -"display notices as private messages (if auto, use private buffer if found)" -msgstr "" -"afficher les notices comme des messages privés (si auto, utilise le tampon " -"privé s'il est trouvé)" - -msgid "close buffer when /part is issued on a channel" -msgstr "fermer le tampon lorsque /part est exécuté sur un canal" - msgid "strip colors in topic (used only when displaying buffer title)" msgstr "" "supprimer les couleurs dans le titre (utilisé seulement lors de l'affichage " diff --git a/po/hu.po b/po/hu.po index 9b7e7a36e..731be99d5 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.3-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-07-16 15:42+0200\n" +"POT-Creation-Date: 2010-07-17 10:15+0200\n" "PO-Revision-Date: 2010-06-20 21:24+0200\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -4319,6 +4319,21 @@ msgid "" "private buffer is not found" msgstr "" +msgid "" +"chars used to stop in nick when computing color with letters of nick (at " +"least one char outside this list must be in string before stopping) " +"(example: nick \"_nick_away\" with \"_\" in chars will return color of nick " +"\"_nick\")" +msgstr "" + +#, fuzzy +msgid "" +"display notices as private messages (if auto, use private buffer if found)" +msgstr "figyelmeztetések privát üzenetként való mutatása" + +msgid "close buffer when /part is issued on a channel" +msgstr "" + msgid "" "number of IRC raw messages to save in memory when raw data buffer is closed " "(messages will be displayed when opening raw data buffer)" @@ -4339,14 +4354,6 @@ msgstr "új üzenetet tartalmazó ablak színe" msgid "enable smart filter for \"part\" and \"quit\" messages" msgstr "" -#, fuzzy -msgid "" -"display notices as private messages (if auto, use private buffer if found)" -msgstr "figyelmeztetések privát üzenetként való mutatása" - -msgid "close buffer when /part is issued on a channel" -msgstr "" - msgid "strip colors in topic (used only when displaying buffer title)" msgstr "" diff --git a/po/it.po b/po/it.po index c19f95477..c6ae61238 100644 --- a/po/it.po +++ b/po/it.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: Weechat 0.3.3-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-07-16 15:42+0200\n" +"POT-Creation-Date: 2010-07-17 10:15+0200\n" "PO-Revision-Date: 2010-06-20 21:24+0200\n" "Last-Translator: Marco Paolone \n" "Language-Team: weechat-dev \n" @@ -4586,6 +4586,22 @@ msgstr "" "buffer di destinazione predefinito per le opzioni di msgbuffer quando la " "destinazione è privata ed il buffer privato non viene trovato" +msgid "" +"chars used to stop in nick when computing color with letters of nick (at " +"least one char outside this list must be in string before stopping) " +"(example: nick \"_nick_away\" with \"_\" in chars will return color of nick " +"\"_nick\")" +msgstr "" + +msgid "" +"display notices as private messages (if auto, use private buffer if found)" +msgstr "" +"visualizza notifiche come messaggi privati (se automatico, utilizza il " +"buffer privato se viene trovato)" + +msgid "close buffer when /part is issued on a channel" +msgstr "chiude buffer quando viene digitato /part nel canale" + msgid "" "number of IRC raw messages to save in memory when raw data buffer is closed " "(messages will be displayed when opening raw data buffer)" @@ -4615,15 +4631,6 @@ msgstr "" "abilita filtro smart per i messaggi \"part\" (uscita) e \"quit " "(disconnessione)" -msgid "" -"display notices as private messages (if auto, use private buffer if found)" -msgstr "" -"visualizza notifiche come messaggi privati (se automatico, utilizza il " -"buffer privato se viene trovato)" - -msgid "close buffer when /part is issued on a channel" -msgstr "chiude buffer quando viene digitato /part nel canale" - msgid "strip colors in topic (used only when displaying buffer title)" msgstr "" "elimina colori nell'argomento (utilizzato solo quando viene visualizzato il " diff --git a/po/pl.po b/po/pl.po index 2299b7abf..e233a55d7 100644 --- a/po/pl.po +++ b/po/pl.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.3-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-07-16 15:42+0200\n" +"POT-Creation-Date: 2010-07-17 10:15+0200\n" "PO-Revision-Date: 2010-06-20 21:25+0200\n" "Last-Translator: B.J. Stobiecki \n" "Language-Team: weechat-dev \n" @@ -4557,6 +4557,22 @@ msgstr "" "domyślny bufor docelowy dla bufora wiadomości, kiedy cel jest prywatny i nie " "odnaleziono tego prywatnego bufora" +msgid "" +"chars used to stop in nick when computing color with letters of nick (at " +"least one char outside this list must be in string before stopping) " +"(example: nick \"_nick_away\" with \"_\" in chars will return color of nick " +"\"_nick\")" +msgstr "" + +msgid "" +"display notices as private messages (if auto, use private buffer if found)" +msgstr "" +"wyświetlaj powiadomienia jako prywatne wiadomości (jeśli auto, użwa " +"prywatnego bufora jeśli taki istnieje)" + +msgid "close buffer when /part is issued on a channel" +msgstr "zamyka bufor, kiedy na kanale wykonamy /part" + msgid "" "number of IRC raw messages to save in memory when raw data buffer is closed " "(messages will be displayed when opening raw data buffer)" @@ -4583,15 +4599,6 @@ msgstr "włącza mądre filtrowanie dla wiadomości \"join\"" msgid "enable smart filter for \"part\" and \"quit\" messages" msgstr "włącza inteligentne filtrowanie dla wiadomości \"part\" oraz \"quit\"" -msgid "" -"display notices as private messages (if auto, use private buffer if found)" -msgstr "" -"wyświetlaj powiadomienia jako prywatne wiadomości (jeśli auto, użwa " -"prywatnego bufora jeśli taki istnieje)" - -msgid "close buffer when /part is issued on a channel" -msgstr "zamyka bufor, kiedy na kanale wykonamy /part" - msgid "strip colors in topic (used only when displaying buffer title)" msgstr "usuń kolory w tematach (używane przy wuświetlaniu tytyłu bufora)" diff --git a/po/ru.po b/po/ru.po index b2008fe0f..aebc493df 100644 --- a/po/ru.po +++ b/po/ru.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.3-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-07-16 15:42+0200\n" +"POT-Creation-Date: 2010-07-17 10:15+0200\n" "PO-Revision-Date: 2010-06-20 21:25+0200\n" "Last-Translator: Pavel Shevchuk \n" "Language-Team: weechat-dev \n" @@ -4325,6 +4325,21 @@ msgid "" "private buffer is not found" msgstr "" +msgid "" +"chars used to stop in nick when computing color with letters of nick (at " +"least one char outside this list must be in string before stopping) " +"(example: nick \"_nick_away\" with \"_\" in chars will return color of nick " +"\"_nick\")" +msgstr "" + +#, fuzzy +msgid "" +"display notices as private messages (if auto, use private buffer if found)" +msgstr "отображать notice'ы в виде личных сообщений" + +msgid "close buffer when /part is issued on a channel" +msgstr "" + msgid "" "number of IRC raw messages to save in memory when raw data buffer is closed " "(messages will be displayed when opening raw data buffer)" @@ -4345,14 +4360,6 @@ msgstr "цвет текущего окна с сообщениями" msgid "enable smart filter for \"part\" and \"quit\" messages" msgstr "" -#, fuzzy -msgid "" -"display notices as private messages (if auto, use private buffer if found)" -msgstr "отображать notice'ы в виде личных сообщений" - -msgid "close buffer when /part is issued on a channel" -msgstr "" - msgid "strip colors in topic (used only when displaying buffer title)" msgstr "" diff --git a/po/weechat.pot b/po/weechat.pot index a6ccb2f21..d14557027 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: 2010-07-16 15:42+0200\n" +"POT-Creation-Date: 2010-07-17 10:15+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -3692,6 +3692,20 @@ msgid "" "private buffer is not found" msgstr "" +msgid "" +"chars used to stop in nick when computing color with letters of nick (at " +"least one char outside this list must be in string before stopping) " +"(example: nick \"_nick_away\" with \"_\" in chars will return color of nick " +"\"_nick\")" +msgstr "" + +msgid "" +"display notices as private messages (if auto, use private buffer if found)" +msgstr "" + +msgid "close buffer when /part is issued on a channel" +msgstr "" + msgid "" "number of IRC raw messages to save in memory when raw data buffer is closed " "(messages will be displayed when opening raw data buffer)" @@ -3711,13 +3725,6 @@ msgstr "" msgid "enable smart filter for \"part\" and \"quit\" messages" msgstr "" -msgid "" -"display notices as private messages (if auto, use private buffer if found)" -msgstr "" - -msgid "close buffer when /part is issued on a channel" -msgstr "" - msgid "strip colors in topic (used only when displaying buffer title)" msgstr "" diff --git a/src/plugins/irc/irc-config.c b/src/plugins/irc/irc-config.c index 6d2e4e7f3..eed2cb110 100644 --- a/src/plugins/irc/irc-config.c +++ b/src/plugins/irc/irc-config.c @@ -75,6 +75,7 @@ struct t_config_option *irc_config_look_hide_nickserv_pwd; struct t_config_option *irc_config_look_highlight_tags; struct t_config_option *irc_config_look_item_display_server; struct t_config_option *irc_config_look_msgbuffer_fallback; +struct t_config_option *irc_config_look_nick_color_stop_chars; struct t_config_option *irc_config_look_notice_as_pv; struct t_config_option *irc_config_look_part_closes_buffer; struct t_config_option *irc_config_look_raw_messages; @@ -153,24 +154,17 @@ irc_config_get_server_from_option_name (const char *name) } /* - * irc_config_change_look_color_nicks_number: called when the - * "weechat.look.color_nicks_number" - * option is changed + * irc_config_compute_nick_colors: compute nick colors for all servers and + * channels */ -int -irc_config_change_look_color_nicks_number (void *data, const char *option, - const char *value) +void +irc_config_compute_nick_colors () { struct t_irc_server *ptr_server; struct t_irc_channel *ptr_channel; struct t_irc_nick *ptr_nick; - /* make C compiler happy */ - (void) data; - (void) option; - (void) value; - for (ptr_server = irc_servers; ptr_server; ptr_server = ptr_server->next_server) { @@ -184,6 +178,24 @@ irc_config_change_look_color_nicks_number (void *data, const char *option, } } } +} + +/* + * irc_config_change_look_color_nicks_number: called when the + * "weechat.look.color_nicks_number" + * option is changed + */ + +int +irc_config_change_look_color_nicks_number (void *data, const char *option, + const char *value) +{ + /* make C compiler happy */ + (void) data; + (void) option; + (void) value; + + irc_config_compute_nick_colors (); return WEECHAT_RC_OK; } @@ -337,6 +349,22 @@ irc_config_change_look_highlight_tags (void *data, } } +/* + * irc_config_change_look_nick_color_stop_chars: called when the "nick color + * stop chars" option is changed + */ + +void +irc_config_change_look_nick_color_stop_chars (void *data, + struct t_config_option *option) +{ + /* make C compiler happy */ + (void) data; + (void) option; + + irc_config_compute_nick_colors (); +} + /* * irc_config_change_look_item_display_server: called when the * "item_display_server" option is @@ -1641,6 +1669,26 @@ irc_config_init () "private and that private buffer is not found"), "current|server", 0, 0, "current", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + irc_config_look_nick_color_stop_chars = weechat_config_new_option ( + irc_config_file, ptr_section, + "nick_color_stop_chars", "string", + N_("chars used to stop in nick when computing color with letters of " + "nick (at least one char outside this list must be in string before " + "stopping) (example: nick \"_nick_away\" with \"_\" in chars will " + "return color of nick \"_nick\")"), + NULL, 0, 0, "_|[", NULL, 0, NULL, NULL, + &irc_config_change_look_nick_color_stop_chars, NULL, NULL, NULL); + irc_config_look_notice_as_pv = weechat_config_new_option ( + irc_config_file, ptr_section, + "notice_as_pv", "integer", + N_("display notices as private messages (if auto, use private buffer " + "if found)"), + "auto|never|always", 0, 0, "auto", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + irc_config_look_part_closes_buffer = weechat_config_new_option ( + irc_config_file, ptr_section, + "part_closes_buffer", "boolean", + N_("close buffer when /part is issued on a channel"), + NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_raw_messages = weechat_config_new_option ( irc_config_file, ptr_section, "raw_messages", "integer", @@ -1669,17 +1717,6 @@ irc_config_init () "smart_filter_quit", "boolean", N_("enable smart filter for \"part\" and \"quit\" messages"), NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); - irc_config_look_notice_as_pv = weechat_config_new_option ( - irc_config_file, ptr_section, - "notice_as_pv", "integer", - N_("display notices as private messages (if auto, use private buffer " - "if found)"), - "auto|never|always", 0, 0, "auto", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); - irc_config_look_part_closes_buffer = weechat_config_new_option ( - irc_config_file, ptr_section, - "part_closes_buffer", "boolean", - N_("close buffer when /part is issued on a channel"), - NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); irc_config_look_topic_strip_colors = weechat_config_new_option ( irc_config_file, ptr_section, "topic_strip_colors", "boolean", diff --git a/src/plugins/irc/irc-config.h b/src/plugins/irc/irc-config.h index ea425405b..7950c8b3a 100644 --- a/src/plugins/irc/irc-config.h +++ b/src/plugins/irc/irc-config.h @@ -94,6 +94,7 @@ extern struct t_config_option *irc_config_look_hide_nickserv_pwd; extern struct t_config_option *irc_config_look_highlight_tags; extern struct t_config_option *irc_config_look_item_display_server; extern struct t_config_option *irc_config_look_msgbuffer_fallback; +extern struct t_config_option *irc_config_look_nick_color_stop_chars; extern struct t_config_option *irc_config_look_notice_as_pv; extern struct t_config_option *irc_config_look_part_closes_buffer; extern struct t_config_option *irc_config_look_raw_messages; diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c index 835d39482..a9e5110af 100644 --- a/src/plugins/irc/irc-nick.c +++ b/src/plugins/irc/irc-nick.c @@ -90,15 +90,55 @@ irc_nick_is_nick (const char *string) } /* - * irc_nick_find_color: find a color code for a nick - * (according to nick letters) + * irc_nick_strdup_for_color: duplicate a nick and stop at first char in list + * (using option irc.look.nick_color_stop_chars) */ -const char * -irc_nick_find_color (const char *nickname) +char * +irc_nick_strdup_for_color (const char *nickname) +{ + int char_size, other_char_seen; + char *result, *pos, utf_char[16]; + + result = malloc (strlen (nickname) + 1); + pos = result; + other_char_seen = 0; + while (nickname[0]) + { + char_size = weechat_utf8_char_size (nickname); + memcpy (utf_char, nickname, char_size); + utf_char[char_size] = '\0'; + + if (strstr (weechat_config_string (irc_config_look_nick_color_stop_chars), + utf_char)) + { + if (other_char_seen) + { + pos[0] = '\0'; + return result; + } + } + else + { + other_char_seen = 1; + } + memcpy (pos, utf_char, char_size); + pos += char_size; + + nickname += char_size; + } + pos[0] = '\0'; + return result; +} + +/* + * irc_nick_hash_color: hash a nickname to find color + */ + +int +irc_nick_hash_color (const char *nickname) { int color; - char color_name[64]; const char *ptr_nick; color = 0; @@ -108,8 +148,25 @@ irc_nick_find_color (const char *nickname) color += weechat_utf8_char_int (ptr_nick); ptr_nick = weechat_utf8_next_char (ptr_nick); } - color = (color % - weechat_config_integer (weechat_config_get ("weechat.look.color_nicks_number"))); + return (color % + weechat_config_integer (weechat_config_get ("weechat.look.color_nicks_number"))); +} + +/* + * irc_nick_find_color: find a color code for a nick + * (according to nick letters) + */ + +const char * +irc_nick_find_color (const char *nickname) +{ + int color; + char *nickname2, color_name[64]; + + nickname2 = irc_nick_strdup_for_color (nickname); + color = irc_nick_hash_color ((nickname2) ? nickname2 : nickname); + if (nickname2) + free (nickname2); snprintf (color_name, sizeof (color_name), "chat_nick_color%02d", color + 1); @@ -126,18 +183,12 @@ const char * irc_nick_find_color_name (const char *nickname) { int color; - char color_name[128]; - const char *ptr_nick; + char *nickname2, color_name[128]; - color = 0; - ptr_nick = nickname; - while (ptr_nick && ptr_nick[0]) - { - color += weechat_utf8_char_int (ptr_nick); - ptr_nick = weechat_utf8_next_char (ptr_nick); - } - color = (color % - weechat_config_integer (weechat_config_get ("weechat.look.color_nicks_number"))); + nickname2 = irc_nick_strdup_for_color (nickname); + color = irc_nick_hash_color ((nickname2) ? nickname2 : nickname); + if (nickname2) + free (nickname2); snprintf (color_name, sizeof (color_name), "weechat.color.chat_nick_color%02d", color + 1);