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.tar.gz rockbox-17c348432553d80089014cabaf8784f16519faa8.zip |
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 67b5516419..3e49960686 100644 --- a/utils/newparser/handle_tags.c +++ b/utils/newparser/handle_tags.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <stdio.h> | 22 | #include <stdio.h> |
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <stdbool.h> | 24 | #include <stdbool.h> |
25 | #include <stdint.h> | ||
25 | #include <string.h> | 26 | #include <string.h> |
26 | #include <ctype.h> | 27 | #include <ctype.h> |
27 | 28 | ||
@@ -78,8 +79,11 @@ struct tag_handler_table { | |||
78 | int flags; | 79 | int flags; |
79 | tag_handler *func; | 80 | tag_handler *func; |
80 | }; | 81 | }; |
82 | #define EAT_LINE_ENDING 0x01 | ||
81 | 83 | ||
82 | struct tag_handler_table table[] = { | 84 | struct tag_handler_table table[] = { |
85 | { SKIN_TOKEN_ENABLE_THEME, EAT_LINE_ENDING, NULL }, | ||
86 | { SKIN_TOKEN_DISABLE_THEME, EAT_LINE_ENDING, NULL }, | ||
83 | /* file tags */ | 87 | /* file tags */ |
84 | { SKIN_TOKEN_FILE_BITRATE , 0, handle_this_or_next_track }, | 88 | { SKIN_TOKEN_FILE_BITRATE , 0, handle_this_or_next_track }, |
85 | { SKIN_TOKEN_FILE_CODEC , 0, handle_this_or_next_track }, | 89 | { SKIN_TOKEN_FILE_CODEC , 0, handle_this_or_next_track }, |
@@ -108,31 +112,43 @@ struct tag_handler_table table[] = { | |||
108 | { SKIN_TOKEN_TRANSLATEDSTRING, 0, handle_translate_string}, | 112 | { SKIN_TOKEN_TRANSLATEDSTRING, 0, handle_translate_string}, |
109 | }; | 113 | }; |
110 | 114 | ||
111 | int handle_tree(struct skin *skin, struct skin_element* tree) | 115 | int handle_tree(struct skin *skin, struct skin_element* tree, struct line *line) |
112 | { | 116 | { |
113 | /* for later.. do this in two steps | 117 | /* for later.. do this in two steps |
114 | * 1) count how much skin buffer is needed | 118 | * 1) count how much skin buffer is needed |
115 | * 2) do the actual tree->skin conversion | 119 | * 2) do the actual tree->skin conversion |
116 | */ | 120 | */ |
117 | struct skin_element* element = tree; | 121 | struct skin_element* element = tree; |
122 | struct line *current_line = line; | ||
118 | int counter; | 123 | int counter; |
119 | while (element) | 124 | while (element) |
120 | { | 125 | { |
121 | if (element->type == SUBLINES) | 126 | if (element->type == LINE) |
127 | { | ||
128 | struct line *line = (struct line*)malloc(sizeof(struct line)); | ||
129 | line->update_mode = 0; | ||
130 | line->eat_line_ending = false; | ||
131 | element->data = line; | ||
132 | current_line = line; | ||
133 | } | ||
134 | else if (element->type == SUBLINES) | ||
122 | { | 135 | { |
123 | struct subline *subline = malloc(sizeof(struct subline)); | 136 | struct subline *subline = malloc(sizeof(struct subline)); |
124 | subline->current_line = -1; | 137 | subline->current_line = -1; |
125 | subline->last_change_tick = 0; | 138 | subline->last_change_tick = 0; |
126 | element->data = subline; | 139 | element->data = subline; |
127 | } | 140 | } |
128 | if (element->type == TAG) | 141 | else if (element->type == TAG) |
129 | { | 142 | { |
130 | int i; | 143 | int i; |
131 | for(i=0;i<sizeof(table)/sizeof(*table);i++) | 144 | for(i=0;i<sizeof(table)/sizeof(*table);i++) |
132 | { | 145 | { |
133 | if (table[i].type == element->tag->type) | 146 | if (table[i].type == element->tag->type) |
134 | { | 147 | { |
135 | table[i].func(skin, element, false); | 148 | if (table[i].func) |
149 | table[i].func(skin, element, false); | ||
150 | if (table[i].flags&EAT_LINE_ENDING) | ||
151 | line->eat_line_ending = true; | ||
136 | break; | 152 | break; |
137 | } | 153 | } |
138 | } | 154 | } |
@@ -145,7 +161,7 @@ int handle_tree(struct skin *skin, struct skin_element* tree) | |||
145 | counter = 0; | 161 | counter = 0; |
146 | while (counter < element->children_count) | 162 | while (counter < element->children_count) |
147 | { | 163 | { |
148 | int ret = handle_tree(skin, element->children[counter]); | 164 | int ret = handle_tree(skin, element->children[counter], current_line); |
149 | counter++; | 165 | counter++; |
150 | } | 166 | } |
151 | element = element->next; | 167 | element = element->next; |
diff --git a/utils/newparser/newparser.c b/utils/newparser/newparser.c index 4baf4aec03..f56fe6db84 100644 --- a/utils/newparser/newparser.c +++ b/utils/newparser/newparser.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "tag_table.h" | 29 | #include "tag_table.h" |
30 | #include "skin_structs.h" | 30 | #include "skin_structs.h" |
31 | 31 | ||
32 | int handle_tree(struct skin *skin, struct skin_element* tree); | 32 | int handle_tree(struct skin *skin, struct skin_element* tree, struct line* line); |
33 | void skin_render(struct skin_element* root); | 33 | void skin_render(struct skin_element* root); |
34 | 34 | ||
35 | int main(int argc, char* argv[]) | 35 | int main(int argc, char* argv[]) |
@@ -73,7 +73,7 @@ int main(int argc, char* argv[]) | |||
73 | 73 | ||
74 | struct skin_element* tree = skin_parse(buffer); | 74 | struct skin_element* tree = skin_parse(buffer); |
75 | struct skin skin; | 75 | struct skin skin; |
76 | handle_tree(&skin, tree); | 76 | handle_tree(&skin, tree, NULL); |
77 | skin_render(tree); | 77 | skin_render(tree); |
78 | 78 | ||
79 | skin_free_tree(tree); | 79 | skin_free_tree(tree); |
diff --git a/utils/newparser/skin_render.c b/utils/newparser/skin_render.c index 03324665a1..8c581134a8 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, | |||
94 | buf, buf_size, line_number); | 94 | buf, buf_size, line_number); |
95 | } | 95 | } |
96 | 96 | ||
97 | void skin_render_viewport(struct skin_element* line, bool draw_tags) | 97 | void skin_render_viewport(struct skin_element* viewport, bool draw_tags) |
98 | { | 98 | { |
99 | int line_number = 0; | 99 | int line_number = 0; |
100 | char linebuf[MAX_LINE]; | 100 | char linebuf[MAX_LINE]; |
101 | skin_render_func func = skin_render_line; | 101 | skin_render_func func = skin_render_line; |
102 | struct skin_element* line = viewport; | ||
102 | while (line) | 103 | while (line) |
103 | { | 104 | { |
104 | linebuf[0] = '\0'; | 105 | linebuf[0] = '\0'; |
@@ -107,10 +108,14 @@ void skin_render_viewport(struct skin_element* line, bool draw_tags) | |||
107 | else if (line->type == LINE) | 108 | else if (line->type == LINE) |
108 | func = skin_render_line; | 109 | func = skin_render_line; |
109 | 110 | ||
110 | func (line, linebuf, sizeof(linebuf), line_number); | 111 | func(line, linebuf, sizeof(linebuf), line_number); |
111 | if (draw_tags) | 112 | if (draw_tags) |
112 | { | 113 | { |
113 | printf("%s\n", linebuf); | 114 | printf("%s", linebuf); |
115 | if (!((struct line*)line->data)->eat_line_ending) | ||
116 | { | ||
117 | printf("\n"); | ||
118 | } | ||
114 | } | 119 | } |
115 | line_number++; | 120 | line_number++; |
116 | line = line->next; | 121 | line = line->next; |
diff --git a/utils/newparser/skin_structs.h b/utils/newparser/skin_structs.h index 7dec7f85dc..5755120e74 100644 --- a/utils/newparser/skin_structs.h +++ b/utils/newparser/skin_structs.h | |||
@@ -51,6 +51,11 @@ struct progressbar { | |||
51 | bool have_bitmap_pb; | 51 | bool have_bitmap_pb; |
52 | }; | 52 | }; |
53 | 53 | ||
54 | struct line { | ||
55 | unsigned update_mode; | ||
56 | bool eat_line_ending; | ||
57 | }; | ||
58 | |||
54 | struct subline { | 59 | struct subline { |
55 | int timeout; | 60 | int timeout; |
56 | int current_line; | 61 | int current_line; |