[w3m-dev 04409] Re: [patch] support for the <button> tag (HTML 4.01)

[email protected] Wed, 25 Aug 2010 21:29:52 +0900
Newsgroups gmane.comp.web.w3m.devel
Message-ID <[email protected]>
On Fri, Aug 13, 2010 at 05:11:09PM +0900, [email protected] wrote:
> =E3=81=AB=E4=B8=8A=E3=81=8C=E3=81=A3=E3=81=A6=E3=81=84=E3=82=8B <button=
> =E3=82=B5=E3=83=9D=E3=83=BC=E3=83=88=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=99=
=E3=82=8B=E3=83=91=E3=83=83=E3=83=81=E3=81=AF
>=20
> http://www.sic.med.tohoku.ac.jp/~satodai/w3m-dev/200203.month/3100.html
>=20
> =E3=81=AE=E3=82=88=E3=81=86=E3=81=A7=E3=81=99=E3=81=8C=E3=80=81
>=20
> http://www.sic.med.tohoku.ac.jp/~satodai/w3m-dev/200203.month/3105.html
>=20
> =E3=81=AB=E3=81=A6=E5=8D=B4=E4=B8=8B=E3=81=95=E3=82=8C=E3=81=A6=E3=81=97=
=E3=81=BE=E3=81=A3=E3=81=9F=E3=82=88=E3=81=86=E3=81=A7=E3=81=99=E3=80=82

=E3=81=A8=E3=82=8A=E3=81=82=E3=81=88=E3=81=9A=E3=80=81=E7=8F=BE=E5=9C=A8=E3=
=81=AE CVS HEAD =E3=81=AB=E3=81=AF=E5=BD=93=E3=81=9F=E3=82=89=E3=81=AA=E3=
=81=8F=E3=81=AA=E3=81=A3=E3=81=A6=E3=81=84=E3=81=9F=E3=81=AE=E3=81=A7=E5=B7=
=AE=E5=88=86=E3=82=92=E5=8F=96=E3=82=8A=E7=9B=B4=E3=81=97=E3=81=BE=E3=81=97=
=E3=81=9F=E3=80=82

> =E3=81=A7=E3=82=82=E5=90=8C=E3=81=98=E3=82=88=E3=81=86=E3=81=AA=E3=83=91=
=E3=83=83=E3=83=81=E3=81=8C=E6=8F=90=E4=BE=9B=E3=81=95=E3=82=8C=E3=81=A6=E3=
=81=84=E3=81=BE=E3=81=99=E3=81=8C=E3=80=81
> =E9=81=95=E3=81=84=E3=81=8C=E3=82=88=E3=81=8F=E3=82=8F=E3=81=8B=E3=82=8A=
=E3=81=BE=E3=81=9B=E3=82=93=E3=81=A7=E3=81=97=E3=81=9F=E3=80=82
> # <pre_int> =EF=BD=9E </pre_int> =E3=81=AE=E6=9C=89=E7=84=A1=EF=BC=9F
>=20
> http://github.com/shinh/w3m/commit/c64a257e6bee7bf8b27f6f21892447846b98=
0b02
> http://github.com/shinh/w3m/commit/c64a257e6bee7bf8b27f6f21892447846b98=
0b02.diff

=E3=82=92=E5=8F=82=E8=80=83=E3=81=AB=E3=80=81=E3=82=B3=E3=83=A1=E3=83=B3=E3=
=83=88=E3=82=A2=E3=82=A6=E3=83=88=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=81=
=9F <pre_int> =EF=BD=9E </pre_int> =E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97=E3=
=81=A6=E3=81=82=E3=82=8A=E3=81=BE=E3=81=99=E3=80=82
--=20
Regards,
	dai

GPG Fingerprint =3D 0B29 D88E 42E6 B765 B8D8 EA50 7839 619D D439 668E
=0C
diff -urp a/file.c b/file.c
--- a/file.c	2010-08-03 19:20:10.000000000 +0900
+++ b/file.c	2010-08-25 21:13:12.000000000 +0900
@@ -3730,6 +3730,63 @@ process_input(struct parsed_tag *tag)
 }
