diff --git a/doc/de/autogen/user/weechat_options.txt b/doc/de/autogen/user/weechat_options.txt index 2db81d8..f1870f5 100644 --- a/doc/de/autogen/user/weechat_options.txt +++ b/doc/de/autogen/user/weechat_options.txt @@ -598,6 +598,16 @@ ** Typ: integer ** Werte: 1 .. 2147483647 (Standardwert: `30`) +* *weechat.palette.180* +** Beschreibung: `couleur personnalisée dans la palette, le format est: "alias;fg,bg;r/g/b" où alias est le nom de la couleur, fg,bg est "texte,fond" (par exemple: "200,-1"), r/g/b est la redéfinition de la couleur (le terminal doit le supporter) (tout est optionnel dans ce format)` +** Typ: Zeichenkette +** Werte: beliebige Zeichenkette (Standardwert: `""`) + +* *weechat.palette.215* +** Beschreibung: `couleur personnalisée dans la palette, le format est: "alias;fg,bg;r/g/b" où alias est le nom de la couleur, fg,bg est "texte,fond" (par exemple: "200,-1"), r/g/b est la redéfinition de la couleur (le terminal doit le supporter) (tout est optionnel dans ce format)` +** Typ: Zeichenkette +** Werte: beliebige Zeichenkette (Standardwert: `""`) + * *weechat.plugin.autoload* ** Beschreibung: `Eine durch Kommata getrennte Liste der Erweiterungen die beim Programmstart automatisch geladen werden sollen, "*" lädt alle gefundenen Erweiterungen. Beginnt der Name hingegen mit "!" wird die Erweiterung nicht geladen. Suchmuster können mit einem Joker ("*") beginnen oder enden um mehrere Erweiterungen zu laden (Beispiele: "*" oder "*,!lua,!tcl")` ** Typ: Zeichenkette diff --git a/doc/de/weechat_user.de.txt b/doc/de/weechat_user.de.txt index 77d5be5..64d27fb 100644 --- a/doc/de/weechat_user.de.txt +++ b/doc/de/weechat_user.de.txt @@ -281,6 +281,10 @@ Befehlszeile: -a, --no-connect:: deaktiviert das automatische Verbinden mit den Servern beim Start von WeeChat +// TRANSLATION MISSING +-c, --colors:: + Display default colors in terminal + -d, --dir 'path':: legt den Konfigurationsordner für WeeChat fest (Voreinstellung: ~/.weechat) in dem die Erweiterungen, Skripten, Protokolldateien etc.pp. gesichert werden. diff --git a/doc/en/autogen/user/weechat_options.txt b/doc/en/autogen/user/weechat_options.txt index 7814c45..e4a84c8 100644 --- a/doc/en/autogen/user/weechat_options.txt +++ b/doc/en/autogen/user/weechat_options.txt @@ -598,6 +598,16 @@ ** type: integer ** values: 1 .. 2147483647 (default value: `30`) +* *weechat.palette.180* +** description: `couleur personnalisée dans la palette, le format est: "alias;fg,bg;r/g/b" où alias est le nom de la couleur, fg,bg est "texte,fond" (par exemple: "200,-1"), r/g/b est la redéfinition de la couleur (le terminal doit le supporter) (tout est optionnel dans ce format)` +** type: string +** values: any string (default value: `""`) + +* *weechat.palette.215* +** description: `couleur personnalisée dans la palette, le format est: "alias;fg,bg;r/g/b" où alias est le nom de la couleur, fg,bg est "texte,fond" (par exemple: "200,-1"), r/g/b est la redéfinition de la couleur (le terminal doit le supporter) (tout est optionnel dans ce format)` +** type: string +** values: any string (default value: `""`) + * *weechat.plugin.autoload* ** description: `comma separated list of plugins to load automatically at startup, "*" means all plugins found, a name beginning with "!" is a negative value to prevent a plugin from being loaded, names can start or end with "*" to match several plugins (examples: "*" or "*,!lua,!tcl")` ** type: string diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt index 129ce8f..2753503 100644 --- a/doc/en/weechat_plugin_api.en.txt +++ b/doc/en/weechat_plugin_api.en.txt @@ -2474,6 +2474,48 @@ item = weechat.list_search(list, data) item = weechat.list_search(list, "my data") ---------------------------------------- +weechat_list_search_pos +^^^^^^^^^^^^^^^^^^^^^^^ + +_New in version 0.3.4._ + +Search an item position in a list. + +Prototype: + +[source,C] +---------------------------------------- +int weechat_list_search_pos (struct t_weelist *weelist, + const char *data); +---------------------------------------- + +Arguments: + +* 'weelist': list pointer +* 'data': data to search in list + +Return value: + +* position of item found, -1 if item was not found + +C example: + +[source,C] +---------------------------------------- +int pos_item = weechat_list_search_pos (list, "my data"); +---------------------------------------- + +Script (Python): + +[source,python] +---------------------------------------- +# prototype +pos_item = weechat.list_search_pos(list, data) + +# example +pos_item = weechat.list_search_pos(list, "my data") +---------------------------------------- + weechat_list_casesearch ^^^^^^^^^^^^^^^^^^^^^^^ @@ -2514,6 +2556,48 @@ item = weechat.list_casesearch(list, data) item = weechat.list_casesearch(list, "my data") ---------------------------------------- +weechat_list_casesearch_pos +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +_New in version 0.3.4._ + +Search an item position in a list, ignoring case. + +Prototype: + +[source,C] +---------------------------------------- +int weechat_list_casesearch_pos (struct t_weelist *weelist, + const char *data); +---------------------------------------- + +Arguments: + +* 'weelist': list pointer +* 'data': data to search in list + +Return value: + +* position of item found, -1 if item was not found + +C example: + +[source,C] +---------------------------------------- +int pos_item = weechat_list_casesearch_pos (list, "my data"); +---------------------------------------- + +Script (Python): + +[source,python] +---------------------------------------- +# prototype +pos_item = weechat.list_casesearch_pos(list, data) + +# example +pos_item = weechat.list_casesearch_pos(list, "my data") +---------------------------------------- + weechat_list_get ^^^^^^^^^^^^^^^^ diff --git a/doc/en/weechat_user.en.txt b/doc/en/weechat_user.en.txt index bd47d40..f8c9e3f 100644 --- a/doc/en/weechat_user.en.txt +++ b/doc/en/weechat_user.en.txt @@ -283,6 +283,9 @@ Command line arguments: -a, --no-connect:: Disable auto-connect to servers when WeeChat is starting +-c, --colors:: + Display default colors in terminal + -d, --dir 'path':: Set path as home for WeeChat (used for configuration files, logs, user plugins and scripts), default value is '~/.weechat' (note: directory is diff --git a/doc/fr/autogen/user/weechat_options.txt b/doc/fr/autogen/user/weechat_options.txt index a3529ea..40198b7 100644 --- a/doc/fr/autogen/user/weechat_options.txt +++ b/doc/fr/autogen/user/weechat_options.txt @@ -598,6 +598,16 @@ ** type: entier ** valeurs: 1 .. 2147483647 (valeur par défaut: `30`) +* *weechat.palette.180* +** description: `couleur personnalisée dans la palette, le format est: "alias;fg,bg;r/g/b" où alias est le nom de la couleur, fg,bg est "texte,fond" (par exemple: "200,-1"), r/g/b est la redéfinition de la couleur (le terminal doit le supporter) (tout est optionnel dans ce format)` +** type: chaîne +** valeurs: toute chaîne (valeur par défaut: `""`) + +* *weechat.palette.215* +** description: `couleur personnalisée dans la palette, le format est: "alias;fg,bg;r/g/b" où alias est le nom de la couleur, fg,bg est "texte,fond" (par exemple: "200,-1"), r/g/b est la redéfinition de la couleur (le terminal doit le supporter) (tout est optionnel dans ce format)` +** type: chaîne +** valeurs: toute chaîne (valeur par défaut: `""`) + * *weechat.plugin.autoload* ** description: `liste des extensions à charger automatiquement au démarrage (séparées par des virgules), "*" signifie toutes les extensions trouvées, un nom commençant par "!" est une valeur négative pour empêcher une extension d'être chargée, les noms peuvent commencer ou se terminer par "*" pour indiquer plusieurs extensions (exemples: "*" ou "*,!lua,!tcl")` ** type: chaîne diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt index 8000962..9f65d2f 100644 --- a/doc/fr/weechat_plugin_api.fr.txt +++ b/doc/fr/weechat_plugin_api.fr.txt @@ -2501,6 +2501,48 @@ item = weechat.list_search(list, data) item = weechat.list_search(list, "ma donnée") ---------------------------------------- +weechat_list_search_pos +^^^^^^^^^^^^^^^^^^^^^^^ + +_Nouveau dans la version 0.3.4._ + +Recherche la position d'un élément dans une liste. + +Prototype : + +[source,C] +---------------------------------------- +int weechat_list_search_pos (struct t_weelist *weelist, + const char *data); +---------------------------------------- + +Paramètres : + +* 'weelist' : pointeur vers la liste +* 'data' : donnée à chercher dans la liste + +Valeur de retour : + +* position de l'élément trouvé, -1 si aucun élément n'a été trouvé + +Exemple en C : + +[source,C] +---------------------------------------- +int pos_item = weechat_list_search_pos (list, "ma donnée"); +---------------------------------------- + +Script (Python) : + +[source,python] +---------------------------------------- +# prototype +pos_item = weechat.list_search_pos(list, data) + +# exemple +pos_item = weechat.list_search_pos(list, "ma donnée") +---------------------------------------- + weechat_list_casesearch ^^^^^^^^^^^^^^^^^^^^^^^ @@ -2541,6 +2583,48 @@ item = weechat.list_casesearch(list, data) item = weechat.list_casesearch(list, "ma donnée") ---------------------------------------- +weechat_list_casesearch_pos +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +_Nouveau dans la version 0.3.4._ + +Recherche la position d'un élément dans la liste, sans tenir compte de la casse. + +Prototype : + +[source,C] +---------------------------------------- +int weechat_list_casesearch_pos (struct t_weelist *weelist, + const char *data); +---------------------------------------- + +Paramètres : + +* 'weelist' : pointeur vers la liste +* 'data' : données à chercher dans la liste + +Valeur de retour : + +* position l'élément trouvé, -1 si aucun élément n'a été trouvé + +Exemple en C : + +[source,C] +---------------------------------------- +int pos_item = weechat_list_casesearch_pos (list, "ma donnée"); +---------------------------------------- + +Script (Python) : + +[source,python] +---------------------------------------- +# prototype +pos_item = weechat.list_casesearch_pos(list, data) + +# exemple +pos_item = weechat.list_casesearch_pos(list, "ma donnée") +---------------------------------------- + weechat_list_get ^^^^^^^^^^^^^^^^ diff --git a/doc/fr/weechat_user.fr.txt b/doc/fr/weechat_user.fr.txt index ec35c7a..7c62211 100644 --- a/doc/fr/weechat_user.fr.txt +++ b/doc/fr/weechat_user.fr.txt @@ -289,6 +289,9 @@ Paramètres de ligne de commande : -a, --no-connect:: Supprimer la connexion automatique aux serveurs lors du démarrage +-c, --colors:: + Afficher les couleurs par défaut du terminal + -d, --dir 'path':: Définir le répertoire comme étant la base de WeeChat (utilisé pour les fichiers de configuration, logs, extensions diff --git a/doc/it/autogen/user/weechat_options.txt b/doc/it/autogen/user/weechat_options.txt index 943c5c6..7d6a5c1 100644 --- a/doc/it/autogen/user/weechat_options.txt +++ b/doc/it/autogen/user/weechat_options.txt @@ -598,6 +598,16 @@ ** tipo: intero ** valori: 1 .. 2147483647 (valore predefinito: `30`) +* *weechat.palette.180* +** descrizione: `couleur personnalisée dans la palette, le format est: "alias;fg,bg;r/g/b" où alias est le nom de la couleur, fg,bg est "texte,fond" (par exemple: "200,-1"), r/g/b est la redéfinition de la couleur (le terminal doit le supporter) (tout est optionnel dans ce format)` +** tipo: stringa +** valori: qualsiasi stringa (valore predefinito: `""`) + +* *weechat.palette.215* +** descrizione: `couleur personnalisée dans la palette, le format est: "alias;fg,bg;r/g/b" où alias est le nom de la couleur, fg,bg est "texte,fond" (par exemple: "200,-1"), r/g/b est la redéfinition de la couleur (le terminal doit le supporter) (tout est optionnel dans ce format)` +** tipo: stringa +** valori: qualsiasi stringa (valore predefinito: `""`) + * *weechat.plugin.autoload* ** descrizione: `elenco separato da virgole di plugin da caricare automaticamente all'avvio, "*" equivale a tutti i plugin trovati. un nome che comincia con "!" è un valore negativo per impedire il caricamento di un plugin, i nomi possono iniziare o finire con "*" per corrispondere a più plugin (esempi: "*" oppure "*,!lua,!tcl")` ** tipo: stringa diff --git a/doc/it/weechat_plugin_api.it.txt b/doc/it/weechat_plugin_api.it.txt index 79dbd6e..377898d 100644 --- a/doc/it/weechat_plugin_api.it.txt +++ b/doc/it/weechat_plugin_api.it.txt @@ -2461,6 +2461,49 @@ item = weechat.list_search(list, data) item = weechat.list_search(list, "my data") ---------------------------------------- +// TRANSLATION MISSING +weechat_list_search_pos +^^^^^^^^^^^^^^^^^^^^^^^ + +_New in version 0.3.4._ + +Search an item position in a list. + +Prototype: + +[source,C] +---------------------------------------- +int weechat_list_search_pos (struct t_weelist *weelist, + const char *data); +---------------------------------------- + +Arguments: + +* 'weelist': list pointer +* 'data': data to search in list + +Return value: + +* position of item found, -1 if item was not found + +C example: + +[source,C] +---------------------------------------- +int pos_item = weechat_list_search_pos (list, "my data"); +---------------------------------------- + +Script (Python): + +[source,python] +---------------------------------------- +# prototype +pos_item = weechat.list_search_pos(list, data) + +# example +pos_item = weechat.list_search_pos(list, "my data") +---------------------------------------- + weechat_list_casesearch ^^^^^^^^^^^^^^^^^^^^^^^ @@ -2502,6 +2545,49 @@ item = weechat.list_casesearch(list, data) item = weechat.list_casesearch(list, "my data") ---------------------------------------- +// TRANSLATION MISSING +weechat_list_casesearch_pos +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +_New in version 0.3.4._ + +Search an item position in a list, ignoring case. + +Prototype: + +[source,C] +---------------------------------------- +int weechat_list_casesearch_pos (struct t_weelist *weelist, + const char *data); +---------------------------------------- + +Arguments: + +* 'weelist': list pointer +* 'data': data to search in list + +Return value: + +* position of item found, -1 if item was not found + +C example: + +[source,C] +---------------------------------------- +int pos_item = weechat_list_casesearch_pos (list, "my data"); +---------------------------------------- + +Script (Python): + +[source,python] +---------------------------------------- +# prototype +pos_item = weechat.list_casesearch_pos(list, data) + +# example +pos_item = weechat.list_casesearch_pos(list, "my data") +---------------------------------------- + weechat_list_get ^^^^^^^^^^^^^^^^ diff --git a/doc/it/weechat_user.it.txt b/doc/it/weechat_user.it.txt index 4a6f480..a58227e 100644 --- a/doc/it/weechat_user.it.txt +++ b/doc/it/weechat_user.it.txt @@ -290,6 +290,10 @@ Argomenti a riga di comando: -a, --no-connect:: Disabilita la connessione automatica ai server all'avvio di WeeChat +// TRANSLATION MISSING +-c, --colors:: + Display default colors in terminal + -d, --dir 'path':: Imposta una cartella come home per WeeChat (utilizzata per i file di configurazione, log, plugin e script dell'utente), il valore predefinito diff --git a/doc/weechat-curses.1 b/doc/weechat-curses.1 index 99fba44..e556508 100644 --- a/doc/weechat-curses.1 +++ b/doc/weechat-curses.1 @@ -23,6 +23,10 @@ It is compliant with IRC RFCs 1459, 2810, 2811, 2812, and 2813. .br disable auto-connect to servers at startup .TP +.B \-c, \-\-colors +.br +display default colors in terminal +.TP .B \-d, \-\-dir .br set WeeChat home dir diff --git a/po/cs.po b/po/cs.po index 761abdb..c713f7c 100644 --- a/po/cs.po +++ b/po/cs.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-12-09 22:59+0100\n" +"POT-Creation-Date: 2010-12-19 19:54+0100\n" "PO-Revision-Date: 2010-11-06 11:55+0100\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -43,8 +43,10 @@ msgstr "" msgid "Usage: %s [option...] [plugin:option...]\n" msgstr "Použití: %s [volba...] [plugin:volba...]\n" +#, fuzzy msgid "" " -a, --no-connect disable auto-connect to servers at startup\n" +" -c, --colors display default colors in terminal\n" " -d, --dir set WeeChat home directory (default: ~/.weechat)\n" " -h, --help this help\n" " -k, --keys display WeeChat default keys\n" @@ -1760,6 +1762,17 @@ msgstr "\t\tZměnil se den na %s" msgid "debug level for plugin (\"core\" for WeeChat core)" msgstr "úroveň ladění pro plugin (\"core\" pro jádro WeeChat)" +msgid "" +"custom color in palette, format is: \"alias;fg,bg;r/g/b\" where alias is " +"color name, fg,bg is \"foreground,background\" (example: \"200,-1\"), r/g/b " +"is redefinition of color (terminal must support it) (everything is optional " +"in this format)" +msgstr "" + +#, fuzzy, c-format +msgid "%sError: palette option must be numeric" +msgstr "%sChyba: selhalo uložení voleb do %s" + msgid "Notify level for buffer" msgstr "Úroveň upozornění pro buffer" @@ -2527,6 +2540,16 @@ msgstr "" "čtení - špatný podpis (formát aktualizačního souboru se mohl změnit od " "poslední verze)" +msgid "Terminal infos:" +msgstr "Informace o terminálu:" + +msgid "No color support in terminal." +msgstr "" + +#, fuzzy +msgid "Default colors:" +msgstr "Výchozí klávesové zkratky obnoveny" + msgid "Terminal lost, exiting WeeChat..." msgstr "Terminál ztracen, ukončuji WeeChat..." @@ -2537,9 +2560,6 @@ msgstr "Obdržen signál %s, ukončuji WeeChat.." msgid "Signal SIGHUP received, reloading configuration files" msgstr "Obdržen signál SIGHUP, znovunačítám konfigurační soubory" -msgid "Terminal infos:" -msgstr "Informace o terminálu:" - #, c-format msgid " TERM='%s', size: %dx%d" msgstr " TERM='%s', velikost: %dx%d" diff --git a/po/de.po b/po/de.po index 20b0d52..4a4d3bd 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-12-09 22:59+0100\n" +"POT-Creation-Date: 2010-12-19 19:54+0100\n" "PO-Revision-Date: 2010-12-07 23:21+0100\n" "Last-Translator: Nils G.\n" "Language-Team: weechat-dev \n" @@ -47,8 +47,10 @@ msgstr "" msgid "Usage: %s [option...] [plugin:option...]\n" msgstr "Aufruf: %s [Option...] [Erweiterung:Option...]\n" +#, fuzzy msgid "" " -a, --no-connect disable auto-connect to servers at startup\n" +" -c, --colors display default colors in terminal\n" " -d, --dir set WeeChat home directory (default: ~/.weechat)\n" " -h, --help this help\n" " -k, --keys display WeeChat default keys\n" @@ -1819,6 +1821,17 @@ msgstr "\t\tEin neuer Tag bricht an. Heute ist %s" msgid "debug level for plugin (\"core\" for WeeChat core)" msgstr "Debug-Level für Erweiterung (\"core\" für den WeeChat Core)" +msgid "" +"custom color in palette, format is: \"alias;fg,bg;r/g/b\" where alias is " +"color name, fg,bg is \"foreground,background\" (example: \"200,-1\"), r/g/b " +"is redefinition of color (terminal must support it) (everything is optional " +"in this format)" +msgstr "" + +#, fuzzy, c-format +msgid "%sError: palette option must be numeric" +msgstr "%sFehler: Optionen konnten nicht unter %s gesichert werden" + msgid "Notify level for buffer" msgstr "Benachrichtigungsstufe für Buffer" @@ -2637,6 +2650,16 @@ msgstr "" "lese - falsche Signatur (das Dateiformat wurde vermutlich seit der letzten " "Version verändern)" +msgid "Terminal infos:" +msgstr "Terminal Informationen:" + +msgid "No color support in terminal." +msgstr "" + +#, fuzzy +msgid "Default colors:" +msgstr "Standard rmodifier:" + msgid "Terminal lost, exiting WeeChat..." msgstr "Terminal verloren, beende WeeChat..." @@ -2647,9 +2670,6 @@ msgstr "Signal %s empfangen, beende WeeChat..." msgid "Signal SIGHUP received, reloading configuration files" msgstr "Signal SIGHUP empfangen, lese Konfigurationsdateien neu" -msgid "Terminal infos:" -msgstr "Terminal Informationen:" - #, c-format msgid " TERM='%s', size: %dx%d" msgstr " TERM='%s', Größe: %dx%d" diff --git a/po/es.po b/po/es.po index 858f177..8f3c603 100644 --- a/po/es.po +++ b/po/es.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-12-09 22:59+0100\n" +"POT-Creation-Date: 2010-12-19 19:54+0100\n" "PO-Revision-Date: 2010-11-06 11:56+0100\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -44,8 +44,10 @@ msgstr "" msgid "Usage: %s [option...] [plugin:option...]\n" msgstr "Uso: %s [opción...] [plugin:opción...]\n" +#, fuzzy msgid "" " -a, --no-connect disable auto-connect to servers at startup\n" +" -c, --colors display default colors in terminal\n" " -d, --dir set WeeChat home directory (default: ~/.weechat)\n" " -h, --help this help\n" " -k, --keys display WeeChat default keys\n" @@ -1773,6 +1775,17 @@ msgstr "\t\tNuevo día, %s" msgid "debug level for plugin (\"core\" for WeeChat core)" msgstr "nivel de depurado para el plugin (\"core\" para el núcleo de WeeChat)" +msgid "" +"custom color in palette, format is: \"alias;fg,bg;r/g/b\" where alias is " +"color name, fg,bg is \"foreground,background\" (example: \"200,-1\"), r/g/b " +"is redefinition of color (terminal must support it) (everything is optional " +"in this format)" +msgstr "" + +#, fuzzy, c-format +msgid "%sError: palette option must be numeric" +msgstr "%sError: no se pudo guardar las opciones en %s" + msgid "Notify level for buffer" msgstr "Nivel de notificación para el buffer" @@ -2560,6 +2573,16 @@ msgstr "" "lectura - firma incorrecta (el formato del archivo de actualización puede " "haber cambiado desde la última versión)" +msgid "Terminal infos:" +msgstr "Información de la terminal:" + +msgid "No color support in terminal." +msgstr "" + +#, fuzzy +msgid "Default colors:" +msgstr "Atajos predefinidos restaurados" + msgid "Terminal lost, exiting WeeChat..." msgstr "Se perdió la terminal, cerrando WeeChat..." @@ -2570,9 +2593,6 @@ msgstr "Señal %s recibida, cerrando WeeChat..." msgid "Signal SIGHUP received, reloading configuration files" msgstr "Señal SIGHUP recibida, recargando archivos de configuración" -msgid "Terminal infos:" -msgstr "Información de la terminal:" - #, c-format msgid " TERM='%s', size: %dx%d" msgstr " TERM='%s', tamaño: %dx%d" diff --git a/po/fr.po b/po/fr.po index d831e3e..0f0e297 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-12-09 22:59+0100\n" -"PO-Revision-Date: 2010-12-09 20:22+0100\n" +"POT-Creation-Date: 2010-12-19 19:54+0100\n" +"PO-Revision-Date: 2010-12-19 19:54+0100\n" "Last-Translator: Sebastien Helleu \n" "Language-Team: weechat-dev \n" "Language: French\n" @@ -46,6 +46,7 @@ msgstr "Utilisation: %s [option...] [extension:option...]\n" msgid "" " -a, --no-connect disable auto-connect to servers at startup\n" +" -c, --colors display default colors in terminal\n" " -d, --dir set WeeChat home directory (default: ~/.weechat)\n" " -h, --help this help\n" " -k, --keys display WeeChat default keys\n" @@ -62,6 +63,7 @@ msgid "" " about possible options)\n" msgstr "" " -a, --no-connect désactiver l'auto-connexion aux serveurs au démarrage\n" +" -c, --colors afficher les couleurs par défaut du terminal\n" " -d, --dir définir le répertoire de base pour WeeChat (défaut: ~/." "weechat)\n" " -h, --help cette aide\n" @@ -1789,6 +1791,21 @@ msgstr "\t\tJour changé: %s" msgid "debug level for plugin (\"core\" for WeeChat core)" msgstr "niveau de debug pour l'extension (\"core\" pour le coeur de WeeChat)" +msgid "" +"custom color in palette, format is: \"alias;fg,bg;r/g/b\" where alias is " +"color name, fg,bg is \"foreground,background\" (example: \"200,-1\"), r/g/b " +"is redefinition of color (terminal must support it) (everything is optional " +"in this format)" +msgstr "" +"couleur personnalisée dans la palette, le format est: \"alias;fg,bg;r/g/b\" " +"où alias est le nom de la couleur, fg,bg est \"texte,fond\" (par exemple: " +"\"200,-1\"), r/g/b est la redéfinition de la couleur (le terminal doit le " +"supporter) (tout est optionnel dans ce format)" + +#, c-format +msgid "%sError: palette option must be numeric" +msgstr "%sErreur: l'option de palette doit être numérique" + msgid "Notify level for buffer" msgstr "Niveau de notification pour le tampon" @@ -2598,6 +2615,15 @@ msgstr "" "lecture - mauvaise signature (le format de fichier upgrade a peut-être " "changé depuis la dernière version)" +msgid "Terminal infos:" +msgstr "Infos sur le terminal:" + +msgid "No color support in terminal." +msgstr "Pas de support pour la couleur dans le terminal." + +msgid "Default colors:" +msgstr "Couleurs par défaut:" + msgid "Terminal lost, exiting WeeChat..." msgstr "Terminal perdu, sortie de WeeChat..." @@ -2608,9 +2634,6 @@ msgstr "Signal %s reçu, sortie de WeeChat..." msgid "Signal SIGHUP received, reloading configuration files" msgstr "Signal SIGHUP reçu, rechargement des fichiers de configuration" -msgid "Terminal infos:" -msgstr "Infos sur le terminal:" - #, c-format msgid " TERM='%s', size: %dx%d" msgstr " TERM='%s', taille: %dx%d" diff --git a/po/hu.po b/po/hu.po index da46923..f37e91c 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-12-09 22:59+0100\n" +"POT-Creation-Date: 2010-12-19 19:54+0100\n" "PO-Revision-Date: 2010-11-05 17:17+0100\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -46,6 +46,7 @@ msgstr "" #, fuzzy msgid "" " -a, --no-connect disable auto-connect to servers at startup\n" +" -c, --colors display default colors in terminal\n" " -d, --dir set WeeChat home directory (default: ~/.weechat)\n" " -h, --help this help\n" " -k, --keys display WeeChat default keys\n" @@ -1584,6 +1585,17 @@ msgstr "A mai dátum: %s\n" msgid "debug level for plugin (\"core\" for WeeChat core)" msgstr "" +msgid "" +"custom color in palette, format is: \"alias;fg,bg;r/g/b\" where alias is " +"color name, fg,bg is \"foreground,background\" (example: \"200,-1\"), r/g/b " +"is redefinition of color (terminal must support it) (everything is optional " +"in this format)" +msgstr "" + +#, fuzzy, c-format +msgid "%sError: palette option must be numeric" +msgstr "%s nem sikerült a modul opciókat elmenteni\n" + #, fuzzy msgid "Notify level for buffer" msgstr "szobanév nem található a pufferhez" @@ -2364,6 +2376,16 @@ msgid "" "version)" msgstr "" +msgid "Terminal infos:" +msgstr "" + +msgid "No color support in terminal." +msgstr "" + +#, fuzzy +msgid "Default colors:" +msgstr "Alapértelmezett billentyűparancsok visszaállítva\n" + msgid "Terminal lost, exiting WeeChat..." msgstr "" @@ -2375,9 +2397,6 @@ msgstr "" msgid "Signal SIGHUP received, reloading configuration files" msgstr "%s nem sikerült a konfigurációs fájlt elmenteni\n" -msgid "Terminal infos:" -msgstr "" - #, c-format msgid " TERM='%s', size: %dx%d" msgstr "" diff --git a/po/it.po b/po/it.po index 28e4a1b..5c33612 100644 --- a/po/it.po +++ b/po/it.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-12-11 12:39+0100\n" +"POT-Creation-Date: 2010-12-19 19:54+0100\n" "PO-Revision-Date: 2010-12-10 14:11+0100\n" "Last-Translator: Marco Paolone \n" "Language-Team: weechat-dev \n" @@ -43,8 +43,10 @@ msgstr "" msgid "Usage: %s [option...] [plugin:option...]\n" msgstr "Utilizzo: %s [opzione...] [plugin:opzione...]\n" +#, fuzzy msgid "" " -a, --no-connect disable auto-connect to servers at startup\n" +" -c, --colors display default colors in terminal\n" " -d, --dir set WeeChat home directory (default: ~/.weechat)\n" " -h, --help this help\n" " -k, --keys display WeeChat default keys\n" @@ -1780,6 +1782,17 @@ msgstr "\t\tOggi è %s" msgid "debug level for plugin (\"core\" for WeeChat core)" msgstr "livello di debug per il plugin (\"core\" per il core di WeeChat)" +msgid "" +"custom color in palette, format is: \"alias;fg,bg;r/g/b\" where alias is " +"color name, fg,bg is \"foreground,background\" (example: \"200,-1\"), r/g/b " +"is redefinition of color (terminal must support it) (everything is optional " +"in this format)" +msgstr "" + +#, fuzzy, c-format +msgid "%sError: palette option must be numeric" +msgstr "%sErrore: impossibile salvare le opzioni in %s" + msgid "Notify level for buffer" msgstr "Livello di notifica per il buffer" @@ -2574,6 +2587,16 @@ msgstr "" "lettura - firma errata (l'aggiornamento del formato del file potrebbe essere " "cambiato dall'ultima versione)" +msgid "Terminal infos:" +msgstr "Informazioni sul terminale:" + +msgid "No color support in terminal." +msgstr "" + +#, fuzzy +msgid "Default colors:" +msgstr "Rmodifier predefiniti:" + msgid "Terminal lost, exiting WeeChat..." msgstr "Terminale perduto, chiusura di WeeChat..." @@ -2584,9 +2607,6 @@ msgstr "Ricevuto segnale %s, chiusura di WeeChat..." msgid "Signal SIGHUP received, reloading configuration files" msgstr "Ricevuto segnale SIGHUP, caricamento dei file di configurazione" -msgid "Terminal infos:" -msgstr "Informazioni sul terminale:" - #, c-format msgid " TERM='%s', size: %dx%d" msgstr " TERM='%s', dimensione %dx%d" diff --git a/po/pl.po b/po/pl.po index fbb7e7b..8e42f59 100644 --- a/po/pl.po +++ b/po/pl.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-12-09 22:59+0100\n" +"POT-Creation-Date: 2010-12-19 19:54+0100\n" "PO-Revision-Date: 2010-11-06 11:56+0100\n" "Last-Translator: Krzysztof Koroscik \n" "Language-Team: weechat-dev \n" @@ -45,8 +45,10 @@ msgstr "" msgid "Usage: %s [option...] [plugin:option...]\n" msgstr "Użycie: %s [argumenty...] [wtyczka:opcje...]\n" +#, fuzzy msgid "" " -a, --no-connect disable auto-connect to servers at startup\n" +" -c, --colors display default colors in terminal\n" " -d, --dir set WeeChat home directory (default: ~/.weechat)\n" " -h, --help this help\n" " -k, --keys display WeeChat default keys\n" @@ -1781,6 +1783,17 @@ msgstr "\t\tDzień zmienił się na %s" msgid "debug level for plugin (\"core\" for WeeChat core)" msgstr "poziom debugowania dla wtyczki (\"core\" dla rdzenia WeeChat)" +msgid "" +"custom color in palette, format is: \"alias;fg,bg;r/g/b\" where alias is " +"color name, fg,bg is \"foreground,background\" (example: \"200,-1\"), r/g/b " +"is redefinition of color (terminal must support it) (everything is optional " +"in this format)" +msgstr "" + +#, fuzzy, c-format +msgid "%sError: palette option must be numeric" +msgstr "%sBłąd: nie udało się zapisać ustawień do %s" + msgid "Notify level for buffer" msgstr "Poziom powiadomień dla buforu" @@ -2556,6 +2569,16 @@ msgid "" msgstr "" "odczyt - zła sygnatura (format pliku mógł ulec zmianie od poprzedniej wersji)" +msgid "Terminal infos:" +msgstr "Informacje terminala:" + +msgid "No color support in terminal." +msgstr "" + +#, fuzzy +msgid "Default colors:" +msgstr "Przywrócono domyślne przypisania klawiszy" + msgid "Terminal lost, exiting WeeChat..." msgstr "Utracono terminal, wychodzę z WeeChat..." @@ -2566,9 +2589,6 @@ msgstr "Otrzymano sygnał %s, wychodzę z WeeChat..." msgid "Signal SIGHUP received, reloading configuration files" msgstr "Otrzymano sygnał SIGHUP, przeładowuję pliki konfiguracyjne" -msgid "Terminal infos:" -msgstr "Informacje terminala:" - #, c-format msgid " TERM='%s', size: %dx%d" msgstr " TERM='%s', rozmiar: %dx%d" diff --git a/po/pt_BR.po b/po/pt_BR.po index cd623b8..4ac5c4a 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-12-09 22:59+0100\n" +"POT-Creation-Date: 2010-12-19 19:54+0100\n" "PO-Revision-Date: 2010-11-13 09:26+0100\n" "Last-Translator: Ivan Sichmann Freitas \n" "Language-Team: weechat-dev \n" @@ -43,8 +43,10 @@ msgstr "" msgid "Usage: %s [option...] [plugin:option...]\n" msgstr "Uso: %s [opção...] [plugin:opção...]\n" +#, fuzzy msgid "" " -a, --no-connect disable auto-connect to servers at startup\n" +" -c, --colors display default colors in terminal\n" " -d, --dir set WeeChat home directory (default: ~/.weechat)\n" " -h, --help this help\n" " -k, --keys display WeeChat default keys\n" @@ -1414,6 +1416,17 @@ msgstr "" msgid "debug level for plugin (\"core\" for WeeChat core)" msgstr "" +msgid "" +"custom color in palette, format is: \"alias;fg,bg;r/g/b\" where alias is " +"color name, fg,bg is \"foreground,background\" (example: \"200,-1\"), r/g/b " +"is redefinition of color (terminal must support it) (everything is optional " +"in this format)" +msgstr "" + +#, fuzzy, c-format +msgid "%sError: palette option must be numeric" +msgstr "%sErro: falhou ao salvar as opções para %s" + msgid "Notify level for buffer" msgstr "" @@ -2083,6 +2096,16 @@ msgid "" "version)" msgstr "" +msgid "Terminal infos:" +msgstr "" + +msgid "No color support in terminal." +msgstr "" + +#, fuzzy +msgid "Default colors:" +msgstr "comando padrão:" + msgid "Terminal lost, exiting WeeChat..." msgstr "" @@ -2093,9 +2116,6 @@ msgstr "" msgid "Signal SIGHUP received, reloading configuration files" msgstr "" -msgid "Terminal infos:" -msgstr "" - #, c-format msgid " TERM='%s', size: %dx%d" msgstr "" diff --git a/po/ru.po b/po/ru.po index 508e972..bfcc414 100644 --- a/po/ru.po +++ b/po/ru.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.4-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2010-12-09 22:59+0100\n" +"POT-Creation-Date: 2010-12-19 19:54+0100\n" "PO-Revision-Date: 2010-11-05 17:17+0100\n" "Last-Translator: Pavel Shevchuk \n" "Language-Team: weechat-dev \n" @@ -48,6 +48,7 @@ msgstr "" #, fuzzy msgid "" " -a, --no-connect disable auto-connect to servers at startup\n" +" -c, --colors display default colors in terminal\n" " -d, --dir set WeeChat home directory (default: ~/.weechat)\n" " -h, --help this help\n" " -k, --keys display WeeChat default keys\n" @@ -1593,6 +1594,17 @@ msgstr "Дата сменилась на %s\n" msgid "debug level for plugin (\"core\" for WeeChat core)" msgstr "" +msgid "" +"custom color in palette, format is: \"alias;fg,bg;r/g/b\" where alias is " +"color name, fg,bg is \"foreground,background\" (example: \"200,-1\"), r/g/b " +"is redefinition of color (terminal must support it) (everything is optional " +"in this format)" +msgstr "" + +#, fuzzy, c-format +msgid "%sError: palette option must be numeric" +msgstr "%s не могу сохранить конфигурационный файл pluginов\n" + #, fuzzy msgid "Notify level for buffer" msgstr "не найдено имя канала для буфера" @@ -2380,6 +2392,16 @@ msgid "" "version)" msgstr "" +msgid "Terminal infos:" +msgstr "" + +msgid "No color support in terminal." +msgstr "" + +#, fuzzy +msgid "Default colors:" +msgstr "Комбинации клавиш по умолчанию восстановлены\n" + msgid "Terminal lost, exiting WeeChat..." msgstr "" @@ -2391,9 +2413,6 @@ msgstr "" msgid "Signal SIGHUP received, reloading configuration files" msgstr "%s не могу сохранить конфигурационный файл\n" -msgid "Terminal infos:" -msgstr "" - #, c-format msgid " TERM='%s', size: %dx%d" msgstr "" diff --git a/po/weechat.pot b/po/weechat.pot index d86b6c8..f6c7215 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-12-09 22:59+0100\n" +"POT-Creation-Date: 2010-12-19 19:54+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -30,6 +30,7 @@ msgstr "" msgid "" " -a, --no-connect disable auto-connect to servers at startup\n" +" -c, --colors display default colors in terminal\n" " -d, --dir set WeeChat home directory (default: ~/.weechat)\n" " -h, --help this help\n" " -k, --keys display WeeChat default keys\n" @@ -1354,6 +1355,17 @@ msgstr "" msgid "debug level for plugin (\"core\" for WeeChat core)" msgstr "" +msgid "" +"custom color in palette, format is: \"alias;fg,bg;r/g/b\" where alias is " +"color name, fg,bg is \"foreground,background\" (example: \"200,-1\"), r/g/b " +"is redefinition of color (terminal must support it) (everything is optional " +"in this format)" +msgstr "" + +#, c-format +msgid "%sError: palette option must be numeric" +msgstr "" + msgid "Notify level for buffer" msgstr "" @@ -2023,6 +2035,15 @@ msgid "" "version)" msgstr "" +msgid "Terminal infos:" +msgstr "" + +msgid "No color support in terminal." +msgstr "" + +msgid "Default colors:" +msgstr "" + msgid "Terminal lost, exiting WeeChat..." msgstr "" @@ -2033,9 +2054,6 @@ msgstr "" msgid "Signal SIGHUP received, reloading configuration files" msgstr "" -msgid "Terminal infos:" -msgstr "" - #, c-format msgid " TERM='%s', size: %dx%d" msgstr "" diff --git a/src/core/wee-completion.c b/src/core/wee-completion.c index cd4bbf5..eb27494 100644 --- a/src/core/wee-completion.c +++ b/src/core/wee-completion.c @@ -37,6 +37,7 @@ #include "weechat.h" #include "wee-config.h" +#include "wee-hashtable.h" #include "wee-hook.h" #include "wee-list.h" #include "wee-proxy.h" @@ -706,6 +707,24 @@ completion_list_add_plugins_commands_cb (void *data, } /* + * completion_list_add_color_alias_cb: add color alias in completion + */ + +void +completion_list_add_color_alias_cb (void *data, + struct t_hashtable *hashtable, + const void *key, const void *value) +{ + /* make C compiler happy */ + (void) hashtable; + (void) value; + + gui_completion_list_add ((struct t_gui_completion *)data, + (char *)key, + 0, WEECHAT_LIST_POS_SORT); +} + +/* * completion_list_add_config_option_values_cb: add option value to completion * list */ @@ -888,6 +907,12 @@ completion_list_add_config_option_values_cb (void *data, color_name, 0, WEECHAT_LIST_POS_SORT); } + if (gui_color_hash_palette_alias) + { + hashtable_map (gui_color_hash_palette_alias, + &completion_list_add_color_alias_cb, + completion); + } gui_completion_list_add (completion, "++1", 0, WEECHAT_LIST_POS_END); gui_completion_list_add (completion, "--1", diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c index 65fd6d0..651a175 100644 --- a/src/core/wee-config-file.c +++ b/src/core/wee-config-file.c @@ -1260,12 +1260,9 @@ config_file_option_set (struct t_config_option *option, const char *value, number = strtol (value + 2, &error, 10); if (error && !error[0]) { - number = number % (num_colors + 1); - value_int = (old_value + number) % - (num_colors + 1); - if (value_int > num_colors - 1) - value_int -= num_colors; - if (value_int <= num_colors - 1) + if (gui_color_assign_by_diff (&value_int, + gui_color_get_name (old_value), + number)) new_value_ok = 1; } } @@ -1275,19 +1272,15 @@ config_file_option_set (struct t_config_option *option, const char *value, number = strtol (value + 2, &error, 10); if (error && !error[0]) { - number = number % (num_colors + 1); - value_int = (old_value + num_colors - number) % - num_colors; - if (value_int < 0) - value_int += num_colors; - if (value_int >= 0) + if (gui_color_assign_by_diff (&value_int, + gui_color_get_name (old_value), + -1 * number)) new_value_ok = 1; } } else { - gui_color_assign (&value_int, value); - if ((value_int >= 0) && (value_int <= num_colors - 1)) + if (gui_color_assign (&value_int, value)) new_value_ok = 1; } if (new_value_ok) diff --git a/src/core/wee-config.c b/src/core/wee-config.c index e101fbd..719cf21 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -61,6 +61,7 @@ struct t_config_file *weechat_config_file = NULL; struct t_config_section *weechat_config_section_debug = NULL; +struct t_config_section *weechat_config_section_color = NULL; struct t_config_section *weechat_config_section_proxy = NULL; struct t_config_section *weechat_config_section_bar = NULL; struct t_config_section *weechat_config_section_notify = NULL; @@ -661,6 +662,130 @@ config_weechat_debug_set (const char *plugin_name, const char *value) } /* + * config_weechat_palette_change_cb: called when a palette option is changed + */ + +void +config_weechat_palette_change_cb (void *data, + struct t_config_option *option) +{ + char *error; + int number; + + /* make C compiler happy */ + (void) data; + (void) option; + + error = NULL; + number = (int)strtol (option->name, &error, 10); + if (error && !error[0]) + { + gui_color_palette_change (number, CONFIG_STRING(option)); + } +} + +/* + * config_weechat_palette_create_option_cb: create option in "palette" section + */ + +int +config_weechat_palette_create_option_cb (void *data, + struct t_config_file *config_file, + struct t_config_section *section, + const char *option_name, + const char *value) +{ + struct t_config_option *ptr_option; + char *error; + int rc, number; + + /* make C compiler happy */ + (void) data; + + rc = WEECHAT_CONFIG_OPTION_SET_ERROR; + + error = NULL; + number = (int)strtol (option_name, &error, 10); + if (error && !error[0]) + { + if (option_name) + { + ptr_option = config_file_search_option (config_file, section, + option_name); + if (ptr_option) + { + if (value) + rc = config_file_option_set (ptr_option, value, 1); + else + { + config_file_option_free (ptr_option); + rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE; + } + } + else + { + if (value) + { + ptr_option = config_file_new_option ( + config_file, section, + option_name, "string", + _("custom color in palette, format is: \"alias;fg,bg;r/g/b\" " + "where alias is color name, fg,bg is \"foreground,background\" " + "(example: \"200,-1\"), r/g/b is redefinition of color " + "(terminal must support it) (everything is optional " + "in this format)"), + NULL, 0, 0, "", value, 0, NULL, NULL, + &config_weechat_palette_change_cb, NULL, + NULL, NULL); + rc = (ptr_option) ? + WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE : WEECHAT_CONFIG_OPTION_SET_ERROR; + if (ptr_option) + gui_color_palette_add (number, value); + } + else + rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE; + } + } + } + else + { + gui_chat_printf (NULL, + _("%sError: palette option must be numeric"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]); + } + + return rc; +} + +/* + * config_weechat_palette_delete_option_cb: delete option in "palette" section + */ + +int +config_weechat_palette_delete_option_cb (void *data, + struct t_config_file *config_file, + struct t_config_section *section, + struct t_config_option *option) +{ + char *error; + int number; + + /* make C compiler happy */ + (void) data; + (void) config_file; + (void) section; + + error = NULL; + number = (int)strtol (option->name, &error, 10); + if (error && !error[0]) + gui_color_palette_remove (number); + + config_file_option_free (option); + + return WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED; +} + +/* * config_weechat_proxy_read_cb: read proxy option in config file */ @@ -1606,6 +1731,19 @@ config_weechat_init_options () "messages"), NULL, 0, 0, "%a, %d %b %Y %T", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + /* palette */ + ptr_section = config_file_new_section (weechat_config_file, "palette", + 1, 1, + NULL, NULL, NULL, NULL, + NULL, NULL, + &config_weechat_palette_create_option_cb, NULL, + &config_weechat_palette_delete_option_cb, NULL); + if (!ptr_section) + { + config_file_free (weechat_config_file); + return 0; + } + /* colors */ ptr_section = config_file_new_section (weechat_config_file, "color", 0, 0, @@ -1617,6 +1755,8 @@ config_weechat_init_options () return 0; } + weechat_config_section_color = ptr_section; + /* general color settings */ config_color_separator = config_file_new_option ( weechat_config_file, ptr_section, @@ -2232,9 +2372,9 @@ config_weechat_init () _("FATAL: error initializing configuration options")); } - /* create timer to check if day has changed */ if (!config_day_change_timer) { + /* create timer to check if day has changed */ gettimeofday (&tv_time, NULL); local_time = localtime (&tv_time.tv_sec); config_day_change_old_day = local_time->tm_mday; @@ -2244,8 +2384,9 @@ config_weechat_init () 0, &config_day_change_timer_cb, NULL); - config_change_highlight_regex (NULL, NULL); } + if (!config_highlight_regex) + config_change_highlight_regex (NULL, NULL); return rc; } diff --git a/src/core/wee-config.h b/src/core/wee-config.h index ed7d45d..659f091 100644 --- a/src/core/wee-config.h +++ b/src/core/wee-config.h @@ -94,6 +94,7 @@ enum t_config_look_save_layout_on_exit }; extern struct t_config_file *weechat_config_file; +extern struct t_config_section *weechat_config_section_color; extern struct t_config_section *weechat_config_section_proxy; extern struct t_config_section *weechat_config_section_bar; extern struct t_config_section *weechat_config_section_notify; diff --git a/src/core/wee-list.c b/src/core/wee-list.c index 599b93a..411f716 100644 --- a/src/core/wee-list.c +++ b/src/core/wee-list.c @@ -183,6 +183,32 @@ weelist_search (struct t_weelist *weelist, const char *data) } /* + * weelist_search_pos: search data in a list (case sensitive), return position + * of item found, -1 if not found + */ + +int +weelist_search_pos (struct t_weelist *weelist, const char *data) +{ + struct t_weelist_item *ptr_item; + int i; + + if (!weelist || !data) + return -1; + + i = 0; + for (ptr_item = weelist->items; ptr_item; + ptr_item = ptr_item->next_item) + { + if (strcmp (data, ptr_item->data) == 0) + return i; + i++; + } + /* data not found in list */ + return -1; +} + +/* * weelist_casesearch: search data in a list (case unsensitive) */ @@ -205,6 +231,31 @@ weelist_casesearch (struct t_weelist *weelist, const char *data) } /* + * weelist_casesearch_pos: search data in a list (case unsensitive), return + * position of item found, -1 if not found + */ + +int +weelist_casesearch_pos (struct t_weelist *weelist, const char *data) +{ + struct t_weelist_item *ptr_item; + int i; + + if (!weelist || !data) + return -1; + + for (ptr_item = weelist->items; ptr_item; + ptr_item = ptr_item->next_item) + { + if (string_strcasecmp (data, ptr_item->data) == 0) + return i; + i++; + } + /* data not found in list */ + return -1; +} + +/* * weelist_get: get an item in a list by position (0 is first element) */ diff --git a/src/core/wee-list.h b/src/core/wee-list.h index 7b8f603..a2efff0 100644 --- a/src/core/wee-list.h +++ b/src/core/wee-list.h @@ -41,8 +41,10 @@ extern struct t_weelist_item *weelist_add (struct t_weelist *weelist, void *user_data); extern struct t_weelist_item *weelist_search (struct t_weelist *weelist, const char *data); +extern int weelist_search_pos (struct t_weelist *weelist, const char *data); extern struct t_weelist_item *weelist_casesearch (struct t_weelist *weelist, const char *data); +extern int weelist_casesearch_pos (struct t_weelist *weelist, const char *data); extern struct t_weelist_item *weelist_get (struct t_weelist *weelist, int position); extern void weelist_set (struct t_weelist_item *item, const char *value); diff --git a/src/core/weechat.c b/src/core/weechat.c index 75dac6b..8d60ba4 100644 --- a/src/core/weechat.c +++ b/src/core/weechat.c @@ -110,6 +110,7 @@ weechat_display_usage (char *exec_name) string_iconv_fprintf (stdout, "\n\n"); string_iconv_fprintf (stdout, _(" -a, --no-connect disable auto-connect to servers at startup\n" + " -c, --colors display default colors in terminal\n" " -d, --dir set WeeChat home directory (default: ~/.weechat)\n" " -h, --help this help\n" " -k, --keys display WeeChat default keys\n" @@ -173,7 +174,13 @@ weechat_parse_args (int argc, char *argv[]) for (i = 1; i < argc; i++) { - if ((strcmp (argv[i], "-d") == 0) + if ((strcmp (argv[i], "-c") == 0) + || (strcmp (argv[i], "--colors") == 0)) + { + gui_color_display_terminal_colors (); + weechat_shutdown (EXIT_SUCCESS, 0); + } + else if ((strcmp (argv[i], "-d") == 0) || (strcmp (argv[i], "--dir") == 0)) { if (i + 1 < argc) diff --git a/src/gui/curses/gui-curses-bar-window.c b/src/gui/curses/gui-curses-bar-window.c index 6130ccb..af89feb 100644 --- a/src/gui/curses/gui-curses-bar-window.c +++ b/src/gui/curses/gui-curses-bar-window.c @@ -156,7 +156,9 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window, int hide_chars_if_scrolling) { int weechat_color, x_with_hidden, size_on_screen, fg, bg, low_char, hidden; - char str_fg[3], str_bg[3], utf_char[16], *next_char, *output; + int pair; + char str_fg[3], str_bg[3], str_pair[6], utf_char[16], *next_char, *output; + char *error; if (!string || !string[0]) return 1; @@ -223,25 +225,42 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window, string += 6; } break; + case GUI_COLOR_PAIR_CHAR: /* pair number */ + if ((isdigit (string[1])) && (isdigit (string[2])) + && (isdigit (string[3])) && (isdigit (string[4])) + && (isdigit (string[5]))) + { + memcpy (str_pair, string + 1, 5); + str_pair[5] = '\0'; + error = NULL; + pair = (int)strtol (str_pair, &error, 10); + if (error && !error[0]) + { + gui_window_set_custom_color_pair (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, + pair); + } + string += 6; + } + break; case GUI_COLOR_BAR_CHAR: /* bar color */ switch (string[1]) { case GUI_COLOR_BAR_FG_CHAR: /* bar foreground */ gui_window_set_custom_color_fg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, - CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG])); + CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG])); string += 2; break; case GUI_COLOR_BAR_DELIM_CHAR: /* bar delimiter */ gui_window_set_custom_color_fg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, - CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_COLOR_DELIM])); + CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_DELIM])); string += 2; break; case GUI_COLOR_BAR_BG_CHAR: /* bar background */ gui_window_set_custom_color_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, - CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG])); + CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG])); string += 2; break; case GUI_COLOR_BAR_START_INPUT_CHAR: @@ -282,9 +301,9 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window, break; case GUI_COLOR_RESET_CHAR: gui_window_set_custom_color_fg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, - CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG])); + CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_FG])); gui_window_set_custom_color_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, - CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG])); + CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG])); gui_window_remove_color_style (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, A_BOLD | A_UNDERLINE | A_REVERSE); string++; @@ -653,7 +672,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window, y = 0; gui_window_set_custom_color_fg_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, CONFIG_COLOR(config_color_bar_more), - CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG])); + CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG])); mvwprintw (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, y, x, "--"); } @@ -666,7 +685,7 @@ gui_bar_window_draw (struct t_gui_bar_window *bar_window, y = (bar_window->height > 1) ? bar_window->height - 1 : 0; gui_window_set_custom_color_fg_bg (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, CONFIG_COLOR(config_color_bar_more), - CONFIG_INTEGER(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG])); + CONFIG_COLOR(bar_window->bar->options[GUI_BAR_OPTION_COLOR_BG])); mvwprintw (GUI_BAR_WINDOW_OBJECTS(bar_window)->win_bar, y, x, "++"); } diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c index 3653c1d..4a655e4 100644 --- a/src/gui/curses/gui-curses-chat.c +++ b/src/gui/curses/gui-curses-chat.c @@ -179,8 +179,8 @@ char * gui_chat_string_next_char (struct t_gui_window *window, const unsigned char *string, int apply_style) { - char str_fg[3], str_bg[3]; - int weechat_color, fg, bg; + char str_fg[3], str_bg[3], str_pair[6], *error; + int weechat_color, fg, bg, pair; while (string[0]) { @@ -245,6 +245,26 @@ gui_chat_string_next_char (struct t_gui_window *window, string += 6; } break; + case GUI_COLOR_PAIR_CHAR: /* pair number */ + if ((isdigit (string[1])) && (isdigit (string[2])) + && (isdigit (string[3])) && (isdigit (string[4])) + && (isdigit (string[5]))) + { + if (apply_style) + { + memcpy (str_pair, string + 1, 5); + str_pair[5] = '\0'; + error = NULL; + pair = (int)strtol (str_pair, &error, 10); + if (error && !error[0]) + { + gui_window_set_custom_color_pair (GUI_WINDOW_OBJECTS(window)->win_chat, + pair); + } + } + string += 6; + } + break; case GUI_COLOR_BAR_CHAR: /* bar color */ switch (string[1]) { diff --git a/src/gui/curses/gui-curses-color.c b/src/gui/curses/gui-curses-color.c index 9638841..92e6235 100644 --- a/src/gui/curses/gui-curses-color.c +++ b/src/gui/curses/gui-curses-color.c @@ -31,8 +31,11 @@ #include "../../core/weechat.h" #include "../../core/wee-config.h" +#include "../../core/wee-hashtable.h" +#include "../../core/wee-list.h" #include "../../core/wee-string.h" #include "../../core/wee-utf8.h" +#include "../../plugins/plugin.h" #include "../gui-color.h" #include "../gui-chat.h" #include "gui-curses.h" @@ -84,23 +87,41 @@ gui_color_search (const char *color_name) /* * gui_color_assign: assign a WeeChat color (read from config) + * return 1 if ok, 0 if error */ int gui_color_assign (int *color, const char *color_name) { - int i; + int color_index, pair; + char *error; - /* look for curses colors in table */ - i = 0; - while (gui_weechat_colors[i].string) + /* search for color alias */ + pair = gui_color_palette_get_alias (color_name); + if (pair >= 0) { - if (string_strcasecmp (gui_weechat_colors[i].string, color_name) == 0) + *color = 0x10000 | pair; + return 1; + } + + /* is it pair number? */ + error = NULL; + pair = (int)strtol (color_name, &error, 10); + if (error && !error[0] && (pair >= 0)) + { + /* color_name is a number, use this pair number */ + *color = 0x10000 | pair; + return 1; + } + else + { + /* search for basic WeeChat color */ + color_index = gui_color_search (color_name); + if (color_index >= 0) { - *color = i; + *color = color_index; return 1; } - i++; } /* color not found */ @@ -108,6 +129,57 @@ gui_color_assign (int *color, const char *color_name) } /* + * gui_color_assign_by_diff: assign color by difference + * It is called when a color option is + * set with value ++X or --X, to search + * another color (for example ++1 is + * next color/alias in list) + * return 1 if ok, 0 if error + */ + +int +gui_color_assign_by_diff (int *color, const char *color_name, int diff) +{ + int index, list_size; + struct t_weelist_item *ptr_item; + const char *name; + + index = weelist_search_pos (gui_color_list_with_alias, color_name); + if (index < 0) + index = 0; + + list_size = weelist_size (gui_color_list_with_alias); + + diff = diff % (list_size + 1); + + if (diff > 0) + { + index = (index + diff) % (list_size + 1); + while (index > list_size - 1) + { + index -= list_size; + } + } + else + { + index = (index + list_size + diff) % list_size; + while (index < 0) + { + index += list_size; + } + } + + ptr_item = weelist_get (gui_color_list_with_alias, index); + if (!ptr_item) + return 0; + name = weelist_string (ptr_item); + if (name) + return gui_color_assign (color, name); + + return 0; +} + +/* * gui_color_get_number: get number of available colors */ @@ -124,13 +196,30 @@ gui_color_get_number () const char * gui_color_get_name (int num_color) { + static char color[32][16]; + static int index_color = 0; + struct t_gui_color_palette *ptr_color_palette; + + if (num_color & 0x10000) + { + ptr_color_palette = gui_color_palette_get (num_color & 0xFFFF); + if (ptr_color_palette && ptr_color_palette->alias) + return ptr_color_palette->alias; + index_color = (index_color + 1) % 32; + color[index_color][0] = '\0'; + snprintf (color[index_color], sizeof (color[index_color]), + "%d", num_color & 0xFFFF); + return color[index_color]; + } + return gui_weechat_colors[num_color].string; } /* - * gui_color_build: build a WeeChat color with foreground, - * background and attributes (attributes are - * given with foreground color, with a OR) + * gui_color_build: build a WeeChat color with foreground and background + * (foreground and background must be >= 0, + * if they are >= 0x10000, then it is a pair number + * (pair = value & 0xFFFF)) */ void @@ -144,9 +233,20 @@ gui_color_build (int number, int foreground, int background) gui_color[number]->string = malloc (4); } - gui_color[number]->foreground = gui_weechat_colors[foreground].foreground; - gui_color[number]->background = gui_weechat_colors[background].foreground; - gui_color[number]->attributes = gui_weechat_colors[foreground].attributes; + if (foreground & 0x10000) + { + gui_color[number]->foreground = foreground; + gui_color[number]->background = 0; + gui_color[number]->attributes = 0; + } + else + { + if (background & 0x10000) + background = 0; + gui_color[number]->foreground = gui_weechat_colors[foreground].foreground; + gui_color[number]->background = gui_weechat_colors[background].foreground; + gui_color[number]->attributes = gui_weechat_colors[foreground].attributes; + } if (gui_color[number]->string) { snprintf (gui_color[number]->string, 4, @@ -170,6 +270,9 @@ gui_color_get_pair (int num_color) fg = gui_color[num_color]->foreground; bg = gui_color[num_color]->background; + if ((fg > 0) && (fg & 0x10000)) + return fg & 0xFFFF; + if (((fg == -1) || (fg == 99)) && ((bg == -1) || (bg == 99))) return gui_color_last_pair; @@ -182,13 +285,42 @@ gui_color_get_pair (int num_color) } /* + * gui_color_init_pair: init a color pair + */ + +void +gui_color_init_pair (int number) +{ + struct t_gui_color_palette *ptr_color_palette; + int fg, bg; + + if ((number >= 1) && (number <= COLOR_PAIRS - 1)) + { + ptr_color_palette = gui_color_palette_get (number); + if (ptr_color_palette) + { + init_pair (number, + ptr_color_palette->foreground, + ptr_color_palette->background); + } + else + { + fg = (number - 1) % gui_color_num_bg; + bg = ((number - 1) < gui_color_num_bg) ? -1 : (number - 1) / gui_color_num_bg; + init_pair (number, fg, bg); + } + } +} + +/* * gui_color_init_pairs: init color pairs */ void gui_color_init_pairs () { - int i, fg, bg, num_colors; + int i, num_colors; + struct t_gui_color_palette *ptr_color_palette; /* * depending on terminal and $TERM value, we can have for example: @@ -199,29 +331,35 @@ gui_color_init_pairs () * urxvt | xterm-256color | 256 | 32767 * screen | screen | 8 | 64 * screen | screen-256color | 256 | 32767 - */ + */ if (has_colors ()) { gui_color_num_bg = (COLOR_PAIRS >= 256) ? 16 : 8; num_colors = (COLOR_PAIRS >= 256) ? 256 : COLOR_PAIRS; + gui_color_last_pair = num_colors - 1; + + /* WeeChat pairs */ for (i = 1; i < num_colors; i++) { - fg = (i - 1) % gui_color_num_bg; - bg = ((i - 1) < gui_color_num_bg) ? -1 : (i - 1) / gui_color_num_bg; - init_pair (i, fg, bg); + gui_color_init_pair (i); } - gui_color_last_pair = num_colors - 1; /* disable white on white, replaced by black on white */ - init_pair (gui_color_last_pair, -1, -1); + ptr_color_palette = gui_color_palette_get (gui_color_last_pair); + if (!ptr_color_palette) + init_pair (gui_color_last_pair, -1, -1); /* * white on default bg is default (-1) (for terminals with white/light * background) */ if (!CONFIG_BOOLEAN(config_look_color_real_white)) - init_pair (COLOR_WHITE + 1, -1, -1); + { + ptr_color_palette = gui_color_palette_get (COLOR_WHITE); + if (!ptr_color_palette) + init_pair (COLOR_WHITE + 1, -1, -1); + } } } @@ -297,6 +435,236 @@ gui_color_init () } /* + * gui_color_display_terminal_colors: display terminal colors + * This is called by command line option + * "-c" / "--colors" + */ + +void +gui_color_display_terminal_colors () +{ + int lines, line, col, color; + int color_support, colors, color_pairs, change_color; + char str_line[1024], str_color[64]; + + color_support = 0; + colors = 0; + color_pairs = 0; + change_color = 0; + + initscr (); + if (has_colors ()) + { + color_support = 1; + start_color (); + use_default_colors (); + colors = COLORS; + color_pairs = COLOR_PAIRS; + change_color = can_change_color () ? 1 : 0; + refresh (); + endwin (); + } + printf ("\n"); + printf ("%s $TERM=%s COLORS: %d, COLOR_PAIRS: %d, " + "can_change_color: %s\n", + _("Terminal infos:"), + getenv ("TERM"), colors, color_pairs, + (change_color) ? "yes" : "no"); + if (colors == 0) + { + printf ("%s\n", _("No color support in terminal.")); + } + else + { + printf ("\n"); + printf ("%s\n", _("Default colors:")); + printf ("------------------------------------------------------------" + "--------------------\n"); + lines = (colors < 16) ? colors : 16; + for (line = 0; line < lines; line++) + { + str_line[0] = '\0'; + for (col = 0; col < 16; col++) + { + color = (col * 16) + line; + if (color < colors) + { + snprintf (str_color, sizeof (str_color), + "\33[0;38;5;%dm %03d ", color, color); + strcat (str_line, str_color); + } + } + printf ("%s\n", str_line); + } + printf ("\33[0m"); + printf ("------------------------------------------------------------" + "--------------------\n"); + } + printf ("\n"); +} + +/* + * gui_color_palette_add_alias_cb: add an alias in hashtable with aliases + */ + +void +gui_color_palette_add_alias_cb (void *data, + struct t_hashtable *hashtable, + const void *key, const void *value) +{ + struct t_gui_color_palette *color_palette; + char *error; + int number; + + /* make C compiler happy */ + (void) data; + (void) hashtable; + + color_palette = (struct t_gui_color_palette *)value; + + if (color_palette && color_palette->alias) + { + error = NULL; + number = (int)strtol ((char *)key, &error, 10); + if (error && !error[0]) + { + hashtable_set (gui_color_hash_palette_alias, + color_palette->alias, + &number); + } + weelist_add (gui_color_list_with_alias, color_palette->alias, + WEECHAT_LIST_POS_END, NULL); + } +} + +/* + * gui_color_palette_build_aliases: build aliases for palette + */ + +void +gui_color_palette_build_aliases () +{ + int i; + + hashtable_remove_all (gui_color_hash_palette_alias); + weelist_remove_all (gui_color_list_with_alias); + for (i = 0; i < GUI_CURSES_NUM_WEECHAT_COLORS; i++) + { + weelist_add (gui_color_list_with_alias, + gui_weechat_colors[i].string, + WEECHAT_LIST_POS_END, + NULL); + } + hashtable_map (gui_color_hash_palette_color, + &gui_color_palette_add_alias_cb, NULL); +} + +/* + * gui_color_palette_new: create a new color in palette + */ + +struct t_gui_color_palette * +gui_color_palette_new (int number, const char *value) +{ + struct t_gui_color_palette *new_color_palette; + char **items, *pos, *pos2, *error1, *error2, *error3, str_number[64]; + int num_items, fg, bg, r, g, b; + + if (!value) + return NULL; + + new_color_palette = malloc (sizeof (*new_color_palette)); + if (new_color_palette) + { + new_color_palette->alias = NULL; + new_color_palette->foreground = number; + new_color_palette->background = -1; + new_color_palette->r = -1; + new_color_palette->g = -1; + new_color_palette->b = -1; + items = string_split (value, ";", 0, 0, &num_items); + if (items) + { + if ((num_items >= 1) && items[0][0]) + { + new_color_palette->alias = strdup (items[0]); + } + if ((num_items >= 2) && items[1][0]) + { + pos = strchr (items[1], ','); + if (pos) + { + pos[0] = '\0'; + error1 = NULL; + fg = (int)strtol (items[1], &error1, 10); + error2 = NULL; + bg = (int)strtol (pos + 1, &error2, 10); + if (error1 && !error1[0] && error2 && !error2[0] + && (fg >= -1) && (bg >= -1)) + { + new_color_palette->foreground = fg; + new_color_palette->background = bg; + } + } + } + if ((num_items >= 3) && items[2][0]) + { + pos = strchr (items[2], '/'); + if (pos) + { + pos[0] = '\0'; + pos2 = strchr (pos + 1, '/'); + if (pos2) + { + pos2[0] = '\0'; + error1 = NULL; + r = (int)strtol (items[2], &error1, 10); + error2 = NULL; + g = (int)strtol (pos + 1, &error2, 10); + error3 = NULL; + b = (int)strtol (pos2 + 1, &error3, 10); + if (error1 && !error1[0] && error2 && !error2[0] + && error3 && !error3[0] + && (r >= 0) && (r <= 1000) + && (g >= 0) && (g <= 1000) + && (b >= 0) && (b <= 1000)) + { + new_color_palette->r = r; + new_color_palette->g = g; + new_color_palette->b = b; + } + } + } + } + string_free_split (items); + } + if (!new_color_palette->alias) + { + snprintf (str_number, sizeof (str_number), "%d", number); + new_color_palette->alias = strdup (str_number); + } + } + + return new_color_palette; +} + +/* + * gui_color_palette_free: free a color in palette + */ + +void +gui_color_palette_free (struct t_gui_color_palette *color_palette) +{ + if (!color_palette) + return; + + if (color_palette->alias) + free (color_palette->alias); + + free (color_palette); +} + +/* * gui_color_end: end GUI colors */ diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index 7e215a5..0ba65f0 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -235,9 +235,9 @@ gui_window_reset_style (WINDOW *window, int num_color) window_current_style_attr = 0; window_current_color_attr = 0; + wattroff (window, A_BOLD | A_UNDERLINE | A_REVERSE); wattron (window, COLOR_PAIR(gui_color_get_pair (num_color)) | gui_color[num_color]->attributes); - wattroff (window, A_BOLD | A_UNDERLINE | A_REVERSE); } /* @@ -296,9 +296,17 @@ gui_window_set_weechat_color (WINDOW *window, int num_color) { gui_window_reset_style (window, num_color); wattron (window, gui_color[num_color]->attributes); - gui_window_set_color (window, - gui_color[num_color]->foreground, - gui_color[num_color]->background); + if ((gui_color[num_color]->foreground > 0) + && (gui_color[num_color]->foreground & 0x10000)) + { + wattron (window, COLOR_PAIR(gui_color[num_color]->foreground & 0xFFFF)); + } + else + { + gui_window_set_color (window, + gui_color[num_color]->foreground, + gui_color[num_color]->background); + } } } @@ -323,6 +331,21 @@ gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg) } /* + * gui_window_set_custom_color_pair: set a custom color for a window + * (pair number) + */ + +void +gui_window_set_custom_color_pair (WINDOW *window, int pair) +{ + if ((pair >= 0) && (pair <= gui_color_last_pair)) + { + gui_window_remove_color_style (window, A_BOLD); + wattron (window, COLOR_PAIR(pair)); + } +} + +/* * gui_window_set_custom_color_fg: set a custom color for a window * (foreground only) */ @@ -331,15 +354,22 @@ void gui_window_set_custom_color_fg (WINDOW *window, int fg) { int current_bg; - - if ((fg >= 0) && (fg < GUI_CURSES_NUM_WEECHAT_COLORS)) + + if (fg >= 0) { - current_bg = window_current_style_bg; - gui_window_remove_color_style (window, A_BOLD); - gui_window_set_color_style (window, gui_weechat_colors[fg].attributes); - gui_window_set_color (window, - gui_weechat_colors[fg].foreground, - current_bg); + if (fg & 0x10000) + { + gui_window_set_custom_color_pair (window, fg & 0xFFFF); + } + else if (fg < GUI_CURSES_NUM_WEECHAT_COLORS) + { + current_bg = window_current_style_bg; + gui_window_remove_color_style (window, A_BOLD); + gui_window_set_color_style (window, gui_weechat_colors[fg].attributes); + gui_window_set_color (window, + gui_weechat_colors[fg].foreground, + current_bg); + } } } @@ -353,14 +383,21 @@ gui_window_set_custom_color_bg (WINDOW *window, int bg) { int current_attr, current_fg; - if ((bg >= 0) && (bg < GUI_CURSES_NUM_WEECHAT_COLORS)) + if (bg >= 0) { - current_attr = window_current_style_attr; - current_fg = window_current_style_fg; - gui_window_set_color_style (window, current_attr); - gui_window_set_color (window, current_fg, - (gui_color_num_bg > 8) ? - gui_weechat_colors[bg].background : gui_weechat_colors[bg].foreground); + if (bg & 0x10000) + { + gui_window_set_custom_color_pair (window, bg & 0xFFFF); + } + else if (bg < GUI_CURSES_NUM_WEECHAT_COLORS) + { + current_attr = window_current_style_attr; + current_fg = window_current_style_fg; + gui_window_set_color_style (window, current_attr); + gui_window_set_color (window, current_fg, + (gui_color_num_bg > 8) ? + gui_weechat_colors[bg].background : gui_weechat_colors[bg].foreground); + } } } diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h index 133d4fa..cd40875 100644 --- a/src/gui/curses/gui-curses.h +++ b/src/gui/curses/gui-curses.h @@ -86,6 +86,7 @@ extern void gui_window_remove_color_style (WINDOW *window, int style); extern void gui_window_set_color (WINDOW *window, int fg, int bg); extern void gui_window_set_weechat_color (WINDOW *window, int num_color); extern void gui_window_set_custom_color_fg_bg (WINDOW *window, int fg, int bg); +extern void gui_window_set_custom_color_pair (WINDOW *window, int pair); extern void gui_window_set_custom_color_fg (WINDOW *window, int fg); extern void gui_window_set_custom_color_bg (WINDOW *window, int bg); extern void gui_window_clrtoeol_with_current_bg (WINDOW *window); diff --git a/src/gui/gtk/gui-gtk-color.c b/src/gui/gtk/gui-gtk-color.c index a4d7d09..96d20c4 100644 --- a/src/gui/gtk/gui-gtk-color.c +++ b/src/gui/gtk/gui-gtk-color.c @@ -102,6 +102,26 @@ gui_color_assign (int *color, const char *color_name) } /* + * gui_color_assign_by_diff: assign color by difference + * It is called when a color option is + * set with value ++X or --X, to search + * another color (for example ++1 is + * next color/alias in list) + * return 1 if ok, 0 if error + */ + +int +gui_color_assign_by_diff (int *color, const char *color_name, int diff) +{ + /* TODO: write this function for Gtk */ + (void) color; + (void) color_name; + (void) diff; + + return 1; +} + +/* * gui_color_get_number: get number of available colors */ @@ -148,6 +168,17 @@ gui_color_get_pair (int num_color) } /* + * gui_color_init_pair: init a color pair + */ + +void +gui_color_init_pair (int number) +{ + /* This function does nothing in Gtk GUI */ + (void) number; +} + +/* * gui_color_init_pairs: init color pairs */ @@ -216,6 +247,53 @@ gui_color_init () } /* + * gui_color_display_terminal_colors: display terminal colors + * This is called by command line option + * "-c" / "--colors" + */ + +void +gui_color_display_terminal_colors () +{ + /* This function does nothing in Gtk GUI */ +} + +/* + * gui_color_palette_build_aliases: build aliases for palette + */ + +void +gui_color_palette_build_aliases () +{ + /* This function does nothing in Gtk GUI */ +} + +/* + * gui_color_palette_new: create a new color in palette + */ + +struct t_gui_color_palette * +gui_color_palette_new (int number, const char *value) +{ + /* This function does nothing in Gtk GUI */ + (void) number; + (void) value; + + return NULL; +} + +/* + * gui_color_palette_free: free a color in palette + */ + +void +gui_color_palette_free (struct t_gui_color_palette *color_palette) +{ + /* This function does nothing in Gtk GUI */ + (void) color_palette; +} + +/* * gui_color_end: end GUI colors */ diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c index 56ffb0d..db9dfd1 100644 --- a/src/gui/gui-bar-item.c +++ b/src/gui/gui-bar-item.c @@ -377,16 +377,38 @@ gui_bar_item_get_value (const char *name, struct t_gui_bar *bar, bar_color[0] = '\0'; if (prefix || suffix) { - snprintf (delimiter_color, sizeof (delimiter_color), - "%c%c%02d", - GUI_COLOR_COLOR_CHAR, - GUI_COLOR_FG_CHAR, - CONFIG_COLOR(bar->options[GUI_BAR_OPTION_COLOR_DELIM])); - snprintf (bar_color, sizeof (bar_color), - "%c%c%02d", - GUI_COLOR_COLOR_CHAR, - GUI_COLOR_FG_CHAR, - CONFIG_COLOR(bar->options[GUI_BAR_OPTION_COLOR_FG])); + if (CONFIG_COLOR(bar->options[GUI_BAR_OPTION_COLOR_DELIM]) & 0x10000) + { + snprintf (delimiter_color, sizeof (delimiter_color), + "%c%c%05d", + GUI_COLOR_COLOR_CHAR, + GUI_COLOR_PAIR_CHAR, + CONFIG_COLOR(bar->options[GUI_BAR_OPTION_COLOR_DELIM]) & 0xFFFF); + } + else + { + snprintf (delimiter_color, sizeof (delimiter_color), + "%c%c%02d", + GUI_COLOR_COLOR_CHAR, + GUI_COLOR_FG_CHAR, + CONFIG_COLOR(bar->options[GUI_BAR_OPTION_COLOR_DELIM])); + } + if (CONFIG_COLOR(bar->options[GUI_BAR_OPTION_COLOR_FG]) & 0x10000) + { + snprintf (bar_color, sizeof (bar_color), + "%c%c%05d", + GUI_COLOR_COLOR_CHAR, + GUI_COLOR_PAIR_CHAR, + CONFIG_COLOR(bar->options[GUI_BAR_OPTION_COLOR_FG]) & 0xFFFF); + } + else + { + snprintf (bar_color, sizeof (bar_color), + "%c%c%02d", + GUI_COLOR_COLOR_CHAR, + GUI_COLOR_FG_CHAR, + CONFIG_COLOR(bar->options[GUI_BAR_OPTION_COLOR_FG])); + } } snprintf (result, length, "%s%s%s%s%s%s", diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c index 99c8bc0..acbf18e 100644 --- a/src/gui/gui-color.c +++ b/src/gui/gui-color.c @@ -36,13 +36,22 @@ #include "../core/weechat.h" #include "../core/wee-config.h" +#include "../core/wee-hashtable.h" +#include "../core/wee-list.h" #include "../core/wee-string.h" #include "../core/wee-utf8.h" +#include "../plugins/plugin.h" #include "gui-color.h" +#include "gui-window.h" struct t_gui_color *gui_color[GUI_COLOR_NUM_COLORS]; /* GUI colors */ +/* palette colors and aliases */ +struct t_hashtable *gui_color_hash_palette_color = NULL; +struct t_hashtable *gui_color_hash_palette_alias = NULL; +struct t_weelist *gui_color_list_with_alias = NULL; + /* * gui_color_search_config: search a color with configuration option name @@ -52,27 +61,21 @@ struct t_gui_color *gui_color[GUI_COLOR_NUM_COLORS]; /* GUI colors */ const char * gui_color_search_config (const char *color_name) { - struct t_config_section *ptr_section; struct t_config_option *ptr_option; if (color_name) { - ptr_section = config_file_search_section (weechat_config_file, - "color"); - if (ptr_section) + for (ptr_option = weechat_config_section_color->options; + ptr_option; ptr_option = ptr_option->next_option) { - for (ptr_option = ptr_section->options; ptr_option; - ptr_option = ptr_option->next_option) + if (string_strcasecmp (ptr_option->name, color_name) == 0) { - if (string_strcasecmp (ptr_option->name, color_name) == 0) + if (ptr_option->min < 0) { - if (ptr_option->min < 0) - { - return gui_color_get_custom ( - gui_color_get_name (CONFIG_COLOR(ptr_option))); - } - return GUI_COLOR(ptr_option->min); + return gui_color_get_custom ( + gui_color_get_name (CONFIG_COLOR(ptr_option))); } + return GUI_COLOR(ptr_option->min); } } } @@ -88,13 +91,13 @@ gui_color_search_config (const char *color_name) const char * gui_color_get_custom (const char *color_name) { - int fg, bg; - static char color[20][16]; + int fg, bg, pair; + static char color[32][16]; static int index_color = 0; - char *pos_comma, *str_fg, *pos_bg; + char *pos_comma, *str_fg, *pos_bg, *error; /* attribute or other color name (GUI dependent) */ - index_color = (index_color + 1) % 20; + index_color = (index_color + 1) % 32; color[index_color][0] = '\0'; if (!color_name || !color_name[0]) @@ -189,55 +192,86 @@ gui_color_get_custom (const char *color_name) else { /* custom color name (GUI dependent) */ - pos_comma = strchr (color_name, ','); - if (pos_comma) + pair = gui_color_palette_get_alias (color_name); + if (pair >= 0) { - if (pos_comma == color_name) - str_fg = NULL; - else - str_fg = string_strndup (color_name, pos_comma - color_name); - pos_bg = pos_comma + 1; + snprintf (color[index_color], sizeof (color[index_color]), + "%s%s%05d", + GUI_COLOR_COLOR_STR, + GUI_COLOR_PAIR_STR, + pair); } else { - str_fg = strdup (color_name); - pos_bg = NULL; - } - - if (str_fg && pos_bg) - { - fg = gui_color_search (str_fg); - bg = gui_color_search (pos_bg); - if ((fg >= 0) && (bg >= 0)) + error = NULL; + pair = (int)strtol (color_name, &error, 10); + if (error && !error[0]) { snprintf (color[index_color], sizeof (color[index_color]), - "%s*%02d,%02d", - GUI_COLOR_COLOR_STR, fg, bg); + "%s%s%05d", + GUI_COLOR_COLOR_STR, + GUI_COLOR_PAIR_STR, + pair); } - } - else if (str_fg && !pos_bg) - { - fg = gui_color_search (str_fg); - if (fg >= 0) - { - snprintf (color[index_color], sizeof (color[index_color]), - "%sF%02d", - GUI_COLOR_COLOR_STR, fg); - } - } - else if (!str_fg && pos_bg) - { - bg = gui_color_search (pos_bg); - if (bg >= 0) + else { - snprintf (color[index_color], sizeof (color[index_color]), - "%sB%02d", - GUI_COLOR_COLOR_STR, bg); + pos_comma = strchr (color_name, ','); + if (pos_comma) + { + if (pos_comma == color_name) + str_fg = NULL; + else + str_fg = string_strndup (color_name, pos_comma - color_name); + pos_bg = pos_comma + 1; + } + else + { + str_fg = strdup (color_name); + pos_bg = NULL; + } + + if (str_fg && pos_bg) + { + fg = gui_color_search (str_fg); + bg = gui_color_search (pos_bg); + if ((fg >= 0) && (bg >= 0)) + { + snprintf (color[index_color], sizeof (color[index_color]), + "%s%s%02d,%02d", + GUI_COLOR_COLOR_STR, + GUI_COLOR_FG_BG_STR, + fg, bg); + } + } + else if (str_fg && !pos_bg) + { + fg = gui_color_search (str_fg); + if (fg >= 0) + { + snprintf (color[index_color], sizeof (color[index_color]), + "%s%s%02d", + GUI_COLOR_COLOR_STR, + GUI_COLOR_FG_STR, + fg); + } + } + else if (!str_fg && pos_bg) + { + bg = gui_color_search (pos_bg); + if (bg >= 0) + { + snprintf (color[index_color], sizeof (color[index_color]), + "%s%s%02d", + GUI_COLOR_COLOR_STR, + GUI_COLOR_BG_STR, + bg); + } + } + + if (str_fg) + free (str_fg); } } - - if (str_fg) - free (str_fg); } return color[index_color]; @@ -288,6 +322,12 @@ gui_color_decode (const char *string, const char *replacement) && ptr_string[4] && ptr_string[5]) ptr_string += 6; break; + case GUI_COLOR_PAIR_CHAR: + if ((isdigit (string[1])) && (isdigit (string[2])) + && (isdigit (string[3])) && (isdigit (string[4])) + && (isdigit (string[5]))) + ptr_string += 6; + break; case GUI_COLOR_BAR_CHAR: ptr_string++; switch (ptr_string[0]) @@ -438,3 +478,144 @@ gui_color_free (struct t_gui_color *color) free (color); } } + +/* + * gui_color_palette_alloc: allocate hashtables and lists for palette + */ + +void +gui_color_palette_alloc () +{ + if (!gui_color_hash_palette_color) + { + gui_color_hash_palette_color = hashtable_new (16, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_POINTER, + NULL, + NULL); + } + if (!gui_color_hash_palette_alias) + { + gui_color_hash_palette_alias = hashtable_new (16, + WEECHAT_HASHTABLE_STRING, + WEECHAT_HASHTABLE_INTEGER, + NULL, + NULL); + } + if (!gui_color_list_with_alias) + { + gui_color_list_with_alias = weelist_new (); + } +} + +/* + * gui_color_palette_get_alias: get color pair number with alias + * return -1 if alias is not found + */ + +int +gui_color_palette_get_alias (const char *alias) +{ + int *ptr_number; + + if (gui_color_hash_palette_alias) + { + ptr_number = hashtable_get (gui_color_hash_palette_alias, alias); + if (ptr_number) + return *ptr_number; + } + + /* alias not found */ + return -1; +} + +/* + * gui_color_palette_get: get a color palette with number + */ + +struct t_gui_color_palette * +gui_color_palette_get (int number) +{ + char str_number[64]; + + snprintf (str_number, sizeof (str_number), "%d", number); + return hashtable_get (gui_color_hash_palette_color, + str_number); +} + +/* + * gui_color_palette_add: add a color in palette + */ + +void +gui_color_palette_add (int number, const char *value) +{ + struct t_gui_color_palette *new_color_palette, *ptr_color_palette; + char str_number[64]; + + gui_color_palette_alloc (); + + new_color_palette = gui_color_palette_new (number, value); + if (!new_color_palette) + return; + + snprintf (str_number, sizeof (str_number), "%d", number); + ptr_color_palette = hashtable_get (gui_color_hash_palette_color, + str_number); + if (ptr_color_palette) + gui_color_palette_free (ptr_color_palette); + hashtable_set (gui_color_hash_palette_color, + str_number, new_color_palette); + gui_color_palette_build_aliases (); + + if (gui_init_ok) + gui_color_init_pair (number); +} + +/* + * gui_color_palette_remove: remove a color in palette + */ + +void +gui_color_palette_remove (int number) +{ + struct t_gui_color_palette *ptr_color_palette; + char str_number[64]; + + gui_color_palette_alloc (); + + snprintf (str_number, sizeof (str_number), "%d", number); + ptr_color_palette = hashtable_get (gui_color_hash_palette_color, + str_number); + if (ptr_color_palette) + { + gui_color_palette_free (ptr_color_palette); + hashtable_remove (gui_color_hash_palette_color, str_number); + gui_color_palette_build_aliases (); + if (gui_init_ok) + gui_color_init_pair (number); + } +} + +/* + * gui_color_palette_change: change a color in palette + */ + +void +gui_color_palette_change (int number, const char *value) +{ + struct t_gui_color_palette *ptr_color_palette; + char str_number[64]; + + gui_color_palette_alloc (); + + snprintf (str_number, sizeof (str_number), "%d", number); + ptr_color_palette = hashtable_get (gui_color_hash_palette_color, + str_number); + if (ptr_color_palette) + { + gui_color_palette_free (ptr_color_palette); + hashtable_remove (gui_color_hash_palette_color, str_number); + gui_color_palette_add (number, value); + } +} diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h index 0d8872b..1ea73bd 100644 --- a/src/gui/gui-color.h +++ b/src/gui/gui-color.h @@ -97,6 +97,8 @@ enum t_gui_color_enum #define GUI_COLOR_BG_STR "B" #define GUI_COLOR_FG_BG_CHAR '*' #define GUI_COLOR_FG_BG_STR "*" +#define GUI_COLOR_PAIR_CHAR '@' +#define GUI_COLOR_PAIR_STR "@" #define GUI_COLOR_BAR_CHAR 'b' #define GUI_COLOR_BAR_STR "b" #define GUI_COLOR_BAR_FG_CHAR 'F' @@ -122,9 +124,22 @@ struct t_gui_color char *string; /* WeeChat color: "\x19??", ?? is #color*/ }; +/* custom color in palette */ + +struct t_gui_color_palette +{ + char *alias; /* alias name for this color pair */ + int foreground; /* foreground color */ + int background; /* background color */ + int r, g, b; /* red/green/blue values for color */ +}; + /* color variables */ extern struct t_gui_color *gui_color[]; +extern struct t_hashtable *gui_color_hash_palette_color; +extern struct t_hashtable *gui_color_hash_palette_alias; +extern struct t_weelist *gui_color_list_with_alias; /* color functions */ @@ -133,14 +148,27 @@ extern const char *gui_color_get_custom (const char *color_name); extern char *gui_color_decode (const char *string, const char *replacement); extern char *gui_color_string_replace_colors (const char *string); extern void gui_color_free (struct t_gui_color *color); +extern int gui_color_palette_get_alias (const char *alias); +extern struct t_gui_color_palette *gui_color_palette_get (int number); +extern void gui_color_palette_add (int number, const char *value); +extern void gui_color_palette_remove (int number); +extern void gui_color_palette_change (int number, const char *value); /* color functions (GUI dependent) */ extern int gui_color_search (const char *color_name); extern int gui_color_assign (int *color, char const *color_name); +extern int gui_color_assign_by_diff (int *color, const char *color_name, + int diff); extern int gui_color_get_number (); extern const char *gui_color_get_name (int num_color); +extern void gui_color_init_pair (int number); extern void gui_color_init_pairs (); extern void gui_color_init_weechat (); +extern void gui_color_display_terminal_colors (); +extern void gui_color_palette_build_aliases (); +extern struct t_gui_color_palette *gui_color_palette_new (int number, + const char *value); +extern void gui_color_palette_free (struct t_gui_color_palette *color_palette); #endif /* __WEECHAT_GUI_COLOR_H */ diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index 3fbda47..8ae5131 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -511,7 +511,9 @@ plugin_load (const char *filename) new_plugin->list_new = &weelist_new; new_plugin->list_add = &weelist_add; new_plugin->list_search = &weelist_search; + new_plugin->list_search_pos = &weelist_search_pos; new_plugin->list_casesearch = &weelist_casesearch; + new_plugin->list_casesearch_pos = &weelist_casesearch_pos; new_plugin->list_get = &weelist_get; new_plugin->list_set = &weelist_set; new_plugin->list_next = &weelist_next; diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c index 226eb86..991116d 100644 --- a/src/plugins/scripts/lua/weechat-lua-api.c +++ b/src/plugins/scripts/lua/weechat-lua-api.c @@ -817,6 +817,41 @@ weechat_lua_api_list_search (lua_State *L) } /* + * weechat_lua_api_list_search_pos: search position of a string in list + */ + +static int +weechat_lua_api_list_search_pos (lua_State *L) +{ + const char *weelist, *data; + int n, pos; + + /* make C compiler happy */ + (void) L; + + if (!lua_current_script || !lua_current_script->name) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "list_search_pos"); + LUA_RETURN_INT(-1); + } + + n = lua_gettop (lua_current_interpreter); + + if (n < 2) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "list_search_pos"); + LUA_RETURN_INT(-1); + } + + weelist = lua_tostring (lua_current_interpreter, -2); + data = lua_tostring (lua_current_interpreter, -1); + + pos = weechat_list_search_pos (script_str2ptr (weelist), data); + + LUA_RETURN_INT(pos); +} + +/* * weechat_lua_api_list_casesearch: search a string in list (ignore case) */ @@ -854,6 +889,42 @@ weechat_lua_api_list_casesearch (lua_State *L) } /* + * weechat_lua_api_list_casesearch_pos: search position of a string in list + * (ignore case) + */ + +static int +weechat_lua_api_list_casesearch_pos (lua_State *L) +{ + const char *weelist, *data; + int n, pos; + + /* make C compiler happy */ + (void) L; + + if (!lua_current_script || !lua_current_script->name) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(LUA_CURRENT_SCRIPT_NAME, "list_casesearch_pos"); + LUA_RETURN_INT(-1); + } + + n = lua_gettop (lua_current_interpreter); + + if (n < 2) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(LUA_CURRENT_SCRIPT_NAME, "list_casesearch_pos"); + LUA_RETURN_INT(-1); + } + + weelist = lua_tostring (lua_current_interpreter, -2); + data = lua_tostring (lua_current_interpreter, -1); + + pos = weechat_list_casesearch_pos (script_str2ptr (weelist), data); + + LUA_RETURN_INT(pos); +} + +/* * weechat_lua_api_list_get: get item by position */ @@ -7612,7 +7683,9 @@ const struct luaL_reg weechat_lua_api_funcs[] = { { "list_new", &weechat_lua_api_list_new }, { "list_add", &weechat_lua_api_list_add }, { "list_search", &weechat_lua_api_list_search }, + { "list_search_pos", &weechat_lua_api_list_search_pos }, { "list_casesearch", &weechat_lua_api_list_casesearch }, + { "list_casesearch_pos", &weechat_lua_api_list_casesearch_pos }, { "list_get", &weechat_lua_api_list_get }, { "list_set", &weechat_lua_api_list_set }, { "list_next", &weechat_lua_api_list_next }, diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c index 273661e..22060c5 100644 --- a/src/plugins/scripts/perl/weechat-perl-api.c +++ b/src/plugins/scripts/perl/weechat-perl-api.c @@ -729,6 +729,39 @@ XS (XS_weechat_api_list_search) } /* + * weechat::list_search_pos: search position of a string in list + */ + +XS (XS_weechat_api_list_search_pos) +{ + char *weelist, *data; + int pos; + dXSARGS; + + /* make C compiler happy */ + (void) cv; + + if (!perl_current_script || !perl_current_script->name) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "list_search_pos"); + PERL_RETURN_INT(-1); + } + + if (items < 2) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "list_search_pos"); + PERL_RETURN_INT(-1); + } + + weelist = SvPV (ST (0), PL_na); + data = SvPV (ST (1), PL_na); + + pos = weechat_list_search_pos (script_str2ptr (weelist), data); + + PERL_RETURN_INT(pos); +} + +/* * weechat::list_casesearch: search a string in list (ignore case) */ @@ -762,6 +795,40 @@ XS (XS_weechat_api_list_casesearch) } /* + * weechat::list_casesearch_pos: search position of a string in list + * (ignore case) + */ + +XS (XS_weechat_api_list_casesearch_pos) +{ + char *weelist, *data; + int pos; + dXSARGS; + + /* make C compiler happy */ + (void) cv; + + if (!perl_current_script || !perl_current_script->name) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(PERL_CURRENT_SCRIPT_NAME, "list_casesearch_pos"); + PERL_RETURN_INT(-1); + } + + if (items < 2) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PERL_CURRENT_SCRIPT_NAME, "list_casesearch_pos"); + PERL_RETURN_INT(-1); + } + + weelist = SvPV (ST (0), PL_na); + data = SvPV (ST (1), PL_na); + + pos = weechat_list_casesearch_pos (script_str2ptr (weelist), data); + + PERL_RETURN_INT(pos); +} + +/* * weechat::list_get: get item by position */ @@ -6553,7 +6620,9 @@ weechat_perl_api_init (pTHX) newXS ("weechat::list_new", XS_weechat_api_list_new, "weechat"); newXS ("weechat::list_add", XS_weechat_api_list_add, "weechat"); newXS ("weechat::list_search", XS_weechat_api_list_search, "weechat"); + newXS ("weechat::list_search_pos", XS_weechat_api_list_search_pos, "weechat"); newXS ("weechat::list_casesearch", XS_weechat_api_list_casesearch, "weechat"); + newXS ("weechat::list_casesearch_pos", XS_weechat_api_list_casesearch_pos, "weechat"); newXS ("weechat::list_get", XS_weechat_api_list_get, "weechat"); newXS ("weechat::list_set", XS_weechat_api_list_set, "weechat"); newXS ("weechat::list_next", XS_weechat_api_list_next, "weechat"); diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c index 6429ad3..3aed890 100644 --- a/src/plugins/scripts/python/weechat-python-api.c +++ b/src/plugins/scripts/python/weechat-python-api.c @@ -769,6 +769,39 @@ weechat_python_api_list_search (PyObject *self, PyObject *args) } /* + * weechat_python_api_list_search_pos: search position of a string in list + */ + +static PyObject * +weechat_python_api_list_search_pos (PyObject *self, PyObject *args) +{ + char *weelist, *data; + int pos; + + /* make C compiler happy */ + (void) self; + + if (!python_current_script || !python_current_script->name) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_search_pos"); + PYTHON_RETURN_INT(-1); + } + + weelist = NULL; + data = NULL; + + if (!PyArg_ParseTuple (args, "ss", &weelist, &data)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_search_pos"); + PYTHON_RETURN_INT(-1); + } + + pos = weechat_list_search_pos (script_str2ptr (weelist), data); + + PYTHON_RETURN_INT(pos); +} + +/* * weechat_python_api_list_casesearch: search a string in list (ignore case) */ @@ -803,6 +836,40 @@ weechat_python_api_list_casesearch (PyObject *self, PyObject *args) } /* + * weechat_python_api_list_casesearch_pos: search position of a string in list + * (ignore case) + */ + +static PyObject * +weechat_python_api_list_casesearch_pos (PyObject *self, PyObject *args) +{ + char *weelist, *data; + int pos; + + /* make C compiler happy */ + (void) self; + + if (!python_current_script || !python_current_script->name) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(PYTHON_CURRENT_SCRIPT_NAME, "list_casesearch_pos"); + PYTHON_RETURN_INT(-1); + } + + weelist = NULL; + data = NULL; + + if (!PyArg_ParseTuple (args, "ss", &weelist, &data)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(PYTHON_CURRENT_SCRIPT_NAME, "list_casesearch_pos"); + PYTHON_RETURN_INT(-1); + } + + pos = weechat_list_casesearch_pos (script_str2ptr (weelist), data); + + PYTHON_RETURN_INT(pos); +} + +/* * weechat_python_api_list_get: get item by position */ @@ -6886,7 +6953,9 @@ PyMethodDef weechat_python_funcs[] = { "list_new", &weechat_python_api_list_new, METH_VARARGS, "" }, { "list_add", &weechat_python_api_list_add, METH_VARARGS, "" }, { "list_search", &weechat_python_api_list_search, METH_VARARGS, "" }, + { "list_search_pos", &weechat_python_api_list_search_pos, METH_VARARGS, "" }, { "list_casesearch", &weechat_python_api_list_casesearch, METH_VARARGS, "" }, + { "list_casesearch_pos", &weechat_python_api_list_casesearch_pos, METH_VARARGS, "" }, { "list_get", &weechat_python_api_list_get, METH_VARARGS, "" }, { "list_set", &weechat_python_api_list_set, METH_VARARGS, "" }, { "list_next", &weechat_python_api_list_next, METH_VARARGS, "" }, diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c index 3351652..93d211d 100644 --- a/src/plugins/scripts/ruby/weechat-ruby-api.c +++ b/src/plugins/scripts/ruby/weechat-ruby-api.c @@ -831,6 +831,42 @@ weechat_ruby_api_list_search (VALUE class, VALUE weelist, VALUE data) } /* + * weechat_ruby_api_list_search_pos: search position of a string in list + */ + +static VALUE +weechat_ruby_api_list_search_pos (VALUE class, VALUE weelist, VALUE data) +{ + char *c_weelist, *c_data; + int pos; + + /* make C compiler happy */ + (void) class; + + if (!ruby_current_script || !ruby_current_script->name) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "list_search_pos"); + RUBY_RETURN_INT(-1); + } + + if (NIL_P (weelist) || NIL_P (data)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "list_search_pos"); + RUBY_RETURN_INT(-1); + } + + Check_Type (weelist, T_STRING); + Check_Type (data, T_STRING); + + c_weelist = StringValuePtr (weelist); + c_data = StringValuePtr (data); + + pos = weechat_list_search_pos (script_str2ptr(c_weelist), c_data); + + RUBY_RETURN_INT(pos); +} + +/* * weechat_ruby_api_list_casesearch: search a string in list (ignore case) */ @@ -867,6 +903,43 @@ weechat_ruby_api_list_casesearch (VALUE class, VALUE weelist, VALUE data) } /* + * weechat_ruby_api_list_casesearch_pos: search position of a string in list + * (ignore case) + */ + +static VALUE +weechat_ruby_api_list_casesearch_pos (VALUE class, VALUE weelist, VALUE data) +{ + char *c_weelist, *c_data; + int pos; + + /* make C compiler happy */ + (void) class; + + if (!ruby_current_script || !ruby_current_script->name) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(RUBY_CURRENT_SCRIPT_NAME, "list_casesearch_pos"); + RUBY_RETURN_INT(-1); + } + + if (NIL_P (weelist) || NIL_P (data)) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(RUBY_CURRENT_SCRIPT_NAME, "list_casesearch_pos"); + RUBY_RETURN_INT(-1); + } + + Check_Type (weelist, T_STRING); + Check_Type (data, T_STRING); + + c_weelist = StringValuePtr (weelist); + c_data = StringValuePtr (data); + + pos = weechat_list_casesearch_pos (script_str2ptr(c_weelist), c_data); + + RUBY_RETURN_INT(pos); +} + +/* * weechat_ruby_api_list_get: get item by position */ @@ -7546,7 +7619,9 @@ weechat_ruby_api_init (VALUE ruby_mWeechat) rb_define_module_function (ruby_mWeechat, "list_new", &weechat_ruby_api_list_new, 0); rb_define_module_function (ruby_mWeechat, "list_add", &weechat_ruby_api_list_add, 4); rb_define_module_function (ruby_mWeechat, "list_search", &weechat_ruby_api_list_search, 2); + rb_define_module_function (ruby_mWeechat, "list_search_pos", &weechat_ruby_api_list_search_pos, 2); rb_define_module_function (ruby_mWeechat, "list_casesearch", &weechat_ruby_api_list_casesearch, 2); + rb_define_module_function (ruby_mWeechat, "list_casesearch_pos", &weechat_ruby_api_list_casesearch_pos, 2); rb_define_module_function (ruby_mWeechat, "list_get", &weechat_ruby_api_list_get, 2); rb_define_module_function (ruby_mWeechat, "list_set", &weechat_ruby_api_list_set, 2); rb_define_module_function (ruby_mWeechat, "list_next", &weechat_ruby_api_list_next, 1); diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c index 581b549..9d19462 100644 --- a/src/plugins/scripts/tcl/weechat-tcl-api.c +++ b/src/plugins/scripts/tcl/weechat-tcl-api.c @@ -932,6 +932,41 @@ weechat_tcl_api_list_search (ClientData clientData, Tcl_Interp *interp, } /* + * weechat_tcl_api_list_search_pos: search position of a string in list + */ + +static int +weechat_tcl_api_list_search_pos (ClientData clientData, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]) +{ + Tcl_Obj* objp; + char *weelist, *data; + int i, pos; + + /* make C compiler happy */ + (void) clientData; + + if (!tcl_current_script || !tcl_current_script->name) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "list_search_pos"); + TCL_RETURN_INT(-1); + } + + if (objc < 3) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "list_search_pos"); + TCL_RETURN_INT(-1); + } + + weelist = Tcl_GetStringFromObj (objv[1], &i); + data = Tcl_GetStringFromObj (objv[2], &i); + + pos = weechat_list_search_pos (script_str2ptr (weelist), data); + + TCL_RETURN_INT(pos); +} + +/* * weechat_tcl_api_list_casesearch: search a string in list (ignore case) */ @@ -968,6 +1003,42 @@ weechat_tcl_api_list_casesearch (ClientData clientData, Tcl_Interp *interp, } /* + * weechat_tcl_api_list_casesearch_pos: search position of a string in list + * (ignore case) + */ + +static int +weechat_tcl_api_list_casesearch_pos (ClientData clientData, Tcl_Interp *interp, + int objc, Tcl_Obj *CONST objv[]) +{ + Tcl_Obj* objp; + char *weelist, *data; + int i, pos; + + /* make C compiler happy */ + (void) clientData; + + if (!tcl_current_script || !tcl_current_script->name) + { + WEECHAT_SCRIPT_MSG_NOT_INIT(TCL_CURRENT_SCRIPT_NAME, "list_casesearch_pos"); + TCL_RETURN_INT(-1); + } + + if (objc < 3) + { + WEECHAT_SCRIPT_MSG_WRONG_ARGS(TCL_CURRENT_SCRIPT_NAME, "list_casesearch_pos"); + TCL_RETURN_INT(-1); + } + + weelist = Tcl_GetStringFromObj (objv[1], &i); + data = Tcl_GetStringFromObj (objv[2], &i); + + pos = weechat_list_casesearch_pos (script_str2ptr (weelist), data); + + TCL_RETURN_INT(pos); +} + +/* * weechat_tcl_api_list_get: get item by position */ @@ -7405,8 +7476,12 @@ void weechat_tcl_api_init (Tcl_Interp *interp) weechat_tcl_api_list_add, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp, "weechat::list_search", weechat_tcl_api_list_search, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); + Tcl_CreateObjCommand (interp, "weechat::list_search_pos", + weechat_tcl_api_list_search_pos, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp, "weechat::list_casesearch", weechat_tcl_api_list_casesearch, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); + Tcl_CreateObjCommand (interp, "weechat::list_casesearch_pos", + weechat_tcl_api_list_casesearch_pos, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp, "weechat::list_get", weechat_tcl_api_list_get, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL); Tcl_CreateObjCommand (interp, "weechat::list_set", diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index 4f84669..9ac9b3a 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -45,7 +45,7 @@ struct timeval; */ /* API version (used to check that plugin has same API and can be loaded) */ -#define WEECHAT_PLUGIN_API_VERSION "20101125-01" +#define WEECHAT_PLUGIN_API_VERSION "20101219-01" /* macros for defining plugin infos */ #define WEECHAT_PLUGIN_NAME(__name) \ @@ -237,8 +237,12 @@ struct t_weechat_plugin void *user_data); struct t_weelist_item *(*list_search) (struct t_weelist *weelist, const char *data); + int (*list_search_pos) (struct t_weelist *weelist, + const char *data); struct t_weelist_item *(*list_casesearch) (struct t_weelist *weelist, const char *data); + int (*list_casesearch_pos) (struct t_weelist *weelist, + const char *data); struct t_weelist_item *(*list_get) (struct t_weelist *weelist, int position); void (*list_set) (struct t_weelist_item *item, const char *value); @@ -899,8 +903,12 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); weechat_plugin->list_add(__list, __string, __where, __user_data) #define weechat_list_search(__list, __string) \ weechat_plugin->list_search(__list, __string) +#define weechat_list_search_pos(__list, __string) \ + weechat_plugin->list_search_pos(__list, __string) #define weechat_list_casesearch(__list, __string) \ weechat_plugin->list_casesearch(__list, __string) +#define weechat_list_casesearch_pos(__list, __string) \ + weechat_plugin->list_casesearch_pos(__list, __string) #define weechat_list_get(__list, __index) \ weechat_plugin->list_get(__list, __index) #define weechat_list_set(__item, __value) \