diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-05-01 21:47:44 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-05-04 21:06:32 +0200 |
commit | 25d7192677f8a415cd9ba94229d86aecb9ca5797 (patch) | |
tree | 06e42e2538b827d1b6e9b2aeb06eb3c9414decc9 /src/plugins | |
parent | bbbe83370f64b22306ab8606a4999c0bd9cb8015 (diff) | |
download | weechat-25d7192677f8a415cd9ba94229d86aecb9ca5797.zip |
api: don't split on newline by default in functions `command` and `command_options` when input_multiline is set to 0
The API functions `command` and `command_options` (when `split_newline` = 0,
which is the default value) don't split on newline and then the first line is
executed and the subsequent lines (after "\n") are ignored.
There are no changes when the input has multiple lines filled by the user: the
split is done and multiple commands are executed (for example if the user is
pasting multiple commands to execute).
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/plugin-api.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/plugins/plugin-api.c b/src/plugins/plugin-api.c index 22ddc5374..2d7aedb8f 100644 --- a/src/plugins/plugin-api.c +++ b/src/plugins/plugin-api.c @@ -395,15 +395,16 @@ plugin_api_command_options (struct t_weechat_plugin *plugin, struct t_hashtable *options) { char *command2, *error; - const char *ptr_commands_allowed, *ptr_delay; + const char *ptr_commands_allowed, *ptr_delay, *ptr_split_newline; long delay; - int rc; + int rc, split_newline; if (!plugin || !command) return WEECHAT_RC_ERROR; ptr_commands_allowed = NULL; delay = 0; + split_newline = 0; if (options) { @@ -416,6 +417,12 @@ plugin_api_command_options (struct t_weechat_plugin *plugin, if (!error || error[0]) delay = 0; } + ptr_split_newline = hashtable_get (options, "split_newline"); + if (ptr_split_newline) + { + split_newline = (string_strcmp (ptr_split_newline, "1") == 0) ? + 1 : 0; + } } command2 = string_iconv_to_internal (plugin->charset, command); @@ -423,6 +430,7 @@ plugin_api_command_options (struct t_weechat_plugin *plugin, rc = input_data_delayed ((buffer) ? buffer : gui_current_window->buffer, (command2) ? command2 : command, ptr_commands_allowed, + split_newline, delay); if (command2) |