summaryrefslogtreecommitdiff
path: root/sys/src/cmd/mothra
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-10-10 23:59:19 +0200
committercinap_lenrek <cinap_lenrek@gmx.de>2013-10-10 23:59:19 +0200
commit3b99a601546a722838cfdb65de9848b7a367b169 (patch)
tree7f063e1e43ced213e02ef1c769c3e0c784f431e8 /sys/src/cmd/mothra
parentf72da96f2898465c88ff683a69e5b7a14a931737 (diff)
mothra: handle <input type=image>
Diffstat (limited to 'sys/src/cmd/mothra')
-rw-r--r--sys/src/cmd/mothra/forms.c21
-rw-r--r--sys/src/cmd/mothra/html.h9
-rw-r--r--sys/src/cmd/mothra/mothra.c7
-rw-r--r--sys/src/cmd/mothra/rdhtml.c4
4 files changed, 35 insertions, 6 deletions
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
@@ -112,6 +112,15 @@ enum{
};
/*
+ * 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.
* Tag_text tags text not in a tag.
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;