1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
8 * $Id: skin_parser.c 26752 2010-06-10 21:22:16Z bieber $
10 * Copyright (C) 2010 Jonathan Gordon
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
27 #include "skin_parser.h"
28 #include "skin_debug.h"
29 #include "tag_table.h"
31 #include "skin_scan.h"
33 void skin_render_alternator(struct skin_element
* alternator
, int line_number
);
35 /* Draw a LINE element onto the display */
36 void skin_render_line(struct skin_element
* line
, int line_number
)
39 if (line
->children_count
== 0)
40 return; /* empty line, do nothing */
41 struct skin_element
*child
= line
->children
[0];
47 value
= 0; /* actually get it from the token :p */
48 if (value
>= child
->children_count
)
49 value
= child
->children_count
-1;
50 if (child
->children
[value
]->type
== SUBLINES
)
51 skin_render_alternator(child
->children
[value
], line_number
);
52 else if (child
->children
[value
]->type
== LINE
)
53 skin_render_line(child
->children
[value
], line_number
);
56 printf("%%%s", child
->tag
->name
);
59 printf("%s", (char*)(child
->data
));
69 void skin_render_alternator(struct skin_element
* alternator
, int line_number
)
71 /*TODO Choose which subline to draw */
72 skin_render_line(alternator
->children
[0], line_number
);
75 void skin_render_viewport(struct skin_element
* viewport
)
77 struct skin_element
*line
= viewport
;
81 printf("\n[%d]", line_number
); /* might be incorrect */
82 if (line
->type
== SUBLINES
)
83 skin_render_alternator(line
, line_number
);
84 else if (line
->type
== LINE
)
85 skin_render_line(line
, line_number
);
91 void skin_render(struct skin_element
* root
)
93 struct skin_element
* viewport
= root
;
96 skin_render_viewport(viewport
->children
[0]);
97 viewport
= viewport
->next
;