summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2013-08-04 12:18:47 +0200
committerSebastien Helleu <flashcode@flashtux.org>2013-08-04 12:18:47 +0200
commit8ca36552eaa5fcdb2b82961dee0fa81ed69fe2bb (patch)
treeac56c52d00ec9cf8d87c0276217980066d1bab27 /src
parentf486b84134a86bd58ce9427afd1dbf652d48964c (diff)
downloadweechat-8ca36552eaa5fcdb2b82961dee0fa81ed69fe2bb.zip
core: change color format for options from `${xxx}` to `${color:xxx}`
Options affected: - weechat.look.buffer_time_format - weechat.look.prefix_action - weechat.look.prefix_error - weechat.look.prefix_join - weechat.look.prefix_network - weechat.look.prefix_quit
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-config.c33
-rw-r--r--src/gui/gui-chat.c5
-rw-r--r--src/gui/gui-color.c79
-rw-r--r--src/gui/gui-color.h1
4 files changed, 23 insertions, 95 deletions
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index fb86fe2ad..88f4cf881 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -1958,10 +1958,12 @@ config_weechat_init_options ()
config_look_buffer_time_format = config_file_new_option (
weechat_config_file, ptr_section,
"buffer_time_format", "string",
+ /* TRANSLATORS: string "${color:xxx}" must NOT be translated */
N_("time format for each line displayed in buffers (see man strftime "
- "for date/time specifiers), colors are allowed with format "
- "\"${color}\", for example french time: "
- "\"${lightblue}%H${white}%M${lightred}%S\""),
+ "for date/time specifiers) (note: content is evaluated, so you can "
+ "use colors with format \"${color:xxx}\", see /help eval); for "
+ "example time using grayscale (requires support of 256 colors): "
+ "\"${color:251}%H${color:243}%M${color:238}%S\""),
NULL, 0, 0, "%H:%M:%S", NULL, 0, NULL, NULL, &config_change_buffer_time_format, NULL, NULL, NULL);
config_look_color_basic_force_bold = config_file_new_option (
weechat_config_file, ptr_section,
@@ -2272,36 +2274,41 @@ 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, colors are allowed with format "
- "\"${color}\""),
+ /* TRANSLATORS: string "${color:xxx}" must NOT be translated */
+ N_("prefix for error messages (note: content is evaluated, so you can "
+ "use colors with format \"${color:xxx}\", see /help eval)"),
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}\""),
+ /* TRANSLATORS: string "${color:xxx}" must NOT be translated */
+ N_("prefix for network messages (note: content is evaluated, so you can "
+ "use colors with format \"${color:xxx}\", see /help eval)"),
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}\""),
+ /* TRANSLATORS: string "${color:xxx}" must NOT be translated */
+ N_("prefix for action messages (note: content is evaluated, so you can "
+ "use colors with format \"${color:xxx}\", see /help eval)"),
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}\""),
+ /* TRANSLATORS: string "${color:xxx}" must NOT be translated */
+ N_("prefix for join messages (note: content is evaluated, so you can "
+ "use colors with format \"${color:xxx}\", see /help eval)"),
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}\""),
+ /* TRANSLATORS: string "${color:xxx}" must NOT be translated */
+ N_("prefix for quit messages (note: content is evaluated, so you can "
+ "use colors with format \"${color:xxx}\", see /help eval)"),
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 (
diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c
index 22b0acfe2..b1045f6b2 100644
--- a/src/gui/gui-chat.c
+++ b/src/gui/gui-chat.c
@@ -32,6 +32,7 @@
#include "../core/weechat.h"
#include "../core/wee-config.h"
+#include "../core/wee-eval.h"
#include "../core/wee-hashtable.h"
#include "../core/wee-hook.h"
#include "../core/wee-string.h"
@@ -119,7 +120,7 @@ gui_chat_prefix_build ()
ptr_prefix);
if (pos_color)
- gui_chat_prefix[i] = gui_color_string_replace_colors (prefix);
+ gui_chat_prefix[i] = eval_expression (prefix, NULL, NULL, NULL);
else
gui_chat_prefix[i] = strdup (prefix);
}
@@ -373,7 +374,7 @@ gui_chat_get_time_string (time_t date)
if (strstr (text_time, "${"))
{
- text_with_color = gui_color_string_replace_colors (text_time);
+ text_with_color = eval_expression (text_time, NULL, NULL, NULL);
if (text_with_color)
{
if (strcmp (text_time, text_with_color) != 0)
diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c
index dee38132c..fb38aa430 100644
--- a/src/gui/gui-color.c
+++ b/src/gui/gui-color.c
@@ -583,85 +583,6 @@ gui_color_decode (const char *string, const char *replacement)
}
/*
- * Replaces colors in string with color codes.
- *
- * Colors are using format: ${name} where name is a color name.
- */
-
-char *
-gui_color_string_replace_colors (const char *string)
-{
- int length, length_color, index_string, index_result;
- char *result, *result2, *color_name;
- const char *pos_end_name, *ptr_color;
-
- if (!string)
- return NULL;
-
- length = strlen (string) + 1;
- result = malloc (length);
- if (result)
- {
- index_string = 0;
- index_result = 0;
- while (string[index_string])
- {
- if ((string[index_string] == '\\')
- && (string[index_string + 1] == '$'))
- {
- index_string++;
- result[index_result++] = string[index_string++];
- }
- else if ((string[index_string] == '$')
- && (string[index_string + 1] == '{'))
- {
- pos_end_name = strchr (string + index_string + 2, '}');
- if (pos_end_name)
- {
- color_name = string_strndup (string + index_string + 2,
- pos_end_name - (string + index_string + 2));
- if (color_name)
- {
- ptr_color = gui_color_get_custom (color_name);
- if (ptr_color)
- {
- length_color = strlen (ptr_color);
- length += length_color;
- result2 = realloc (result, length);
- if (!result2)
- {
- if (result)
- free (result);
- free (color_name);
- return NULL;
- }
- result = result2;
- strcpy (result + index_result, ptr_color);
- index_result += length_color;
- index_string += pos_end_name - string -
- index_string + 1;
- }
- else
- result[index_result++] = string[index_string++];
-
- free (color_name);
- }
- else
- result[index_result++] = string[index_string++];
- }
- else
- result[index_result++] = string[index_string++];
- }
- else
- result[index_result++] = string[index_string++];
- }
- result[index_result] = '\0';
- }
-
- return result;
-}
-
-/*
* Frees a color.
*/
diff --git a/src/gui/gui-color.h b/src/gui/gui-color.h
index 47c2aae88..91e56fe60 100644
--- a/src/gui/gui-color.h
+++ b/src/gui/gui-color.h
@@ -165,7 +165,6 @@ extern int gui_color_attr_get_flag (char c);
extern void gui_color_attr_build_string (int color, char *str_attr);
extern const char *gui_color_get_custom (const char *color_name);
extern char *gui_color_decode (const char *string, const char *replacement);
-extern char *gui_color_string_replace_colors (const char *string);
extern void gui_color_free (struct t_gui_color *color);
extern void gui_color_palette_alloc_structs ();
extern int gui_color_palette_get_alias (const char *alias);