diff options
-rw-r--r-- | doc/en/weechat_user.en.adoc | 13 | ||||
-rw-r--r-- | src/plugins/trigger/trigger-callback.h | 6 | ||||
-rw-r--r-- | src/plugins/trigger/trigger-command.c | 40 | ||||
-rw-r--r-- | src/plugins/trigger/trigger-completion.c | 21 | ||||
-rw-r--r-- | src/plugins/trigger/trigger-config.c | 12 | ||||
-rw-r--r-- | src/plugins/trigger/trigger-config.h | 2 | ||||
-rw-r--r-- | src/plugins/trigger/trigger.c | 36 | ||||
-rw-r--r-- | src/plugins/trigger/trigger.h | 20 |
8 files changed, 75 insertions, 75 deletions
diff --git a/doc/en/weechat_user.en.adoc b/doc/en/weechat_user.en.adoc index 878326d3f..1637803ca 100644 --- a/doc/en/weechat_user.en.adoc +++ b/doc/en/weechat_user.en.adoc @@ -2986,10 +2986,9 @@ A trigger has the following options (names are The return code of callback (default is `ok`, which should be used in almost all triggers, the other values are rarely used). -| once_action | `none`, `disable`, `delete` | - Action to take with the trigger after the trigger executes once (default is - `none` which should be used in almost all triggers, the other values are - rarely used). +| post_action | `none`, `disable`, `delete` | + Action to take on the trigger after execution (default is `none` which should + be used in almost all triggers, the other values are rarely used). |=== For example, the default _beep_ trigger has following options: @@ -3002,7 +3001,7 @@ trigger.trigger.beep.conditions = "${tg_highlight} || ${tg_msg_pv}" trigger.trigger.beep.regex = "" trigger.trigger.beep.command = "/print -beep" trigger.trigger.beep.return_code = ok -trigger.trigger.beep.once_action = none +trigger.trigger.beep.post_action = none ---- [[trigger_execution]] @@ -3014,8 +3013,8 @@ order, if triggers are globally enabled and if the trigger itself is enabled: . check trigger conditions: if false, exit . replace text in trigger using regular expression(s) . execute command(s) -. exit with a return code (except for hooks _modifier_ and _focus_). -. perform once action (when not `none`) +. exit with a return code (except for hooks _modifier_ and _focus_) +. perform post action (if different from `none`). [[trigger_hook_arguments]] ==== Hook arguments diff --git a/src/plugins/trigger/trigger-callback.h b/src/plugins/trigger/trigger-callback.h index 44d6c3694..e6bda1730 100644 --- a/src/plugins/trigger/trigger-callback.h +++ b/src/plugins/trigger/trigger-callback.h @@ -64,14 +64,14 @@ weechat_hashtable_free (extra_vars); \ trigger->hook_running = 0; \ switch (weechat_config_integer ( \ - trigger->options[TRIGGER_OPTION_ONCE_ACTION])) \ + trigger->options[TRIGGER_OPTION_POST_ACTION])) \ { \ - case TRIGGER_ONCE_DISABLE: \ + case TRIGGER_POST_ACTION_DISABLE: \ weechat_config_option_set ( \ trigger->options[TRIGGER_OPTION_ENABLED], \ "off", 1); \ break; \ - case TRIGGER_ONCE_DELETE: \ + case TRIGGER_POST_ACTION_DELETE: \ trigger_free (trigger); \ break; \ default: \ diff --git a/src/plugins/trigger/trigger-command.c b/src/plugins/trigger/trigger-command.c index b50d0665a..b633f799a 100644 --- a/src/plugins/trigger/trigger-command.c +++ b/src/plugins/trigger/trigger-command.c @@ -59,11 +59,11 @@ trigger_command_display_trigger_internal (const char *name, int commands_count, char **commands, int return_code, - int once_action, + int post_action, int verbose) { - char str_conditions[64], str_regex[64], str_command[64], str_rc[64], str_once[64]; - char spaces[256]; + char str_conditions[64], str_regex[64], str_command[64], str_rc[64]; + char str_post_action[64], spaces[256]; int i, length; if (verbose >= 1) @@ -158,15 +158,15 @@ trigger_command_display_trigger_internal (const char *name, weechat_color ("reset"), trigger_return_code_string[return_code]); } - if ((once_action >= 0) && (once_action != TRIGGER_ONCE_NONE)) + if ((post_action >= 0) && (post_action != TRIGGER_POST_ACTION_NONE)) { weechat_printf_date_tags ( NULL, 0, "no_trigger", "%s %s=1 %s%s", spaces, - weechat_color (weechat_config_string (trigger_config_color_flag_once_action)), + weechat_color (weechat_config_string (trigger_config_color_flag_post_action)), weechat_color ("reset"), - trigger_once_action_string[once_action]); + trigger_post_action_string[post_action]); } } else @@ -175,7 +175,7 @@ trigger_command_display_trigger_internal (const char *name, str_regex[0] = '\0'; str_command[0] = '\0'; str_rc[0] = '\0'; - str_once[0] = '\0'; + str_post_action[0] = '\0'; if (conditions && conditions[0]) { snprintf (str_conditions, sizeof (str_conditions), @@ -206,11 +206,11 @@ trigger_command_display_trigger_internal (const char *name, weechat_color (weechat_config_string (trigger_config_color_flag_return_code)), weechat_color ("reset")); } - if ((once_action >= 0) && (once_action != TRIGGER_ONCE_NONE)) + if ((post_action >= 0) && (post_action != TRIGGER_POST_ACTION_NONE)) { - snprintf (str_once, sizeof (str_once), + snprintf (str_post_action, sizeof (str_post_action), " %s=1%s", - weechat_color (weechat_config_string (trigger_config_color_flag_once_action)), + weechat_color (weechat_config_string (trigger_config_color_flag_post_action)), weechat_color ("reset")); } weechat_printf_date_tags ( @@ -233,7 +233,7 @@ trigger_command_display_trigger_internal (const char *name, str_regex, str_command, str_rc, - str_once); + str_post_action); } } @@ -258,7 +258,7 @@ trigger_command_display_trigger (struct t_trigger *trigger, int verbose) trigger->commands_count, trigger->commands, weechat_config_integer (trigger->options[TRIGGER_OPTION_RETURN_CODE]), - weechat_config_integer (trigger->options[TRIGGER_OPTION_ONCE_ACTION]), + weechat_config_integer (trigger->options[TRIGGER_OPTION_POST_ACTION]), verbose); } @@ -333,7 +333,7 @@ trigger_command_list_default (int verbose) commands_count, commands, trigger_search_return_code (trigger_config_default_list[i][7]), - trigger_search_once_action (trigger_config_default_list[i][8]), + trigger_search_post_action (trigger_config_default_list[i][8]), verbose); } @@ -593,10 +593,10 @@ trigger_command_trigger (const void *pointer, void *data, goto end; } if ((sargc > 7) && sargv[7][0] - && (trigger_search_once_action (sargv[7]) < 0)) + && (trigger_search_post_action (sargv[7]) < 0)) { weechat_printf_date_tags (NULL, 0, "no_trigger", - _("%s%s: invalid once action \"%s\""), + _("%s%s: invalid post action \"%s\""), weechat_prefix ("error"), TRIGGER_PLUGIN_NAME, sargv[7]); @@ -648,7 +648,7 @@ trigger_command_trigger (const void *pointer, void *data, (sargc > 4) ? sargv[4] : "", /* regex */ (sargc > 5) ? sargv[5] : "", /* command */ (sargc > 6) ? sargv[6] : "", /* return code */ - (sargc > 7) ? sargv[7] : ""); /* once action */ + (sargc > 7) ? sargv[7] : ""); /* post action */ if (ptr_trigger) { weechat_printf_date_tags ( @@ -1050,7 +1050,7 @@ trigger_command_trigger (const void *pointer, void *data, trigger_config_default_list[j][5], /* regex */ trigger_config_default_list[j][6], /* command */ trigger_config_default_list[j][7], /* return code */ - trigger_config_default_list[j][8]); /* once action */ + trigger_config_default_list[j][8]); /* post action */ weechat_printf_date_tags (NULL, 0, "no_trigger", _("Trigger \"%s\" restored"), argv[i]); @@ -1135,7 +1135,7 @@ trigger_command_init () N_("list|listfull|listdefault" " || add|addoff|addreplace <name> <hook> [\"<arguments>\" " "[\"<conditions>\" [\"<regex>\" [\"<command>\" " - "[\"<return_code>\" [\"<once_action>\"]]]]]]" + "[\"<return_code>\" [\"<post_action>\"]]]]]]" " || addinput [<hook>]" " || input|output|recreate <name>" " || set <name> <option> <value>" @@ -1174,7 +1174,7 @@ trigger_command_init () " command: command to execute (many commands can be separated by " "\";\"\n" "return_code: return code in callback (ok (default), ok_eat, error)\n" - "once_action: action to take after execution (none (default), " + "post_action: action to take after execution (none (default), " "disable, delete)\n" " addinput: set input with default arguments to create a trigger\n" " input: set input with the command used to create the trigger\n" @@ -1237,7 +1237,7 @@ trigger_command_init () " || add|addoff|addreplace %(trigger_names) %(trigger_hooks) " "%(trigger_hook_arguments) %(trigger_hook_conditions) " "%(trigger_hook_regex) %(trigger_hook_command) %(trigger_hook_rc) " - "%(trigger_once)" + "%(trigger_post_action)" " || addinput %(trigger_hooks)" " || input|output|recreate %(trigger_names)" " || set %(trigger_names) %(trigger_options)|name %(trigger_option_value)" diff --git a/src/plugins/trigger/trigger-completion.c b/src/plugins/trigger/trigger-completion.c index 4ea5d779d..34902e2d2 100644 --- a/src/plugins/trigger/trigger-completion.c +++ b/src/plugins/trigger/trigger-completion.c @@ -434,14 +434,14 @@ trigger_completion_hook_rc_cb (const void *pointer, void *data, } /* - * Adds default once actions to completion list. + * Adds default post actions to completion list. */ int -trigger_completion_once_cb (const void *pointer, void *data, - const char *completion_item, - struct t_gui_buffer *buffer, - struct t_gui_completion *completion) +trigger_completion_post_action_cb (const void *pointer, void *data, + const char *completion_item, + struct t_gui_buffer *buffer, + struct t_gui_completion *completion) { int i; @@ -451,10 +451,11 @@ trigger_completion_once_cb (const void *pointer, void *data, (void) completion_item; (void) buffer; - for (i = 0; i < TRIGGER_NUM_ONCE_ACTIONS; i++) + for (i = 0; i < TRIGGER_NUM_POST_ACTIONS; i++) { weechat_hook_completion_list_add (completion, - trigger_once_action_string[i], 0, WEECHAT_LIST_POS_END); + trigger_post_action_string[i], + 0, WEECHAT_LIST_POS_END); } return WEECHAT_RC_OK; @@ -501,7 +502,7 @@ trigger_completion_init () weechat_hook_completion ("trigger_hook_rc", N_("default return codes for hook callback"), &trigger_completion_hook_rc_cb, NULL, NULL); - weechat_hook_completion ("trigger_once", - N_("trigger once actions"), - &trigger_completion_once_cb, NULL, NULL); + weechat_hook_completion ("trigger_post_action", + N_("trigger post actions"), + &trigger_completion_post_action_cb, NULL, NULL); } diff --git a/src/plugins/trigger/trigger-config.c b/src/plugins/trigger/trigger-config.c index b070f6705..b610a0f48 100644 --- a/src/plugins/trigger/trigger-config.c +++ b/src/plugins/trigger/trigger-config.c @@ -42,7 +42,7 @@ struct t_config_option *trigger_config_color_flag_command; struct t_config_option *trigger_config_color_flag_conditions; struct t_config_option *trigger_config_color_flag_regex; struct t_config_option *trigger_config_color_flag_return_code; -struct t_config_option *trigger_config_color_flag_once_action; +struct t_config_option *trigger_config_color_flag_post_action; struct t_config_option *trigger_config_color_regex; struct t_config_option *trigger_config_color_replace; struct t_config_option *trigger_config_color_trigger; @@ -366,11 +366,11 @@ trigger_config_create_trigger_option (const char *trigger_name, int index_option "ok|ok_eat|error", 0, 0, value, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); break; - case TRIGGER_OPTION_ONCE_ACTION: + case TRIGGER_OPTION_POST_ACTION: ptr_option = weechat_config_new_option ( trigger_config_file, trigger_config_section_trigger, option_name, "integer", - N_("action to take after execution"), + N_("action to take on the trigger after execution"), "none|disable|delete", 0, 0, value, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); break; @@ -683,10 +683,10 @@ trigger_config_init () N_("text color for return code flag (in /trigger list)"), NULL, 0, 0, "lightmagenta", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - trigger_config_color_flag_once_action = weechat_config_new_option ( + trigger_config_color_flag_post_action = weechat_config_new_option ( trigger_config_file, ptr_section, - "flag_once_action", "color", - N_("text color for once action flag (in /trigger list)"), + "flag_post_action", "color", + N_("text color for post action flag (in /trigger list)"), NULL, 0, 0, "lightblue", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); trigger_config_color_regex = weechat_config_new_option ( diff --git a/src/plugins/trigger/trigger-config.h b/src/plugins/trigger/trigger-config.h index 64a41129b..54c18e361 100644 --- a/src/plugins/trigger/trigger-config.h +++ b/src/plugins/trigger/trigger-config.h @@ -33,7 +33,7 @@ extern struct t_config_option *trigger_config_color_flag_command; extern struct t_config_option *trigger_config_color_flag_conditions; extern struct t_config_option *trigger_config_color_flag_regex; extern struct t_config_option *trigger_config_color_flag_return_code; -extern struct t_config_option *trigger_config_color_flag_once_action; +extern struct t_config_option *trigger_config_color_flag_post_action; extern struct t_config_option *trigger_config_color_regex; extern struct t_config_option *trigger_config_color_replace; extern struct t_config_option *trigger_config_color_trigger; diff --git a/src/plugins/trigger/trigger.c b/src/plugins/trigger/trigger.c index bfde186db..b4a121fd2 100644 --- a/src/plugins/trigger/trigger.c +++ b/src/plugins/trigger/trigger.c @@ -44,7 +44,7 @@ struct t_weechat_plugin *weechat_trigger_plugin = NULL; char *trigger_option_string[TRIGGER_NUM_OPTIONS] = { "enabled", "hook", "arguments", "conditions", "regex", "command", - "return_code", "once_action" }; + "return_code", "post_action" }; char *trigger_option_default[TRIGGER_NUM_OPTIONS] = { "on", "signal", "", "", "", "", "ok", "none" }; @@ -69,7 +69,7 @@ char *trigger_return_code_string[TRIGGER_NUM_RETURN_CODES] = int trigger_return_code[TRIGGER_NUM_RETURN_CODES] = { WEECHAT_RC_OK, WEECHAT_RC_OK_EAT, WEECHAT_RC_ERROR }; -char *trigger_once_action_string[TRIGGER_NUM_ONCE_ACTIONS] = +char *trigger_post_action_string[TRIGGER_NUM_POST_ACTIONS] = { "none", "disable", "delete" }; struct t_trigger *triggers = NULL; /* first trigger */ @@ -149,23 +149,23 @@ trigger_search_return_code (const char *return_code) } /* - * Searches for trigger once action. + * Searches for trigger post action. * - * Returns index of once action in enum t_trigger_once_action, -1 if not found. + * Returns index of post action in enum t_trigger_post_action, -1 if not found. */ int -trigger_search_once_action (const char *once_action) +trigger_search_post_action (const char *post_action) { int i; - for (i = 0; i < TRIGGER_NUM_ONCE_ACTIONS; i++) + for (i = 0; i < TRIGGER_NUM_POST_ACTIONS; i++) { - if (weechat_strcasecmp (trigger_once_action_string[i], once_action) == 0) + if (weechat_strcasecmp (trigger_post_action_string[i], post_action) == 0) return i; } - /* once action not found */ + /* post action not found */ return -1; } @@ -897,7 +897,7 @@ struct t_trigger * trigger_new (const char *name, const char *enabled, const char *hook, const char *arguments, const char *conditions, const char *regex, const char *command, const char *return_code, - const char *once_action) + const char *post_action) { struct t_config_option *option[TRIGGER_NUM_OPTIONS]; const char *value[TRIGGER_NUM_OPTIONS]; @@ -915,9 +915,9 @@ trigger_new (const char *name, const char *enabled, const char *hook, return NULL; } - /* look for once action */ - if (once_action && once_action[0] - && (trigger_search_once_action (once_action) < 0)) + /* look for post action */ + if (post_action && post_action[0] + && (trigger_search_post_action (post_action) < 0)) { return NULL; } @@ -929,7 +929,7 @@ trigger_new (const char *name, const char *enabled, const char *hook, value[TRIGGER_OPTION_REGEX] = regex; value[TRIGGER_OPTION_COMMAND] = command; value[TRIGGER_OPTION_RETURN_CODE] = return_code; - value[TRIGGER_OPTION_ONCE_ACTION] = once_action; + value[TRIGGER_OPTION_POST_ACTION] = post_action; for (i = 0; i < TRIGGER_NUM_OPTIONS; i++) { @@ -967,7 +967,7 @@ trigger_create_default () trigger_config_default_list[i][5], /* regex */ trigger_config_default_list[i][6], /* command */ trigger_config_default_list[i][7], /* return code */ - trigger_config_default_list[i][8]); /* once action */ + trigger_config_default_list[i][8]); /* post action */ } } @@ -1052,7 +1052,7 @@ trigger_copy (struct t_trigger *trigger, const char *name) weechat_config_string (trigger->options[TRIGGER_OPTION_REGEX]), weechat_config_string (trigger->options[TRIGGER_OPTION_COMMAND]), weechat_config_string (trigger->options[TRIGGER_OPTION_RETURN_CODE]), - weechat_config_string (trigger->options[TRIGGER_OPTION_ONCE_ACTION])); + weechat_config_string (trigger->options[TRIGGER_OPTION_POST_ACTION])); } /* @@ -1140,9 +1140,9 @@ trigger_print_log () weechat_log_printf (" return_code . . . . . . : %d ('%s')", weechat_config_integer (ptr_trigger->options[TRIGGER_OPTION_RETURN_CODE]), trigger_return_code_string[weechat_config_integer (ptr_trigger->options[TRIGGER_OPTION_RETURN_CODE])]); - weechat_log_printf (" once_action . . . . . . : %d ('%s')", - weechat_config_integer (ptr_trigger->options[TRIGGER_OPTION_ONCE_ACTION]), - trigger_once_action_string[weechat_config_integer (ptr_trigger->options[TRIGGER_OPTION_ONCE_ACTION])]); + weechat_log_printf (" post_action . . . . . . : %d ('%s')", + weechat_config_integer (ptr_trigger->options[TRIGGER_OPTION_POST_ACTION]), + trigger_post_action_string[weechat_config_integer (ptr_trigger->options[TRIGGER_OPTION_POST_ACTION])]); weechat_log_printf (" hooks_count . . . . . . : %d", ptr_trigger->hooks_count); weechat_log_printf (" hooks . . . . . . . . . : 0x%lx", ptr_trigger->hooks); for (i = 0; i < ptr_trigger->hooks_count; i++) diff --git a/src/plugins/trigger/trigger.h b/src/plugins/trigger/trigger.h index 2d0f0228c..b780dd2de 100644 --- a/src/plugins/trigger/trigger.h +++ b/src/plugins/trigger/trigger.h @@ -38,7 +38,7 @@ enum t_trigger_option TRIGGER_OPTION_REGEX, /* replace text with 1 or more regex */ TRIGGER_OPTION_COMMAND, /* command run if conditions are OK */ TRIGGER_OPTION_RETURN_CODE, /* return code for hook callback */ - TRIGGER_OPTION_ONCE_ACTION, /* action to take after execution */ + TRIGGER_OPTION_POST_ACTION, /* action to take after execution */ /* number of trigger options */ TRIGGER_NUM_OPTIONS, }; @@ -67,13 +67,13 @@ enum t_trigger_return_code TRIGGER_NUM_RETURN_CODES, }; -enum t_trigger_once_action +enum t_trigger_post_action { - TRIGGER_ONCE_NONE = 0, - TRIGGER_ONCE_DISABLE, - TRIGGER_ONCE_DELETE, - /* number of once actions */ - TRIGGER_NUM_ONCE_ACTIONS, + TRIGGER_POST_ACTION_NONE = 0, + TRIGGER_POST_ACTION_DISABLE, + TRIGGER_POST_ACTION_DELETE, + /* number of post actions */ + TRIGGER_NUM_POST_ACTIONS, }; struct t_trigger_regex @@ -124,7 +124,7 @@ extern char *trigger_hook_default_rc[]; extern char *trigger_hook_regex_default_var[]; extern char *trigger_return_code_string[]; extern int trigger_return_code[]; -extern char *trigger_once_action_string[]; +extern char *trigger_post_action_string[]; extern struct t_trigger *triggers; extern struct t_trigger *last_trigger; extern int triggers_count; @@ -135,7 +135,7 @@ extern int trigger_enabled; extern int trigger_search_option (const char *option_name); extern int trigger_search_hook_type (const char *type); extern int trigger_search_return_code (const char *return_code); -extern int trigger_search_once_action (const char *once_action); +extern int trigger_search_post_action (const char *post_action); extern struct t_trigger *trigger_search (const char *name); extern struct t_trigger *trigger_search_with_option (struct t_config_option *option); extern void trigger_regex_free (int *regex_count, @@ -162,7 +162,7 @@ extern struct t_trigger *trigger_new (const char *name, const char *replace, const char *command, const char *return_code, - const char *once_action); + const char *post_action); extern void trigger_create_default (); extern int trigger_rename (struct t_trigger *trigger, const char *name); extern struct t_trigger *trigger_copy (struct t_trigger *trigger, |