mirror of
https://github.com/irssi/irssi.git
synced 2024-10-27 05:20:20 -04:00
Changed the escaping system - theme_format_expand_data()'s
EXPAND_FLAG_IGNORE_EMPTY now also checks if the argument is a $variable that is empty. Statusbar now first expands the formats and after then expands $variables. Should fix at least when trying to print #$$$ channel in statusbar. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2023 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
cda63f03d4
commit
fc91857029
@ -235,6 +235,46 @@ static void theme_format_append_next(THEME_REC *theme, GString *str,
|
||||
(*format)++;
|
||||
}
|
||||
|
||||
/* returns TRUE if data is empty, or the data is a $variable which is empty */
|
||||
static int data_is_empty(const char **data)
|
||||
{
|
||||
const char *p;
|
||||
char *ret;
|
||||
int free_ret, empty;
|
||||
|
||||
p = *data;
|
||||
while (*p == ' ') p++;
|
||||
|
||||
if (*p == '}') {
|
||||
/* empty */
|
||||
*data = p+1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (*p != '$') {
|
||||
/* not empty */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* variable - check if it's empty */
|
||||
p++;
|
||||
ret = parse_special((char **) &p, active_win->active_server,
|
||||
active_win->active, NULL, &free_ret, NULL, 0);
|
||||
p++;
|
||||
|
||||
while (*p == ' ') p++;
|
||||
empty = *p == '}' && (ret == NULL || *ret == '\0');
|
||||
if (free_ret) g_free(ret);
|
||||
|
||||
if (empty) {
|
||||
/* empty */
|
||||
*data = p+1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* expand a single {abstract ...data... } */
|
||||
static char *theme_format_expand_abstract(THEME_REC *theme,
|
||||
const char **formatp,
|
||||
@ -261,17 +301,11 @@ static char *theme_format_expand_abstract(THEME_REC *theme,
|
||||
treated as arguments */
|
||||
if (*p == ' ') {
|
||||
len++;
|
||||
if ((flags & EXPAND_FLAG_IGNORE_EMPTY)) {
|
||||
/* if the data is empty, ignore the abstract */
|
||||
p = format+len;
|
||||
while (*p == ' ') p++;
|
||||
if (*p == '}') {
|
||||
*formatp = p+1;
|
||||
g_free(abstract);
|
||||
return NULL;
|
||||
}
|
||||
if ((flags & EXPAND_FLAG_IGNORE_EMPTY) && data_is_empty(&p)) {
|
||||
*formatp = p;
|
||||
g_free(abstract);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
*formatp = format+len;
|
||||
|
||||
|
@ -44,7 +44,7 @@ void theme_register_module(const char *module, FORMAT_REC *formats);
|
||||
void theme_unregister_module(const char *module);
|
||||
|
||||
#define EXPAND_FLAG_IGNORE_REPLACES 0x01 /* don't use the character replaces when expanding */
|
||||
#define EXPAND_FLAG_IGNORE_EMPTY 0x02 /* if abstract's argument is empty, don't try to expand it (ie. {xx }, but not {xx}) */
|
||||
#define EXPAND_FLAG_IGNORE_EMPTY 0x02 /* if abstract's argument is empty, or the argument is a $variable that is empty, don't try to expand it (ie. {xx }, but not {xx}) */
|
||||
#define EXPAND_FLAG_RECURSIVE_MASK 0x0f
|
||||
/* private */
|
||||
#define EXPAND_FLAG_ROOT 0x10
|
||||
|
@ -297,20 +297,6 @@ static void statusbar_calc_item_positions(STATUSBAR_REC *bar)
|
||||
active_win = old_active_win;
|
||||
}
|
||||
|
||||
/*STATUSBAR_REC *statusbar_find(int pos, int line)
|
||||
{
|
||||
GSList *tmp;
|
||||
|
||||
for (tmp = statusbars; tmp != NULL; tmp = tmp->next) {
|
||||
STATUSBAR_REC *rec = tmp->data;
|
||||
|
||||
if (rec->pos == pos && rec->line == line)
|
||||
return rec;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}*/
|
||||
|
||||
void statusbar_redraw(STATUSBAR_REC *bar, int force)
|
||||
{
|
||||
if (bar != NULL) {
|
||||
@ -673,20 +659,17 @@ void statusbar_item_default_handler(SBAR_ITEM_REC *item, int get_size_only,
|
||||
wiitem = active_win->active;
|
||||
}
|
||||
|
||||
/* expand $variables */
|
||||
tmpstr = parse_special_string(str, server, wiitem, data, NULL,
|
||||
(escape_vars ? PARSE_FLAG_ESCAPE_VARS : 0 ) |
|
||||
PARSE_FLAG_ESCAPE_THEME);
|
||||
|
||||
/* expand templates */
|
||||
str = tmpstr;
|
||||
tmpstr2 = theme_format_expand_data(current_theme, &str,
|
||||
'n', 'n',
|
||||
NULL, NULL,
|
||||
EXPAND_FLAG_ROOT |
|
||||
EXPAND_FLAG_IGNORE_REPLACES |
|
||||
EXPAND_FLAG_IGNORE_EMPTY);
|
||||
g_free(tmpstr);
|
||||
tmpstr = theme_format_expand_data(current_theme, &str,
|
||||
'n', 'n',
|
||||
NULL, NULL,
|
||||
EXPAND_FLAG_ROOT |
|
||||
EXPAND_FLAG_IGNORE_REPLACES |
|
||||
EXPAND_FLAG_IGNORE_EMPTY);
|
||||
/* expand $variables */
|
||||
tmpstr2 = parse_special_string(tmpstr, server, wiitem, data, NULL,
|
||||
(escape_vars ? PARSE_FLAG_ESCAPE_VARS : 0 ));
|
||||
g_free(tmpstr);
|
||||
|
||||
/* remove color codes (not %formats) */
|
||||
tmpstr = strip_codes(tmpstr2);
|
||||
|
Loading…
Reference in New Issue
Block a user