mothra: handle <input type=image>

This commit is contained in:
cinap_lenrek 2013-10-10 23:59:19 +02:00
parent f72da96f28
commit 3b99a60154
4 changed files with 35 additions and 6 deletions

View file

@ -169,10 +169,27 @@ void rdform(Hglob *g){
f->type=RADIO;
else if(cistrcmp(s, "submit")==0)
f->type=SUBMIT;
else if(cistrcmp(s, "image")==0){
f->type=SUBMIT;
s=pl_getattr(g->attr, "src");
if(s && *s)
nstrcpy(g->state->image, s, sizeof(g->state->image));
s=pl_getattr(g->attr, "width");
if(s && *s)
g->state->width=strtolength(g, HORIZ, s);
s=pl_getattr(g->attr, "height");
if(s && *s)
g->state->height=strtolength(g, VERT, s);
s=pl_getattr(g->attr, "alt");
if(s==0 || *s == 0) s = f->value;
pl_htmloutput(g, g->nsp, s, f);
g->state->image[0] = 0;
g->state->width=0;
g->state->height=0;
break;
}
else if(cistrcmp(s, "button")==0)
f->type=BUTTON;
else if(cistrcmp(s, "image")==0)
f->type=FILE;
else if(cistrcmp(s, "file")==0)
f->type=FILE;
else if(cistrcmp(s, "reset")==0)

View file

@ -111,6 +111,15 @@ enum{
ENORMOUS,
};
/*
* length direction
*/
enum{
HORIZ,
VERT,
};
int strtolength(Hglob *g, int dir, char *str);
/*
* Token names for the html parser.
* Tag_end corresponds to </end> tags.

View file

@ -731,6 +731,13 @@ void dolink(Panel *p, int buttons, Rtext *word){
int yoffs;
Action *a;
/* really a button, hit it */
if(word->p != nil && word->p != p && strcmp(word->p->kind, "button") == 0){
extern void pl_buttonhit(Panel *p, int buttons, int check);
pl_buttonhit(word->p, buttons, 0);
return;
}
a=word->user;
if(a == nil || (a->link == nil && a->image == nil))
return;

View file

@ -68,10 +68,6 @@ void pl_linespace(Hglob *g){
g->para=0;
g->linebrk=0;
}
enum{
HORIZ,
VERT,
};
int strtolength(Hglob *g, int dir, char *str){
double f;