diff options
| author | Jonathan Gordon <rockbox@jdgordon.info> | 2012-02-26 00:42:53 +1100 |
|---|---|---|
| committer | Jonathan Gordon <rockbox@jdgordon.info> | 2012-02-26 00:50:14 +1100 |
| commit | 31a05953e142b1ffff631cfb8b817880db7e4c27 (patch) | |
| tree | 499dd370eb2b3b8fad4be38be2ca6bb03bcfdcc8 /apps/gui/skin_engine | |
| parent | 3cdd50bf41504d783b57502e685de481ac62e2f8 (diff) | |
| download | rockbox-31a05953e142b1ffff631cfb8b817880db7e4c27.zip rockbox-31a05953e142b1ffff631cfb8b817880db7e4c27.tar.gz rockbox-31a05953e142b1ffff631cfb8b817880db7e4c27.tar.bz2 rockbox-31a05953e142b1ffff631cfb8b817880db7e4c27.tar.xz | |
FS#12586 - Modify %ss to be able to use numbers for conditionals
i.e %?ss(1,1,%cM)<|one|two|three|...|> or %xd(numbers, %ss(1,1%cM)
Change-Id: I74ecb3f253f3be1fd270f75c0ef79addd364a7de
Diffstat (limited to 'apps/gui/skin_engine')
| -rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 4 | ||||
| -rw-r--r-- | apps/gui/skin_engine/skin_tokens.c | 4 | ||||
| -rw-r--r-- | apps/gui/skin_engine/wps_internals.h | 1 |
3 files changed, 9 insertions, 0 deletions
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 3899f60..340cbbd 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -824,6 +824,10 @@ static int parse_substring_tag(struct skin_element* element, else ss->length = get_param(element, 1)->data.number; ss->token = get_param_code(element, 2)->data; + if (element->params_count > 3) + ss->expect_number = !strcmp(get_param_text(element, 3), "number"); + else + ss->expect_number = false; token->value.data = PTRTOSKINOFFSET(skin_buffer, ss); return 0; } diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c index 82d96f6..7651025 100644 --- a/apps/gui/skin_engine/skin_tokens.c +++ b/apps/gui/skin_engine/skin_tokens.c @@ -942,6 +942,10 @@ const char *get_token_value(struct gui_wps *gwps, buf = &buf[start_byte]; buf[byte_len] = '\0'; + if (ss->expect_number && + intval && (buf[0] >= '0' && buf[0] <= '9')) + *intval = atoi(buf) + 1; /* so 0 is the first item */ + return buf; } return NULL; diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index 9c3fa1b..c55c8d2 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h @@ -286,6 +286,7 @@ struct logical_if { struct substring { int start; int length; + bool expect_number; OFFSETTYPE(struct wps_token *) token; }; |