diff options
author | Timo Sirainen <cras@irssi.org> | 2002-12-04 20:51:51 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2002-12-04 20:51:51 +0000 |
commit | abd9e6f616288a24eae83c2eb213ff9a8b069332 (patch) | |
tree | ec958628e06dd4c7e9cf5169604c0ce3e5bd1f78 /src/fe-common | |
parent | 27f54e286f2b5a1dadca14620a690df03eade5fa (diff) | |
download | irssi-abd9e6f616288a24eae83c2eb213ff9a8b069332.zip |
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
Diffstat (limited to 'src/fe-common')
-rw-r--r-- | src/fe-common/core/themes.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/src/fe-common/core/themes.c b/src/fe-common/core/themes.c index baa1d3e5..0d543843 100644 --- a/src/fe-common/core/themes.c +++ b/src/fe-common/core/themes.c @@ -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] == '$') { |