Hey all.

I want to get a plan down for the skin format changeover which will
happen Very Soon (either before or during DevCon...).

Basically what needs to happen is one small diff get committed to make
the existing parser work with the new format (ready to go, needs more
testers though...). The problem is as soon as that happens the entire
theme site becomes useless for the current build (as do all the
shipped wps's.)

If we get an OK from scorche (or rasher? who else has the required
access?) I want to copy the current theme site and disable updates.
The reason to do this is because there is a script in
utils/skinupdater which (should) extract a given zip file, run the
update program over it and zip it back up so the entire theme site can
get updated in one hit. But if that happens no themes will work for
3.6... so for a while it would great if we hosted 2 copies of the
theme site....

So what we need is:
1) people test the attached diff
2*) clone the theme site
3*) have someone run utils/skinupdater/updatetheme.pl on all the zips
in the themesite
4) commit the attached diff and run the update on all the .wps files
in wps/ (that should be pretty easy)
5) fix bugs (what bugs? not in my code there arnt any! :D )

2 and 3 need someone with shell access to the theme site which I
assume is only scorche which is why devcon is probably the earliest
time this could happen.

I'm not expecting much to happen on 1 going by previous attempts at
getting testers... but I've done basic testing on it so should be
fine.

Any questions? Issues?

I really want to get this in at the latest on the weekend.

Jonathan
diff --git a/README b/README
new file mode 100644
index 0000000..e69de29
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c
index d0e94c7..b1e6552 100644
--- a/apps/gui/skin_engine/skin_display.c
+++ b/apps/gui/skin_engine/skin_display.c
@@ -746,7 +746,18 @@ static bool get_line(struct gui_wps *gwps,
                     skip to the end of the conditional structure */
                 i = find_conditional_end(data, i);
                 break;
-
+            case WPS_TOKEN_VIEWPORT_FGCOLOUR:
+            {
+                struct viewport_colour *col = data->tokens[i].value.data;
+                col->vp->fg_pattern = col->colour;
+            }
+            break;
+            case WPS_TOKEN_VIEWPORT_BGCOLOUR:
+            {
+                struct viewport_colour *col = data->tokens[i].value.data;
+                col->vp->bg_pattern = col->colour;
+            }
+            break;
 #ifdef HAVE_LCD_BITMAP
             case WPS_TOKEN_PEAKMETER:
                 data->peak_meter_enabled = true;
@@ -1206,6 +1217,8 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode)
         struct skin_viewport *skin_viewport =
                         (struct skin_viewport *)viewport_list->token->value.data;
         unsigned vp_refresh_mode = refresh_mode;
+        skin_viewport->vp.fg_pattern = skin_viewport->start_fgcolour;
+        skin_viewport->vp.bg_pattern = skin_viewport->start_bgcolour;
 
         display->set_viewport(&skin_viewport->vp);
 
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c
index 932c3ba..cd65c6e 100644
--- a/apps/gui/skin_engine/skin_parser.c
+++ b/apps/gui/skin_engine/skin_parser.c
@@ -154,6 +154,8 @@ static int parse_playlistview(const char *wps_bufptr,
         struct wps_token *token, struct wps_data *wps_data);
 static int parse_viewport(const char *wps_bufptr,
         struct wps_token *token, struct wps_data *wps_data);
