diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | doc/de/autogen/user/weechat_options.txt | 5 | ||||
-rw-r--r-- | doc/en/autogen/user/weechat_options.txt | 5 | ||||
-rw-r--r-- | doc/fr/autogen/user/weechat_options.txt | 5 | ||||
-rw-r--r-- | doc/it/autogen/user/weechat_options.txt | 5 | ||||
-rw-r--r-- | doc/ja/autogen/user/weechat_options.txt | 5 | ||||
-rw-r--r-- | po/cs.po | 13 | ||||
-rw-r--r-- | po/de.po | 13 | ||||
-rw-r--r-- | po/es.po | 13 | ||||
-rw-r--r-- | po/fr.po | 21 | ||||
-rw-r--r-- | po/hu.po | 13 | ||||
-rw-r--r-- | po/it.po | 13 | ||||
-rw-r--r-- | po/ja.po | 13 | ||||
-rw-r--r-- | po/pl.po | 13 | ||||
-rw-r--r-- | po/pt_BR.po | 13 | ||||
-rw-r--r-- | po/ru.po | 13 | ||||
-rw-r--r-- | po/tr.po | 13 | ||||
-rw-r--r-- | po/weechat.pot | 13 | ||||
-rw-r--r-- | src/core/wee-command.c | 26 | ||||
-rw-r--r-- | src/core/wee-config.c | 7 | ||||
-rw-r--r-- | src/core/wee-config.h | 1 | ||||
-rw-r--r-- | src/gui/gui-key.c | 33 | ||||
-rw-r--r-- | src/gui/gui-key.h | 1 |
23 files changed, 246 insertions, 14 deletions
@@ -1,7 +1,7 @@ WeeChat ChangeLog ================= Sébastien Helleu <flashcode@flashtux.org> -v0.4.2-dev, 2013-07-13 +v0.4.2-dev, 2013-07-15 This document lists all changes for each version. @@ -14,6 +14,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes] Version 0.4.2 (under dev!) -------------------------- +* core: add option weechat.look.key_bind_safe * core: fix char displayed at the intersection of three windows (bug #39331) * core: fix crash in evaluation of expression when reading a string in hdata with a NULL value (bug #39419) diff --git a/doc/de/autogen/user/weechat_options.txt b/doc/de/autogen/user/weechat_options.txt index 3f2d14ac6..65af52aff 100644 --- a/doc/de/autogen/user/weechat_options.txt +++ b/doc/de/autogen/user/weechat_options.txt @@ -593,6 +593,11 @@ ** Typ: boolesch ** Werte: on, off (Standardwert: `on`) +* [[option_weechat.look.key_bind_safe]] *weechat.look.key_bind_safe* +** Beschreibung: `allow only binding of "safe" keys (beginning with a ctrl or meta code)` +** Typ: boolesch +** Werte: on, off (Standardwert: `on`) + * [[option_weechat.look.mouse]] *weechat.look.mouse* ** Beschreibung: `Mausunterstützung einschalten` ** Typ: boolesch diff --git a/doc/en/autogen/user/weechat_options.txt b/doc/en/autogen/user/weechat_options.txt index c6ccc5fb8..a7146e43f 100644 --- a/doc/en/autogen/user/weechat_options.txt +++ b/doc/en/autogen/user/weechat_options.txt @@ -593,6 +593,11 @@ ** type: boolean ** values: on, off (default value: `on`) +* [[option_weechat.look.key_bind_safe]] *weechat.look.key_bind_safe* +** description: `allow only binding of "safe" keys (beginning with a ctrl or meta code)` +** type: boolean +** values: on, off (default value: `on`) + * [[option_weechat.look.mouse]] *weechat.look.mouse* ** description: `enable mouse support` ** type: boolean diff --git a/doc/fr/autogen/user/weechat_options.txt b/doc/fr/autogen/user/weechat_options.txt index 3221a9efe..882a69274 100644 --- a/doc/fr/autogen/user/weechat_options.txt +++ b/doc/fr/autogen/user/weechat_options.txt @@ -593,6 +593,11 @@ ** type: booléen ** valeurs: on, off (valeur par défaut: `on`) +* [[option_weechat.look.key_bind_safe]] *weechat.look.key_bind_safe* +** description: `autoriser seulement l'association de touches "sûres" (commençant par un code ctrl ou meta)` +** type: booléen +** valeurs: on, off (valeur par défaut: `on`) + * [[option_weechat.look.mouse]] *weechat.look.mouse* ** description: `activer le support de la souris` ** type: booléen diff --git a/doc/it/autogen/user/weechat_options.txt b/doc/it/autogen/user/weechat_options.txt index 05286758f..e36ce89f8 100644 --- a/doc/it/autogen/user/weechat_options.txt +++ b/doc/it/autogen/user/weechat_options.txt @@ -593,6 +593,11 @@ ** tipo: bool ** valori: on, off (valore predefinito: `on`) +* [[option_weechat.look.key_bind_safe]] *weechat.look.key_bind_safe* +** descrizione: `allow only binding of "safe" keys (beginning with a ctrl or meta code)` +** tipo: bool +** valori: on, off (valore predefinito: `on`) + * [[option_weechat.look.mouse]] *weechat.look.mouse* ** descrizione: `abilita il supporto del mouse` ** tipo: bool diff --git a/doc/ja/autogen/user/weechat_options.txt b/doc/ja/autogen/user/weechat_options.txt index 179920633..864ac288f 100644 --- a/doc/ja/autogen/user/weechat_options.txt +++ b/doc/ja/autogen/user/weechat_options.txt @@ -593,6 +593,11 @@ ** タイプ: ブール ** 値: on, off (デフォルト値: `on`) +* [[option_weechat.look.key_bind_safe]] *weechat.look.key_bind_safe* +** 説明: `allow only binding of "safe" keys (beginning with a ctrl or meta code)` +** タイプ: ブール +** 値: on, off (デフォルト値: `on`) + * [[option_weechat.look.mouse]] *weechat.look.mouse* ** 説明: `マウスサポートの有効化` ** タイプ: ブール @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-07-11 21:45+0200\n" +"POT-Creation-Date: 2013-07-15 18:33+0200\n" "PO-Revision-Date: 2013-06-10 09:13+0200\n" "Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -431,6 +431,13 @@ msgstr "Klávesa:" msgid "No key found" msgstr "Žádná klávesa nenalezena" +#, c-format +msgid "" +"%sError: it is not safe to bind key \"%s\" because it does not start with a " +"ctrl or meta code (tip: use alt-k to find key codes); if you want to bind " +"this key anyway, turn off option weechat.look.key_bind_safe" +msgstr "" + #, fuzzy, c-format msgid "%sError: context \"%s\" not found" msgstr "%sChyba: filtr \"%s\" nenalezen" @@ -2674,6 +2681,10 @@ msgstr "" msgid "jump back to initial buffer after reaching end of hotlist" msgstr "" +msgid "" +"allow only binding of \"safe\" keys (beginning with a ctrl or meta code)" +msgstr "" + #, fuzzy msgid "text to display before nick in prefix of message, example: \"<\"" msgstr "text pro zobrazení před přezdívkou v okně rozhovoru" @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-07-11 21:45+0200\n" +"POT-Creation-Date: 2013-07-15 18:33+0200\n" "PO-Revision-Date: 2013-07-02 22:20+0100\n" "Last-Translator: Nils Görs <weechatter@arcor.de>\n" "Language-Team: German <weechatter@arcor.de>\n" @@ -446,6 +446,13 @@ msgid "No key found" msgstr "Keine Taste gefunden" #, c-format +msgid "" +"%sError: it is not safe to bind key \"%s\" because it does not start with a " +"ctrl or meta code (tip: use alt-k to find key codes); if you want to bind " +"this key anyway, turn off option weechat.look.key_bind_safe" +msgstr "" + +#, c-format msgid "%sError: context \"%s\" not found" msgstr "%sFehler: Kontext\"%s\" nicht gefunden" @@ -3009,6 +3016,10 @@ msgstr "" "springt zurück zum Ausgangsbuffer, falls keine weiteren Einträge in der " "Hotlist vorhanden sind" +msgid "" +"allow only binding of \"safe\" keys (beginning with a ctrl or meta code)" +msgstr "" + msgid "text to display before nick in prefix of message, example: \"<\"" msgstr "Text, der vor dem Nick dargestellt werden soll, Beispiel: \"<\"" @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-07-11 21:45+0200\n" +"POT-Creation-Date: 2013-07-15 18:33+0200\n" "PO-Revision-Date: 2013-07-02 15:57+0200\n" "Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -441,6 +441,13 @@ msgid "No key found" msgstr "Ninguna tecla encontrada" #, c-format +msgid "" +"%sError: it is not safe to bind key \"%s\" because it does not start with a " +"ctrl or meta code (tip: use alt-k to find key codes); if you want to bind " +"this key anyway, turn off option weechat.look.key_bind_safe" +msgstr "" + +#, c-format msgid "%sError: context \"%s\" not found" msgstr "%sError: contexto \"%s\" no encontrado" @@ -2831,6 +2838,10 @@ msgstr "" msgid "jump back to initial buffer after reaching end of hotlist" msgstr "" +msgid "" +"allow only binding of \"safe\" keys (beginning with a ctrl or meta code)" +msgstr "" + #, fuzzy msgid "text to display before nick in prefix of message, example: \"<\"" msgstr "texto a mostrar antes del apodo en la ventana de charla" @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-07-11 21:45+0200\n" -"PO-Revision-Date: 2013-07-11 20:02+0200\n" +"POT-Creation-Date: 2013-07-15 18:33+0200\n" +"PO-Revision-Date: 2013-07-15 18:35+0200\n" "Last-Translator: Sebastien Helleu <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language: fr\n" @@ -438,6 +438,17 @@ msgid "No key found" msgstr "Aucune touche trouvée" #, c-format +msgid "" +"%sError: it is not safe to bind key \"%s\" because it does not start with a " +"ctrl or meta code (tip: use alt-k to find key codes); if you want to bind " +"this key anyway, turn off option weechat.look.key_bind_safe" +msgstr "" +"%sErreur: il n'est pas sûr d'associer la touche \"%s\" car elle ne commence " +"pas par un code ctrl ou meta (astuce: utilisez alt-k pour trouver le code " +"d'une touche); si vous voulez quand même associer cette touche, désactivez " +"l'option weechat.look.key_bind_safe" + +#, c-format msgid "%sError: context \"%s\" not found" msgstr "%sErreur: contexte \"%s\" non trouvé" @@ -2920,6 +2931,12 @@ msgstr "" msgid "jump back to initial buffer after reaching end of hotlist" msgstr "retourner au tampon initial après avoir atteint la fin de la hotlist" +msgid "" +"allow only binding of \"safe\" keys (beginning with a ctrl or meta code)" +msgstr "" +"autoriser seulement l'association de touches \"sûres\" (commençant par un " +"code ctrl ou meta)" + msgid "text to display before nick in prefix of message, example: \"<\"" msgstr "texte à afficher avant le pseudo dans le préfixe, par exemple: \"<\"" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-07-11 21:45+0200\n" +"POT-Creation-Date: 2013-07-15 18:33+0200\n" "PO-Revision-Date: 2013-07-02 15:57+0200\n" "Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -447,6 +447,13 @@ msgstr "Billentyű:\n" msgid "No key found" msgstr "Nem találtam billentyűt.\n" +#, c-format +msgid "" +"%sError: it is not safe to bind key \"%s\" because it does not start with a " +"ctrl or meta code (tip: use alt-k to find key codes); if you want to bind " +"this key anyway, turn off option weechat.look.key_bind_safe" +msgstr "" + #, fuzzy, c-format msgid "%sError: context \"%s\" not found" msgstr "%s a \"%s\" modul nem található\n" @@ -2297,6 +2304,10 @@ msgstr "" msgid "jump back to initial buffer after reaching end of hotlist" msgstr "" +msgid "" +"allow only binding of \"safe\" keys (beginning with a ctrl or meta code)" +msgstr "" + #, fuzzy msgid "text to display before nick in prefix of message, example: \"<\"" msgstr "a név előtt megjelenítendő szöveg a beszédablakban" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-07-11 21:45+0200\n" +"POT-Creation-Date: 2013-07-15 18:33+0200\n" "PO-Revision-Date: 2013-06-14 19:39-0300\n" "Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -437,6 +437,13 @@ msgid "No key found" msgstr "Nessun tasto trovato" #, c-format +msgid "" +"%sError: it is not safe to bind key \"%s\" because it does not start with a " +"ctrl or meta code (tip: use alt-k to find key codes); if you want to bind " +"this key anyway, turn off option weechat.look.key_bind_safe" +msgstr "" + +#, c-format msgid "%sError: context \"%s\" not found" msgstr "%sErrore: contesto \"%s\" non trovato" @@ -2877,6 +2884,10 @@ msgstr "" msgid "jump back to initial buffer after reaching end of hotlist" msgstr "torna al buffer iniziale dopo aver raggiunto la fine della hotlist" +msgid "" +"allow only binding of \"safe\" keys (beginning with a ctrl or meta code)" +msgstr "" + msgid "text to display before nick in prefix of message, example: \"<\"" msgstr "" "testo da visualizzare prima del nick nel prefisso del messaggio, esempio: \"<" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-07-11 21:45+0200\n" +"POT-Creation-Date: 2013-07-15 18:33+0200\n" "PO-Revision-Date: 2013-07-02 16:02+0200\n" "Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n" "Language-Team: Japanese <https://github.com/l/WeeChat>\n" @@ -438,6 +438,13 @@ msgid "No key found" msgstr "キーがありません" #, c-format +msgid "" +"%sError: it is not safe to bind key \"%s\" because it does not start with a " +"ctrl or meta code (tip: use alt-k to find key codes); if you want to bind " +"this key anyway, turn off option weechat.look.key_bind_safe" +msgstr "" + +#, c-format msgid "%sError: context \"%s\" not found" msgstr "%sエラー: コンテキスト \"%s\" が見つかりません" @@ -2836,6 +2843,10 @@ msgstr "" msgid "jump back to initial buffer after reaching end of hotlist" msgstr "ホットリストの最後に到達したら最初のバッファに移動する" +msgid "" +"allow only binding of \"safe\" keys (beginning with a ctrl or meta code)" +msgstr "" + msgid "text to display before nick in prefix of message, example: \"<\"" msgstr "" "メッセージプレフィックス中のニックネームの前に表示するテキスト、例: \"<\"" @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-07-11 21:45+0200\n" +"POT-Creation-Date: 2013-07-15 18:33+0200\n" "PO-Revision-Date: 2013-07-02 15:37+0200\n" "Last-Translator: Krzysztof Korościk <soltys@szluug.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -442,6 +442,13 @@ msgid "No key found" msgstr "Nie znaleziono klawisza" #, c-format +msgid "" +"%sError: it is not safe to bind key \"%s\" because it does not start with a " +"ctrl or meta code (tip: use alt-k to find key codes); if you want to bind " +"this key anyway, turn off option weechat.look.key_bind_safe" +msgstr "" + +#, c-format msgid "%sError: context \"%s\" not found" msgstr "%sBłąd: nie odnaleziono kontekstu \"%s\"" @@ -2900,6 +2907,10 @@ msgstr "" msgid "jump back to initial buffer after reaching end of hotlist" msgstr "wróć do początkowego buforu po dotarciu na koniec hotlisty" +msgid "" +"allow only binding of \"safe\" keys (beginning with a ctrl or meta code)" +msgstr "" + msgid "text to display before nick in prefix of message, example: \"<\"" msgstr "teks wyświetlany przed nickiem w prefiksie wiadomości, przykład: \"<\"" diff --git a/po/pt_BR.po b/po/pt_BR.po index 2e60c5ffe..df63682a3 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-07-11 21:45+0200\n" +"POT-Creation-Date: 2013-07-15 18:33+0200\n" "PO-Revision-Date: 2013-06-10 09:19+0200\n" "Last-Translator: Sergio Durigan Junior <sergiosdj@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -468,6 +468,13 @@ msgid "No key found" msgstr "Nenhuma tecla encontrada" #, c-format +msgid "" +"%sError: it is not safe to bind key \"%s\" because it does not start with a " +"ctrl or meta code (tip: use alt-k to find key codes); if you want to bind " +"this key anyway, turn off option weechat.look.key_bind_safe" +msgstr "" + +#, c-format msgid "%sError: context \"%s\" not found" msgstr "%sErro: contexto \"%s\" não encontrado" @@ -2752,6 +2759,10 @@ msgstr "" msgid "jump back to initial buffer after reaching end of hotlist" msgstr "" +msgid "" +"allow only binding of \"safe\" keys (beginning with a ctrl or meta code)" +msgstr "" + #, fuzzy msgid "text to display before nick in prefix of message, example: \"<\"" msgstr "texto a ser exibido antes do apelido na janela de chat" @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-07-11 21:45+0200\n" +"POT-Creation-Date: 2013-07-15 18:33+0200\n" "PO-Revision-Date: 2013-07-02 16:02+0200\n" "Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -456,6 +456,13 @@ msgstr "Клавиша:\n" msgid "No key found" msgstr "Клавиши не найдены.\n" +#, c-format +msgid "" +"%sError: it is not safe to bind key \"%s\" because it does not start with a " +"ctrl or meta code (tip: use alt-k to find key codes); if you want to bind " +"this key anyway, turn off option weechat.look.key_bind_safe" +msgstr "" + #, fuzzy, c-format msgid "%sError: context \"%s\" not found" msgstr "%s plugin \"%s\" не найден\n" @@ -2327,6 +2334,10 @@ msgstr "" msgid "jump back to initial buffer after reaching end of hotlist" msgstr "" +msgid "" +"allow only binding of \"safe\" keys (beginning with a ctrl or meta code)" +msgstr "" + #, fuzzy msgid "text to display before nick in prefix of message, example: \"<\"" msgstr "текст, который отображать до ника в окне чата" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.4.2-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2013-07-11 21:45+0200\n" +"POT-Creation-Date: 2013-07-15 18:33+0200\n" "PO-Revision-Date: 2013-06-28 13:51+0200\n" "Last-Translator: Hasan Kiran <sunder67@hotmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -406,6 +406,13 @@ msgid "No key found" msgstr "Tuş bulunamadı" #, c-format +msgid "" +"%sError: it is not safe to bind key \"%s\" because it does not start with a " +"ctrl or meta code (tip: use alt-k to find key codes); if you want to bind " +"this key anyway, turn off option weechat.look.key_bind_safe" +msgstr "" + +#, c-format msgid "%sError: context \"%s\" not found" msgstr "" @@ -2050,6 +2057,10 @@ msgstr "" msgid "jump back to initial buffer after reaching end of hotlist" msgstr "" +msgid "" +"allow only binding of \"safe\" keys (beginning with a ctrl or meta code)" +msgstr "" + msgid "text to display before nick in prefix of message, example: \"<\"" msgstr "" diff --git a/po/weechat.pot b/po/weechat.pot index efa160fc3..c5efdddb9 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: 2013-07-11 21:45+0200\n" +"POT-Creation-Date: 2013-07-15 18:33+0200\n" "PO-Revision-Date: 2013-02-14 18:20+0100\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -406,6 +406,13 @@ msgid "No key found" msgstr "" #, c-format +msgid "" +"%sError: it is not safe to bind key \"%s\" because it does not start with a " +"ctrl or meta code (tip: use alt-k to find key codes); if you want to bind " +"this key anyway, turn off option weechat.look.key_bind_safe" +msgstr "" + +#, c-format msgid "%sError: context \"%s\" not found" msgstr "" @@ -2057,6 +2064,10 @@ msgstr "" msgid "jump back to initial buffer after reaching end of hotlist" msgstr "" +msgid "" +"allow only binding of \"safe\" keys (beginning with a ctrl or meta code)" +msgstr "" + msgid "text to display before nick in prefix of message, example: \"<\"" msgstr "" diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 133646047..3daf55edc 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -2876,6 +2876,19 @@ COMMAND_CALLBACK(key) } /* bind new key */ + if (CONFIG_BOOLEAN(config_look_key_bind_safe) + && !gui_key_is_safe (GUI_KEY_CONTEXT_DEFAULT, argv[2])) + { + gui_chat_printf (NULL, + _("%sError: it is not safe to bind key \"%s\" because " + "it does not start with a ctrl or meta code (tip: " + "use alt-k to find key codes); if you want to " + "bind this key anyway, turn off option " + "weechat.look.key_bind_safe"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], + argv[2]); + return WEECHAT_RC_OK; + } gui_key_verbose = 1; ptr_new_key = gui_key_bind (NULL, GUI_KEY_CONTEXT_DEFAULT, argv[2], argv_eol[3]); @@ -2932,6 +2945,19 @@ COMMAND_CALLBACK(key) } /* bind new key */ + if (CONFIG_BOOLEAN(config_look_key_bind_safe) + && !gui_key_is_safe (GUI_KEY_CONTEXT_DEFAULT, argv[3])) + { + gui_chat_printf (NULL, + _("%sError: it is not safe to bind key \"%s\" because " + "it does not start with a ctrl or meta code (tip: " + "use alt-k to find key codes); if you want to " + "bind this key anyway, turn off option " + "weechat.look.key_bind_safe"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], + argv[3]); + return WEECHAT_RC_OK; + } gui_key_verbose = 1; ptr_new_key = gui_key_bind (NULL, context, argv[3], argv_eol[4]); diff --git a/src/core/wee-config.c b/src/core/wee-config.c index 0dddc6034..95efa5e98 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -124,6 +124,7 @@ struct t_config_option *config_look_item_buffer_filter; struct t_config_option *config_look_jump_current_to_previous_buffer; struct t_config_option *config_look_jump_previous_buffer_when_closing; struct t_config_option *config_look_jump_smart_back_to_buffer; +struct t_config_option *config_look_key_bind_safe; struct t_config_option *config_look_nick_prefix; struct t_config_option *config_look_nick_suffix; struct t_config_option *config_look_mouse; @@ -2203,6 +2204,12 @@ config_weechat_init_options () "jump_smart_back_to_buffer", "boolean", N_("jump back to initial buffer after reaching end of hotlist"), NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + config_look_key_bind_safe = config_file_new_option ( + weechat_config_file, ptr_section, + "key_bind_safe", "boolean", + N_("allow only binding of \"safe\" keys (beginning with a ctrl or meta " + "code)"), + NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); config_look_nick_prefix = config_file_new_option ( weechat_config_file, ptr_section, "nick_prefix", "string", diff --git a/src/core/wee-config.h b/src/core/wee-config.h index 7e822a5c8..b1f541b5d 100644 --- a/src/core/wee-config.h +++ b/src/core/wee-config.h @@ -149,6 +149,7 @@ extern struct t_config_option *config_look_item_buffer_filter; extern struct t_config_option *config_look_jump_current_to_previous_buffer; extern struct t_config_option *config_look_jump_previous_buffer_when_closing; extern struct t_config_option *config_look_jump_smart_back_to_buffer; +extern struct t_config_option *config_look_key_bind_safe; extern struct t_config_option *config_look_nick_prefix; extern struct t_config_option *config_look_nick_suffix; extern struct t_config_option *config_look_mouse; diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c index 032596fc7..63308b105 100644 --- a/src/gui/gui-key.c +++ b/src/gui/gui-key.c @@ -581,6 +581,39 @@ gui_key_set_score (struct t_gui_key *key) } /* + * Checks if a key is safe or not: a safe key begins always with the "meta" or + * "ctrl" code (except "@" allowed in cursor/mouse contexts). + * + * Returns: + * 1: key is safe + * 0: key is NOT safe + */ + +int +gui_key_is_safe (int context, const char *key) +{ + char *internal_code; + int rc; + + /* "@" is allowed at beginning for cursor/mouse contexts */ + if ((key[0] == '@') + && ((context == GUI_KEY_CONTEXT_CURSOR) + || (context == GUI_KEY_CONTEXT_MOUSE))) + { + return 1; + } + + /* check that first char is a ctrl or meta code */ + internal_code = gui_key_get_internal_code (key); + if (!internal_code) + return 0; + rc = (internal_code[0] == '\x01') ? 1 : 0; + free (internal_code); + + return rc; +} + +/* * Adds a new key in keys list. * * If buffer is not null, then key is specific to buffer, otherwise it's general diff --git a/src/gui/gui-key.h b/src/gui/gui-key.h index 0a32fee1e..7a3ec575f 100644 --- a/src/gui/gui-key.h +++ b/src/gui/gui-key.h @@ -90,6 +90,7 @@ extern int gui_key_search_context (const char *context); extern void gui_key_grab_init (int grab_command, const char *delay); extern char *gui_key_get_internal_code (const char *key); extern char *gui_key_get_expanded_name (const char *key); +extern int gui_key_is_safe (int context, const char *key); extern struct t_gui_key *gui_key_new (struct t_gui_buffer *buffer, int context, const char *key, |