From bea5769a055b31df3f78acf6c179f7f1949a42ca Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sat, 5 Nov 2005 11:34:52 +0000 Subject: Fixed some bugs with color codes: - colors are now removed in topic for display in title bar - completion of /topic command now strips color codes - color codes are encoded in commands (not only text sent to channel/pv) - double '%' is replaced by single '%' in command line (when irc_colors_send is ON) --- src/common/command.c | 21 ++++++++++++++++++++- src/common/completion.c | 20 ++++++++++++-------- 2 files changed, 32 insertions(+), 9 deletions(-) (limited to 'src/common') diff --git a/src/common/command.c b/src/common/command.c index f77b2ac37..7a83344cd 100644 --- a/src/common/command.c +++ b/src/common/command.c @@ -481,7 +481,7 @@ int exec_weechat_command (t_irc_server *server, char *string) { int i, argc, return_code, length1, length2; - char *command, *pos, *ptr_args, **argv, *alias_command; + char *command, *pos, *ptr_args, *ptr_args_color, **argv, *alias_command; t_weechat_alias *ptr_alias; if ((!string) || (!string[0]) || (string[0] != '/')) @@ -512,6 +512,15 @@ exec_weechat_command (t_irc_server *server, char *string) ptr_args = NULL; } + ptr_args_color = NULL; + + if (ptr_args && (cfg_irc_colors_send)) + { + ptr_args_color = (char *)gui_color_encode ((unsigned char *)ptr_args); + if (ptr_args_color) + ptr_args = ptr_args_color; + } + #ifdef PLUGINS if (!plugin_cmd_handler_exec ((server) ? server->name : "", command + 1, ptr_args)) #else @@ -572,6 +581,8 @@ exec_weechat_command (t_irc_server *server, char *string) } free_exploded_string (argv); free (command); + if (ptr_args_color) + free (ptr_args_color); return 1; } } @@ -619,6 +630,8 @@ exec_weechat_command (t_irc_server *server, char *string) _("%s command \"%s\" needs a server connection!\n"), WEECHAT_ERROR, irc_commands[i].command_name); free (command); + if (ptr_args_color) + free (ptr_args_color); return 0; } if (irc_commands[i].cmd_function_args) @@ -637,6 +650,8 @@ exec_weechat_command (t_irc_server *server, char *string) } free_exploded_string (argv); free (command); + if (ptr_args_color) + free (ptr_args_color); return 1; } } @@ -665,6 +680,8 @@ exec_weechat_command (t_irc_server *server, char *string) free_exploded_string (argv); free (command); + if (ptr_args_color) + free (ptr_args_color); return 1; } } @@ -676,6 +693,8 @@ exec_weechat_command (t_irc_server *server, char *string) free_exploded_string (argv); } free (command); + if (ptr_args_color) + free (ptr_args_color); return 0; } diff --git a/src/common/completion.c b/src/common/completion.c index 30dba84d0..b4cc9ae56 100644 --- a/src/common/completion.c +++ b/src/common/completion.c @@ -108,7 +108,7 @@ completion_build_list (t_completion *completion, void *channel) t_irc_server *ptr_server; t_irc_channel *ptr_channel; t_irc_nick *ptr_nick; - char *pos, option_name[256], *string; + char *pos, option_name[256], *string, *string2; t_weechat_alias *ptr_alias; t_config_option *option; void *option_value; @@ -647,15 +647,19 @@ completion_build_list (t_completion *completion, void *channel) completion_stop (completion); else { - string = weechat_convert_encoding ((local_utf8) ? - cfg_look_charset_decode_iso : cfg_look_charset_decode_utf, - (cfg_look_charset_internal && cfg_look_charset_internal[0]) ? - cfg_look_charset_internal : local_charset, - ((t_irc_channel *)channel)->topic); + string = (char *)gui_color_decode ((unsigned char *)((t_irc_channel *)channel)->topic, 0); + string2 = weechat_convert_encoding ((local_utf8) ? + cfg_look_charset_decode_iso : cfg_look_charset_decode_utf, + (cfg_look_charset_internal && cfg_look_charset_internal[0]) ? + cfg_look_charset_internal : local_charset, + (string) ? string : ((t_irc_channel *)channel)->topic); weelist_add (&completion->completion_list, &completion->last_completion, - string); - free (string); + (string2) ? string2 : ((t_irc_channel *)channel)->topic); + if (string) + free (string); + if (string2) + free (string2); } } else -- cgit v1.2.3