diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2014-03-16 09:52:44 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2014-03-16 09:52:44 +0100 |
commit | fcf5e84fa48cf96847f5078326fa1f3761b25988 (patch) | |
tree | 7ce47fd344245f8fdb37e149f4f9872b99b1d380 /src/plugins/exec | |
parent | ffba715ea18481372305c23b94938f08a7c04785 (diff) | |
download | weechat-fcf5e84fa48cf96847f5078326fa1f3761b25988.zip |
exec: add values "irc" and "weechat" for option "-color", replace "decode" by "auto"
Diffstat (limited to 'src/plugins/exec')
-rw-r--r-- | src/plugins/exec/exec-command.c | 17 | ||||
-rw-r--r-- | src/plugins/exec/exec.c | 31 | ||||
-rw-r--r-- | src/plugins/exec/exec.h | 4 |
3 files changed, 38 insertions, 14 deletions
diff --git a/src/plugins/exec/exec-command.c b/src/plugins/exec/exec-command.c index 4cfc94fe0..04472db7f 100644 --- a/src/plugins/exec/exec-command.c +++ b/src/plugins/exec/exec-command.c @@ -391,7 +391,7 @@ exec_command_run (struct t_gui_buffer *buffer, cmd_options.new_buffer = 0; cmd_options.switch_to_buffer = 1; cmd_options.line_numbers = -1; - cmd_options.color = EXEC_COLOR_DECODE; + cmd_options.color = EXEC_COLOR_AUTO; cmd_options.display_rc = 1; cmd_options.ptr_command_name = NULL; cmd_options.pipe_command = NULL; @@ -752,9 +752,10 @@ exec_command_init () N_("execute external commands"), N_("-list" " || [-sh|-nosh] [-bg|-nobg] [-stdin|-nostdin] [-buffer <name>] " - "[-l|-o|-n] |-sw|-nosw] [-ln|-noln] [-color off|decode|strip] " - "[-rc|-norc] [-timeout <timeout>] [-name <name>] " - "[-pipe <command>] [-hsignal <name>] <command>" + "[-l|-o|-n] |-sw|-nosw] [-ln|-noln] " + "[-color ansi|auto|irc|weechat|strip] [-rc|-norc] " + "[-timeout <timeout>] [-name <name>] [-pipe <command>] " + "[-hsignal <name>] <command>" " || -in <id> <text>" " || -inclose <id> [<text>]" " || -signal <id> <signal>" @@ -786,9 +787,11 @@ exec_command_init () " -ln: display line numbers (default in new buffer only)\n" " -noln: don't display line numbers\n" " -color: action on ANSI colors in output:\n" - " ansi: keep ANSI codes as-is\n" - " decode: convert ANSI colors to WeeChat/IRC (default)\n" - " strip: remove ANSI colors\n" + " ansi: keep ANSI codes as-is\n" + " auto: convert ANSI colors to WeeChat/IRC (default)\n" + " irc: convert ANSI colors to IRC colors\n" + " weechat: convert ANSI colors to WeeChat colors\n" + " strip: remove ANSI colors\n" " -rc: display return code (default)\n" " -norc: don't display return code\n" "-timeout: set a timeout for the command (in seconds)\n" diff --git a/src/plugins/exec/exec.c b/src/plugins/exec/exec.c index 9b56fcf5c..c10f8e7c6 100644 --- a/src/plugins/exec/exec.c +++ b/src/plugins/exec/exec.c @@ -45,7 +45,7 @@ struct t_exec_cmd *last_exec_cmd = NULL; /* last executed command */ int exec_cmds_count = 0; /* number of executed commands */ char *exec_color_string[EXEC_NUM_COLORS] = -{ "ansi", "decode", "strip" }; +{ "ansi", "auto", "irc", "weechat", "strip" }; /* @@ -225,16 +225,35 @@ exec_concat_output (int *size, char **output, const char *text) char * exec_decode_color (struct t_exec_cmd *exec_cmd, const char *string) { + int irc_color, keep_colors; + if (!string) return NULL; - if (exec_cmd->color == EXEC_COLOR_ANSI) - return strdup (string); + irc_color = 0; + keep_colors = 1; + switch (exec_cmd->color) + { + case EXEC_COLOR_ANSI: + return strdup (string); + break; + case EXEC_COLOR_AUTO: + irc_color = (exec_cmd->output_to_buffer || exec_cmd->pipe_command); + break; + case EXEC_COLOR_IRC: + irc_color = 1; + break; + case EXEC_COLOR_WEECHAT: + irc_color = 0; + break; + case EXEC_COLOR_STRIP: + keep_colors = 0; + break; + } return weechat_hook_modifier_exec ( - (exec_cmd->output_to_buffer || exec_cmd->pipe_command) ? - "irc_color_decode_ansi" : "color_decode_ansi", - (exec_cmd->color == EXEC_COLOR_DECODE) ? "1" : "0", + (irc_color) ? "irc_color_decode_ansi" : "color_decode_ansi", + (keep_colors) ? "1" : "0", string); } diff --git a/src/plugins/exec/exec.h b/src/plugins/exec/exec.h index c9ac28135..5e3bdd616 100644 --- a/src/plugins/exec/exec.h +++ b/src/plugins/exec/exec.h @@ -28,7 +28,9 @@ enum t_exec_color { EXEC_COLOR_ANSI = 0, - EXEC_COLOR_DECODE, + EXEC_COLOR_AUTO, + EXEC_COLOR_IRC, + EXEC_COLOR_WEECHAT, EXEC_COLOR_STRIP, /* number of color actions */ EXEC_NUM_COLORS, |