diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2006-06-15 13:06:36 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2006-06-15 13:06:36 +0000 |
commit | 87d3725823213e031e0ff33ec41f08824125b70b (patch) | |
tree | e0490d1912e6732f2832c72eaad0ecb52b8fed41 /src/common | |
parent | a38b9ecf797fb8376faee854899a504c7533669f (diff) | |
download | weechat-87d3725823213e031e0ff33ec41f08824125b70b.zip |
Added color encoding for some commands like /me
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/command.c | 31 | ||||
-rw-r--r-- | src/common/command.h | 4 |
2 files changed, 26 insertions, 9 deletions
diff --git a/src/common/command.c b/src/common/command.c index 5d218409e..c63905d05 100644 --- a/src/common/command.c +++ b/src/common/command.c @@ -674,7 +674,8 @@ exec_weechat_command (t_irc_server *server, t_irc_channel *channel, char *string int only_builtin) { int i, rc, argc, argc2, return_code, length1, length2; - char *command, *pos, *ptr_args, *ptr_args2, **argv, **argv2, *alias_command; + char *command, *pos, *ptr_args, *ptr_args2, *ptr_args3; + char **argv, **argv2, *alias_command; char **commands, **ptr_cmd, **ptr_next_cmd; t_weechat_alias *ptr_alias; @@ -842,11 +843,16 @@ exec_weechat_command (t_irc_server *server, t_irc_channel *channel, char *string } else { - ptr_args2 = (weechat_commands[i].charset_conversion && ptr_args) ? + ptr_args2 = (weechat_commands[i].conversion && ptr_args) ? channel_iconv_encode (server, channel, ptr_args) : NULL; + ptr_args3 = (weechat_commands[i].conversion + && cfg_irc_colors_send && ptr_args) ? + (char *)gui_color_encode ((ptr_args2) ? (unsigned char *)ptr_args2 : + (unsigned char *)ptr_args) : NULL; if (weechat_commands[i].cmd_function_args) { - argv2 = explode_string ((ptr_args2) ? ptr_args2 : ptr_args, + argv2 = explode_string ((ptr_args3) ? ptr_args3 : + ((ptr_args2) ? ptr_args2 : ptr_args), " ", 0, &argc2); return_code = (int) (weechat_commands[i].cmd_function_args) (server, channel, argc2, argv2); @@ -854,7 +860,8 @@ exec_weechat_command (t_irc_server *server, t_irc_channel *channel, char *string } else return_code = (int) (weechat_commands[i].cmd_function_1arg) - (server, channel, (ptr_args2) ? ptr_args2 : ptr_args); + (server, channel, (ptr_args3) ? ptr_args3 : + ((ptr_args2) ? ptr_args2 : ptr_args)); if (return_code < 0) { irc_display_prefix (NULL, NULL, PREFIX_ERROR); @@ -864,6 +871,8 @@ exec_weechat_command (t_irc_server *server, t_irc_channel *channel, char *string } if (ptr_args2) free (ptr_args2); + if (ptr_args3) + free (ptr_args3); } free_exploded_string (argv); free (command); @@ -929,11 +938,16 @@ exec_weechat_command (t_irc_server *server, t_irc_channel *channel, char *string free (command); return 0; } - ptr_args2 = (irc_commands[i].charset_conversion && ptr_args) ? + ptr_args2 = (irc_commands[i].conversion && ptr_args) ? channel_iconv_encode (server, channel, ptr_args) : NULL; + ptr_args3 = (irc_commands[i].conversion + && cfg_irc_colors_send && ptr_args) ? + (char *)gui_color_encode ((ptr_args2) ? (unsigned char *)ptr_args2 : + (unsigned char *)ptr_args) : NULL; if (irc_commands[i].cmd_function_args) { - argv2 = explode_string ((ptr_args2) ? ptr_args2 : ptr_args, + argv2 = explode_string ((ptr_args3) ? ptr_args3 : + ((ptr_args2) ? ptr_args2 : ptr_args), " ", 0, &argc2); return_code = (int) (irc_commands[i].cmd_function_args) (server, channel, argc2, argv2); @@ -941,7 +955,8 @@ exec_weechat_command (t_irc_server *server, t_irc_channel *channel, char *string } else return_code = (int) (irc_commands[i].cmd_function_1arg) - (server, channel, (ptr_args2) ? ptr_args2 : ptr_args); + (server, channel, (ptr_args3) ? ptr_args3 : + ((ptr_args2) ? ptr_args2 : ptr_args)); if (return_code < 0) { irc_display_prefix (NULL, NULL, PREFIX_ERROR); @@ -951,6 +966,8 @@ exec_weechat_command (t_irc_server *server, t_irc_channel *channel, char *string } if (ptr_args2) free (ptr_args2); + if (ptr_args3) + free (ptr_args3); } free_exploded_string (argv); free (command); diff --git a/src/common/command.h b/src/common/command.h index ae41d501c..975bd9c79 100644 --- a/src/common/command.h +++ b/src/common/command.h @@ -38,8 +38,8 @@ struct t_weechat_command char *completion_template; /* template for completion */ /* NULL=no completion, ""=default (nick) */ int min_arg, max_arg; /* min & max number of arguments */ - int charset_conversion; /* = 1 if cmd args are converted before */ - /* they're executed */ + int conversion; /* = 1 if cmd args are converted (charset */ + /* and color) before execution */ int (*cmd_function_args)(t_irc_server *, t_irc_channel *, int, char **); /* function called when user enters cmd */ int (*cmd_function_1arg)(t_irc_server *, t_irc_channel *, char *); |