diff options
| author | Jonathan Gordon <rockbox@jdgordon.info> | 2010-06-13 14:42:09 +0000 |
|---|---|---|
| committer | Jonathan Gordon <rockbox@jdgordon.info> | 2010-06-13 14:42:09 +0000 |
| commit | 17c348432553d80089014cabaf8784f16519faa8 (patch) | |
| tree | 7a2b7f4ba000f4df94c7a60bd099a1baa9a60c1a /utils/newparser | |
| parent | a8c073216d63abf2ee42ef4f42e16d109c3f5791 (diff) | |
| download | rockbox-17c348432553d80089014cabaf8784f16519faa8.zip rockbox-17c348432553d80089014cabaf8784f16519faa8.tar.gz rockbox-17c348432553d80089014cabaf8784f16519faa8.tar.bz2 rockbox-17c348432553d80089014cabaf8784f16519faa8.tar.xz | |
Start dealing with LINE elements... setup a flag which lets tags tell the renderer to not start a new line in the viewport (i.e %we/d/i %X/x/xd etc)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26833 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/newparser')
| -rw-r--r-- | utils/newparser/handle_tags.c | 28 | ||||
| -rw-r--r-- | utils/newparser/newparser.c | 4 | ||||
| -rw-r--r-- | utils/newparser/skin_render.c | 11 | ||||
| -rw-r--r-- | utils/newparser/skin_structs.h | 5 |
4 files changed, 37 insertions, 11 deletions
diff --git a/utils/newparser/handle_tags.c b/utils/newparser/handle_tags.c index 67b5516..3e49960 100644 --- a/utils/newparser/handle_tags.c +++ b/utils/newparser/handle_tags.c @@ -22,6 +22,7 @@ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> +#include <stdint.h> #include <string.h> #include <ctype.h> @@ -78,8 +79,11 @@ struct tag_handler_table { int flags; tag_handler *func; }; +#define EAT_LINE_ENDING 0x01 struct tag_handler_table table[] = { + { SKIN_TOKEN_ENABLE_THEME, EAT_LINE_ENDING, NULL }, + { SKIN_TOKEN_DISABLE_THEME, EAT_LINE_ENDING, NULL }, /* file tags */ { SKIN_TOKEN_FILE_BITRATE , 0, handle_this_or_next_track }, { SKIN_TOKEN_FILE_CODEC , 0, handle_this_or_next_track }, @@ -108,31 +112,43 @@ struct tag_handler_table table[] = { { SKIN_TOKEN_TRANSLATEDSTRING, 0, handle_translate_string}, }; -int handle_tree(struct skin *skin, struct skin_element* tree) +int handle_tree(struct skin *skin, struct skin_element* tree, struct line *line) { /* for later.. do this in two steps * 1) count how much skin buffer is needed * 2) do the actual tree->skin conversion */ struct skin_element* element = tree; + struct line *current_line = line; int counter; while (element) { - if (element->type == SUBLINES) + if (element->type == LINE) + { + struct line *line = (struct line*)malloc(sizeof(struct line)); + line->update_mode = 0; + line->eat_line_ending = false; + element->data = line; + current_line = line; + } + else if (element->type == SUBLINES) { struct subline *subline = malloc(sizeof(struct subline)); subline->current_line = -1; subline->last_change_tick = 0; element->data = subline; } - if (element->type == TAG) + else if (element->type == TAG) { - int i; + int i; for(i=0;i<sizeof(table)/sizeof(*table);i++) { if (table[i].type == element->tag->type) { - table[i].func(skin, element, false); + if (table[i].func) + table[i].func(skin, element, false); + if (table[i].flags&EAT_LINE_ENDING) + line->eat_line_ending = true; break; } } @@ -145,7 +161,7 @@ int handle_tree(struct skin *skin, struct skin_element* tree) counter = 0; while (counter < element->children_count) { - int ret = handle_tree(skin, element->children[counter]); + int ret = handle_tree(skin, element->children[counter], current_line); counter++; } element = element->next; diff --git a/utils/newparser/newparser.c b/utils/newparser/newparser.c index 4baf4ae..f56fe6d 100644 --- a/utils/newparser/newparser.c +++ b/utils/newparser/newparser.c @@ -29,7 +29,7 @@ #include "tag_table.h" #include "skin_structs.h" -int handle_tree(struct skin *skin, struct skin_element* tree); +int handle_tree(struct skin *skin, struct skin_element* tree, struct line* line); void skin_render(struct skin_element* root); int main(int argc, char* argv[]) @@ -73,7 +73,7 @@ int main(int argc, char* argv[]) struct skin_element* tree = skin_parse(buffer); struct skin skin; - handle_tree(&skin, tree); + handle_tree(&skin, tree, NULL); skin_render(tree); skin_free_tree(tree); diff --git a/utils/newparser/skin_render.c b/utils/newparser/skin_render.c index 0332466..8c58113 100644 --- a/utils/newparser/skin_render.c +++ b/utils/newparser/skin_render.c @@ -94,11 +94,12 @@ void skin_render_alternator(struct skin_element* alternator, buf, buf_size, line_number); } -void skin_render_viewport(struct skin_element* line, bool draw_tags) +void skin_render_viewport(struct skin_element* viewport, bool draw_tags) { int line_number = 0; char linebuf[MAX_LINE]; skin_render_func func = skin_render_line; + struct skin_element* line = viewport; while (line) { linebuf[0] = '\0'; @@ -107,10 +108,14 @@ void skin_render_viewport(struct skin_element* line, bool draw_tags) else if (line->type == LINE) func = skin_render_line; - func (line, linebuf, sizeof(linebuf), line_number); + func(line, linebuf, sizeof(linebuf), line_number); if (draw_tags) { - printf("%s\n", linebuf); + printf("%s", linebuf); + if (!((struct line*)line->data)->eat_line_ending) + { + printf("\n"); + } } line_number++; line = line->next; diff --git a/utils/newparser/skin_structs.h b/utils/newparser/skin_structs.h index 7dec7f8..5755120 100644 --- a/utils/newparser/skin_structs.h +++ b/utils/newparser/skin_structs.h @@ -51,6 +51,11 @@ struct progressbar { bool have_bitmap_pb; }; +struct line { + unsigned update_mode; + bool eat_line_ending; +}; + struct subline { int timeout; int current_line; |