Evas textblock: Format tags now support quoting values.

For example: "<font='Sans:style=Bold Oblique'>bla</font>".

SVN revision: 61843
This commit is contained in:
Tom Hacohen 2011-07-28 09:18:55 +00:00
parent bb87f260a6
commit 5fd7c82d5f
1 changed files with 32 additions and 15 deletions

View File

@ -1561,32 +1561,46 @@ _format_is_param(const char *item)
static void static void
_format_param_parse(const char *item, const char **key, const char **val) _format_param_parse(const char *item, const char **key, const char **val)
{ {
const char *equal, *end; const char *start, *end, *quote;
equal = strchr(item, '='); start = strchr(item, '=');
*key = eina_stringshare_add_length(item, equal - item); *key = eina_stringshare_add_length(item, start - item);
equal++; /* Advance after the '=' */ start++; /* Advance after the '=' */
/* Null terminate before the spaces */ /* If we can find a quote, our new delimiter is a quote, not a space. */
end = strchr(equal, ' '); if ((quote = strchr(start, '\'')))
if (end)
{ {
*val = eina_stringshare_add_length(equal, end - equal); start = quote + 1;
end = strchr(start, '\'');
} }
else else
{ {
*val = eina_stringshare_add(equal); end = strchr(start, ' ');
}
/* Null terminate before the spaces */
if (end)
{
*val = eina_stringshare_add_length(start, end - start);
}
else
{
*val = eina_stringshare_add(start);
} }
} }
/** /**
* @internal * @internal
* FIXME: comment. * This function parses the format passed in *s and advances s to point to the
* next format item, while returning the current one as the return value.
* @param s The current and returned position in the format string.
* @return the current item parsed from the string.
*/ */
static const char * static const char *
_format_parse(const char **s) _format_parse(const char **s)
{ {
const char *p, *item; const char *p;
const char *s1 = NULL, *s2 = NULL; const char *s1 = NULL, *s2 = NULL;
Eina_Bool quote = EINA_FALSE;;
p = *s; p = *s;
if (*p == 0) return NULL; if (*p == 0) return NULL;
@ -1599,7 +1613,12 @@ _format_parse(const char **s)
} }
else if (!s2) else if (!s2)
{ {
if ((p > *s) && (p[-1] != '\\')) if (*p == '\'')
{
quote = !quote;
}
if ((p > *s) && (p[-1] != '\\') && (!quote))
{ {
if (*p == ' ') s2 = p; if (*p == ' ') s2 = p;
} }
@ -1608,10 +1627,8 @@ _format_parse(const char **s)
p++; p++;
if (s1 && s2) if (s1 && s2)
{ {
item = s1;
*s = s2; *s = s2;
return item; return s1;
} }
} }
*s = p; *s = p;