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

core: add color support in options weechat.look.prefix_{action|error|join|network|quit} (task #9555)

This commit is contained in:
Nils Görs
2012-12-01 16:03:20 +01:00
committed by Sebastien Helleu
parent 638b2e3f1c
commit 2ae8d81b1f
19 changed files with 349 additions and 185 deletions
+10 -5
View File
@@ -2117,27 +2117,32 @@ config_weechat_init_options ()
config_look_prefix[GUI_CHAT_PREFIX_ERROR] = config_file_new_option (
weechat_config_file, ptr_section,
"prefix_error", "string",
N_("prefix for error messages"),
N_("prefix for error messages, colors are allowed with format "
"\"${color}\""),
NULL, 0, 0, "=!=", 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"),
N_("prefix for network messages, colors are allowed with format "
"\"${color}\""),
NULL, 0, 0, "--", 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"),
N_("prefix for action messages, colors are allowed with format "
"\"${color}\""),
NULL, 0, 0, " *", 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"),
N_("prefix for join messages, colors are allowed with format "
"\"${color}\""),
NULL, 0, 0, "-->", 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"),
N_("prefix for quit messages, colors are allowed with format "
"\"${color}\""),
NULL, 0, 0, "<--", NULL, 0, NULL, NULL, &config_change_prefix, NULL, NULL, NULL);
config_look_prefix_align = config_file_new_option (
weechat_config_file, ptr_section,
+18 -26
View File
@@ -91,7 +91,12 @@ gui_chat_init ()
void
gui_chat_prefix_build ()
{
char prefix[128];
const char *ptr_prefix;
char prefix[512], *pos_color;
int prefix_color[GUI_CHAT_NUM_PREFIXES] =
{ GUI_COLOR_CHAT_PREFIX_ERROR, GUI_COLOR_CHAT_PREFIX_NETWORK,
GUI_COLOR_CHAT_PREFIX_ACTION, GUI_COLOR_CHAT_PREFIX_JOIN,
GUI_COLOR_CHAT_PREFIX_QUIT };
int i;
for (i = 0; i < GUI_CHAT_NUM_PREFIXES; i++)
@@ -101,32 +106,19 @@ gui_chat_prefix_build ()
free (gui_chat_prefix[i]);
gui_chat_prefix[i] = NULL;
}
ptr_prefix = CONFIG_STRING(config_look_prefix[i]);
pos_color = strstr (ptr_prefix, "${");
snprintf(prefix, sizeof (prefix), "%s%s\t",
(!pos_color || (pos_color > ptr_prefix)) ? GUI_COLOR(prefix_color[i]) : "",
ptr_prefix);
if (pos_color)
gui_chat_prefix[i] = gui_color_string_replace_colors (prefix);
else
gui_chat_prefix[i] = strdup (prefix);
}
snprintf (prefix, sizeof (prefix), "%s%s\t",
GUI_COLOR(GUI_COLOR_CHAT_PREFIX_ERROR),
CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_ERROR]));
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR] = strdup (prefix);
snprintf (prefix, sizeof (prefix), "%s%s\t",
GUI_COLOR(GUI_COLOR_CHAT_PREFIX_NETWORK),
CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_NETWORK]));
gui_chat_prefix[GUI_CHAT_PREFIX_NETWORK] = strdup (prefix);
snprintf (prefix, sizeof (prefix), "%s%s\t",
GUI_COLOR(GUI_COLOR_CHAT_PREFIX_ACTION),
CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_ACTION]));
gui_chat_prefix[GUI_CHAT_PREFIX_ACTION] = strdup (prefix);
snprintf (prefix, sizeof (prefix), "%s%s\t",
GUI_COLOR(GUI_COLOR_CHAT_PREFIX_JOIN),
CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_JOIN]));
gui_chat_prefix[GUI_CHAT_PREFIX_JOIN] = strdup (prefix);
snprintf (prefix, sizeof (prefix), "%s%s\t",
GUI_COLOR(GUI_COLOR_CHAT_PREFIX_QUIT),
CONFIG_STRING(config_look_prefix[GUI_CHAT_PREFIX_QUIT]));
gui_chat_prefix[GUI_CHAT_PREFIX_QUIT] = strdup (prefix);
}
/*