1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-09 03:03:12 +02:00

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)
This commit is contained in:
Sebastien Helleu
2005-11-05 11:34:52 +00:00
parent fd562722d0
commit bea5769a05
16 changed files with 1532 additions and 1466 deletions
+20 -1
View File
@@ -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;
}
+12 -8
View File
@@ -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
+16 -8
View File
@@ -298,6 +298,10 @@ gui_color_encode (unsigned char *string)
string++;
switch (string[0])
{
case '%': /* double '%' replaced by single '%' */
out[out_pos++] = string[0];
string++;
break;
case 'B': /* bold */
out[out_pos++] = GUI_ATTR_BOLD_CHAR;
string++;
@@ -727,7 +731,7 @@ void
gui_draw_buffer_title (t_gui_buffer *buffer, int erase)
{
t_gui_window *ptr_win;
char format[32], *buf;
char format[32], *buf, *buf2;
if (!gui_ok)
return;
@@ -745,13 +749,17 @@ gui_draw_buffer_title (t_gui_buffer *buffer, int erase)
{
if (CHANNEL(buffer)->topic)
{
buf = 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,
CHANNEL(buffer)->topic);
mvwprintw (ptr_win->win_title, 0, 0, format, buf);
free (buf);
buf = (char *)gui_color_decode ((unsigned char *)(CHANNEL(buffer)->topic), 0);
buf2 = 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,
(buf) ? buf : CHANNEL(buffer)->topic);
mvwprintw (ptr_win->win_title, 0, 0, format, (buf2) ? buf2 : CHANNEL(buffer)->topic);
if (buf)
free (buf);
if (buf2)
free (buf2);
}
else
mvwprintw (ptr_win->win_title, 0, 0, format, " ");
+5 -3
View File
@@ -2378,15 +2378,17 @@ irc_cmd_recv_topic (t_irc_server *server, char *host, char *nick, char *argument
{
irc_display_prefix (server, buffer, PREFIX_INFO);
if (pos)
{
gui_printf (buffer,
_("%s%s%s has changed topic for %s%s%s to: \"%s\"\n"),
_("%s%s%s has changed topic for %s%s%s to:"),
GUI_COLOR(COLOR_WIN_CHAT_NICK),
nick,
GUI_COLOR(COLOR_WIN_CHAT),
GUI_COLOR(COLOR_WIN_CHAT_CHANNEL),
arguments,
GUI_COLOR(COLOR_WIN_CHAT),
pos);
GUI_COLOR(COLOR_WIN_CHAT));
gui_printf (buffer, " \"%s\"\n", pos);
}
else
gui_printf (buffer,
_("%s%s%s has unset topic for %s%s\n"),