From fdd39c6b97683ad6cdb009e2518baa5d2fc9b16b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Mon, 6 Apr 2020 20:49:17 +0200 Subject: [PATCH] buflist: evaluate option buflist.look.sort (closes #1465) The evaluation allows to use different sort for the bar items, for example with such value: ${if:${bar_item.name}==buflist?number:short_name} This sorts by number on the first bar item and by short name on the two other bar items. --- ChangeLog.adoc | 4 ++ doc/de/autogen/user/buflist_options.adoc | 2 +- doc/en/autogen/user/buflist_options.adoc | 2 +- doc/fr/autogen/user/buflist_options.adoc | 2 +- doc/it/autogen/user/buflist_options.adoc | 2 +- doc/ja/autogen/user/buflist_options.adoc | 2 +- doc/pl/autogen/user/buflist_options.adoc | 2 +- po/cs.po | 5 +- po/de.po | 6 +- po/es.po | 5 +- po/fr.po | 11 ++-- po/hu.po | 5 +- po/it.po | 5 +- po/ja.po | 6 +- po/pl.po | 50 ++++++++-------- po/pt.po | 5 +- po/pt_BR.po | 5 +- po/ru.po | 5 +- po/tr.po | 5 +- po/weechat.pot | 5 +- src/plugins/buflist/buflist-bar-item.c | 28 +++++++-- src/plugins/buflist/buflist-bar-item.h | 4 ++ src/plugins/buflist/buflist-config.c | 76 ++++++++++++++++++------ src/plugins/buflist/buflist-config.h | 8 ++- src/plugins/buflist/buflist.c | 19 ++++-- src/plugins/buflist/buflist.h | 4 +- 26 files changed, 185 insertions(+), 88 deletions(-) diff --git a/ChangeLog.adoc b/ChangeLog.adoc index d53df1cec..a560c29bc 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -18,6 +18,10 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] [[v2.9]] == Version 2.9 (under dev) +New features:: + + * buflist: evaluate option buflist.look.sort so that sort can be customized for each of the three buflist bar items (issue #1465) + Bug fixes:: * python: fix crash when invalid UTF-8 string is in a WeeChat hashtable converted to a Python dict (issue #1463) diff --git a/doc/de/autogen/user/buflist_options.adoc b/doc/de/autogen/user/buflist_options.adoc index 634a77c7f..d8908bb2d 100644 --- a/doc/de/autogen/user/buflist_options.adoc +++ b/doc/de/autogen/user/buflist_options.adoc @@ -147,7 +147,7 @@ ** Standardwert: `+""+` * [[option_buflist.look.sort]] *buflist.look.sort* -** Beschreibung: pass:none[durch Kommata getrennte Liste von Feldern um die Buffer zu sortieren; jedes Feld ist entweder eine hdata Variable von Buffer ("var"), eine hdata Variable vom Typ IRC Server ("irc_server.var") oder eine hdata Variable vom Typ IRC Channel ("irc_channel.var"); wird das "-" Zeichen vor einem Feld angewendet, wird die Ausgabe umgekehrt, um bei einem Vergleich nicht zwischen Groß- und Kleinschreibung zu unterscheiden wird das Zeichen "~" verwendet; Beispiel: "-~short_name" sortiert die Buffer nach ihrem Kurznamen, wobei dies invertierte passiert und nicht zwischen Groß-oder Kleinschreibung unterschieden wird] +** Beschreibung: pass:none[comma-separated list of fields to sort buffers; each field is a hdata variable of buffer ("var"), a hdata variable of IRC server ("irc_server.var") or a hdata variable of IRC channel ("irc_channel.var"); char "-" can be used before field to reverse order, char "~" can be used to do a case insensitive comparison; example: "-~short_name" for case insensitive and reverse sort on buffer short name (note: content is evaluated, only the pointer to bar_item can be used, for example "bar_item.name")] ** Typ: Zeichenkette ** Werte: beliebige Zeichenkette ** Standardwert: `+"number,-active"+` diff --git a/doc/en/autogen/user/buflist_options.adoc b/doc/en/autogen/user/buflist_options.adoc index a28f958e9..ce4f8c0d4 100644 --- a/doc/en/autogen/user/buflist_options.adoc +++ b/doc/en/autogen/user/buflist_options.adoc @@ -147,7 +147,7 @@ ** default value: `+""+` * [[option_buflist.look.sort]] *buflist.look.sort* -** description: pass:none[comma-separated list of fields to sort buffers; each field is a hdata variable of buffer ("var"), a hdata variable of IRC server ("irc_server.var") or a hdata variable of IRC channel ("irc_channel.var"); char "-" can be used before field to reverse order, char "~" can be used to do a case insensitive comparison; example: "-~short_name" for case insensitive and reverse sort on buffer short name] +** description: pass:none[comma-separated list of fields to sort buffers; each field is a hdata variable of buffer ("var"), a hdata variable of IRC server ("irc_server.var") or a hdata variable of IRC channel ("irc_channel.var"); char "-" can be used before field to reverse order, char "~" can be used to do a case insensitive comparison; example: "-~short_name" for case insensitive and reverse sort on buffer short name (note: content is evaluated, only the pointer to bar_item can be used, for example "bar_item.name")] ** type: string ** values: any string ** default value: `+"number,-active"+` diff --git a/doc/fr/autogen/user/buflist_options.adoc b/doc/fr/autogen/user/buflist_options.adoc index 1024c29a0..b7a50732a 100644 --- a/doc/fr/autogen/user/buflist_options.adoc +++ b/doc/fr/autogen/user/buflist_options.adoc @@ -147,7 +147,7 @@ ** valeur par défaut: `+""+` * [[option_buflist.look.sort]] *buflist.look.sort* -** description: pass:none[liste de champs séparés par des virgules pour trier les tampons ; chaque champ est une variable hdata du tampon ("var"), une variable hdata du serveur IRC ("irc_server.var") ou une variable hdata du canal IRC ("irc_channel.var") ; le caractère "-" peut être utilisé pour inverser l'ordre, le caractère "~" peut être utilisé pour effectuer une comparaison insensible à la casse ; exemple : "-~short_name" pour un tri inverse insensible à la casse sur le nom court du tampon] +** description: pass:none[liste de champs séparés par des virgules pour trier les tampons ; chaque champ est une variable hdata du tampon ("var"), une variable hdata du serveur IRC ("irc_server.var") ou une variable hdata du canal IRC ("irc_channel.var") ; le caractère "-" peut être utilisé pour inverser l'ordre, le caractère "~" peut être utilisé pour effectuer une comparaison insensible à la casse ; exemple : "-~short_name" pour un tri inverse insensible à la casse sur le nom court du tampon (note : le contenu est évalué, seul le pointeur vers bar_item peut être utilisé, par exemple "bar_item.name")] ** type: chaîne ** valeurs: toute chaîne ** valeur par défaut: `+"number,-active"+` diff --git a/doc/it/autogen/user/buflist_options.adoc b/doc/it/autogen/user/buflist_options.adoc index cbafd9b85..bb206e568 100644 --- a/doc/it/autogen/user/buflist_options.adoc +++ b/doc/it/autogen/user/buflist_options.adoc @@ -147,7 +147,7 @@ ** valore predefinito: `+""+` * [[option_buflist.look.sort]] *buflist.look.sort* -** descrizione: pass:none[comma-separated list of fields to sort buffers; each field is a hdata variable of buffer ("var"), a hdata variable of IRC server ("irc_server.var") or a hdata variable of IRC channel ("irc_channel.var"); char "-" can be used before field to reverse order, char "~" can be used to do a case insensitive comparison; example: "-~short_name" for case insensitive and reverse sort on buffer short name] +** descrizione: pass:none[comma-separated list of fields to sort buffers; each field is a hdata variable of buffer ("var"), a hdata variable of IRC server ("irc_server.var") or a hdata variable of IRC channel ("irc_channel.var"); char "-" can be used before field to reverse order, char "~" can be used to do a case insensitive comparison; example: "-~short_name" for case insensitive and reverse sort on buffer short name (note: content is evaluated, only the pointer to bar_item can be used, for example "bar_item.name")] ** tipo: stringa ** valori: qualsiasi stringa ** valore predefinito: `+"number,-active"+` diff --git a/doc/ja/autogen/user/buflist_options.adoc b/doc/ja/autogen/user/buflist_options.adoc index 14ab3eca4..4b427e457 100644 --- a/doc/ja/autogen/user/buflist_options.adoc +++ b/doc/ja/autogen/user/buflist_options.adoc @@ -147,7 +147,7 @@ ** デフォルト値: `+""+` * [[option_buflist.look.sort]] *buflist.look.sort* -** 説明: pass:none[バッファをソートする際に考慮するフィールドのコンマ区切りリスト; 各フィールドはバッファの hdata 変数 ("var")、IRC サーバの hdata 変数 ("irc_server.var")、IRC チャンネルの hdata 変数 ("irc_channel.var") のどれかです; フィールドの先頭に "-" 文字を付けることでソート順を逆にすることも可能です。大文字小文字を区別せずに比較を行うには "~" 文字を使います; 例: "-~short_name" バッファの短縮名を使い、大文字小文字を区別せずにソートして、順番を逆にします] +** 説明: pass:none[comma-separated list of fields to sort buffers; each field is a hdata variable of buffer ("var"), a hdata variable of IRC server ("irc_server.var") or a hdata variable of IRC channel ("irc_channel.var"); char "-" can be used before field to reverse order, char "~" can be used to do a case insensitive comparison; example: "-~short_name" for case insensitive and reverse sort on buffer short name (note: content is evaluated, only the pointer to bar_item can be used, for example "bar_item.name")] ** タイプ: 文字列 ** 値: 未制約文字列 ** デフォルト値: `+"number,-active"+` diff --git a/doc/pl/autogen/user/buflist_options.adoc b/doc/pl/autogen/user/buflist_options.adoc index e7e420831..06bc82c5d 100644 --- a/doc/pl/autogen/user/buflist_options.adoc +++ b/doc/pl/autogen/user/buflist_options.adoc @@ -147,7 +147,7 @@ ** domyślna wartość: `+""+` * [[option_buflist.look.sort]] *buflist.look.sort* -** opis: pass:none[oddzielona przecinkami lista pól do sortowania buforów; każde pole to zmienna hdata bufora ("var"), zmienna hdata serwera IRC ("irc_server.var") lub zmienna hdata kanału IRC ("irc_channel.var"); znak "-" użyty przed nazwą pola odwraca kolejność, znak "~" może zostać użyty do porównań niewrażliwych na wielkość liter; przykład: "-~short_name" dla sortowania odwrotnego, niewrażliwego na wielkość liter po skróconej nazwie bufora] +** opis: pass:none[comma-separated list of fields to sort buffers; each field is a hdata variable of buffer ("var"), a hdata variable of IRC server ("irc_server.var") or a hdata variable of IRC channel ("irc_channel.var"); char "-" can be used before field to reverse order, char "~" can be used to do a case insensitive comparison; example: "-~short_name" for case insensitive and reverse sort on buffer short name (note: content is evaluated, only the pointer to bar_item can be used, for example "bar_item.name")] ** typ: ciąg ** wartości: dowolny ciąg ** domyślna wartość: `+"number,-active"+` diff --git a/po/cs.po b/po/cs.po index 0ca31ef85..59697f3e2 100644 --- a/po/cs.po +++ b/po/cs.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-04-02 08:04+0200\n" +"POT-Creation-Date: 2020-04-06 20:37+0200\n" "PO-Revision-Date: 2020-03-08 14:22+0100\n" "Last-Translator: Ondřej Súkup \n" "Language-Team: weechat-dev \n" @@ -5036,7 +5036,8 @@ msgid "" "var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " "can be used before field to reverse order, char \"~\" can be used to do a " "case insensitive comparison; example: \"-~short_name\" for case insensitive " -"and reverse sort on buffer short name" +"and reverse sort on buffer short name (note: content is evaluated, only the " +"pointer to bar_item can be used, for example \"bar_item.name\")" msgstr "" msgid "" diff --git a/po/de.po b/po/de.po index d75507b60..e81336250 100644 --- a/po/de.po +++ b/po/de.po @@ -24,7 +24,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-04-02 08:04+0200\n" +"POT-Creation-Date: 2020-04-06 20:37+0200\n" "PO-Revision-Date: 2020-04-03 20:03+0200\n" "Last-Translator: Nils Görs \n" "Language-Team: German \n" @@ -6095,13 +6095,15 @@ msgstr "" "benutzerdefinierte Variablen genutzt werden und dadurch eine Aktualisierung " "erforderlich wird" +#, fuzzy msgid "" "comma-separated list of fields to sort buffers; each field is a hdata " "variable of buffer (\"var\"), a hdata variable of IRC server (\"irc_server." "var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " "can be used before field to reverse order, char \"~\" can be used to do a " "case insensitive comparison; example: \"-~short_name\" for case insensitive " -"and reverse sort on buffer short name" +"and reverse sort on buffer short name (note: content is evaluated, only the " +"pointer to bar_item can be used, for example \"bar_item.name\")" msgstr "" "durch Kommata getrennte Liste von Feldern um die Buffer zu sortieren; jedes " "Feld ist entweder eine hdata Variable von Buffer (\"var\"), eine hdata " diff --git a/po/es.po b/po/es.po index 3a2193e0b..ac0a5a252 100644 --- a/po/es.po +++ b/po/es.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-04-02 08:04+0200\n" +"POT-Creation-Date: 2020-04-06 20:37+0200\n" "PO-Revision-Date: 2020-03-08 14:22+0100\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -5236,7 +5236,8 @@ msgid "" "var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " "can be used before field to reverse order, char \"~\" can be used to do a " "case insensitive comparison; example: \"-~short_name\" for case insensitive " -"and reverse sort on buffer short name" +"and reverse sort on buffer short name (note: content is evaluated, only the " +"pointer to bar_item can be used, for example \"bar_item.name\")" msgstr "" msgid "" diff --git a/po/fr.po b/po/fr.po index f6eb2d08a..cd9287663 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-04-02 08:04+0200\n" -"PO-Revision-Date: 2020-04-02 20:26+0200\n" +"POT-Creation-Date: 2020-04-06 20:37+0200\n" +"PO-Revision-Date: 2020-04-06 20:37+0200\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" "Language: fr\n" @@ -5962,7 +5962,8 @@ msgid "" "var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " "can be used before field to reverse order, char \"~\" can be used to do a " "case insensitive comparison; example: \"-~short_name\" for case insensitive " -"and reverse sort on buffer short name" +"and reverse sort on buffer short name (note: content is evaluated, only the " +"pointer to bar_item can be used, for example \"bar_item.name\")" msgstr "" "liste de champs séparés par des virgules pour trier les tampons ; chaque " "champ est une variable hdata du tampon (\"var\"), une variable hdata du " @@ -5970,7 +5971,9 @@ msgstr "" "(\"irc_channel.var\") ; le caractère \"-\" peut être utilisé pour inverser " "l'ordre, le caractère \"~\" peut être utilisé pour effectuer une comparaison " "insensible à la casse ; exemple : \"-~short_name\" pour un tri inverse " -"insensible à la casse sur le nom court du tampon" +"insensible à la casse sur le nom court du tampon (note : le contenu est " +"évalué, seul le pointeur vers bar_item peut être utilisé, par exemple " +"\"bar_item.name\")" msgid "" "format of each line with a buffer (note: content is evaluated, see /help " diff --git a/po/hu.po b/po/hu.po index 23c1f2e12..86bbc84c1 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-04-02 08:04+0200\n" +"POT-Creation-Date: 2020-04-06 20:37+0200\n" "PO-Revision-Date: 2020-03-08 14:22+0100\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -4574,7 +4574,8 @@ msgid "" "var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " "can be used before field to reverse order, char \"~\" can be used to do a " "case insensitive comparison; example: \"-~short_name\" for case insensitive " -"and reverse sort on buffer short name" +"and reverse sort on buffer short name (note: content is evaluated, only the " +"pointer to bar_item can be used, for example \"bar_item.name\")" msgstr "" msgid "" diff --git a/po/it.po b/po/it.po index 95c3d7631..b134720a0 100644 --- a/po/it.po +++ b/po/it.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-04-02 08:04+0200\n" +"POT-Creation-Date: 2020-04-06 20:37+0200\n" "PO-Revision-Date: 2020-03-08 14:22+0100\n" "Last-Translator: Esteban I. Ruiz Moreno \n" "Language-Team: weechat-dev \n" @@ -5371,7 +5371,8 @@ msgid "" "var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " "can be used before field to reverse order, char \"~\" can be used to do a " "case insensitive comparison; example: \"-~short_name\" for case insensitive " -"and reverse sort on buffer short name" +"and reverse sort on buffer short name (note: content is evaluated, only the " +"pointer to bar_item can be used, for example \"bar_item.name\")" msgstr "" msgid "" diff --git a/po/ja.po b/po/ja.po index 9c3d3f2db..828b19037 100644 --- a/po/ja.po +++ b/po/ja.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-04-02 08:04+0200\n" +"POT-Creation-Date: 2020-04-06 20:37+0200\n" "PO-Revision-Date: 2020-03-08 14:22+0100\n" "Last-Translator: AYANOKOUZI, Ryuunosuke \n" "Language-Team: Japanese \n" "Language-Team: Polish \n" @@ -30,8 +30,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10" -" || n%100>=20) ? 1 : 2);\n" +"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " +"|| n%100>=20) ? 1 : 2);\n" "X-Generator: Lokalize 19.12.3\n" msgid "any string" @@ -5674,9 +5674,9 @@ msgstr "" " - dane elementu paska (pełną listę można znaleźć w dokumentacji API dla " "hdata \"bar_item\"), na przykład:\n" " - ${bar_item.name}\n" -" - dane okna, w którym element paska jest wyświetlany (okna nie ma w głównych " -"paskach, zobacz hdata \"window\" w dokumentacji API dla pełnej listy " -"zmiennych), na przykład:\n" +" - dane okna, w którym element paska jest wyświetlany (okna nie ma w " +"głównych paskach, zobacz hdata \"window\" w dokumentacji API dla pełnej " +"listy zmiennych), na przykład:\n" " - ${window.number}\n" " - ${window.buffer.full_name}\n" " - dane buforu (zobacz hdata \"buffer\" w dokumentacji API dla pełnej listy " @@ -5815,13 +5815,15 @@ msgstr "" "ustawione są jakieś zmienne używane do formatowania wymagające odpowiedniego " "odświeżania" +#, fuzzy msgid "" "comma-separated list of fields to sort buffers; each field is a hdata " "variable of buffer (\"var\"), a hdata variable of IRC server (\"irc_server." "var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " "can be used before field to reverse order, char \"~\" can be used to do a " "case insensitive comparison; example: \"-~short_name\" for case insensitive " -"and reverse sort on buffer short name" +"and reverse sort on buffer short name (note: content is evaluated, only the " +"pointer to bar_item can be used, for example \"bar_item.name\")" msgstr "" "oddzielona przecinkami lista pól do sortowania buforów; każde pole to " "zmienna hdata bufora (\"var\"), zmienna hdata serwera IRC (\"irc_server.var" @@ -6915,12 +6917,11 @@ msgid "" "evaluation of string and then much faster; formats can be switched with key " "ctrl+X" msgstr "" -"pierwszy format dla każdej linii, użyty kiedy opcja fset.look.format_number" -" ma " -"wartość 1 (uwaga: zawartość jest przetwarzana, zobacz /help fset); pusty ciąg " -"używa domyślnego formatu (\"${marked} ${name} ${type} ${value2}\"), który " -"nie przetwarza ciągów, przez co jest szybszy; formaty można zmienić za pomocą " -"ctrl-X" +"pierwszy format dla każdej linii, użyty kiedy opcja fset.look.format_number " +"ma wartość 1 (uwaga: zawartość jest przetwarzana, zobacz /help fset); pusty " +"ciąg używa domyślnego formatu (\"${marked} ${name} ${type} ${value2}\"), " +"który nie przetwarza ciągów, przez co jest szybszy; formaty można zmienić za " +"pomocą ctrl-X" msgid "" "second format of each line, used when option fset.look.format_number is set " @@ -6930,11 +6931,10 @@ msgid "" "ctrl+X" msgstr "" "drugi format dla każdej linii, użyty kiedy opcja fset.look.format_number ma " -"wartość 2 (uwaga: zawartość jest przetwarzana, zobacz /help fset); pusty ciąg" -" używa " -"domyślnego formatu (\"${marked} ${name} ${type} ${value2}\"), który nie " -"przetwarza ciągów, przez co jest szybszy; formaty można zmienić za pomocą " -"ctrl-X" +"wartość 2 (uwaga: zawartość jest przetwarzana, zobacz /help fset); pusty " +"ciąg używa domyślnego formatu (\"${marked} ${name} ${type} ${value2}\"), " +"który nie przetwarza ciągów, przez co jest szybszy; formaty można zmienić za " +"pomocą ctrl-X" msgid "color for default value" msgstr "kolor dla wartości domyślnej" @@ -9144,11 +9144,10 @@ msgid "" "evaluated with ${irc_server.xxx} and ${server} is replaced by the server " "name)" msgstr "" -"hasło do klucza prywatnego certyfikatu SSL; tylko dla gnutls w wersji >=" -" 3.1.0 " -"(uwaga: zawartość jest przetwarzana zobacz /help eval; opcje serwera są" -" przetwarzane " -"w postaci ${irc_server.xxx}, ${server} jest zastępowany nazwą serwera)" +"hasło do klucza prywatnego certyfikatu SSL; tylko dla gnutls w wersji >= " +"3.1.0 (uwaga: zawartość jest przetwarzana zobacz /help eval; opcje serwera " +"są przetwarzane w postaci ${irc_server.xxx}, ${server} jest zastępowany " +"nazwą serwera)" msgid "" "string with priorities for gnutls (for syntax, see documentation of function " @@ -11528,9 +11527,8 @@ msgid "" "1 if automatic connection to servers is enabled, 0 if it has been disabled " "by the user (option \"-a\" or \"--no-connect\")" msgstr "" -"1 jeśli automatycznie łączenie z serwerami jest włączone, 0 jeśli zostało" -" wyłączone " -"przez użytkownika (opcja \"-a\" lub \"--no-connect\")" +"1 jeśli automatycznie łączenie z serwerami jest włączone, 0 jeśli zostało " +"wyłączone przez użytkownika (opcja \"-a\" lub \"--no-connect\")" msgid "terminal charset" msgstr "kodowanie terminala" diff --git a/po/pt.po b/po/pt.po index ee76fa0e3..0e9186524 100644 --- a/po/pt.po +++ b/po/pt.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-04-02 08:04+0200\n" +"POT-Creation-Date: 2020-04-06 20:37+0200\n" "PO-Revision-Date: 2020-03-08 14:22+0100\n" "Last-Translator: Vasco Almeida \n" "Language-Team: Portuguese <>\n" @@ -5645,7 +5645,8 @@ msgid "" "var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " "can be used before field to reverse order, char \"~\" can be used to do a " "case insensitive comparison; example: \"-~short_name\" for case insensitive " -"and reverse sort on buffer short name" +"and reverse sort on buffer short name (note: content is evaluated, only the " +"pointer to bar_item can be used, for example \"bar_item.name\")" msgstr "" msgid "" diff --git a/po/pt_BR.po b/po/pt_BR.po index f927bbab6..e5d8e4323 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-04-02 08:04+0200\n" +"POT-Creation-Date: 2020-04-06 20:37+0200\n" "PO-Revision-Date: 2019-11-03 08:38+0100\n" "Last-Translator: Eduardo Elias \n" "Language-Team: weechat-dev \n" @@ -5187,7 +5187,8 @@ msgid "" "var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " "can be used before field to reverse order, char \"~\" can be used to do a " "case insensitive comparison; example: \"-~short_name\" for case insensitive " -"and reverse sort on buffer short name" +"and reverse sort on buffer short name (note: content is evaluated, only the " +"pointer to bar_item can be used, for example \"bar_item.name\")" msgstr "" msgid "" diff --git a/po/ru.po b/po/ru.po index fff7959c6..5b6f52db9 100644 --- a/po/ru.po +++ b/po/ru.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-04-02 08:04+0200\n" +"POT-Creation-Date: 2020-04-06 20:37+0200\n" "PO-Revision-Date: 2020-03-08 14:22+0100\n" "Last-Translator: Aleksey V Zapparov AKA ixti \n" "Language-Team: weechat-dev \n" @@ -4611,7 +4611,8 @@ msgid "" "var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " "can be used before field to reverse order, char \"~\" can be used to do a " "case insensitive comparison; example: \"-~short_name\" for case insensitive " -"and reverse sort on buffer short name" +"and reverse sort on buffer short name (note: content is evaluated, only the " +"pointer to bar_item can be used, for example \"bar_item.name\")" msgstr "" msgid "" diff --git a/po/tr.po b/po/tr.po index 213d19006..edf474d1e 100644 --- a/po/tr.po +++ b/po/tr.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-04-02 08:04+0200\n" +"POT-Creation-Date: 2020-04-06 20:37+0200\n" "PO-Revision-Date: 2019-11-03 08:38+0100\n" "Last-Translator: Hasan Kiran \n" "Language-Team: weechat-dev \n" @@ -4181,7 +4181,8 @@ msgid "" "var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " "can be used before field to reverse order, char \"~\" can be used to do a " "case insensitive comparison; example: \"-~short_name\" for case insensitive " -"and reverse sort on buffer short name" +"and reverse sort on buffer short name (note: content is evaluated, only the " +"pointer to bar_item can be used, for example \"bar_item.name\")" msgstr "" msgid "" diff --git a/po/weechat.pot b/po/weechat.pot index fcee63b9f..2c83e405b 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2020-04-02 08:04+0200\n" +"POT-Creation-Date: 2020-04-06 20:37+0200\n" "PO-Revision-Date: 2014-08-16 10:27+0200\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" @@ -4165,7 +4165,8 @@ msgid "" "var\") or a hdata variable of IRC channel (\"irc_channel.var\"); char \"-\" " "can be used before field to reverse order, char \"~\" can be used to do a " "case insensitive comparison; example: \"-~short_name\" for case insensitive " -"and reverse sort on buffer short name" +"and reverse sort on buffer short name (note: content is evaluated, only the " +"pointer to bar_item can be used, for example \"bar_item.name\")" msgstr "" msgid "" diff --git a/src/plugins/buflist/buflist-bar-item.c b/src/plugins/buflist/buflist-bar-item.c index 8a2f089d5..527805fb8 100644 --- a/src/plugins/buflist/buflist-bar-item.c +++ b/src/plugins/buflist/buflist-bar-item.c @@ -29,13 +29,15 @@ #include "buflist-config.h" -struct t_gui_bar_item *buflist_bar_item_buflist[BUFLIST_BAR_NUM_ITEMS]; +struct t_gui_bar_item *buflist_bar_item_buflist[BUFLIST_BAR_NUM_ITEMS] = +{ NULL, NULL, NULL }; struct t_hashtable *buflist_hashtable_pointers = NULL; struct t_hashtable *buflist_hashtable_extra_vars = NULL; struct t_hashtable *buflist_hashtable_options_conditions = NULL; -struct t_arraylist *buflist_list_buffers[BUFLIST_BAR_NUM_ITEMS]; +struct t_arraylist *buflist_list_buffers[BUFLIST_BAR_NUM_ITEMS] = +{ NULL, NULL, NULL }; -int old_line_number_current_buffer[BUFLIST_BAR_NUM_ITEMS]; +int old_line_number_current_buffer[BUFLIST_BAR_NUM_ITEMS] = { -1, -1, -1 }; /* @@ -81,6 +83,24 @@ buflist_bar_item_get_index (const char *item_name) return -1; } +/* + * Returns the bar item index with a bar item pointer, -1 if not found. + */ + +int +buflist_bar_item_get_index_with_pointer (struct t_gui_bar_item *item) +{ + int i; + + for (i = 0; i < BUFLIST_BAR_NUM_ITEMS; i++) + { + if (buflist_bar_item_buflist[i] == item) + return i; + } + + return -1; +} + /* * Updates buflist bar item if buflist is enabled (or if force argument is 1). */ @@ -332,7 +352,7 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data, 16, 0, 1, NULL, NULL, NULL, NULL); - buffers = buflist_sort_buffers (); + buffers = buflist_sort_buffers (item); num_buffers = weechat_arraylist_size (buffers); for (i = 0; i < num_buffers; i++) diff --git a/src/plugins/buflist/buflist-bar-item.h b/src/plugins/buflist/buflist-bar-item.h index 808bb68a7..bef68b6f8 100644 --- a/src/plugins/buflist/buflist-bar-item.h +++ b/src/plugins/buflist/buflist-bar-item.h @@ -24,10 +24,14 @@ #define BUFLIST_BAR_NUM_ITEMS 3 +struct t_gui_bar_item; + +extern struct t_gui_bar_item *buflist_bar_item_buflist[BUFLIST_BAR_NUM_ITEMS]; extern struct t_arraylist *buflist_list_buffers[BUFLIST_BAR_NUM_ITEMS]; extern const char *buflist_bar_item_get_name (int index); extern int buflist_bar_item_get_index (const char *item_name); +extern int buflist_bar_item_get_index_with_pointer (struct t_gui_bar_item *item); extern void buflist_bar_item_update (int force); extern int buflist_bar_item_init (); extern void buflist_bar_item_end (); diff --git a/src/plugins/buflist/buflist-config.c b/src/plugins/buflist/buflist-config.c index ad7f46270..111cf996a 100644 --- a/src/plugins/buflist/buflist-config.c +++ b/src/plugins/buflist/buflist-config.c @@ -61,8 +61,8 @@ struct t_config_option *buflist_config_format_number; struct t_hook **buflist_config_signals_refresh = NULL; int buflist_config_num_signals_refresh = 0; -char **buflist_config_sort_fields = NULL; -int buflist_config_sort_fields_count = 0; +char **buflist_config_sort_fields[BUFLIST_BAR_NUM_ITEMS] = { NULL, NULL, NULL }; +int buflist_config_sort_fields_count[BUFLIST_BAR_NUM_ITEMS] = { 0, 0, 0 }; char *buflist_config_format_buffer_eval = NULL; char *buflist_config_format_buffer_current_eval = NULL; char *buflist_config_format_hotlist_eval = NULL; @@ -246,23 +246,58 @@ void buflist_config_change_sort (const void *pointer, void *data, struct t_config_option *option) { + int i; + struct t_hashtable *hashtable_pointers; + char *sort; + /* make C compiler happy */ (void) pointer; (void) data; (void) option; - if (buflist_config_sort_fields) - weechat_string_free_split (buflist_config_sort_fields); + for (i = 0; i < BUFLIST_BAR_NUM_ITEMS; i++) + { + if (buflist_config_sort_fields[i]) + { + weechat_string_free_split (buflist_config_sort_fields[i]); + buflist_config_sort_fields[i] = NULL; + buflist_config_sort_fields_count[i] = 0; + } + } - buflist_config_sort_fields = weechat_string_split ( - weechat_config_string (buflist_config_look_sort), - ",", + hashtable_pointers = weechat_hashtable_new ( + 32, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_POINTER, NULL, - WEECHAT_STRING_SPLIT_STRIP_LEFT - | WEECHAT_STRING_SPLIT_STRIP_RIGHT - | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS, - 0, - &buflist_config_sort_fields_count); + NULL); + if (!hashtable_pointers) + return; + + for (i = 0; i < BUFLIST_BAR_NUM_ITEMS; i++) + { + weechat_hashtable_set (hashtable_pointers, + "bar_item", buflist_bar_item_buflist[i]); + + sort = weechat_string_eval_expression ( + weechat_config_string (buflist_config_look_sort), + hashtable_pointers, + NULL, + NULL); + + buflist_config_sort_fields[i] = weechat_string_split ( + (sort) ? sort : "", + ",", + NULL, + WEECHAT_STRING_SPLIT_STRIP_LEFT + | WEECHAT_STRING_SPLIT_STRIP_RIGHT + | WEECHAT_STRING_SPLIT_COLLAPSE_SEPS, + 0, + &buflist_config_sort_fields_count[i]); + + if (sort) + free (sort); + } buflist_bar_item_update (0); } @@ -522,7 +557,9 @@ buflist_config_init () "char \"-\" can be used before field to reverse order, " "char \"~\" can be used to do a case insensitive comparison; " "example: \"-~short_name\" for case insensitive and reverse " - "sort on buffer short name"), + "sort on buffer short name " + "(note: content is evaluated, only the pointer to bar_item can be " + "used, for example \"bar_item.name\")"), NULL, 0, 0, "number,-active", NULL, 0, NULL, NULL, NULL, &buflist_config_change_sort, NULL, NULL, @@ -726,16 +763,21 @@ buflist_config_write () void buflist_config_free () { + int i; + weechat_config_free (buflist_config_file); if (buflist_config_signals_refresh) buflist_config_free_signals_refresh (); - if (buflist_config_sort_fields) + for (i = 0; i < BUFLIST_BAR_NUM_ITEMS; i++) { - weechat_string_free_split (buflist_config_sort_fields); - buflist_config_sort_fields = NULL; - buflist_config_sort_fields_count = 0; + if (buflist_config_sort_fields[i]) + { + weechat_string_free_split (buflist_config_sort_fields[i]); + buflist_config_sort_fields[i] = NULL; + buflist_config_sort_fields_count[i] = 0; + } } if (buflist_config_format_buffer_eval) diff --git a/src/plugins/buflist/buflist-config.h b/src/plugins/buflist/buflist-config.h index a5f387adf..848af87aa 100644 --- a/src/plugins/buflist/buflist-config.h +++ b/src/plugins/buflist/buflist-config.h @@ -20,6 +20,8 @@ #ifndef WEECHAT_PLUGIN_BUFLIST_CONFIG_H #define WEECHAT_PLUGIN_BUFLIST_CONFIG_H +#include "buflist-bar-item.h" + #define BUFLIST_CONFIG_NAME "buflist" #define BUFLIST_CONFIG_SIGNALS_REFRESH \ @@ -56,12 +58,14 @@ extern struct t_config_option *buflist_config_format_name; extern struct t_config_option *buflist_config_format_nick_prefix; extern struct t_config_option *buflist_config_format_number; -extern char **buflist_config_sort_fields; -extern int buflist_config_sort_fields_count; +extern char **buflist_config_sort_fields[BUFLIST_BAR_NUM_ITEMS]; +extern int buflist_config_sort_fields_count[BUFLIST_BAR_NUM_ITEMS]; extern char *buflist_config_format_buffer_eval; extern char *buflist_config_format_buffer_current_eval; extern char *buflist_config_format_hotlist_eval; +extern void buflist_config_change_sort (const void *pointer, void *data, + struct t_config_option *option); extern int buflist_config_init (); extern int buflist_config_read (); extern int buflist_config_write (); diff --git a/src/plugins/buflist/buflist.c b/src/plugins/buflist/buflist.c index 31392f8b7..29c0b024c 100644 --- a/src/plugins/buflist/buflist.c +++ b/src/plugins/buflist/buflist.c @@ -221,25 +221,30 @@ int buflist_compare_buffers (void *data, struct t_arraylist *arraylist, void *pointer1, void *pointer2) { - int i, reverse, case_sensitive, rc; + int i, item_number, reverse, case_sensitive, rc; const char *ptr_field; struct t_gui_hotlist *ptr_hotlist1, *ptr_hotlist2; void *ptr_server1, *ptr_server2, *ptr_channel1, *ptr_channel2; struct t_hdata *hdata_irc_server, *hdata_irc_channel; + struct t_gui_bar_item *ptr_item; /* make C compiler happy */ - (void) data; (void) arraylist; + ptr_item = (struct t_gui_bar_item *)data; + item_number = buflist_bar_item_get_index_with_pointer (ptr_item); + if (item_number < 0) + item_number= 0; + hdata_irc_server = weechat_hdata_get ("irc_server"); hdata_irc_channel = weechat_hdata_get ("irc_channel"); - for (i = 0; i < buflist_config_sort_fields_count; i++) + for (i = 0; i < buflist_config_sort_fields_count[item_number]; i++) { rc = 0; reverse = 1; case_sensitive = 1; - ptr_field = buflist_config_sort_fields[i]; + ptr_field = buflist_config_sort_fields[item_number][i]; while ((ptr_field[0] == '-') || (ptr_field[0] == '~')) { if (ptr_field[0] == '-') @@ -337,13 +342,13 @@ buflist_compare_buffers (void *data, struct t_arraylist *arraylist, */ struct t_arraylist * -buflist_sort_buffers () +buflist_sort_buffers (struct t_gui_bar_item *item) { struct t_arraylist *buffers; struct t_gui_buffer *ptr_buffer; buffers = weechat_arraylist_new (128, 1, 1, - &buflist_compare_buffers, NULL, + &buflist_compare_buffers, item, NULL, NULL); ptr_buffer = weechat_hdata_get_list (buflist_hdata_buffer, "gui_buffers"); @@ -454,6 +459,8 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[]) if (!buflist_bar_item_init ()) return WEECHAT_RC_ERROR; + buflist_config_change_sort (NULL, NULL, NULL); + buflist_command_init (); if (weechat_config_boolean (buflist_config_look_enabled)) diff --git a/src/plugins/buflist/buflist.h b/src/plugins/buflist/buflist.h index 85577d40d..f13637de5 100644 --- a/src/plugins/buflist/buflist.h +++ b/src/plugins/buflist/buflist.h @@ -25,6 +25,8 @@ #define BUFLIST_BAR_NAME "buflist" +struct t_gui_bar_item; + extern struct t_weechat_plugin *weechat_buflist_plugin; extern struct t_hdata *buflist_hdata_window; @@ -38,6 +40,6 @@ extern void buflist_add_bar (); extern void buflist_buffer_get_irc_pointers (struct t_gui_buffer *buffer, void **irc_server, void **irc_channel); -extern struct t_arraylist *buflist_sort_buffers (); +extern struct t_arraylist *buflist_sort_buffers (struct t_gui_bar_item *item); #endif /* WEECHAT_PLUGIN_BUFLIST_H */