[w3m-dev 03413] Re: setting form on loading
* form.c (loadPreForm): add textarea (preFormUpdateBuffer): submit if value is matched as well case FORM_TEXTAREA case FORM_SELECT ifdef MENU_SELECT From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
This commit is contained in:
		
							
								
								
									
										10
									
								
								ChangeLog
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								ChangeLog
									
									
									
									
									
								
							@@ -1,3 +1,11 @@
 | 
				
			|||||||
 | 
					2002-11-12  Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						* [w3m-dev 03413] Re: setting form on loading
 | 
				
			||||||
 | 
						* form.c (loadPreForm): add textarea
 | 
				
			||||||
 | 
							(preFormUpdateBuffer): submit if value is matched as well
 | 
				
			||||||
 | 
									case FORM_TEXTAREA
 | 
				
			||||||
 | 
									case FORM_SELECT ifdef MENU_SELECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
2002-11-12  Yuji Abe <cbo46560@pop12.odn.ne.jp>
 | 
					2002-11-12  Yuji Abe <cbo46560@pop12.odn.ne.jp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	* [w3m-dev 03411] do AUXBIN_TARGETS
 | 
						* [w3m-dev 03411] do AUXBIN_TARGETS
 | 
				
			||||||
@@ -4547,4 +4555,4 @@ a	* [w3m-dev 03276] compile error on EWS4800
 | 
				
			|||||||
	* release-0-2-1
 | 
						* release-0-2-1
 | 
				
			||||||
	* import w3m-0.2.1
 | 
						* import w3m-0.2.1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$Id: ChangeLog,v 1.499 2002/11/12 12:18:29 ukai Exp $
 | 
					$Id: ChangeLog,v 1.500 2002/11/12 12:22:59 ukai Exp $
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										57
									
								
								form.c
									
									
									
									
									
								
							
							
						
						
									
										57
									
								
								form.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: form.c,v 1.19 2002/11/08 16:07:06 ukai Exp $ */
 | 
					/* $Id: form.c,v 1.20 2002/11/12 12:22:59 ukai Exp $ */
 | 
				
			||||||
