From ca1e0dde07501093ac90244a06715b5c3bfb79ee Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Sat, 27 Jul 2013 22:31:36 +0200 Subject: [PATCH] core: use default value for prefixes used in messages displayed before the interface is initialized --- src/core/wee-config.c | 15 ++++++++++----- src/gui/gui-chat.c | 19 +++++++++++++------ src/gui/gui-chat.h | 6 ++++++ 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/core/wee-config.c b/src/core/wee-config.c index ad547481b..b7f794713 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -2272,31 +2272,36 @@ config_weechat_init_options () "prefix_error", "string", N_("prefix for error messages, colors are allowed with format " "\"${color}\""), - NULL, 0, 0, "=!=", NULL, 0, NULL, NULL, &config_change_prefix, NULL, NULL, NULL); + NULL, 0, 0, GUI_CHAT_PREFIX_ERROR_DEFAULT, + NULL, 0, NULL, NULL, &config_change_prefix, NULL, NULL, NULL); config_look_prefix[GUI_CHAT_PREFIX_NETWORK] = config_file_new_option ( weechat_config_file, ptr_section, "prefix_network", "string", N_("prefix for network messages, colors are allowed with format " "\"${color}\""), - NULL, 0, 0, "--", NULL, 0, NULL, NULL, &config_change_prefix, NULL, NULL, NULL); + NULL, 0, 0, GUI_CHAT_PREFIX_NETWORK_DEFAULT, + NULL, 0, NULL, NULL, &config_change_prefix, NULL, NULL, NULL); config_look_prefix[GUI_CHAT_PREFIX_ACTION] = config_file_new_option ( weechat_config_file, ptr_section, "prefix_action", "string", N_("prefix for action messages, colors are allowed with format " "\"${color}\""), - NULL, 0, 0, " *", NULL, 0, NULL, NULL, &config_change_prefix, NULL, NULL, NULL); + NULL, 0, 0, GUI_CHAT_PREFIX_ACTION_DEFAULT, + NULL, 0, NULL, NULL, &config_change_prefix, NULL, NULL, NULL); config_look_prefix[GUI_CHAT_PREFIX_JOIN] = config_file_new_option ( weechat_config_file, ptr_section, "prefix_join", "string", N_("prefix for join messages, colors are allowed with format " "\"${color}\""), - NULL, 0, 0, "-->", NULL, 0, NULL, NULL, &config_change_prefix, NULL, NULL, NULL); + NULL, 0, 0, GUI_CHAT_PREFIX_JOIN_DEFAULT, + NULL, 0, NULL, NULL, &config_change_prefix, NULL, NULL, NULL); config_look_prefix[GUI_CHAT_PREFIX_QUIT] = config_file_new_option ( weechat_config_file, ptr_section, "prefix_quit", "string", N_("prefix for quit messages, colors are allowed with format " "\"${color}\""), - NULL, 0, 0, "<--", NULL, 0, NULL, NULL, &config_change_prefix, NULL, NULL, NULL); + NULL, 0, 0, GUI_CHAT_PREFIX_QUIT_DEFAULT, + NULL, 0, NULL, NULL, &config_change_prefix, NULL, NULL, NULL); config_look_prefix_align = config_file_new_option ( weechat_config_file, ptr_section, "prefix_align", "integer", diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c index ba665ea7d..22b0acfe2 100644 --- a/src/gui/gui-chat.c +++ b/src/gui/gui-chat.c @@ -65,12 +65,19 @@ char *gui_chat_lines_waiting_buffer = NULL; /* lines waiting for core */ void gui_chat_init () { - /* build empty prefixes */ - gui_chat_prefix[GUI_CHAT_PREFIX_ERROR] = strdup (gui_chat_prefix_empty); - gui_chat_prefix[GUI_CHAT_PREFIX_NETWORK] = strdup (gui_chat_prefix_empty); - gui_chat_prefix[GUI_CHAT_PREFIX_ACTION] = strdup (gui_chat_prefix_empty); - gui_chat_prefix[GUI_CHAT_PREFIX_JOIN] = strdup (gui_chat_prefix_empty); - gui_chat_prefix[GUI_CHAT_PREFIX_QUIT] = strdup (gui_chat_prefix_empty); + char *default_prefix[GUI_CHAT_NUM_PREFIXES] = + { GUI_CHAT_PREFIX_ERROR_DEFAULT, GUI_CHAT_PREFIX_NETWORK_DEFAULT, + GUI_CHAT_PREFIX_ACTION_DEFAULT, GUI_CHAT_PREFIX_JOIN_DEFAULT, + GUI_CHAT_PREFIX_QUIT_DEFAULT }; + char str_prefix[64]; + int i; + + /* build default prefixes */ + for (i = 0; i < GUI_CHAT_NUM_PREFIXES; i++) + { + snprintf (str_prefix, sizeof (str_prefix), "%s\t", default_prefix[i]); + gui_chat_prefix[i] = strdup (str_prefix); + } /* some hsignals */ hook_hsignal (NULL, "chat_quote_time_prefix_message", diff --git a/src/gui/gui-chat.h b/src/gui/gui-chat.h index 5fb40478c..cd77d77d0 100644 --- a/src/gui/gui-chat.h +++ b/src/gui/gui-chat.h @@ -30,6 +30,12 @@ struct t_gui_line; #define GUI_CHAT_TAG_NO_HIGHLIGHT "no_highlight" +#define GUI_CHAT_PREFIX_ERROR_DEFAULT "=!=" +#define GUI_CHAT_PREFIX_NETWORK_DEFAULT "--" +#define GUI_CHAT_PREFIX_ACTION_DEFAULT " *" +#define GUI_CHAT_PREFIX_JOIN_DEFAULT "-->" +#define GUI_CHAT_PREFIX_QUIT_DEFAULT "<--" + enum t_gui_chat_prefix { GUI_CHAT_PREFIX_ERROR = 0,