mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 04:46:37 +02:00
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.
This commit is contained in:
@@ -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 <name> <hook> [\"<arguments>\" [\"<conditions>\" "
|
||||
"[\"<regex>\" [\"<command>\" [\"<return_code>\"]]]]]"
|
||||
" || addinput [<hook>]"
|
||||
" || input|output <name>"
|
||||
" || input|output|recreate <name>"
|
||||
" || set <name> <option> <value>"
|
||||
" || rename|copy <name> <new_name>"
|
||||
" || enable|disable|toggle|restart <name>|-all [<name>...]"
|
||||
@@ -897,6 +909,7 @@ trigger_command_init ()
|
||||
" addinput: set input with default arguments to create a trigger\n"
|
||||
" input: set input with the command used to create the trigger\n"
|
||||
" output: send the command to create the trigger on the buffer\n"
|
||||
" recreate: same as input, but the trigger is first deleted\n"
|
||||
" set: set an option in a trigger\n"
|
||||
" option: name of option: name, hook, arguments, conditions, "
|
||||
"regex, command, return_code\n"
|
||||
@@ -949,7 +962,7 @@ trigger_command_init ()
|
||||
"%(trigger_hook_conditions) %(trigger_hook_regex) "
|
||||
"%(trigger_hook_command) %(trigger_hook_rc)"
|
||||
" || addinput %(trigger_hooks)"
|
||||
" || input|output %(trigger_names)"
|
||||
" || input|output|recreate %(trigger_names)"
|
||||
" || set %(trigger_names) %(trigger_options)|name %(trigger_option_value)"
|
||||
" || rename|copy %(trigger_names) %(trigger_names)"
|
||||
" || enable|disable|toggle|restart|del %(trigger_names)|-all "
|
||||
|
||||
Reference in New Issue
Block a user