From f52770137f066fccbffe1fd833e2bf7ed2432800 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Fri, 14 Feb 2014 15:15:21 +0100 Subject: trigger: add option "recreate" in command /trigger The "recreate" option is the same as "input" but the trigger is first deleted. So this lets you recreate the same trigger and edit some things if needed. --- src/plugins/trigger/trigger-command.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/trigger/trigger-command.c b/src/plugins/trigger/trigger-command.c index b951e3f13..6addfbcfb 100644 --- a/src/plugins/trigger/trigger-command.c +++ b/src/plugins/trigger/trigger-command.c @@ -532,9 +532,15 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc, goto end; } - /* get command to create a trigger (in input or send it to buffer) */ + /* + * get command to create a trigger, and according to option: + * - input: put the command in input + * - output: send the command to the buffer + * - recreate: same as input, but the trigger is first deleted + */ if ((weechat_strcasecmp (argv[1], "input") == 0) - || (weechat_strcasecmp (argv[1], "output") == 0)) + || (weechat_strcasecmp (argv[1], "output") == 0) + || (weechat_strcasecmp (argv[1], "recreate") == 0)) { if (argc < 3) { @@ -561,17 +567,23 @@ trigger_command_trigger (void *data, struct t_gui_buffer *buffer, int argc, weechat_config_string (ptr_trigger->options[TRIGGER_OPTION_REGEX]), weechat_config_string (ptr_trigger->options[TRIGGER_OPTION_COMMAND]), weechat_config_string (ptr_trigger->options[TRIGGER_OPTION_RETURN_CODE])); - if (weechat_strcasecmp (argv[1], "input") == 0) + if (weechat_strcasecmp (argv[1], "recreate") == 0) + { + trigger_free (ptr_trigger); + weechat_printf_tags (NULL, "no_trigger", + _("Trigger \"%s\" removed"), argv[2]); + } + if (weechat_strcasecmp (argv[1], "output") == 0) + { + weechat_command (buffer, input); + } + else { weechat_buffer_set (buffer, "input", input + 1); snprintf (str_pos, sizeof (str_pos), "%d", weechat_utf8_strlen (input + 1)); weechat_buffer_set (buffer, "input_pos", str_pos); } - else - { - weechat_command (buffer, input); - } goto end; } @@ -860,7 +872,7 @@ trigger_command_init () " || add [\"\" [\"\" " "[\"\" [\"\" [\"\"]]]]]" " || addinput []" - " || input|output " + " || input|output|recreate " " || set