=20
 Str
+process_button(struct parsed_tag *tag)
+{
+    Str tmp =3D NULL;
+    char *p, *q, *r, *qq =3D NULL;
+    int qlen, v;
+
+    if (cur_form_id < 0) {
+       char *s =3D "<form_int method=3Dinternal action=3Dnone>";
+       tmp =3D process_form(parse_tag(&s, TRUE));
+    }
+    if (tmp =3D=3D NULL)
+       tmp =3D Strnew();
+
+    p =3D "submit";
+    parsedtag_get_value(tag, ATTR_TYPE, &p);
+    q =3D NULL;
+    parsedtag_get_value(tag, ATTR_VALUE, &q);
+    r =3D "";
+    parsedtag_get_value(tag, ATTR_NAME, &r);
+
+    v =3D formtype(p);
+    if (v =3D=3D FORM_UNKNOWN)
+       return NULL;
+
+    if (!q) {
+       switch (v) {
+       case FORM_INPUT_SUBMIT:
+       case FORM_INPUT_BUTTON:
+           q =3D "SUBMIT";
+           break;
+       case FORM_INPUT_RESET:
+           q =3D "RESET";
+           break;
+       }
+    }
+    if (q) {
+       qq =3D html_quote(q);
+       qlen =3D strlen(q);
+    }
+
+    Strcat_charp(tmp, "<pre_int>");
+    Strcat(tmp, Sprintf("<input_alt hseq=3D\"%d\" fid=3D\"%d\" type=3D%s=
 "
+                       "name=3D\"%s\" value=3D\"%s\">",
+                       cur_hseq++, cur_form_id, p, html_quote(r), qq));
+    return tmp;
+}
+
+Str
+process_n_button(void)
+{
+    Str tmp =3D Strnew();
+    Strcat_charp(tmp, "</input_alt>");
+    Strcat_charp(tmp, "</pre_int>");
+    return tmp;
+}
+
+Str
 process_select(struct parsed_tag *tag)
 {
     Str tmp =3D NULL;
@@ -4968,6 +5025,16 @@ HTMLtagproc1(struct parsed_tag *tag, str
     case HTML_INPUT:
 	close_anchor(h_env, obuf);
 	tmp =3D process_input(tag);
+       if (tmp)
+           HTMLlineproc1(tmp->ptr, h_env);
+       return 1;
+    case HTML_BUTTON:
+       tmp =3D process_button(tag);
+       if (tmp)
+           HTMLlineproc1(tmp->ptr, h_env);
+       return 1;
+    case HTML_N_BUTTON:
+       tmp =3D process_n_button();
 	if (tmp)
 	    HTMLlineproc1(tmp->ptr, h_env);
 	return 1;
diff -urp a/html.c b/html.c
--- a/html.c	2010-08-16 19:20:22.000000000 +0900
+++ b/html.c	2010-08-25 21:18:03.000000000 +0900
@@ -56,6 +56,9 @@ unsigned char ALST_INPUT[] =3D
     ATTR_CORE
 };
 #define MAXA_INPUT      MAXA_CORE + 12
+unsigned char ALST_BUTTON[] =3D
+    { ATTR_TYPE, ATTR_VALUE, ATTR_NAME, ATTR_CORE };
+#define MAXA_BUTTON	MAXA_CORE + 3
 unsigned char ALST_TEXTAREA[] =3D
     { ATTR_COLS, ATTR_ROWS, ATTR_NAME, ATTR_READONLY, ATTR_CORE };
 #define MAXA_TEXTAREA   MAXA_CORE + 4
@@ -247,24 +250,24 @@ TagInfo TagMAP[MAX_HTMLTAG] =3D {
     {"/bdo", NULL, 0, TFLG_END},	/* 121 HTML_N_BDO */
     {"big", ALST_NOP, MAXA_NOP, 0},		/* 122 HTML_BIG */
     {"/big", NULL, 0, TFLG_END},	/* 123 HTML_N_BIG */
-    {"button", ALST_NOP, MAXA_NOP, 0},		/* 124 HTML_BUTTON */
-    {"fieldset", ALST_NOP, MAXA_NOP, 0},	        /* 125 HTML_FIELDSET */
-    {"/fieldset", NULL, 0, TFLG_END},	/* 126 HTML_N_FIELDSET */
-    {"iframe", ALST_NOP, MAXA_NOP, 0},		/* 127 HTML_IFRAME */
-    {"label", ALST_NOP, MAXA_NOP, 0}, 		/* 128 HTML_LABEL */
-    {"/label", NULL, 0, TFLG_END},	/* 129 HTML_N_LABEL */
-    {"legend", ALST_NOP, MAXA_NOP, 0},		/* 130 HTML_LEGEND */
-    {"/legend", NULL, 0, TFLG_END},	/* 131 HTML_N_LEGEND */
-    {"noscript", ALST_NOP, MAXA_NOP, 0},	        /* 132 HTML_NOSCRIPT */
-    {"/noscript", NULL, 0, TFLG_END},	/* 133 HTML_N_NOSCRIPT */
-    {"object", ALST_NOP, MAXA_NOP, 0},		/* 134 HTML_OBJECT */
-    {"optgroup", ALST_NOP, MAXA_NOP, 0},	        /* 135 HTML_OPTGROUP */
-    {"/optgroup", NULL, 0, TFLG_END},	/* 136 HTML_N_OPTGROUP */
-    {"param", ALST_NOP, MAXA_NOP, 0},		/* 137 HTML_PARAM */
-    {"small", ALST_NOP, MAXA_NOP, 0}, 		/* 138 HTML_SMALL */
-    {"/small", NULL, 0, TFLG_END},	/* 139 HTML_N_SMALL */
+    {"button", ALST_BUTTON, MAXA_BUTTON, 0},	/* 124 HTML_BUTTON */
+    {"/button", NULL, 0, TFLG_END},	/* 125 HTML_N_BUTTON */
+    {"fieldset", ALST_NOP, MAXA_NOP, 0},	/* 126 HTML_FIELDSET */
+    {"/fieldset", NULL, 0, TFLG_END},	/* 127 HTML_N_FIELDSET */
+    {"iframe", ALST_NOP, MAXA_NOP, 0},		/* 128 HTML_IFRAME */
+    {"label", ALST_NOP, MAXA_NOP, 0}, 		/* 129 HTML_LABEL */
+    {"/label", NULL, 0, TFLG_END},	/* 130 HTML_N_LABEL */
+    {"legend", ALST_NOP, MAXA_NOP, 0},		/* 131 HTML_LEGEND */
+    {"/legend", NULL, 0, TFLG_END},	/* 132 HTML_N_LEGEND */
+    {"noscript", ALST_NOP, MAXA_NOP, 0},	        /* 133 HTML_NOSCRIPT */
+    {"/noscript", NULL, 0, TFLG_END},	/* 134 HTML_N_NOSCRIPT */
+    {"object", ALST_NOP, MAXA_NOP, 0},		/* 135 HTML_OBJECT */
+    {"optgroup", ALST_NOP, MAXA_NOP, 0},	        /* 136 HTML_OPTGROUP */
+    {"/optgroup", NULL, 0, TFLG_END},	/* 137 HTML_N_OPTGROUP */
+    {"param", ALST_NOP, MAXA_NOP, 0},		/* 138 HTML_PARAM */
+    {"small", ALST_NOP, MAXA_NOP, 0}, 		/* 139 HTML_SMALL */
+    {"/small", NULL, 0, TFLG_END},	/* 140 HTML_N_SMALL */
=20
-    {NULL, NULL, 0, 0},		/* 140 Undefined */
     {NULL, NULL, 0, 0},		/* 141 Undefined */
     {NULL, NULL, 0, 0},		/* 142 Undefined */
     {NULL, NULL, 0, 0},		/* 143 Undefined */
diff -urp a/html.h b/html.h
--- a/html.h	2010-08-16 19:20:22.000000000 +0900
+++ b/html.h	2010-08-25 21:19:27.000000000 +0900
@@ -214,21 +214,22 @@ typedef struct {
 #define HTML_BIG        122
 #define HTML_N_BIG      123
 #define HTML_BUTTON     124
-#define HTML_FIELDSET   125
-#define HTML_N_FIELDSET 126
-#define HTML_IFRAME     127
-#define HTML_LABEL      128
-#define HTML_N_LABEL    129
-#define HTML_LEGEND     130
-#define HTML_N_LEGEND   131
-#define HTML_NOSCRIPT   132
-#define HTML_N_NOSCRIPT 133
-#define HTML_OBJECT     134
-#define HTML_OPTGROUP   135
-#define HTML_N_OPTGROUP 136
-#define HTML_PARAM      137
-#define HTML_SMALL      138
-#define HTML_N_SMALL    139
+#define HTML_N_BUTTON   125
+#define HTML_FIELDSET   126
+#define HTML_N_FIELDSET 127
+#define HTML_IFRAME     128
+#define HTML_LABEL      129
+#define HTML_N_LABEL    130
+#define HTML_LEGEND     131
+#define HTML_N_LEGEND   132
+#define HTML_NOSCRIPT   133
+#define HTML_N_NOSCRIPT 134
+#define HTML_OBJECT     135
+#define HTML_OPTGROUP   136
+#define HTML_N_OPTGROUP 137
+#define HTML_PARAM      138
+#define HTML_SMALL      139
+#define HTML_N_SMALL    140
=20
    /* pseudo tag */
 #define HTML_SELECT_INT     160
diff -urp a/proto.h b/proto.h
--- a/proto.h	2010-07-26 09:16:54.000000000 +0900
+++ b/proto.h	2010-08-25 19:33:45.000000000 +0900
@@ -207,6 +207,8 @@ extern int getImageSize(ImageCache * cac
 extern Str process_img(struct parsed_tag *tag, int width);
 extern Str process_anchor(struct parsed_tag *tag, char *tagbuf);
 extern Str process_input(struct parsed_tag *tag);
+extern Str process_button(struct parsed_tag *tag);
+extern Str process_n_button(void);
 extern Str process_select(struct parsed_tag *tag);
 extern Str process_n_select(void);
 extern void feed_select(char *str);
diff -urp a/table.c b/table.c
--- a/table.c	2010-08-09 21:54:48.000000000 +0900
+++ b/table.c	2010-08-25 19:33:45.000000000 +0900
@@ -2878,6 +2878,14 @@ feed_table_tag(struct table *tbl, char *
 	tmp =3D process_input(tag);
 	feed_table1(tbl, tmp, mode, width);
 	break;
+    case HTML_BUTTON:
+       tmp =3D process_button(tag);
+       feed_table1(tbl, tmp, mode, width);
+       break;
+    case HTML_N_BUTTON:
+       tmp =3D process_n_button();
+       feed_table1(tbl, tmp, mode, width);
+       break;
     case HTML_SELECT:
 	tmp =3D process_select(tag);
 	if (tmp)
diff -urp a/tagtable.tab b/tagtable.tab
--- a/tagtable.tab	2010-08-16 19:20:22.000000000 +0900
+++ b/tagtable.tab	2010-08-25 21:16:26.000000000 +0900
@@ -176,6 +176,7 @@ bdo		HTML_BDO
 big		HTML_BIG
 /big		HTML_N_BIG
 button		HTML_BUTTON
+/button		HTML_N_BUTTON
 fieldset	HTML_FIELDSET
 /fieldset	HTML_N_FIELDSET
 iframe		HTML_IFRAME