From 3b99a601546a722838cfdb65de9848b7a367b169 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Thu, 10 Oct 2013 23:59:19 +0200 Subject: mothra: handle --- sys/src/cmd/mothra/forms.c | 21 +++++++++++++++++++-- sys/src/cmd/mothra/html.h | 9 +++++++++ sys/src/cmd/mothra/mothra.c | 7 +++++++ sys/src/cmd/mothra/rdhtml.c | 4 ---- 4 files changed, 35 insertions(+), 6 deletions(-) (limited to 'sys/src') diff --git a/sys/src/cmd/mothra/forms.c b/sys/src/cmd/mothra/forms.c index 321751214..d8feef5ba 100644 --- a/sys/src/cmd/mothra/forms.c +++ b/sys/src/cmd/mothra/forms.c @@ -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) diff --git a/sys/src/cmd/mothra/html.h b/sys/src/cmd/mothra/html.h index 0988a7e80..f486755be 100644 --- a/sys/src/cmd/mothra/html.h +++ b/sys/src/cmd/mothra/html.h @@ -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 tags. diff --git a/sys/src/cmd/mothra/mothra.c b/sys/src/cmd/mothra/mothra.c index f40d22960..9e87d4819 100644 --- a/sys/src/cmd/mothra/mothra.c +++ b/sys/src/cmd/mothra/mothra.c @@ -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; diff --git a/sys/src/cmd/mothra/rdhtml.c b/sys/src/cmd/mothra/rdhtml.c index 2549a0697..fe89b1e98 100644 --- a/sys/src/cmd/mothra/rdhtml.c +++ b/sys/src/cmd/mothra/rdhtml.c @@ -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; -- cgit v1.2.3