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,36 +206,50 @@ draw_markup_on_element(markup_parser_data_t *p, const char *elem,
/* hack: markup.c validates tags so we can avoid strcmps here */
switch (*elem) {
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,
*values, &data->bg_color);
else if(!a_strcmp(*names, "image"))
break;
case A_TK_IMAGE:
data->bg_image = draw_image_new(*values);
break;
default:
break;
}
break;
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);
else if(!a_strcmp(*names, "shadow"))
break;
case A_TK_SHADOW:
xcolor_new(data->connection, data->phys_screen, *values,
&data->shadow.color);
else if(!a_strcmp(*names, "shadow_offset"))
break;
case A_TK_SHADOW_OFFSET:
data->shadow.offset = atoi(*values);
break;
default:
break;
}
break;
case 'm': /* margin */
for (; *names; names++, values++)
switch(a_tokenize(*names, -1))
{
if(!a_strcmp(*names, "left"))
case A_TK_LEFT:
data->margin.left = atoi(*values);
else if(!a_strcmp(*names, "right"))
break;
case A_TK_RIGHT:
data->margin.right = atoi(*values);
break;
default:
break;
}
break;
}

View File

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