1
0
mirror of https://github.com/irssi/irssi.git synced 2024-07-14 03:04:17 -04:00

Better support %n in theme abstracts. Patch by c0ffee.

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3043 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2002-12-04 20:51:51 +00:00 committed by cras
parent 27f54e286f
commit abd9e6f616

View File

@ -301,6 +301,40 @@ static int data_is_empty(const char **data)
return FALSE;
}
/* return "data" from {abstract data} string */
char *theme_format_expand_get(THEME_REC *theme, const char **format)
{
GString *str;
char *ret, dummy;
int braces = 1; /* we start with one brace opened */
str = g_string_new(NULL);
while (**format != '\0' && braces != 0) {
if (**format == '{')
braces++;
else if (**format == '}')
braces--;
else {
theme_format_append_next(theme, str, format,
'n', 'n',
&dummy, &dummy, 0);
continue;
}
if (braces == 0) {
(*format)++;
break;
}
g_string_append_c(str, **format);
(*format)++;
}
ret = str->str;
g_string_free(str, FALSE);
return ret;
}
/* expand a single {abstract ...data... } */
static char *theme_format_expand_abstract(THEME_REC *theme,
const char **formatp,
@ -345,9 +379,8 @@ static char *theme_format_expand_abstract(THEME_REC *theme,
abstract = g_strdup(data);
/* we'll need to get the data part. it may contain
more abstracts, they are automatically expanded. */
data = theme_format_expand_data(theme, formatp, default_fg, default_bg,
NULL, NULL, flags);
more abstracts, they are _NOT_ expanded. */
data = theme_format_expand_get(theme, formatp);
len = strlen(data);
if (len > 1 && i_isdigit(data[len-1]) && data[len-2] == '$') {