forked from len0rd/rockbox
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
This commit is contained in:
parent
3cdd50bf41
commit
31a05953e1
5 changed files with 24 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -286,6 +286,7 @@ struct logical_if {
|
|||
struct substring {
|
||||
int start;
|
||||
int length;
|
||||
bool expect_number;
|
||||
OFFSETTYPE(struct wps_token *) token;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ static const struct tag_info legal_tags[] =
|
|||
{ SKIN_TOKEN_VAR_GETVAL, "vg", "S", SKIN_REFRESH_DYNAMIC },
|
||||
{ SKIN_TOKEN_VAR_TIMEOUT, "vl", "S|D", SKIN_REFRESH_DYNAMIC },
|
||||
|
||||
{ SKIN_TOKEN_SUBSTRING, "ss", "IiT", SKIN_REFRESH_DYNAMIC },
|
||||
{ SKIN_TOKEN_SUBSTRING, "ss", "IiT|s", SKIN_REFRESH_DYNAMIC },
|
||||
{ SKIN_TOKEN_UNKNOWN, "" , "", 0 }
|
||||
/* Keep this here to mark the end of the table */
|
||||
};
|
||||
|
|
|
|||
|
|
@ -740,6 +740,20 @@ a horizontal progressbar which doesn't fill and draws the image
|
|||
fits inside the specified width and height.}
|
||||
|
||||
\section{Other Tags}
|
||||
|
||||
\begin{tagmap}
|
||||
\config{\%ss(start, length, tag [,number]} & Get a substring from another tag.\\
|
||||
\end{tagmap}
|
||||
Use this tag to get a substring from another tag.
|
||||
\begin{description}
|
||||
\item[start] -- first character to take (0 being the start of the string)
|
||||
\item[length] -- length of the substring to return (- for the rest of the string)
|
||||
\item[tag] -- tag to get
|
||||
\item[number] -- OPTIONAL. if this is present it will assume the
|
||||
substring is a number so it can be used with conditionals. (i.e \config{\%cM}).
|
||||
0 is the first conditional option
|
||||
\end{description}
|
||||
|
||||
\begin{tagmap}
|
||||
\config{\%(} & The character `('\\
|
||||
\config{\%)} & The character `)'\\
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue