From c7a1a01d8fdb65282cd6e68af095618be8ffcc5a Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sat, 12 Nov 2011 16:09:14 +0100 Subject: [PATCH] core: add new option weechat.completion.base_word_until_cursor: allow completion in middle of words (enabled by default) (task #9771) --- ChangeLog | 2 ++ doc/de/autogen/user/weechat_options.txt | 5 +++++ doc/en/autogen/user/weechat_options.txt | 5 +++++ doc/fr/autogen/user/weechat_options.txt | 5 +++++ doc/it/autogen/user/weechat_options.txt | 5 +++++ po/cs.po | 7 ++++++- po/de.po | 7 ++++++- po/es.po | 7 ++++++- po/fr.po | 11 +++++++++-- po/hu.po | 7 ++++++- po/it.po | 7 ++++++- po/pl.po | 7 ++++++- po/pt_BR.po | 7 ++++++- po/ru.po | 7 ++++++- po/weechat.pot | 7 ++++++- src/core/wee-config.c | 7 +++++++ src/core/wee-config.h | 1 + src/gui/gui-completion.c | 17 +++++++++++++---- 18 files changed, 106 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 089ae05ec..03a459f42 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ v0.3.7-dev, 2011-11-12 Version 0.3.7 (under dev!) -------------------------- +* core: add new option weechat.completion.base_word_until_cursor: allow + completion in middle of words (enabled by default) (task #9771) * core: add option "jump_last_buffer_displayed" for command /input (key: alt+"/") (task #11553) * core: display error in command /buffer if arguments are wrong (bug #34180) diff --git a/doc/de/autogen/user/weechat_options.txt b/doc/de/autogen/user/weechat_options.txt index 39ef5325c..af0c95ae5 100644 --- a/doc/de/autogen/user/weechat_options.txt +++ b/doc/de/autogen/user/weechat_options.txt @@ -263,6 +263,11 @@ ** Typ: Farbe ** Werte: ein Farbname für WeeChat (default, black, (dark)gray, white, (light)red, (light)green, brown, yellow, (light)blue, (light)magenta, (light)cyan), eine Terminal-Farbnummer oder ein Alias; Attribute werden vor einer Farbe gesetzt (ausschließlich für die Textfarbe und nicht für den Hintergrund): "*" für fett, "!" für invertiert, "_" für unterstrichen (Standardwert: `default`) +* [[option_weechat.completion.base_word_until_cursor]] *weechat.completion.base_word_until_cursor* +** Beschreibung: `if enabled, the base word to complete ends at char before cursor; otherwise the base word ends at first space after cursor` +** Typ: boolesch +** Werte: on, off (Standardwert: `on`) + * [[option_weechat.completion.default_template]] *weechat.completion.default_template* ** Beschreibung: `Standardvorlage für die automatische Vervollständigung (in der Dokumentation finden Sie die vorgegebenen Codes und Werte)` ** Typ: Zeichenkette diff --git a/doc/en/autogen/user/weechat_options.txt b/doc/en/autogen/user/weechat_options.txt index 79cd43dfd..5e1fce663 100644 --- a/doc/en/autogen/user/weechat_options.txt +++ b/doc/en/autogen/user/weechat_options.txt @@ -263,6 +263,11 @@ ** type: color ** values: a WeeChat color name (default, black, (dark)gray, white, (light)red, (light)green, brown, yellow, (light)blue, (light)magenta, (light)cyan), a terminal color number or an alias; attributes are allowed before color (for text color only, not background): "*" for bold, "!" for reverse, "_" for underline (default value: `default`) +* [[option_weechat.completion.base_word_until_cursor]] *weechat.completion.base_word_until_cursor* +** description: `if enabled, the base word to complete ends at char before cursor; otherwise the base word ends at first space after cursor` +** type: boolean +** values: on, off (default value: `on`) + * [[option_weechat.completion.default_template]] *weechat.completion.default_template* ** description: `default completion template (please see documentation for template codes and values)` ** type: string diff --git a/doc/fr/autogen/user/weechat_options.txt b/doc/fr/autogen/user/weechat_options.txt index 3e41b969e..1d26b33e2 100644 --- a/doc/fr/autogen/user/weechat_options.txt +++ b/doc/fr/autogen/user/weechat_options.txt @@ -263,6 +263,11 @@ ** type: couleur ** valeurs: un nom de couleur WeeChat (default, black, (dark)gray, white, (light)red, (light)green, brown, yellow, (light)blue, (light)magenta, (light)cyan), un numéro de couleur du terminal ou un alias; des attributs sont autorisés avant la couleur (seulement pour la couleur du texte, pas le fond) : "*" pour du gras, "!" pour la vidéo inverse, "_" pour du souligné (valeur par défaut: `default`) +* [[option_weechat.completion.base_word_until_cursor]] *weechat.completion.base_word_until_cursor* +** description: `si activé, le mot de base pour la complétion s'arrête au caractère avant le curseur; sinon le mot de base s'arrête au premier espace après le curseur` +** type: booléen +** valeurs: on, off (valeur par défaut: `on`) + * [[option_weechat.completion.default_template]] *weechat.completion.default_template* ** description: `modèle de complétion par défaut (merci de consulter la documentation pour les codes et valeurs du modèle)` ** type: chaîne diff --git a/doc/it/autogen/user/weechat_options.txt b/doc/it/autogen/user/weechat_options.txt index 3d84bd8d7..dab468186 100644 --- a/doc/it/autogen/user/weechat_options.txt +++ b/doc/it/autogen/user/weechat_options.txt @@ -263,6 +263,11 @@ ** tipo: colore ** valori: un nome colore di WeeChat (default, black, (dark)gray, white, (light)red, (light)green, brown, yellow, (light)blue, (light)magenta, (light)cyan), un numero colore del terminale o un alias; attributi consentiti prima del colore (solo per il colore del testo, non lo sfondo): "*" per il grassetto, "!" per l'inverso, "_" per la sottolineatura (valore predefinito: `default`) +* [[option_weechat.completion.base_word_until_cursor]] *weechat.completion.base_word_until_cursor* +** descrizione: `if enabled, the base word to complete ends at char before cursor; otherwise the base word ends at first space after cursor` +** tipo: bool +** valori: on, off (valore predefinito: `on`) + * [[option_weechat.completion.default_template]] *weechat.completion.default_template* ** descrizione: `modello di completamento predefinito (consulta la documentazione per codici e valori del template)` ** tipo: stringa diff --git a/po/cs.po b/po/cs.po index 88f996e45..4298275b4 100644 --- a/po/cs.po +++ b/po/cs.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-11-08 17:56+0100\n" +"POT-Creation-Date: 2011-11-12 16:06+0100\n" "PO-Revision-Date: 2011-11-03 16:57+0100\n" "Last-Translator: Jiri Golembiovsky \n" "Language-Team: weechat-dev \n" @@ -2792,6 +2792,11 @@ msgstr "barva textu pro nepřítomné přezdíveky" msgid "text color for offline nicknames" msgstr "barva textu pro nepřipojené přezdíveky" +msgid "" +"if enabled, the base word to complete ends at char before cursor; otherwise " +"the base word ends at first space after cursor" +msgstr "" + msgid "" "default completion template (please see documentation for template codes and " "values)" diff --git a/po/de.po b/po/de.po index d41ddbdc1..b44efd297 100644 --- a/po/de.po +++ b/po/de.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-11-08 22:58+0100\n" +"POT-Creation-Date: 2011-11-12 16:06+0100\n" "PO-Revision-Date: 2011-11-08 22:03+0100\n" "Last-Translator: Nils Görs\n" "Language-Team: weechat-dev \n" @@ -3048,6 +3048,11 @@ msgstr "Textfarbe von abwesenden Nicknamen" msgid "text color for offline nicknames" msgstr "Textfarbe von Nicknamen die Offline sind" +msgid "" +"if enabled, the base word to complete ends at char before cursor; otherwise " +"the base word ends at first space after cursor" +msgstr "" + msgid "" "default completion template (please see documentation for template codes and " "values)" diff --git a/po/es.po b/po/es.po index 50904637c..8d1204637 100644 --- a/po/es.po +++ b/po/es.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-11-08 17:56+0100\n" +"POT-Creation-Date: 2011-11-12 16:06+0100\n" "PO-Revision-Date: 2011-11-03 16:57+0100\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -2952,6 +2952,11 @@ msgstr "color para apodos ausentes" msgid "text color for offline nicknames" msgstr "color para apodos desconectados" +msgid "" +"if enabled, the base word to complete ends at char before cursor; otherwise " +"the base word ends at first space after cursor" +msgstr "" + msgid "" "default completion template (please see documentation for template codes and " "values)" diff --git a/po/fr.po b/po/fr.po index 823ecca66..088504fb4 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-11-08 17:56+0100\n" -"PO-Revision-Date: 2011-11-08 17:15+0100\n" +"POT-Creation-Date: 2011-11-12 16:06+0100\n" +"PO-Revision-Date: 2011-11-12 16:06+0100\n" "Last-Translator: Sebastien Helleu \n" "Language-Team: weechat-dev \n" "Language: French\n" @@ -2969,6 +2969,13 @@ msgstr "couleur du texte pour les pseudos absents" msgid "text color for offline nicknames" msgstr "couleur du texte pour les pseudos déconnectés" +msgid "" +"if enabled, the base word to complete ends at char before cursor; otherwise " +"the base word ends at first space after cursor" +msgstr "" +"si activé, le mot de base pour la complétion s'arrête au caractère avant le " +"curseur; sinon le mot de base s'arrête au premier espace après le curseur" + msgid "" "default completion template (please see documentation for template codes and " "values)" diff --git a/po/hu.po b/po/hu.po index e1ddc4838..f24958d4a 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-11-08 17:56+0100\n" +"POT-Creation-Date: 2011-11-12 16:06+0100\n" "PO-Revision-Date: 2011-10-22 12:21+0200\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -2463,6 +2463,11 @@ msgstr "távollevő felhasználók nevének színe" msgid "text color for offline nicknames" msgstr "távollevő felhasználók nevének színe" +msgid "" +"if enabled, the base word to complete ends at char before cursor; otherwise " +"the base word ends at first space after cursor" +msgstr "" + msgid "" "default completion template (please see documentation for template codes and " "values)" diff --git a/po/it.po b/po/it.po index 107bc1cc4..8cfd9726b 100644 --- a/po/it.po +++ b/po/it.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-11-08 17:56+0100\n" +"POT-Creation-Date: 2011-11-12 16:06+0100\n" "PO-Revision-Date: 2011-11-03 16:57+0100\n" "Last-Translator: Marco Paolone \n" "Language-Team: weechat-dev \n" @@ -2945,6 +2945,11 @@ msgstr "colore del testo per i nick assenti" msgid "text color for offline nicknames" msgstr "colore del testo per i nick non in linea" +msgid "" +"if enabled, the base word to complete ends at char before cursor; otherwise " +"the base word ends at first space after cursor" +msgstr "" + msgid "" "default completion template (please see documentation for template codes and " "values)" diff --git a/po/pl.po b/po/pl.po index f417d40ed..1a523704f 100644 --- a/po/pl.po +++ b/po/pl.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-11-08 17:56+0100\n" +"POT-Creation-Date: 2011-11-12 16:06+0100\n" "PO-Revision-Date: 2011-11-03 16:57+0100\n" "Last-Translator: Krzysztof Korościk \n" "Language-Team: weechat-dev \n" @@ -2942,6 +2942,11 @@ msgstr "kolor nicków ze statusem nieobecności" msgid "text color for offline nicknames" msgstr "kolor dla nieobecnych nicków" +msgid "" +"if enabled, the base word to complete ends at char before cursor; otherwise " +"the base word ends at first space after cursor" +msgstr "" + msgid "" "default completion template (please see documentation for template codes and " "values)" diff --git a/po/pt_BR.po b/po/pt_BR.po index 18546275b..6d4176be8 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-11-08 17:56+0100\n" +"POT-Creation-Date: 2011-11-12 16:06+0100\n" "PO-Revision-Date: 2011-11-03 16:58+0100\n" "Last-Translator: Ivan Sichmann Freitas \n" "Language-Team: weechat-dev \n" @@ -2903,6 +2903,11 @@ msgstr "cor de texto para apelidos ausentes" msgid "text color for offline nicknames" msgstr "cor de texto para apelidos desconectados" +msgid "" +"if enabled, the base word to complete ends at char before cursor; otherwise " +"the base word ends at first space after cursor" +msgstr "" + msgid "" "default completion template (please see documentation for template codes and " "values)" diff --git a/po/ru.po b/po/ru.po index 453f0bc43..eded9cd42 100644 --- a/po/ru.po +++ b/po/ru.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat 0.3.7-dev\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2011-11-08 17:56+0100\n" +"POT-Creation-Date: 2011-11-12 16:06+0100\n" "PO-Revision-Date: 2011-10-22 12:21+0200\n" "Last-Translator: Pavel Shevchuk \n" "Language-Team: weechat-dev \n" @@ -2481,6 +2481,11 @@ msgstr "цвет отошедших ников" msgid "text color for offline nicknames" msgstr "цвет отошедших ников" +msgid "" +"if enabled, the base word to complete ends at char before cursor; otherwise " +"the base word ends at first space after cursor" +msgstr "" + msgid "" "default completion template (please see documentation for template codes and " "values)" diff --git a/po/weechat.pot b/po/weechat.pot index 8254af587..cd3792c9e 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: 2011-11-08 17:56+0100\n" +"POT-Creation-Date: 2011-11-12 16:06+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -2149,6 +2149,11 @@ msgstr "" msgid "text color for offline nicknames" msgstr "" +msgid "" +"if enabled, the base word to complete ends at char before cursor; otherwise " +"the base word ends at first space after cursor" +msgstr "" + msgid "" "default completion template (please see documentation for template codes and " "values)" diff --git a/src/core/wee-config.c b/src/core/wee-config.c index 7d1b9510d..00b2307ed 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -202,6 +202,7 @@ struct t_config_option *config_color_nicklist_offline; /* config, completion section */ +struct t_config_option *config_completion_base_word_until_cursor; struct t_config_option *config_completion_default_template; struct t_config_option *config_completion_nick_add_space; struct t_config_option *config_completion_nick_completer; @@ -2427,6 +2428,12 @@ config_weechat_init_options () return 0; } + config_completion_base_word_until_cursor = config_file_new_option ( + weechat_config_file, ptr_section, + "base_word_until_cursor", "boolean", + N_("if enabled, the base word to complete ends at char before cursor; " + "otherwise the base word ends at first space after cursor"), + NULL, 0, 0, "on", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); config_completion_default_template = config_file_new_option ( weechat_config_file, ptr_section, "default_template", "string", diff --git a/src/core/wee-config.h b/src/core/wee-config.h index 57ffd7941..e46e94707 100644 --- a/src/core/wee-config.h +++ b/src/core/wee-config.h @@ -222,6 +222,7 @@ extern struct t_config_option *config_color_nicklist_group; extern struct t_config_option *config_color_nicklist_away; extern struct t_config_option *config_color_nicklist_offline; +extern struct t_config_option *config_completion_base_word_until_cursor; extern struct t_config_option *config_completion_default_template; extern struct t_config_option *config_completion_nick_add_space; extern struct t_config_option *config_completion_nick_completer; diff --git a/src/gui/gui-completion.c b/src/gui/gui-completion.c index 06211172a..c789022ae 100644 --- a/src/gui/gui-completion.c +++ b/src/gui/gui-completion.c @@ -686,12 +686,21 @@ gui_completion_find_context (struct t_gui_completion *completion, } pos_start = i + 1; } - i = pos; - while ((i < size) && (data[i] != ' ')) + if (CONFIG_BOOLEAN (config_completion_base_word_until_cursor)) { - i++; + /* base word stops at cursor */ + pos_end = pos - 1; + } + else + { + /* base word stops after first space found (on or after cursor) */ + i = pos; + while ((i < size) && (data[i] != ' ')) + { + i++; + } + pos_end = i - 1; } - pos_end = i - 1; if (completion->context == GUI_COMPLETION_COMMAND) {