From 68d6f1b415c7d04949f8e3aa428cd1a486cf6f70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 25 Aug 2019 19:10:32 +0200 Subject: [PATCH] api: add infos "term_colors" and "term_color_pairs" --- ChangeLog.adoc | 1 + doc/de/autogen/plugin_api/infos.adoc | 4 +++ doc/en/autogen/plugin_api/infos.adoc | 4 +++ doc/fr/autogen/plugin_api/infos.adoc | 4 +++ doc/it/autogen/plugin_api/infos.adoc | 4 +++ doc/ja/autogen/plugin_api/infos.adoc | 4 +++ doc/pl/autogen/plugin_api/infos.adoc | 4 +++ po/cs.po | 10 +++++- po/de.po | 10 +++++- po/es.po | 10 +++++- po/fr.po | 10 ++++-- po/hu.po | 8 ++++- po/it.po | 10 +++++- po/ja.po | 10 +++++- po/pl.po | 10 +++++- po/pt.po | 10 +++++- po/pt_BR.po | 8 ++++- po/ru.po | 8 ++++- po/tr.po | 8 ++++- po/weechat.pot | 8 ++++- src/gui/curses/gui-curses-color.c | 10 ++++++ src/gui/gui-color.h | 1 + src/plugins/plugin-api-info.c | 48 ++++++++++++++++++++++++++++ 23 files changed, 190 insertions(+), 14 deletions(-) diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 45ff70188..382f429e4 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -22,6 +22,7 @@ New features:: * core: add support of 32767 color pairs (issue #1343, issue #1345) * core: add option "close" in command /window (issue #853) + * api: add infos "term_colors" and "term_color_pairs" * api: add function list_user_data (issue #666) * api: add argument "strip_items" in function string_split * buflist: add infolist "buflist" with list of buffer pointers (issue #1375) diff --git a/doc/de/autogen/plugin_api/infos.adoc b/doc/de/autogen/plugin_api/infos.adoc index 43b4ae7f3..b7c7e5b52 100644 --- a/doc/de/autogen/plugin_api/infos.adoc +++ b/doc/de/autogen/plugin_api/infos.adoc @@ -108,6 +108,10 @@ | weechat | pid | WeeChat PID (Prozess-ID) | - +| weechat | term_color_pairs | number of color pairs supported in terminal | - + +| weechat | term_colors | number of colors supported in terminal | - + | weechat | term_height | Höhe des Terminals | - | weechat | term_width | Breite des Terminals | - diff --git a/doc/en/autogen/plugin_api/infos.adoc b/doc/en/autogen/plugin_api/infos.adoc index eeec4d01f..2a0e777b0 100644 --- a/doc/en/autogen/plugin_api/infos.adoc +++ b/doc/en/autogen/plugin_api/infos.adoc @@ -108,6 +108,10 @@ | weechat | pid | WeeChat PID (process ID) | - +| weechat | term_color_pairs | number of color pairs supported in terminal | - + +| weechat | term_colors | number of colors supported in terminal | - + | weechat | term_height | height of terminal | - | weechat | term_width | width of terminal | - diff --git a/doc/fr/autogen/plugin_api/infos.adoc b/doc/fr/autogen/plugin_api/infos.adoc index 3d97d41c5..27d3f9ef7 100644 --- a/doc/fr/autogen/plugin_api/infos.adoc +++ b/doc/fr/autogen/plugin_api/infos.adoc @@ -108,6 +108,10 @@ | weechat | pid | PID (ID de processus) de WeeChat | - +| weechat | term_color_pairs | nombre de paires de couleurs supportées dans le terminal | - + +| weechat | term_colors | nombre de couleurs supportées dans le terminal | - + | weechat | term_height | hauteur du terminal | - | weechat | term_width | largeur du terminal | - diff --git a/doc/it/autogen/plugin_api/infos.adoc b/doc/it/autogen/plugin_api/infos.adoc index 0a01f09f6..d66ded0f0 100644 --- a/doc/it/autogen/plugin_api/infos.adoc +++ b/doc/it/autogen/plugin_api/infos.adoc @@ -108,6 +108,10 @@ | weechat | pid | WeeChat PID (process ID) | - +| weechat | term_color_pairs | number of color pairs supported in terminal | - + +| weechat | term_colors | number of colors supported in terminal | - + | weechat | term_height | height of terminal | - | weechat | term_width | width of terminal | - diff --git a/doc/ja/autogen/plugin_api/infos.adoc b/doc/ja/autogen/plugin_api/infos.adoc index 9e7972d3e..5a1151fd8 100644 --- a/doc/ja/autogen/plugin_api/infos.adoc +++ b/doc/ja/autogen/plugin_api/infos.adoc @@ -108,6 +108,10 @@ | weechat | pid | WeeChat の PID (プロセス ID) | - +| weechat | term_color_pairs | number of color pairs supported in terminal | - + +| weechat | term_colors | number of colors supported in terminal | - + | weechat | term_height | 端末の高さ | - | weechat | term_width | 端末の幅 | - diff --git a/doc/pl/autogen/plugin_api/infos.adoc b/doc/pl/autogen/plugin_api/infos.adoc index 1bde61e8e..fe3f8ccd9 100644 --- a/doc/pl/autogen/plugin_api/infos.adoc +++ b/doc/pl/autogen/plugin_api/infos.adoc @@ -108,6 +108,10 @@ | weechat | pid | WeeChat PID (ID procesu) | - +| weechat | term_color_pairs | number of color pairs supported in terminal | - + +| weechat | term_colors | number of colors supported in terminal | - + | weechat | term_height | wysokość terminala | - | weechat | term_width | szerokość terminala | - diff --git a/po/cs.po b/po/cs.po index 49d4e9c13..16dffd37d 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: 2019-08-24 07:05+0200\n" +"POT-Creation-Date: 2019-08-25 17:27+0200\n" "PO-Revision-Date: 2019-05-13 21:31+0200\n" "Last-Translator: Ondřej Súkup \n" "Language-Team: weechat-dev \n" @@ -10116,6 +10116,14 @@ msgstr "šířka terminálu" msgid "height of terminal" msgstr "výška terminálu" +#, fuzzy +msgid "number of colors supported in terminal" +msgstr "Terminál nepodporuje barvy." + +#, fuzzy +msgid "number of color pairs supported in terminal" +msgstr "Terminál nepodporuje barvy." + msgid "POSIX extended regular expression to search ANSI escape codes" msgstr "Rozšířené POSIX regulární výrazy k hledání ANSI escape kodů" diff --git a/po/de.po b/po/de.po index 7d5ccc011..351a9f619 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: 2019-08-24 07:05+0200\n" +"POT-Creation-Date: 2019-08-25 17:27+0200\n" "PO-Revision-Date: 2019-08-24 08:05+0200\n" "Last-Translator: Nils Görs \n" "Language-Team: German \n" @@ -11936,6 +11936,14 @@ msgstr "Breite des Terminals" msgid "height of terminal" msgstr "Höhe des Terminals" +#, fuzzy +msgid "number of colors supported in terminal" +msgstr "keine Farbunterstützung durch Terminal." + +#, fuzzy +msgid "number of color pairs supported in terminal" +msgstr "keine Farbunterstützung durch Terminal." + msgid "POSIX extended regular expression to search ANSI escape codes" msgstr "erweiterte reguläre POSIX Ausdrücke um ANSI Escapesequenz zu suchen" diff --git a/po/es.po b/po/es.po index 46ab768e6..d6f82f417 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: 2019-08-24 07:05+0200\n" +"POT-Creation-Date: 2019-08-25 17:27+0200\n" "PO-Revision-Date: 2019-05-13 21:31+0200\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -10429,6 +10429,14 @@ msgstr "" msgid "height of terminal" msgstr "" +#, fuzzy +msgid "number of colors supported in terminal" +msgstr "No hay soporte para color en la terminal." + +#, fuzzy +msgid "number of color pairs supported in terminal" +msgstr "No hay soporte para color en la terminal." + msgid "POSIX extended regular expression to search ANSI escape codes" msgstr "" diff --git a/po/fr.po b/po/fr.po index f3f2fc873..c9277fd05 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: 2019-08-24 07:05+0200\n" -"PO-Revision-Date: 2019-08-24 07:09+0200\n" +"POT-Creation-Date: 2019-08-25 17:27+0200\n" +"PO-Revision-Date: 2019-08-25 19:08+0200\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" "Language: fr\n" @@ -11664,6 +11664,12 @@ msgstr "largeur du terminal" msgid "height of terminal" msgstr "hauteur du terminal" +msgid "number of colors supported in terminal" +msgstr "nombre de couleurs supportées dans le terminal" + +msgid "number of color pairs supported in terminal" +msgstr "nombre de paires de couleurs supportées dans le terminal" + msgid "POSIX extended regular expression to search ANSI escape codes" msgstr "" "expression régulière POSIX étendue pour chercher les codes ANSI échappés" diff --git a/po/hu.po b/po/hu.po index 505e5acb4..6e268af3f 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: 2019-08-24 07:05+0200\n" +"POT-Creation-Date: 2019-08-25 17:27+0200\n" "PO-Revision-Date: 2019-05-13 21:31+0200\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -9479,6 +9479,12 @@ msgstr "" msgid "height of terminal" msgstr "" +msgid "number of colors supported in terminal" +msgstr "" + +msgid "number of color pairs supported in terminal" +msgstr "" + msgid "POSIX extended regular expression to search ANSI escape codes" msgstr "" diff --git a/po/it.po b/po/it.po index e6c9b67f6..8aaf00e2f 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: 2019-08-24 07:05+0200\n" +"POT-Creation-Date: 2019-08-25 17:27+0200\n" "PO-Revision-Date: 2019-05-13 21:31+0200\n" "Last-Translator: Esteban I. Ruiz Moreno \n" "Language-Team: weechat-dev \n" @@ -10611,6 +10611,14 @@ msgstr "" msgid "height of terminal" msgstr "" +#, fuzzy +msgid "number of colors supported in terminal" +msgstr "Nessun supporto al colore nel terminale." + +#, fuzzy +msgid "number of color pairs supported in terminal" +msgstr "Nessun supporto al colore nel terminale." + msgid "POSIX extended regular expression to search ANSI escape codes" msgstr "" diff --git a/po/ja.po b/po/ja.po index a68934ef3..ec3779e93 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: 2019-08-24 07:05+0200\n" +"POT-Creation-Date: 2019-08-25 17:27+0200\n" "PO-Revision-Date: 2019-06-22 08:40+0200\n" "Last-Translator: AYANOKOUZI, Ryuunosuke \n" "Language-Team: Japanese \n" "Language-Team: Polish \n" @@ -11402,6 +11402,14 @@ msgstr "szerokość terminala" msgid "height of terminal" msgstr "wysokość terminala" +#, fuzzy +msgid "number of colors supported in terminal" +msgstr "Brak wsparcia dla kolorów w terminalu." + +#, fuzzy +msgid "number of color pairs supported in terminal" +msgstr "Brak wsparcia dla kolorów w terminalu." + msgid "POSIX extended regular expression to search ANSI escape codes" msgstr "" "Rozszerzone wyrażenia regularne POSIX do wyszukiwania kodów escapującyhc ANSI" diff --git a/po/pt.po b/po/pt.po index 2659050bc..2083a9ccc 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: 2019-08-24 07:05+0200\n" +"POT-Creation-Date: 2019-08-25 17:27+0200\n" "PO-Revision-Date: 2019-05-13 21:32+0200\n" "Last-Translator: Vasco Almeida \n" "Language-Team: Portuguese <>\n" @@ -11074,6 +11074,14 @@ msgstr "largura do terminal" msgid "height of terminal" msgstr "altura do terminal" +#, fuzzy +msgid "number of colors supported in terminal" +msgstr "O terminal não tem suporte de cor." + +#, fuzzy +msgid "number of color pairs supported in terminal" +msgstr "O terminal não tem suporte de cor." + msgid "POSIX extended regular expression to search ANSI escape codes" msgstr "expressão regular POSIX estendida para procurar códigos de escape ANSI" diff --git a/po/pt_BR.po b/po/pt_BR.po index e76fac5bf..44ef4cfc3 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: 2019-08-24 07:05+0200\n" +"POT-Creation-Date: 2019-08-25 17:27+0200\n" "PO-Revision-Date: 2019-05-13 21:32+0200\n" "Last-Translator: Eduardo Elias \n" "Language-Team: weechat-dev \n" @@ -9919,6 +9919,12 @@ msgstr "largura do terminal" msgid "height of terminal" msgstr "altura do terminal" +msgid "number of colors supported in terminal" +msgstr "" + +msgid "number of color pairs supported in terminal" +msgstr "" + msgid "POSIX extended regular expression to search ANSI escape codes" msgstr "" diff --git a/po/ru.po b/po/ru.po index 5814c99d3..2c2eabb3a 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: 2019-08-24 07:05+0200\n" +"POT-Creation-Date: 2019-08-25 17:27+0200\n" "PO-Revision-Date: 2019-05-13 21:32+0200\n" "Last-Translator: Aleksey V Zapparov AKA ixti \n" "Language-Team: weechat-dev \n" @@ -9515,6 +9515,12 @@ msgstr "" msgid "height of terminal" msgstr "" +msgid "number of colors supported in terminal" +msgstr "" + +msgid "number of color pairs supported in terminal" +msgstr "" + msgid "POSIX extended regular expression to search ANSI escape codes" msgstr "" diff --git a/po/tr.po b/po/tr.po index 314724ea6..18a191231 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: 2019-08-24 07:05+0200\n" +"POT-Creation-Date: 2019-08-25 17:27+0200\n" "PO-Revision-Date: 2019-05-13 21:32+0200\n" "Last-Translator: Hasan Kiran \n" "Language-Team: weechat-dev \n" @@ -8645,6 +8645,12 @@ msgstr "" msgid "height of terminal" msgstr "" +msgid "number of colors supported in terminal" +msgstr "" + +msgid "number of color pairs supported in terminal" +msgstr "" + msgid "POSIX extended regular expression to search ANSI escape codes" msgstr "" diff --git a/po/weechat.pot b/po/weechat.pot index 9934006e7..0f6e7fc72 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: 2019-08-24 07:05+0200\n" +"POT-Creation-Date: 2019-08-25 17:27+0200\n" "PO-Revision-Date: 2014-08-16 10:27+0200\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" @@ -8508,6 +8508,12 @@ msgstr "" msgid "height of terminal" msgstr "" +msgid "number of colors supported in terminal" +msgstr "" + +msgid "number of color pairs supported in terminal" +msgstr "" + msgid "POSIX extended regular expression to search ANSI escape codes" msgstr "" diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c index f62b8a047..bc6118d95 100644 --- a/src/gui/curses/gui-curses-color.c +++ b/src/gui/curses/gui-curses-color.c @@ -285,6 +285,16 @@ gui_color_get_term_colors () return gui_color_term_colors; } +/* + * Gets number of color pairs supported by terminal. + */ + +int +gui_color_get_term_color_pairs () +{ + return gui_color_term_color_pairs; +} + /* * Gets current pairs as arrays (one array for foregrounds, another for * backgrounds). diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h index 7045b9c73..90d8d6b30 100644 --- a/src/gui/gui-color.h +++ b/src/gui/gui-color.h @@ -207,6 +207,7 @@ extern int gui_color_assign_by_diff (int *color, const char *color_name, int diff); extern int gui_color_get_weechat_colors_number (); extern int gui_color_get_term_colors (); +extern int gui_color_get_term_color_pairs (); extern const char *gui_color_get_name (int num_color); extern void gui_color_free_vars (); extern void gui_color_init_weechat (); diff --git a/src/plugins/plugin-api-info.c b/src/plugins/plugin-api-info.c index dfab31033..d0fe9c66f 100644 --- a/src/plugins/plugin-api-info.c +++ b/src/plugins/plugin-api-info.c @@ -484,6 +484,48 @@ plugin_api_info_term_height_cb (const void *pointer, void *data, return strdup (value); } +/* + * Returns WeeChat info "term_colors". + */ + +char * +plugin_api_info_term_colors_cb (const void *pointer, void *data, + const char *info_name, + const char *arguments) +{ + char value[32]; + + /* make C compiler happy */ + (void) pointer; + (void) data; + (void) info_name; + (void) arguments; + + snprintf (value, sizeof (value), "%d", gui_color_get_term_colors ()); + return strdup (value); +} + +/* + * Returns WeeChat info "term_color_pairs". + */ + +char * +plugin_api_info_term_color_pairs_cb (const void *pointer, void *data, + const char *info_name, + const char *arguments) +{ + char value[32]; + + /* make C compiler happy */ + (void) pointer; + (void) data; + (void) info_name; + (void) arguments; + + snprintf (value, sizeof (value), "%d", gui_color_get_term_color_pairs ()); + return strdup (value); +} + /* * Returns WeeChat info "color_ansi_regex". */ @@ -1718,6 +1760,12 @@ plugin_api_info_init () hook_info (NULL, "term_height", N_("height of terminal"), NULL, &plugin_api_info_term_height_cb, NULL, NULL); + hook_info (NULL, "term_colors", + N_("number of colors supported in terminal"), + NULL, &plugin_api_info_term_colors_cb, NULL, NULL); + hook_info (NULL, "term_color_pairs", + N_("number of color pairs supported in terminal"), + NULL, &plugin_api_info_term_color_pairs_cb, NULL, NULL); hook_info (NULL, "color_ansi_regex", N_("POSIX extended regular expression to search ANSI escape " "codes"),