From 4da8fcf34d79d063a011329044c09b3a9cc382d9 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sun, 19 Jan 2014 23:29:00 +0100 Subject: [PATCH] core: add command /print --- ChangeLog | 1 + doc/de/autogen/user/weechat_commands.txt | 38 ++++ doc/en/autogen/user/weechat_commands.txt | 38 ++++ doc/fr/autogen/user/weechat_commands.txt | 38 ++++ doc/it/autogen/user/weechat_commands.txt | 38 ++++ doc/ja/autogen/user/weechat_commands.txt | 38 ++++ doc/pl/autogen/user/weechat_commands.txt | 38 ++++ po/cs.po | 46 ++++- po/de.po | 46 ++++- po/es.po | 46 ++++- po/fr.po | 84 ++++++++- po/hu.po | 46 ++++- po/it.po | 46 ++++- po/ja.po | 46 ++++- po/pl.po | 46 ++++- po/pt_BR.po | 46 ++++- po/ru.po | 46 ++++- po/tr.po | 45 ++++- po/weechat.pot | 45 ++++- src/core/wee-command.c | 229 +++++++++++++++++++++++ src/core/wee-string.c | 162 +++++++++++----- src/core/wee-string.h | 2 +- src/gui/gui-input.c | 2 +- 23 files changed, 1145 insertions(+), 67 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2d230c31d..75b74fd7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] == Version 0.4.3 (under dev) +* core: add command /print * core: add option weechat.look.tab_width * core: add completion "plugins_installed" * core: fix crash in /eval when config option has a NULL value diff --git a/doc/de/autogen/user/weechat_commands.txt b/doc/de/autogen/user/weechat_commands.txt index 0c95ea36e..5070f5ada 100644 --- a/doc/de/autogen/user/weechat_commands.txt +++ b/doc/de/autogen/user/weechat_commands.txt @@ -561,6 +561,44 @@ arguments: Argumente die der Erweiterung beim installieren übergeben werden sol Ohne Angabe eines Arguments werden alle installierten Erweiterungen angezeigt. ---- +[[command_weechat_print]] +[command]*`print`* display text on a buffer:: + +---- +/print [-buffer |] [-core] [-escape] [-date ] [-tags ] [-action|-error|-join|-network|-quit] + -stdout|-stderr + +-buffer: the buffer where text is displayed (default: current buffer) + -core: alias of "-buffer core.weechat" +-escape: interpret escaped chars (for example \a, \07, \x07) + -date: message date, format can be: + -n: 'n' seconds before now + +n: 'n' seconds in the future + n: 'n' seconds since the Epoch (see man time) + date/time (ISO 8601): yyyy-mm-ddThh:mm:ss, example: 2014-01-19T04:32:55 + time: hh:mm:ss (example: 04:32:55) + -tags: comma-separated list of tags (see /help filter for a list of tags most commonly used) + text: text to display (prefix and message must be separated by \t) +-stdout: display text on stdout (not in a buffer) +-stderr: display text on stderr (not in a buffer) + +The options -action ... -quit use the prefix defined in options "weechat.look.prefix_*". + +With options -stdout and -stderr, escaped chars are always interpreted. + +Examples: + display a reminder on core buffer with a highlight: + /print -core -tags notify_highlight Reminder: buy milk + display an error on core buffer: + /print -core -error Some error here + display message on core buffer with prefix "abc": + /print -core abc The message + display a message on channel #weechat: + /print -buffer irc.freenode.#weechat Message on #weechat + send alert (BEL): + /print -stderr \a +---- + [[command_weechat_proxy]] [command]*`proxy`* Proxys verwalten:: diff --git a/doc/en/autogen/user/weechat_commands.txt b/doc/en/autogen/user/weechat_commands.txt index 12a20d9bd..3dc69a684 100644 --- a/doc/en/autogen/user/weechat_commands.txt +++ b/doc/en/autogen/user/weechat_commands.txt @@ -561,6 +561,44 @@ arguments: arguments given to plugin on load Without argument, this command lists loaded plugins. ---- +[[command_weechat_print]] +[command]*`print`* display text on a buffer:: + +---- +/print [-buffer |] [-core] [-escape] [-date ] [-tags ] [-action|-error|-join|-network|-quit] + -stdout|-stderr + +-buffer: the buffer where text is displayed (default: current buffer) + -core: alias of "-buffer core.weechat" +-escape: interpret escaped chars (for example \a, \07, \x07) + -date: message date, format can be: + -n: 'n' seconds before now + +n: 'n' seconds in the future + n: 'n' seconds since the Epoch (see man time) + date/time (ISO 8601): yyyy-mm-ddThh:mm:ss, example: 2014-01-19T04:32:55 + time: hh:mm:ss (example: 04:32:55) + -tags: comma-separated list of tags (see /help filter for a list of tags most commonly used) + text: text to display (prefix and message must be separated by \t) +-stdout: display text on stdout (not in a buffer) +-stderr: display text on stderr (not in a buffer) + +The options -action ... -quit use the prefix defined in options "weechat.look.prefix_*". + +With options -stdout and -stderr, escaped chars are always interpreted. + +Examples: + display a reminder on core buffer with a highlight: + /print -core -tags notify_highlight Reminder: buy milk + display an error on core buffer: + /print -core -error Some error here + display message on core buffer with prefix "abc": + /print -core abc The message + display a message on channel #weechat: + /print -buffer irc.freenode.#weechat Message on #weechat + send alert (BEL): + /print -stderr \a +---- + [[command_weechat_proxy]] [command]*`proxy`* manage proxies:: diff --git a/doc/fr/autogen/user/weechat_commands.txt b/doc/fr/autogen/user/weechat_commands.txt index 513410da1..d2ad06c27 100644 --- a/doc/fr/autogen/user/weechat_commands.txt +++ b/doc/fr/autogen/user/weechat_commands.txt @@ -561,6 +561,44 @@ paramètres: paramètres donnés à l'extension lors de son chargement Sans paramètre, cette commande liste les extensions chargées. ---- +[[command_weechat_print]] +[command]*`print`* afficher du texte dans un tampon:: + +---- +/print [-buffer |] [-core] [-escape] [-date ] [-tags <étiquettes>] [-action|-error|-join|-network|-quit] + -stdout|-stderr + +-buffer: le tampon où est affiché le texte (par défaut: tampon courant) + -core: alias de "-buffer core.weechat" +-escape: interpréter les caractères échappés (par exemple \a, \07, \x07) + -date: date du message, le format peut être : + -n: 'n' secondes avant maintenant + +n: 'n' secondes dans le futur + n: 'n' secondes depuis l'époque (voir man time) + date/heure (ISO 8601): yyyy-mm-ddThh:mm:ss, exemple: 2014-01-19T04:32:55 + heure: hh:mm:ss (exemple: 04:32:55) + -tags: liste d'étiquettes séparées par des virgules (voir /help filter pour une liste des étiquettes couramment utilisées) + texte: texte à afficher (le préfixe et le message doivent être séparés par \t) +-stdout: afficher le texte sur stdout (pas dans un tampon) +-stderr: afficher le texte sur stderr (pas dans un tampon) + +Les options -action ... -quit utilisent le préfixe défini dans les options "weechat.look.prefix_*". + +Avec les options -stdout et -stderr, les caractères échappés sont toujours interprétés. + +Exemples: + afficher un pense-bête sur le tampon core avec un highlight: + /print -core -tags notify_highlight Pense-bête: acheter du lait + afficher une erreur sur le tampon core: + /print -core -error Une erreur ici + afficher un message sur le tampon core avec le préfixe "abc": + /print -core abc\tLe message + afficher un message sur le canal #weechat: + /print -buffer irc.freenode.#weechat Message sur #weechat + envoyer une alerte (BEL): + /print -stderr \a +---- + [[command_weechat_proxy]] [command]*`proxy`* gestion des proxies:: diff --git a/doc/it/autogen/user/weechat_commands.txt b/doc/it/autogen/user/weechat_commands.txt index 1588b6c4b..ca78ac9d6 100644 --- a/doc/it/autogen/user/weechat_commands.txt +++ b/doc/it/autogen/user/weechat_commands.txt @@ -561,6 +561,44 @@ argomenti: argomenti passati al plugin durante il caricamento Senza argomento, questo comando elenca i plugin caricati. ---- +[[command_weechat_print]] +[command]*`print`* display text on a buffer:: + +---- +/print [-buffer |] [-core] [-escape] [-date ] [-tags ] [-action|-error|-join|-network|-quit] + -stdout|-stderr + +-buffer: the buffer where text is displayed (default: current buffer) + -core: alias of "-buffer core.weechat" +-escape: interpret escaped chars (for example \a, \07, \x07) + -date: message date, format can be: + -n: 'n' seconds before now + +n: 'n' seconds in the future + n: 'n' seconds since the Epoch (see man time) + date/time (ISO 8601): yyyy-mm-ddThh:mm:ss, example: 2014-01-19T04:32:55 + time: hh:mm:ss (example: 04:32:55) + -tags: comma-separated list of tags (see /help filter for a list of tags most commonly used) + text: text to display (prefix and message must be separated by \t) +-stdout: display text on stdout (not in a buffer) +-stderr: display text on stderr (not in a buffer) + +The options -action ... -quit use the prefix defined in options "weechat.look.prefix_*". + +With options -stdout and -stderr, escaped chars are always interpreted. + +Examples: + display a reminder on core buffer with a highlight: + /print -core -tags notify_highlight Reminder: buy milk + display an error on core buffer: + /print -core -error Some error here + display message on core buffer with prefix "abc": + /print -core abc The message + display a message on channel #weechat: + /print -buffer irc.freenode.#weechat Message on #weechat + send alert (BEL): + /print -stderr \a +---- + [[command_weechat_proxy]] [command]*`proxy`* gestione dei proxy:: diff --git a/doc/ja/autogen/user/weechat_commands.txt b/doc/ja/autogen/user/weechat_commands.txt index 012b5db50..0ea144c52 100644 --- a/doc/ja/autogen/user/weechat_commands.txt +++ b/doc/ja/autogen/user/weechat_commands.txt @@ -561,6 +561,44 @@ arguments: ロードするプラグインに与える引数 引数無しでは、ロードされたプラグインをリストアップ。 ---- +[[command_weechat_print]] +[command]*`print`* display text on a buffer:: + +---- +/print [-buffer |] [-core] [-escape] [-date ] [-tags ] [-action|-error|-join|-network|-quit] + -stdout|-stderr + +-buffer: the buffer where text is displayed (default: current buffer) + -core: alias of "-buffer core.weechat" +-escape: interpret escaped chars (for example \a, \07, \x07) + -date: message date, format can be: + -n: 'n' seconds before now + +n: 'n' seconds in the future + n: 'n' seconds since the Epoch (see man time) + date/time (ISO 8601): yyyy-mm-ddThh:mm:ss, example: 2014-01-19T04:32:55 + time: hh:mm:ss (example: 04:32:55) + -tags: comma-separated list of tags (see /help filter for a list of tags most commonly used) + text: text to display (prefix and message must be separated by \t) +-stdout: display text on stdout (not in a buffer) +-stderr: display text on stderr (not in a buffer) + +The options -action ... -quit use the prefix defined in options "weechat.look.prefix_*". + +With options -stdout and -stderr, escaped chars are always interpreted. + +Examples: + display a reminder on core buffer with a highlight: + /print -core -tags notify_highlight Reminder: buy milk + display an error on core buffer: + /print -core -error Some error here + display message on core buffer with prefix "abc": + /print -core abc The message + display a message on channel #weechat: + /print -buffer irc.freenode.#weechat Message on #weechat + send alert (BEL): + /print -stderr \a +---- + [[command_weechat_proxy]] [command]*`proxy`* プロキシの管理:: diff --git a/doc/pl/autogen/user/weechat_commands.txt b/doc/pl/autogen/user/weechat_commands.txt index 36b596cce..38feae0d7 100644 --- a/doc/pl/autogen/user/weechat_commands.txt +++ b/doc/pl/autogen/user/weechat_commands.txt @@ -561,6 +561,44 @@ argumenty: argumenty przekazywane do wtyczki podczas ładowania Bez argumentów ta komenda wyświetli wszystkie załadowane wtyczki. ---- +[[command_weechat_print]] +[command]*`print`* display text on a buffer:: + +---- +/print [-buffer |] [-core] [-escape] [-date ] [-tags ] [-action|-error|-join|-network|-quit] + -stdout|-stderr + +-buffer: the buffer where text is displayed (default: current buffer) + -core: alias of "-buffer core.weechat" +-escape: interpret escaped chars (for example \a, \07, \x07) + -date: message date, format can be: + -n: 'n' seconds before now + +n: 'n' seconds in the future + n: 'n' seconds since the Epoch (see man time) + date/time (ISO 8601): yyyy-mm-ddThh:mm:ss, example: 2014-01-19T04:32:55 + time: hh:mm:ss (example: 04:32:55) + -tags: comma-separated list of tags (see /help filter for a list of tags most commonly used) + text: text to display (prefix and message must be separated by \t) +-stdout: display text on stdout (not in a buffer) +-stderr: display text on stderr (not in a buffer) + +The options -action ... -quit use the prefix defined in options "weechat.look.prefix_*". + +With options -stdout and -stderr, escaped chars are always interpreted. + +Examples: + display a reminder on core buffer with a highlight: + /print -core -tags notify_highlight Reminder: buy milk + display an error on core buffer: + /print -core -error Some error here + display message on core buffer with prefix "abc": + /print -core abc The message + display a message on channel #weechat: + /print -buffer irc.freenode.#weechat Message on #weechat + send alert (BEL): + /print -stderr \a +---- + [[command_weechat_proxy]] [command]*`proxy`* zarządzanie proxy:: diff --git a/po/cs.po b/po/cs.po index 7c1df24f9..9049e4cdf 100644 --- a/po/cs.po +++ b/po/cs.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-18 21:17+0100\n" +"POT-Creation-Date: 2014-01-19 19:42+0100\n" "PO-Revision-Date: 2014-01-18 21:20+0100\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -1860,6 +1860,50 @@ msgstr "" "\n" "Zavolání příkazu bez parametrů vypíše načtené pluginy." +#, fuzzy +msgid "display text on a buffer" +msgstr "barva textu pro jeméno bufferu" + +msgid "" +"[-buffer |] [-core] [-escape] [-date ] [-tags ] [-" +"action|-error|-join|-network|-quit] || -stdout|-stderr " +msgstr "" + +msgid "" +"-buffer: the buffer where text is displayed (default: current buffer)\n" +" -core: alias of \"-buffer core.weechat\"\n" +"-escape: interpret escaped chars (for example \\a, \\07, \\x07)\n" +" -date: message date, format can be:\n" +" -n: 'n' seconds before now\n" +" +n: 'n' seconds in the future\n" +" n: 'n' seconds since the Epoch (see man time)\n" +" date/time (ISO 8601): yyyy-mm-ddThh:mm:ss, example: " +"2014-01-19T04:32:55\n" +" time: hh:mm:ss (example: 04:32:55)\n" +" -tags: comma-separated list of tags (see /help filter for a list of tags " +"most commonly used)\n" +" text: text to display (prefix and message must be separated by \\t)\n" +"-stdout: display text on stdout (not in a buffer)\n" +"-stderr: display text on stderr (not in a buffer)\n" +"\n" +"The options -action ... -quit use the prefix defined in options \"weechat." +"look.prefix_*\".\n" +"\n" +"With options -stdout and -stderr, escaped chars are always interpreted.\n" +"\n" +"Examples:\n" +" display a reminder on core buffer with a highlight:\n" +" /print -core -tags notify_highlight Reminder: buy milk\n" +" display an error on core buffer:\n" +" /print -core -error Some error here\n" +" display message on core buffer with prefix \"abc\":\n" +" /print -core abc\tThe message\n" +" display a message on channel #weechat:\n" +" /print -buffer irc.freenode.#weechat Message on #weechat\n" +" send alert (BEL):\n" +" /print -stderr \\a" +msgstr "" + msgid "manage proxies" msgstr "spravovat proxy" diff --git a/po/de.po b/po/de.po index 8f12ca8e9..dca95e407 100644 --- a/po/de.po +++ b/po/de.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.3-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-18 21:17+0100\n" +"POT-Creation-Date: 2014-01-19 19:42+0100\n" "PO-Revision-Date: 2014-01-18 21:20+0100\n" "Last-Translator: Nils Görs \n" "Language-Team: German \n" @@ -2098,6 +2098,50 @@ msgstr "" "Ohne Angabe eines Arguments werden alle installierten Erweiterungen " "angezeigt." +#, fuzzy +msgid "display text on a buffer" +msgstr "Textfarbe in Relay-Buffer" + +msgid "" +"[-buffer |] [-core] [-escape] [-date ] [-tags ] [-" +"action|-error|-join|-network|-quit] || -stdout|-stderr " +msgstr "" + +msgid "" +"-buffer: the buffer where text is displayed (default: current buffer)\n" +" -core: alias of \"-buffer core.weechat\"\n" +"-escape: interpret escaped chars (for example \\a, \\07, \\x07)\n" +" -date: message date, format can be:\n" +" -n: 'n' seconds before now\n" +" +n: 'n' seconds in the future\n" +" n: 'n' seconds since the Epoch (see man time)\n" +" date/time (ISO 8601): yyyy-mm-ddThh:mm:ss, example: " +"2014-01-19T04:32:55\n" +" time: hh:mm:ss (example: 04:32:55)\n" +" -tags: comma-separated list of tags (see /help filter for a list of tags " +"most commonly used)\n" +" text: text to display (prefix and message must be separated by \\t)\n" +"-stdout: display text on stdout (not in a buffer)\n" +"-stderr: display text on stderr (not in a buffer)\n" +"\n" +"The options -action ... -quit use the prefix defined in options \"weechat." +"look.prefix_*\".\n" +"\n" +"With options -stdout and -stderr, escaped chars are always interpreted.\n" +"\n" +"Examples:\n" +" display a reminder on core buffer with a highlight:\n" +" /print -core -tags notify_highlight Reminder: buy milk\n" +" display an error on core buffer:\n" +" /print -core -error Some error here\n" +" display message on core buffer with prefix \"abc\":\n" +" /print -core abc\tThe message\n" +" display a message on channel #weechat:\n" +" /print -buffer irc.freenode.#weechat Message on #weechat\n" +" send alert (BEL):\n" +" /print -stderr \\a" +msgstr "" + msgid "manage proxies" msgstr "Proxys verwalten" diff --git a/po/es.po b/po/es.po index 79d0b1137..26487fa86 100644 --- a/po/es.po +++ b/po/es.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-18 21:17+0100\n" +"POT-Creation-Date: 2014-01-19 19:42+0100\n" "PO-Revision-Date: 2014-01-18 21:21+0100\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -1965,6 +1965,50 @@ msgstr "" "\n" "Sin argumentos, este comando lista los plugins cargados." +#, fuzzy +msgid "display text on a buffer" +msgstr "color del texto en el buffer del repetidor" + +msgid "" +"[-buffer |] [-core] [-escape] [-date ] [-tags ] [-" +"action|-error|-join|-network|-quit] || -stdout|-stderr " +msgstr "" + +msgid "" +"-buffer: the buffer where text is displayed (default: current buffer)\n" +" -core: alias of \"-buffer core.weechat\"\n" +"-escape: interpret escaped chars (for example \\a, \\07, \\x07)\n" +" -date: message date, format can be:\n" +" -n: 'n' seconds before now\n" +" +n: 'n' seconds in the future\n" +" n: 'n' seconds since the Epoch (see man time)\n" +" date/time (ISO 8601): yyyy-mm-ddThh:mm:ss, example: " +"2014-01-19T04:32:55\n" +" time: hh:mm:ss (example: 04:32:55)\n" +" -tags: comma-separated list of tags (see /help filter for a list of tags " +"most commonly used)\n" +" text: text to display (prefix and message must be separated by \\t)\n" +"-stdout: display text on stdout (not in a buffer)\n" +"-stderr: display text on stderr (not in a buffer)\n" +"\n" +"The options -action ... -quit use the prefix defined in options \"weechat." +"look.prefix_*\".\n" +"\n" +"With options -stdout and -stderr, escaped chars are always interpreted.\n" +"\n" +"Examples:\n" +" display a reminder on core buffer with a highlight:\n" +" /print -core -tags notify_highlight Reminder: buy milk\n" +" display an error on core buffer:\n" +" /print -core -error Some error here\n" +" display message on core buffer with prefix \"abc\":\n" +" /print -core abc\tThe message\n" +" display a message on channel #weechat:\n" +" /print -buffer irc.freenode.#weechat Message on #weechat\n" +" send alert (BEL):\n" +" /print -stderr \\a" +msgstr "" + msgid "manage proxies" msgstr "gestionar los proxies" diff --git a/po/fr.po b/po/fr.po index 294f739c8..cbb16baba 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-18 21:17+0100\n" -"PO-Revision-Date: 2014-01-18 21:18+0100\n" +"POT-Creation-Date: 2014-01-19 19:42+0100\n" +"PO-Revision-Date: 2014-01-19 23:27+0100\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" "Language: fr\n" @@ -2043,6 +2043,86 @@ msgstr "" "\n" "Sans paramètre, cette commande liste les extensions chargées." +msgid "display text on a buffer" +msgstr "afficher du texte dans un tampon" + +msgid "" +"[-buffer |] [-core] [-escape] [-date ] [-tags ] [-" +"action|-error|-join|-network|-quit] || -stdout|-stderr " +msgstr "" +"[-buffer |] [-core] [-escape] [-date ] [-tags " +"<étiquettes>] [-action|-error|-join|-network|-quit] || -stdout|-" +"stderr " + +msgid "" +"-buffer: the buffer where text is displayed (default: current buffer)\n" +" -core: alias of \"-buffer core.weechat\"\n" +"-escape: interpret escaped chars (for example \\a, \\07, \\x07)\n" +" -date: message date, format can be:\n" +" -n: 'n' seconds before now\n" +" +n: 'n' seconds in the future\n" +" n: 'n' seconds since the Epoch (see man time)\n" +" date/time (ISO 8601): yyyy-mm-ddThh:mm:ss, example: " +"2014-01-19T04:32:55\n" +" time: hh:mm:ss (example: 04:32:55)\n" +" -tags: comma-separated list of tags (see /help filter for a list of tags " +"most commonly used)\n" +" text: text to display (prefix and message must be separated by \\t)\n" +"-stdout: display text on stdout (not in a buffer)\n" +"-stderr: display text on stderr (not in a buffer)\n" +"\n" +"The options -action ... -quit use the prefix defined in options \"weechat." +"look.prefix_*\".\n" +"\n" +"With options -stdout and -stderr, escaped chars are always interpreted.\n" +"\n" +"Examples:\n" +" display a reminder on core buffer with a highlight:\n" +" /print -core -tags notify_highlight Reminder: buy milk\n" +" display an error on core buffer:\n" +" /print -core -error Some error here\n" +" display message on core buffer with prefix \"abc\":\n" +" /print -core abc\tThe message\n" +" display a message on channel #weechat:\n" +" /print -buffer irc.freenode.#weechat Message on #weechat\n" +" send alert (BEL):\n" +" /print -stderr \\a" +msgstr "" +"-buffer: le tampon où est affiché le texte (par défaut: tampon courant)\n" +" -core: alias de \"-buffer core.weechat\"\n" +"-escape: interpréter les caractères échappés (par exemple \\a, \\07, \\x07)\n" +" -date: date du message, le format peut être :\n" +" -n: 'n' secondes avant maintenant\n" +" +n: 'n' secondes dans le futur\n" +" n: 'n' secondes depuis l'époque (voir man time)\n" +" date/heure (ISO 8601): yyyy-mm-ddThh:mm:ss, exemple: " +"2014-01-19T04:32:55\n" +" heure: hh:mm:ss (exemple: 04:32:55)\n" +" -tags: liste d'étiquettes séparées par des virgules (voir /help filter " +"pour une liste des étiquettes couramment utilisées)\n" +" texte: texte à afficher (le préfixe et le message doivent être séparés par " +"\\t)\n" +"-stdout: afficher le texte sur stdout (pas dans un tampon)\n" +"-stderr: afficher le texte sur stderr (pas dans un tampon)\n" +"\n" +"Les options -action ... -quit utilisent le préfixe défini dans les options " +"\"weechat.look.prefix_*\".\n" +"\n" +"Avec les options -stdout et -stderr, les caractères échappés sont toujours " +"interprétés.\n" +"\n" +"Exemples:\n" +" afficher un pense-bête sur le tampon core avec un highlight:\n" +" /print -core -tags notify_highlight Pense-bête: acheter du lait\n" +" afficher une erreur sur le tampon core:\n" +" /print -core -error Une erreur ici\n" +" afficher un message sur le tampon core avec le préfixe \"abc\":\n" +" /print -core abc\\tLe message\n" +" afficher un message sur le canal #weechat:\n" +" /print -buffer irc.freenode.#weechat Message sur #weechat\n" +" envoyer une alerte (BEL):\n" +" /print -stderr \\a" + msgid "manage proxies" msgstr "gestion des proxies" diff --git a/po/hu.po b/po/hu.po index 19dc59959..b93940265 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-18 21:17+0100\n" +"POT-Creation-Date: 2014-01-19 19:42+0100\n" "PO-Revision-Date: 2014-01-06 10:16+0100\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -1641,6 +1641,50 @@ msgstr "" "\n" "Paraméter nélkül a /plugin parancs listázza a betöltött modulokat." +#, fuzzy +msgid "display text on a buffer" +msgstr "szerver nevének színe" + +msgid "" +"[-buffer |] [-core] [-escape] [-date ] [-tags ] [-" +"action|-error|-join|-network|-quit] || -stdout|-stderr " +msgstr "" + +msgid "" +"-buffer: the buffer where text is displayed (default: current buffer)\n" +" -core: alias of \"-buffer core.weechat\"\n" +"-escape: interpret escaped chars (for example \\a, \\07, \\x07)\n" +" -date: message date, format can be:\n" +" -n: 'n' seconds before now\n" +" +n: 'n' seconds in the future\n" +" n: 'n' seconds since the Epoch (see man time)\n" +" date/time (ISO 8601): yyyy-mm-ddThh:mm:ss, example: " +"2014-01-19T04:32:55\n" +" time: hh:mm:ss (example: 04:32:55)\n" +" -tags: comma-separated list of tags (see /help filter for a list of tags " +"most commonly used)\n" +" text: text to display (prefix and message must be separated by \\t)\n" +"-stdout: display text on stdout (not in a buffer)\n" +"-stderr: display text on stderr (not in a buffer)\n" +"\n" +"The options -action ... -quit use the prefix defined in options \"weechat." +"look.prefix_*\".\n" +"\n" +"With options -stdout and -stderr, escaped chars are always interpreted.\n" +"\n" +"Examples:\n" +" display a reminder on core buffer with a highlight:\n" +" /print -core -tags notify_highlight Reminder: buy milk\n" +" display an error on core buffer:\n" +" /print -core -error Some error here\n" +" display message on core buffer with prefix \"abc\":\n" +" /print -core abc\tThe message\n" +" display a message on channel #weechat:\n" +" /print -buffer irc.freenode.#weechat Message on #weechat\n" +" send alert (BEL):\n" +" /print -stderr \\a" +msgstr "" + #, fuzzy msgid "manage proxies" msgstr "pufferek kezelése" diff --git a/po/it.po b/po/it.po index 49c646a40..6e992b9c2 100644 --- a/po/it.po +++ b/po/it.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-18 21:17+0100\n" +"POT-Creation-Date: 2014-01-19 19:42+0100\n" "PO-Revision-Date: 2014-01-18 21:22+0100\n" "Last-Translator: Esteban I. Ruiz Moreno \n" "Language-Team: weechat-dev \n" @@ -2002,6 +2002,50 @@ msgstr "" "\n" "Senza argomento, questo comando elenca i plugin caricati." +#, fuzzy +msgid "display text on a buffer" +msgstr "colore del testo nei buffer relay" + +msgid "" +"[-buffer |] [-core] [-escape] [-date ] [-tags ] [-" +"action|-error|-join|-network|-quit] || -stdout|-stderr " +msgstr "" + +msgid "" +"-buffer: the buffer where text is displayed (default: current buffer)\n" +" -core: alias of \"-buffer core.weechat\"\n" +"-escape: interpret escaped chars (for example \\a, \\07, \\x07)\n" +" -date: message date, format can be:\n" +" -n: 'n' seconds before now\n" +" +n: 'n' seconds in the future\n" +" n: 'n' seconds since the Epoch (see man time)\n" +" date/time (ISO 8601): yyyy-mm-ddThh:mm:ss, example: " +"2014-01-19T04:32:55\n" +" time: hh:mm:ss (example: 04:32:55)\n" +" -tags: comma-separated list of tags (see /help filter for a list of tags " +"most commonly used)\n" +" text: text to display (prefix and message must be separated by \\t)\n" +"-stdout: display text on stdout (not in a buffer)\n" +"-stderr: display text on stderr (not in a buffer)\n" +"\n" +"The options -action ... -quit use the prefix defined in options \"weechat." +"look.prefix_*\".\n" +"\n" +"With options -stdout and -stderr, escaped chars are always interpreted.\n" +"\n" +"Examples:\n" +" display a reminder on core buffer with a highlight:\n" +" /print -core -tags notify_highlight Reminder: buy milk\n" +" display an error on core buffer:\n" +" /print -core -error Some error here\n" +" display message on core buffer with prefix \"abc\":\n" +" /print -core abc\tThe message\n" +" display a message on channel #weechat:\n" +" /print -buffer irc.freenode.#weechat Message on #weechat\n" +" send alert (BEL):\n" +" /print -stderr \\a" +msgstr "" + msgid "manage proxies" msgstr "gestione dei proxy" diff --git a/po/ja.po b/po/ja.po index 6f7d2aaf2..4453fac31 100644 --- a/po/ja.po +++ b/po/ja.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-18 21:17+0100\n" +"POT-Creation-Date: 2014-01-19 19:42+0100\n" "PO-Revision-Date: 2014-01-18 21:22+0100\n" "Last-Translator: AYANOKOUZI, Ryuunosuke \n" "Language-Team: Japanese \n" @@ -1988,6 +1988,50 @@ msgstr "" "\n" "引数無しでは、ロードされたプラグインをリストアップ。" +#, fuzzy +msgid "display text on a buffer" +msgstr "リレーバッファ内のテキスト色" + +msgid "" +"[-buffer |] [-core] [-escape] [-date ] [-tags ] [-" +"action|-error|-join|-network|-quit] || -stdout|-stderr " +msgstr "" + +msgid "" +"-buffer: the buffer where text is displayed (default: current buffer)\n" +" -core: alias of \"-buffer core.weechat\"\n" +"-escape: interpret escaped chars (for example \\a, \\07, \\x07)\n" +" -date: message date, format can be:\n" +" -n: 'n' seconds before now\n" +" +n: 'n' seconds in the future\n" +" n: 'n' seconds since the Epoch (see man time)\n" +" date/time (ISO 8601): yyyy-mm-ddThh:mm:ss, example: " +"2014-01-19T04:32:55\n" +" time: hh:mm:ss (example: 04:32:55)\n" +" -tags: comma-separated list of tags (see /help filter for a list of tags " +"most commonly used)\n" +" text: text to display (prefix and message must be separated by \\t)\n" +"-stdout: display text on stdout (not in a buffer)\n" +"-stderr: display text on stderr (not in a buffer)\n" +"\n" +"The options -action ... -quit use the prefix defined in options \"weechat." +"look.prefix_*\".\n" +"\n" +"With options -stdout and -stderr, escaped chars are always interpreted.\n" +"\n" +"Examples:\n" +" display a reminder on core buffer with a highlight:\n" +" /print -core -tags notify_highlight Reminder: buy milk\n" +" display an error on core buffer:\n" +" /print -core -error Some error here\n" +" display message on core buffer with prefix \"abc\":\n" +" /print -core abc\tThe message\n" +" display a message on channel #weechat:\n" +" /print -buffer irc.freenode.#weechat Message on #weechat\n" +" send alert (BEL):\n" +" /print -stderr \\a" +msgstr "" + msgid "manage proxies" msgstr "プロキシの管理" diff --git a/po/pl.po b/po/pl.po index 5b29c37f8..ca2ed4336 100644 --- a/po/pl.po +++ b/po/pl.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-18 21:17+0100\n" +"POT-Creation-Date: 2014-01-19 19:42+0100\n" "PO-Revision-Date: 2014-01-18 21:23+0100\n" "Last-Translator: Krzysztof Korościk \n" "Language-Team: weechat-dev \n" @@ -2037,6 +2037,50 @@ msgstr "" "\n" "Bez argumentów ta komenda wyświetli wszystkie załadowane wtyczki." +#, fuzzy +msgid "display text on a buffer" +msgstr "kolor tekstu w buforze pośrednika" + +msgid "" +"[-buffer |] [-core] [-escape] [-date ] [-tags ] [-" +"action|-error|-join|-network|-quit] || -stdout|-stderr " +msgstr "" + +msgid "" +"-buffer: the buffer where text is displayed (default: current buffer)\n" +" -core: alias of \"-buffer core.weechat\"\n" +"-escape: interpret escaped chars (for example \\a, \\07, \\x07)\n" +" -date: message date, format can be:\n" +" -n: 'n' seconds before now\n" +" +n: 'n' seconds in the future\n" +" n: 'n' seconds since the Epoch (see man time)\n" +" date/time (ISO 8601): yyyy-mm-ddThh:mm:ss, example: " +"2014-01-19T04:32:55\n" +" time: hh:mm:ss (example: 04:32:55)\n" +" -tags: comma-separated list of tags (see /help filter for a list of tags " +"most commonly used)\n" +" text: text to display (prefix and message must be separated by \\t)\n" +"-stdout: display text on stdout (not in a buffer)\n" +"-stderr: display text on stderr (not in a buffer)\n" +"\n" +"The options -action ... -quit use the prefix defined in options \"weechat." +"look.prefix_*\".\n" +"\n" +"With options -stdout and -stderr, escaped chars are always interpreted.\n" +"\n" +"Examples:\n" +" display a reminder on core buffer with a highlight:\n" +" /print -core -tags notify_highlight Reminder: buy milk\n" +" display an error on core buffer:\n" +" /print -core -error Some error here\n" +" display message on core buffer with prefix \"abc\":\n" +" /print -core abc\tThe message\n" +" display a message on channel #weechat:\n" +" /print -buffer irc.freenode.#weechat Message on #weechat\n" +" send alert (BEL):\n" +" /print -stderr \\a" +msgstr "" + msgid "manage proxies" msgstr "zarządzanie proxy" diff --git a/po/pt_BR.po b/po/pt_BR.po index f7a132d9c..bbc7344c8 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-18 21:17+0100\n" +"POT-Creation-Date: 2014-01-19 19:42+0100\n" "PO-Revision-Date: 2014-01-18 21:23+0100\n" "Last-Translator: Sergio Durigan Junior \n" "Language-Team: weechat-dev \n" @@ -1943,6 +1943,50 @@ msgstr "" "\n" "Sem argumentos, este comando lista plugins carregados." +#, fuzzy +msgid "display text on a buffer" +msgstr "cor do texto para nomes de buffer" + +msgid "" +"[-buffer |] [-core] [-escape] [-date ] [-tags ] [-" +"action|-error|-join|-network|-quit] || -stdout|-stderr " +msgstr "" + +msgid "" +"-buffer: the buffer where text is displayed (default: current buffer)\n" +" -core: alias of \"-buffer core.weechat\"\n" +"-escape: interpret escaped chars (for example \\a, \\07, \\x07)\n" +" -date: message date, format can be:\n" +" -n: 'n' seconds before now\n" +" +n: 'n' seconds in the future\n" +" n: 'n' seconds since the Epoch (see man time)\n" +" date/time (ISO 8601): yyyy-mm-ddThh:mm:ss, example: " +"2014-01-19T04:32:55\n" +" time: hh:mm:ss (example: 04:32:55)\n" +" -tags: comma-separated list of tags (see /help filter for a list of tags " +"most commonly used)\n" +" text: text to display (prefix and message must be separated by \\t)\n" +"-stdout: display text on stdout (not in a buffer)\n" +"-stderr: display text on stderr (not in a buffer)\n" +"\n" +"The options -action ... -quit use the prefix defined in options \"weechat." +"look.prefix_*\".\n" +"\n" +"With options -stdout and -stderr, escaped chars are always interpreted.\n" +"\n" +"Examples:\n" +" display a reminder on core buffer with a highlight:\n" +" /print -core -tags notify_highlight Reminder: buy milk\n" +" display an error on core buffer:\n" +" /print -core -error Some error here\n" +" display message on core buffer with prefix \"abc\":\n" +" /print -core abc\tThe message\n" +" display a message on channel #weechat:\n" +" /print -buffer irc.freenode.#weechat Message on #weechat\n" +" send alert (BEL):\n" +" /print -stderr \\a" +msgstr "" + msgid "manage proxies" msgstr "gerenciar proxies" diff --git a/po/ru.po b/po/ru.po index 12992af22..6dcf22733 100644 --- a/po/ru.po +++ b/po/ru.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-18 21:17+0100\n" +"POT-Creation-Date: 2014-01-19 19:42+0100\n" "PO-Revision-Date: 2014-01-06 10:17+0100\n" "Last-Translator: Aleksey V Zapparov AKA ixti \n" "Language-Team: weechat-dev \n" @@ -1664,6 +1664,50 @@ msgstr "" "\n" "Команда /plugin без аргументов перечисляет загруженные pluginы." +#, fuzzy +msgid "display text on a buffer" +msgstr "цвет названия сервера" + +msgid "" +"[-buffer |] [-core] [-escape] [-date ] [-tags ] [-" +"action|-error|-join|-network|-quit] || -stdout|-stderr " +msgstr "" + +msgid "" +"-buffer: the buffer where text is displayed (default: current buffer)\n" +" -core: alias of \"-buffer core.weechat\"\n" +"-escape: interpret escaped chars (for example \\a, \\07, \\x07)\n" +" -date: message date, format can be:\n" +" -n: 'n' seconds before now\n" +" +n: 'n' seconds in the future\n" +" n: 'n' seconds since the Epoch (see man time)\n" +" date/time (ISO 8601): yyyy-mm-ddThh:mm:ss, example: " +"2014-01-19T04:32:55\n" +" time: hh:mm:ss (example: 04:32:55)\n" +" -tags: comma-separated list of tags (see /help filter for a list of tags " +"most commonly used)\n" +" text: text to display (prefix and message must be separated by \\t)\n" +"-stdout: display text on stdout (not in a buffer)\n" +"-stderr: display text on stderr (not in a buffer)\n" +"\n" +"The options -action ... -quit use the prefix defined in options \"weechat." +"look.prefix_*\".\n" +"\n" +"With options -stdout and -stderr, escaped chars are always interpreted.\n" +"\n" +"Examples:\n" +" display a reminder on core buffer with a highlight:\n" +" /print -core -tags notify_highlight Reminder: buy milk\n" +" display an error on core buffer:\n" +" /print -core -error Some error here\n" +" display message on core buffer with prefix \"abc\":\n" +" /print -core abc\tThe message\n" +" display a message on channel #weechat:\n" +" /print -buffer irc.freenode.#weechat Message on #weechat\n" +" send alert (BEL):\n" +" /print -stderr \\a" +msgstr "" + #, fuzzy msgid "manage proxies" msgstr "управление буферами" diff --git a/po/tr.po b/po/tr.po index 47e961ed4..4b3dd2af7 100644 --- a/po/tr.po +++ b/po/tr.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-18 21:17+0100\n" +"POT-Creation-Date: 2014-01-19 19:42+0100\n" "PO-Revision-Date: 2014-01-06 10:17+0100\n" "Last-Translator: Hasan Kiran \n" "Language-Team: weechat-dev \n" @@ -1476,6 +1476,49 @@ msgid "" "Without argument, this command lists loaded plugins." msgstr "" +msgid "display text on a buffer" +msgstr "" + +msgid "" +"[-buffer |] [-core] [-escape] [-date ] [-tags ] [-" +"action|-error|-join|-network|-quit] || -stdout|-stderr " +msgstr "" + +msgid "" +"-buffer: the buffer where text is displayed (default: current buffer)\n" +" -core: alias of \"-buffer core.weechat\"\n" +"-escape: interpret escaped chars (for example \\a, \\07, \\x07)\n" +" -date: message date, format can be:\n" +" -n: 'n' seconds before now\n" +" +n: 'n' seconds in the future\n" +" n: 'n' seconds since the Epoch (see man time)\n" +" date/time (ISO 8601): yyyy-mm-ddThh:mm:ss, example: " +"2014-01-19T04:32:55\n" +" time: hh:mm:ss (example: 04:32:55)\n" +" -tags: comma-separated list of tags (see /help filter for a list of tags " +"most commonly used)\n" +" text: text to display (prefix and message must be separated by \\t)\n" +"-stdout: display text on stdout (not in a buffer)\n" +"-stderr: display text on stderr (not in a buffer)\n" +"\n" +"The options -action ... -quit use the prefix defined in options \"weechat." +"look.prefix_*\".\n" +"\n" +"With options -stdout and -stderr, escaped chars are always interpreted.\n" +"\n" +"Examples:\n" +" display a reminder on core buffer with a highlight:\n" +" /print -core -tags notify_highlight Reminder: buy milk\n" +" display an error on core buffer:\n" +" /print -core -error Some error here\n" +" display message on core buffer with prefix \"abc\":\n" +" /print -core abc\tThe message\n" +" display a message on channel #weechat:\n" +" /print -buffer irc.freenode.#weechat Message on #weechat\n" +" send alert (BEL):\n" +" /print -stderr \\a" +msgstr "" + msgid "manage proxies" msgstr "" diff --git a/po/weechat.pot b/po/weechat.pot index 538a9a9fe..7c0f6fabc 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.1-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2014-01-18 21:17+0100\n" +"POT-Creation-Date: 2014-01-19 19:42+0100\n" "PO-Revision-Date: 2013-02-14 18:20+0100\n" "Last-Translator: FULL NAME \n" "Language-Team: weechat-dev \n" @@ -1479,6 +1479,49 @@ msgid "" "Without argument, this command lists loaded plugins." msgstr "" +msgid "display text on a buffer" +msgstr "" + +msgid "" +"[-buffer |] [-core] [-escape] [-date ] [-tags ] [-" +"action|-error|-join|-network|-quit] || -stdout|-stderr " +msgstr "" + +msgid "" +"-buffer: the buffer where text is displayed (default: current buffer)\n" +" -core: alias of \"-buffer core.weechat\"\n" +"-escape: interpret escaped chars (for example \\a, \\07, \\x07)\n" +" -date: message date, format can be:\n" +" -n: 'n' seconds before now\n" +" +n: 'n' seconds in the future\n" +" n: 'n' seconds since the Epoch (see man time)\n" +" date/time (ISO 8601): yyyy-mm-ddThh:mm:ss, example: " +"2014-01-19T04:32:55\n" +" time: hh:mm:ss (example: 04:32:55)\n" +" -tags: comma-separated list of tags (see /help filter for a list of tags " +"most commonly used)\n" +" text: text to display (prefix and message must be separated by \\t)\n" +"-stdout: display text on stdout (not in a buffer)\n" +"-stderr: display text on stderr (not in a buffer)\n" +"\n" +"The options -action ... -quit use the prefix defined in options \"weechat." +"look.prefix_*\".\n" +"\n" +"With options -stdout and -stderr, escaped chars are always interpreted.\n" +"\n" +"Examples:\n" +" display a reminder on core buffer with a highlight:\n" +" /print -core -tags notify_highlight Reminder: buy milk\n" +" display an error on core buffer:\n" +" /print -core -error Some error here\n" +" display message on core buffer with prefix \"abc\":\n" +" /print -core abc\tThe message\n" +" display a message on channel #weechat:\n" +" /print -buffer irc.freenode.#weechat Message on #weechat\n" +" send alert (BEL):\n" +" /print -stderr \\a" +msgstr "" + msgid "manage proxies" msgstr "" diff --git a/src/core/wee-command.c b/src/core/wee-command.c index be2f34c40..c47069dda 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -20,12 +20,18 @@ * along with WeeChat. If not, see . */ +/* this define is needed for strptime() (not on OpenBSD) */ +#if !defined(__OpenBSD__) +#define _XOPEN_SOURCE 700 +#endif + #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include +#include #include #include #include @@ -4171,6 +4177,182 @@ COMMAND_CALLBACK(plugin) return WEECHAT_RC_OK; } +/* + * Callback for command "/print": display text on a buffer. + */ + +COMMAND_CALLBACK(print) +{ + struct t_gui_buffer *ptr_buffer; + int i, escape, to_stdout, to_stderr; + time_t date, date_now; + struct tm tm_date; + char *tags, *pos, *text, *text2, *error; + const char *prefix; + long value; + + /* make C compiler happy */ + (void) data; + + if (argc < 2) + return WEECHAT_RC_OK; + + ptr_buffer = buffer; + date = 0; + tags = NULL; + prefix = NULL; + escape = 0; + to_stdout = 0; + to_stderr = 0; + + for (i = 1; i < argc; i++) + { + if (string_strcasecmp (argv[i], "-buffer") == 0) + { + if (i + 1 >= argc) + return WEECHAT_RC_ERROR; + i++; + ptr_buffer = gui_buffer_search_by_number_or_name (argv[i]); + if (!ptr_buffer) + return WEECHAT_RC_ERROR; + } + else if (string_strcasecmp (argv[i], "-core") == 0) + { + ptr_buffer = NULL; + } + else if (string_strcasecmp (argv[i], "-escape") == 0) + { + escape = 1; + } + else if (string_strcasecmp (argv[i], "-date") == 0) + { + if (i + 1 >= argc) + return WEECHAT_RC_ERROR; + i++; + if ((argv[i][0] == '-') || (argv[i][0] == '+')) + { + error = NULL; + value = strtol (argv[i] + 1, &error, 10); + if (!error || error[0]) + return WEECHAT_RC_ERROR; + date = (argv[i][0] == '-') ? + time (NULL) - value : time (NULL) + value; + } + else + { + error = NULL; + value = strtol (argv[i], &error, 10); + if (error && !error[0]) + { + date = value; + } + else + { + memset (&tm_date, 0, sizeof (struct tm)); + if (strchr (argv[i], '-')) + { + /* ISO 8601 (date/time) */ + if (strptime (argv[i], "%Y-%m-%dT%H:%M:%S", &tm_date)) + { + if (tm_date.tm_year > 0) + date = mktime (&tm_date); + } + } + else + { + /* time only (use current date) */ + date_now = time (NULL); + localtime_r (&date_now, &tm_date); + if (strptime (argv[i], "%H:%M:%S", &tm_date)) + date = mktime (&tm_date); + } + } + } + } + else if (string_strcasecmp (argv[i], "-tags") == 0) + { + if (i + 1 >= argc) + return WEECHAT_RC_ERROR; + i++; + tags = argv[i]; + } + else if (string_strcasecmp (argv[i], "-action") == 0) + { + prefix = gui_chat_prefix[GUI_CHAT_PREFIX_ACTION]; + } + else if (string_strcasecmp (argv[i], "-error") == 0) + { + prefix = gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]; + } + else if (string_strcasecmp (argv[i], "-join") == 0) + { + prefix = gui_chat_prefix[GUI_CHAT_PREFIX_JOIN]; + } + else if (string_strcasecmp (argv[i], "-network") == 0) + { + prefix = gui_chat_prefix[GUI_CHAT_PREFIX_NETWORK]; + } + else if (string_strcasecmp (argv[i], "-quit") == 0) + { + prefix = gui_chat_prefix[GUI_CHAT_PREFIX_QUIT]; + } + else if (string_strcasecmp (argv[i], "-stdout") == 0) + { + to_stdout = 1; + } + else if (string_strcasecmp (argv[i], "-stderr") == 0) + { + to_stderr = 1; + } + else + break; + } + + if (i >= argc) + return WEECHAT_RC_OK; + + if (to_stdout || to_stderr) + { + text = string_convert_escaped_chars (argv_eol[i]); + if (text) + { + fprintf ((to_stdout) ? stdout : stderr, "%s", text); + free (text); + } + } + else + { + text = strdup (argv_eol[i]); + if (text) + { + pos = NULL; + if (!prefix) + { + pos = strstr (text, "\\t"); + if (pos) + { + pos[0] = '\t'; + memmove (pos + 1, pos + 2, strlen (pos + 2) + 1); + } + } + text2 = (escape) ? + string_convert_escaped_chars (text) : strdup (text); + if (text2) + { + gui_chat_printf_date_tags ( + ptr_buffer, date, tags, + "%s%s", + (prefix) ? prefix : ((!prefix && !pos) ? "\t" : ""), + text2); + free (text2); + } + free (text); + } + } + + return WEECHAT_RC_OK; +} + /* * Displays a list of proxies. */ @@ -6912,6 +7094,53 @@ command_init () " || reload %(plugins_names)" " || unload %(plugins_names)", &command_plugin, NULL); + hook_command ( + NULL, "print", + N_("display text on a buffer"), + N_("[-buffer |] [-core] [-escape] [-date ] " + "[-tags ] [-action|-error|-join|-network|-quit] " + " || -stdout|-stderr "), + N_("-buffer: the buffer where text is displayed (default: current " + "buffer)\n" + " -core: alias of \"-buffer core.weechat\"\n" + "-escape: interpret escaped chars (for example \\a, \\07, \\x07)\n" + " -date: message date, format can be:\n" + " -n: 'n' seconds before now\n" + " +n: 'n' seconds in the future\n" + " n: 'n' seconds since the Epoch (see man time)\n" + " date/time (ISO 8601): yyyy-mm-ddThh:mm:ss, example: " + "2014-01-19T04:32:55\n" + " time: hh:mm:ss (example: 04:32:55)\n" + " -tags: comma-separated list of tags (see /help filter for a list " + "of tags most commonly used)\n" + " text: text to display (prefix and message must be separated by " + "\\t)\n" + "-stdout: display text on stdout (not in a buffer)\n" + "-stderr: display text on stderr (not in a buffer)\n" + "\n" + "The options -action ... -quit use the prefix defined in options " + "\"weechat.look.prefix_*\".\n" + "\n" + "With options -stdout and -stderr, escaped chars are always " + "interpreted.\n" + "\n" + "Examples:\n" + " display a reminder on core buffer with a highlight:\n" + " /print -core -tags notify_highlight Reminder: buy milk\n" + " display an error on core buffer:\n" + " /print -core -error Some error here\n" + " display message on core buffer with prefix \"abc\":\n" + " /print -core abc\tThe message\n" + " display a message on channel #weechat:\n" + " /print -buffer irc.freenode.#weechat Message on #weechat\n" + " send alert (BEL):\n" + " /print -stderr \\a"), + "-buffer %(buffers_numbers)|%(buffers_plugins_names)" + " || -core|-escape|-date|-tags|-action|-error|-join|-network|-quit" + " || -prefix" + " || -stdout" + " || -stderr", + &command_print, NULL); hook_command ( NULL, "proxy", N_("manage proxies"), diff --git a/src/core/wee-string.c b/src/core/wee-string.c index bfd1105f0..aea897eaf 100644 --- a/src/core/wee-string.c +++ b/src/core/wee-string.c @@ -54,6 +54,11 @@ #include "../plugins/plugin.h" +#define IS_OCTAL_DIGIT(c) ((c >= '0') && (c <= '7')) +#define HEX2DEC(c) (((c >= 'a') && (c <= 'f')) ? c - 'a' + 10 : \ + ((c >= 'A') && (c <= 'F')) ? c - 'A' + 10 : \ + c - '0') + typedef uint32_t string_shared_count_t; struct t_hashtable *string_hashtable_shared = NULL; @@ -623,74 +628,127 @@ string_strip (const char *string, int left, int right, const char *chars) } /* - * Converts hex chars (\x??) to value. + * Converts escaped chars to their value. + * + * Following escaped chars are supported: + * \" double quote + * \\ backslash + * \a alert (BEL) + * \b backspace + * \e escape + * \f form feed + * \n new line + * \r carriage return + * \t horizontal tab + * \v vertical tab + * \0ooo octal value (ooo is 0 to 3 digits) + * \xhh hexadecimal value (hh is 1 to 2 digits) * * Note: result must be freed after use. */ char * -string_convert_hex_chars (const char *string) +string_convert_escaped_chars (const char *string) { - char *output, hex_str[8], *error; - int pos_output; - long number; + const unsigned char *ptr_string; + char *output; + int pos_output, i, value; + /* the output length is always <= to string length */ output = malloc (strlen (string) + 1); - if (output) + if (!output) + return NULL; + + pos_output = 0; + ptr_string = (const unsigned char *)string; + while (ptr_string && ptr_string[0]) { - pos_output = 0; - while (string && string[0]) + if (ptr_string[0] == '\\') { - if (string[0] == '\\') + ptr_string++; + switch (ptr_string[0]) { - string++; - switch (string[0]) - { - case '\\': - output[pos_output++] = '\\'; - string++; - break; - case 'x': - case 'X': - if (isxdigit ((unsigned char)string[1]) - && isxdigit ((unsigned char)string[2])) + case '"': + output[pos_output++] = '"'; + ptr_string++; + break; + case '\\': + output[pos_output++] = '\\'; + ptr_string++; + break; + case 'a': /* alert */ + output[pos_output++] = 7; + ptr_string++; + break; + case 'b': /* backspace */ + output[pos_output++] = 8; + ptr_string++; + break; + case 'e': /* escape */ + output[pos_output++] = 27; + ptr_string++; + break; + case 'f': /* form feed */ + output[pos_output++] = 12; + ptr_string++; + break; + case 'n': /* new line */ + output[pos_output++] = 10; + ptr_string++; + break; + case 'r': /* carriage return */ + output[pos_output++] = 13; + ptr_string++; + break; + case 't': /* horizontal tab */ + output[pos_output++] = 9; + ptr_string++; + break; + case 'v': /* vertical tab */ + output[pos_output++] = 11; + ptr_string++; + break; + case '0': /* octal value (0 to 3 digits expected) */ + value = 0; + for (i = 0; (i < 3) && IS_OCTAL_DIGIT(ptr_string[i + 1]); i++) + { + value = (value * 8) + (ptr_string[i + 1] - '0'); + } + output[pos_output++] = value; + ptr_string += 1 + i; + break; + case 'x': /* hexadecimal value (1 to 2 digits expected) */ + case 'X': + if (isxdigit (ptr_string[1])) + { + value = 0; + for (i = 0; (i < 2) && isxdigit (ptr_string[i + 1]); i++) { - snprintf (hex_str, sizeof (hex_str), - "0x%c%c", string[1], string[2]); - number = strtol (hex_str, &error, 16); - if (error && !error[0]) - { - output[pos_output++] = number; - string += 3; - } - else - { - output[pos_output++] = '\\'; - output[pos_output++] = string[0]; - string++; - } + value = (value * 16) + HEX2DEC(ptr_string[i + 1]); } - else - { - output[pos_output++] = string[0]; - string++; - } - break; - default: - output[pos_output++] = '\\'; - output[pos_output++] = string[0]; - string++; - break; - } - } - else - { - output[pos_output++] = string[0]; - string++; + output[pos_output++] = value; + ptr_string += 1 + i; + } + else + { + output[pos_output++] = ptr_string[0]; + ptr_string++; + } + break; + default: + output[pos_output++] = '\\'; + output[pos_output++] = ptr_string[0]; + ptr_string++; + break; } } - output[pos_output] = '\0'; + else + { + output[pos_output++] = ptr_string[0]; + ptr_string++; + } } + output[pos_output] = '\0'; return output; } diff --git a/src/core/wee-string.h b/src/core/wee-string.h index 3b75fb388..9a7c5d76b 100644 --- a/src/core/wee-string.h +++ b/src/core/wee-string.h @@ -47,7 +47,7 @@ extern char *string_expand_home (const char *path); extern char *string_remove_quotes (const char *string, const char *quotes); extern char *string_strip (const char *string, int left, int right, const char *chars); -extern char *string_convert_hex_chars (const char *string); +extern char *string_convert_escaped_chars (const char *string); extern char *string_mask_to_regex (const char *mask); extern const char *string_regex_flags (const char *regex, int default_flags, int *flags); diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c index 2545fe027..7105c5c5a 100644 --- a/src/gui/gui-input.c +++ b/src/gui/gui-input.c @@ -1666,7 +1666,7 @@ gui_input_insert (struct t_gui_buffer *buffer, const char *args) if (args) { gui_buffer_undo_snap (buffer); - args2 = string_convert_hex_chars (args); + args2 = string_convert_escaped_chars (args); gui_input_insert_string (buffer, (args2) ? args2 : args, -1); gui_input_text_changed_modifier_and_signal (buffer, 1, /* save undo */