diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-04-25 22:10:48 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-04-25 22:10:48 +0200 |
commit | ac25043b272aa94c6c1498785fecb110f20e9fa4 (patch) | |
tree | dc5996df4557a0dd114a3101db297665fc932771 | |
parent | 0debd47d3e3374f05e1e791e525d2f1c5d183ce4 (diff) | |
download | weechat-ac25043b272aa94c6c1498785fecb110f20e9fa4.zip |
core: add option `split_return` in command `/input` (closes #1916)
-rw-r--r-- | ChangeLog.adoc | 1 | ||||
-rw-r--r-- | po/cs.po | 4 | ||||
-rw-r--r-- | po/de.po | 60 | ||||
-rw-r--r-- | po/es.po | 4 | ||||
-rw-r--r-- | po/fr.po | 8 | ||||
-rw-r--r-- | po/hu.po | 4 | ||||
-rw-r--r-- | po/it.po | 4 | ||||
-rw-r--r-- | po/ja.po | 4 | ||||
-rw-r--r-- | po/pl.po | 4 | ||||
-rw-r--r-- | po/pt.po | 4 | ||||
-rw-r--r-- | po/pt_BR.po | 4 | ||||
-rw-r--r-- | po/ru.po | 4 | ||||
-rw-r--r-- | po/sr.po | 4 | ||||
-rw-r--r-- | po/tr.po | 4 | ||||
-rw-r--r-- | po/weechat.pot | 4 | ||||
-rw-r--r-- | src/core/wee-command.c | 6 | ||||
-rw-r--r-- | src/gui/gui-input.c | 76 | ||||
-rw-r--r-- | src/gui/gui-input.h | 1 |
18 files changed, 167 insertions, 33 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 07b2e27e7..220733fff 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -24,6 +24,7 @@ New features:: * core: render newline characters in chat line messages (issue #1908) * core: don't split on newline characters in printf_date_tags when input_multiline is set (issue #1909) * core: add key @kbd:[l] in cursor mode to quote line, add variable "_chat_focused_line" in function hashtable sent to hook_focus callback (issue #1913, issue #1914) + * core: add option `split_return` in command `/input` (issue #1916) * core: add command `/reset` to reset options to their default values * core: add option `rename` in command `/bar` * core: add relative move of read marker with `/buffer set unread [+/-]N` (issue #1895) @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-04-22 08:03+0200\n" +"POT-Creation-Date: 2023-04-25 22:07+0200\n" "PO-Revision-Date: 2023-03-25 21:13+0100\n" "Last-Translator: Ondřej Súkup <mimi.vx@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -1851,6 +1851,8 @@ msgstr "<action> [<argumenty>]" msgid "" "list of actions:\n" " return: simulate key \"enter\"\n" +" split_return: split input on newlines then simulate key \"enter\" for each " +"line\n" " complete_next: complete word with next completion\n" " complete_previous: complete word with previous completion\n" " search_text_here: search text in buffer at current position\n" @@ -26,7 +26,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-04-22 08:03+0200\n" +"POT-Creation-Date: 2023-04-25 22:07+0200\n" "PO-Revision-Date: 2023-04-22 09:33+0200\n" "Last-Translator: Nils Görs <weechatter@arcor.de>\n" "Language-Team: German - Germany <weechatter@arcor.de>\n" @@ -2273,9 +2273,67 @@ msgstr "Funktionen für die Befehlszeile" msgid "<action> [<arguments>]" msgstr "<action> [<arguments>]" +#, fuzzy +#| msgid "" +#| "list of actions:\n" +#| " return: simulate key \"enter\"\n" +#| " complete_next: complete word with next completion\n" +#| " complete_previous: complete word with previous completion\n" +#| " search_text_here: search text in buffer at current position\n" +#| " search_text: search text in buffer\n" +#| " search_switch_case: switch exact case for search\n" +#| " search_switch_regex: switch search type: string/regular expression\n" +#| " search_switch_where: switch search in messages/prefixes\n" +#| " search_previous: search previous line\n" +#| " search_next: search next line\n" +#| " search_stop_here: stop search at current position\n" +#| " search_stop: stop search\n" +#| " delete_previous_char: delete previous char\n" +#| " delete_next_char: delete next char\n" +#| " delete_previous_word: delete previous word\n" +#| " delete_previous_word_whitespace: delete previous word (until " +#| "whitespace)\n" +#| " delete_next_word: delete next word\n" +#| " delete_beginning_of_line: delete from beginning of line until cursor\n" +#| " delete_beginning_of_input: delete from beginning of input until cursor\n" +#| " delete_end_of_line: delete from cursor until end of line\n" +#| " delete_end_of_input: delete from cursor until end of input\n" +#| " delete_line: delete current line\n" +#| " delete_input: delete entire input\n" +#| " clipboard_paste: paste from the internal clipboard\n" +#| " transpose_chars: transpose two chars\n" +#| " undo: undo last command line action\n" +#| " redo: redo last command line action\n" +#| " move_beginning_of_line: move cursor to beginning of line\n" +#| " move_beginning_of_input: move cursor to beginning of input\n" +#| " move_end_of_line: move cursor to end of line\n" +#| " move_end_of_input: move cursor to end of input\n" +#| " move_previous_char: move cursor to previous char\n" +#| " move_next_char: move cursor to next char\n" +#| " move_previous_word: move cursor to previous word\n" +#| " move_next_word: move cursor to next word\n" +#| " move_previous_line: move cursor to previous line\n" +#| " move_next_line: move cursor to next line\n" +#| " history_previous: recall previous command in current buffer history\n" +#| " history_next: recall next command in current buffer history\n" +#| " history_global_previous: recall previous command in global history\n" +#| " history_global_next: recall next command in global history\n" +#| " grab_key: grab a key (optional argument: delay for end of grab, default " +#| "is 500 milliseconds)\n" +#| " grab_key_command: grab a key with its associated command (optional " +#| "argument: delay for end of grab, default is 500 milliseconds)\n" +#| " grab_mouse: grab mouse event code\n" +#| " grab_mouse_area: grab mouse event code with area\n" +#| " insert: insert text in command line (escaped chars are allowed, see /" +#| "help print)\n" +#| " send: send text to the buffer\n" +#| "\n" +#| "This command is used by key bindings or plugins." msgid "" "list of actions:\n" " return: simulate key \"enter\"\n" +" split_return: split input on newlines then simulate key \"enter\" for each " +"line\n" " complete_next: complete word with next completion\n" " complete_previous: complete word with previous completion\n" " search_text_here: search text in buffer at current position\n" @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-04-22 08:03+0200\n" +"POT-Creation-Date: 2023-04-25 22:07+0200\n" "PO-Revision-Date: 2023-03-25 21:13+0100\n" "Last-Translator: Santiago Forero <santiago@forero.xyz>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -2318,6 +2318,8 @@ msgstr "<acción> [<argumentos>]" msgid "" "list of actions:\n" " return: simulate key \"enter\"\n" +" split_return: split input on newlines then simulate key \"enter\" for each " +"line\n" " complete_next: complete word with next completion\n" " complete_previous: complete word with previous completion\n" " search_text_here: search text in buffer at current position\n" @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-04-22 08:03+0200\n" -"PO-Revision-Date: 2023-04-22 08:04+0200\n" +"POT-Creation-Date: 2023-04-25 22:07+0200\n" +"PO-Revision-Date: 2023-04-25 22:07+0200\n" "Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" "Language: fr\n" @@ -2232,6 +2232,8 @@ msgstr "<action> [<paramètres>]" msgid "" "list of actions:\n" " return: simulate key \"enter\"\n" +" split_return: split input on newlines then simulate key \"enter\" for each " +"line\n" " complete_next: complete word with next completion\n" " complete_previous: complete word with previous completion\n" " search_text_here: search text in buffer at current position\n" @@ -2286,6 +2288,8 @@ msgid "" msgstr "" "liste des actions :\n" " return : simuler la touche \"entrée\"\n" +" split_return : découper la ligne de commande sur les caractères de retour " +"chariot puis simuler la touche \"entrée\" pour chaque ligne\n" " complete_next : compléter le mot avec la complétion suivante\n" " complete_previous : compléter le mot avec la complétion précédente\n" " search_text_here : chercher du texte dans le tampon à la position " @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-04-22 08:03+0200\n" +"POT-Creation-Date: 2023-04-25 22:07+0200\n" "PO-Revision-Date: 2022-10-15 22:51+0200\n" "Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -1718,6 +1718,8 @@ msgstr "fogadó típusa [paraméterek]" msgid "" "list of actions:\n" " return: simulate key \"enter\"\n" +" split_return: split input on newlines then simulate key \"enter\" for each " +"line\n" " complete_next: complete word with next completion\n" " complete_previous: complete word with previous completion\n" " search_text_here: search text in buffer at current position\n" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-04-22 08:03+0200\n" +"POT-Creation-Date: 2023-04-25 22:07+0200\n" "PO-Revision-Date: 2023-03-25 21:13+0100\n" "Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -1913,6 +1913,8 @@ msgstr "<azioni> [<argomenti>]" msgid "" "list of actions:\n" " return: simulate key \"enter\"\n" +" split_return: split input on newlines then simulate key \"enter\" for each " +"line\n" " complete_next: complete word with next completion\n" " complete_previous: complete word with previous completion\n" " search_text_here: search text in buffer at current position\n" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-04-22 08:03+0200\n" +"POT-Creation-Date: 2023-04-25 22:07+0200\n" "PO-Revision-Date: 2023-03-25 21:13+0100\n" "Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n" "Language-Team: Japanese <https://github.com/l/weechat/tree/master/" @@ -2234,6 +2234,8 @@ msgstr "<action> [<arguments>]" msgid "" "list of actions:\n" " return: simulate key \"enter\"\n" +" split_return: split input on newlines then simulate key \"enter\" for each " +"line\n" " complete_next: complete word with next completion\n" " complete_previous: complete word with previous completion\n" " search_text_here: search text in buffer at current position\n" @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-04-22 08:03+0200\n" +"POT-Creation-Date: 2023-04-25 22:07+0200\n" "PO-Revision-Date: 2023-04-13 20:09+0200\n" "Last-Translator: Krzysztof Korościk <soltys@soltys.info>\n" "Language-Team: Polish <kde-i18n-doc@kde.org>\n" @@ -2530,6 +2530,8 @@ msgstr "<akcja> [<argumenty>]" msgid "" "list of actions:\n" " return: simulate key \"enter\"\n" +" split_return: split input on newlines then simulate key \"enter\" for each " +"line\n" " complete_next: complete word with next completion\n" " complete_previous: complete word with previous completion\n" " search_text_here: search text in buffer at current position\n" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-04-22 08:03+0200\n" +"POT-Creation-Date: 2023-04-25 22:07+0200\n" "PO-Revision-Date: 2023-03-25 21:13+0100\n" "Last-Translator: Vasco Almeida <vascomalmeida@sapo.pt>\n" "Language-Team: Portuguese <>\n" @@ -2222,6 +2222,8 @@ msgstr "<ação> [<argumentos>]" msgid "" "list of actions:\n" " return: simulate key \"enter\"\n" +" split_return: split input on newlines then simulate key \"enter\" for each " +"line\n" " complete_next: complete word with next completion\n" " complete_previous: complete word with previous completion\n" " search_text_here: search text in buffer at current position\n" diff --git a/po/pt_BR.po b/po/pt_BR.po index db8cb1328..d59a7294a 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: 2023-04-22 08:03+0200\n" +"POT-Creation-Date: 2023-04-25 22:07+0200\n" "PO-Revision-Date: 2023-03-25 21:13+0100\n" "Last-Translator: Érico Nogueira <ericonr@disroot.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -1987,6 +1987,8 @@ msgstr "<ação> [<argumentos>]" msgid "" "list of actions:\n" " return: simulate key \"enter\"\n" +" split_return: split input on newlines then simulate key \"enter\" for each " +"line\n" " complete_next: complete word with next completion\n" " complete_previous: complete word with previous completion\n" " search_text_here: search text in buffer at current position\n" @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-04-22 08:03+0200\n" +"POT-Creation-Date: 2023-04-25 22:07+0200\n" "PO-Revision-Date: 2023-03-25 21:13+0100\n" "Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -1739,6 +1739,8 @@ msgstr "адресат тип [аргументы]" msgid "" "list of actions:\n" " return: simulate key \"enter\"\n" +" split_return: split input on newlines then simulate key \"enter\" for each " +"line\n" " complete_next: complete word with next completion\n" " complete_previous: complete word with previous completion\n" " search_text_here: search text in buffer at current position\n" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-04-22 08:03+0200\n" +"POT-Creation-Date: 2023-04-25 22:07+0200\n" "PO-Revision-Date: 2023-04-13 20:10+0200\n" "Last-Translator: Ivan Pešić <ivan.pesic@gmail.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -2516,6 +2516,8 @@ msgstr "<акција> [<аргументи>]" msgid "" "list of actions:\n" " return: simulate key \"enter\"\n" +" split_return: split input on newlines then simulate key \"enter\" for each " +"line\n" " complete_next: complete word with next completion\n" " complete_previous: complete word with previous completion\n" " search_text_here: search text in buffer at current position\n" @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-04-23 16:51+0200\n" +"POT-Creation-Date: 2023-04-25 22:07+0200\n" "PO-Revision-Date: 2023-04-23 16:51+0200\n" "Last-Translator: Emir SARI <emir_sari@icloud.com>\n" "Language-Team: weechat-dev <weechat-dev@nongnu.org>\n" @@ -2219,6 +2219,8 @@ msgstr "<eylem> [<argümanlar>]" msgid "" "list of actions:\n" " return: simulate key \"enter\"\n" +" split_return: split input on newlines then simulate key \"enter\" for each " +"line\n" " complete_next: complete word with next completion\n" " complete_previous: complete word with previous completion\n" " search_text_here: search text in buffer at current position\n" diff --git a/po/weechat.pot b/po/weechat.pot index f4c4b029a..6683bebc9 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2023-04-22 08:03+0200\n" +"POT-Creation-Date: 2023-04-25 22:07+0200\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" @@ -1586,6 +1586,8 @@ msgstr "" msgid "" "list of actions:\n" " return: simulate key \"enter\"\n" +" split_return: split input on newlines then simulate key \"enter\" for each " +"line\n" " complete_next: complete word with next completion\n" " complete_previous: complete word with previous completion\n" " search_text_here: search text in buffer at current position\n" diff --git a/src/core/wee-command.c b/src/core/wee-command.c index c28b376d1..8d753774c 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -3456,6 +3456,8 @@ COMMAND_CALLBACK(input) gui_input_clipboard_paste (buffer); else if (string_strcmp (argv[1], "return") == 0) gui_input_return (buffer); + else if (string_strcmp (argv[1], "split_return") == 0) + gui_input_split_return (buffer); else if (string_strcmp (argv[1], "complete_next") == 0) gui_input_complete_next (buffer); else if (string_strcmp (argv[1], "complete_previous") == 0) @@ -8356,6 +8358,8 @@ command_init () N_("<action> [<arguments>]"), N_("list of actions:\n" " return: simulate key \"enter\"\n" + " split_return: split input on newlines then simulate key \"enter\" " + "for each line\n" " complete_next: complete word with next completion\n" " complete_previous: complete word with previous completion\n" " search_text_here: search text in buffer at current position\n" @@ -8411,7 +8415,7 @@ command_init () " send: send text to the buffer\n" "\n" "This command is used by key bindings or plugins."), - "return || " + "return || split_return || " "complete_next || complete_previous || search_text_here || " "search_text || search_switch_case || search_switch_regex || " "search_switch_where || search_previous || search_next || " diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c index ebc38b1be..02fc5cab6 100644 --- a/src/gui/gui-input.c +++ b/src/gui/gui-input.c @@ -317,7 +317,7 @@ gui_input_clipboard_paste (struct t_gui_buffer *buffer) } /* - * Terminates line: + * Sends data to buffer: * - saves text in history * - stops completion * - frees all undos @@ -326,9 +326,26 @@ gui_input_clipboard_paste (struct t_gui_buffer *buffer) */ void +gui_input_send_data_to_buffer (struct t_gui_buffer *buffer, char *data) +{ + gui_history_add (buffer, data); + gui_buffer_undo_free_all (buffer); + buffer->ptr_history = NULL; + gui_history_ptr = NULL; + gui_input_text_changed_modifier_and_signal (buffer, + 0, /* save undo */ + 1); /* stop completion */ + (void) input_data (buffer, data, NULL); +} + +/* + * Sends current input to buffer. + */ + +void gui_input_return (struct t_gui_buffer *buffer) { - char *command; + char *data; if (CONFIG_BOOLEAN(config_look_bare_display_exit_on_input) && gui_window_bare_display) @@ -340,24 +357,49 @@ gui_input_return (struct t_gui_buffer *buffer) && (buffer->input_get_empty || (buffer->input_buffer_size > 0))) { buffer->input_buffer[buffer->input_buffer_size] = '\0'; - command = strdup (buffer->input_buffer); - if (command) + data = strdup (buffer->input_buffer); + if (gui_input_optimize_size (buffer, 0, 0)) + { + buffer->input_buffer[0] = '\0'; + buffer->input_buffer_pos = 0; + buffer->input_buffer_1st_display = 0; + } + if (data) + { + gui_input_send_data_to_buffer (buffer, data); + free (data); + } + } +} + +/* + * Splits input on newlines then sends each line to buffer. + */ + +void +gui_input_split_return (struct t_gui_buffer *buffer) +{ + char **lines; + int i, num_lines; + + if (buffer->input + && (buffer->input_get_empty || (buffer->input_buffer_size > 0))) + { + buffer->input_buffer[buffer->input_buffer_size] = '\0'; + lines = string_split (buffer->input_buffer, "\n", NULL, 0, 0, &num_lines); + if (gui_input_optimize_size (buffer, 0, 0)) + { + buffer->input_buffer[0] = '\0'; + buffer->input_buffer_pos = 0; + buffer->input_buffer_1st_display = 0; + } + if (lines) { - gui_history_add (buffer, buffer->input_buffer); - if (gui_input_optimize_size (buffer, 0, 0)) + for (i = 0; i < num_lines; i++) { - buffer->input_buffer[0] = '\0'; - buffer->input_buffer_pos = 0; - buffer->input_buffer_1st_display = 0; + gui_input_send_data_to_buffer (buffer, lines[i]); } - gui_buffer_undo_free_all (buffer); - buffer->ptr_history = NULL; - gui_history_ptr = NULL; - gui_input_text_changed_modifier_and_signal (buffer, - 0, /* save undo */ - 1); /* stop completion */ - (void) input_data (buffer, command, NULL); - free (command); + string_free_split (lines); } } } diff --git a/src/gui/gui-input.h b/src/gui/gui-input.h index e6d2172c5..a75459f3b 100644 --- a/src/gui/gui-input.h +++ b/src/gui/gui-input.h @@ -39,6 +39,7 @@ extern void gui_input_insert_string (struct t_gui_buffer *buffer, const char *string); extern void gui_input_clipboard_paste (struct t_gui_buffer *buffer); extern void gui_input_return (struct t_gui_buffer *buffer); +extern void gui_input_split_return (struct t_gui_buffer *buffer); extern void gui_input_complete_next (struct t_gui_buffer *buffer); extern void gui_input_complete_previous (struct t_gui_buffer *buffer); extern void gui_input_search_text_here (struct t_gui_buffer *buffer); |