draw: use tokenize() in markup parsing

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-06-23 13:39:47 +02:00
parent 7dd1fa0e0b
commit 7803225553
2 changed files with 36 additions and 17 deletions

View File

@ -206,37 +206,51 @@ draw_markup_on_element(markup_parser_data_t *p, const char *elem,
/* hack: markup.c validates tags so we can avoid strcmps here */ /* hack: markup.c validates tags so we can avoid strcmps here */
switch (*elem) { switch (*elem) {
case 'b': /* bg */ case 'b': /* bg */
for (; *names; names++, values++) for(; *names; names++, values++)
{ switch(a_tokenize(*names, -1))
if(!a_strcmp(*names, "color")) {
case A_TK_COLOR:
data->has_bg_color = xcolor_new(data->connection, data->phys_screen, data->has_bg_color = xcolor_new(data->connection, data->phys_screen,
*values, &data->bg_color); *values, &data->bg_color);
else if(!a_strcmp(*names, "image")) break;
case A_TK_IMAGE:
data->bg_image = draw_image_new(*values); data->bg_image = draw_image_new(*values);
} break;
default:
break;
}
break; break;
case 't': /* text */ case 't': /* text */
for (; *names; names++, values++) for(; *names; names++, values++)
{ switch(a_tokenize(*names, -1))
if(!a_strcmp(*names, "align")) {
case A_TK_ALIGN:
data->align = draw_align_get_from_str(*values); data->align = draw_align_get_from_str(*values);
else if(!a_strcmp(*names, "shadow")) break;
case A_TK_SHADOW:
xcolor_new(data->connection, data->phys_screen, *values, xcolor_new(data->connection, data->phys_screen, *values,
&data->shadow.color); &data->shadow.color);
else if(!a_strcmp(*names, "shadow_offset")) break;
case A_TK_SHADOW_OFFSET:
data->shadow.offset = atoi(*values); data->shadow.offset = atoi(*values);
} break;
default:
break;
}
break; break;
case 'm': /* margin */ case 'm': /* margin */
for (; *names; names++, values++) for (; *names; names++, values++)
{ switch(a_tokenize(*names, -1))
if(!a_strcmp(*names, "left")) {
case A_TK_LEFT:
data->margin.left = atoi(*values); data->margin.left = atoi(*values);
else if(!a_strcmp(*names, "right")) break;
case A_TK_RIGHT:
data->margin.right = atoi(*values); data->margin.right = atoi(*values);
} break;
default:
break;
}
break; break;
} }
} }

View File

@ -1,3 +1,4 @@
align
bg bg
border_padding border_padding
border_width border_width
@ -6,6 +7,7 @@ bottom
bottomleft bottomleft
bottomright bottomright
center center
color
data data
draw_style draw_style
fg fg
@ -16,6 +18,7 @@ flex
gap gap
grow grow
height height
image
left left
line line
max_value max_value
@ -23,6 +26,8 @@ min_value
reverse reverse
right right
scale scale
shadow
shadow_offset
text text
ticks_count ticks_count
ticks_gap ticks_gap