+static int parse_viewportcolour(const char *wps_bufptr,
+        struct wps_token *token, struct wps_data *wps_data);
 static int parse_statusbar_enable(const char *wps_bufptr,
         struct wps_token *token, struct wps_data *wps_data);
 static int parse_statusbar_disable(const char *wps_bufptr,
@@ -400,6 +402,8 @@ static const struct wps_tag all_tags[] = {
     { WPS_TOKEN_LIST_TITLE_TEXT,          "Lt",  WPS_REFRESH_DYNAMIC, NULL },
     { WPS_TOKEN_LIST_TITLE_ICON,          "Li",  WPS_REFRESH_DYNAMIC, NULL },
 #endif
+    { WPS_TOKEN_VIEWPORT_FGCOLOUR,        "Vf", WPS_REFRESH_STATIC, parse_viewportcolour },
+    { WPS_TOKEN_VIEWPORT_BGCOLOUR,        "Vb", WPS_REFRESH_STATIC, parse_viewportcolour },
     { WPS_NO_TOKEN,                       "V",   0,    parse_viewport      },
 
 #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1))
@@ -618,9 +622,11 @@ static int get_image_id(int c)
 char *get_image_filename(const char *start, const char* bmpdir,
                                 char *buf, int buf_size)
 {
-    const char *end = strchr(start, '|');
+    const char *end = start;
     int bmpdirlen = strlen(bmpdir);
 
+    while (*end && *end != ',' && *end != ')')
+        end++;
     if ( !end || (end - start) >= (buf_size - bmpdirlen - 2) )
     {
         buf[0] = '\0';
@@ -639,7 +645,7 @@ static int parse_image_display(const char *wps_bufptr,
                                struct wps_token *token,
                                struct wps_data *wps_data)
 {
-    char label = wps_bufptr[0];
+    char label = wps_bufptr[1];
     int subimage;
     struct gui_img *img;;
 
@@ -651,17 +657,17 @@ static int parse_image_display(const char *wps_bufptr,
         return WPS_ERROR_INVALID_PARAM;
     }
 
-    if ((subimage = get_image_id(wps_bufptr[1])) != -1)
+    if ((subimage = get_image_id(wps_bufptr[2])) != -1)
     {
         if (subimage >= img->num_subimages)
             return WPS_ERROR_INVALID_PARAM;
 
         /* Store sub-image number to display in high bits */
         token->value.i = label | (subimage << 8);
-        return 2; /* We have consumed 2 bytes */
+        return 4; /* We have consumed 2 bytes */
     } else {
         token->value.i = label;
-        return 1; /* We have consumed 1 byte */
+        return 3; /* We have consumed 1 byte */
     }
 }
 
@@ -670,10 +676,8 @@ static int parse_image_load(const char *wps_bufptr,
                             struct wps_data *wps_data)
 {
     const char *ptr = wps_bufptr;
-    const char *pos;
     const char* filename;
     const char* id;
-    const char *newline;
     int x,y;
     struct gui_img *img;
 
@@ -682,16 +686,16 @@ static int parse_image_load(const char *wps_bufptr,
        or %xl|n|filename.bmp|x|y|num_subimages|
     */
 
-    if (*ptr != '|')
+    if (*ptr != '(')
         return WPS_ERROR_INVALID_PARAM;
 
     ptr++;
 
-    if (!(ptr = parse_list("ssdd", NULL, '|', ptr, &id, &filename, &x, &y)))
+    if (!(ptr = parse_list("ssdd", NULL, ',', ptr, &id, &filename, &x, &y)))
         return WPS_ERROR_INVALID_PARAM;
 
-    /* Check there is a terminating | */
-    if (*ptr != '|')
+    /* Check there is a terminating ) */
+    if (*ptr != ')' && *ptr != ',')
         return WPS_ERROR_INVALID_PARAM;
 
     /* check the image number and load state */
@@ -718,15 +722,11 @@ static int parse_image_load(const char *wps_bufptr,
     {
         img->always_display = true;
     }
-    else
+    else if (*ptr == ',')
     {
         /* Parse the (optional) number of sub-images */
         ptr++;
-        newline = strchr(ptr, '\n');
-        pos = strchr(ptr, '|');
-        if (pos && pos < newline)
-            img->num_subimages = atoi(ptr);
-
+        img->num_subimages = atoi(ptr);
         if (img->num_subimages <= 0)
             return WPS_ERROR_INVALID_PARAM;
     }
@@ -751,16 +751,16 @@ static int parse_font_load(const char *wps_bufptr,
     int id;
     char *filename;
     
-    if (*ptr != '|')
+    if (*ptr != '(')
         return WPS_ERROR_INVALID_PARAM;
 
     ptr++;
 
-    if (!(ptr = parse_list("ds", NULL, '|', ptr, &id, &filename)))
+    if (!(ptr = parse_list("ds", NULL, ',', ptr, &id, &filename)))
         return WPS_ERROR_INVALID_PARAM;
 
     /* Check there is a terminating | */
-    if (*ptr != '|')
+    if (*ptr != ')')
         return WPS_ERROR_INVALID_PARAM;
         
     if (id <= FONT_UI || id >= MAXFONTS-1)
@@ -774,7 +774,7 @@ static int parse_font_load(const char *wps_bufptr,
     /* make sure the filename contains .fnt, 
      * we dont actually use it, but require it anyway */
     ptr = strchr(filename, '.');
-    if (!ptr || strncmp(ptr, ".fnt|", 5))
+    if (!ptr || strncmp(ptr, ".fnt)", 5))
         return WPS_ERROR_INVALID_PARAM;
     skinfonts[id-FONT_FIRSTUSERFONT].id = -1;
     skinfonts[id-FONT_FIRSTUSERFONT].name = filename;
@@ -788,7 +788,7 @@ static int parse_viewport_display(const char *wps_bufptr,
                                   struct wps_data *wps_data)
 {
     (void)wps_data;
-    char letter = wps_bufptr[0];
+    char letter = wps_bufptr[1];
 
     if (letter < 'a' || letter > 'z')
     {
@@ -796,10 +796,11 @@ static int parse_viewport_display(const char *wps_bufptr,
         return WPS_ERROR_INVALID_PARAM;
     }
     token->value.i = letter;
-    return 1;
+    return 3;
 }
 
 #ifdef HAVE_LCD_BITMAP
+/* FIXME */
 static int parse_playlistview_text(struct playlistviewer *viewer,
                              enum info_line_type line,  char* text)
 {
@@ -891,14 +892,14 @@ static int parse_playlistview_text(struct playlistviewer *viewer,
     return text - start;
 }
 
-
+/* TEST ME */
 static int parse_playlistview(const char *wps_bufptr,
         struct wps_token *token, struct wps_data *wps_data)
 {
     (void)wps_data;
     /* %Vp|<use icons>|<start offset>|info line text|no info text| */
     struct playlistviewer *viewer = skin_buffer_alloc(sizeof(struct playlistviewer));
-    char *ptr = strchr(wps_bufptr, '|');
+    char *ptr = strchr(wps_bufptr, '(');
     int length;
     if (!viewer || !ptr)
         return WPS_ERROR_INVALID_PARAM;
@@ -906,7 +907,7 @@ static int parse_playlistview(const char *wps_bufptr,
     viewer->show_icons = true;
     viewer->start_offset = atoi(ptr+1);
     token->value.data = (void*)viewer;
-    ptr = strchr(ptr+1, '|');
+    ptr = strchr(ptr+1, ',');
     length = parse_playlistview_text(viewer, TRACK_HAS_INFO, ptr);
     if (length < 0)
         return WPS_ERROR_INVALID_PARAM;
@@ -944,7 +945,7 @@ static int parse_viewport(const char *wps_bufptr,
 
     if (*ptr == 'i')
     {
-        if (*(ptr+1) == '|')
+        if (*(ptr+1) == '(')
         {
             char label = *(ptr+2);
             if (label >= 'a' && label <= 'z')
@@ -966,7 +967,7 @@ static int parse_viewport(const char *wps_bufptr,
     }
     else if (*ptr == 'l')
     {
-        if (*(ptr+1) == '|')
+        if (*(ptr+1) == '(')
         {
             char label = *(ptr+2);
             if (label >= 'a' && label <= 'z')
@@ -979,17 +980,17 @@ static int parse_viewport(const char *wps_bufptr,
             ptr += 3;
         }
     }
-    if (*ptr != '|')
+    if (*ptr != ',' && *ptr != '(')
         return WPS_ERROR_INVALID_PARAM;
 
     ptr++;
     struct viewport *vp = &skin_vp->vp;
-    /* format: %V|x|y|width|height|font|fg_pattern|bg_pattern| */
-    if (!(ptr = viewport_parse_viewport(vp, curr_screen, ptr, '|')))
+    /* format: %V|x|y|width|height|font| */
+    if (!(ptr = viewport_parse_viewport(vp, curr_screen, ptr, ',')))
         return WPS_ERROR_INVALID_PARAM;
 
-    /* Check for trailing | */
-    if (*ptr != '|')
+    /* Check for trailing ) */
+    if (*ptr != ')')
         return WPS_ERROR_INVALID_PARAM;
 
     if (follow_lang_direction && lang_is_rtl())
@@ -999,6 +1000,9 @@ static int parse_viewport(const char *wps_bufptr,
     }
     else
         vp->flags &= ~VP_FLAG_ALIGN_RIGHT; /* ignore right-to-left languages */
+        
+    skin_vp->start_fgcolour = vp->fg_pattern;
+    skin_vp->start_bgcolour = vp->bg_pattern;
 
     struct skin_token_list *list = new_skin_token_list_item(NULL, skin_vp);
     if (!list)
@@ -1008,6 +1012,27 @@ static int parse_viewport(const char *wps_bufptr,
     /* Skip the rest of the line */
     return skip_end_of_line(wps_bufptr);
 }
+static int parse_viewportcolour(const char *wps_bufptr,
+        struct wps_token *token, struct wps_data *wps_data)
+{
+    const char *ptr = wps_bufptr;
+    struct viewport_colour *colour = skin_buffer_alloc(sizeof(struct viewport_colour));
+    int set;
+    if (*ptr != '(' || !colour)
+        return -1;
+    ptr++;
+    if (!(ptr = parse_list("c", &set, ',', ptr, &colour->colour)))
+        return -1;
+    if (*ptr != ')')
+        return -1;
+    if (!set)
+        colour->colour = get_viewport_default_colour(curr_screen,
+                                        token->type == WPS_TOKEN_VIEWPORT_FGCOLOUR);
+    colour->vp = &curr_vp->vp;
+    token->value.data = colour;
+    ptr++;
+    return ptr - wps_bufptr;
+}
 
 #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1))
 static int parse_image_special(const char *wps_bufptr,
@@ -1020,7 +1045,7 @@ static int parse_image_special(const char *wps_bufptr,
     const char *newline;
     bool error = false;
 
-    pos = strchr(wps_bufptr + 1, '|');
+    pos = strchr(wps_bufptr + 1, ')');
     newline = strchr(wps_bufptr, '\n');
 
     error = (pos > newline);
@@ -1063,10 +1088,10 @@ static int parse_setting_and_lang(const char *wps_bufptr,
     char temp[64];
 
     /* Find the setting's cfg_name */
-    if (*ptr != '|')
+    if (*ptr != '(')
         return WPS_ERROR_INVALID_PARAM;
     ptr++;
-    end = strchr(ptr,'|');
+    end = strchr(ptr,')');
     if (!end || (size_t)(end-ptr+1) > sizeof temp)
         return WPS_ERROR_INVALID_PARAM;
     strlcpy(temp, ptr,end-ptr+1);
@@ -1103,10 +1128,12 @@ static int parse_dir_level(const char *wps_bufptr,
                            struct wps_token *token,
                            struct wps_data *wps_data)
 {
-    char val[] = { *wps_bufptr, '\0' };
+    char val[] = { wps_bufptr[1], '\0' };
+    if (wps_bufptr[0] != '(' || wps_bufptr[2] != ')')
+        return WPS_ERROR_INVALID_PARAM;
     token->value.i = atoi(val);
     (void)wps_data; /* Kill warnings */
-    return 1;
+    return 3;
 }
 
 static int parse_timeout(const char *wps_bufptr,
@@ -1119,28 +1146,31 @@ static int parse_timeout(const char *wps_bufptr,
     bool have_tenth = false;
 
     (void)wps_data; /* Kill the warning */
-
-    while ( isdigit(*wps_bufptr) || *wps_bufptr == '.' )
+    if (*wps_bufptr == '(')
     {
-        if (*wps_bufptr != '.')
+        while ( isdigit(*wps_bufptr) || *wps_bufptr == '.' )
         {
-            val *= 10;
-            val += *wps_bufptr - '0';
-            if (have_point)
+            if (*wps_bufptr != '.')
             {
-                have_tenth = true;
-                wps_bufptr++;
-                skip++;
-                break;
+                val *= 10;
+                val += *wps_bufptr - '0';
+                if (have_point)
+                {
+                    have_tenth = true;
+                    wps_bufptr++;
+                    skip++;
+                    break;
+                }
             }
-        }
-        else
-            have_point = true;
+            else
+                have_point = true;
 
-        wps_bufptr++;
-        skip++;
+            wps_bufptr++;
+            skip++;
+        }
+        if (*wps_bufptr != ')')
+            return -1;
     }
-
     if (have_tenth == false)
         val *= 10;
 
@@ -1203,7 +1233,7 @@ static int parse_progressbar(const char *wps_bufptr,
     pb->follow_lang_direction = follow_lang_direction > 0;
     pb->draw = false;
 
-    if (*wps_bufptr != '|') /* regular old style */
+    if (*wps_bufptr != '(') /* regular old style */
     {
         pb->x = 0;
         pb->width = vp->width;
@@ -1216,7 +1246,7 @@ static int parse_progressbar(const char *wps_bufptr,
     }
     ptr = wps_bufptr + 1;
 
-    if (!(ptr = parse_list("sdddd", &set, '|', ptr, &filename,
+    if (!(ptr = parse_list("sdddd", &set, ',', ptr, &filename,
                                                  &x, &y, &width, &height)))
     {
         /* If we are in a conditional then we probably don't want to fail
@@ -1297,9 +1327,8 @@ static int parse_progressbar(const char *wps_bufptr,
 #ifdef HAVE_ALBUMART
 static int parse_int(const char *newline, const char **_pos, int *num)
 {
-    *_pos = parse_list("d", NULL, '|', *_pos, num);
-
-    return (!*_pos || *_pos > newline || **_pos != '|');
+    *_pos = parse_list("d", NULL, ',', *_pos, num);
+    return (!*_pos || *_pos > newline || (**_pos != ',' && **_pos != ')'));
 }
 
 static int parse_albumart_load(const char *wps_bufptr,
@@ -1329,7 +1358,7 @@ static int parse_albumart_load(const char *wps_bufptr,
 
     _pos = wps_bufptr;
 
-    if (*_pos != '|')
+    if (*_pos != '(')
         return WPS_ERROR_INVALID_PARAM; /* malformed token: e.g. %Cl7  */
 
     ++_pos;
@@ -1386,7 +1415,7 @@ static int parse_albumart_load(const char *wps_bufptr,
         }
     }
     /* extract max width data */
-    if (*_pos != '|')
+    if (*_pos != ',')
     {
         if (parse_int(newline, &_pos, &aa->width))
             return WPS_ERROR_INVALID_PARAM;
@@ -1428,7 +1457,7 @@ static int parse_albumart_load(const char *wps_bufptr,
         }
     }
     /* extract max height data */
-    if (*_pos != '|')
+    if (*_pos != ',')
     {
         if (parse_int(newline, &_pos, &aa->height))
             return WPS_ERROR_INVALID_PARAM;
@@ -1536,15 +1565,15 @@ static int parse_touchregion(const char *wps_bufptr,
     */
 
 
-    if (*ptr != '|')
+    if (*ptr != '(')
         return WPS_ERROR_INVALID_PARAM;
     ptr++;
 
-    if (!(ptr = parse_list("dddds", NULL, '|', ptr, &x, &y, &w, &h, &action)))
+    if (!(ptr = parse_list("dddds", NULL, ',', ptr, &x, &y, &w, &h, &action)))
         return WPS_ERROR_INVALID_PARAM;
 
     /* Check there is a terminating | */
-    if (*ptr != '|')
+    if (*ptr != ')')
         return WPS_ERROR_INVALID_PARAM;
 
     region = skin_buffer_alloc(sizeof(struct touchregion));
@@ -1560,7 +1589,7 @@ static int parse_touchregion(const char *wps_bufptr,
     region->wvp = curr_vp;
     region->armed = false;
 
-    end = strchr(action, '|');
+    end = strchr(action, ')');
     if (!end || (size_t)(end-action+1) > sizeof temp)
         return WPS_ERROR_INVALID_PARAM;
     strlcpy(temp, action, end-action+1);
diff --git a/apps/gui/skin_engine/skin_tokens.h b/apps/gui/skin_engine/skin_tokens.h
index f25b123..4731131 100644
--- a/apps/gui/skin_engine/skin_tokens.h
+++ b/apps/gui/skin_engine/skin_tokens.h
@@ -56,6 +56,8 @@ enum wps_token_type {
     WPS_VIEWPORT_ENABLE,
     WPS_VIEWPORT_CUSTOMLIST,
     WPS_TOKEN_UIVIEWPORT_ENABLE,
+    WPS_TOKEN_VIEWPORT_FGCOLOUR,
+    WPS_TOKEN_VIEWPORT_BGCOLOUR,
     
     /* Battery */
   TOKEN_MARKER_BATTERY,
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h
index 945932a..bb115a4 100644
--- a/apps/gui/skin_engine/wps_internals.h
+++ b/apps/gui/skin_engine/wps_internals.h
@@ -209,8 +209,13 @@ struct skin_viewport {
     struct skin_line *lines;
     char hidden_flags;
     char label;
+    int start_fgcolour;
+    int start_bgcolour;
+};
+struct viewport_colour {
+    struct viewport *vp;
+    int colour;
 };
-
 #ifdef HAVE_TOUCHSCREEN
 struct touchregion {
     struct skin_viewport* wvp;/* The viewport this region is in */
diff --git a/apps/gui/statusbar-skinned.c b/apps/gui/statusbar-skinned.c
index a53555a..2cdb1c3 100644
--- a/apps/gui/statusbar-skinned.c
+++ b/apps/gui/statusbar-skinned.c
@@ -200,7 +200,7 @@ void sb_create_from_settings(enum screen_type screen)
         {
             y = screens[screen].lcdheight - STATUSBAR_HEIGHT;
         }
-        len = snprintf(ptr, remaining, "%%V|0|%d|-|%d|0|-|-|\n%%wi\n", 
+        len = snprintf(ptr, remaining, "%%V(0,%d,-,%d,0)\n%%wi\n", 
                        y, height);
         remaining -= len;
         ptr += len;
@@ -215,9 +215,7 @@ void sb_create_from_settings(enum screen_type screen)
     
     if (ptr2[0] && ptr2[0] != '-') /* from ui viewport setting */
     {
-        len = snprintf(ptr, remaining, "%%ax%%Vi|%s|\n", ptr2);
-        while ((ptr2 = strchr(ptr, ',')))
-            *ptr2 = '|';
+        len = snprintf(ptr, remaining, "%%ax%%Vi(-,%s)\n", ptr2);
     }
     else
     {
@@ -232,7 +230,7 @@ void sb_create_from_settings(enum screen_type screen)
             default:
                 height = screens[screen].lcdheight;
         }
-        len = snprintf(ptr, remaining, "%%ax%%Vi|0|%d|-|%d|1|-|-|\n", 
+        len = snprintf(ptr, remaining, "%%ax%%Vi(-,0,%d,-,%d,1)\n", 
                        y, height);
     }
     sb_skin_data_load(screen, buf, false);
diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c
index a100d56..594c077 100644
--- a/apps/gui/viewport.c
+++ b/apps/gui/viewport.c
@@ -376,6 +376,33 @@ void viewport_set_defaults(struct viewport *vp,
 
 
 #ifdef HAVE_LCD_BITMAP
+
+int get_viewport_default_colour(enum screen_type screen, bool fgcolour)
+{
+    int colour;
+#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)
+    if (fgcolour)
+    {
+#if (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)
+        if (screen == SCREEN_REMOTE)
+            colour = REMOTE_FG_FALLBACK;
+        else
+#endif
+            colour = FG_FALLBACK;
+    }
+    else
+    {
+#if (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)
+        if (screen == SCREEN_REMOTE)
+            colour = REMOTE_BG_FALLBACK;
+        else
+#endif
+            colour = BG_FALLBACK;
+    }
+#endif /* LCD_DEPTH > 1 || LCD_REMOTE_DEPTH > 1 */
+    return colour;
+}
+
 const char* viewport_parse_viewport(struct viewport *vp,
                                     enum screen_type screen,
                                     const char *bufptr,
@@ -383,7 +410,6 @@ const char* viewport_parse_viewport(struct viewport *vp,
 {
     /* parse the list to the viewport struct */
     const char *ptr = bufptr;
-    int depth;
     uint32_t set = 0;
 
     enum {
@@ -392,33 +418,11 @@ const char* viewport_parse_viewport(struct viewport *vp,
         PL_WIDTH,
         PL_HEIGHT,
         PL_FONT,
-        PL_FG,
-        PL_BG,
     };
     
-    /* Work out the depth of this display */
-    depth = screens[screen].depth;
-#if (LCD_DEPTH == 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 1)
-    if (depth == 1)
-    {
-        if (!(ptr = parse_list("ddddd", &set, separator, ptr,
-                    &vp->x, &vp->y, &vp->width, &vp->height, &vp->font)))
-            return NULL;
-    }
-    else
-#endif
-#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)
-    if (depth >= 2)
-    {
-        if (!(ptr = parse_list(ARG_STRING(depth), &set, separator, ptr,
-                    &vp->x, &vp->y, &vp->width, &vp->height, &vp->font,
-                    &vp->fg_pattern,&vp->bg_pattern)))
-            return NULL;
-    }
-    else
-#endif
-    {}
-#undef ARG_STRING
+    if (!(ptr = parse_list("ddddd", &set, separator, ptr,
+                &vp->x, &vp->y, &vp->width, &vp->height, &vp->font)))
+        return NULL;
 
     /* X and Y *must* be set */
     if (!LIST_VALUE_PARSED(set, PL_X) || !LIST_VALUE_PARSED(set, PL_Y))
@@ -441,24 +445,8 @@ const char* viewport_parse_viewport(struct viewport *vp,
         vp->height = (vp->height + screens[screen].lcdheight) - vp->y;
 
 #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)
-    if (!LIST_VALUE_PARSED(set, PL_FG))
-    {
-#if (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)
-        if (screen == SCREEN_REMOTE)
-            vp->fg_pattern = REMOTE_FG_FALLBACK;
-        else
-#endif
-            vp->fg_pattern = FG_FALLBACK;
-    }
-    if (!LIST_VALUE_PARSED(set, PL_BG))
-    {
-#if (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)
-        if (screen == SCREEN_REMOTE)
-            vp->bg_pattern = REMOTE_BG_FALLBACK;
-        else
-#endif
-            vp->bg_pattern = BG_FALLBACK;
-    }
+    vp->fg_pattern = get_viewport_default_colour(screen, true);
+    vp->bg_pattern = get_viewport_default_colour(screen, false);
 #endif /* LCD_DEPTH > 1 || LCD_REMOTE_DEPTH > 1 */
 
 #ifdef HAVE_LCD_COLOR
diff --git a/apps/gui/viewport.h b/apps/gui/viewport.h
index 6a4dd02..943cac2 100644
--- a/apps/gui/viewport.h
+++ b/apps/gui/viewport.h
@@ -48,6 +48,7 @@ void viewport_set_defaults(struct viewport *vp,
                             const enum screen_type screen);
 void viewport_set_fullscreen(struct viewport *vp,
                               const enum screen_type screen);
+int get_viewport_default_colour(enum screen_type screen, bool fgcolour);
 
 #ifdef HAVE_LCD_BITMAP
 void viewportmanager_theme_enable(enum screen_type screen, bool enable,
diff --git a/apps/gui/wps.c b/apps/gui/wps.c
index 090276d..d0d2de1 100644
--- a/apps/gui/wps.c
+++ b/apps/gui/wps.c
@@ -129,23 +129,23 @@ void wps_data_load(enum screen_type screen, const char *buf, bool isfile)
         char *skin_buf[NB_SCREENS] = {
 #ifdef HAVE_LCD_BITMAP
 #if LCD_DEPTH > 1
-            "%Xd\n"
+            "%X(d)\n"
 #endif
             "%s%?it<%?in<%in. |>%it|%fn>\n"
-            "%s%?ia<%ia|%?d2<%d2|(root)>>\n"
-            "%s%?id<%id|%?d1<%d1|(root)>> %?iy<(%iy)|>\n\n"
+            "%s%?ia<%ia|%?d(2)<%d(2)|(root)>>\n"
+            "%s%?id<%id|%?d(1)<%d(1)|(root)>> %?iy<(%iy)|>\n\n"
             "%al%pc/%pt%ar[%pp:%pe]\n"
             "%fbkBit %?fv<avg|> %?iv<(id3v%iv)|(no id3)>\n"
             "%pb\n%pm\n",
 #else
-            "%s%pp/%pe: %?it<%it|%fn> - %?ia<%ia|%d2> - %?id<%id|%d1>\n"
+            "%s%pp/%pe: %?it<%it|%fn> - %?ia<%ia|%d(2)> - %?id<%id|%d(1)>\n"
             "%pc%?ps<*|/>%pt\n",
 #endif
 #ifdef HAVE_REMOTE_LCD
 #if LCD_REMOTE_DEPTH > 1
-            "%Xd\n"
+            "%X(d)\n"
 #endif
-            "%s%?ia<%ia|%?d2<%d2|(root)>>\n"
+            "%s%?ia<%ia|%?d(2)<%d(2)|(root)>>\n"
             "%s%?it<%?in<%in. |>%it|%fn>\n"
             "%al%pc/%pt%ar[%pp:%pe]\n"
             "%fbkBit %?fv<avg|> %?iv<(id3v%iv)|(no id3)>\n"
diff --git a/apps/misc.c b/apps/misc.c
index 95c0dd6..a842c0e 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -967,6 +968,7 @@ const char* parse_list(const char *fmt, uint32_t *set_vals,
     const char** s;
     int* d;
     bool set, is_negative;
+    bool is_last_var;
     int i=0;
 
     va_start(ap, str);
@@ -981,6 +983,7 @@ const char* parse_list(const char *fmt, uint32_t *set_vals,
                 goto err;
             p++;
         }
+        is_last_var = fmt[1] == '\0';
         set = false;
         switch (*fmt++) 
         {
@@ -988,9 +991,9 @@ const char* parse_list(const char *fmt, uint32_t *set_vals,
                 s = va_arg(ap, const char **);
 
                 *s = p;
-                while (*p && *p != sep)
+                while (*p && *p != sep && *p != ')')
                     p++;
-                set = (s[0][0]!='-') && (s[0][1]!=sep) ;
+                set = (s[0][0]!='-') && (s[0][1]!=sep && s[0][1]!=')') ;
                 break;
 
             case 'd': /* int */
@@ -1028,7 +1031,7 @@ const char* parse_list(const char *fmt, uint32_t *set_vals,
                 {
                     if (!set_vals || *p != '-')
                         goto err;
-                    while (*p && *p != sep)
+                    while (*p && *p != sep && (!is_last_var || (is_last_var && *p!=')')))
                         p++;
                 }
                 else
@@ -1053,7 +1056,7 @@ const char* parse_list(const char *fmt, uint32_t *set_vals,
                     goto err;
                 else
                 {
-                    while (*p && *p != sep)
+                    while (*p && *p != sep && (!is_last_var || (is_last_var && *p!=')')))
                         p++;
                 }
 
diff --git a/wps/wpsbuild.pl b/wps/wpsbuild.pl
index 81a90f3..ae0a717 100755
--- a/wps/wpsbuild.pl
+++ b/wps/wpsbuild.pl
@@ -225,7 +225,7 @@ sub copywps
 
            open(WPSFILE, "$dir/$req_g_wps");
            while (<WPSFILE>) {
-              $filelist[$#filelist + 1] = $1 if (/\|([^|]*?.bmp)\|/);
+              $filelist[$#filelist + 1] = $1 if (/[\(,]([^,]*?.bmp)[\),]/);
            }
            close(WPSFILE);
 

Reply via email to