diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2014-02-09 17:01:36 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2014-02-09 17:01:36 +0100 |
commit | 75e1c5320e0b286fb842f5e1174b60737400c06b (patch) | |
tree | c5af7a25395d6465f51651b1fafee26cca2a6dc6 /src | |
parent | 6ab17dfec19b9e8f164eaa64a070dfc1f0d15f14 (diff) | |
download | weechat-75e1c5320e0b286fb842f5e1174b60737400c06b.zip |
trigger: add options trigger.color.flag_{command|conditions|regex|return_code}
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/trigger/trigger-command.c | 67 | ||||
-rw-r--r-- | src/plugins/trigger/trigger-config.c | 28 | ||||
-rw-r--r-- | src/plugins/trigger/trigger-config.h | 4 |
3 files changed, 87 insertions, 12 deletions
diff --git a/src/plugins/trigger/trigger-command.c b/src/plugins/trigger/trigger-command.c index 16798d142..48b7e708a 100644 --- a/src/plugins/trigger/trigger-command.c +++ b/src/plugins/trigger/trigger-command.c @@ -40,6 +40,7 @@ trigger_command_display_trigger (const char *name, int enabled, const char *hook int commands_count, char **commands, int return_code, int full) { + char str_conditions[64], str_regex[64], str_command[64], str_rc[64]; char spaces[256]; int i, length; @@ -47,7 +48,7 @@ trigger_command_display_trigger (const char *name, int enabled, const char *hook { weechat_printf_tags ( NULL, "no_trigger", - " %s%s%s: %s%s(%s%s%s)", + " %s%s%s: %s%s%s%s%s%s%s", (enabled) ? weechat_color (weechat_config_string (trigger_config_color_trigger)) : weechat_color (weechat_config_string (trigger_config_color_trigger_disabled)), @@ -55,9 +56,11 @@ trigger_command_display_trigger (const char *name, int enabled, const char *hook weechat_color ("reset"), hook, weechat_color ("chat_delimiters"), + (arguments && arguments[0]) ? "(" : "", weechat_color ("reset"), arguments, - weechat_color ("chat_delimiters")); + weechat_color ("chat_delimiters"), + (arguments && arguments[0]) ? ")" : ""); length = weechat_strlen_screen (name) + 3; if (length >= (int)sizeof (spaces)) length = sizeof (spaces) - 1; @@ -66,8 +69,9 @@ trigger_command_display_trigger (const char *name, int enabled, const char *hook if (conditions && conditions[0]) { weechat_printf_tags (NULL, "no_trigger", - "%s =? %s\"%s%s%s\"", + "%s %s=? %s\"%s%s%s\"", spaces, + weechat_color (weechat_config_string (trigger_config_color_flag_conditions)), weechat_color ("chat_delimiters"), weechat_color ("reset"), conditions, @@ -76,9 +80,10 @@ trigger_command_display_trigger (const char *name, int enabled, const char *hook for (i = 0; i < regex_count; i++) { weechat_printf_tags (NULL, "no_trigger", - "%s %d~ %s\"%s%s%s\" --> " + "%s %s~%d %s\"%s%s%s\" --> " "\"%s%s%s\"%s%s%s%s", spaces, + weechat_color (weechat_config_string (trigger_config_color_flag_regex)), i + 1, weechat_color ("chat_delimiters"), weechat_color (weechat_config_string (trigger_config_color_regex)), @@ -97,8 +102,9 @@ trigger_command_display_trigger (const char *name, int enabled, const char *hook for (i = 0; commands[i]; i++) { weechat_printf_tags (NULL, "no_trigger", - "%s %d> %s\"%s%s%s\"", + "%s %s/%d %s\"%s%s%s\"", spaces, + weechat_color (weechat_config_string (trigger_config_color_flag_command)), i + 1, weechat_color ("chat_delimiters"), weechat_color ("reset"), @@ -109,16 +115,52 @@ trigger_command_display_trigger (const char *name, int enabled, const char *hook if ((return_code >= 0) && (return_code != TRIGGER_RC_OK)) { weechat_printf_tags (NULL, "no_trigger", - "%s $: %s", + "%s %s=> %s%s", spaces, + weechat_color (weechat_config_string (trigger_config_color_flag_return_code)), + weechat_color ("reset"), trigger_return_code_string[return_code]); } } else { + str_conditions[0] ='\0'; + str_regex[0] = '\0'; + str_command[0] = '\0'; + str_rc[0] = '\0'; + if (conditions && conditions[0]) + { + snprintf (str_conditions, sizeof (str_conditions), + " %s=?%s", + weechat_color (weechat_config_string (trigger_config_color_flag_conditions)), + weechat_color ("reset")); + } + if (regex_count > 0) + { + snprintf (str_regex, sizeof (str_regex), + " %s~%d%s", + weechat_color (weechat_config_string (trigger_config_color_flag_regex)), + regex_count, + weechat_color ("reset")); + } + if (commands_count > 0) + { + snprintf (str_command, sizeof (str_command), + " %s/%d%s", + weechat_color (weechat_config_string (trigger_config_color_flag_command)), + commands_count, + weechat_color ("reset")); + } + if ((return_code >= 0) && (return_code != TRIGGER_RC_OK)) + { + snprintf (str_rc, sizeof (str_rc), + " %s=>%s", + weechat_color (weechat_config_string (trigger_config_color_flag_return_code)), + weechat_color ("reset")); + } weechat_printf_tags ( NULL, "no_trigger", - " %s%s%s: %s%s(%s%s%s)%s (%s%s%d regex, %d %s)", + " %s%s%s: %s%s%s%s%s%s%s%s%s%s%s%s", (enabled) ? weechat_color (weechat_config_string (trigger_config_color_trigger)) : weechat_color (weechat_config_string (trigger_config_color_trigger_disabled)), @@ -126,15 +168,16 @@ trigger_command_display_trigger (const char *name, int enabled, const char *hook weechat_color ("reset"), hook, weechat_color ("chat_delimiters"), + (arguments && arguments[0]) ? "(" : "", weechat_color ("reset"), arguments, weechat_color ("chat_delimiters"), + (arguments && arguments[0]) ? ")" : "", weechat_color ("reset"), - (conditions && conditions[0]) ? _("conditions") : "", - (conditions && conditions[0]) ? ", " : "", - regex_count, - commands_count, - NG_("command", "commands", commands_count)); + str_conditions, + str_regex, + str_command, + str_rc); } } diff --git a/src/plugins/trigger/trigger-config.c b/src/plugins/trigger/trigger-config.c index 7c7215019..556d1d76a 100644 --- a/src/plugins/trigger/trigger-config.c +++ b/src/plugins/trigger/trigger-config.c @@ -37,6 +37,10 @@ struct t_config_option *trigger_config_look_test; /* trigger config, color section */ +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_regex; struct t_config_option *trigger_config_color_replace; struct t_config_option *trigger_config_color_trigger; @@ -560,6 +564,30 @@ trigger_config_init () return 0; } + trigger_config_color_flag_command = weechat_config_new_option ( + trigger_config_file, ptr_section, + "flag_command", "color", + N_("text color for command flag (in /trigger list)"), + NULL, 0, 0, "lightgreen", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL); + trigger_config_color_flag_conditions = weechat_config_new_option ( + trigger_config_file, ptr_section, + "flag_conditions", "color", + N_("text color for conditions flag (in /trigger list)"), + NULL, 0, 0, "yellow", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL); + trigger_config_color_flag_regex = weechat_config_new_option ( + trigger_config_file, ptr_section, + "flag_regex", "color", + N_("text color for regex flag (in /trigger list)"), + NULL, 0, 0, "lightcyan", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL); + trigger_config_color_flag_return_code = weechat_config_new_option ( + trigger_config_file, ptr_section, + "flag_return_code", "color", + N_("text color for return code flag (in /trigger list)"), + NULL, 0, 0, "lightmagenta", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL); trigger_config_color_regex = weechat_config_new_option ( trigger_config_file, ptr_section, "regex", "color", diff --git a/src/plugins/trigger/trigger-config.h b/src/plugins/trigger/trigger-config.h index 19993ad2e..34550f82e 100644 --- a/src/plugins/trigger/trigger-config.h +++ b/src/plugins/trigger/trigger-config.h @@ -26,6 +26,10 @@ extern struct t_config_file *trigger_config_file; extern struct t_config_section *trigger_config_section_trigger; +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_regex; extern struct t_config_option *trigger_config_color_replace; extern struct t_config_option *trigger_config_color_trigger; |