/* 
 | 
					/* 
 | 
				
			||||||
 * HTML forms
 | 
					 * HTML forms
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@@ -725,28 +725,38 @@ add_pre_form_item(struct pre_form *pf, struct pre_form_item *prev, int type,
 | 
				
			|||||||
 * passwd <name> <value>
 | 
					 * passwd <name> <value>
 | 
				
			||||||
 * checkbox <name> <value> [<checked>]
 | 
					 * checkbox <name> <value> [<checked>]
 | 
				
			||||||
 * radio <name> <value>
 | 
					 * radio <name> <value>
 | 
				
			||||||
 * submit [<name>]
 | 
					 * select <name> <value>
 | 
				
			||||||
 | 
					 * submit [<name> [<value>]]
 | 
				
			||||||
 | 
					 * textarea <name>
 | 
				
			||||||
 | 
					 * <value>
 | 
				
			||||||
 | 
					 * /textarea
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
loadPreForm(void)
 | 
					loadPreForm(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    FILE *fp;
 | 
					    FILE *fp;
 | 
				
			||||||
    Str line = NULL;
 | 
					    Str line = NULL, textarea = NULL;
 | 
				
			||||||
    struct pre_form *pf = NULL;
 | 
					    struct pre_form *pf = NULL;
 | 
				
			||||||
    struct pre_form_item *pi = NULL;
 | 
					    struct pre_form_item *pi = NULL;
 | 
				
			||||||
 | 
					    int type = -1;
 | 
				
			||||||
 | 
					    char *name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    PreForm = NULL;
 | 
					    PreForm = NULL;
 | 
				
			||||||
    fp = openSecretFile(pre_form_file);
 | 
					    fp = openSecretFile(pre_form_file);
 | 
				
			||||||
    if (fp == NULL)
 | 
					    if (fp == NULL)
 | 
				
			||||||
	return;
 | 
						return;
 | 
				
			||||||
    while (1) {
 | 
					    while (1) {
 | 
				
			||||||
	int type = 0;
 | 
					 | 
				
			||||||
	char *p, *s, *arg;
 | 
						char *p, *s, *arg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	line = Strfgets(fp);
 | 
						line = Strfgets(fp);
 | 
				
			||||||
	if (line->length == 0)
 | 
						if (line->length == 0)
 | 
				
			||||||
	    break;
 | 
						    break;
 | 
				
			||||||
 | 
						if (textarea && !(!strncmp(line->ptr, "/textarea", 9) &&
 | 
				
			||||||
 | 
						    IS_SPACE(line->ptr[9]))) {
 | 
				
			||||||
 | 
						    Strcat(textarea, line);
 | 
				
			||||||
 | 
						    continue;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	Strchop(line);
 | 
						Strchop(line);
 | 
				
			||||||
	Strremovefirstspaces(line);
 | 
						Strremovefirstspaces(line);
 | 
				
			||||||
	p = line->ptr;
 | 
						p = line->ptr;
 | 
				
			||||||
@@ -777,6 +787,19 @@ loadPreForm(void)
 | 
				
			|||||||
	    type = FORM_INPUT_RADIO;
 | 
						    type = FORM_INPUT_RADIO;
 | 
				
			||||||
	else if (!strcmp(s, "submit"))
 | 
						else if (!strcmp(s, "submit"))
 | 
				
			||||||
	    type = FORM_INPUT_SUBMIT;
 | 
						    type = FORM_INPUT_SUBMIT;
 | 
				
			||||||
 | 
						else if (!strcmp(s, "select"))
 | 
				
			||||||
 | 
						    type = FORM_SELECT;
 | 
				
			||||||
 | 
						else if (!strcmp(s, "textarea")) {
 | 
				
			||||||
 | 
						    type = FORM_TEXTAREA;
 | 
				
			||||||
 | 
						    name = Strnew_charp(arg)->ptr;
 | 
				
			||||||
 | 
						    textarea = Strnew();
 | 
				
			||||||
 | 
						    continue;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (!strcmp(s, "/textarea")) {
 | 
				
			||||||
 | 
						    pi = add_pre_form_item(pf, pi, type, name, textarea->ptr, NULL);
 | 
				
			||||||
 | 
						    textarea = NULL;
 | 
				
			||||||
 | 
						    continue;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
	    continue;
 | 
						    continue;
 | 
				
			||||||
	s = getQWord(&p);
 | 
						s = getQWord(&p);
 | 
				
			||||||
@@ -790,10 +813,11 @@ preFormUpdateBuffer(Buffer *buf)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    struct pre_form *pf;
 | 
					    struct pre_form *pf;
 | 
				
			||||||
    struct pre_form_item *pi;
 | 
					    struct pre_form_item *pi;
 | 
				
			||||||
    int i;
 | 
					    int i, j;
 | 
				
			||||||
    Anchor *a;
 | 
					    Anchor *a;
 | 
				
			||||||
    FormList *fl;
 | 
					    FormList *fl;
 | 
				
			||||||
    FormItemList *fi;
 | 
					    FormItemList *fi;
 | 
				
			||||||
 | 
					    FormSelectOptionItem *opt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!buf || !buf->formitem || !PreForm)
 | 
					    if (!buf || !buf->formitem || !PreForm)
 | 
				
			||||||
	return;
 | 
						return;
 | 
				
			||||||
@@ -812,8 +836,10 @@ preFormUpdateBuffer(Buffer *buf)
 | 
				
			|||||||
		if (pi->type != fi->type)
 | 
							if (pi->type != fi->type)
 | 
				
			||||||
		    continue;
 | 
							    continue;
 | 
				
			||||||
		if (pi->type == FORM_INPUT_SUBMIT) {
 | 
							if (pi->type == FORM_INPUT_SUBMIT) {
 | 
				
			||||||
		    if (!pi->name || !*pi->name ||
 | 
							    if ((!pi->name || !*pi->name ||
 | 
				
			||||||
			(fi->name && !Strcmp_charp(fi->name, pi->name)))
 | 
								 (fi->name && !Strcmp_charp(fi->name, pi->name))) &&
 | 
				
			||||||
 | 
								(!pi->value || !*pi->value ||
 | 
				
			||||||
 | 
								 (fi->value && !Strcmp_charp(fi->value, pi->value))))
 | 
				
			||||||
			buf->submit = a;
 | 
								buf->submit = a;
 | 
				
			||||||
		    continue;
 | 
							    continue;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -823,6 +849,7 @@ preFormUpdateBuffer(Buffer *buf)
 | 
				
			|||||||
		case FORM_INPUT_TEXT:
 | 
							case FORM_INPUT_TEXT:
 | 
				
			||||||
		case FORM_INPUT_FILE:
 | 
							case FORM_INPUT_FILE:
 | 
				
			||||||
		case FORM_INPUT_PASSWORD:
 | 
							case FORM_INPUT_PASSWORD:
 | 
				
			||||||
 | 
							case FORM_TEXTAREA:
 | 
				
			||||||
		    fi->value = Strnew_charp(pi->value);
 | 
							    fi->value = Strnew_charp(pi->value);
 | 
				
			||||||
		    formUpdateBuffer(a, buf, fi);
 | 
							    formUpdateBuffer(a, buf, fi);
 | 
				
			||||||
		    break;
 | 
							    break;
 | 
				
			||||||
@@ -838,6 +865,22 @@ preFormUpdateBuffer(Buffer *buf)
 | 
				
			|||||||
			!Strcmp_charp(fi->value, pi->value))
 | 
								!Strcmp_charp(fi->value, pi->value))
 | 
				
			||||||
			formRecheckRadio(a, buf, fi);
 | 
								formRecheckRadio(a, buf, fi);
 | 
				
			||||||
		    break;
 | 
							    break;
 | 
				
			||||||
 | 
					#ifdef MENU_SELECT
 | 
				
			||||||
 | 
							case FORM_SELECT:
 | 
				
			||||||
 | 
							    for (j = 0, opt = fi->select_option; opt != NULL;
 | 
				
			||||||
 | 
								 j++, opt = opt->next) {
 | 
				
			||||||
 | 
								if (pi->value && opt->value &&
 | 
				
			||||||
 | 
								    !Strcmp_charp(opt->value, pi->value)) {
 | 
				
			||||||
 | 
								    fi->selected = j;
 | 
				
			||||||
 | 
								    fi->value = opt->value;
 | 
				
			||||||
 | 
								    fi->label = opt->label;
 | 
				
			||||||
 | 
								    updateSelectOption(fi, fi->select_option);
 | 
				
			||||||
 | 
								    formUpdateBuffer(a, buf, fi);
 | 
				
			||||||
 | 
								    break;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							    }
 | 
				
			||||||
 | 
							    break;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	    }
 | 
						    }
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user