diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/common/command.c | 368 | ||||
-rw-r--r-- | src/common/completion.c | 2 | ||||
-rw-r--r-- | src/common/log.c | 22 | ||||
-rw-r--r-- | src/common/weechat.c | 57 | ||||
-rw-r--r-- | src/common/weeconfig.c | 22 | ||||
-rw-r--r-- | src/common/weeconfig.h | 3 | ||||
-rw-r--r-- | src/gui/curses/gui-display.c | 2018 | ||||
-rw-r--r-- | src/gui/gui-common.c | 445 | ||||
-rw-r--r-- | src/gui/gui.h | 241 | ||||
-rw-r--r-- | src/irc/irc-commands.c | 1 | ||||
-rw-r--r-- | src/irc/irc-dcc.c | 230 | ||||
-rw-r--r-- | src/irc/irc-display.c | 233 | ||||
-rw-r--r-- | src/irc/irc-nick.c | 2 | ||||
-rw-r--r-- | src/irc/irc-recv.c | 1273 | ||||
-rw-r--r-- | src/irc/irc-send.c | 133 | ||||
-rw-r--r-- | src/irc/irc-server.c | 4 | ||||
-rw-r--r-- | src/plugins/plugins-interface.c | 2 |
17 files changed, 2835 insertions, 2221 deletions
diff --git a/src/common/command.c b/src/common/command.c index 9cbc5cc3a..e3aea11cb 100644 --- a/src/common/command.c +++ b/src/common/command.c @@ -303,7 +303,7 @@ alias_new (char *alias_name, char *alias_command) if (!weelist_search (index_commands, alias_command)) { irc_display_prefix (NULL, NULL, PREFIX_ERROR); - gui_printf (NULL, _("%s target command \"%s\" does not exist!\n"), + gui_printf (NULL, _("%s target command \"/%s\" does not exist!\n"), WEECHAT_ERROR, alias_command); return NULL; } @@ -689,7 +689,7 @@ user_command (t_irc_server *server, t_gui_buffer *buffer, char *command) { t_irc_nick *ptr_nick; int plugin_args_length; - char *plugin_args; + char *command_with_colors, *command_with_colors2, *plugin_args; if ((!command) || (!command[0]) || (command[0] == '\r') || (command[0] == '\n')) return; @@ -709,28 +709,37 @@ user_command (t_irc_server *server, t_gui_buffer *buffer, char *command) if (server && (!BUFFER_IS_SERVER(buffer))) { + command_with_colors = (cfg_irc_colors_send) ? + (char *)gui_color_encode ((unsigned char *)command) : NULL; + if (CHANNEL(buffer)->dcc_chat) dcc_chat_sendf ((t_irc_dcc *)(CHANNEL(buffer)->dcc_chat), - "%s\r\n", command); + "%s\r\n", + (command_with_colors) ? command_with_colors : command); else server_sendf (server, "PRIVMSG %s :%s\r\n", - CHANNEL(buffer)->name, command); + CHANNEL(buffer)->name, + (command_with_colors) ? + command_with_colors : command); + + command_with_colors2 = (command_with_colors) ? + (char *)gui_color_decode ((unsigned char *)command_with_colors, 1) : NULL; if (CHANNEL(buffer)->type == CHAT_PRIVATE) { - gui_printf_type_color (CHANNEL(buffer)->buffer, - MSG_TYPE_NICK, - COLOR_WIN_CHAT_DARK, "<"); - gui_printf_type_color (CHANNEL(buffer)->buffer, - MSG_TYPE_NICK, - COLOR_WIN_NICK_SELF, - "%s", server->nick); - gui_printf_type_color (CHANNEL(buffer)->buffer, - MSG_TYPE_NICK, - COLOR_WIN_CHAT_DARK, "> "); - gui_printf_type_color (CHANNEL(buffer)->buffer, - MSG_TYPE_MSG, - COLOR_WIN_CHAT, "%s\n", command); + gui_printf_type (CHANNEL(buffer)->buffer, + MSG_TYPE_NICK, + "%s<%s%s%s> ", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_NICK_SELF), + server->nick, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); + gui_printf_type (CHANNEL(buffer)->buffer, + MSG_TYPE_MSG, + "%s%s\n", + GUI_COLOR(COLOR_WIN_CHAT), + (command_with_colors2) ? + command_with_colors2 : command); } else { @@ -739,8 +748,10 @@ user_command (t_irc_server *server, t_gui_buffer *buffer, char *command) { irc_display_nick (CHANNEL(buffer)->buffer, ptr_nick, NULL, MSG_TYPE_NICK, 1, 1, 0); - gui_printf_color (CHANNEL(buffer)->buffer, - COLOR_WIN_CHAT, "%s\n", command); + gui_printf (CHANNEL(buffer)->buffer, + "%s\n", + (command_with_colors2) ? + command_with_colors2 : command); } else { @@ -751,6 +762,11 @@ user_command (t_irc_server *server, t_gui_buffer *buffer, char *command) } } + if (command_with_colors) + free (command_with_colors); + if (command_with_colors2) + free (command_with_colors2); + /* sending a copy of the message as PRIVMSG to plugins because irc server doesn't */ plugin_args_length = strlen ("localhost PRIVMSG :") + strlen (CHANNEL(buffer)->name) + strlen(command) + 16; @@ -810,6 +826,13 @@ weechat_cmd_alias (char *arguments) WEECHAT_ERROR, "alias"); return -1; } + if (arguments[0] == '/') + { + irc_display_prefix (NULL, NULL, PREFIX_ERROR); + gui_printf (NULL, _("%s alias can not start with \"/\"\n"), + WEECHAT_ERROR, "alias"); + return -1; + } if (!alias_new (arguments, pos)) return -1; if (weelist_add (&index_commands, &last_index_command, arguments)) @@ -845,8 +868,10 @@ weechat_cmd_alias (char *arguments) for (ptr_alias = weechat_alias; ptr_alias; ptr_alias = ptr_alias->next_alias) { - gui_printf (NULL, " %s => %s\n", + gui_printf (NULL, " %s %s=>%s %s\n", ptr_alias->alias_name, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), ptr_alias->alias_command + 1); } } @@ -867,38 +892,32 @@ void weechat_cmd_buffer_display_info (t_gui_buffer *buffer) { if (buffer->dcc) - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, "DCC\n"); + gui_printf (NULL, "%sDCC\n", + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL)); else if (BUFFER_IS_SERVER (buffer)) - { - gui_printf (NULL, _("Server: ")); - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, - "%s\n", SERVER(buffer)->name); - } + gui_printf (NULL, _("%sServer: %s%s\n"), + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + SERVER(buffer)->name); else if (BUFFER_IS_CHANNEL (buffer)) - { - gui_printf (NULL, _("Channel: ")); - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, - "%s", CHANNEL(buffer)->name); - gui_printf (NULL, _(" (server: ")); - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, - "%s", SERVER(buffer)->name); - gui_printf (NULL, ")\n"); - } + gui_printf (NULL, _("%sChannel: %s%s %s(server: %s%s%s)\n"), + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + CHANNEL(buffer)->name, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + SERVER(buffer)->name, + GUI_COLOR(COLOR_WIN_CHAT)); else if (BUFFER_IS_PRIVATE (buffer)) - { - gui_printf (NULL, _("Private with: ")); - gui_printf_color (NULL, COLOR_WIN_CHAT_NICK, - "%s", CHANNEL(buffer)->name); - gui_printf (NULL, _(" (server: ")); - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, - "%s", SERVER(buffer)->name); - gui_printf (NULL, ")\n"); - } + gui_printf (NULL, _("%sPrivate with: %s%s %s(server: %s%s%s)\n"), + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + CHANNEL(buffer)->name, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + SERVER(buffer)->name); else - { - gui_printf (NULL, _("not connected")); - gui_printf (NULL, "\n"); - } + gui_printf (NULL, _("not connected\n")); } /* @@ -924,10 +943,11 @@ weechat_cmd_buffer (int argc, char **argv) for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer) { - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "["); - gui_printf (NULL, "%d", ptr_buffer->number); - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "] "); - + gui_printf (NULL, "%s[%s%d%s] ", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + ptr_buffer->number, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); weechat_cmd_buffer_display_info (ptr_buffer); } } @@ -1314,9 +1334,10 @@ weechat_cmd_help (int argc, char **argv) gui_printf (NULL, _("%s internal commands:\n"), PACKAGE_NAME); for (i = 0; weechat_commands[i].command_name; i++) { - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, " %s", - weechat_commands[i].command_name); - gui_printf (NULL, " - %s\n", + gui_printf (NULL, " %s%s %s- %s\n", + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + weechat_commands[i].command_name, + GUI_COLOR(COLOR_WIN_CHAT), _(weechat_commands[i].command_description)); } gui_printf (NULL, "\n"); @@ -1325,9 +1346,10 @@ weechat_cmd_help (int argc, char **argv) { if (irc_commands[i].cmd_function_args || irc_commands[i].cmd_function_1arg) { - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, " %s", - irc_commands[i].command_name); - gui_printf (NULL, " - %s\n", + gui_printf (NULL, " %s%s %s- %s\n", + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + irc_commands[i].command_name, + GUI_COLOR(COLOR_WIN_CHAT), _(irc_commands[i].command_description)); } } @@ -1342,11 +1364,13 @@ weechat_cmd_help (int argc, char **argv) { if (ptr_handler->type == HANDLER_COMMAND) { - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, " %s", - ptr_handler->command); + gui_printf (NULL, " %s%s", + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + ptr_handler->command); if (ptr_handler->description && ptr_handler->description[0]) - gui_printf (NULL, " - %s", + gui_printf (NULL, " %s- %s", + GUI_COLOR(COLOR_WIN_CHAT), ptr_handler->description); gui_printf (NULL, "\n"); } @@ -1361,11 +1385,13 @@ weechat_cmd_help (int argc, char **argv) { gui_printf (NULL, "\n"); gui_printf (NULL, "[w]"); - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, " /%s", - weechat_commands[i].command_name); + gui_printf (NULL, " %s/%s", + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + weechat_commands[i].command_name); if (weechat_commands[i].arguments && weechat_commands[i].arguments[0]) - gui_printf (NULL, " %s\n", + gui_printf (NULL, " %s%s\n", + GUI_COLOR(COLOR_WIN_CHAT), _(weechat_commands[i].arguments)); else gui_printf (NULL, "\n"); @@ -1387,11 +1413,13 @@ weechat_cmd_help (int argc, char **argv) { gui_printf (NULL, "\n"); gui_printf (NULL, "[i]"); - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, " /%s", - irc_commands[i].command_name); + gui_printf (NULL, " %s/%s", + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + irc_commands[i].command_name); if (irc_commands[i].arguments && irc_commands[i].arguments[0]) - gui_printf (NULL, " %s\n", + gui_printf (NULL, " %s%s\n", + GUI_COLOR(COLOR_WIN_CHAT), _(irc_commands[i].arguments)); else gui_printf (NULL, "\n"); @@ -1418,11 +1446,13 @@ weechat_cmd_help (int argc, char **argv) { gui_printf (NULL, "\n"); gui_printf (NULL, "[p]"); - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, " /%s", - ptr_handler->command); + gui_printf (NULL, " %s/%s", + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + ptr_handler->command); if (ptr_handler->arguments && ptr_handler->arguments[0]) - gui_printf (NULL, " %s\n", + gui_printf (NULL, " %s%s\n", + GUI_COLOR(COLOR_WIN_CHAT), ptr_handler->arguments); else gui_printf (NULL, "\n"); @@ -1456,17 +1486,27 @@ void weechat_cmd_ignore_display (char *text, t_irc_ignore *ptr_ignore) { if (text) - gui_printf (NULL, "%s ", text); + gui_printf (NULL, "%s%s ", + GUI_COLOR(COLOR_WIN_CHAT), + text); - gui_printf (NULL, _("on")); - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, " %s", ptr_ignore->server_name); - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "/"); - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, "%s", ptr_ignore->channel_name); - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, ":"); - gui_printf (NULL, _(" ignoring ")); - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, "%s", ptr_ignore->type); - gui_printf (NULL, _(" from ")); - gui_printf_color (NULL, COLOR_WIN_CHAT_HOST, "%s\n", ptr_ignore->mask); + gui_printf (NULL, "%s%s %s%s%s/%s%s%s:%s%s%s%s%s%s%s%s\n", + GUI_COLOR(COLOR_WIN_CHAT), + _("on"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + ptr_ignore->server_name, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + ptr_ignore->channel_name, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + _(" ignoring "), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + ptr_ignore->type, + GUI_COLOR(COLOR_WIN_CHAT), + _(" from "), + GUI_COLOR(COLOR_WIN_CHAT_HOST), + ptr_ignore->mask); } /* @@ -1493,9 +1533,11 @@ weechat_cmd_ignore (int argc, char **argv) ptr_ignore = ptr_ignore->next_ignore) { i++; - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "["); - gui_printf (NULL, "%d", i); - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "] "); + gui_printf (NULL, "%s[%s%d%s] ", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + i, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); weechat_cmd_ignore_display (NULL, ptr_ignore); } } @@ -1547,13 +1589,15 @@ weechat_cmd_key_display (t_gui_key *key, int new_key) expanded_name = gui_key_get_expanded_name (key->key); if (new_key) { - gui_printf (NULL, _("New key binding:\n")); - gui_printf (NULL, " %s", (expanded_name) ? expanded_name : key->key); + irc_display_prefix (NULL, NULL, PREFIX_INFO); + gui_printf (NULL, _("New key binding: %s"), + (expanded_name) ? expanded_name : key->key); } else gui_printf (NULL, " %20s", (expanded_name) ? expanded_name : key->key); - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, " => "); - gui_printf (NULL, "%s\n", + gui_printf (NULL, "%s => %s%s\n", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), (key->function) ? gui_key_function_search_by_ptr (key->function) : key->command); if (expanded_name) @@ -1592,7 +1636,10 @@ weechat_cmd_key (char *arguments) while (arguments[0] == ' ') arguments++; if (gui_key_unbind (arguments)) + { + irc_display_prefix (NULL, NULL, PREFIX_INFO); gui_printf (NULL, _("Key \"%s\" unbinded\n"), arguments); + } else { irc_display_prefix (NULL, NULL, PREFIX_ERROR); @@ -1624,6 +1671,7 @@ weechat_cmd_key (char *arguments) { gui_key_free_all (); gui_key_init (); + irc_display_prefix (NULL, NULL, PREFIX_INFO); gui_printf (NULL, _("Default key bindings restored\n")); } else @@ -1692,8 +1740,10 @@ weechat_cmd_plugin (int argc, char **argv) { /* plugin info */ irc_display_prefix (NULL, NULL, PREFIX_PLUGIN); - gui_printf (NULL, " %s v%s - %s (%s)\n", + gui_printf (NULL, " %s%s%s v%s - %s (%s)\n", + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), ptr_plugin->name, + GUI_COLOR(COLOR_WIN_CHAT), ptr_plugin->version, ptr_plugin->description, ptr_plugin->filename); @@ -1904,13 +1954,14 @@ weechat_cmd_server (int argc, char **argv) } } + server_free (server_found); + irc_display_prefix (NULL, NULL, PREFIX_INFO); - gui_printf_color (NULL, COLOR_WIN_CHAT, _("Server")); - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, - " %s ", server_found->name); - gui_printf_color (NULL, COLOR_WIN_CHAT, _("has been deleted\n")); + gui_printf (NULL, _("Server %s%s%s has been deleted\n"), + GUI_COLOR(COLOR_WIN_CHAT_SERVER), + server_found->name, + GUI_COLOR(COLOR_WIN_CHAT)); - server_free (server_found); gui_redraw_buffer (gui_current_window->buffer); return 0; @@ -2051,10 +2102,10 @@ weechat_cmd_server (int argc, char **argv) if (new_server) { irc_display_prefix (NULL, NULL, PREFIX_INFO); - gui_printf_color (NULL, COLOR_WIN_CHAT, _("Server")); - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, - " %s ", server.name); - gui_printf_color (NULL, COLOR_WIN_CHAT, _("created\n")); + gui_printf (NULL, _("Server %s%s%s created\n"), + GUI_COLOR(COLOR_WIN_CHAT_SERVER), + server.name, + GUI_COLOR(COLOR_WIN_CHAT)); } else { @@ -2086,11 +2137,11 @@ weechat_cmd_set_display_option (t_config_option *option, char *prefix, void *val { char *color_name, *pos_nickserv, *pos_pwd, *value2; - gui_printf (NULL, " %s%s%s", + gui_printf (NULL, " %s%s%s%s = ", (prefix) ? prefix : "", (prefix) ? "." : "", - option->option_name); - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, " = "); + option->option_name, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); if (!value) { if (option->option_type == OPTION_TYPE_STRING) @@ -2101,21 +2152,25 @@ weechat_cmd_set_display_option (t_config_option *option, char *prefix, void *val switch (option->option_type) { case OPTION_TYPE_BOOLEAN: - gui_printf_color (NULL, COLOR_WIN_CHAT_HOST, - "%s\n", (*((int *)value)) ? "ON" : "OFF"); + gui_printf (NULL, "%s%s\n", + GUI_COLOR(COLOR_WIN_CHAT_HOST), + (*((int *)value)) ? "ON" : "OFF"); break; case OPTION_TYPE_INT: - gui_printf_color (NULL, COLOR_WIN_CHAT_HOST, - "%d\n", *((int *)value)); + gui_printf (NULL, "%s%d\n", + GUI_COLOR(COLOR_WIN_CHAT_HOST), + *((int *)value)); break; case OPTION_TYPE_INT_WITH_STRING: - gui_printf_color (NULL, COLOR_WIN_CHAT_HOST, - "%s\n", option->array_values[*((int *)value)]); + gui_printf (NULL, "%s%s\n", + GUI_COLOR(COLOR_WIN_CHAT_HOST), + option->array_values[*((int *)value)]); break; case OPTION_TYPE_COLOR: - color_name = gui_get_color_by_value (*((int *)value)); - gui_printf_color (NULL, COLOR_WIN_CHAT_HOST, - "%s\n", (color_name) ? color_name : _("(unknown)")); + color_name = gui_get_color_name (*((int *)value)); + gui_printf (NULL, "%s%s\n", + GUI_COLOR(COLOR_WIN_CHAT_HOST), + (color_name) ? color_name : _("(unknown)")); break; case OPTION_TYPE_STRING: if (*((char **)value)) @@ -2138,9 +2193,12 @@ weechat_cmd_set_display_option (t_config_option *option, char *prefix, void *val pos_pwd[0] = '*'; pos_pwd++; } - gui_printf (NULL, _("(password hidden) ")); + gui_printf (NULL, _("%s(password hidden) "), + GUI_COLOR(COLOR_WIN_CHAT)); } - gui_printf_color (NULL, COLOR_WIN_CHAT_HOST, "%s", value2); + gui_printf (NULL, "%s%s", + GUI_COLOR(COLOR_WIN_CHAT_HOST), + value2); free (value2); } gui_printf (NULL, "\n"); @@ -2210,12 +2268,14 @@ weechat_cmd_set (char *arguments) switch (config_set_server_value (ptr_server, pos + 1, value)) { case 0: - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "\n["); - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, "%s", - config_sections[CONFIG_SECTION_SERVER].section_name); - gui_printf_color (NULL, COLOR_WIN_CHAT_NICK, " %s", - ptr_server->name); - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "]\n"); + gui_printf (NULL, "\n"); + gui_printf (NULL, "%s[%s%s %s%s]\n", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + config_sections[CONFIG_SECTION_SERVER].section_name, + GUI_COLOR(COLOR_WIN_CHAT_SERVER), + ptr_server->name, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); for (i = 0; weechat_options[CONFIG_SECTION_SERVER][i].option_name; i++) { if (strcmp (weechat_options[CONFIG_SECTION_SERVER][i].option_name, pos + 1) == 0) @@ -2262,10 +2322,12 @@ weechat_cmd_set (char *arguments) if (config_option_set_value (ptr_option, value) == 0) { (void) (ptr_option->handler_change()); - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "\n["); - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, - "%s", config_get_section (ptr_option)); - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "]\n"); + gui_printf (NULL, "\n"); + gui_printf (NULL, "%s[%s%s%s]\n", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + config_get_section (ptr_option), + GUI_COLOR(COLOR_WIN_CHAT_DARK)); weechat_cmd_set_display_option (ptr_option, NULL, NULL); } else @@ -2304,11 +2366,12 @@ weechat_cmd_set (char *arguments) { if (!section_displayed) { - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "\n["); - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, - "%s", - config_sections[i].section_name); - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "]\n"); + gui_printf (NULL, "\n"); + gui_printf (NULL, "%s[%s%s%s]\n", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + config_sections[i].section_name, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); section_displayed = 1; } weechat_cmd_set_display_option (&weechat_options[i][j], NULL, NULL); @@ -2334,12 +2397,14 @@ weechat_cmd_set (char *arguments) { if (!section_displayed) { - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "\n["); - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, "%s", - config_sections[CONFIG_SECTION_SERVER].section_name); - gui_printf_color (NULL, COLOR_WIN_CHAT_NICK, " %s", - ptr_server->name); - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "]\n"); + gui_printf (NULL, "\n"); + gui_printf (NULL, "%s[%s%s %s%s%s]\n", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + config_sections[CONFIG_SECTION_SERVER].section_name, + GUI_COLOR(COLOR_WIN_CHAT_SERVER), + ptr_server->name, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); section_displayed = 1; } ptr_option_value = config_get_server_option_ptr (ptr_server, @@ -2369,7 +2434,9 @@ weechat_cmd_set (char *arguments) if ((number_found == 1) && (last_section >= 0) && (last_option >= 0)) { gui_printf (NULL, "\n"); - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, _("Detail:\n")); + gui_printf (NULL, _("%sDetail:\n"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL)); + gui_printf (NULL, GUI_COLOR(COLOR_WIN_CHAT_CHANNEL)); switch (weechat_options[last_section][last_option].option_type) { case OPTION_TYPE_BOOLEAN: @@ -2419,7 +2486,11 @@ weechat_cmd_set (char *arguments) } else { - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, "\n%d ", number_found); + gui_printf (NULL, "\n"); + gui_printf (NULL, "%s%d %s", + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + number_found, + GUI_COLOR(COLOR_WIN_CHAT)); if (option) gui_printf (NULL, _("config option(s) found with \"%s\"\n"), option); @@ -2506,7 +2577,10 @@ weechat_cmd_unignore (int argc, char **argv) if (ret) { irc_display_prefix (NULL, NULL, PREFIX_INFO); - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, "%d ", ret); + gui_printf (NULL, "%s%d%s ", + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + ret, + GUI_COLOR(COLOR_WIN_CHAT)); if (ret > 1) gui_printf (NULL, _("ignore were removed.\n")); else @@ -2545,17 +2619,19 @@ weechat_cmd_window (int argc, char **argv) i = 1; for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) { - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "["); - gui_printf (NULL, "%d", i); - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "] ("); - gui_printf (NULL, "%d", ptr_win->win_x); - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, ":"); - gui_printf (NULL, "%d", ptr_win->win_y); - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, ";"); - gui_printf (NULL, "%d", ptr_win->win_width); - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "x"); - gui_printf (NULL, "%d", ptr_win->win_height); - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, ") "); + gui_printf (NULL, "%s[%s%d%s] (%s%d:%d%s;%s%dx%d%s) ", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + i, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + ptr_win->win_x, + ptr_win->win_y, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + ptr_win->win_width, + ptr_win->win_height, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); weechat_cmd_buffer_display_info (ptr_win->buffer); diff --git a/src/common/completion.c b/src/common/completion.c index 2dc6bc879..30dba84d0 100644 --- a/src/common/completion.c +++ b/src/common/completion.c @@ -425,7 +425,7 @@ completion_build_list (t_completion *completion, void *channel) weelist_add (&completion->completion_list, &completion->last_completion, (option_value) ? - gui_get_color_by_value (*((int *)(option_value))) : + gui_get_color_name (*((int *)(option_value))) : option->default_string); break; case OPTION_TYPE_STRING: diff --git a/src/common/log.c b/src/common/log.c index 06f62f7cd..1c18553ec 100644 --- a/src/common/log.c +++ b/src/common/log.c @@ -73,28 +73,6 @@ log_write (t_gui_buffer *buffer, char *message) } /* - * log_write_line: writes a WeeChat line to log file - */ - -void -log_write_line (t_gui_buffer *buffer, t_gui_line *line) -{ - t_gui_message *ptr_msg; - - if (buffer->log_file) - { - log_write_date (buffer); - for (ptr_msg = line->messages; ptr_msg; ptr_msg = ptr_msg->next_message) - { - if (ptr_msg->type != MSG_TYPE_TIME) - fprintf (buffer->log_file, "%s", ptr_msg->message); - } - fprintf (buffer->log_file, "\n"); - fflush (buffer->log_file); - } -} - -/* * log_start: starts a log */ diff --git a/src/common/weechat.c b/src/common/weechat.c index 58a2e348e..245776975 100644 --- a/src/common/weechat.c +++ b/src/common/weechat.c @@ -169,6 +169,7 @@ void wee_log_printf (char *message, ...) { static char buffer[4096]; + char *ptr_buffer; va_list argptr; static time_t seconds; struct tm *date_tmp; @@ -180,6 +181,17 @@ wee_log_printf (char *message, ...) vsnprintf (buffer, sizeof (buffer) - 1, message, argptr); va_end (argptr); + /* keep only valid chars */ + ptr_buffer = buffer; + while (ptr_buffer[0]) + { + if ((ptr_buffer[0] != '\n') + && (ptr_buffer[0] != '\r') + && ((unsigned char)(ptr_buffer[0]) < 32)) + ptr_buffer[0] = '.'; + ptr_buffer++; + } + seconds = time (NULL); date_tmp = localtime (&seconds); if (date_tmp) @@ -667,35 +679,42 @@ weechat_welcome_message () { if (cfg_look_startup_logo) { - gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX1, - " ___ __ ______________ _____ \n" - " __ | / /___________ ____/__ /_______ __ /_\n" - " __ | /| / /_ _ \\ _ \\ / __ __ \\ __ `/ __/\n" - " __ |/ |/ / / __/ __/ /___ _ / / / /_/ // /_ \n" - " ____/|__/ \\___/\\___/\\____/ /_/ /_/\\__,_/ \\__/ \n"); + gui_printf (NULL, + "%s ___ __ ______________ _____ \n" + "%s __ | / /___________ ____/__ /_______ __ /_\n" + "%s __ | /| / /_ _ \\ _ \\ / __ __ \\ __ `/ __/\n" + "%s __ |/ |/ / / __/ __/ /___ _ / / / /_/ // /_ \n" + "%s ____/|__/ \\___/\\___/\\____/ /_/ /_/\\__,_/ \\__/ \n", + GUI_COLOR(COLOR_WIN_CHAT_NICK), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + GUI_COLOR(COLOR_WIN_CHAT_NICK)); } if (cfg_look_weechat_slogan && cfg_look_weechat_slogan[0]) { - gui_printf_color (NULL, COLOR_WIN_CHAT, _("%sWelcome to "), - (cfg_look_startup_logo) ? " " : ""); - gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX2, PACKAGE_NAME); - gui_printf_color (NULL, COLOR_WIN_CHAT, - ", %s\n", cfg_look_weechat_slogan); + gui_printf (NULL, _("%sWelcome to %s%s%s, %s\n"), + (cfg_look_startup_logo) ? " " : "", + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + PACKAGE_NAME, + GUI_NO_COLOR, + cfg_look_weechat_slogan); } if (cfg_look_startup_version) { - gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX2, - "%s" PACKAGE_STRING, - (cfg_look_startup_logo) ? " " : ""); - gui_printf_color (NULL, COLOR_WIN_CHAT, - ", %s %s %s\n", - _("compiled on"), __DATE__, __TIME__); + gui_printf (NULL, "%s%s%s%s, %s %s %s\n", + (cfg_look_startup_logo) ? " " : "", + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + PACKAGE_STRING, + GUI_NO_COLOR, + _("compiled on"), __DATE__, __TIME__); } if (cfg_look_startup_logo || (cfg_look_weechat_slogan && cfg_look_weechat_slogan[0]) || cfg_look_startup_version) - gui_printf_color (NULL, COLOR_WIN_CHAT_PREFIX1, - "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n"); + gui_printf (NULL, + "%s-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n", + GUI_COLOR(COLOR_WIN_CHAT_NICK)); wee_log_printf ("%s (%s %s %s)\n", PACKAGE_STRING, _("compiled on"), __DATE__, __TIME__); diff --git a/src/common/weeconfig.c b/src/common/weeconfig.c index eaacbc5e8..89c2a0935 100644 --- a/src/common/weeconfig.c +++ b/src/common/weeconfig.c @@ -77,7 +77,6 @@ char *cfg_look_buffer_timestamp; int cfg_look_color_nicks; int cfg_look_color_nicks_number; int cfg_look_color_actions; -int cfg_look_remove_colors_from_msgs; int cfg_look_nicklist; int cfg_look_nicklist_position; char *cfg_look_nicklist_position_values[] = @@ -154,10 +153,6 @@ t_config_option weechat_options_look[] = N_("display actions with different colors"), OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, NULL, NULL, &cfg_look_color_actions, NULL, config_change_noop }, - { "look_remove_colors_from_msgs", N_("remove colors from incoming messages"), - N_("remove colors from incoming messages"), - OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, - NULL, NULL, &cfg_look_remove_colors_from_msgs, NULL, config_change_noop }, { "look_nicklist", N_("display nicklist window"), N_("display nicklist window (for channel windows)"), OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, @@ -435,7 +430,7 @@ t_config_option weechat_options_colors[] = { "col_input_delimiters", N_("color for input text (delimiters)"), N_("color for input text (delimiters)"), OPTION_TYPE_COLOR, 0, 0, 0, - "white", NULL, &cfg_col_input_delimiters, NULL, &config_change_color }, + "cyan", NULL, &cfg_col_input_delimiters, NULL, &config_change_color }, { "col_input_bg", N_("background for input window"), N_("background for input window"), OPTION_TYPE_COLOR, 0, 0, 0, @@ -637,6 +632,8 @@ int cfg_irc_lag_min_show; int cfg_irc_lag_disconnect; int cfg_irc_fifo_pipe; char *cfg_irc_highlight; +int cfg_irc_colors_receive; +int cfg_irc_colors_send; t_config_option weechat_options_irc[] = { { "irc_display_away", N_("display message to all channels when away"), @@ -684,6 +681,15 @@ t_config_option weechat_options_irc[] = "words may begin or end with \"*\" for partial match)"), OPTION_TYPE_STRING, 0, 0, 0, "", NULL, NULL, &cfg_irc_highlight, &config_change_noop }, + { "irc_colors_receive", N_("keep colors from incoming messages"), + N_("keep colors from incoming messages"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_irc_colors_receive, NULL, config_change_noop }, + { "irc_colors_send", N_("allow user to send colors"), + N_("allow user to send colors with special codes (%B=bold, %Cxx,yy=color, " + "%U=underline, %R=reverse)"), + OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, + NULL, NULL, &cfg_irc_colors_send, NULL, config_change_noop }, { NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL } }; @@ -1043,7 +1049,7 @@ config_change_color () { t_gui_window *ptr_win; - gui_init_colors (); + gui_rebuild_weechat_colors (); for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) gui_redraw_buffer (ptr_win->buffer); } @@ -2072,7 +2078,7 @@ config_write (char *config_name) fprintf (file, "%s=%s\n", weechat_options[i][j].option_name, (weechat_options[i][j].ptr_int) ? - gui_get_color_by_value (*weechat_options[i][j].ptr_int) : + gui_get_color_name (*weechat_options[i][j].ptr_int) : weechat_options[i][j].default_string); break; case OPTION_TYPE_STRING: diff --git a/src/common/weeconfig.h b/src/common/weeconfig.h index f383a6011..929bfbe8e 100644 --- a/src/common/weeconfig.h +++ b/src/common/weeconfig.h @@ -92,7 +92,6 @@ extern char *cfg_look_buffer_timestamp; extern int cfg_look_color_nicks; extern int cfg_look_color_nicks_number; extern int cfg_look_color_actions; -extern int cfg_look_remove_colors_from_msgs; extern int cfg_look_nicklist; extern int cfg_look_nicklist_position; extern int cfg_look_nicklist_min_size; @@ -189,6 +188,8 @@ extern int cfg_irc_lag_min_show; extern int cfg_irc_lag_disconnect; extern int cfg_irc_fifo_pipe; extern char *cfg_irc_highlight; +extern int cfg_irc_colors_receive; +extern int cfg_irc_colors_send; extern int cfg_dcc_auto_accept_files; extern int cfg_dcc_auto_accept_chats; diff --git a/src/gui/curses/gui-display.c b/src/gui/curses/gui-display.c index 8c2897a90..bc9708367 100644 --- a/src/gui/curses/gui-display.c +++ b/src/gui/curses/gui-display.c @@ -47,30 +47,49 @@ #include "../../irc/irc.h" -t_gui_color gui_colors[] = -{ { "default", -1 | A_NORMAL }, - { "black", COLOR_BLACK | A_NORMAL }, - { "red", COLOR_RED | A_NORMAL }, - { "lightred", COLOR_RED | A_BOLD }, - { "green", COLOR_GREEN | A_NORMAL }, - { "lightgreen", COLOR_GREEN | A_BOLD }, - { "brown", COLOR_YELLOW | A_NORMAL }, - { "yellow", COLOR_YELLOW | A_BOLD }, - { "blue", COLOR_BLUE | A_NORMAL }, - { "lightblue", COLOR_BLUE | A_BOLD }, - { "magenta", COLOR_MAGENTA | A_NORMAL }, - { "lightmagenta", COLOR_MAGENTA | A_BOLD }, - { "cyan", COLOR_CYAN | A_NORMAL }, - { "lightcyan", COLOR_CYAN | A_BOLD }, - { "white", COLOR_WHITE | A_BOLD }, - { NULL, 0 } +t_gui_color gui_weechat_colors[] = +{ { -1, 0, 0, "default" }, + { WEECHAT_COLOR_BLACK, 0, 0, "black" }, + { WEECHAT_COLOR_RED, 0, 0, "red" }, + { WEECHAT_COLOR_RED, 0, A_BOLD, "lightred" }, + { WEECHAT_COLOR_GREEN, 0, 0, "green" }, + { WEECHAT_COLOR_GREEN, 0, A_BOLD, "lightgreen" }, + { WEECHAT_COLOR_YELLOW, 0, 0, "brown" }, + { WEECHAT_COLOR_YELLOW, 0, A_BOLD, "yellow" }, + { WEECHAT_COLOR_BLUE, 0, 0, "blue" }, + { WEECHAT_COLOR_BLUE, 0, A_BOLD, "lightblue" }, + { WEECHAT_COLOR_MAGENTA, 0, 0, "magenta" }, + { WEECHAT_COLOR_MAGENTA, 0, A_BOLD, "lightmagenta" }, + { WEECHAT_COLOR_CYAN, 0, 0, "cyan" }, + { WEECHAT_COLOR_CYAN, 0, A_BOLD, "lightcyan" }, + { WEECHAT_COLOR_WHITE, 0, A_BOLD, "white" }, + { 0, 0, 0, NULL } }; -int color_attr[NUM_COLORS]; +int gui_irc_colors[16][2] = +{ { /* 0 */ WEECHAT_COLOR_WHITE, A_BOLD }, + { /* 1 */ WEECHAT_COLOR_BLACK, 0 }, + { /* 2 */ WEECHAT_COLOR_BLUE, 0 }, + { /* 3 */ WEECHAT_COLOR_GREEN, 0 }, + { /* 4 */ WEECHAT_COLOR_RED, A_BOLD }, + { /* 5 */ WEECHAT_COLOR_RED, 0 }, + { /* 6 */ WEECHAT_COLOR_MAGENTA, 0 }, + { /* 7 */ WEECHAT_COLOR_YELLOW, 0 }, + { /* 8 */ WEECHAT_COLOR_YELLOW, A_BOLD }, + { /* 9 */ WEECHAT_COLOR_GREEN, A_BOLD }, + { /* 10 */ WEECHAT_COLOR_CYAN, 0 }, + { /* 11 */ WEECHAT_COLOR_CYAN, A_BOLD }, + { /* 12 */ WEECHAT_COLOR_BLUE, A_BOLD }, + { /* 13 */ WEECHAT_COLOR_MAGENTA, A_BOLD }, + { /* 14 */ WEECHAT_COLOR_WHITE, 0 }, + { /* 15 */ WEECHAT_COLOR_WHITE, A_BOLD } +}; + +t_gui_color *gui_color[NUM_COLORS]; /* - * gui_assign_color: assign a color (read from config) + * gui_assign_color: assign a WeeChat color (read from config) */ int @@ -80,11 +99,11 @@ gui_assign_color (int *color, char *color_name) /* look for curses colors in table */ i = 0; - while (gui_colors[i].name) + while (gui_weechat_colors[i].string) { - if (ascii_strcasecmp (gui_colors[i].name, color_name) == 0) + if (ascii_strcasecmp (gui_weechat_colors[i].string, color_name) == 0) { - *color = gui_colors[i].color; + *color = i; return 1; } i++; @@ -95,79 +114,434 @@ gui_assign_color (int *color, char *color_name) } /* - * gui_get_color_by_name: get color by name + * gui_get_color_name: get color name */ -int -gui_get_color_by_name (char *color_name) +char * +gui_get_color_name (int num_color) { - int i; - - /* look for curses colors in table */ - i = 0; - while (gui_colors[i].name) + return gui_weechat_colors[num_color].string; +} + +/* + * gui_color_decode: parses a message (coming from IRC server), + * and according: + * - remove any color/style in message + * or: + * - change colors by codes to be compatible with + * other IRC clients + * After use, string returned has to be free() + */ + +unsigned char * +gui_color_decode (unsigned char *string, int keep_colors) +{ + unsigned char *out; + int out_length, out_pos; + char str_fg[3], str_bg[3]; + int fg, bg, attr; + + out_length = (strlen ((char *)string) * 2) + 1; + out = (unsigned char *)malloc (out_length); + if (!out) + return NULL; + + out_pos = 0; + while (string[0] && (out_pos < out_length - 1)) { - if (ascii_strcasecmp (gui_colors[i].name, color_name) == 0) - return gui_colors[i].color; - i++; + switch (string[0]) + { + case GUI_ATTR_BOLD_CHAR: + case GUI_ATTR_RESET_CHAR: + case GUI_ATTR_FIXED_CHAR: + case GUI_ATTR_REVERSE_CHAR: + case GUI_ATTR_REVERSE2_CHAR: + case GUI_ATTR_ITALIC_CHAR: + case GUI_ATTR_UNDERLINE_CHAR: + if (keep_colors) + out[out_pos++] = string[0]; + string++; + break; + case GUI_ATTR_COLOR_CHAR: + string++; + str_fg[0] = '\0'; + str_bg[0] = '\0'; + if (isdigit (string[0])) + { + str_fg[0] = string[0]; + str_fg[1] = '\0'; + string++; + if (isdigit (string[0])) + { + str_fg[1] = string[0]; + str_fg[2] = '\0'; + string++; + } + } + if (string[0] == ',') + { + string++; + if (isdigit (string[0])) + { + str_bg[0] = string[0]; + str_bg[1] = '\0'; + string++; + if (isdigit (string[0])) + { + str_bg[1] = string[0]; + str_bg[2] = '\0'; + string++; + } + } + } + if (keep_colors) + { + if (!str_fg[0] && !str_bg[0]) + out[out_pos++] = GUI_ATTR_COLOR_CHAR; + else + { + attr = 0; + if (str_fg[0]) + { + sscanf (str_fg, "%d", &fg); + fg %= 16; + attr |= gui_irc_colors[fg][1]; + } + if (str_bg[0]) + { + sscanf (str_bg, "%d", &bg); + bg %= 16; + attr |= gui_irc_colors[bg][1]; + } + if (attr & A_BOLD) + { + out[out_pos++] = GUI_ATTR_WEECHAT_SET_CHAR; + out[out_pos++] = GUI_ATTR_BOLD_CHAR; + } + else + { + out[out_pos++] = GUI_ATTR_WEECHAT_REMOVE_CHAR; + out[out_pos++] = GUI_ATTR_BOLD_CHAR; + } + out[out_pos++] = GUI_ATTR_COLOR_CHAR; + if (str_fg[0]) + { + out[out_pos++] = (gui_irc_colors[fg][0] / 10) + '0'; + out[out_pos++] = (gui_irc_colors[fg][0] % 10) + '0'; + } + if (str_bg[0]) + { + out[out_pos++] = ','; + out[out_pos++] = (gui_irc_colors[bg][0] / 10) + '0'; + out[out_pos++] = (gui_irc_colors[bg][0] % 10) + '0'; + } + } + } + break; + case GUI_ATTR_WEECHAT_SET_CHAR: + case GUI_ATTR_WEECHAT_REMOVE_CHAR: + string++; + if (string[0]) + { + if (keep_colors) + { + out[out_pos++] = *(string - 1); + out[out_pos++] = string[0]; + } + string++; + } + break; + default: + out[out_pos++] = string[0]; + string++; + } } - - /* color not found */ - return -1; + out[out_pos] = '\0'; + return out; } /* - * gui_get_color_by_value: get color name by value + * gui_color_encode: parses a message (entered by user), and + * encode special chars (%B, %C, ..) in IRC colors + * After use, string returned has to be free() */ -char * -gui_get_color_by_value (int color_value) +unsigned char * +gui_color_encode (unsigned char *string) { - int i; + unsigned char *out; + int out_length, out_pos; - /* look for curses colors in table */ - i = 0; - while (gui_colors[i].name) + out_length = strlen ((char *)string) + 1; + out = (unsigned char *)malloc (out_length); + if (!out) + return NULL; + + out_pos = 0; + while (string[0] && (out_pos < out_length - 1)) { - if (gui_colors[i].color == color_value) - return gui_colors[i].name; - i++; + switch (string[0]) + { + case '%': + string++; + switch (string[0]) + { + case 'B': /* bold */ + out[out_pos++] = GUI_ATTR_BOLD_CHAR; + string++; + break; + case 'C': /* color */ + out[out_pos++] = GUI_ATTR_COLOR_CHAR; + string++; + if (isdigit (string[0])) + { + out[out_pos++] = string[0]; + string++; + if (isdigit (string[0])) + { + out[out_pos++] = string[0]; + string++; + } + } + if (string[0] == ',') + { + out[out_pos++] = ','; + string++; + if (isdigit (string[0])) + { + out[out_pos++] = string[0]; + string++; + if (isdigit (string[0])) + { + out[out_pos++] = string[0]; + string++; + } + } + } + break; + case 'R': /* reverse */ + out[out_pos++] = GUI_ATTR_REVERSE_CHAR; + string++; + break; + case 'U': /* underline */ + out[out_pos++] = GUI_ATTR_UNDERLINE_CHAR; + string++; + break; + default: + out[out_pos++] = '%'; + out[out_pos++] = string[0]; + string++; + } + break; + default: + out[out_pos++] = string[0]; + string++; + } } + out[out_pos] = '\0'; + return out; +} + +/* + * gui_color_build: build a WeeChat color with foreground, + * background and attributes (attributes are + * given with foreground color, with a OR) + */ + +t_gui_color * +gui_color_build (int number, int foreground, int background) +{ + t_gui_color *new_color; + + new_color = (t_gui_color *)malloc (sizeof (t_gui_color)); + if (!new_color) + return NULL; + + new_color->foreground = gui_weechat_colors[foreground].foreground; + new_color->background = gui_weechat_colors[background].foreground; + new_color->attributes = gui_weechat_colors[foreground].attributes; + new_color->string = (char *)malloc (4); + if (new_color->string) + snprintf (new_color->string, 4, + "%s%02d", + GUI_ATTR_WEECHAT_COLOR_STR, number); + + return new_color; +} + +/* + * gui_color_get_pair: get color pair with a WeeChat color number + */ + +int +gui_color_get_pair (int num_color) +{ + int fg, bg; - /* color not found */ - return NULL; + fg = gui_color[num_color]->foreground; + bg = gui_color[num_color]->background; + + if (((fg == -1) || (fg == 99)) + && ((bg == -1) || (bg == 99))) + return 63; + if ((fg == -1) || (fg == 99)) + fg = WEECHAT_COLOR_WHITE; + if ((bg == -1) || (bg == 99)) + bg = 0; + + return (bg * 8) + fg; +} + +/* + * gui_window_set_weechat_color: set WeeChat color for window + */ + +void +gui_window_set_weechat_color (WINDOW *window, int num_color) +{ + if (has_colors ()) + { + wattroff (window, A_BOLD | A_UNDERLINE | A_REVERSE); + wattron (window, COLOR_PAIR(gui_color_get_pair (num_color)) | + gui_color[num_color]->attributes); + } +} + +/* + * gui_window_chat_set_style: set style (bold, underline, ..) + * for a chat window + */ + +void +gui_window_chat_set_style (t_gui_window *window, int style) +{ + if (has_colors ()) + { + wattron (window->win_chat, style); + } +} + +/* + * gui_window_chat_remove_style: remove style (bold, underline, ..) + * for a chat window + */ + +void +gui_window_chat_remove_style (t_gui_window *window, int style) +{ + if (has_colors ()) + { + wattroff (window->win_chat, style); + } +} + +/* + * gui_window_chat_toggle_style: toggle a style (bold, underline, ..) + * for a chat window + */ + +void +gui_window_chat_toggle_style (t_gui_window *window, int style) +{ + window->current_style_attr ^= style; + if (window->current_style_attr & style) + gui_window_chat_set_style (window, style); + else + gui_window_chat_remove_style (window, style); +} + +/* + * gui_window_chat_reset_style: reset style (color and attr) + * for a chat window + */ + +void +gui_window_chat_reset_style (t_gui_window *window) +{ + window->current_style_fg = -1; + window->current_style_bg = -1; + window->current_style_attr = 0; + window->current_color_attr = 0; + + gui_window_set_weechat_color (window->win_chat, COLOR_WIN_CHAT); + gui_window_chat_remove_style (window, + A_BOLD | A_UNDERLINE | A_REVERSE); +} + +/* + * gui_window_chat_set_color_style: set style for color + */ + +void +gui_window_chat_set_color_style (t_gui_window *window, int style) +{ + window->current_color_attr |= style; + wattron (window->win_chat, style); } /* - * gui_window_set_color: set color for window + * gui_window_chat_remove_color_style: remove style for color */ void -gui_window_set_color (WINDOW *window, int num_color) +gui_window_chat_remove_color_style (t_gui_window *window, int style) +{ + window->current_color_attr &= !style; + wattroff (window->win_chat, style); +} + +/* + * gui_window_chat_reset_color_style: reset style for color + */ + +void +gui_window_chat_reset_color_style (t_gui_window *window) +{ + wattroff (window->win_chat, window->current_color_attr); + window->current_color_attr = 0; +} + +/* + * gui_window_chat_set_color: set color for a chat window + */ + +void +gui_window_chat_set_color (t_gui_window *window, int fg, int bg) { if (has_colors ()) { - if (color_attr[num_color - 1] & A_BOLD) - wattron (window, COLOR_PAIR (num_color) | A_BOLD); + if (((fg == -1) || (fg == 99)) + && ((bg == -1) || (bg == 99))) + wattron (window->win_chat, COLOR_PAIR(63)); else { - wattroff (window, A_BOLD); - wattron (window, COLOR_PAIR (num_color)); + if ((fg == -1) || (fg == 99)) + fg = WEECHAT_COLOR_WHITE; + if ((bg == -1) || (bg == 99)) + bg = 0; + wattron (window->win_chat, COLOR_PAIR((bg * 8) + fg)); } } } /* - * gui_buffer_has_nicklist: returns 1 if buffer has nicklist + * gui_window_chat_set_weechat_color: set a WeeChat color for a chat window */ -int -gui_buffer_has_nicklist (t_gui_buffer *buffer) +void +gui_window_chat_set_weechat_color (t_gui_window *window, int weechat_color) { - return (((CHANNEL(buffer)) && (CHANNEL(buffer)->type == CHAT_CHANNEL)) ? 1 : 0); + if (has_colors ()) + { + gui_window_chat_reset_style (window); + gui_window_chat_set_style (window, + gui_color[weechat_color]->attributes); + gui_window_chat_set_color (window, + gui_color[weechat_color]->foreground, + gui_color[weechat_color]->background); + } } - /* * gui_calculate_pos_size: calculate position and size for a buffer & subwindows */ @@ -300,11 +674,12 @@ gui_calculate_pos_size (t_gui_window *window) */ void -gui_curses_window_clear (WINDOW *window) +gui_curses_window_clear (WINDOW *window, int num_color) { if (!gui_ok) return; + wbkgdset(window, ' ' | COLOR_PAIR (gui_color_get_pair (num_color))); werase (window); wmove (window, 0, 0); } @@ -325,7 +700,7 @@ gui_draw_window_separator (t_gui_window *window) 1, window->win_y, window->win_x - 1); - gui_window_set_color (window->win_separator, COLOR_WIN_TITLE); + gui_window_set_weechat_color (window->win_separator, COLOR_WIN_TITLE); wborder (window->win_separator, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); wnoutrefresh (window->win_separator); refresh (); @@ -350,9 +725,9 @@ gui_draw_buffer_title (t_gui_buffer *buffer, int erase) if (ptr_win->buffer == buffer) { if (erase) - gui_curses_window_clear (ptr_win->win_title); + gui_curses_window_clear (ptr_win->win_title, COLOR_WIN_TITLE); - gui_window_set_color (ptr_win->win_title, COLOR_WIN_TITLE); + gui_window_set_weechat_color (ptr_win->win_title, COLOR_WIN_TITLE); snprintf (format, 32, "%%-%ds", ptr_win->win_width); if (CHANNEL(buffer)) { @@ -395,15 +770,14 @@ void gui_display_new_line (t_gui_window *window, int num_lines, int count, int *lines_displayed, int simulate) { - char format_empty[32]; - if ((count == 0) || (*lines_displayed >= num_lines - count)) { if ((!simulate) && (window->win_chat_cursor_x <= window->win_chat_width - 1)) { - snprintf (format_empty, 32, "%%-%ds", - window->win_chat_width - window->win_chat_cursor_x); - wprintw (window->win_chat, format_empty, " "); + wmove (window->win_chat, + window->win_chat_cursor_y, + window->win_chat_cursor_x); + wclrtoeol (window->win_chat); } window->win_chat_cursor_y++; } @@ -412,20 +786,203 @@ gui_display_new_line (t_gui_window *window, int num_lines, int count, } /* - * gui_message_get_next_char: returns next char of message at offset + * gui_word_get_next_char: returns next char of a word + * special chars like colors, bold, .. are skipped + */ + +char * +gui_word_get_next_char (t_gui_window *window, unsigned char *string, int apply_style) +{ + char str_fg[3], str_bg[3]; + int fg, bg, weechat_color; + + while (string[0]) + { + switch (string[0]) + { + case GUI_ATTR_BOLD_CHAR: + string++; + if (apply_style) + gui_window_chat_toggle_style (window, A_BOLD); + break; + case GUI_ATTR_COLOR_CHAR: + string++; + str_fg[0] = '\0'; + str_bg[0] = '\0'; + fg = 99; + bg = 99; + if (isdigit (string[0])) + { + str_fg[0] = string[0]; + str_fg[1] = '\0'; + string++; + if (isdigit (string[0])) + { + str_fg[1] = string[0]; + str_fg[2] = '\0'; + string++; + } + } + if (string[0] == ',') + { + string++; + if (isdigit (string[0])) + { + str_bg[0] = string[0]; + str_bg[1] = '\0'; + string++; + if (isdigit (string[0])) + { + str_bg[1] = string[0]; + str_bg[2] = '\0'; + string++; + } + } + } + if (apply_style) + { + if (str_fg[0] || str_bg[0]) + { + if (str_fg[0]) + sscanf (str_fg, "%d", &fg); + else + fg = window->current_style_fg; + if (str_bg[0]) + sscanf (str_bg, "%d", &bg); + else + bg = window->current_style_bg; + } + if (!str_fg[0] && !str_bg[0]) + gui_window_chat_reset_color_style (window); + window->current_style_fg = fg; + window->current_style_bg = bg; + gui_window_chat_set_color (window, fg, bg); + } + break; + case GUI_ATTR_RESET_CHAR: + string++; + if (apply_style) + gui_window_chat_reset_style (window); + break; + case GUI_ATTR_FIXED_CHAR: + string++; + break; + case GUI_ATTR_REVERSE_CHAR: + case GUI_ATTR_REVERSE2_CHAR: + string++; + if (apply_style) + gui_window_chat_toggle_style (window, A_REVERSE); + break; + case GUI_ATTR_WEECHAT_COLOR_CHAR: + string++; + if (isdigit (string[0]) && isdigit (string[1])) + { + str_fg[0] = string[0]; + str_fg[1] = string[1]; + str_fg[2] = '\0'; + string += 2; + if (apply_style) + { + sscanf (str_fg, "%d", &weechat_color); + gui_window_chat_set_weechat_color (window, weechat_color); + } + } + break; + case GUI_ATTR_WEECHAT_SET_CHAR: + string++; + switch (string[0]) + { + case GUI_ATTR_BOLD_CHAR: + string++; + if (apply_style) + gui_window_chat_set_color_style (window, A_BOLD); + break; + case GUI_ATTR_REVERSE_CHAR: + case GUI_ATTR_REVERSE2_CHAR: + string++; + if (apply_style) + gui_window_chat_set_color_style (window, A_REVERSE); + break; + case GUI_ATTR_UNDERLINE_CHAR: + string++; + if (apply_style) + gui_window_chat_set_color_style (window, A_UNDERLINE); + break; + } + break; + case GUI_ATTR_WEECHAT_REMOVE_CHAR: + string++; + switch (string[0]) + { + case GUI_ATTR_BOLD_CHAR: + string++; + if (apply_style) + gui_window_chat_remove_color_style (window, A_BOLD); + break; + case GUI_ATTR_REVERSE_CHAR: + case GUI_ATTR_REVERSE2_CHAR: + string++; + if (apply_style) + gui_window_chat_remove_color_style (window, A_REVERSE); + break; + case GUI_ATTR_UNDERLINE_CHAR: + string++; + if (apply_style) + gui_window_chat_remove_color_style (window, A_UNDERLINE); + break; + } + break; + case GUI_ATTR_ITALIC_CHAR: + string++; + break; + case GUI_ATTR_UNDERLINE_CHAR: + string++; + if (apply_style) + gui_window_chat_toggle_style (window, A_UNDERLINE); + break; + default: + if (string[0] < 32) + string++; + else + return utf8_next_char ((char *)string); + } + + } + + /* nothing found except color/attrib codes, so return NULL */ + return NULL; +} + +/* + * gui_display_word_raw: display word on chat buffer, letter by letter + * special chars like color, bold, .. are interpreted */ void -gui_message_get_next_char (t_gui_message **message, int *offset) +gui_display_word_raw (t_gui_window *window, char *string) { - if (!(*message)) - return; + char *prev_char, *next_char, saved_char; + + wmove (window->win_chat, + window->win_chat_cursor_y, + window->win_chat_cursor_x); - (*offset) += utf8_char_size ((*message)->message + (*offset)); - if (!((*message)->message[*offset])) + while (string && string[0]) { - *message = (*message)->next_message; - *offset = 0; + next_char = gui_word_get_next_char (window, (unsigned char *)string, 1); + if (!next_char) + return; + + prev_char = utf8_prev_char (string, next_char); + if (prev_char) + { + saved_char = next_char[0]; + next_char[0] = '\0'; + wprintw (window->win_chat, "%s", prev_char); + next_char[0] = saved_char; + } + + string = next_char; } } @@ -434,35 +991,34 @@ gui_message_get_next_char (t_gui_message **message, int *offset) */ void -gui_display_word (t_gui_window *window, t_gui_line *line, - t_gui_message *message, int offset, - t_gui_message *end_msg, int end_offset, +gui_display_word (t_gui_window *window, + t_gui_line *line, + char *data, + char *end_offset, int num_lines, int count, int *lines_displayed, int simulate) { - char format_align[32]; - char saved_char_end, saved_char; - int pos_saved_char, end_of_word, chars_to_display, num_displayed; + char *end_line, saved_char_end, saved_char; + int pos_saved_char, chars_to_display, num_displayed; - if (!message || !end_msg || + if (!data || ((!simulate) && (window->win_chat_cursor_y > window->win_chat_height - 1))) return; - snprintf (format_align, 32, "%%-%ds", line->length_align); - - saved_char_end = '\0'; - if (end_msg) + end_line = data + strlen (data); + + if (end_offset[0]) + { + saved_char_end = end_offset[1]; + end_offset[1] = '\0'; + } + else { - saved_char_end = end_msg->message[end_offset + 1]; - end_msg->message[end_offset + 1] = '\0'; + end_offset = NULL; + saved_char_end = '\0'; } - end_of_word = 0; - while (!end_of_word) + while (data && data[0]) { - /* set text color if beginning of message */ - if (!simulate) - gui_window_set_color (window->win_chat, message->color); - /* insert spaces for align text under time/nick */ if ((line->length_align > 0) && (window->win_chat_cursor_x == 0) && @@ -471,77 +1027,55 @@ gui_display_word (t_gui_window *window, t_gui_line *line, (line->length_align < (window->win_chat_width - 5))) { if (!simulate) - mvwprintw (window->win_chat, - window->win_chat_cursor_y, - window->win_chat_cursor_x, - format_align, " "); + { + wmove (window->win_chat, + window->win_chat_cursor_y, + window->win_chat_cursor_x); + wclrtoeol (window->win_chat); + } window->win_chat_cursor_x += line->length_align; } - chars_to_display = utf8_strlen (message->message + offset); + chars_to_display = gui_word_strlen (window, data); /* too long for current line */ if (window->win_chat_cursor_x + chars_to_display > window->win_chat_width) { num_displayed = window->win_chat_width - window->win_chat_cursor_x; - pos_saved_char = utf8_real_pos (message->message + offset, num_displayed); - saved_char = message->message[offset + pos_saved_char]; - message->message[offset + pos_saved_char] = '\0'; + pos_saved_char = gui_word_real_pos (window, data, num_displayed); + saved_char = data[pos_saved_char]; + data[pos_saved_char] = '\0'; if ((!simulate) && ((count == 0) || (*lines_displayed >= num_lines - count))) - mvwprintw (window->win_chat, - window->win_chat_cursor_y, - window->win_chat_cursor_x, - "%s", message->message + offset); - message->message[offset + pos_saved_char] = saved_char; - offset += pos_saved_char; + gui_display_word_raw (window, data); + data[pos_saved_char] = saved_char; + data += pos_saved_char; } else { num_displayed = chars_to_display; if ((!simulate) && ((count == 0) || (*lines_displayed >= num_lines - count))) - mvwprintw (window->win_chat, - window->win_chat_cursor_y, - window->win_chat_cursor_x, - "%s", message->message + offset); - if (message == end_msg) - { - if (end_msg) - end_msg->message[end_offset + 1] = saved_char_end; - if (saved_char_end == '\0') - { - message = message->next_message; - offset = 0; - } - else - offset = end_offset + 1; - } - else - { - message = message->next_message; - offset = 0; - } + gui_display_word_raw (window, data); + data += strlen (data); } window->win_chat_cursor_x += num_displayed; /* display new line? */ - if (!message || + if ((data >= end_line) || ((window->win_chat_cursor_y <= window->win_chat_height - 1) && (window->win_chat_cursor_x > (window->win_chat_width - 1)))) gui_display_new_line (window, num_lines, count, lines_displayed, simulate); - /* end of word? */ - if (!message || (message->prev_message == end_msg) || - ((message == end_msg) && (offset > end_offset)) || + if ((data >= end_line) || (window->win_chat_cursor_y >= window->win_chat_height)) - end_of_word = 1; + data = NULL; } - - if (end_msg) - end_msg->message[end_offset + 1] = saved_char_end; + + if (end_offset) + end_offset[1] = saved_char_end; } /* @@ -549,39 +1083,57 @@ gui_display_word (t_gui_window *window, t_gui_line *line, */ void -gui_get_word_info (t_gui_message *message, int offset, - t_gui_message **word_start_msg, int *word_start_offset, - t_gui_message **word_end_msg, int *word_end_offset, +gui_get_word_info (t_gui_window *window, + char *data, + int *word_start_offset, int *word_end_offset, int *word_length_with_spaces, int *word_length) { - *word_start_msg = NULL; + char *start_data, *prev_char, *next_char; + int leading_spaces, char_size; + *word_start_offset = 0; - *word_end_msg = NULL; *word_end_offset = 0; *word_length_with_spaces = 0; *word_length = 0; - /* leading spaces */ - while (message && (message->message[offset] == ' ')) - { - (*word_length_with_spaces)++; - gui_message_get_next_char (&message, &offset); - } + start_data = data; - /* not only spaces? */ - if (message) + leading_spaces = 1; + while (data && data[0]) { - *word_start_msg = message; - *word_start_offset = offset; - - /* find end of word */ - while (message && (message->message[offset]) && (message->message[offset] != ' ')) + next_char = gui_word_get_next_char (window, (unsigned char *)data, 0); + if (next_char) { - *word_end_msg = message; - *word_end_offset = offset + utf8_char_size (message->message + offset) - 1; - (*word_length_with_spaces) += utf8_char_size (message->message + offset); - (*word_length) += utf8_char_size (message->message + offset); - gui_message_get_next_char (&message, &offset); + prev_char = utf8_prev_char (data, next_char); + if (prev_char) + { + if (prev_char[0] != ' ') + { + if (leading_spaces) + *word_start_offset = prev_char - start_data; + leading_spaces = 0; + char_size = next_char - prev_char; + *word_end_offset = next_char - start_data - 1; + (*word_length_with_spaces) += char_size; + (*word_length) += char_size; + } + else + { + if (leading_spaces) + (*word_length_with_spaces)++; + else + { + *word_end_offset = prev_char - start_data - 1; + return; + } + } + data = next_char; + } + } + else + { + *word_end_offset = data + strlen (data) - start_data - 1; + return; } } } @@ -598,11 +1150,12 @@ gui_get_word_info (t_gui_message *message, int offset, int gui_display_line (t_gui_window *window, t_gui_line *line, int count, int simulate) { - int num_lines, x, y, offset, lines_displayed; - t_gui_message *ptr_message, *word_start_msg, *word_end_msg; + int num_lines, x, y, lines_displayed; int word_start_offset, word_end_offset; int word_length_with_spaces, word_length; int skip_spaces; + char *ptr_data, *ptr_end_offset, *next_char, *prev_char; + char *ptr_style, saved_char; if (simulate) { @@ -623,17 +1176,22 @@ gui_display_line (t_gui_window *window, t_gui_line *line, int count, int simulat window->win_chat_cursor_y = y; } - ptr_message = line->messages; - offset = 0; + /* reset color & style for a new line */ + gui_window_chat_reset_style (window); + lines_displayed = 0; - while (ptr_message) + ptr_data = line->data; + while (ptr_data && ptr_data[0]) { skip_spaces = 0; - gui_get_word_info (ptr_message, offset, - &word_start_msg, &word_start_offset, - &word_end_msg, &word_end_offset, + gui_get_word_info (window, + ptr_data, + &word_start_offset, + &word_end_offset, &word_length_with_spaces, &word_length); + ptr_end_offset = ptr_data + word_end_offset; + if (word_length > 0) { /* spaces + word too long for current line */ @@ -642,8 +1200,20 @@ gui_display_line (t_gui_window *window, t_gui_line *line, int count, int simulat { gui_display_new_line (window, num_lines, count, &lines_displayed, simulate); - ptr_message = word_start_msg; - offset = word_start_offset; + /* apply styles before jumping to start of word */ + if (!simulate && (word_start_offset > 0)) + { + saved_char = ptr_data[word_start_offset]; + ptr_data[word_start_offset] = '\0'; + ptr_style = ptr_data; + while ((ptr_style = gui_word_get_next_char (window, (unsigned char *)ptr_style, 1)) != NULL) + { + /* loop until no style/char available */ + } + ptr_data[word_start_offset] = saved_char; + } + /* jump to start of word */ + ptr_data += word_start_offset; } /* word is exactly width => we'll skip next leading spaces for next line */ @@ -651,25 +1221,34 @@ gui_display_line (t_gui_window *window, t_gui_line *line, int count, int simulat skip_spaces = 1; /* display word */ - gui_display_word (window, line, - ptr_message, offset, - word_end_msg, word_end_offset, + gui_display_word (window, line, ptr_data, + ptr_end_offset, num_lines, count, &lines_displayed, simulate); if (window->win_chat_cursor_y >= window->win_chat_height) - ptr_message = NULL; + ptr_data = NULL; else { /* move pointer after end of word */ - ptr_message = word_end_msg; - offset = word_end_offset; - gui_message_get_next_char (&ptr_message, &offset); + ptr_data = ptr_end_offset + 1; + if (*(ptr_data - 1) == '\0') + ptr_data = NULL; /* skip leading spaces? */ if (skip_spaces) { - while (ptr_message && (ptr_message->message[offset] == ' ')) - gui_message_get_next_char (&ptr_message, &offset); + while (ptr_data && (ptr_data[0] == ' ')) + { + next_char = gui_word_get_next_char (window, + (unsigned char *)ptr_data, 0); + if (!next_char) + break; + prev_char = utf8_prev_char (ptr_data, next_char); + if (prev_char && (prev_char[0] == ' ')) + ptr_data = next_char; + else + break; + } } } } @@ -677,7 +1256,7 @@ gui_display_line (t_gui_window *window, t_gui_line *line, int count, int simulat { gui_display_new_line (window, num_lines, count, &lines_displayed, simulate); - ptr_message = NULL; + ptr_data = NULL; } } @@ -817,7 +1396,7 @@ gui_draw_buffer_chat (t_gui_buffer *buffer, int erase) { if (erase) { - gui_window_set_color (ptr_win->win_chat, COLOR_WIN_CHAT); + gui_window_set_weechat_color (ptr_win->win_chat, COLOR_WIN_CHAT); snprintf (format_empty, 32, "%%-%ds", ptr_win->win_chat_width); for (i = 0; i < ptr_win->win_chat_height; i++) @@ -826,7 +1405,7 @@ gui_draw_buffer_chat (t_gui_buffer *buffer, int erase) } } - gui_window_set_color (ptr_win->win_chat, COLOR_WIN_CHAT); + gui_window_set_weechat_color (ptr_win->win_chat, COLOR_WIN_CHAT); if (buffer->dcc) { @@ -839,9 +1418,9 @@ gui_draw_buffer_chat (t_gui_buffer *buffer, int erase) break; /* nickname and filename */ - gui_window_set_color (ptr_win->win_chat, - (ptr_dcc == dcc_selected) ? - COLOR_DCC_SELECTED : COLOR_WIN_CHAT); + gui_window_set_weechat_color (ptr_win->win_chat, + (ptr_dcc == dcc_selected) ? + COLOR_DCC_SELECTED : COLOR_WIN_CHAT); mvwprintw (ptr_win->win_chat, i, 0, "%s %-16s ", (ptr_dcc == dcc_selected) ? "***" : " ", ptr_dcc->nick); @@ -861,14 +1440,14 @@ gui_draw_buffer_chat (t_gui_buffer *buffer, int erase) } /* status */ - gui_window_set_color (ptr_win->win_chat, - (ptr_dcc == dcc_selected) ? - COLOR_DCC_SELECTED : COLOR_WIN_CHAT); + gui_window_set_weechat_color (ptr_win->win_chat, + (ptr_dcc == dcc_selected) ? + COLOR_DCC_SELECTED : COLOR_WIN_CHAT); mvwprintw (ptr_win->win_chat, i + 1, 0, "%s %s ", (ptr_dcc == dcc_selected) ? "***" : " ", (DCC_IS_RECV(ptr_dcc->type)) ? "-->>" : "<<--"); - gui_window_set_color (ptr_win->win_chat, - COLOR_DCC_WAITING + ptr_dcc->status); + gui_window_set_weechat_color (ptr_win->win_chat, + COLOR_DCC_WAITING + ptr_dcc->status); 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]) ? @@ -878,9 +1457,9 @@ gui_draw_buffer_chat (t_gui_buffer *buffer, int erase) free (buf); /* other infos */ - gui_window_set_color (ptr_win->win_chat, - (ptr_dcc == dcc_selected) ? - COLOR_DCC_SELECTED : COLOR_WIN_CHAT); + gui_window_set_weechat_color (ptr_win->win_chat, + (ptr_dcc == dcc_selected) ? + COLOR_DCC_SELECTED : COLOR_WIN_CHAT); if (DCC_IS_FILE(ptr_dcc->type)) { wprintw (ptr_win->win_chat, " ["); @@ -1021,7 +1600,7 @@ gui_draw_buffer_nick (t_gui_buffer *buffer, int erase) char format[32], format_empty[32]; t_irc_nick *ptr_nick; - if (!gui_ok) + if (!gui_ok || !BUFFER_HAS_NICKLIST(buffer)) return; for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) @@ -1030,7 +1609,7 @@ gui_draw_buffer_nick (t_gui_buffer *buffer, int erase) { if (erase) { - gui_window_set_color (ptr_win->win_nick, COLOR_WIN_NICK); + gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK); snprintf (format_empty, 32, "%%-%ds", ptr_win->win_nick_width); for (i = 0; i < ptr_win->win_nick_height; i++) @@ -1039,177 +1618,174 @@ gui_draw_buffer_nick (t_gui_buffer *buffer, int erase) } } - if (gui_buffer_has_nicklist (buffer)) + max_length = nick_get_max_length (CHANNEL(buffer)); + if ((buffer->num_displayed > 0) && + ((max_length + 2) != ptr_win->win_nick_width)) { - max_length = nick_get_max_length (CHANNEL(buffer)); - if ((buffer->num_displayed > 0) && - ((max_length + 2) != ptr_win->win_nick_width)) + gui_calculate_pos_size (ptr_win); + delwin (ptr_win->win_chat); + delwin (ptr_win->win_nick); + ptr_win->win_chat = newwin (ptr_win->win_chat_height, + ptr_win->win_chat_width, + ptr_win->win_chat_y, + ptr_win->win_chat_x); + ptr_win->win_nick = newwin (ptr_win->win_nick_height, + ptr_win->win_nick_width, + ptr_win->win_nick_y, + ptr_win->win_nick_x); + gui_draw_buffer_chat (buffer, 1); + + gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK); + + snprintf (format_empty, 32, "%%-%ds", ptr_win->win_nick_width); + for (i = 0; i < ptr_win->win_nick_height; i++) { - gui_calculate_pos_size (ptr_win); - delwin (ptr_win->win_chat); - delwin (ptr_win->win_nick); - ptr_win->win_chat = newwin (ptr_win->win_chat_height, - ptr_win->win_chat_width, - ptr_win->win_chat_y, - ptr_win->win_chat_x); - ptr_win->win_nick = newwin (ptr_win->win_nick_height, - ptr_win->win_nick_width, - ptr_win->win_nick_y, - ptr_win->win_nick_x); - gui_draw_buffer_chat (buffer, 1); - - gui_window_set_color (ptr_win->win_nick, COLOR_WIN_NICK); - - snprintf (format_empty, 32, "%%-%ds", ptr_win->win_nick_width); - for (i = 0; i < ptr_win->win_nick_height; i++) - { - mvwprintw (ptr_win->win_nick, i, 0, format_empty, " "); - } + mvwprintw (ptr_win->win_nick, i, 0, format_empty, " "); } - snprintf (format, 32, "%%.%ds", - ((cfg_look_nicklist_min_size > 0) - && (max_length < cfg_look_nicklist_min_size)) ? - cfg_look_nicklist_min_size : - (((cfg_look_nicklist_max_size > 0) - && (max_length > cfg_look_nicklist_max_size)) ? - cfg_look_nicklist_max_size : max_length)); - - if (has_colors ()) + } + snprintf (format, 32, "%%.%ds", + ((cfg_look_nicklist_min_size > 0) + && (max_length < cfg_look_nicklist_min_size)) ? + cfg_look_nicklist_min_size : + (((cfg_look_nicklist_max_size > 0) + && (max_length > cfg_look_nicklist_max_size)) ? + cfg_look_nicklist_max_size : max_length)); + + if (has_colors ()) + { + gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_SEP); + switch (cfg_look_nicklist_position) + { + case CFG_LOOK_NICKLIST_LEFT: + mvwvline (ptr_win->win_nick, + 0, ptr_win->win_nick_width - 1, ACS_VLINE, + ptr_win->win_chat_height); + break; + case CFG_LOOK_NICKLIST_RIGHT: + mvwvline (ptr_win->win_nick, + 0, 0, ACS_VLINE, + ptr_win->win_chat_height); + break; + case CFG_LOOK_NICKLIST_TOP: + mvwhline (ptr_win->win_nick, + ptr_win->win_nick_height - 1, 0, ACS_HLINE, + ptr_win->win_chat_width); + break; + case CFG_LOOK_NICKLIST_BOTTOM: + mvwhline (ptr_win->win_nick, + 0, 0, ACS_HLINE, + ptr_win->win_chat_width); + break; + } + } + + gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK); + x = 0; + y = (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM) ? 1 : 0; + column = 0; + + if ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) || + (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM)) + nicks_displayed = (ptr_win->win_width / (max_length + 2)) * (ptr_win->win_height - 1); + else + nicks_displayed = ptr_win->win_nick_height; + + ptr_nick = CHANNEL(buffer)->nicks; + for (i = 0; i < ptr_win->win_nick_start; i++) + { + if (!ptr_nick) + break; + ptr_nick = ptr_nick->next_nick; + } + if (ptr_nick) + { + for (i = 0; i < nicks_displayed; i++) { - gui_window_set_color (ptr_win->win_nick, COLOR_WIN_NICK_SEP); switch (cfg_look_nicklist_position) { case CFG_LOOK_NICKLIST_LEFT: - mvwvline (ptr_win->win_nick, - 0, ptr_win->win_nick_width - 1, ACS_VLINE, - ptr_win->win_chat_height); + x = 0; break; case CFG_LOOK_NICKLIST_RIGHT: - mvwvline (ptr_win->win_nick, - 0, 0, ACS_VLINE, - ptr_win->win_chat_height); + x = 1; break; case CFG_LOOK_NICKLIST_TOP: - mvwhline (ptr_win->win_nick, - ptr_win->win_nick_height - 1, 0, ACS_HLINE, - ptr_win->win_chat_width); - break; case CFG_LOOK_NICKLIST_BOTTOM: - mvwhline (ptr_win->win_nick, - 0, 0, ACS_HLINE, - ptr_win->win_chat_width); + x = column; break; } - } - - gui_window_set_color (ptr_win->win_nick, COLOR_WIN_NICK); - x = 0; - y = (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM) ? 1 : 0; - column = 0; - - if ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) || - (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM)) - nicks_displayed = (ptr_win->win_width / (max_length + 2)) * (ptr_win->win_height - 1); - else - nicks_displayed = ptr_win->win_nick_height; - - ptr_nick = CHANNEL(buffer)->nicks; - for (i = 0; i < ptr_win->win_nick_start; i++) - { - if (!ptr_nick) - break; - ptr_nick = ptr_nick->next_nick; - } - if (ptr_nick) - { - for (i = 0; i < nicks_displayed; i++) + if ( ((i == 0) && (ptr_win->win_nick_start > 0)) + || ((i == nicks_displayed - 1) && (ptr_nick->next_nick)) ) { - switch (cfg_look_nicklist_position) + gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_MORE); + j = (max_length + 1) >= 4 ? 4 : max_length + 1; + for (x = 1; x <= j; x++) + mvwprintw (ptr_win->win_nick, y, x, "+"); + } + else + { + if (ptr_nick->is_chanowner) + { + gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_CHANOWNER); + mvwprintw (ptr_win->win_nick, y, x, "~"); + x++; + } + else if (ptr_nick->is_chanadmin) + { + gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_CHANADMIN); + mvwprintw (ptr_win->win_nick, y, x, "&"); + x++; + } + else if (ptr_nick->is_op) { - case CFG_LOOK_NICKLIST_LEFT: - x = 0; - break; - case CFG_LOOK_NICKLIST_RIGHT: - x = 1; - break; - case CFG_LOOK_NICKLIST_TOP: - case CFG_LOOK_NICKLIST_BOTTOM: - x = column; - break; + gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_OP); + mvwprintw (ptr_win->win_nick, y, x, "@"); + x++; } - if ( ((i == 0) && (ptr_win->win_nick_start > 0)) - || ((i == nicks_displayed - 1) && (ptr_nick->next_nick)) ) + else if (ptr_nick->is_halfop) { - gui_window_set_color (ptr_win->win_nick, COLOR_WIN_NICK_MORE); - j = (max_length + 1) >= 4 ? 4 : max_length + 1; - for (x = 1; x <= j; x++) - mvwprintw (ptr_win->win_nick, y, x, "+"); + gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_HALFOP); + mvwprintw (ptr_win->win_nick, y, x, "%%"); + x++; + } + else if (ptr_nick->has_voice) + { + gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK_VOICE); + mvwprintw (ptr_win->win_nick, y, x, "+"); + x++; } else { - if (ptr_nick->is_chanowner) - { - gui_window_set_color (ptr_win->win_nick, COLOR_WIN_NICK_CHANOWNER); - mvwprintw (ptr_win->win_nick, y, x, "~"); - x++; - } - else if (ptr_nick->is_chanadmin) - { - gui_window_set_color (ptr_win->win_nick, COLOR_WIN_NICK_CHANADMIN); - mvwprintw (ptr_win->win_nick, y, x, "&"); - x++; - } - else if (ptr_nick->is_op) - { - gui_window_set_color (ptr_win->win_nick, COLOR_WIN_NICK_OP); - mvwprintw (ptr_win->win_nick, y, x, "@"); - x++; - } - else if (ptr_nick->is_halfop) - { - gui_window_set_color (ptr_win->win_nick, COLOR_WIN_NICK_HALFOP); - mvwprintw (ptr_win->win_nick, y, x, "%%"); - x++; - } - else if (ptr_nick->has_voice) - { - gui_window_set_color (ptr_win->win_nick, COLOR_WIN_NICK_VOICE); - mvwprintw (ptr_win->win_nick, y, x, "+"); - x++; - } - else - { - gui_window_set_color (ptr_win->win_nick, COLOR_WIN_NICK); - mvwprintw (ptr_win->win_nick, y, x, " "); - x++; - } - gui_window_set_color (ptr_win->win_nick, - ((cfg_irc_away_check > 0) && (ptr_nick->is_away)) ? - COLOR_WIN_NICK_AWAY : COLOR_WIN_NICK); - mvwprintw (ptr_win->win_nick, y, x, format, ptr_nick->nick); - - ptr_nick = ptr_nick->next_nick; - - if (!ptr_nick) - break; + gui_window_set_weechat_color (ptr_win->win_nick, COLOR_WIN_NICK); + mvwprintw (ptr_win->win_nick, y, x, " "); + x++; } - y++; - if ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) || - (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM)) + gui_window_set_weechat_color (ptr_win->win_nick, + ((cfg_irc_away_check > 0) && (ptr_nick->is_away)) ? + COLOR_WIN_NICK_AWAY : COLOR_WIN_NICK); + mvwprintw (ptr_win->win_nick, y, x, format, ptr_nick->nick); + + ptr_nick = ptr_nick->next_nick; + + if (!ptr_nick) + break; + } + y++; + if ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) || + (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM)) + { + if (y - ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM) ? 1 : 0) >= ptr_win->win_nick_height - 1) { - if (y - ((cfg_look_nicklist_position == CFG_LOOK_NICKLIST_BOTTOM) ? 1 : 0) >= ptr_win->win_nick_height - 1) - { - column += max_length + 2; - y = (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) ? - 0 : 1; - } + column += max_length + 2; + y = (cfg_look_nicklist_position == CFG_LOOK_NICKLIST_TOP) ? + 0 : 1; } } } } - wnoutrefresh (ptr_win->win_nick); - refresh (); } + wnoutrefresh (ptr_win->win_nick); + refresh (); } } @@ -1234,64 +1810,59 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) { - if (has_colors ()) - wbkgdset(ptr_win->win_status, ' ' | COLOR_PAIR (COLOR_WIN_STATUS)); - if (erase) - gui_curses_window_clear (ptr_win->win_status); + gui_curses_window_clear (ptr_win->win_status, COLOR_WIN_STATUS); - gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS); - /* wborder (ptr_win->win_status, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); */ - wmove (ptr_win->win_status, 0, 0); + gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS); /* display number of buffers */ - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DELIMITERS); - wprintw (ptr_win->win_status, "["); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); + mvwprintw (ptr_win->win_status, 0, 0, "["); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS); wprintw (ptr_win->win_status, "%d", (last_gui_buffer) ? last_gui_buffer->number : 0); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, "] "); /* display "<servers>" or current server */ if (ptr_win->buffer->all_servers) { wprintw (ptr_win->win_status, "["); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS); wprintw (ptr_win->win_status, _("<servers>")); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, "] "); } else if (SERVER(ptr_win->buffer) && SERVER(ptr_win->buffer)->name) { wprintw (ptr_win->win_status, "["); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS); wprintw (ptr_win->win_status, "%s", SERVER(ptr_win->buffer)->name); if (SERVER(ptr_win->buffer)->is_away) wprintw (ptr_win->win_status, _("(away)")); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, "] "); } /* infos about current buffer */ if (SERVER(ptr_win->buffer) && !CHANNEL(ptr_win->buffer)) { - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS); wprintw (ptr_win->win_status, "%d", ptr_win->buffer->number); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, ":"); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_CHANNEL); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_CHANNEL); if (SERVER(ptr_win->buffer)->is_connected) wprintw (ptr_win->win_status, "[%s] ", SERVER(ptr_win->buffer)->name); @@ -1303,35 +1874,35 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) server_get_number_buffer (SERVER(ptr_win->buffer), &server_pos, &server_total); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, "("); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS); wprintw (ptr_win->win_status, "%d", server_pos); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, "/"); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS); wprintw (ptr_win->win_status, "%d", server_total); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, ") "); } } if (SERVER(ptr_win->buffer) && CHANNEL(ptr_win->buffer)) { - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS); wprintw (ptr_win->win_status, "%d", ptr_win->buffer->number); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, ":"); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_CHANNEL); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_CHANNEL); if ((!CHANNEL(ptr_win->buffer)->nicks) && (CHANNEL(ptr_win->buffer)->type != CHAT_PRIVATE)) wprintw (ptr_win->win_status, "(%s)", @@ -1344,11 +1915,11 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) /* display channel modes */ if (CHANNEL(ptr_win->buffer)->type == CHAT_CHANNEL) { - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, "("); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS); i = 0; first_mode = 1; while (CHANNEL(ptr_win->buffer)->modes[i]) @@ -1371,40 +1942,40 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) if (CHANNEL(ptr_win->buffer)->modes[CHANNEL_MODE_LIMIT] != ' ') wprintw (ptr_win->win_status, ",%d", CHANNEL(ptr_win->buffer)->limit); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, ")"); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS); } /* display DCC if private is DCC CHAT */ if ((CHANNEL(ptr_win->buffer)->type == CHAT_PRIVATE) && (CHANNEL(ptr_win->buffer)->dcc_chat)) { - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, "("); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_CHANNEL); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_CHANNEL); wprintw (ptr_win->win_status, "DCC"); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, ")"); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS); } } wprintw (ptr_win->win_status, " "); } if (!SERVER(ptr_win->buffer)) { - gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS); + gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS); wprintw (ptr_win->win_status, "%d", ptr_win->buffer->number); - gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, ":"); - gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS_CHANNEL); + gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS_CHANNEL); if (ptr_win->buffer->dcc) wprintw (ptr_win->win_status, "<DCC> "); else @@ -1414,10 +1985,10 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) /* display list of other active windows (if any) with numbers */ if (hotlist) { - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, "["); - gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS); + gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS); wprintw (ptr_win->win_status, _("Act: ")); names_count = 0; @@ -1427,23 +1998,23 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) switch (ptr_hotlist->priority) { case HOTLIST_LOW: - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DATA_OTHER); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DATA_OTHER); display_name = ((cfg_look_hotlist_names_level & 1) != 0); break; case HOTLIST_MSG: - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DATA_MSG); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DATA_MSG); display_name = ((cfg_look_hotlist_names_level & 2) != 0); break; case HOTLIST_PRIVATE: - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DATA_PRIVATE); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DATA_PRIVATE); display_name = ((cfg_look_hotlist_names_level & 4) != 0); break; case HOTLIST_HIGHLIGHT: - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DATA_HIGHLIGHT); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DATA_HIGHLIGHT); display_name = ((cfg_look_hotlist_names_level & 8) != 0); break; default: @@ -1454,11 +2025,11 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) { wprintw (ptr_win->win_status, "%d", ptr_hotlist->buffer->number); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, ":"); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS); wprintw (ptr_win->win_status, "DCC"); } else @@ -1471,12 +2042,12 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) { names_count++; - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, ":"); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS); if (cfg_look_hotlist_names_length == 0) snprintf (format, sizeof (format) - 1, "%%s"); else @@ -1492,8 +2063,8 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) if (ptr_hotlist->next_hotlist) wprintw (ptr_win->win_status, ","); } - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, "] "); } @@ -1502,20 +2073,20 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) { if (SERVER(ptr_win->buffer)->lag / 1000 >= cfg_irc_lag_min_show) { - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, "["); - gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS); + gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS); wprintw (ptr_win->win_status, _("Lag: %.1f"), ((float)(SERVER(ptr_win->buffer)->lag)) / 1000); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, "]"); } } /* display "-MORE-" (if last line is not displayed) & nicks count */ - if (gui_buffer_has_nicklist (ptr_win->buffer)) + if (BUFFER_HAS_NICKLIST(ptr_win->buffer)) { snprintf (str_nicks, sizeof (str_nicks) - 1, "%d", CHANNEL(ptr_win->buffer)->nicks_count); x = ptr_win->win_width - strlen (str_nicks) - 4; @@ -1526,7 +2097,7 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) x -= strlen (more) - 1; if (x < 0) x = 0; - gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS_MORE); + gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS_MORE); if (ptr_win->start_line) mvwprintw (ptr_win->win_status, 0, x, "%s", more); else @@ -1534,15 +2105,15 @@ gui_draw_buffer_status (t_gui_buffer *buffer, int erase) snprintf (format, sizeof (format) - 1, "%%-%ds", (int)(strlen (more))); mvwprintw (ptr_win->win_status, 0, x, format, " "); } - if (gui_buffer_has_nicklist (ptr_win->buffer)) + if (BUFFER_HAS_NICKLIST(ptr_win->buffer)) { - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, " ["); - gui_window_set_color (ptr_win->win_status, COLOR_WIN_STATUS); + gui_window_set_weechat_color (ptr_win->win_status, COLOR_WIN_STATUS); wprintw (ptr_win->win_status, "%s", str_nicks); - gui_window_set_color (ptr_win->win_status, - COLOR_WIN_STATUS_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_status, + COLOR_WIN_STATUS_DELIMITERS); wprintw (ptr_win->win_status, "]"); } free (more); @@ -1575,7 +2146,7 @@ gui_draw_buffer_infobar_time (t_gui_buffer *buffer) local_time = localtime (&time_seconds); if (local_time) { - gui_window_set_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR); + gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR); mvwprintw (ptr_win->win_infobar, 0, 1, "%02d:%02d", @@ -1609,24 +2180,19 @@ gui_draw_buffer_infobar (t_gui_buffer *buffer, int erase) for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) { - if (has_colors ()) - wbkgdset(ptr_win->win_infobar, ' ' | COLOR_PAIR (COLOR_WIN_INFOBAR)); - if (erase) - gui_curses_window_clear (ptr_win->win_infobar); - - gui_window_set_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR); - /* wborder (ptr_win->win_infobar, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); */ - wmove (ptr_win->win_infobar, 0, 0); + gui_curses_window_clear (ptr_win->win_infobar, COLOR_WIN_INFOBAR); + + gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR); time_seconds = time (NULL); local_time = localtime (&time_seconds); if (local_time) { strftime (text_time, 1024, cfg_look_infobar_timestamp, local_time); - gui_window_set_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS); wprintw (ptr_win->win_infobar, "["); - gui_window_set_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR); + gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR); wprintw (ptr_win->win_infobar, "%02d:%02d", local_time->tm_hour, local_time->tm_min); @@ -1634,17 +2200,17 @@ gui_draw_buffer_infobar (t_gui_buffer *buffer, int erase) wprintw (ptr_win->win_infobar, ":%02d", local_time->tm_sec); - gui_window_set_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS); wprintw (ptr_win->win_infobar, "]"); - gui_window_set_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR); + gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR); wprintw (ptr_win->win_infobar, " %s", text_time); } if (gui_infobar) { - gui_window_set_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS); + gui_window_set_weechat_color (ptr_win->win_infobar, COLOR_WIN_INFOBAR_DELIMITERS); wprintw (ptr_win->win_infobar, " | "); - gui_window_set_color (ptr_win->win_infobar, gui_infobar->color); + gui_window_set_weechat_color (ptr_win->win_infobar, gui_infobar->color); wprintw (ptr_win->win_infobar, "%s", gui_infobar->text); } @@ -1662,13 +2228,13 @@ gui_get_input_width (t_gui_window *window) { if (CHANNEL(window->buffer)) return (window->win_width - strlen (CHANNEL(window->buffer)->name) - - strlen (SERVER(window->buffer)->nick) - 3); + strlen (SERVER(window->buffer)->nick) - 4); else { if (SERVER(window->buffer) && (SERVER(window->buffer)->is_connected)) - return (window->win_width - strlen (SERVER(window->buffer)->nick) - 2); + return (window->win_width - strlen (SERVER(window->buffer)->nick) - 3); else - return (window->win_width - strlen (cfg_look_no_nickname) - 2); + return (window->win_width - strlen (cfg_look_no_nickname) - 3); } } @@ -1693,14 +2259,7 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase) if (ptr_win->buffer == buffer) { if (erase) - gui_curses_window_clear (ptr_win->win_input); - - if (has_colors ()) - { - gui_window_set_color (ptr_win->win_input, COLOR_WIN_INPUT); - wborder (ptr_win->win_input, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); - wnoutrefresh (ptr_win->win_input); - } + gui_curses_window_clear (ptr_win->win_input, COLOR_WIN_INPUT); if (buffer->dcc) { @@ -1764,13 +2323,15 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase) } if (CHANNEL(buffer)) { - gui_window_set_color (ptr_win->win_input, COLOR_WIN_INPUT_CHANNEL); - mvwprintw (ptr_win->win_input, 0, 0, "%s ", CHANNEL(buffer)->name); - gui_window_set_color (ptr_win->win_input, COLOR_WIN_INPUT_NICK); + gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_DELIMITERS); + mvwprintw (ptr_win->win_input, 0, 0, "["); + gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_CHANNEL); + wprintw (ptr_win->win_input, "%s ", CHANNEL(buffer)->name); + gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_NICK); wprintw (ptr_win->win_input, "%s", SERVER(buffer)->nick); - gui_window_set_color (ptr_win->win_input, COLOR_WIN_INPUT_DELIMITERS); - wprintw (ptr_win->win_input, "> "); - gui_window_set_color (ptr_win->win_input, COLOR_WIN_INPUT); + gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_DELIMITERS); + wprintw (ptr_win->win_input, "] "); + gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT); snprintf (format, 32, "%%-%ds", input_width); if (ptr_win == gui_current_window) wprintw (ptr_win->win_input, format, @@ -1781,7 +2342,7 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase) ""); wclrtoeol (ptr_win->win_input); ptr_win->win_input_x = utf8_strlen (CHANNEL(buffer)->name) + - utf8_strlen (SERVER(buffer)->nick) + 3 + + utf8_strlen (SERVER(buffer)->nick) + 4 + (buffer->input_buffer_pos - buffer->input_buffer_1st_display); if (ptr_win == gui_current_window) move (ptr_win->win_y + ptr_win->win_height - 1, @@ -1789,15 +2350,17 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase) } else { - gui_window_set_color (ptr_win->win_input, COLOR_WIN_INPUT_NICK); + gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_DELIMITERS); + mvwprintw (ptr_win->win_input, 0, 0, "["); + gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_NICK); if (SERVER(buffer) && (SERVER(buffer)->is_connected)) ptr_nickname = SERVER(buffer)->nick; else ptr_nickname = cfg_look_no_nickname; - mvwprintw (ptr_win->win_input, 0, 0, "%s", ptr_nickname); - gui_window_set_color (ptr_win->win_input, COLOR_WIN_INPUT_DELIMITERS); - wprintw (ptr_win->win_input, "> "); - gui_window_set_color (ptr_win->win_input, COLOR_WIN_INPUT); + wprintw (ptr_win->win_input, "%s", ptr_nickname); + gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT_DELIMITERS); + wprintw (ptr_win->win_input, "] "); + gui_window_set_weechat_color (ptr_win->win_input, COLOR_WIN_INPUT); snprintf (format, 32, "%%-%ds", input_width); if (ptr_win == gui_current_window) wprintw (ptr_win->win_input, format, @@ -1807,7 +2370,7 @@ gui_draw_buffer_input (t_gui_buffer *buffer, int erase) wprintw (ptr_win->win_input, format, ""); wclrtoeol (ptr_win->win_input); - ptr_win->win_input_x = utf8_strlen (ptr_nickname) + 2 + + ptr_win->win_input_x = utf8_strlen (ptr_nickname) + 3 + (buffer->input_buffer_pos - buffer->input_buffer_1st_display); if (ptr_win == gui_current_window) move (ptr_win->win_y + ptr_win->win_height - 1, @@ -1932,11 +2495,17 @@ gui_switch_to_buffer (t_gui_window *window, t_gui_buffer *buffer) /* create status/infobar windows */ if (cfg_look_infobar) { - window->win_infobar = newwin (1, window->win_width, window->win_y + window->win_height - 2, window->win_x); - window->win_status = newwin (1, window->win_width, window->win_y + window->win_height - 3, window->win_x); + window->win_infobar = newwin (1, window->win_width, + window->win_y + window->win_height - 2, + window->win_x); + window->win_status = newwin (1, window->win_width, + window->win_y + window->win_height - 3, + window->win_x); } else - window->win_status = newwin (1, window->win_width, window->win_y + window->win_height - 2, window->win_x); + window->win_status = newwin (1, window->win_width, + window->win_y + window->win_height - 2, + window->win_x); window->start_line = NULL; window->start_line_pos = 0; @@ -2035,7 +2604,7 @@ gui_window_nick_beginning (t_gui_window *window) if (!gui_ok) return; - if (gui_buffer_has_nicklist (window->buffer)) + if (BUFFER_HAS_NICKLIST(window->buffer)) { if (window->win_nick_start > 0) { @@ -2057,7 +2626,7 @@ gui_window_nick_end (t_gui_window *window) if (!gui_ok) return; - if (gui_buffer_has_nicklist (window->buffer)) + if (BUFFER_HAS_NICKLIST(window->buffer)) { new_start = CHANNEL(window->buffer)->nicks_count - window->win_nick_height; @@ -2084,7 +2653,7 @@ gui_window_nick_page_up (t_gui_window *window) if (!gui_ok) return; - if (gui_buffer_has_nicklist (window->buffer)) + if (BUFFER_HAS_NICKLIST(window->buffer)) { if (window->win_nick_start > 0) { @@ -2106,7 +2675,7 @@ gui_window_nick_page_down (t_gui_window *window) if (!gui_ok) return; - if (gui_buffer_has_nicklist (window->buffer)) + if (BUFFER_HAS_NICKLIST(window->buffer)) { if ((CHANNEL(window->buffer)->nicks_count > window->win_nick_height) && (window->win_nick_start + window->win_nick_height - 1 @@ -2421,6 +2990,7 @@ gui_refresh_screen () } gui_current_window = old_current_window; + gui_switch_to_buffer (gui_current_window, gui_current_window->buffer); gui_redraw_buffer (gui_current_window->buffer); } @@ -2437,6 +3007,93 @@ gui_pre_init (int *argc, char **argv[]) } /* + * gui_init_weechat_colors: init WeeChat colors + */ + +void +gui_init_weechat_colors () +{ + int i; + + /* init WeeChat colors */ + gui_color[COLOR_WIN_TITLE] = gui_color_build (COLOR_WIN_TITLE, cfg_col_title, cfg_col_title_bg); + gui_color[COLOR_WIN_CHAT] = gui_color_build (COLOR_WIN_CHAT, cfg_col_chat, cfg_col_chat_bg); + gui_color[COLOR_WIN_CHAT_TIME] = gui_color_build (COLOR_WIN_CHAT_TIME, cfg_col_chat_time, cfg_col_chat_bg); + gui_color[COLOR_WIN_CHAT_TIME_SEP] = gui_color_build (COLOR_WIN_CHAT_TIME_SEP, cfg_col_chat_time_sep, cfg_col_chat_bg); + gui_color[COLOR_WIN_CHAT_PREFIX1] = gui_color_build (COLOR_WIN_CHAT_PREFIX1, cfg_col_chat_prefix1, cfg_col_chat_bg); + gui_color[COLOR_WIN_CHAT_PREFIX2] = gui_color_build (COLOR_WIN_CHAT_PREFIX2, cfg_col_chat_prefix2, cfg_col_chat_bg); + gui_color[COLOR_WIN_CHAT_SERVER] = gui_color_build (COLOR_WIN_CHAT_SERVER, cfg_col_chat_server, cfg_col_chat_bg); + gui_color[COLOR_WIN_CHAT_JOIN] = gui_color_build (COLOR_WIN_CHAT_JOIN, cfg_col_chat_join, cfg_col_chat_bg); + gui_color[COLOR_WIN_CHAT_PART] = gui_color_build (COLOR_WIN_CHAT_PART, cfg_col_chat_part, cfg_col_chat_bg); + gui_color[COLOR_WIN_CHAT_NICK] = gui_color_build (COLOR_WIN_CHAT_NICK, cfg_col_chat_nick, cfg_col_chat_bg); + gui_color[COLOR_WIN_CHAT_HOST] = gui_color_build (COLOR_WIN_CHAT_HOST, cfg_col_chat_host, cfg_col_chat_bg); + gui_color[COLOR_WIN_CHAT_CHANNEL] = gui_color_build (COLOR_WIN_CHAT_CHANNEL, cfg_col_chat_channel, cfg_col_chat_bg); + gui_color[COLOR_WIN_CHAT_DARK] = gui_color_build (COLOR_WIN_CHAT_DARK, cfg_col_chat_dark, cfg_col_chat_bg); + gui_color[COLOR_WIN_CHAT_HIGHLIGHT] = gui_color_build (COLOR_WIN_CHAT_HIGHLIGHT, cfg_col_chat_highlight, cfg_col_chat_bg); + gui_color[COLOR_WIN_STATUS] = gui_color_build (COLOR_WIN_STATUS, cfg_col_status, cfg_col_status_bg); + gui_color[COLOR_WIN_STATUS_DELIMITERS] = gui_color_build (COLOR_WIN_STATUS_DELIMITERS, cfg_col_status_delimiters, cfg_col_status_bg); + gui_color[COLOR_WIN_STATUS_CHANNEL] = gui_color_build (COLOR_WIN_STATUS_CHANNEL, cfg_col_status_channel, cfg_col_status_bg); + gui_color[COLOR_WIN_STATUS_DATA_MSG] = gui_color_build (COLOR_WIN_STATUS_DATA_MSG, cfg_col_status_data_msg, cfg_col_status_bg); + gui_color[COLOR_WIN_STATUS_DATA_PRIVATE] = gui_color_build (COLOR_WIN_STATUS_DATA_PRIVATE, cfg_col_status_data_private, cfg_col_status_bg); + gui_color[COLOR_WIN_STATUS_DATA_HIGHLIGHT] = gui_color_build (COLOR_WIN_STATUS_DATA_HIGHLIGHT, cfg_col_status_data_highlight, cfg_col_status_bg); + gui_color[COLOR_WIN_STATUS_DATA_OTHER] = gui_color_build (COLOR_WIN_STATUS_DATA_OTHER, cfg_col_status_data_other, cfg_col_status_bg); + gui_color[COLOR_WIN_STATUS_MORE] = gui_color_build (COLOR_WIN_STATUS_MORE, cfg_col_status_more, cfg_col_status_bg); + gui_color[COLOR_WIN_INFOBAR] = gui_color_build (COLOR_WIN_INFOBAR, cfg_col_infobar, cfg_col_infobar_bg); + gui_color[COLOR_WIN_INFOBAR_DELIMITERS] = gui_color_build (COLOR_WIN_INFOBAR_DELIMITERS, cfg_col_infobar_delimiters, cfg_col_infobar_bg); + gui_color[COLOR_WIN_INFOBAR_HIGHLIGHT] = gui_color_build (COLOR_WIN_INFOBAR_HIGHLIGHT, cfg_col_infobar_highlight, cfg_col_infobar_bg); + gui_color[COLOR_WIN_INPUT] = gui_color_build (COLOR_WIN_INPUT, cfg_col_input, cfg_col_input_bg); + gui_color[COLOR_WIN_INPUT_CHANNEL] = gui_color_build (COLOR_WIN_INPUT_CHANNEL, cfg_col_input_channel, cfg_col_input_bg); + gui_color[COLOR_WIN_INPUT_NICK] = gui_color_build (COLOR_WIN_INPUT_NICK, cfg_col_input_nick, cfg_col_input_bg); + gui_color[COLOR_WIN_INPUT_DELIMITERS] = gui_color_build (COLOR_WIN_INPUT_DELIMITERS, cfg_col_input_delimiters, cfg_col_input_bg); + gui_color[COLOR_WIN_NICK] = gui_color_build (COLOR_WIN_NICK, cfg_col_nick, cfg_col_nick_bg); + gui_color[COLOR_WIN_NICK_AWAY] = gui_color_build (COLOR_WIN_NICK_AWAY, cfg_col_nick_away, cfg_col_nick_bg); + gui_color[COLOR_WIN_NICK_CHANOWNER] = gui_color_build (COLOR_WIN_NICK_CHANOWNER, cfg_col_nick_chanowner, cfg_col_nick_bg); + gui_color[COLOR_WIN_NICK_CHANADMIN] = gui_color_build (COLOR_WIN_NICK_CHANADMIN, cfg_col_nick_chanadmin, cfg_col_nick_bg); + gui_color[COLOR_WIN_NICK_OP] = gui_color_build (COLOR_WIN_NICK_OP, cfg_col_nick_op, cfg_col_nick_bg); + gui_color[COLOR_WIN_NICK_HALFOP] = gui_color_build (COLOR_WIN_NICK_HALFOP, cfg_col_nick_halfop, cfg_col_nick_bg); + gui_color[COLOR_WIN_NICK_VOICE] = gui_color_build (COLOR_WIN_NICK_VOICE, cfg_col_nick_voice, cfg_col_nick_bg); + gui_color[COLOR_WIN_NICK_MORE] = gui_color_build (COLOR_WIN_NICK_MORE, cfg_col_nick_more, cfg_col_nick_bg); + gui_color[COLOR_WIN_NICK_SEP] = gui_color_build (COLOR_WIN_NICK_SEP, cfg_col_nick_sep, cfg_col_nick_bg); + gui_color[COLOR_WIN_NICK_SELF] = gui_color_build (COLOR_WIN_NICK_SELF, cfg_col_nick_self, cfg_col_nick_bg); + gui_color[COLOR_WIN_NICK_PRIVATE] = gui_color_build (COLOR_WIN_NICK_PRIVATE, cfg_col_nick_private, cfg_col_nick_bg); + + for (i = 0; i < COLOR_WIN_NICK_NUMBER; i++) + { + gui_color[COLOR_WIN_NICK_1 + i] = gui_color_build (COLOR_WIN_NICK_1 + i, cfg_col_nick_colors[i], cfg_col_chat_bg); + } + + gui_color[COLOR_DCC_SELECTED] = gui_color_build (COLOR_DCC_SELECTED, cfg_col_dcc_selected, cfg_col_chat_bg); + gui_color[COLOR_DCC_WAITING] = gui_color_build (COLOR_DCC_WAITING, cfg_col_dcc_waiting, cfg_col_chat_bg); + gui_color[COLOR_DCC_CONNECTING] = gui_color_build (COLOR_DCC_CONNECTING, cfg_col_dcc_connecting, cfg_col_chat_bg); + gui_color[COLOR_DCC_ACTIVE] = gui_color_build (COLOR_DCC_ACTIVE, cfg_col_dcc_active, cfg_col_chat_bg); + gui_color[COLOR_DCC_DONE] = gui_color_build (COLOR_DCC_DONE, cfg_col_dcc_done, cfg_col_chat_bg); + gui_color[COLOR_DCC_FAILED] = gui_color_build (COLOR_DCC_FAILED, cfg_col_dcc_failed, cfg_col_chat_bg); + gui_color[COLOR_DCC_ABORTED] = gui_color_build (COLOR_DCC_ABORTED, cfg_col_dcc_aborted, cfg_col_chat_bg); +} + +/* + * gui_rebuild_weechat_colors: rebuild WeeChat colors + */ + +void +gui_rebuild_weechat_colors () +{ + int i; + + for (i = 0; i < NUM_COLORS; i++) + { + if (gui_color[i]) + { + if (gui_color[i]->string) + free (gui_color[i]->string); + free (gui_color[i]); + gui_color[i] = NULL; + } + } + gui_init_weechat_colors (); +} + +/* * gui_init_colors: init GUI colors */ @@ -2444,162 +3101,23 @@ void gui_init_colors () { int i; + char shift_colors[8] = { 0, 4, 2, 6, 1, 5, 3, 7 }; if (has_colors ()) { start_color (); use_default_colors (); - init_pair (COLOR_WIN_TITLE, - cfg_col_title, cfg_col_title_bg); - init_pair (COLOR_WIN_CHAT, - cfg_col_chat, cfg_col_chat_bg); - init_pair (COLOR_WIN_CHAT_TIME, - cfg_col_chat_time, cfg_col_chat_bg); - init_pair (COLOR_WIN_CHAT_TIME_SEP, - cfg_col_chat_time_sep, cfg_col_chat_bg); - init_pair (COLOR_WIN_CHAT_PREFIX1, - cfg_col_chat_prefix1, cfg_col_chat_bg); - init_pair (COLOR_WIN_CHAT_PREFIX2, - cfg_col_chat_prefix2, cfg_col_chat_bg); - init_pair (COLOR_WIN_CHAT_SERVER, - cfg_col_chat_server, cfg_col_chat_bg); - init_pair (COLOR_WIN_CHAT_JOIN, - cfg_col_chat_join, cfg_col_chat_bg); - init_pair (COLOR_WIN_CHAT_PART, - cfg_col_chat_part, cfg_col_chat_bg); - init_pair (COLOR_WIN_CHAT_NICK, - cfg_col_chat_nick, cfg_col_chat_bg); - init_pair (COLOR_WIN_CHAT_HOST, - cfg_col_chat_host, cfg_col_chat_bg); - init_pair (COLOR_WIN_CHAT_CHANNEL, - cfg_col_chat_channel, cfg_col_chat_bg); - init_pair (COLOR_WIN_CHAT_DARK, - cfg_col_chat_dark, cfg_col_chat_bg); - init_pair (COLOR_WIN_CHAT_HIGHLIGHT, - cfg_col_chat_highlight, cfg_col_chat_bg); - init_pair (COLOR_WIN_STATUS, - cfg_col_status, cfg_col_status_bg); - init_pair (COLOR_WIN_STATUS_DELIMITERS, - cfg_col_status_delimiters, cfg_col_status_bg); - init_pair (COLOR_WIN_STATUS_CHANNEL, - cfg_col_status_channel, cfg_col_status_bg); - init_pair (COLOR_WIN_STATUS_DATA_MSG, - cfg_col_status_data_msg, cfg_col_status_bg); - init_pair (COLOR_WIN_STATUS_DATA_PRIVATE, - cfg_col_status_data_private, cfg_col_status_bg); - init_pair (COLOR_WIN_STATUS_DATA_HIGHLIGHT, - cfg_col_status_data_highlight, cfg_col_status_bg); - init_pair (COLOR_WIN_STATUS_DATA_OTHER, - cfg_col_status_data_other, cfg_col_status_bg); - init_pair (COLOR_WIN_STATUS_MORE, - cfg_col_status_more, cfg_col_status_bg); - init_pair (COLOR_WIN_INFOBAR, - cfg_col_infobar, cfg_col_infobar_bg); - init_pair (COLOR_WIN_INFOBAR_DELIMITERS, - cfg_col_infobar_delimiters, cfg_col_infobar_bg); - init_pair (COLOR_WIN_INFOBAR_HIGHLIGHT, - cfg_col_infobar_highlight, cfg_col_infobar_bg); - init_pair (COLOR_WIN_INPUT, - cfg_col_input, cfg_col_input_bg); - init_pair (COLOR_WIN_INPUT_CHANNEL, - cfg_col_input_channel, cfg_col_input_bg); - init_pair (COLOR_WIN_INPUT_NICK, - cfg_col_input_nick, cfg_col_input_bg); - init_pair (COLOR_WIN_INPUT_DELIMITERS, - cfg_col_input_delimiters, cfg_col_input_bg); - init_pair (COLOR_WIN_NICK, - cfg_col_nick, cfg_col_nick_bg); - init_pair (COLOR_WIN_NICK_AWAY, - cfg_col_nick_away, cfg_col_nick_bg); - init_pair (COLOR_WIN_NICK_CHANOWNER, - cfg_col_nick_chanowner, cfg_col_nick_bg); - init_pair (COLOR_WIN_NICK_CHANADMIN, - cfg_col_nick_chanadmin, cfg_col_nick_bg); - init_pair (COLOR_WIN_NICK_OP, - cfg_col_nick_op, cfg_col_nick_bg); - init_pair (COLOR_WIN_NICK_HALFOP, - cfg_col_nick_halfop, cfg_col_nick_bg); - init_pair (COLOR_WIN_NICK_VOICE, - cfg_col_nick_voice, cfg_col_nick_bg); - init_pair (COLOR_WIN_NICK_MORE, - cfg_col_nick_more, cfg_col_nick_bg); - init_pair (COLOR_WIN_NICK_SEP, - cfg_col_nick_sep, cfg_col_nick_bg); - init_pair (COLOR_WIN_NICK_SELF, - cfg_col_nick_self, cfg_col_nick_bg); - init_pair (COLOR_WIN_NICK_PRIVATE, - cfg_col_nick_private, cfg_col_nick_bg); + for (i = 1; i < COLOR_PAIRS; i++) + init_pair (i, shift_colors[i % 8], (i < 8) ? -1 : shift_colors[i / 8]); - for (i = 0; i < COLOR_WIN_NICK_NUMBER; i++) - { - init_pair (COLOR_WIN_NICK_FIRST + i, cfg_col_nick_colors[i], cfg_col_chat_bg); - color_attr[COLOR_WIN_NICK_FIRST + i - 1] = (cfg_col_nick_colors[i] >= 0) ? cfg_col_nick_colors[i] & A_BOLD : 0; - } + /* disable white on white, replaced by black on white */ + init_pair (63, -1, -1); - init_pair (COLOR_DCC_SELECTED, - cfg_col_dcc_selected, cfg_col_chat_bg); - init_pair (COLOR_DCC_WAITING, - cfg_col_dcc_waiting, cfg_col_chat_bg); - init_pair (COLOR_DCC_CONNECTING, - cfg_col_dcc_connecting, cfg_col_chat_bg); - init_pair (COLOR_DCC_ACTIVE, - cfg_col_dcc_active, cfg_col_chat_bg); - init_pair (COLOR_DCC_DONE, - cfg_col_dcc_done, cfg_col_chat_bg); - init_pair (COLOR_DCC_FAILED, - cfg_col_dcc_failed, cfg_col_chat_bg); - init_pair (COLOR_DCC_ABORTED, - cfg_col_dcc_aborted, cfg_col_chat_bg); - - color_attr[COLOR_WIN_TITLE - 1] = (cfg_col_title >= 0) ? cfg_col_title & A_BOLD : 0; - color_attr[COLOR_WIN_CHAT - 1] = (cfg_col_chat >= 0) ? cfg_col_chat & A_BOLD : 0; - color_attr[COLOR_WIN_CHAT_TIME - 1] = (cfg_col_chat_time >= 0) ? cfg_col_chat_time & A_BOLD : 0; - color_attr[COLOR_WIN_CHAT_TIME_SEP - 1] = (cfg_col_chat_time_sep >= 0) ? cfg_col_chat_time_sep & A_BOLD : 0; - color_attr[COLOR_WIN_CHAT_DARK - 1] = (cfg_col_chat_dark >= 0) ? cfg_col_chat_dark & A_BOLD : 0; - color_attr[COLOR_WIN_CHAT_PREFIX1 - 1] = (cfg_col_chat_prefix1 >= 0) ? cfg_col_chat_prefix1 & A_BOLD : 0; - color_attr[COLOR_WIN_CHAT_PREFIX2 - 1] = (cfg_col_chat_prefix2 >= 0) ? cfg_col_chat_prefix2 & A_BOLD : 0; - color_attr[COLOR_WIN_CHAT_SERVER - 1] = (cfg_col_chat_server >= 0) ? cfg_col_chat_server & A_BOLD : 0; - color_attr[COLOR_WIN_CHAT_JOIN - 1] = (cfg_col_chat_join >= 0) ? cfg_col_chat_join & A_BOLD : 0; - color_attr[COLOR_WIN_CHAT_PART - 1] = (cfg_col_chat_part >= 0) ? cfg_col_chat_part & A_BOLD : 0; - color_attr[COLOR_WIN_CHAT_NICK - 1] = (cfg_col_chat_nick >= 0) ? cfg_col_chat_nick & A_BOLD : 0; - color_attr[COLOR_WIN_CHAT_HOST - 1] = (cfg_col_chat_host >= 0) ? cfg_col_chat_host & A_BOLD : 0; - color_attr[COLOR_WIN_CHAT_CHANNEL - 1] = (cfg_col_chat_channel >= 0) ? cfg_col_chat_channel & A_BOLD : 0; - color_attr[COLOR_WIN_CHAT_DARK - 1] = (cfg_col_chat_dark >= 0) ? cfg_col_chat_dark & A_BOLD : 0; - color_attr[COLOR_WIN_CHAT_HIGHLIGHT - 1] = (cfg_col_chat_highlight >= 0) ? cfg_col_chat_highlight & A_BOLD : 0; - color_attr[COLOR_WIN_STATUS - 1] = (cfg_col_status >= 0) ? cfg_col_status & A_BOLD : 0; - color_attr[COLOR_WIN_STATUS_DELIMITERS - 1] = (cfg_col_status_delimiters >= 0) ? cfg_col_status_delimiters & A_BOLD : 0; - color_attr[COLOR_WIN_STATUS_CHANNEL - 1] = (cfg_col_status_channel >= 0) ? cfg_col_status_channel & A_BOLD : 0; - color_attr[COLOR_WIN_STATUS_DATA_MSG - 1] = (cfg_col_status_data_msg >= 0) ? cfg_col_status_data_msg & A_BOLD : 0; - color_attr[COLOR_WIN_STATUS_DATA_PRIVATE - 1] = (cfg_col_status_data_private >= 0) ? cfg_col_status_data_private & A_BOLD : 0; - color_attr[COLOR_WIN_STATUS_DATA_HIGHLIGHT - 1] = (cfg_col_status_data_highlight >= 0) ? cfg_col_status_data_highlight & A_BOLD : 0; - color_attr[COLOR_WIN_STATUS_DATA_OTHER - 1] = (cfg_col_status_data_other >= 0) ? cfg_col_status_data_other & A_BOLD : 0; - color_attr[COLOR_WIN_STATUS_MORE - 1] = (cfg_col_status_more >= 0) ? cfg_col_status_more & A_BOLD : 0; - color_attr[COLOR_WIN_INFOBAR - 1] = (cfg_col_infobar >= 0) ? cfg_col_infobar & A_BOLD : 0; - color_attr[COLOR_WIN_INFOBAR_DELIMITERS - 1] = (cfg_col_infobar_delimiters >= 0) ? cfg_col_infobar_delimiters & A_BOLD : 0; - color_attr[COLOR_WIN_INFOBAR_HIGHLIGHT - 1] = (cfg_col_infobar_highlight >= 0) ? cfg_col_infobar_highlight & A_BOLD : 0; - color_attr[COLOR_WIN_INPUT - 1] = (cfg_col_input >= 0) ? cfg_col_input & A_BOLD : 0; - color_attr[COLOR_WIN_INPUT_CHANNEL - 1] = (cfg_col_input_channel >= 0) ? cfg_col_input_channel & A_BOLD : 0; - color_attr[COLOR_WIN_INPUT_NICK - 1] = (cfg_col_input_nick >= 0) ? cfg_col_input_nick & A_BOLD : 0; - color_attr[COLOR_WIN_INPUT_DELIMITERS - 1] = (cfg_col_input_delimiters >= 0) ? cfg_col_input_delimiters & A_BOLD : 0; - color_attr[COLOR_WIN_NICK - 1] = (cfg_col_nick >= 0) ? cfg_col_nick & A_BOLD : 0; - color_attr[COLOR_WIN_NICK_AWAY - 1] = (cfg_col_nick_away >= 0) ? cfg_col_nick_away & A_BOLD : 0; - color_attr[COLOR_WIN_NICK_CHANOWNER - 1] = (cfg_col_nick_chanowner >= 0) ? cfg_col_nick_chanowner & A_BOLD : 0; - color_attr[COLOR_WIN_NICK_CHANADMIN - 1] = (cfg_col_nick_chanadmin >= 0) ? cfg_col_nick_chanadmin & A_BOLD : 0; - color_attr[COLOR_WIN_NICK_OP - 1] = (cfg_col_nick_op >= 0) ? cfg_col_nick_op & A_BOLD : 0; - color_attr[COLOR_WIN_NICK_HALFOP - 1] = (cfg_col_nick_halfop >= 0) ? cfg_col_nick_halfop & A_BOLD : 0; - color_attr[COLOR_WIN_NICK_VOICE - 1] = (cfg_col_nick_voice >= 0) ? cfg_col_nick_voice & A_BOLD : 0; - color_attr[COLOR_WIN_NICK_MORE - 1] = (cfg_col_nick_more >= 0) ? cfg_col_nick_more & A_BOLD : 0; - color_attr[COLOR_WIN_NICK_SEP - 1] = 0; - color_attr[COLOR_WIN_NICK_SELF - 1] = (cfg_col_nick_self >= 0) ? cfg_col_nick_self & A_BOLD : 0; - color_attr[COLOR_WIN_NICK_PRIVATE - 1] = (cfg_col_nick_private >= 0) ? cfg_col_nick_private & A_BOLD : 0; - color_attr[COLOR_DCC_SELECTED - 1] = (cfg_col_dcc_selected >= 0) ? cfg_col_dcc_selected & A_BOLD : 0; - color_attr[COLOR_DCC_WAITING - 1] = (cfg_col_dcc_waiting >= 0) ? cfg_col_dcc_waiting & A_BOLD : 0; - color_attr[COLOR_DCC_CONNECTING - 1] = (cfg_col_dcc_connecting >= 0) ? cfg_col_dcc_connecting & A_BOLD : 0; - color_attr[COLOR_DCC_ACTIVE - 1] = (cfg_col_dcc_active >= 0) ? cfg_col_dcc_active & A_BOLD : 0; - color_attr[COLOR_DCC_DONE - 1] = (cfg_col_dcc_done >= 0) ? cfg_col_dcc_done & A_BOLD : 0; - color_attr[COLOR_DCC_FAILED - 1] = (cfg_col_dcc_failed >= 0) ? cfg_col_dcc_failed & A_BOLD : 0; - color_attr[COLOR_DCC_ABORTED - 1] = (cfg_col_dcc_aborted >= 0) ? cfg_col_dcc_aborted & A_BOLD : 0; + /* white on default bg is default (-1) */ + init_pair (WEECHAT_COLOR_WHITE, -1, -1); + + gui_init_weechat_colors (); } } @@ -2705,243 +3223,3 @@ gui_end () refresh (); endwin (); } - -/* - * gui_add_message: add a message to a buffer - */ - -void -gui_add_message (t_gui_buffer *buffer, int type, int color, char *message) -{ - char *pos; - int length; - char *ptr_string; - - /* create new line if previous was ending by '\n' (or if 1st line) */ - if (buffer->line_complete) - { - buffer->line_complete = 0; - if (!gui_new_line (buffer)) - return; - } - if (!gui_new_message (buffer)) - return; - - buffer->last_line->last_message->type = type; - buffer->last_line->last_message->color = color; - pos = strchr (message, '\n'); - if (pos) - { - pos[0] = '\0'; - buffer->line_complete = 1; - } - buffer->last_line->last_message->message = strdup (message); - ptr_string = buffer->last_line->last_message->message; - while (ptr_string[0]) - { - if ((ptr_string[0] > 0) && (ptr_string[0] < 32)) - ptr_string[0] = 32; - ptr_string++; - } - length = utf8_strlen (message); - buffer->last_line->length += length; - if (type & MSG_TYPE_MSG) - buffer->last_line->line_with_message = 1; - if (type & MSG_TYPE_HIGHLIGHT) - buffer->last_line->line_with_highlight = 1; - if ((type & MSG_TYPE_TIME) || (type & MSG_TYPE_NICK) || (type & MSG_TYPE_PREFIX)) - buffer->last_line->length_align += length; - if (type & MSG_TYPE_NOLOG) - buffer->last_line->log_write = 0; - if (pos) - { - pos[0] = '\n'; - if (buffer->num_displayed > 0) - gui_draw_buffer_chat (buffer, 0); - if (gui_add_hotlist && (buffer->num_displayed == 0)) - { - if (3 - buffer->last_line->line_with_message - - buffer->last_line->line_with_highlight <= - buffer->notify_level) - { - if (buffer->last_line->line_with_highlight) - hotlist_add (HOTLIST_HIGHLIGHT, buffer); - else if (BUFFER_IS_PRIVATE(buffer) && (buffer->last_line->line_with_message)) - hotlist_add (HOTLIST_PRIVATE, buffer); - else if (buffer->last_line->line_with_message) - hotlist_add (HOTLIST_MSG, buffer); - else - hotlist_add (HOTLIST_LOW, buffer); - gui_draw_buffer_status (gui_current_window->buffer, 1); - } - } - } - if (buffer->line_complete && buffer->log_file && buffer->last_line->log_write) - log_write_line (buffer, buffer->last_line); -} - -/* - * gui_printf_internal: display a message in a buffer - * This function should NEVER be called directly. - * You should use macros defined in gui.h - */ - -void -gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, int color, char *message, ...) -{ - static char buf[8192]; - char text_time[1024]; - char text_time_char[2]; - time_t time_seconds; - struct tm *local_time; - int time_first_digit, time_last_digit; - char *pos, *buf2, *buf3; - int i, j; - va_list argptr; - static time_t seconds; - struct tm *date_tmp; - - if (gui_init_ok) - { - if (color == -1) - color = COLOR_WIN_CHAT; - - if (buffer == NULL) - { - type |= MSG_TYPE_NOLOG; - if (SERVER(gui_current_window->buffer)) - buffer = SERVER(gui_current_window->buffer)->buffer; - else - buffer = gui_current_window->buffer; - - if (!buffer || buffer->dcc) - buffer = gui_buffers; - } - - if (buffer == NULL) - { - wee_log_printf ("WARNING: gui_printf_internal without buffer! This is a bug, " - "please send to developers - thanks\n"); - return; - } - - if (buffer->dcc) - buffer = gui_buffers; - - if (buffer->dcc) - return; - } - - va_start (argptr, message); - vsnprintf (buf, sizeof (buf) - 1, message, argptr); - va_end (argptr); - - if (!buf[0]) - return; - - if (cfg_look_remove_colors_from_msgs) - { - buf2 = (char *) malloc (strlen (buf) + 2); - i = 0; - j = 0; - while (buf[i]) - { - if (buf[i] == 0x02) - i++; - else - { - if (buf[i] == 0x03) - { - if ((buf[i+1] >= '0') && (buf[i+1] <= '9') - && (buf[i+2] >= '0') && (buf[i+2] <= '9')) - i += 3; - else - i++; - } - else - buf2[j++] = buf[i++]; - } - } - buf2[j] = '\0'; - } - else - buf2 = strdup (buf); - - if (!local_utf8 || !utf8_is_valid (buf2)) - buf3 = 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, - buf2); - else - buf3 = strdup (buf2); - - if (gui_init_ok) - { - seconds = time (NULL); - date_tmp = localtime (&seconds); - - pos = buf3 - 1; - while (pos) - { - if (display_time - && cfg_look_buffer_timestamp && cfg_look_buffer_timestamp[0] - && ((!buffer->last_line) || (buffer->line_complete))) - { - time_seconds = time (NULL); - local_time = localtime (&time_seconds); - strftime (text_time, sizeof (text_time), cfg_look_buffer_timestamp, local_time); - - time_first_digit = -1; - time_last_digit = -1; - i = 0; - while (text_time[i]) - { - if (isdigit (text_time[i])) - { - if (time_first_digit == -1) - time_first_digit = i; - time_last_digit = i; - } - i++; - } - - text_time_char[1] = '\0'; - i = 0; - while (text_time[i]) - { - text_time_char[0] = text_time[i]; - if (time_first_digit < 0) - gui_add_message (buffer, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME, - text_time_char); - else - { - if ((i < time_first_digit) || (i > time_last_digit)) - gui_add_message (buffer, MSG_TYPE_TIME, COLOR_WIN_CHAT_DARK, - text_time_char); - else - { - if (isdigit (text_time[i])) - gui_add_message (buffer, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME, - text_time_char); - else - gui_add_message (buffer, MSG_TYPE_TIME, COLOR_WIN_CHAT_TIME_SEP, - text_time_char); - } - } - i++; - } - gui_add_message (buffer, MSG_TYPE_TIME, COLOR_WIN_CHAT_DARK, " "); - } - gui_add_message (buffer, type, color, pos + 1); - pos = strchr (pos + 1, '\n'); - if (pos && !pos[1]) - pos = NULL; - } - } - else - printf ("%s", buf3); - - free (buf2); - free (buf3); -} diff --git a/src/gui/gui-common.c b/src/gui/gui-common.c index 96066a30b..2f4c6163f 100644 --- a/src/gui/gui-common.c +++ b/src/gui/gui-common.c @@ -31,6 +31,7 @@ #include <string.h> #include <signal.h> #include <time.h> +#include <ctype.h> #include "../common/weechat.h" #include "gui.h" @@ -302,19 +303,12 @@ gui_buffer_clear (t_gui_buffer *buffer) { t_gui_window *ptr_win; t_gui_line *ptr_line; - t_gui_message *ptr_message; while (buffer->lines) { ptr_line = buffer->lines->next_line; - while (buffer->lines->messages) - { - ptr_message = buffer->lines->messages->next_message; - if (buffer->lines->messages->message) - free (buffer->lines->messages->message); - free (buffer->lines->messages); - buffer->lines->messages = ptr_message; - } + if (buffer->lines->data) + free (buffer->lines->data); free (buffer->lines); buffer->lines = ptr_line; } @@ -351,47 +345,6 @@ gui_buffer_clear_all () gui_buffer_clear (ptr_buffer); } -/* - * gui_infobar_printf: display message in infobar - */ - -void -gui_infobar_printf (int time_displayed, int color, char *message, ...) -{ - static char buffer[1024]; - va_list argptr; - t_gui_infobar *ptr_infobar; - char *pos, *buf2; - - va_start (argptr, message); - vsnprintf (buffer, sizeof (buffer) - 1, message, argptr); - va_end (argptr); - - 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, - buffer); - - ptr_infobar = (t_gui_infobar *)malloc (sizeof (t_gui_infobar)); - if (ptr_infobar) - { - ptr_infobar->color = color; - ptr_infobar->text = strdup (buf2); - pos = strchr (ptr_infobar->text, '\n'); - if (pos) - pos[0] = '\0'; - ptr_infobar->remaining_time = (time_displayed <= 0) ? -1 : time_displayed; - ptr_infobar->next_infobar = gui_infobar; - gui_infobar = ptr_infobar; - gui_draw_buffer_infobar (gui_current_window->buffer, 1); - } - else - wee_log_printf (_("Not enough memory for infobar message\n")); - - free (buf2); -} - /* * gui_window_free: delete a window */ @@ -416,25 +369,6 @@ gui_window_free (t_gui_window *window) } /* - * gui_infobar_remove: remove last displayed message in infobar - */ - -void -gui_infobar_remove () -{ - t_gui_infobar *new_infobar; - - if (gui_infobar) - { - new_infobar = gui_infobar->next_infobar; - if (gui_infobar->text) - free (gui_infobar->text); - free (gui_infobar); - gui_infobar = new_infobar; - } -} - -/* * gui_line_free: delete a line from a buffer */ @@ -442,8 +376,7 @@ void gui_line_free (t_gui_line *line) { t_gui_window *ptr_win; - t_gui_message *ptr_message; - + for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) { if (ptr_win->start_line == line) @@ -452,14 +385,8 @@ gui_line_free (t_gui_line *line) ptr_win->start_line_pos = 0; } } - while (line->messages) - { - ptr_message = line->messages->next_message; - if (line->messages->message) - free (line->messages->message); - free (line->messages); - line->messages = ptr_message; - } + if (line->data) + free (line->data); free (line); } @@ -566,8 +493,7 @@ gui_new_line (t_gui_buffer *buffer) new_line->log_write = 1; new_line->line_with_message = 0; new_line->line_with_highlight = 0; - new_line->messages = NULL; - new_line->last_message = NULL; + new_line->data = NULL; if (!buffer->lines) buffer->lines = new_line; else @@ -602,30 +528,345 @@ gui_new_line (t_gui_buffer *buffer) } /* - * gui_new_message: create a new message for last line of a buffer + * gui_word_strlen: returns length of a word + * special chars like color, bold, .. are ignored + */ + +int +gui_word_strlen (t_gui_window *window, char *string) +{ + int length; + + length = 0; + while (string && string[0]) + { + string = gui_word_get_next_char (window, (unsigned char *)string, 0); + if (string) + length++; + } + return length; +} + +/* + * gui_word_real_pos: get real position in string (ignoring color/bold/.. chars) + */ + +int +gui_word_real_pos (t_gui_window *window, char *string, int pos) +{ + char *saved_pos; + int real_pos; + + if (pos <= 0) + return 0; + + real_pos = 0; + while (string && string[0] && (pos > 0)) + { + saved_pos = string; + string = gui_word_get_next_char (window, (unsigned char *)string, 0); + pos--; + if (string) + real_pos += (string - saved_pos); + } + return real_pos; +} + +/* + * gui_add_to_line: add a message to last line of buffer */ -t_gui_message * -gui_new_message (t_gui_buffer *buffer) +void +gui_add_to_line (t_gui_buffer *buffer, int type, char *message) { - t_gui_message *new_message; + char *pos; + int length; - if ((new_message = (t_gui_message *) malloc (sizeof (struct t_gui_message)))) + /* create new line if previous was ending by '\n' (or if 1st line) */ + if (buffer->line_complete) { - if (!buffer->last_line->messages) - buffer->last_line->messages = new_message; + buffer->line_complete = 0; + if (!gui_new_line (buffer)) + return; + } + + pos = strchr (message, '\n'); + if (pos) + { + pos[0] = '\0'; + buffer->line_complete = 1; + } + if (buffer->last_line->data) + { + buffer->last_line->data = (char *) realloc (buffer->last_line->data, + strlen (buffer->last_line->data) + + strlen (message) + 1); + strcat (buffer->last_line->data, message); + } + else + buffer->last_line->data = strdup (message); + + length = gui_word_strlen (NULL, message); + buffer->last_line->length += length; + if (type & MSG_TYPE_MSG) + buffer->last_line->line_with_message = 1; + if (type & MSG_TYPE_HIGHLIGHT) + buffer->last_line->line_with_highlight = 1; + if ((type & MSG_TYPE_TIME) || (type & MSG_TYPE_NICK) || (type & MSG_TYPE_PREFIX)) + buffer->last_line->length_align += length; + if (type & MSG_TYPE_NOLOG) + buffer->last_line->log_write = 0; + if (pos) + { + pos[0] = '\n'; + if (buffer->num_displayed > 0) + gui_draw_buffer_chat (buffer, 0); + if (gui_add_hotlist && (buffer->num_displayed == 0)) + { + if (3 - buffer->last_line->line_with_message - + buffer->last_line->line_with_highlight <= + buffer->notify_level) + { + if (buffer->last_line->line_with_highlight) + hotlist_add (HOTLIST_HIGHLIGHT, buffer); + else if (BUFFER_IS_PRIVATE(buffer) && (buffer->last_line->line_with_message)) + hotlist_add (HOTLIST_PRIVATE, buffer); + else if (buffer->last_line->line_with_message) + hotlist_add (HOTLIST_MSG, buffer); + else + hotlist_add (HOTLIST_LOW, buffer); + gui_draw_buffer_status (gui_current_window->buffer, 1); + } + } + } + if (buffer->line_complete && buffer->log_file && buffer->last_line->log_write) + { + log_write (buffer, buffer->last_line->data); + log_write (buffer, "\n"); + } +} + +/* + * gui_printf_internal: display a message in a buffer + * This function should NEVER be called directly. + * You should use macros defined in gui.h + */ + +void +gui_printf_internal (t_gui_buffer *buffer, int display_time, int type, char *message, ...) +{ + static char buf[8192]; + char text_time[1024]; + char text_time_char[2]; + time_t time_seconds; + struct tm *local_time; + int time_first_digit, time_last_digit; + char *pos, *buf2; + int i; + va_list argptr; + static time_t seconds; + struct tm *date_tmp; + + if (gui_init_ok) + { + if (buffer == NULL) + { + type |= MSG_TYPE_NOLOG; + if (SERVER(gui_current_window->buffer)) + buffer = SERVER(gui_current_window->buffer)->buffer; + else + buffer = gui_current_window->buffer; + + if (!buffer || buffer->dcc) + buffer = gui_buffers; + } + + if (buffer == NULL) + { + wee_log_printf ("WARNING: gui_printf_internal without buffer! This is a bug, " + "please send to developers - thanks\n"); + return; + } + + if (buffer->dcc) + buffer = gui_buffers; + + if (buffer->dcc) + return; + } + + va_start (argptr, message); + vsnprintf (buf, sizeof (buf) - 1, message, argptr); + va_end (argptr); + + if (!buf[0]) + return; + + if (!local_utf8 || !utf8_is_valid (buf)) + 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); + else + buf2 = strdup (buf); + + if (gui_init_ok) + { + seconds = time (NULL); + date_tmp = localtime (&seconds); + + pos = buf2 - 1; + while (pos) + { + if (display_time + && cfg_look_buffer_timestamp && cfg_look_buffer_timestamp[0] + && ((!buffer->last_line) || (buffer->line_complete))) + { + time_seconds = time (NULL); + local_time = localtime (&time_seconds); + strftime (text_time, sizeof (text_time), cfg_look_buffer_timestamp, local_time); + + time_first_digit = -1; + time_last_digit = -1; + i = 0; + while (text_time[i]) + { + if (isdigit (text_time[i])) + { + if (time_first_digit == -1) + time_first_digit = i; + time_last_digit = i; + } + i++; + } + + text_time_char[1] = '\0'; + i = 0; + while (text_time[i]) + { + text_time_char[0] = text_time[i]; + if (time_first_digit < 0) + { + gui_add_to_line (buffer, MSG_TYPE_TIME, + GUI_COLOR(COLOR_WIN_CHAT_TIME)); + gui_add_to_line (buffer, MSG_TYPE_TIME, text_time_char); + } + else + { + if ((i < time_first_digit) || (i > time_last_digit)) + { + gui_add_to_line (buffer, MSG_TYPE_TIME, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); + gui_add_to_line (buffer, MSG_TYPE_TIME, text_time_char); + } + else + { + if (isdigit (text_time[i])) + { + gui_add_to_line (buffer, MSG_TYPE_TIME, + GUI_COLOR(COLOR_WIN_CHAT_TIME)); + gui_add_to_line (buffer, MSG_TYPE_TIME, text_time_char); + } + else + { + gui_add_to_line (buffer, MSG_TYPE_TIME, + GUI_COLOR(COLOR_WIN_CHAT_TIME_SEP)); + gui_add_to_line (buffer, MSG_TYPE_TIME, text_time_char); + } + } + } + i++; + } + gui_add_to_line (buffer, MSG_TYPE_TIME, GUI_COLOR(COLOR_WIN_CHAT)); + gui_add_to_line (buffer, MSG_TYPE_TIME, " "); + } + gui_add_to_line (buffer, type, pos + 1); + pos = strchr (pos + 1, '\n'); + if (pos && !pos[1]) + pos = NULL; + } + } + else + printf ("%s", buf2); + + free (buf2); +} + +/* + * gui_infobar_printf: display message in infobar + */ + +void +gui_infobar_printf (int time_displayed, int color, char *message, ...) +{ + static char buffer[1024]; + va_list argptr; + t_gui_infobar *ptr_infobar; + char *pos, *buf2, *buf3; + + va_start (argptr, message); + vsnprintf (buffer, sizeof (buffer) - 1, message, argptr); + va_end (argptr); + + buf2 = (char *)gui_color_decode ((unsigned char *)buffer, 0); + + if (buf2) + { + if (!local_utf8 || !utf8_is_valid (buf2)) + buf3 = 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, + buf2); else - buffer->last_line->last_message->next_message = new_message; - new_message->prev_message = buffer->last_line->last_message; - new_message->next_message = NULL; - buffer->last_line->last_message = new_message; + buf3 = strdup (buf2); } else + buf3 = NULL; + + if (buf3) { - wee_log_printf (_("Not enough memory for new message\n")); - return NULL; + ptr_infobar = (t_gui_infobar *)malloc (sizeof (t_gui_infobar)); + if (ptr_infobar) + { + ptr_infobar->color = color; + ptr_infobar->text = strdup (buf3); + pos = strchr (ptr_infobar->text, '\n'); + if (pos) + pos[0] = '\0'; + ptr_infobar->remaining_time = (time_displayed <= 0) ? -1 : time_displayed; + ptr_infobar->next_infobar = gui_infobar; + gui_infobar = ptr_infobar; + gui_draw_buffer_infobar (gui_current_window->buffer, 1); + } + else + wee_log_printf (_("Not enough memory for infobar message\n")); + } + + if (buf2) + free (buf2); + if (buf3) + free (buf3); +} + +/* + * gui_infobar_remove: remove last displayed message in infobar + */ + +void +gui_infobar_remove () +{ + t_gui_infobar *new_infobar; + + if (gui_infobar) + { + new_infobar = gui_infobar->next_infobar; + if (gui_infobar->text) + free (gui_infobar->text); + free (gui_infobar); + gui_infobar = new_infobar; } - return new_message; } /* @@ -1219,9 +1460,7 @@ void gui_buffer_print_log (t_gui_buffer *buffer) { t_gui_line *ptr_line; - t_gui_message *ptr_message; int num; - char buf[4096]; wee_log_printf ("[buffer (addr:0x%X)]\n", buffer); wee_log_printf (" num_displayed. . . . : %d\n", buffer->num_displayed); @@ -1266,16 +1505,10 @@ gui_buffer_print_log (t_gui_buffer *buffer) while (ptr_line) { - buf[0] = '\0'; - for (ptr_message = ptr_line->messages; ptr_message; - ptr_message = ptr_message->next_message) - { - if (strlen (buf) + strlen (ptr_message->message) + 1 >= sizeof (buf)) - break; - strcat (buf, ptr_message->message); - } num--; - wee_log_printf (" line N-%05d: %s\n", num, buf); + wee_log_printf (" line N-%05d: %s\n", + num, + (ptr_line->data) ? ptr_line->data : "(empty)"); ptr_line = ptr_line->next_line; } diff --git a/src/gui/gui.h b/src/gui/gui.h index fdc5f4493..09f13dbca 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -26,57 +26,114 @@ #define INPUT_BUFFER_BLOCK_SIZE 256 -#define NUM_COLORS 57 -#define COLOR_WIN_TITLE 1 -#define COLOR_WIN_CHAT 2 -#define COLOR_WIN_CHAT_TIME 3 -#define COLOR_WIN_CHAT_TIME_SEP 4 -#define COLOR_WIN_CHAT_PREFIX1 5 -#define COLOR_WIN_CHAT_PREFIX2 6 -#define COLOR_WIN_CHAT_SERVER 7 -#define COLOR_WIN_CHAT_JOIN 8 -#define COLOR_WIN_CHAT_PART 9 -#define COLOR_WIN_CHAT_NICK 10 -#define COLOR_WIN_CHAT_HOST 11 -#define COLOR_WIN_CHAT_CHANNEL 12 -#define COLOR_WIN_CHAT_DARK 13 -#define COLOR_WIN_CHAT_HIGHLIGHT 14 -#define COLOR_WIN_STATUS 15 -#define COLOR_WIN_STATUS_DELIMITERS 16 -#define COLOR_WIN_STATUS_CHANNEL 17 -#define COLOR_WIN_STATUS_DATA_MSG 18 -#define COLOR_WIN_STATUS_DATA_PRIVATE 19 -#define COLOR_WIN_STATUS_DATA_HIGHLIGHT 20 -#define COLOR_WIN_STATUS_DATA_OTHER 21 -#define COLOR_WIN_STATUS_MORE 22 -#define COLOR_WIN_INFOBAR 23 -#define COLOR_WIN_INFOBAR_DELIMITERS 24 -#define COLOR_WIN_INFOBAR_HIGHLIGHT 25 -#define COLOR_WIN_INPUT 26 -#define COLOR_WIN_INPUT_CHANNEL 27 -#define COLOR_WIN_INPUT_NICK 28 -#define COLOR_WIN_INPUT_DELIMITERS 29 -#define COLOR_WIN_NICK 30 -#define COLOR_WIN_NICK_AWAY 31 -#define COLOR_WIN_NICK_CHANOWNER 32 -#define COLOR_WIN_NICK_CHANADMIN 33 -#define COLOR_WIN_NICK_OP 34 -#define COLOR_WIN_NICK_HALFOP 35 -#define COLOR_WIN_NICK_VOICE 36 -#define COLOR_WIN_NICK_MORE 37 -#define COLOR_WIN_NICK_SEP 38 -#define COLOR_WIN_NICK_SELF 39 -#define COLOR_WIN_NICK_PRIVATE 40 -#define COLOR_WIN_NICK_FIRST 41 -#define COLOR_WIN_NICK_LAST 50 -#define COLOR_WIN_NICK_NUMBER (COLOR_WIN_NICK_LAST - COLOR_WIN_NICK_FIRST + 1) -#define COLOR_DCC_SELECTED 51 -#define COLOR_DCC_WAITING 52 -#define COLOR_DCC_CONNECTING 53 -#define COLOR_DCC_ACTIVE 54 -#define COLOR_DCC_DONE 55 -#define COLOR_DCC_FAILED 56 -#define COLOR_DCC_ABORTED 57 +/* shift ncurses colors for compatibility with colors + in IRC messages (same as other IRC clients) */ + +#define WEECHAT_COLOR_BLACK COLOR_BLACK +#define WEECHAT_COLOR_RED COLOR_BLUE +#define WEECHAT_COLOR_GREEN COLOR_GREEN +#define WEECHAT_COLOR_YELLOW COLOR_CYAN +#define WEECHAT_COLOR_BLUE COLOR_RED +#define WEECHAT_COLOR_MAGENTA COLOR_MAGENTA +#define WEECHAT_COLOR_CYAN COLOR_YELLOW +#define WEECHAT_COLOR_WHITE COLOR_WHITE + +#define COLOR_WIN_NICK_NUMBER 10 + +typedef enum t_weechat_color t_weechat_color; + +enum t_weechat_color +{ + COLOR_WIN_TITLE = 0, + COLOR_WIN_CHAT, + COLOR_WIN_CHAT_TIME, + COLOR_WIN_CHAT_TIME_SEP, + COLOR_WIN_CHAT_PREFIX1, + COLOR_WIN_CHAT_PREFIX2, + COLOR_WIN_CHAT_SERVER, + COLOR_WIN_CHAT_JOIN, + COLOR_WIN_CHAT_PART, + COLOR_WIN_CHAT_NICK, + COLOR_WIN_CHAT_HOST, + COLOR_WIN_CHAT_CHANNEL, + COLOR_WIN_CHAT_DARK, + COLOR_WIN_CHAT_HIGHLIGHT, + COLOR_WIN_STATUS, + COLOR_WIN_STATUS_DELIMITERS, + COLOR_WIN_STATUS_CHANNEL, + COLOR_WIN_STATUS_DATA_MSG, + COLOR_WIN_STATUS_DATA_PRIVATE, + COLOR_WIN_STATUS_DATA_HIGHLIGHT, + COLOR_WIN_STATUS_DATA_OTHER, + COLOR_WIN_STATUS_MORE, + COLOR_WIN_INFOBAR, + COLOR_WIN_INFOBAR_DELIMITERS, + COLOR_WIN_INFOBAR_HIGHLIGHT, + COLOR_WIN_INPUT, + COLOR_WIN_INPUT_CHANNEL, + COLOR_WIN_INPUT_NICK, + COLOR_WIN_INPUT_DELIMITERS, + COLOR_WIN_NICK, + COLOR_WIN_NICK_AWAY, + COLOR_WIN_NICK_CHANOWNER, + COLOR_WIN_NICK_CHANADMIN, + COLOR_WIN_NICK_OP, + COLOR_WIN_NICK_HALFOP, + COLOR_WIN_NICK_VOICE, + COLOR_WIN_NICK_MORE, + COLOR_WIN_NICK_SEP, + COLOR_WIN_NICK_SELF, + COLOR_WIN_NICK_PRIVATE, + COLOR_WIN_NICK_1, + COLOR_WIN_NICK_2, + COLOR_WIN_NICK_3, + COLOR_WIN_NICK_4, + COLOR_WIN_NICK_5, + COLOR_WIN_NICK_6, + COLOR_WIN_NICK_7, + COLOR_WIN_NICK_8, + COLOR_WIN_NICK_9, + COLOR_WIN_NICK_10, + COLOR_DCC_SELECTED, + COLOR_DCC_WAITING, + COLOR_DCC_CONNECTING, + COLOR_DCC_ACTIVE, + COLOR_DCC_DONE, + COLOR_DCC_FAILED, + COLOR_DCC_ABORTED, + NUM_COLORS +}; + +/* attributes in IRC messages for color & style (bold, ..) */ + +#define GUI_ATTR_BOLD_CHAR '\x02' +#define GUI_ATTR_BOLD_STR "\x02" +#define GUI_ATTR_COLOR_CHAR '\x03' +#define GUI_ATTR_COLOR_STR "\x03" +#define GUI_ATTR_RESET_CHAR '\x0F' +#define GUI_ATTR_RESET_STR "\x0F" +#define GUI_ATTR_FIXED_CHAR '\x11' +#define GUI_ATTR_FIXED_STR "\x11" +#define GUI_ATTR_REVERSE_CHAR '\x12' +#define GUI_ATTR_REVERSE_STR "\x12" +#define GUI_ATTR_REVERSE2_CHAR '\x16' +#define GUI_ATTR_REVERSE2_STR "\x16" +#define GUI_ATTR_ITALIC_CHAR '\x1D' +#define GUI_ATTR_ITALIC_STR "\x1D" +#define GUI_ATTR_UNDERLINE_CHAR '\x1F' +#define GUI_ATTR_UNDERLINE_STR "\x1F" + +/* WeeChat internal attributes (should never be in IRC messages) */ + +#define GUI_ATTR_WEECHAT_COLOR_CHAR '\x19' +#define GUI_ATTR_WEECHAT_COLOR_STR "\x19" +#define GUI_ATTR_WEECHAT_SET_CHAR '\x1A' +#define GUI_ATTR_WEECHAT_SET_STR "\x1A" +#define GUI_ATTR_WEECHAT_REMOVE_CHAR '\x1B' +#define GUI_ATTR_WEECHAT_REMOVE_STR "\x1B" + +#define GUI_COLOR(color) ((gui_color[color]) ? gui_color[color]->string : "") +#define GUI_NO_COLOR GUI_ATTR_RESET_STR #define SERVER(buffer) ((t_irc_server *)(buffer->server)) #define CHANNEL(buffer) ((t_irc_channel *)(buffer->channel)) @@ -85,6 +142,8 @@ #define BUFFER_IS_CHANNEL(buffer) (CHANNEL(buffer) && (CHANNEL(buffer)->type == CHAT_CHANNEL)) #define BUFFER_IS_PRIVATE(buffer) (CHANNEL(buffer) && (CHANNEL(buffer)->type == CHAT_PRIVATE)) +#define BUFFER_HAS_NICKLIST(buffer) (BUFFER_IS_CHANNEL(buffer)) + #define MSG_TYPE_TIME 1 #define MSG_TYPE_PREFIX 2 #define MSG_TYPE_NICK 4 @@ -94,22 +153,16 @@ #define MSG_TYPE_NOLOG 64 #define gui_printf(buffer, fmt, argz...) \ - gui_printf_internal(buffer, 1, MSG_TYPE_INFO, -1, fmt, ##argz) - -#define gui_printf_color(buffer, color, fmt, argz...) \ - gui_printf_internal(buffer, 1, MSG_TYPE_INFO, color, fmt, ##argz) + gui_printf_internal(buffer, 1, MSG_TYPE_INFO, fmt, ##argz) #define gui_printf_type(buffer, type, fmt, argz...) \ - gui_printf_internal(buffer, 1, type, -1, fmt, ##argz) - -#define gui_printf_type_color(buffer, type, color, fmt, argz...) \ - gui_printf_internal(buffer, 1, type, color, fmt, ##argz) + gui_printf_internal(buffer, 1, type, fmt, ##argz) #define gui_printf_nolog(buffer, fmt, argz...) \ - gui_printf_internal(buffer, 1, MSG_TYPE_INFO | MSG_TYPE_NOLOG, -1, fmt, ##argz) + gui_printf_internal(buffer, 1, MSG_TYPE_INFO | MSG_TYPE_NOLOG, fmt, ##argz) #define gui_printf_nolog_notime(buffer, fmt, argz...) \ - gui_printf_internal(buffer, 0, MSG_TYPE_NOLOG, -1, fmt, ##argz) + gui_printf_internal(buffer, 0, MSG_TYPE_NOLOG, fmt, ##argz) #define NOTIFY_LEVEL_MIN 0 #define NOTIFY_LEVEL_MAX 3 @@ -118,38 +171,14 @@ #define KEY_SHOW_MODE_DISPLAY 1 #define KEY_SHOW_MODE_BIND 2 -typedef struct t_gui_message t_gui_message; - -struct t_gui_message -{ - int type; /* type of message (time, nick, other) */ - int color; /* color of message */ - char *message; /* message content */ - t_gui_message *prev_message; /* link to previous message for line */ - t_gui_message *next_message; /* link to next message for line */ -}; - -typedef struct t_gui_line t_gui_line; - -struct t_gui_line -{ - int length; /* length of the line (in char) */ - int length_align; /* alignment length (time or time/nick) */ - int log_write; /* = 1 if line will be written to log */ - int line_with_message; /* line contains a message from a user? */ - int line_with_highlight; /* line contains highlight */ - t_gui_message *messages; /* messages for the line */ - t_gui_message *last_message; /* last message of the line */ - t_gui_line *prev_line; /* link to previous line */ - t_gui_line *next_line; /* link to next line */ -}; - typedef struct t_gui_color t_gui_color; struct t_gui_color { - char *name; - int color; + int foreground; /* foreground color */ + int background; /* background color */ + int attributes; /* attributes (bold, ..) */ + char *string; /* WeeChat color: "\x19??", ?? is #color*/ }; typedef struct t_gui_infobar t_gui_infobar; @@ -164,6 +193,20 @@ struct t_gui_infobar t_gui_infobar *next_infobar; /* next message for infobar */ }; +typedef struct t_gui_line t_gui_line; + +struct t_gui_line +{ + int length; /* length of the line (in char) */ + int length_align; /* alignment length (time or time/nick) */ + int log_write; /* = 1 if line will be written to log */ + int line_with_message; /* line contains a message from a user? */ + int line_with_highlight; /* line contains highlight */ + char *data; /* line content */ + t_gui_line *prev_line; /* link to previous line */ + t_gui_line *next_line; /* link to next line */ +}; + typedef struct t_gui_buffer t_gui_buffer; struct t_gui_buffer @@ -260,6 +303,11 @@ struct t_gui_window /* windows for Qt GUI */ /* TODO: declare Qt window */ + int current_style_fg;; /* current color used for foreground */ + int current_style_bg;; /* current color used for background */ + int current_style_attr; /* current attributes (bold, ..) */ + int current_color_attr; /* attr sum of last color(s) displayed */ + /* DCC */ void *dcc_first; /* first dcc displayed */ void *dcc_selected; /* selected dcc */ @@ -316,6 +364,8 @@ extern int gui_key_grab; extern int gui_key_grab_count; extern char *gui_input_clipboard; +extern t_gui_color *gui_color[NUM_COLORS]; + /* GUI independent functions: windows & buffers */ extern t_gui_window *gui_window_new (int, int, int, int); @@ -327,7 +377,9 @@ extern void gui_window_free (t_gui_window *); extern void gui_infobar_remove (); extern void gui_buffer_free (t_gui_buffer *, int); extern t_gui_line *gui_new_line (t_gui_buffer *); -extern t_gui_message *gui_new_message (t_gui_buffer *); +extern int gui_word_strlen (t_gui_window *, char *); +extern int gui_word_real_pos (t_gui_window *, char *, int); +extern void gui_printf_internal (t_gui_buffer *, int, int, char *, ...); extern void gui_optimize_input_buffer_size (t_gui_buffer *); extern void gui_exec_action_dcc (t_gui_window *, char *); extern int gui_insert_string_input (t_gui_window *, char *, int); @@ -403,11 +455,13 @@ extern void gui_key_free_all (); /* GUI dependant functions: display */ extern int gui_assign_color (int *, char *); -extern int gui_get_color_by_name (char *); -extern char *gui_get_color_by_value (int); +extern char *gui_get_color_name (int); +extern unsigned char *gui_color_decode (unsigned char *, int); +extern unsigned char *gui_color_encode (unsigned char *); extern int gui_buffer_has_nicklist (t_gui_buffer *); extern void gui_calculate_pos_size (t_gui_window *); extern void gui_draw_buffer_title (t_gui_buffer *, int); +extern char *gui_word_get_next_char (t_gui_window *, unsigned char *, int); extern void gui_draw_buffer_chat (t_gui_buffer *, int); extern void gui_draw_buffer_nick (t_gui_buffer *, int); extern void gui_draw_buffer_status (t_gui_buffer *, int); @@ -434,11 +488,10 @@ extern void gui_window_merge_auto (t_gui_window *); extern void gui_window_merge_all (t_gui_window *); extern void gui_refresh_screen (); extern void gui_pre_init (int *, char **[]); -extern void gui_init_colors (); +extern void gui_rebuild_weechat_colors (); extern void gui_set_window_title (); extern void gui_init (); extern void gui_end (); -extern void gui_printf_internal (t_gui_buffer *, int, int, int, char *, ...); extern void gui_input_default_key_bindings (); extern void gui_main_loop (); diff --git a/src/irc/irc-commands.c b/src/irc/irc-commands.c index 2ddd68485..f994d2262 100644 --- a/src/irc/irc-commands.c +++ b/src/irc/irc-commands.c @@ -384,6 +384,7 @@ t_irc_command irc_commands[] = { "375", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, { "376", N_("a server message"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, { "381", N_("you are now an IRC operator"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, + { "382", N_("rehashing"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, { "391", N_("server local time"), "", "", 0, 0, 1, NULL, NULL, irc_cmd_recv_server_msg }, { "401", N_("no such nick/channel"), "", "", 0, MAX_ARGS, 1, NULL, NULL, irc_cmd_recv_error }, diff --git a/src/irc/irc-dcc.c b/src/irc/irc-dcc.c index 739fe93c1..103791aa2 100644 --- a/src/irc/irc-dcc.c +++ b/src/irc/irc-dcc.c @@ -364,30 +364,26 @@ dcc_close (t_irc_dcc *ptr_dcc, int status) { irc_display_prefix (ptr_dcc->server, ptr_dcc->server->buffer, PREFIX_INFO); - gui_printf (ptr_dcc->server->buffer, _("DCC: file ")); - gui_printf_color (ptr_dcc->server->buffer, - COLOR_WIN_CHAT_CHANNEL, - "%s", - ptr_dcc->filename); + gui_printf (ptr_dcc->server->buffer, + _("DCC: file %s%s%s"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + ptr_dcc->filename, + GUI_COLOR(COLOR_WIN_CHAT)); if (ptr_dcc->local_filename) - { - gui_printf (ptr_dcc->server->buffer, _(" (local filename: ")); - gui_printf_color (ptr_dcc->server->buffer, - COLOR_WIN_CHAT_CHANNEL, - "%s", - ptr_dcc->local_filename); - gui_printf (ptr_dcc->server->buffer, ")"); - } + gui_printf (ptr_dcc->server->buffer, + _(" (local filename: %s%s%s)"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + ptr_dcc->local_filename, + GUI_COLOR(COLOR_WIN_CHAT)); if (ptr_dcc->type == DCC_FILE_SEND) gui_printf (ptr_dcc->server->buffer, _(" sent to ")); else gui_printf (ptr_dcc->server->buffer, _(" received from ")); - gui_printf_color (ptr_dcc->server->buffer, - COLOR_WIN_CHAT_NICK, - "%s", - ptr_dcc->nick); - gui_printf (ptr_dcc->server->buffer, - (status == DCC_DONE) ? _(": ok!\n") : _(": FAILED\n")); + gui_printf (ptr_dcc->server->buffer, "%s%s%s: %s\n", + GUI_COLOR(COLOR_WIN_CHAT_NICK), + ptr_dcc->nick, + GUI_COLOR(COLOR_WIN_CHAT), + (status == DCC_DONE) ? _("OK") : _("FAILED")); } } if (status == DCC_ABORTED) @@ -399,15 +395,17 @@ dcc_close (t_irc_dcc *ptr_dcc, int status) else ptr_buffer = ptr_dcc->server->buffer; irc_display_prefix (ptr_dcc->server, ptr_buffer, PREFIX_INFO); - gui_printf (ptr_buffer, _("DCC chat closed with ")); - gui_printf_color (ptr_buffer, COLOR_WIN_CHAT_NICK, - "%s", ptr_dcc->nick); - gui_printf_color (ptr_buffer, COLOR_WIN_CHAT_DARK, " ("); - gui_printf_color (ptr_buffer, COLOR_WIN_CHAT_HOST, - "%d.%d.%d.%d", - ptr_dcc->addr >> 24, (ptr_dcc->addr >> 16) & 0xff, - (ptr_dcc->addr >> 8) & 0xff, ptr_dcc->addr & 0xff); - gui_printf_color (ptr_buffer, COLOR_WIN_CHAT_DARK, ")\n"); + gui_printf (ptr_buffer, + _("DCC chat closed with %s%s %s(%s%d.%d.%d.%d%s)\n"), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + ptr_dcc->nick, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_HOST), + ptr_dcc->addr >> 24, + (ptr_dcc->addr >> 16) & 0xff, + (ptr_dcc->addr >> 8) & 0xff, + ptr_dcc->addr & 0xff, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); } } @@ -467,16 +465,17 @@ dcc_channel_for_chat (t_irc_dcc *ptr_dcc) irc_display_prefix (ptr_dcc->server, ptr_dcc->channel->buffer, PREFIX_INFO); gui_printf_type (ptr_dcc->channel->buffer, MSG_TYPE_MSG, - _("Connected to ")); - gui_printf_color (ptr_dcc->channel->buffer, COLOR_WIN_CHAT_NICK, - "%s", ptr_dcc->nick); - gui_printf_color (ptr_dcc->channel->buffer, COLOR_WIN_CHAT_DARK, " ("); - gui_printf_color (ptr_dcc->channel->buffer, COLOR_WIN_CHAT_HOST, - "%d.%d.%d.%d", - ptr_dcc->addr >> 24, (ptr_dcc->addr >> 16) & 0xff, - (ptr_dcc->addr >> 8) & 0xff, ptr_dcc->addr & 0xff); - gui_printf_color (ptr_dcc->channel->buffer, COLOR_WIN_CHAT_DARK, ") "); - gui_printf (ptr_dcc->channel->buffer, _("via DCC chat\n")); + _("Connected to %s%s %s(%s%d.%d.%d.%d%s)%s via DCC chat\n"), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + ptr_dcc->nick, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_HOST), + ptr_dcc->addr >> 24, + (ptr_dcc->addr >> 16) & 0xff, + (ptr_dcc->addr >> 8) & 0xff, + ptr_dcc->addr & 0xff, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT)); } /* @@ -565,12 +564,11 @@ dcc_accept_resume (t_irc_server *server, char *filename, int port, irc_display_prefix (ptr_dcc->server, ptr_dcc->server->buffer, PREFIX_INFO); - gui_printf (ptr_dcc->server->buffer, _("DCC: file ")); - gui_printf_color (ptr_dcc->server->buffer, - COLOR_WIN_CHAT_CHANNEL, - "%s ", - ptr_dcc->filename); - gui_printf (ptr_dcc->server->buffer, _("resumed at position %u\n"), + gui_printf (ptr_dcc->server->buffer, + _("DCC: file %s%s%s resumed at position %u\n"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + ptr_dcc->filename, + GUI_COLOR(COLOR_WIN_CHAT), ptr_dcc->start_resume); dcc_redraw (HOTLIST_MSG); } @@ -669,51 +667,70 @@ dcc_add (t_irc_server *server, int type, unsigned long addr, int port, char *nic if (type == DCC_FILE_RECV) { irc_display_prefix (server, server->buffer, PREFIX_INFO); - gui_printf (server->buffer, _("Incoming DCC file from ")); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_NICK, "%s", nick); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_DARK, " ("); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_HOST, - "%d.%d.%d.%d", - addr >> 24, (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_DARK, ")"); - gui_printf (server->buffer, ": "); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_CHANNEL, "%s", filename); - gui_printf (server->buffer, ", "); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_CHANNEL, "%lu", size); - gui_printf (server->buffer, _(" bytes\n")); + gui_printf (server->buffer, + _("Incoming DCC file from %s%s%s (%s%d.%d.%d.%d%s)%s: %s%s%s, %s%lu%s bytes\n"), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_HOST), + addr >> 24, + (addr >> 16) & 0xff, + (addr >> 8) & 0xff, + addr & 0xff, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + filename, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + size, + GUI_COLOR(COLOR_WIN_CHAT)); dcc_redraw (HOTLIST_MSG); } if (type == DCC_FILE_SEND) { irc_display_prefix (server, server->buffer, PREFIX_INFO); - gui_printf (server->buffer, _("Sending DCC file to ")); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_NICK, "%s", nick); - gui_printf (server->buffer, ": "); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_CHANNEL, "%s", filename); - gui_printf (server->buffer, _(" (local filename: ")); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_CHANNEL, "%s", local_filename); - gui_printf (server->buffer, "), "); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_CHANNEL, "%lu", size); - gui_printf (server->buffer, _(" bytes\n")); + gui_printf (server->buffer, + _("Sending DCC file to %s%s%s: %s%s%s " + "(local filename: %s%s%s), %s%lu%s bytes\n"), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + filename, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + local_filename, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + size, + GUI_COLOR(COLOR_WIN_CHAT)); dcc_redraw (HOTLIST_MSG); } if (type == DCC_CHAT_RECV) { irc_display_prefix (server, server->buffer, PREFIX_INFO); - gui_printf (server->buffer, _("Incoming DCC chat request from ")); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_NICK, "%s", nick); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_DARK, " ("); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_HOST, - "%d.%d.%d.%d", - addr >> 24, (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_DARK, ")\n"); + gui_printf (server->buffer, + _("Incoming DCC chat request from %s%s%s " + "(%s%d.%d.%d.%d%s)\n"), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_HOST), + addr >> 24, + (addr >> 16) & 0xff, + (addr >> 8) & 0xff, + addr & 0xff, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); dcc_redraw (HOTLIST_MSG); } if (type == DCC_CHAT_SEND) { irc_display_prefix (server, server->buffer, PREFIX_INFO); - gui_printf (server->buffer, _("Sending DCC chat request to ")); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_NICK, "%s\n", nick); + gui_printf (server->buffer, + _("Sending DCC chat request to %s%s\n"), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick); dcc_redraw (HOTLIST_MSG); } @@ -728,18 +745,15 @@ dcc_add (t_irc_server *server, int type, unsigned long addr, int port, char *nic { irc_display_prefix (new_dcc->server, new_dcc->server->buffer, PREFIX_INFO); - gui_printf (new_dcc->server->buffer, _("DCC: file ")); - gui_printf_color (new_dcc->server->buffer, - COLOR_WIN_CHAT_CHANNEL, - "%s", - new_dcc->filename); - gui_printf (new_dcc->server->buffer, _(" (local filename: ")); - gui_printf_color (new_dcc->server->buffer, - COLOR_WIN_CHAT_CHANNEL, - "%s", - new_dcc->local_filename); - gui_printf (new_dcc->server->buffer, ") "); - gui_printf (new_dcc->server->buffer, _("will be resumed at position %u\n"), + gui_printf (new_dcc->server->buffer, + _("DCC: file %s%s%s (local filename: %s%s%s) " + "will be resumed at position %u\n"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + new_dcc->filename, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + new_dcc->local_filename, + GUI_COLOR(COLOR_WIN_CHAT), new_dcc->start_resume); dcc_redraw (HOTLIST_MSG); } @@ -1070,6 +1084,7 @@ dcc_chat_recv (t_irc_dcc *ptr_dcc) { static char buffer[4096 + 2]; char *buf2, *pos, *ptr_buf, *next_ptr_buf; + char *ptr_buf_color; int num_read; num_read = recv (ptr_dcc->sock, buffer, sizeof (buffer) - 2, 0); @@ -1120,40 +1135,45 @@ dcc_chat_recv (t_irc_dcc *ptr_dcc) if (ptr_buf) { - gui_printf_type_color (ptr_dcc->channel->buffer, - MSG_TYPE_NICK, - COLOR_WIN_CHAT_DARK, "<"); + ptr_buf_color = (char *)gui_color_decode ((unsigned char *)ptr_buf, + cfg_irc_colors_receive); + gui_printf_type (ptr_dcc->channel->buffer, MSG_TYPE_NICK, + "%s<", GUI_COLOR(COLOR_WIN_CHAT_DARK)); if (irc_is_highlight (ptr_buf, ptr_dcc->server->nick)) { - gui_printf_type_color (ptr_dcc->channel->buffer, - MSG_TYPE_NICK | MSG_TYPE_HIGHLIGHT, - COLOR_WIN_CHAT_HIGHLIGHT, - "%s", ptr_dcc->nick); + gui_printf_type (ptr_dcc->channel->buffer, + MSG_TYPE_NICK | MSG_TYPE_HIGHLIGHT, + "%s%s", + GUI_COLOR(COLOR_WIN_CHAT_HIGHLIGHT), + ptr_dcc->nick); if ( (cfg_look_infobar_delay_highlight > 0) && (ptr_dcc->channel->buffer != gui_current_window->buffer) ) gui_infobar_printf (cfg_look_infobar_delay_highlight, COLOR_WIN_INFOBAR_HIGHLIGHT, _("Private %s> %s"), - ptr_dcc->nick, ptr_buf); + ptr_dcc->nick, + (ptr_buf_color) ? ptr_buf_color : ptr_buf); } else - gui_printf_type_color (ptr_dcc->channel->buffer, - MSG_TYPE_NICK, - COLOR_WIN_NICK_PRIVATE, - "%s", ptr_dcc->nick); - gui_printf_type_color (ptr_dcc->channel->buffer, - MSG_TYPE_NICK, - COLOR_WIN_CHAT_DARK, "> "); - gui_printf_type_color (ptr_dcc->channel->buffer, - MSG_TYPE_MSG, - COLOR_WIN_CHAT, "%s\n", ptr_buf); + gui_printf_type (ptr_dcc->channel->buffer, MSG_TYPE_NICK, + "%s%s", + GUI_COLOR(COLOR_WIN_NICK_PRIVATE), + ptr_dcc->nick); + gui_printf_type (ptr_dcc->channel->buffer, MSG_TYPE_NICK, + "%s> ", GUI_COLOR(COLOR_WIN_CHAT_DARK)); + gui_printf_type (ptr_dcc->channel->buffer, MSG_TYPE_MSG, + "%s%s\n", + GUI_COLOR(COLOR_WIN_CHAT), + (ptr_buf_color) ? ptr_buf_color : ptr_buf); + if (ptr_buf_color) + free (ptr_buf_color); } ptr_buf = next_ptr_buf; } if (buf2) - free (buf2); +free (buf2); } else { diff --git a/src/irc/irc-display.c b/src/irc/irc-display.c index 10d2a103a..e6aa330cd 100644 --- a/src/irc/irc-display.c +++ b/src/irc/irc-display.c @@ -52,25 +52,34 @@ irc_display_prefix (t_irc_server *server, t_gui_buffer *buffer, char *prefix) if (prefix[0] == prefix[2]) { - gui_printf_type_color (buffer, type, COLOR_WIN_CHAT_PREFIX1, "%c", prefix[0]); - gui_printf_type_color (buffer, type, COLOR_WIN_CHAT_PREFIX2, "%c", prefix[1]); - gui_printf_type_color (buffer, type, COLOR_WIN_CHAT_PREFIX1, "%c ", prefix[2]); + gui_printf_type (buffer, type, "%s%c%s%c%s%c ", + GUI_COLOR(COLOR_WIN_CHAT_PREFIX1), + prefix[0], + GUI_COLOR(COLOR_WIN_CHAT_PREFIX2), + prefix[1], + GUI_COLOR(COLOR_WIN_CHAT_PREFIX1), + prefix[2]); } else { if (strcmp (prefix, PREFIX_JOIN) == 0) - gui_printf_color (buffer, COLOR_WIN_CHAT_JOIN, "%s ", prefix); + gui_printf_type (buffer, type, "%s%s ", + GUI_COLOR(COLOR_WIN_CHAT_JOIN), prefix); else if (strcmp (prefix, PREFIX_PART) == 0) - gui_printf_color (buffer, COLOR_WIN_CHAT_PART, "%s ", prefix); + gui_printf_type (buffer, type, "%s%s ", + GUI_COLOR(COLOR_WIN_CHAT_PART), prefix); else - gui_printf_color (buffer, COLOR_WIN_CHAT_PREFIX1, "%s ", prefix); + gui_printf_type (buffer, type, "%s%s ", + GUI_COLOR(COLOR_WIN_CHAT_PREFIX1), prefix); } if (server && (server->buffer == buffer) && buffer->all_servers) { - gui_printf_type_color (buffer, type, COLOR_WIN_CHAT_DARK, "["); - gui_printf_type_color (buffer, type, COLOR_WIN_CHAT_SERVER, "%s", server->name); - gui_printf_type_color (buffer, type, COLOR_WIN_CHAT_DARK, "] "); + gui_printf_type (buffer, type, "%s[%s%s%s] ", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_SERVER), server->name, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); } + gui_printf_type (buffer, type, GUI_NO_COLOR); } /* @@ -80,58 +89,51 @@ irc_display_prefix (t_irc_server *server, t_gui_buffer *buffer, char *prefix) void irc_display_nick (t_gui_buffer *buffer, t_irc_nick *nick, char *nickname, - int message_type, int display_around, int color_nick, int no_nickmode) + int type, int display_around, int color_nick, int no_nickmode) { if (display_around) - gui_printf_type_color (buffer, - message_type, COLOR_WIN_CHAT_DARK, - (nick) ? "<" : ">"); + gui_printf_type (buffer, type, "%s%s", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + (nick) ? "<" : ">"); if (nick && cfg_look_nickmode) { if (nick->is_chanowner) - gui_printf_type_color (buffer, - message_type, - COLOR_WIN_NICK_OP, "~"); + gui_printf_type (buffer, type, "%s~", + GUI_COLOR(COLOR_WIN_NICK_OP)); else if (nick->is_chanadmin) - gui_printf_type_color (buffer, - message_type, - COLOR_WIN_NICK_OP, "&"); + gui_printf_type (buffer, type, "%s&", + GUI_COLOR(COLOR_WIN_NICK_OP)); else if (nick->is_op) - gui_printf_type_color (buffer, - message_type, - COLOR_WIN_NICK_OP, "@"); + gui_printf_type (buffer, type, "%s@", + GUI_COLOR(COLOR_WIN_NICK_OP)); else if (nick->is_halfop) - gui_printf_type_color (buffer, - message_type, - COLOR_WIN_NICK_HALFOP, "%%"); + gui_printf_type (buffer, type, "%s%%", + GUI_COLOR(COLOR_WIN_NICK_HALFOP)); else if (nick->has_voice) - gui_printf_type_color (buffer, - message_type, - COLOR_WIN_NICK_VOICE, "+"); + gui_printf_type (buffer, type, "%s+", + GUI_COLOR(COLOR_WIN_NICK_VOICE)); else if (cfg_look_nickmode_empty && !no_nickmode) - gui_printf_type_color (buffer, - message_type, - COLOR_WIN_CHAT, " "); + gui_printf_type (buffer, type, "%s ", + GUI_COLOR(COLOR_WIN_CHAT)); } if (color_nick < 0) - gui_printf_type_color (buffer, - message_type, - COLOR_WIN_CHAT_HIGHLIGHT, - "%s", (nick) ? nick->nick : nickname); + gui_printf_type (buffer, type, "%s%s", + GUI_COLOR(COLOR_WIN_CHAT_HIGHLIGHT), + (nick) ? nick->nick : nickname); else - gui_printf_type_color (buffer, - message_type, - (nick && color_nick) ? + gui_printf_type (buffer, type, "%s%s", + GUI_COLOR((nick && color_nick) ? ((cfg_look_color_nicks) ? - nick->color : COLOR_WIN_CHAT) : - COLOR_WIN_CHAT, - "%s", (nick) ? nick->nick : nickname); + nick->color : COLOR_WIN_CHAT) : + COLOR_WIN_CHAT), + (nick) ? nick->nick : nickname); if (display_around) - gui_printf_type_color (buffer, - message_type, COLOR_WIN_CHAT_DARK, - (nick) ? "> " : "< "); + gui_printf_type (buffer, type, "%s%s", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + (nick) ? "> " : "< "); + gui_printf_type (buffer, type, GUI_NO_COLOR); } /* @@ -144,19 +146,27 @@ irc_display_mode (t_irc_server *server, t_gui_buffer *buffer, char *symbol, char *nick_host, char *message, char *param) { irc_display_prefix (server, buffer, PREFIX_INFO); - gui_printf_color (buffer, COLOR_WIN_CHAT_DARK, "["); - gui_printf_color (buffer, COLOR_WIN_CHAT_CHANNEL, "%s", channel_name); - gui_printf_color (buffer, COLOR_WIN_CHAT, "/"); - gui_printf_color (buffer, COLOR_WIN_CHAT_CHANNEL, "%c%s", set_flag, symbol); - gui_printf_color (buffer, COLOR_WIN_CHAT_DARK, "] "); - gui_printf_color (buffer, COLOR_WIN_CHAT_NICK, "%s", nick_host); + gui_printf (buffer, "%s[%s%s%s/%s%c%s%s] %s%s", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + channel_name, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + set_flag, + symbol, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick_host); if (param) - { - gui_printf_color (buffer, COLOR_WIN_CHAT, " %s ", message); - gui_printf_color (buffer, COLOR_WIN_CHAT_NICK, "%s\n", param); - } + gui_printf (buffer, " %s%s %s%s\n", + GUI_COLOR(COLOR_WIN_CHAT), + message, + GUI_COLOR(COLOR_WIN_CHAT_NICK), + param); else - gui_printf_color (buffer, COLOR_WIN_CHAT, " %s\n", message); + gui_printf (buffer, " %s\n", + GUI_COLOR(COLOR_WIN_CHAT), + message); } /* @@ -167,65 +177,56 @@ void irc_display_server (t_irc_server *server) { gui_printf (NULL, "\n"); - gui_printf_color (NULL, COLOR_WIN_CHAT, _("Server: ")); - gui_printf_color (NULL, COLOR_WIN_CHAT_CHANNEL, "%s", server->name); - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, " ["); - gui_printf_color (NULL, COLOR_WIN_CHAT, "%s", - (server->is_connected) ? - _("connected") : _("not connected")); - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, "]\n"); - gui_printf_color (NULL, COLOR_WIN_CHAT, - " server_autoconnect : %s%s\n", - (server->autoconnect) ? _("yes") : _("no"), - (server->command_line) ? - _(" (temporary server, will not be saved)") : ""); - gui_printf_color (NULL, COLOR_WIN_CHAT, - " server_autoreconnect . . .: %s\n", - (server->autoreconnect) ? _("yes") : _("no")); - gui_printf_color (NULL, COLOR_WIN_CHAT, - " server_autoreconnect_delay: %d seconds\n", - server->autoreconnect_delay); - gui_printf_color (NULL, COLOR_WIN_CHAT, - " server_address . . . . . .: %s\n", - server->address); - gui_printf_color (NULL, COLOR_WIN_CHAT, - " server_port . . . . . . .: %d\n", - server->port); - gui_printf_color (NULL, COLOR_WIN_CHAT, - " server_ipv6 . . . . . . .: %s\n", - (server->ipv6) ? _("yes") : _("no")); - gui_printf_color (NULL, COLOR_WIN_CHAT, - " server_ssl . . . . . . . .: %s\n", - (server->ssl) ? _("yes") : _("no")); - gui_printf_color (NULL, COLOR_WIN_CHAT, - " server_password . . . . .: %s\n", - (server->password && server->password[0]) ? - _("(hidden)") : ""); - gui_printf_color (NULL, COLOR_WIN_CHAT, - " server_nick1/2/3 . . . . .: %s", server->nick1); - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, " / "); - gui_printf_color (NULL, COLOR_WIN_CHAT, "%s", server->nick2); - gui_printf_color (NULL, COLOR_WIN_CHAT_DARK, " / "); - gui_printf_color (NULL, COLOR_WIN_CHAT, "%s\n", server->nick3); - gui_printf_color (NULL, COLOR_WIN_CHAT, - " server_username . . . . .: %s\n", - server->username); - gui_printf_color (NULL, COLOR_WIN_CHAT, - " server_realname . . . . .: %s\n", - server->realname); - gui_printf_color (NULL, COLOR_WIN_CHAT, - " server_command . . . . . .: %s\n", - (server->command && server->command[0]) ? - server->command : ""); - gui_printf_color (NULL, COLOR_WIN_CHAT, - " server_command_delay . . .: %d seconds\n", - server->command_delay); - gui_printf_color (NULL, COLOR_WIN_CHAT, - " server_autojoin . . . . .: %s\n", - (server->autojoin && server->autojoin[0]) ? - server->autojoin : ""); - gui_printf_color (NULL, COLOR_WIN_CHAT, - " server_notify_levels . . .: %s\n", - (server->notify_levels && server->notify_levels[0]) ? - server->notify_levels : ""); + gui_printf (NULL, _("%sServer: %s%s %s[%s%s%s]\n"), + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + server->name, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + (server->is_connected) ? + _("connected") : _("not connected"), + GUI_COLOR(COLOR_WIN_CHAT_DARK)); + + gui_printf (NULL, " server_autoconnect . . . .: %s%s\n", + (server->autoconnect) ? _("yes") : _("no"), + (server->command_line) ? + _(" (temporary server, will not be saved)") : ""); + gui_printf (NULL, " server_autoreconnect . . .: %s\n", + (server->autoreconnect) ? _("yes") : _("no")); + gui_printf (NULL, " server_autoreconnect_delay: %d seconds\n", + server->autoreconnect_delay); + gui_printf (NULL, " server_address . . . . . .: %s\n", + server->address); + gui_printf (NULL, " server_port . . . . . . .: %d\n", + server->port); + gui_printf (NULL, " server_ipv6 . . . . . . .: %s\n", + (server->ipv6) ? _("yes") : _("no")); + gui_printf (NULL, " server_ssl . . . . . . . .: %s\n", + (server->ssl) ? _("yes") : _("no")); + gui_printf (NULL, " server_password . . . . .: %s\n", + (server->password && server->password[0]) ? + _("(hidden)") : ""); + gui_printf (NULL, " server_nick1/2/3 . . . . .: %s %s/ %s%s %s/ %s%s\n", + server->nick1, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + server->nick2, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + server->nick3); + gui_printf (NULL, " server_username . . . . .: %s\n", + server->username); + gui_printf (NULL, " server_realname . . . . .: %s\n", + server->realname); + gui_printf (NULL, " server_command . . . . . .: %s\n", + (server->command && server->command[0]) ? + server->command : ""); + gui_printf (NULL, " server_command_delay . . .: %d seconds\n", + server->command_delay); + gui_printf (NULL, " server_autojoin . . . . .: %s\n", + (server->autojoin && server->autojoin[0]) ? + server->autojoin : ""); + gui_printf (NULL, " server_notify_levels . . .: %s\n", + (server->notify_levels && server->notify_levels[0]) ? + server->notify_levels : ""); } diff --git a/src/irc/irc-nick.c b/src/irc/irc-nick.c index 615606e6e..a91fcd7af 100644 --- a/src/irc/irc-nick.c +++ b/src/irc/irc-nick.c @@ -49,7 +49,7 @@ nick_find_color (t_irc_nick *nick) } color = (color % cfg_look_color_nicks_number); - return COLOR_WIN_NICK_FIRST + color; + return COLOR_WIN_NICK_1 + color; } /* diff --git a/src/irc/irc-recv.c b/src/irc/irc-recv.c index cf59fe2b7..24c9bd2d0 100644 --- a/src/irc/irc-recv.c +++ b/src/irc/irc-recv.c @@ -203,7 +203,7 @@ irc_recv_command (t_irc_server *server, char *entire_line, char *host, char *command, char *arguments) { int i, cmd_found, return_code; - char *pos, *nick; + char *pos, *nick, *args_after_color; if (command == NULL) return -2; @@ -247,7 +247,13 @@ irc_recv_command (t_irc_server *server, char *entire_line, nick = (host) ? strdup (host) : NULL; if (pos) pos[0] = '!'; - return_code = (int) (irc_commands[i].recv_function) (server, host, nick, arguments); + args_after_color = (char *)gui_color_decode ((unsigned char *)arguments, + cfg_irc_colors_receive); + return_code = (int) (irc_commands[i].recv_function) (server, host, nick, + (args_after_color) ? + args_after_color : arguments); + if (args_after_color) + free (args_after_color); if (nick) free (nick); return return_code; @@ -302,9 +308,10 @@ irc_cmd_recv_error (t_irc_server *server, char *host, char *nick, char *argument pos++; if (first) irc_display_prefix (server, ptr_buffer, PREFIX_ERROR); - gui_printf_color (ptr_buffer, - COLOR_WIN_CHAT, - "%s%s\n", (first) ? "" : ": ", pos); + gui_printf (ptr_buffer, "%s%s%s\n", + GUI_COLOR(COLOR_WIN_CHAT), + (first) ? "" : ": ", + pos); pos = NULL; } else @@ -317,10 +324,10 @@ irc_cmd_recv_error (t_irc_server *server, char *host, char *nick, char *argument ptr_buffer = ptr_channel->buffer; irc_display_prefix (server, ptr_buffer, PREFIX_ERROR); } - gui_printf_color (ptr_buffer, - COLOR_WIN_CHAT_CHANNEL, - "%s%s", - (first) ? "" : " ", pos); + gui_printf (ptr_buffer, "%s%s%s", + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + (first) ? "" : " ", + pos); first = 0; pos = pos2 + 1; } @@ -352,12 +359,12 @@ irc_cmd_recv_invite (t_irc_server *server, char *host, char *nick, char *argumen if (!command_ignored) { irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf (server->buffer, _("You have been invited to ")); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_CHANNEL, - "%s ", pos_channel); - gui_printf (server->buffer, _("by")); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_NICK, - " %s\n", nick); + gui_printf (server->buffer, _("You have been invited to %s%s%s by %s%s\n"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + pos_channel, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick); hotlist_add (HOTLIST_HIGHLIGHT, server->buffer); gui_draw_buffer_status (gui_current_window->buffer, 1); } @@ -404,18 +411,17 @@ irc_cmd_recv_join (t_irc_server *server, char *host, char *nick, char *arguments { pos = strchr (host, '!'); irc_display_prefix (server, ptr_channel->buffer, PREFIX_JOIN); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT_NICK, - "%s ", nick); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT_DARK, - "("); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT_HOST, - "%s", (pos) ? pos + 1 : ""); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT_DARK, - ")"); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT, - _(" has joined ")); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT_CHANNEL, - "%s\n", arguments); + gui_printf (ptr_channel->buffer, + _("%s%s %s(%s%s%s)%s has joined %s%s\n"), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_HOST), + (pos) ? pos + 1 : "", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + arguments); } (void) nick_new (ptr_channel, nick, 0, 0, 0, 0, 0); gui_draw_buffer_nick (ptr_channel->buffer, 1); @@ -468,28 +474,23 @@ irc_cmd_recv_kick (t_irc_server *server, char *host, char *nick, char *arguments if (!command_ignored) { irc_display_prefix (server, ptr_channel->buffer, PREFIX_PART); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT_NICK, - "%s", nick); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT, - _(" has kicked ")); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT_NICK, - "%s", pos_nick); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT, - _(" from ")); + gui_printf (ptr_channel->buffer, _("%s%s%s has kicked %s%s%s from %s%s"), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + pos_nick, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + arguments); if (pos_comment) - { - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT_CHANNEL, - "%s ", arguments); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT_DARK, - "("); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT, - "%s", pos_comment); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT_DARK, - ")\n"); - } + gui_printf (ptr_channel->buffer, " %s(%s%s%s)\n", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + pos_comment, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); else - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT_CHANNEL, - "%s\n", arguments); + gui_printf (ptr_channel->buffer, "\n"); } } else @@ -558,26 +559,21 @@ irc_cmd_recv_kill (t_irc_server *server, char *host, char *nick, char *arguments && !ignore_check (host, "kill", ptr_channel->name, server->name)) { irc_display_prefix (server, ptr_channel->buffer, PREFIX_PART); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT_NICK, - "%s", nick); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT, - _(" has killed ")); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT_NICK, - "%s", arguments); + gui_printf (ptr_channel->buffer, _("%s%s%s has killed %s%s%s from server"), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + arguments, + GUI_COLOR(COLOR_WIN_CHAT)); if (pos_comment) - { - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT, - _(" from server")); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT_DARK, - " ("); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT, - "%s", pos_comment); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT_DARK, - ")\n"); - } + gui_printf (ptr_channel->buffer, " %s(%s%s%s)\n", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + pos_comment, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); else - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT, - _(" from server\n")); + gui_printf (ptr_channel->buffer, "\n"); } } } @@ -1020,14 +1016,17 @@ irc_cmd_recv_mode (t_irc_server *server, char *host, char *nick, char *arguments if (!command_ignored) { irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_DARK, "["); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_NICK, "%s", arguments); - gui_printf_color (server->buffer, COLOR_WIN_CHAT, "/"); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_NICK, - "%s", (pos[0] == ':') ? pos + 1 : pos); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_DARK, "] "); - gui_printf_color (server->buffer, COLOR_WIN_CHAT, _("mode changed by")); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_NICK, " %s\n", nick); + gui_printf (server->buffer, _("%s[%s%s%s/%s%s%s]%s mode changed by %s%s\n"), + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + arguments, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + (pos[0] == ':') ? pos + 1 : pos, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick); } } return 0; @@ -1086,27 +1085,18 @@ irc_cmd_recv_nick (t_irc_server *server, char *host, char *nick, char *arguments { irc_display_prefix (server, ptr_channel->buffer, PREFIX_INFO); if (nick_is_me) - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, - _("You are ")); + gui_printf (ptr_channel->buffer, _("You are now known as %s%s\n"), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + arguments); else - { - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_NICK, - "%s", nick); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, _(" is ")); - } - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, - _("now known as ")); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_NICK, - "%s\n", - arguments); + gui_printf (ptr_channel->buffer, _("%s%s%s is now known as %s%s\n"), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + arguments); } - if (gui_buffer_has_nicklist (ptr_channel->buffer)) - gui_draw_buffer_nick (ptr_channel->buffer, 1); + gui_draw_buffer_nick (ptr_channel->buffer, 1); gui_add_hotlist = 1; } } @@ -1180,11 +1170,13 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *nick, char *argumen if (pos2) pos2[0] = '\0'; irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, COLOR_WIN_CHAT, "CTCP "); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_CHANNEL, "VERSION "); - gui_printf_color (server->buffer, COLOR_WIN_CHAT, _("reply from")); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_NICK, " %s", nick); - gui_printf_color (server->buffer, COLOR_WIN_CHAT, ": %s\n", pos); + gui_printf (server->buffer, _("CTCP %sVERSION%s reply from %s%s%s: %s\n"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick, + GUI_COLOR(COLOR_WIN_CHAT), + pos); } else { @@ -1212,14 +1204,14 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *nick, char *argumen difftime = ((sec2 * 1000000) + usec2) - ((sec1 * 1000000) + usec1); irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, COLOR_WIN_CHAT, "CTCP "); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_CHANNEL, "PING "); - gui_printf_color (server->buffer, COLOR_WIN_CHAT, _("reply from")); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_NICK, " %s", nick); - gui_printf_color (server->buffer, COLOR_WIN_CHAT, - _(": %ld.%ld seconds\n"), - difftime / 1000000, - (difftime % 1000000) / 1000); + gui_printf (server->buffer, _("CTCP %sPING%s reply from %s%s%s: %ld.%ld seconds\n"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick, + GUI_COLOR(COLOR_WIN_CHAT), + difftime / 1000000, + (difftime % 1000000) / 1000); } } } @@ -1243,15 +1235,16 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *nick, char *argumen if (!ptr_channel->topic) ptr_channel->topic = strdup ((host2) ? host2 : ""); - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_NICK, - COLOR_WIN_CHAT_DARK, "<"); + gui_printf_type (ptr_channel->buffer, MSG_TYPE_NICK, + "%s<", + GUI_COLOR(COLOR_WIN_CHAT_DARK)); if (irc_is_highlight (pos, server->nick)) { - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_NICK | MSG_TYPE_HIGHLIGHT, - COLOR_WIN_CHAT_HIGHLIGHT, - "%s", nick); + gui_printf_type (ptr_channel->buffer, + MSG_TYPE_NICK | MSG_TYPE_HIGHLIGHT, + "%s%s", + GUI_COLOR(COLOR_WIN_CHAT_HIGHLIGHT), + nick); if ( (cfg_look_infobar_delay_highlight > 0) && (ptr_channel->buffer != gui_current_window->buffer) ) gui_infobar_printf (cfg_look_infobar_delay_highlight, @@ -1260,35 +1253,37 @@ irc_cmd_recv_notice (t_irc_server *server, char *host, char *nick, char *argumen nick, pos); } else - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_NICK, - COLOR_WIN_NICK_PRIVATE, - "%s", nick); - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_NICK, - COLOR_WIN_CHAT_DARK, "> "); - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_MSG, - COLOR_WIN_CHAT, "%s\n", pos); + gui_printf_type (ptr_channel->buffer, MSG_TYPE_NICK, + "%s%s", + GUI_COLOR(COLOR_WIN_NICK_PRIVATE), + nick); + gui_printf_type (ptr_channel->buffer, MSG_TYPE_NICK, + "%s> ", + GUI_COLOR(COLOR_WIN_CHAT_DARK)); + gui_printf_type (ptr_channel->buffer, MSG_TYPE_MSG, + "%s%s\n", + GUI_COLOR(COLOR_WIN_CHAT), + pos); } else { irc_display_prefix (server, server->buffer, PREFIX_SERVER); if (host) { - gui_printf_color (server->buffer, COLOR_WIN_CHAT_NICK, "%s", nick); + gui_printf (server->buffer, "%s%s", + GUI_COLOR(COLOR_WIN_CHAT_NICK), nick); if (host2) - { - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, " ("); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_HOST, "%s", host2); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, ")"); - } - gui_printf_color (server->buffer, COLOR_WIN_CHAT, ": "); + gui_printf (server->buffer, " %s(%s%s%s)", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_HOST), + host2, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); + gui_printf (server->buffer, "%s: ", + GUI_COLOR(COLOR_WIN_CHAT)); } - gui_printf_color (server->buffer, COLOR_WIN_CHAT, "%s\n", pos); + gui_printf (server->buffer, "%s%s\n", + GUI_COLOR(COLOR_WIN_CHAT), + pos); if ((nick) && (ascii_strcasecmp (nick, "nickserv") != 0) && (ascii_strcasecmp (nick, "chanserv") != 0) && (ascii_strcasecmp (nick, "memoserv") != 0)) @@ -1359,33 +1354,27 @@ irc_cmd_recv_part (t_irc_server *server, char *host, char *nick, char *arguments { pos = strchr (host, '!'); irc_display_prefix (server, ptr_channel->buffer, PREFIX_PART); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_NICK, "%s ", nick); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_DARK, "("); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_HOST, "%s", (pos) ? pos + 1 : ""); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_DARK, ")"); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, _(" has left ")); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_CHANNEL, - "%s", ptr_channel->name); + gui_printf (ptr_channel->buffer, _("%s%s %s(%s%s%s)%s has left %s%s"), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_HOST), + (pos) ? pos + 1 : "", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + ptr_channel->name); if (pos_args && pos_args[0]) - { - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_DARK, " ("); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, "%s", pos_args); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_DARK, ")"); - } - gui_printf (ptr_channel->buffer, "\n"); + gui_printf (ptr_channel->buffer, " %s(%s%s%s)\n", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + pos_args, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); + else + gui_printf (ptr_channel->buffer, "\n"); } - if (gui_buffer_has_nicklist (ptr_channel->buffer)) - gui_draw_buffer_nick (ptr_channel->buffer, 1); + gui_draw_buffer_nick (ptr_channel->buffer, 1); gui_draw_buffer_status (ptr_channel->buffer, 1); } } @@ -1511,10 +1500,11 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume irc_display_prefix (server, ptr_channel->buffer, PREFIX_ACTION_ME); if (irc_is_highlight (pos, server->nick)) { - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_MSG | MSG_TYPE_HIGHLIGHT, - COLOR_WIN_CHAT_HIGHLIGHT, - "%s", nick); + gui_printf_type (ptr_channel->buffer, + MSG_TYPE_MSG | MSG_TYPE_HIGHLIGHT, + "%s%s", + GUI_COLOR(COLOR_WIN_CHAT_HIGHLIGHT), + nick); if ( (cfg_look_infobar) && (cfg_look_infobar_delay_highlight > 0) && (ptr_channel->buffer != gui_current_window->buffer) ) @@ -1525,11 +1515,12 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume nick, pos); } else - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_MSG, - COLOR_WIN_CHAT_NICK, "%s", nick); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, " %s\n", pos); + gui_printf_type (ptr_channel->buffer, MSG_TYPE_MSG, + "%s%s", + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick); + gui_printf (ptr_channel->buffer, " %s%s\n", + GUI_COLOR(COLOR_WIN_CHAT), pos); } return 0; } @@ -1544,11 +1535,12 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume { irc_display_prefix (server, ptr_channel->buffer, PREFIX_SERVER); gui_printf (ptr_channel->buffer, - _("Received a CTCP SOUND \"%s\" from "), - pos); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_NICK, - "%s\n", nick); + _("Received a CTCP %sSOUND%s \"%s\" from %s%s\n"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + GUI_COLOR(COLOR_WIN_CHAT), + pos, + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick); } return 0; } @@ -1572,14 +1564,12 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume server_sendf (server, "NOTICE %s :\01PING\01\r\n", nick); irc_display_prefix (server, ptr_channel->buffer, PREFIX_SERVER); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, "CTCP "); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_CHANNEL, "PING "); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, _("received from")); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_NICK, " %s\n", nick); + gui_printf (ptr_channel->buffer, + _("CTCP %sPING%s received from %s%s\n"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick); return 0; } @@ -1603,17 +1593,17 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume if (!command_ignored) { irc_display_prefix (server, ptr_channel->buffer, PREFIX_SERVER); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, _("Unknown CTCP ")); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_CHANNEL, "%s ", pos); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, _("received from")); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_NICK, " %s", nick); + gui_printf (ptr_channel->buffer, + _("Unknown CTCP %s%s%s received from %s%s"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + pos, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick); if (pos2) - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, ": %s\n", pos2); + gui_printf (ptr_channel->buffer, "%s: %s\n", + GUI_COLOR(COLOR_WIN_CHAT), + pos2); else gui_printf (ptr_channel->buffer, "\n"); } @@ -1644,9 +1634,8 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume irc_display_nick (ptr_channel->buffer, ptr_nick, (ptr_nick) ? NULL : nick, MSG_TYPE_NICK, 1, 1, 0); - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_MSG, - COLOR_WIN_CHAT, "%s\n", pos); + gui_printf_type (ptr_channel->buffer, MSG_TYPE_MSG, + "%s\n", pos); } } else @@ -1689,7 +1678,7 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume } buf = (struct utsname *) malloc (sizeof (struct utsname)); - if (buf && (uname (buf) == 0)) + if (buf && (uname (buf) >= 0)) { server_sendf (server, "NOTICE %s :%sVERSION %s v%s" @@ -1707,17 +1696,16 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume nick, "\01", PACKAGE_NAME, PACKAGE_VERSION, __DATE__, "\01\r\n"); irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, "CTCP "); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_CHANNEL, "VERSION "); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, _("received from")); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_NICK, " %s", nick); + gui_printf (server->buffer, + _("CTCP %sVERSION%s received from %s%s"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick); if (pos2) - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, ": %s\n", pos2); + gui_printf (server->buffer, "%s: %s\n", + GUI_COLOR(COLOR_WIN_CHAT), + pos2); else gui_printf (server->buffer, "\n"); } @@ -1747,14 +1735,12 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume server_sendf (server, "NOTICE %s :\01PING\01\r\n", nick); irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, "CTCP "); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_CHANNEL, "PING "); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, _("received from")); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_NICK, " %s\n", nick); + gui_printf (server->buffer, + _("CTCP %sPING%s received from %s%s\n"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick); } return 0; } @@ -2022,9 +2008,11 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume gui_printf_nolog (server->buffer, _("%s unknown DCC CHAT type received from "), WEECHAT_ERROR); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_NICK, - "%s", nick); - gui_printf (server->buffer, ": \"%s\"\n", pos_file); + gui_printf (server->buffer, "%s%s%s: \"%s\"\n", + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick, + GUI_COLOR(COLOR_WIN_CHAT), + pos_file); return -1; } @@ -2066,10 +2054,11 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume irc_display_prefix (server, ptr_channel->buffer, PREFIX_ACTION_ME); if (irc_is_highlight (pos, server->nick)) { - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_MSG | MSG_TYPE_HIGHLIGHT, - COLOR_WIN_CHAT_HIGHLIGHT, - "%s", nick); + gui_printf_type (ptr_channel->buffer, + MSG_TYPE_MSG | MSG_TYPE_HIGHLIGHT, + "%s%s", + GUI_COLOR(COLOR_WIN_CHAT_HIGHLIGHT), + nick); if ( (cfg_look_infobar) && (cfg_look_infobar_delay_highlight > 0) && (ptr_channel->buffer != gui_current_window->buffer) ) @@ -2080,11 +2069,12 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume nick, pos); } else - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_MSG, - COLOR_WIN_CHAT_NICK, "%s", nick); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, " %s\n", pos); + gui_printf_type (ptr_channel->buffer, MSG_TYPE_MSG, + "%s%s", + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick); + gui_printf (ptr_channel->buffer, " %s%s\n", + GUI_COLOR(COLOR_WIN_CHAT), pos); } } else @@ -2110,17 +2100,17 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume pos2 = NULL; } irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, _("Unknown CTCP ")); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_CHANNEL, "%s ", pos); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, _("received from")); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_NICK, " %s", nick); + gui_printf (server->buffer, + _("Unknown CTCP %s%s%s received from %s%s"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + pos, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick); if (pos2) - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, ": %s\n", pos2); + gui_printf (server->buffer, "%s: %s\n", + GUI_COLOR(COLOR_WIN_CHAT), + pos2); else gui_printf (server->buffer, "\n"); } @@ -2147,15 +2137,16 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume if (!ptr_channel->topic) ptr_channel->topic = strdup (host2); - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_NICK, - COLOR_WIN_CHAT_DARK, "<"); + gui_printf_type (ptr_channel->buffer, MSG_TYPE_NICK, + "%s<", + GUI_COLOR(COLOR_WIN_CHAT_DARK)); if (irc_is_highlight (pos, server->nick)) { - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_NICK | MSG_TYPE_HIGHLIGHT, - COLOR_WIN_CHAT_HIGHLIGHT, - "%s", nick); + gui_printf_type (ptr_channel->buffer, + MSG_TYPE_NICK | MSG_TYPE_HIGHLIGHT, + "%s%s", + GUI_COLOR(COLOR_WIN_CHAT_HIGHLIGHT), + nick); if ( (cfg_look_infobar_delay_highlight > 0) && (ptr_channel->buffer != gui_current_window->buffer) ) gui_infobar_printf (cfg_look_infobar_delay_highlight, @@ -2164,16 +2155,17 @@ irc_cmd_recv_privmsg (t_irc_server *server, char *host, char *nick, char *argume nick, pos); } else - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_NICK, - COLOR_WIN_NICK_PRIVATE, - "%s", nick); - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_NICK, - COLOR_WIN_CHAT_DARK, "> "); - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_MSG, - COLOR_WIN_CHAT, "%s\n", pos); + gui_printf_type (ptr_channel->buffer, MSG_TYPE_NICK, + "%s%s", + GUI_COLOR(COLOR_WIN_NICK_PRIVATE), + nick); + gui_printf_type (ptr_channel->buffer, MSG_TYPE_NICK, + "%s> ", + GUI_COLOR(COLOR_WIN_CHAT_DARK)); + gui_printf_type (ptr_channel->buffer, MSG_TYPE_MSG, + "%s%s\n", + GUI_COLOR(COLOR_WIN_CHAT), + pos); } } } @@ -2228,26 +2220,21 @@ irc_cmd_recv_quit (t_irc_server *server, char *host, char *nick, char *arguments { pos = strchr (host, '!'); irc_display_prefix (server, ptr_channel->buffer, PREFIX_QUIT); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_NICK, "%s ", nick); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_DARK, "("); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_HOST, "%s", (pos) ? pos + 1 : ""); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_DARK, ") "); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, _("has quit")); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_DARK, " ("); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, "%s", - arguments); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_DARK, ")\n"); + gui_printf (ptr_channel->buffer, + _("%s%s %s(%s%s%s)%s has quit %s(%s%s%s)\n"), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_HOST), + (pos) ? pos + 1 : "", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + arguments, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); } - if (gui_buffer_has_nicklist (ptr_channel->buffer)) - gui_draw_buffer_nick (ptr_channel->buffer, 1); + gui_draw_buffer_nick (ptr_channel->buffer, 1); gui_draw_buffer_status (ptr_channel->buffer, 1); } } @@ -2281,7 +2268,8 @@ irc_cmd_recv_server_msg (t_irc_server *server, char *host, char *nick, char *arg if (!command_ignored) { irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, COLOR_WIN_CHAT, "%s\n", arguments); + gui_printf (server->buffer, "%s%s\n", + GUI_COLOR(COLOR_WIN_CHAT), arguments); } return 0; } @@ -2324,18 +2312,19 @@ irc_cmd_recv_server_reply (t_irc_server *server, char *host, char *nick, char *a { if (pos[0] == ':') pos++; - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, - "%s%s\n", (first) ? "" : ": ", pos); + gui_printf (server->buffer, "%s%s%s\n", + GUI_COLOR(COLOR_WIN_CHAT), + (first) ? "" : ": ", + pos); pos = NULL; } else { pos2[0] = '\0'; - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_CHANNEL, - "%s%s\n", - (first) ? "" : " ", pos); + gui_printf (server->buffer, "%s%s%s\n", + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + (first) ? "" : " ", + pos); first = 0; pos = pos2 + 1; } @@ -2388,28 +2377,24 @@ irc_cmd_recv_topic (t_irc_server *server, char *host, char *nick, char *argument if (!command_ignored) { irc_display_prefix (server, buffer, PREFIX_INFO); - gui_printf_color (buffer, - COLOR_WIN_CHAT_NICK, "%s", - nick); if (pos) - { - gui_printf_color (buffer, - COLOR_WIN_CHAT, _(" has changed topic for ")); - gui_printf_color (buffer, - COLOR_WIN_CHAT_CHANNEL, "%s", - arguments); - gui_printf_color (buffer, - COLOR_WIN_CHAT, _(" to: \"%s\"\n"), - pos); - } + gui_printf (buffer, + _("%s%s%s has changed topic for %s%s%s to: \"%s\"\n"), + 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); else - { - gui_printf_color (buffer, - COLOR_WIN_CHAT, _(" has unset topic for ")); - gui_printf_color (buffer, - COLOR_WIN_CHAT_CHANNEL, "%s\n", - arguments); - } + gui_printf (buffer, + _("%s%s%s has unset topic for %s%s\n"), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + nick, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + arguments); } if (ptr_channel) @@ -2514,12 +2499,14 @@ irc_cmd_recv_221 (t_irc_server *server, char *host, char *nick, char *arguments) if (!command_ignored) { irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, COLOR_WIN_CHAT, _("User mode")); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_DARK, " ["); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_NICK, "%s", arguments); - gui_printf_color (server->buffer, COLOR_WIN_CHAT, "/"); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_NICK, pos_mode); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_DARK, "]\n"); + gui_printf (server->buffer, _("User mode %s[%s%s%s/%s%s%s]\n"), + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + arguments, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + pos_mode, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); } } else @@ -2566,10 +2553,12 @@ irc_cmd_recv_301 (t_irc_server *server, char *host, char *nick, char *arguments) if (!command_ignored) { irc_display_prefix (server, gui_current_window->buffer, PREFIX_INFO); - gui_printf_color (gui_current_window->buffer, - COLOR_WIN_CHAT_NICK, "%s", pos_nick); - gui_printf_color (gui_current_window->buffer, - COLOR_WIN_CHAT, _(" is away: %s\n"), pos_message); + gui_printf (gui_current_window->buffer, + _("%s%s%s is away: %s\n"), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + pos_nick, + GUI_COLOR(COLOR_WIN_CHAT), + pos_message); } } } @@ -2616,12 +2605,12 @@ irc_cmd_recv_302 (t_irc_server *server, char *host, char *nick, char *arguments) } irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_NICK, "%s", arguments); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, "="); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_HOST, "%s\n", pos_host); + gui_printf (server->buffer, "%s%s%s=%s%s\n", + GUI_COLOR(COLOR_WIN_CHAT_NICK), + arguments, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_HOST), + pos_host); } else ptr_next = NULL; @@ -2650,8 +2639,7 @@ irc_cmd_recv_303 (t_irc_server *server, char *host, char *nick, char *arguments) if (!command_ignored) { irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, _("Users online: ")); + gui_printf (server->buffer, _("Users online: ")); arguments = strchr (arguments, ' '); if (arguments) @@ -2670,8 +2658,9 @@ irc_cmd_recv_303 (t_irc_server *server, char *host, char *nick, char *arguments) while (ptr_next[0] == ' ') ptr_next++; } - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_NICK, "%s ", arguments); + gui_printf (server->buffer, "%s%s ", + GUI_COLOR(COLOR_WIN_CHAT_NICK), + arguments); arguments = ptr_next; if (arguments && !arguments[0]) arguments = NULL; @@ -2703,8 +2692,7 @@ irc_cmd_recv_305 (t_irc_server *server, char *host, char *nick, char *arguments) if (arguments[0] == ':') arguments++; irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, "%s\n", arguments); + gui_printf (server->buffer, "%s\n", arguments); } } server->is_away = 0; @@ -2733,8 +2721,7 @@ irc_cmd_recv_306 (t_irc_server *server, char *host, char *nick, char *arguments) if (arguments[0] == ':') arguments++; irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, "%s\n", arguments); + gui_printf (server->buffer, "%s\n", arguments); } } server->is_away = 1; @@ -2773,15 +2760,13 @@ irc_cmd_recv_307 (t_irc_server *server, char *host, char *nick, char *arguments) pos_msg++; irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, "["); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_NICK, "%s", pos_nick); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, "] "); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, "%s\n", - pos_msg); + gui_printf (server->buffer, "%s[%s%s%s] %s%s\n", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + pos_nick, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + pos_msg); } } } @@ -2837,19 +2822,18 @@ irc_cmd_recv_311 (t_irc_server *server, char *host, char *nick, char *arguments) pos_realname++; irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, "["); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_NICK, "%s", pos_nick); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, "] ("); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_HOST, "%s@%s", - pos_user, pos_host); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, ")"); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, ": %s\n", pos_realname); + gui_printf (server->buffer, + "%s[%s%s%s] (%s%s@%s%s)%s: %s\n", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + pos_nick, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_HOST), + pos_user, + pos_host, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + pos_realname); } } } @@ -2896,20 +2880,18 @@ irc_cmd_recv_312 (t_irc_server *server, char *host, char *nick, char *arguments) pos_serverinfo++; irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, "["); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_NICK, "%s", pos_nick); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, "] "); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, "%s ", pos_server); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, "("); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, "%s", pos_serverinfo); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, ")\n"); + gui_printf (server->buffer, + "%s[%s%s%s] %s%s %s(%s%s%s)\n", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + pos_nick, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + pos_server, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + pos_serverinfo, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); } } } @@ -2948,14 +2930,13 @@ irc_cmd_recv_313 (t_irc_server *server, char *host, char *nick, char *arguments) pos_message++; irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, "["); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_NICK, "%s", pos_nick); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, "] "); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, "%s\n", pos_message); + gui_printf (server->buffer, "%s[%s%s%s] %s%s\n", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + pos_nick, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + pos_message); } } } @@ -3014,18 +2995,17 @@ irc_cmd_recv_314 (t_irc_server *server, char *host, char *nick, char *arguments) pos_realname++; irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_NICK, "%s", pos_nick); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, " ("); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_HOST, - "%s@%s", pos_user, pos_host); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, ")"); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, - " was %s\n", pos_realname); + gui_printf (server->buffer, + _("%s%s %s(%s%s@%s%s)%s was %s\n"), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + pos_nick, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_HOST), + pos_user, + pos_host, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + pos_realname); } } } @@ -3071,8 +3051,11 @@ irc_cmd_recv_315 (t_irc_server *server, char *host, char *nick, char *arguments) if (!command_ignored) { irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_CHANNEL, "%s", arguments); - gui_printf (server->buffer, " %s\n", pos); + gui_printf (server->buffer, "%s%s %s%s\n", + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + arguments, + GUI_COLOR(COLOR_WIN_CHAT), + pos); } } else @@ -3134,53 +3117,37 @@ irc_cmd_recv_317 (t_irc_server *server, char *host, char *nick, char *arguments) sec = ((idle_time % (60 * 60 * 24)) % (60 * 60)) % 60; irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, "["); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_NICK, "%s", pos_nick); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, "] "); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, _("idle: ")); + gui_printf (server->buffer, _("%s[%s%s%s]%s idle: "), + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + pos_nick, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT)); + if (day > 0) - { - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_CHANNEL, - "%d ", day); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, - (day > 1) ? _("days") : _("day")); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, - ", "); - } - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_CHANNEL, - "%02d ", hour); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, - (hour > 1) ? _("hours") : _("hour")); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_CHANNEL, - " %02d ", min); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, - (min > 1) ? _("minutes") : _("minute")); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_CHANNEL, - " %02d ", sec); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, - (sec > 1) ? _("seconds") : _("second")); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, - ", "); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, _("signon at: ")); + gui_printf (server->buffer, "%s%d %s%s, ", + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + day, + GUI_COLOR(COLOR_WIN_CHAT), + (day > 1) ? _("days") : _("day")); + datetime = (time_t)(atol (pos_signon)); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_CHANNEL, - "%s", ctime (&datetime)); + gui_printf (server->buffer, + _("%s%02d %s%s %s%02d %s%s %s%02d %s%s, signon at: %s%s"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + hour, + GUI_COLOR(COLOR_WIN_CHAT), + (hour > 1) ? _("hours") : _("hour"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + min, + GUI_COLOR(COLOR_WIN_CHAT), + (min > 1) ? _("minutes") : _("minute"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + sec, + GUI_COLOR(COLOR_WIN_CHAT), + (sec > 1) ? _("seconds") : _("second"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + ctime (&datetime)); } } } @@ -3220,14 +3187,13 @@ irc_cmd_recv_318 (t_irc_server *server, char *host, char *nick, char *arguments) pos_message++; irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, "["); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_NICK, "%s", pos_nick); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, "] "); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, "%s\n", pos_message); + gui_printf (server->buffer, "%s[%s%s%s] %s%s\n", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + pos_nick, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + pos_message); } } } @@ -3265,36 +3231,33 @@ irc_cmd_recv_319 (t_irc_server *server, char *host, char *nick, char *arguments) pos_channel++; irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, "["); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_NICK, "%s", pos_nick); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, "] "); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, _("Channels: ")); - + gui_printf (server->buffer, "%s[%s%s%s]%s Channels: ", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + pos_nick, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT)); while (pos_channel && pos_channel[0]) { if (pos_channel[0] == '@') { - gui_printf_color (server->buffer, - COLOR_WIN_NICK_OP, "@"); + gui_printf (server->buffer, "%s@", + GUI_COLOR(COLOR_WIN_NICK_OP)); pos_channel++; } else { if (pos_channel[0] == '%') { - gui_printf_color (server->buffer, - COLOR_WIN_NICK_HALFOP, "%"); + gui_printf (server->buffer, "%s%%", + GUI_COLOR(COLOR_WIN_NICK_HALFOP)); pos_channel++; } else if (pos_channel[0] == '+') { - gui_printf_color (server->buffer, - COLOR_WIN_NICK_VOICE, "+"); + gui_printf (server->buffer, "%s+", + GUI_COLOR(COLOR_WIN_NICK_VOICE)); pos_channel++; } } @@ -3306,11 +3269,10 @@ irc_cmd_recv_319 (t_irc_server *server, char *host, char *nick, char *arguments) while (pos[0] == ' ') pos++; } - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_CHANNEL, - "%s%s", - pos_channel, - (pos && pos[0]) ? " " : "\n"); + gui_printf (server->buffer, "%s%s%s", + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + pos_channel, + (pos && pos[0]) ? " " : "\n"); pos_channel = pos; } } @@ -3350,14 +3312,13 @@ irc_cmd_recv_320 (t_irc_server *server, char *host, char *nick, char *arguments) pos_message++; irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, "["); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_NICK, "%s", pos_nick); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, "] "); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, "%s\n", pos_message); + gui_printf (server->buffer, "%s[%s%s%s] %s%s\n", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + pos_nick, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + pos_message); } } } @@ -3568,10 +3529,9 @@ irc_cmd_recv_331 (t_irc_server *server, char *host, char *nick, char *arguments) if (!command_ignored) { irc_display_prefix (server, ptr_channel->buffer, PREFIX_INFO); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, _("No topic set for ")); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_CHANNEL, "%s\n", pos_channel); + gui_printf (ptr_channel->buffer, _("No topic set for %s%s\n"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + pos_channel); } } else @@ -3625,12 +3585,11 @@ irc_cmd_recv_332 (t_irc_server *server, char *host, char *nick, char *arguments) if (!command_ignored) { irc_display_prefix (server, ptr_channel->buffer, PREFIX_INFO); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, _("Topic for ")); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_CHANNEL, "%s", pos); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, _(" is: \"%s\"\n"), pos2); + gui_printf (ptr_channel->buffer, _("Topic for %s%s%s is: \"%s\"\n"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + pos, + GUI_COLOR(COLOR_WIN_CHAT), + pos2); } gui_draw_buffer_title (ptr_channel->buffer, 1); @@ -3697,14 +3656,13 @@ irc_cmd_recv_333 (t_irc_server *server, char *host, char *nick, char *arguments) command_ignored |= ignore_check (host, "333", ptr_channel->name, server->name); if (!command_ignored) { - irc_display_prefix (server, ptr_channel->buffer, PREFIX_INFO); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, _("Topic set by ")); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_NICK, "%s", pos_nick); datetime = (time_t)(atol (pos_date)); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, ", %s", ctime (&datetime)); + irc_display_prefix (server, ptr_channel->buffer, PREFIX_INFO); + gui_printf (ptr_channel->buffer, _("Topic set by %s%s%s, %s"), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + pos_nick, + GUI_COLOR(COLOR_WIN_CHAT), + ctime (&datetime)); } } else @@ -3777,14 +3735,16 @@ irc_cmd_recv_341 (t_irc_server *server, char *host, char *nick, char *arguments) pos_channel++; irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_NICK, - "%s ", arguments); - gui_printf (server->buffer, _("has invited")); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_NICK, - " %s ", pos_nick); - gui_printf (server->buffer, _("on")); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_CHANNEL, - " %s\n", pos_channel); + gui_printf (server->buffer, + _("%s%s%s has invited %s%s%s on %s%s\n"), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + arguments, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + pos_nick, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + pos_channel); gui_draw_buffer_status (gui_current_window->buffer, 1); } else @@ -3836,14 +3796,12 @@ irc_cmd_recv_344 (t_irc_server *server, char *host, char *nick, char *arguments) pos_host++; irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, _("Channel reop")); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_CHANNEL, " %s", pos_channel); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, ": "); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_HOST, "%s\n", pos_host); + gui_printf (server->buffer, _("Channel reop %s%s%s: %s%s\n"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + pos_channel, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_HOST), + pos_host); } } } @@ -3879,8 +3837,11 @@ irc_cmd_recv_345 (t_irc_server *server, char *host, char *nick, char *arguments) if (!command_ignored) { irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_CHANNEL, "%s", arguments); - gui_printf (server->buffer, " %s\n", pos); + gui_printf (server->buffer, "%s%s %s%s\n", + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + arguments, + GUI_COLOR(COLOR_WIN_CHAT), + pos); } } else @@ -3986,25 +3947,35 @@ irc_cmd_recv_348 (t_irc_server *server, char *host, char *nick, char *arguments) if (!command_ignored) { irc_display_prefix (server, buffer, PREFIX_INFO); - gui_printf_color (buffer, COLOR_WIN_CHAT_DARK, "["); - gui_printf_color (buffer, COLOR_WIN_CHAT_CHANNEL, "%s", pos_channel); - gui_printf_color (buffer, COLOR_WIN_CHAT_DARK, "] "); - gui_printf (buffer, _("exception")); - gui_printf_color (buffer, COLOR_WIN_CHAT_HOST, " %s ", pos_exception); - gui_printf (buffer, _("by")); + gui_printf (buffer, "%s[%s%s%s]%s exception %s%s%s by ", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + pos_channel, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_HOST), + pos_exception, + GUI_COLOR(COLOR_WIN_CHAT)); pos = strchr (pos_user, '!'); if (pos) { pos[0] = '\0'; - gui_printf_color (buffer, COLOR_WIN_CHAT_NICK, " %s ", pos_user); - gui_printf_color (buffer, COLOR_WIN_CHAT_DARK, "("); - gui_printf_color (buffer, COLOR_WIN_CHAT_HOST, "%s", pos + 1); - gui_printf_color (buffer, COLOR_WIN_CHAT_DARK, ")"); + gui_printf (buffer, "%s%s %s(%s%s%s)", + GUI_COLOR(COLOR_WIN_CHAT_NICK), + pos_user, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_HOST), + pos + 1, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); } else - gui_printf_color (buffer, COLOR_WIN_CHAT_NICK, " %s", pos_user); + gui_printf (buffer,"%s%s", + GUI_COLOR(COLOR_WIN_CHAT_NICK), + pos_user); datetime = (time_t)(atol (pos_date)); - gui_printf_nolog (buffer, ", %s", ctime (&datetime)); + gui_printf_nolog (buffer, "%s, %s", + GUI_COLOR(COLOR_WIN_CHAT), + ctime (&datetime)); } return 0; } @@ -4061,11 +4032,14 @@ irc_cmd_recv_349 (t_irc_server *server, char *host, char *nick, char *arguments) if (!command_ignored) { irc_display_prefix (server, buffer, PREFIX_INFO); - gui_printf_color (buffer, COLOR_WIN_CHAT_DARK, "["); - gui_printf_color (buffer, COLOR_WIN_CHAT_CHANNEL, "%s", pos_channel); - gui_printf_color (buffer, COLOR_WIN_CHAT_DARK, "] "); - gui_printf_nolog (buffer, "%s\n", pos_msg); - } + gui_printf (buffer, "%s[%s%s%s] %s%s\n", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + pos_channel, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + pos_msg); + } return 0; } @@ -4198,32 +4172,23 @@ irc_cmd_recv_352 (t_irc_server *server, char *host, char *nick, char *arguments) { irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_NICK, - "%s ", pos_nick); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, - _("on")); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_CHANNEL, - " %s", pos_channel); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, - " %s %s ", - pos_attr, pos_hopcount); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_HOST, - "%s@%s", - pos_user, pos_host); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, - " ("); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, - "%s", pos_realname); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, - ")\n"); + gui_printf (server->buffer, + "%s%s%s on %s%s%s %s %s %s%s@%s %s(%s%s%s)\n", + GUI_COLOR(COLOR_WIN_CHAT_NICK), + pos_nick, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + pos_channel, + GUI_COLOR(COLOR_WIN_CHAT), + pos_attr, + pos_hopcount, + GUI_COLOR(COLOR_WIN_CHAT_HOST), + pos_user, + pos_host, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + pos_realname, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); } } } @@ -4386,12 +4351,11 @@ irc_cmd_recv_366 (t_irc_server *server, char *host, char *nick, char *arguments) { /* display users on channel */ irc_display_prefix (server, ptr_channel->buffer, PREFIX_SERVER); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT, - _("Nicks ")); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT_CHANNEL, - "%s", ptr_channel->name); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT, ": "); - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT_DARK, "["); + gui_printf (ptr_channel->buffer, _("Nicks %s%s%s: %s["), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + ptr_channel->name, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_DARK)); for (ptr_nick = ptr_channel->nicks; ptr_nick; ptr_nick = ptr_nick->next_nick) { @@ -4400,62 +4364,41 @@ irc_cmd_recv_366 (t_irc_server *server, char *host, char *nick, char *arguments) if (ptr_nick != ptr_channel->last_nick) gui_printf (ptr_channel->buffer, " "); } - gui_printf_color (ptr_channel->buffer, COLOR_WIN_CHAT_DARK, "]\n"); + gui_printf (ptr_channel->buffer, "%s]\n", + GUI_COLOR(COLOR_WIN_CHAT_DARK)); /* display number of nicks, ops, halfops & voices on the channel */ nick_count (ptr_channel, &num_nicks, &num_op, &num_halfop, &num_voice, &num_normal); irc_display_prefix (server, ptr_channel->buffer, PREFIX_INFO); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, _("Channel ")); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_CHANNEL, - "%s", ptr_channel->name); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, ": "); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_CHANNEL, - "%d ", num_nicks); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, - (num_nicks > 1) ? _("nicks") : _("nick")); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_DARK, " ("); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_CHANNEL, - "%d ", num_op); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, - (num_op > 1) ? _("ops") : _("op")); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, - ", "); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_CHANNEL, - "%d ", num_halfop); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, - (num_halfop > 1) ? _("halfops") : _("halfop")); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, - ", "); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_CHANNEL, - "%d ", num_voice); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, - (num_voice > 1) ? _("voices") : _("voice")); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, - ", "); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_CHANNEL, - "%d ", num_normal); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, - _("normal")); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_DARK, ")\n"); + gui_printf (ptr_channel->buffer, + _("Channel %s%s%s: %s%d%s %s %s(%s%d%s %s, " + "%s%d%s %s, %s%d%s %s, %s%d%s %s%s)\n"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + ptr_channel->name, + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + num_nicks, + GUI_COLOR(COLOR_WIN_CHAT), + (num_nicks > 1) ? _("nicks") : _("nick"), + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + num_op, + GUI_COLOR(COLOR_WIN_CHAT), + (num_op > 1) ? _("ops") : _("op"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + num_halfop, + GUI_COLOR(COLOR_WIN_CHAT), + (num_halfop > 1) ? _("halfops") : _("halfop"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + num_voice, + GUI_COLOR(COLOR_WIN_CHAT), + (num_voice > 1) ? _("voices") : _("voice"), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + num_normal, + GUI_COLOR(COLOR_WIN_CHAT), + _("normal"), + GUI_COLOR(COLOR_WIN_CHAT_DARK)); } irc_cmd_send_mode (server, ptr_channel->name); if (cfg_irc_away_check > 0) @@ -4466,10 +4409,11 @@ irc_cmd_recv_366 (t_irc_server *server, char *host, char *nick, char *arguments) if (!command_ignored) { irc_display_prefix (server, gui_current_window->buffer, PREFIX_INFO); - gui_printf_color (gui_current_window->buffer, - COLOR_WIN_CHAT_CHANNEL, pos); - gui_printf_color (gui_current_window->buffer, - COLOR_WIN_CHAT, ": %s\n", pos2); + gui_printf (gui_current_window->buffer, "%s%s%s: %s\n", + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + pos, + GUI_COLOR(COLOR_WIN_CHAT), + pos2); } return 0; } @@ -4524,42 +4468,24 @@ irc_cmd_recv_367 (t_irc_server *server, char *host, char *nick, char *arguments) pos_ban++; /* look for user who set ban */ + pos_date = NULL; pos_user = strchr (pos_ban, ' '); - if (!pos_user) + if (pos_user) { - irc_display_prefix (server, server->buffer, PREFIX_ERROR); - gui_printf_nolog (server->buffer, - _("%s cannot parse \"%s\" command\n"), - WEECHAT_ERROR, "367"); - return -1; - } - pos_user[0] = '\0'; - pos_user++; - while (pos_user[0] == ' ') + pos_user[0] = '\0'; pos_user++; - - /* look for date/time */ - pos_date = strchr (pos_user, ' '); - if (!pos_date) - { - irc_display_prefix (server, server->buffer, PREFIX_ERROR); - gui_printf_nolog (server->buffer, - _("%s cannot parse \"%s\" command\n"), - WEECHAT_ERROR, "367"); - return -1; - } - pos_date[0] = '\0'; - pos_date++; - while (pos_date[0] == ' ') - pos_date++; - - if (!pos_date || !pos_date[0]) - { - irc_display_prefix (server, server->buffer, PREFIX_ERROR); - gui_printf_nolog (server->buffer, - _("%s cannot parse \"%s\" command\n"), - WEECHAT_ERROR, "367"); - return -1; + while (pos_user[0] == ' ') + pos_user++; + + /* look for date/time */ + pos_date = strchr (pos_user, ' '); + if (pos_date) + { + pos_date[0] = '\0'; + pos_date++; + while (pos_date[0] == ' ') + pos_date++; + } } ptr_channel = channel_search (server, pos_channel); @@ -4570,24 +4496,51 @@ irc_cmd_recv_367 (t_irc_server *server, char *host, char *nick, char *arguments) if (!command_ignored) { irc_display_prefix (server, buffer, PREFIX_INFO); - gui_printf_color (buffer, COLOR_WIN_CHAT_DARK, "["); - gui_printf_color (buffer, COLOR_WIN_CHAT_CHANNEL, "%s", pos_channel); - gui_printf_color (buffer, COLOR_WIN_CHAT_DARK, "] "); - gui_printf_color (buffer, COLOR_WIN_CHAT_HOST, "%s ", pos_ban); - gui_printf (buffer, _("banned by")); - pos = strchr (pos_user, '!'); - if (pos) + if (pos_user) { - pos[0] = '\0'; - gui_printf_color (buffer, COLOR_WIN_CHAT_NICK, " %s ", pos_user); - gui_printf_color (buffer, COLOR_WIN_CHAT_DARK, "("); - gui_printf_color (buffer, COLOR_WIN_CHAT_HOST, "%s", pos + 1); - gui_printf_color (buffer, COLOR_WIN_CHAT_DARK, ")"); + gui_printf_nolog (buffer, _("%s[%s%s%s] %s%s%s banned by "), + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + pos_channel, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_HOST), + pos_ban, + GUI_COLOR(COLOR_WIN_CHAT)); + pos = strchr (pos_user, '!'); + if (pos) + { + pos[0] = '\0'; + gui_printf (buffer, "%s%s %s(%s%s%s)", + GUI_COLOR(COLOR_WIN_CHAT_NICK), + pos_user, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_HOST), + pos + 1, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); + } + else + gui_printf (buffer, "%s%s", + GUI_COLOR(COLOR_WIN_CHAT_NICK), + pos_user); + if (pos_date) + { + datetime = (time_t)(atol (pos_date)); + gui_printf (buffer, "%s, %s", + GUI_COLOR(COLOR_WIN_CHAT), + ctime (&datetime)); + } + else + gui_printf (buffer, "\n"); } else - gui_printf_color (buffer, COLOR_WIN_CHAT_NICK, " %s", pos_user); - datetime = (time_t)(atol (pos_date)); - gui_printf_nolog (buffer, ", %s", ctime (&datetime)); + gui_printf_nolog (buffer, _("%s[%s%s%s] %s%s%s banned\n"), + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + pos_channel, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_HOST), + pos_ban, + GUI_COLOR(COLOR_WIN_CHAT)); } return 0; } @@ -4644,10 +4597,13 @@ irc_cmd_recv_368 (t_irc_server *server, char *host, char *nick, char *arguments) if (!command_ignored) { irc_display_prefix (server, buffer, PREFIX_INFO); - gui_printf_color (buffer, COLOR_WIN_CHAT_DARK, "["); - gui_printf_color (buffer, COLOR_WIN_CHAT_CHANNEL, "%s", pos_channel); - gui_printf_color (buffer, COLOR_WIN_CHAT_DARK, "] "); - gui_printf_nolog (buffer, "%s\n", pos_msg); + gui_printf_nolog (buffer, "%s[%s%s%s] %s%s\n", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + pos_channel, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + pos_msg); } return 0; } @@ -4796,14 +4752,13 @@ irc_cmd_recv_671 (t_irc_server *server, char *host, char *nick, char *arguments) pos_message++; irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, "["); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_NICK, "%s", pos_nick); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT_DARK, "] "); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, "%s\n", pos_message); + gui_printf (server->buffer, "%s[%s%s%s] %s%s\n", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + pos_nick, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + pos_message); } } } diff --git a/src/irc/irc-send.c b/src/irc/irc-send.c index fea02fbbe..2581b21a3 100644 --- a/src/irc/irc-send.c +++ b/src/irc/irc-send.c @@ -110,11 +110,11 @@ irc_cmd_send_ame (t_irc_server *server, char *arguments) ptr_channel->name, (arguments && arguments[0]) ? arguments : ""); irc_display_prefix (NULL, ptr_channel->buffer, PREFIX_ACTION_ME); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT_NICK, "%s", ptr_server->nick); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, " %s\n", - (arguments && arguments[0]) ? arguments : ""); + gui_printf (ptr_channel->buffer, "%s%s %s%s\n", + GUI_COLOR(COLOR_WIN_CHAT_NICK), + ptr_server->nick, + GUI_COLOR(COLOR_WIN_CHAT), + (arguments && arguments[0]) ? arguments : ""); } } } @@ -157,8 +157,7 @@ irc_cmd_send_amsg (t_irc_server *server, char *arguments) { irc_display_nick (ptr_channel->buffer, ptr_nick, NULL, MSG_TYPE_NICK, 1, 1, 0); - gui_printf_color (ptr_channel->buffer, - COLOR_WIN_CHAT, "%s\n", arguments); + gui_printf (ptr_channel->buffer, "%s\n", arguments); } else { @@ -401,20 +400,23 @@ irc_cmd_send_ctcp (t_irc_server *server, char *arguments) } irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, COLOR_WIN_CHAT, "CTCP"); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_DARK, "("); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_NICK, "%s", arguments); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_DARK, ")"); - gui_printf_color (server->buffer, COLOR_WIN_CHAT, ": "); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_CHANNEL, "%s", pos_type); + gui_printf (server->buffer, "CTCP%s(%s%s%s)%s: %s%s", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + arguments, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + GUI_COLOR(COLOR_WIN_CHAT_CHANNEL), + pos_type); if ((ascii_strcasecmp (pos_type, "ping") == 0) && (!pos_args)) { gettimeofday (&tv, &tz); server_sendf (server, "PRIVMSG %s :\01PING %d %d\01\r\n", arguments, tv.tv_sec, tv.tv_usec); - gui_printf_color (server->buffer, COLOR_WIN_CHAT, " %d %d\n", - tv.tv_sec, tv.tv_usec); + gui_printf (server->buffer, " %s%d %d\n", + GUI_COLOR(COLOR_WIN_CHAT), + tv.tv_sec, tv.tv_usec); } else { @@ -422,8 +424,9 @@ irc_cmd_send_ctcp (t_irc_server *server, char *arguments) { server_sendf (server, "PRIVMSG %s :\01%s %s\01\r\n", arguments, pos_type, pos_args); - gui_printf_color (server->buffer, COLOR_WIN_CHAT, " %s\n", - pos_args); + gui_printf (server->buffer, " %s%s\n", + GUI_COLOR(COLOR_WIN_CHAT), + pos_args); } else { @@ -906,11 +909,11 @@ irc_send_me (t_irc_server *server, t_irc_channel *channel, char *arguments) channel->name, (arguments && arguments[0]) ? arguments : ""); irc_display_prefix (NULL, channel->buffer, PREFIX_ACTION_ME); - gui_printf_color (channel->buffer, - COLOR_WIN_CHAT_NICK, "%s", server->nick); - gui_printf_color (channel->buffer, - COLOR_WIN_CHAT, " %s\n", - (arguments && arguments[0]) ? arguments : ""); + gui_printf (channel->buffer, "%s%s %s%s\n", + GUI_COLOR(COLOR_WIN_CHAT_NICK), + server->nick, + GUI_COLOR(COLOR_WIN_CHAT), + (arguments && arguments[0]) ? arguments : ""); return 0; } @@ -1020,9 +1023,7 @@ irc_cmd_send_msg (t_irc_server *server, char *arguments) { irc_display_nick (ptr_channel->buffer, ptr_nick, NULL, MSG_TYPE_NICK, 1, 1, 0); - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_MSG, - COLOR_WIN_CHAT, "%s\n", pos); + gui_printf_type (ptr_channel->buffer, MSG_TYPE_MSG, "%s\n", pos); } else { @@ -1045,9 +1046,7 @@ irc_cmd_send_msg (t_irc_server *server, char *arguments) { irc_display_nick (ptr_channel->buffer, ptr_nick, NULL, MSG_TYPE_NICK, 1, 1, 0); - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_MSG, - COLOR_WIN_CHAT, "%s\n", pos); + gui_printf_type (ptr_channel->buffer, MSG_TYPE_MSG, "%s\n", pos); } else { @@ -1081,17 +1080,15 @@ irc_cmd_send_msg (t_irc_server *server, char *arguments) } } irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_type_color (server->buffer, - MSG_TYPE_NICK, - COLOR_WIN_CHAT_DARK, "-"); - gui_printf_type_color (server->buffer, - MSG_TYPE_NICK, - COLOR_WIN_CHAT_NICK, "%s", arguments); - gui_printf_type_color (server->buffer, - MSG_TYPE_NICK, - COLOR_WIN_CHAT_DARK, "-"); - gui_printf_color (server->buffer, - COLOR_WIN_CHAT, " %s\n", msg_pwd_hidden); + gui_printf_type (server->buffer, MSG_TYPE_NICK, + "%s-%s%s%s- ", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + arguments, + COLOR_WIN_CHAT_DARK); + gui_printf (server->buffer, "%s%s\n", + GUI_COLOR(COLOR_WIN_CHAT), + msg_pwd_hidden); server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos); free (msg_pwd_hidden); return 0; @@ -1112,19 +1109,16 @@ irc_cmd_send_msg (t_irc_server *server, char *arguments) gui_draw_buffer_title (ptr_channel->buffer, 1); } - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_NICK, - COLOR_WIN_CHAT_DARK, "<"); - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_NICK, - COLOR_WIN_NICK_SELF, - "%s", server->nick); - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_NICK, - COLOR_WIN_CHAT_DARK, "> "); - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_MSG, - COLOR_WIN_CHAT, "%s\n", pos); + gui_printf_type (ptr_channel->buffer, MSG_TYPE_NICK, + "%s<%s%s%s> ", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_NICK_SELF), + server->nick, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); + gui_printf_type (ptr_channel->buffer, MSG_TYPE_MSG, + "%s%s\n", + GUI_COLOR(COLOR_WIN_CHAT), + pos); server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos); } } @@ -1217,11 +1211,13 @@ irc_cmd_send_notice (t_irc_server *server, char *arguments) while (pos[0] == ' ') pos++; irc_display_prefix (server, server->buffer, PREFIX_SERVER); - gui_printf_color (server->buffer, COLOR_WIN_CHAT, "notice"); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_DARK, "("); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_NICK, "%s", arguments); - gui_printf_color (server->buffer, COLOR_WIN_CHAT_DARK, ")"); - gui_printf_color (server->buffer, COLOR_WIN_CHAT, ": %s\n", pos); + gui_printf (server->buffer, "notice%s(%s%s%s)%s: %s\n", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT_NICK), + arguments, + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_CHAT), + pos); server_sendf (server, "NOTICE %s :%s\r\n", arguments, pos); } else @@ -1435,19 +1431,16 @@ irc_cmd_send_query (t_irc_server *server, char *arguments) /* display text if given */ if (pos) { - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_NICK, - COLOR_WIN_CHAT_DARK, "<"); - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_NICK, - COLOR_WIN_NICK_SELF, - "%s", server->nick); - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_NICK, - COLOR_WIN_CHAT_DARK, "> "); - gui_printf_type_color (ptr_channel->buffer, - MSG_TYPE_MSG, - COLOR_WIN_CHAT, "%s\n", pos); + gui_printf_type (ptr_channel->buffer, MSG_TYPE_NICK, + "%s<%s%s%s> ", + GUI_COLOR(COLOR_WIN_CHAT_DARK), + GUI_COLOR(COLOR_WIN_NICK_SELF), + server->nick, + GUI_COLOR(COLOR_WIN_CHAT_DARK)); + gui_printf_type (ptr_channel->buffer, MSG_TYPE_MSG, + "%s\n", + GUI_COLOR(COLOR_WIN_CHAT), + pos); server_sendf (server, "PRIVMSG %s :%s\r\n", arguments, pos); } return 0; diff --git a/src/irc/irc-server.c b/src/irc/irc-server.c index 5cce3faa5..ea2f2d777 100644 --- a/src/irc/irc-server.c +++ b/src/irc/irc-server.c @@ -672,7 +672,7 @@ server_msgq_flush () irc_display_prefix (recv_msgq->server, recv_msgq->server->buffer, PREFIX_ERROR); gui_printf (recv_msgq->server->buffer, - _("%s Command '%s' failed!\n"), WEECHAT_ERROR, command); + _("%s Command \"%s\" failed!\n"), WEECHAT_ERROR, command); break; case -2: irc_display_prefix (recv_msgq->server, @@ -684,7 +684,7 @@ server_msgq_flush () irc_display_prefix (recv_msgq->server, recv_msgq->server->buffer, PREFIX_ERROR); gui_printf (recv_msgq->server->buffer, - _("%s Unknown command: cmd=%s, host=%s, args=%s\n"), + _("%s Unknown command: cmd=\"%s\", host=\"%s\", args=\"%s\"\n"), WEECHAT_WARNING, command, host, args); break; } diff --git a/src/plugins/plugins-interface.c b/src/plugins/plugins-interface.c index 66728d611..b65cdb540 100644 --- a/src/plugins/plugins-interface.c +++ b/src/plugins/plugins-interface.c @@ -482,7 +482,7 @@ weechat_plugin_get_config_str_value (t_config_option *option, void *value) return option->array_values[*((int *)value)]; break; case OPTION_TYPE_COLOR: - color_name = gui_get_color_by_value (*((int *)value)); + color_name = gui_get_color_name (*((int *)value)); return (color_name) ? strdup (color_name) : strdup (""); break; case OPTION_TYPE_STRING: |