mirror of
https://github.com/irssi/irssi.git
synced 2024-09-08 04:26:01 -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:
parent
27f54e286f
commit
abd9e6f616
@ -301,6 +301,40 @@ static int data_is_empty(const char **data)
|
|||||||
return FALSE;
|
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... } */
|
/* expand a single {abstract ...data... } */
|
||||||
static char *theme_format_expand_abstract(THEME_REC *theme,
|
static char *theme_format_expand_abstract(THEME_REC *theme,
|
||||||
const char **formatp,
|
const char **formatp,
|
||||||
@ -345,9 +379,8 @@ static char *theme_format_expand_abstract(THEME_REC *theme,
|
|||||||
abstract = g_strdup(data);
|
abstract = g_strdup(data);
|
||||||
|
|
||||||
/* we'll need to get the data part. it may contain
|
/* we'll need to get the data part. it may contain
|
||||||
more abstracts, they are automatically expanded. */
|
more abstracts, they are _NOT_ expanded. */
|
||||||
data = theme_format_expand_data(theme, formatp, default_fg, default_bg,
|
data = theme_format_expand_get(theme, formatp);
|
||||||
NULL, NULL, flags);
|
|
||||||
len = strlen(data);
|
len = strlen(data);
|
||||||
|
|
||||||
if (len > 1 && i_isdigit(data[len-1]) && data[len-2] == '$') {
|
if (len > 1 && i_isdigit(data[len-1]) && data[len-2] == '$') {
|
||||||
|
Loading…
Reference in New Issue
Block a user