ref: 3b99a601546a722838cfdb65de9848b7a367b169
parent: f72da96f2898465c88ff683a69e5b7a14a931737
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Thu Oct 10 19:59:19 EDT 2013
mothra: handle <input type=image>
--- a/sys/src/cmd/mothra/forms.c
+++ b/sys/src/cmd/mothra/forms.c
@@ -169,10 +169,27 @@
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)
--- a/sys/src/cmd/mothra/html.h
+++ b/sys/src/cmd/mothra/html.h
@@ -112,6 +112,15 @@
};
/*
+ * 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.
--- a/sys/src/cmd/mothra/mothra.c
+++ b/sys/src/cmd/mothra/mothra.c
@@ -731,6 +731,13 @@
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;
--- a/sys/src/cmd/mothra/rdhtml.c
+++ b/sys/src/cmd/mothra/rdhtml.c
@@ -68,10 +68,6 @@
g->para=0;
g->linebrk=0;
}
-enum{- HORIZ,
- VERT,
-};
int strtolength(Hglob *g, int dir, char *str){double f;
--
⑨