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

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
This commit is contained in:
Sebastien Helleu
2013-08-04 12:18:47 +02:00
parent f486b84134
commit 8ca36552ea
23 changed files with 445 additions and 252 deletions
-79
View File
@@ -582,85 +582,6 @@ gui_color_decode (const char *string, const char *replacement)
return (char *)out;
}
/*
* 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.
*/