core: add option weechat.completion.command_inline (task #12491)

v2.8-utf8proc
Sébastien Helleu 2014-11-09 12:29:41 +01:00
parent 5bfd710e62
commit af0397fb87
23 changed files with 231 additions and 47 deletions

View File

@ -17,6 +17,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
=== New features
* core: add option weechat.completion.command_inline (task #12491)
* core: add bar item "mouse_status", new options weechat.look.item_mouse_status
and weechat.color.status_mouse (closes #247)
* core: add signals "mouse_enabled" and "mouse_disabled" (closes #244)

View File

@ -56,6 +56,21 @@ You can restore the default "beep" trigger with the following command:
/trigger restore beep
----
=== Completion of inline commands
WeeChat now completes by default inline commands (not only at beginning of
line).
When this feature is enabled, there is no more automatic completion of
absolute paths (except if you are completing a path inside a command argument,
like `/dcc send <nick> <path>`).
To restore the old behavior (no completion of inline commands):
----
/set weechat.completion.command_inline off
----
=== Relay option relay.irc.backlog_tags
The option 'relay.irc.backlog_tags' is now a list separated by commas

View File

@ -318,6 +318,11 @@
** Typ: boolesch
** Werte: on, off (Standardwert: `on`)
* [[option_weechat.completion.command_inline]] *weechat.completion.command_inline*
** Beschreibung: `if enabled, the commands inside command line are completed (the command at beginning of line has higher priority and is used first); note: when this option is enabled, there is no more automatic completion of paths beginning with '/' (outside commands arguments)`
** 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 API-Dokumentation findet man die vorgegebenen Codes und Werte, Funktion "weechat_hook_command")`
** Typ: Zeichenkette

View File

@ -318,6 +318,11 @@
** type: boolean
** values: on, off (default value: `on`)
* [[option_weechat.completion.command_inline]] *weechat.completion.command_inline*
** description: `if enabled, the commands inside command line are completed (the command at beginning of line has higher priority and is used first); note: when this option is enabled, there is no more automatic completion of paths beginning with '/' (outside commands arguments)`
** 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: plugin API reference, function "weechat_hook_command")`
** type: string

View File

@ -318,6 +318,11 @@
** type: booléen
** valeurs: on, off (valeur par défaut: `on`)
* [[option_weechat.completion.command_inline]] *weechat.completion.command_inline*
** description: `si activé, les commandes à l'intérieur de la ligne de commande sont complétées (la commande en début de ligne a une priorité plus élevée et est utilisée en premier) ; note : lorsque cette option est activée, il n'y a plus de complétion automatique des chemins commençant par '/' (en dehors des paramètres de commandes)`
** 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 : Référence API extension, fonction "weechat_hook_command")`
** type: chaîne

View File

@ -318,6 +318,11 @@
** tipo: bool
** valori: on, off (valore predefinito: `on`)
* [[option_weechat.completion.command_inline]] *weechat.completion.command_inline*
** descrizione: `if enabled, the commands inside command line are completed (the command at beginning of line has higher priority and is used first); note: when this option is enabled, there is no more automatic completion of paths beginning with '/' (outside commands arguments)`
** tipo: bool
** valori: on, off (valore predefinito: `on`)
* [[option_weechat.completion.default_template]] *weechat.completion.default_template*
** descrizione: `modello di completamento predefinito (per favore, consulta la documentazione per codici e valori del template: Referenze API per Plugin, funzione "weechat_hook_command")`
** tipo: stringa

View File

@ -318,6 +318,11 @@
** タイプ: ブール
** 値: on, off (デフォルト値: `on`)
* [[option_weechat.completion.command_inline]] *weechat.completion.command_inline*
** 説明: `if enabled, the commands inside command line are completed (the command at beginning of line has higher priority and is used first); note: when this option is enabled, there is no more automatic completion of paths beginning with '/' (outside commands arguments)`
** タイプ: ブール
** 値: on, off (デフォルト値: `on`)
* [[option_weechat.completion.default_template]] *weechat.completion.default_template*
** 説明: `デフォルトの補完テンプレート (テンプレートコードと値のドキュメントを参照: プラグイン API リファレンス、"weechat_hook_command" 関数)`
** タイプ: 文字列

View File

@ -318,6 +318,11 @@
** typ: bool
** wartości: on, off (domyślna wartość: `on`)
* [[option_weechat.completion.command_inline]] *weechat.completion.command_inline*
** opis: `if enabled, the commands inside command line are completed (the command at beginning of line has higher priority and is used first); note: when this option is enabled, there is no more automatic completion of paths beginning with '/' (outside commands arguments)`
** typ: bool
** wartości: on, off (domyślna wartość: `on`)
* [[option_weechat.completion.default_template]] *weechat.completion.default_template*
** opis: `domyślny szablon dopełnień (zajrzyj do dokumentacji w celu uzyskania kodów i wartości szablonów: opis API wtyczek, funkcja "weechat_hook_command")`
** typ: ciąg

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-11-06 20:22+0100\n"
"POT-Creation-Date: 2014-11-09 11:32+0100\n"
"PO-Revision-Date: 2014-11-01 11:58+0100\n"
"Last-Translator: Jiri Golembiovsky <golemj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -3546,6 +3546,13 @@ msgid ""
"the base word ends at first space after cursor"
msgstr ""
msgid ""
"if enabled, the commands inside command line are completed (the command at "
"beginning of line has higher priority and is used first); note: when this "
"option is enabled, there is no more automatic completion of paths beginning "
"with '/' (outside commands arguments)"
msgstr ""
#, fuzzy
msgid ""
"default completion template (please see documentation for template codes and "

View File

@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-11-06 20:22+0100\n"
"POT-Creation-Date: 2014-11-09 11:32+0100\n"
"PO-Revision-Date: 2014-11-06 21:43+0100\n"
"Last-Translator: Nils Görs <weechatter@arcor.de>\n"
"Language-Team: German <weechatter@arcor.de>\n"
@ -4178,6 +4178,13 @@ msgstr ""
"werden, um eine Vervollständigung durchführen zu können (Beispiel: In einen "
"schon geschriebenen Text, einen Nick einzufügen)"
msgid ""
"if enabled, the commands inside command line are completed (the command at "
"beginning of line has higher priority and is used first); note: when this "
"option is enabled, there is no more automatic completion of paths beginning "
"with '/' (outside commands arguments)"
msgstr ""
msgid ""
"default completion template (please see documentation for template codes and "
"values: plugin API reference, function \"weechat_hook_command\")"

View File

@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-11-06 20:22+0100\n"
"POT-Creation-Date: 2014-11-09 11:32+0100\n"
"PO-Revision-Date: 2014-11-01 11:58+0100\n"
"Last-Translator: Elián Hanisch <lambdae2@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -3760,6 +3760,13 @@ msgstr ""
"cursor, de otra forma la palabra base termina en el primer espacio después "
"del cursor"
msgid ""
"if enabled, the commands inside command line are completed (the command at "
"beginning of line has higher priority and is used first); note: when this "
"option is enabled, there is no more automatic completion of paths beginning "
"with '/' (outside commands arguments)"
msgstr ""
#, fuzzy
msgid ""
"default completion template (please see documentation for template codes and "

View File

@ -21,8 +21,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-11-06 20:22+0100\n"
"PO-Revision-Date: 2014-11-06 20:23+0100\n"
"POT-Creation-Date: 2014-11-09 11:32+0100\n"
"PO-Revision-Date: 2014-11-09 11:33+0100\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: fr\n"
@ -4082,6 +4082,18 @@ 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 ""
"if enabled, the commands inside command line are completed (the command at "
"beginning of line has higher priority and is used first); note: when this "
"option is enabled, there is no more automatic completion of paths beginning "
"with '/' (outside commands arguments)"
msgstr ""
"si activé, les commandes à l'intérieur de la ligne de commande sont "
"complétées (la commande en début de ligne a une priorité plus élevée et est "
"utilisée en premier) ; note : lorsque cette option est activée, il n'y a "
"plus de complétion automatique des chemins commençant par '/' (en dehors des "
"paramètres de commandes)"
msgid ""
"default completion template (please see documentation for template codes and "
"values: plugin API reference, function \"weechat_hook_command\")"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-11-06 20:22+0100\n"
"POT-Creation-Date: 2014-11-09 11:32+0100\n"
"PO-Revision-Date: 2014-11-01 11:58+0100\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -3178,6 +3178,13 @@ msgid ""
"the base word ends at first space after cursor"
msgstr ""
msgid ""
"if enabled, the commands inside command line are completed (the command at "
"beginning of line has higher priority and is used first); note: when this "
"option is enabled, there is no more automatic completion of paths beginning "
"with '/' (outside commands arguments)"
msgstr ""
msgid ""
"default completion template (please see documentation for template codes and "
"values: plugin API reference, function \"weechat_hook_command\")"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-11-06 20:22+0100\n"
"POT-Creation-Date: 2014-11-09 11:32+0100\n"
"PO-Revision-Date: 2014-11-01 11:58+0100\n"
"Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -3868,6 +3868,13 @@ msgstr ""
"se abilitata, la parola base da completare termina al carattere prima del "
"cursore; altrimenti la parola base termina al primo spazio dopo il cursore"
msgid ""
"if enabled, the commands inside command line are completed (the command at "
"beginning of line has higher priority and is used first); note: when this "
"option is enabled, there is no more automatic completion of paths beginning "
"with '/' (outside commands arguments)"
msgstr ""
msgid ""
"default completion template (please see documentation for template codes and "
"values: plugin API reference, function \"weechat_hook_command\")"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-11-06 20:22+0100\n"
"POT-Creation-Date: 2014-11-09 11:32+0100\n"
"PO-Revision-Date: 2014-11-01 11:58+0100\n"
"Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n"
"Language-Team: Japanese <https://github.com/l/weechat/tree/translation_ja>\n"
@ -3916,6 +3916,13 @@ msgstr ""
"有効化された場合、補完する元単語はカーソル前の文字で終了; そうでなければ元単"
"語はカーソル後の最初の文字で終了"
msgid ""
"if enabled, the commands inside command line are completed (the command at "
"beginning of line has higher priority and is used first); note: when this "
"option is enabled, there is no more automatic completion of paths beginning "
"with '/' (outside commands arguments)"
msgstr ""
msgid ""
"default completion template (please see documentation for template codes and "
"values: plugin API reference, function \"weechat_hook_command\")"

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-11-06 20:22+0100\n"
"POT-Creation-Date: 2014-11-09 11:32+0100\n"
"PO-Revision-Date: 2014-11-01 11:58+0100\n"
"Last-Translator: Krzysztof Korościk <soltys@szluug.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -4009,6 +4009,13 @@ msgstr ""
"kursorem; w innym wypadku słowo bazowe kończy się na pierwszej spacji po "
"kursorze"
msgid ""
"if enabled, the commands inside command line are completed (the command at "
"beginning of line has higher priority and is used first); note: when this "
"option is enabled, there is no more automatic completion of paths beginning "
"with '/' (outside commands arguments)"
msgstr ""
msgid ""
"default completion template (please see documentation for template codes and "
"values: plugin API reference, function \"weechat_hook_command\")"

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-11-06 20:22+0100\n"
"POT-Creation-Date: 2014-11-09 11:32+0100\n"
"PO-Revision-Date: 2014-11-01 11:59+0100\n"
"Last-Translator: Sergio Durigan Junior <sergiosdj@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -3653,6 +3653,13 @@ msgid ""
"the base word ends at first space after cursor"
msgstr ""
msgid ""
"if enabled, the commands inside command line are completed (the command at "
"beginning of line has higher priority and is used first); note: when this "
"option is enabled, there is no more automatic completion of paths beginning "
"with '/' (outside commands arguments)"
msgstr ""
#, fuzzy
msgid ""
"default completion template (please see documentation for template codes and "

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-11-06 20:22+0100\n"
"POT-Creation-Date: 2014-11-09 11:32+0100\n"
"PO-Revision-Date: 2014-11-01 11:59+0100\n"
"Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -3208,6 +3208,13 @@ msgid ""
"the base word ends at first space after cursor"
msgstr ""
msgid ""
"if enabled, the commands inside command line are completed (the command at "
"beginning of line has higher priority and is used first); note: when this "
"option is enabled, there is no more automatic completion of paths beginning "
"with '/' (outside commands arguments)"
msgstr ""
msgid ""
"default completion template (please see documentation for template codes and "
"values: plugin API reference, function \"weechat_hook_command\")"

View File

@ -20,7 +20,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-11-06 20:22+0100\n"
"POT-Creation-Date: 2014-11-09 11:32+0100\n"
"PO-Revision-Date: 2014-07-25 07:50+0200\n"
"Last-Translator: Hasan Kiran <sunder67@hotmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -2855,6 +2855,13 @@ msgid ""
"the base word ends at first space after cursor"
msgstr ""
msgid ""
"if enabled, the commands inside command line are completed (the command at "
"beginning of line has higher priority and is used first); note: when this "
"option is enabled, there is no more automatic completion of paths beginning "
"with '/' (outside commands arguments)"
msgstr ""
msgid ""
"default completion template (please see documentation for template codes and "
"values: plugin API reference, function \"weechat_hook_command\")"

View File

@ -21,7 +21,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2014-11-06 20:22+0100\n"
"POT-Creation-Date: 2014-11-09 11:32+0100\n"
"PO-Revision-Date: 2014-08-16 10:27+0200\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@ -2852,6 +2852,13 @@ msgid ""
"the base word ends at first space after cursor"
msgstr ""
msgid ""
"if enabled, the commands inside command line are completed (the command at "
"beginning of line has higher priority and is used first); note: when this "
"option is enabled, there is no more automatic completion of paths beginning "
"with '/' (outside commands arguments)"
msgstr ""
msgid ""
"default completion template (please see documentation for template codes and "
"values: plugin API reference, function \"weechat_hook_command\")"

View File

@ -244,6 +244,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_command_inline;
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;
@ -3192,6 +3193,15 @@ config_weechat_init_options ()
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_command_inline = config_file_new_option (
weechat_config_file, ptr_section,
"command_inline", "boolean",
N_("if enabled, the commands inside command line are completed (the "
"command at beginning of line has higher priority and is used "
"first); note: when this option is enabled, there is no more "
"automatic completion of paths beginning with '/' (outside "
"commands arguments)"),
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",

View File

@ -277,6 +277,7 @@ extern struct t_config_option *config_color_nicklist_group;
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_command_inline;
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;

View File

@ -705,33 +705,77 @@ void
gui_completion_find_context (struct t_gui_completion *completion,
const char *data, int size, int pos)
{
int i, command, command_arg, pos_start, pos_end;
int i, command_arg, pos_start, pos_end;
const char *ptr_command, *ptr_data;
char *prev_char;
/* look for context */
gui_completion_free_data (completion);
gui_completion_buffer_init (completion, completion->buffer);
command = (string_is_command_char (data)) ? 1 : 0;
ptr_command = NULL;
command_arg = 0;
i = 0;
while (i < pos)
/* check if data starts with a command */
ptr_data = data;
if (string_is_command_char (ptr_data))
{
if (data[i] == ' ')
ptr_data = utf8_next_char (ptr_data);
if (ptr_data < data + pos)
{
command_arg++;
i++;
while ((i < pos) && (data[i] == ' '))
if (string_is_command_char (ptr_data))
ptr_data = utf8_next_char (ptr_data);
}
if (!string_is_command_char (ptr_data))
ptr_command = ptr_data;
}
/*
* search for the last command in data (only if there is no command at
* beginning and if completion of inline commands is enabled)
*/
if (!ptr_command && CONFIG_BOOLEAN(config_completion_command_inline))
{
ptr_data = data;
while (ptr_data && (ptr_data < data + pos))
{
ptr_data = strchr (ptr_data, ' ');
if (!ptr_data)
break;
if (ptr_data < data + pos)
{
i++;
while ((ptr_data < data + pos) && (ptr_data[0] == ' '))
{
ptr_data++;
}
}
if ((ptr_data < data + pos) && string_is_command_char (ptr_data))
{
ptr_data = utf8_next_char (ptr_data);
if (!string_is_command_char (ptr_data))
ptr_command = ptr_data;
}
}
}
if (ptr_command)
{
/* search argument number and string with arguments */
ptr_data = ptr_command;
while (ptr_data < data + pos)
{
ptr_data = strchr (ptr_data, ' ');
if (!ptr_data)
break;
command_arg++;
while ((ptr_data < data + pos) && (ptr_data[0] == ' '))
{
ptr_data++;
}
if (!completion->args)
completion->args = strdup (data + i);
completion->args = strdup (ptr_data);
}
else
i++;
}
if (command)
{
/* set completion context */
if (command_arg > 0)
{
completion->context = GUI_COMPLETION_COMMAND_ARG;
@ -817,35 +861,29 @@ gui_completion_find_context (struct t_gui_completion *completion,
/* find command (for command argument completion only) */
if (completion->context == GUI_COMPLETION_COMMAND_ARG)
{
pos_start = 0;
while ((pos_start < size) && !string_is_command_char (data + pos_start))
pos_start = ptr_command - data;
pos_end = pos_start;
while ((pos_end < size) && (data[pos_end] != ' '))
{
pos_start += utf8_char_size (data + pos_start);
pos_end += utf8_char_size (data + pos_end);
}
if (string_is_command_char (data + pos_start))
if (data[pos_end] == ' ')
{
prev_char = utf8_prev_char (data, data + pos_end);
pos_end -= utf8_char_size (prev_char);
}
if (pos_end >= pos_start)
{
pos_start += utf8_char_size (data + pos_start);
if (string_is_command_char (data + pos_start))
pos_start += utf8_char_size (data + pos_start);
pos_end = pos_start;
while ((pos_end < size) && (data[pos_end] != ' '))
{
pos_end += utf8_char_size (data + pos_end);
}
if (data[pos_end] == ' ')
{
prev_char = utf8_prev_char (data, data + pos_end);
pos_end -= utf8_char_size (prev_char);
}
completion->base_command = malloc (pos_end - pos_start + 2);
for (i = pos_start; i <= pos_end; i++)
{
completion->base_command[i - pos_start] = data[i];
}
completion->base_command[pos_end - pos_start + 1] = '\0';
gui_completion_build_list (completion);
}
else
completion->base_command = strdup ("");
gui_completion_build_list (completion);
}
/*