lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lynx-dev (patch) form reloading warning fixed


From: Leonid Pauzner
Subject: lynx-dev (patch) form reloading warning fixed
Date: Fri, 28 May 1999 00:18:52 +0400 (MSD)

* When reloading/reparsing the document with forms, issue a warning
  only when user input is detected (forms content changed from its default
  so an information will be lost). New function HText_HaveUserChangedForms()
  called from HTReparse_document() and HTuncache_current_document().


Long awaiting fix.  HText_HaveUserChangedForms() is safe because
non of lynx structures were changed - just calculate a boolean result.
This code is based on HText_ResetForm()



diff -u old/gridtext.c ./gridtext.c
--- old/gridtext.c      Tue May 25 00:17:16 1999
+++ ./gridtext.c        Thu May 27 23:44:04 1999
@@ -6145,6 +6145,13 @@
     if (HTMainText) {
        HTParentAnchor * htmain_anchor = HTMainText->node_anchor;

+       if (HText_HaveUserChangedForms()) {
+           /*
+            *  Issue a warning.  User forms content will be lost.
+            */
+           HTAlert(RELOADING_FORM);
+       }
+
        if (htmain_anchor) {
            if (!(HTOutputFormat && HTOutputFormat == WWW_SOURCE)) {
                FREE(htmain_anchor->UCStages);
@@ -6218,11 +6225,9 @@
        display_partial = display_partial_flag;  /* restore */
        Newline_partial = Newline;  /* initialize */
 #endif
-       if (lynx_mode == FORMS_LYNX_MODE) {
+       if (HText_HaveUserChangedForms()) {
            /*
-            *  Note that if there are no form links on the current
-            *  page, lynx_mode won't have this setting and we won't
-            *  know that this warning should be issued. - FM
+            *  Issue a warning.  Will not restore changed forms, currently.
             */
            HTAlert(RELOADING_FORM);
        }
@@ -6266,11 +6271,9 @@
        display_partial = display_partial_flag;  /* restore */
        Newline_partial = Newline;  /* initialize */
 #endif
-       if (lynx_mode == FORMS_LYNX_MODE) {
+       if (HText_HaveUserChangedForms()) {
            /*
-            *  Note that if there are no form links on the current
-            *  page, lynx_mode won't have this setting and we won't
-            *  know that this warning should be issued. - FM
+            *  Issue a warning.  Will not restore changed forms, currently.
             */
            HTAlert(RELOADING_FORM);
        }
@@ -8921,6 +8924,61 @@

        if (anchor_ptr == HTMainText->last_anchor)
            break;
+
+
+       anchor_ptr = anchor_ptr->next;
+    }
+}
+
+/*
+ * This function called before reloading/reparsing current document
+ * to get an information whether any forms content were changed by user
+ * so any information will be lost.
+ */
+PUBLIC BOOLEAN HText_HaveUserChangedForms NOARGS
+{
+    TextAnchor * anchor_ptr;
+
+    if (!HTMainText)
+       return FALSE;
+
+    /*
+     *  Go through list of anchors to check if any value was changed.
+     *  This code based on HText_ResetForm()
+     */
+    anchor_ptr = HTMainText->first_anchor;
+    while (anchor_ptr) {
+       if (anchor_ptr->link_type == INPUT_ANCHOR) {
+
+                if (anchor_ptr->input_field->type == F_RADIO_TYPE ||
+                    anchor_ptr->input_field->type == F_CHECKBOX_TYPE) {
+
+                   if ((anchor_ptr->input_field->orig_value[0] == '0' &&
+                          anchor_ptr->input_field->num_value == 1) ||
+                       (anchor_ptr->input_field->orig_value[0] != '0' &&
+                          anchor_ptr->input_field->num_value == 0))
+                       return TRUE;
+
+                } else if (anchor_ptr->input_field->type ==
+                           F_OPTION_LIST_TYPE) {
+                   if (strcmp(anchor_ptr->input_field->value,
+                               anchor_ptr->input_field->orig_value))
+                       return TRUE;
+
+                   if (strcmp(anchor_ptr->input_field->cp_submit_value,
+                               anchor_ptr->input_field->orig_submit_value))
+                       return TRUE;
+
+                } else {
+                   if (strcmp(anchor_ptr->input_field->value,
+                                       anchor_ptr->input_field->orig_value))
+                       return TRUE;
+                }
+
+       }
+
+       if (anchor_ptr == HTMainText->last_anchor)
+           return FALSE;


        anchor_ptr = anchor_ptr->next;
diff -u old/gridtext.h ./gridtext.h
--- old/gridtext.h      Tue May 25 00:17:16 1999
+++ ./gridtext.h        Thu May 27 21:32:58 1999
@@ -232,6 +232,7 @@
 extern void HText_DisableCurrentForm NOPARAMS;
 extern void HText_ResetForm PARAMS((FormInfo *form));
 extern void HText_activateRadioButton PARAMS((FormInfo *form));
+extern BOOLEAN HText_HaveUserChangedForms NOPARAMS;

 extern HTList * search_queries; /* Previous isindex and whereis queries */
 extern void HTSearchQueries_free NOPARAMS;
diff -u old/lymainlo.c ./lymainlo.c
--- old/lymainlo.c      Tue May 25 00:17:20 1999
+++ ./lymainlo.c        Thu May 27 23:51:02 1999
@@ -1945,14 +1945,6 @@
             *   this.  As the problems show up, we'll try to fix them,
             *   or add warnings.  - FM)
             */
-           if (lynx_mode == FORMS_LYNX_MODE) {
-               /*
-                *  Note that if there are no form links on the current
-                *  page, lynx_mode won't have this setting and we won't
-                *  know that this warning should be issued. - FM
-                */
-               HTAlert(RELOADING_FORM);
-           }
            newdoc.line = curdoc.line;
            newdoc.link = curdoc.link;
 #endif /* NO_ASSUME_SAME_DOC */
@@ -3920,14 +3912,6 @@
                        }
                    }
 #endif
-                   if (lynx_mode == FORMS_LYNX_MODE) {
-                       /*
-                        *  Note that if there are no form links on the current
-                        *  page, lynx_mode won't have this setting and we won't
-                        *  know that this warning should be issued. - FM
-                        */
-                       HTAlert(RELOADING_FORM);
-                   }
                    HEAD_request = HTLoadedDocumentIsHEAD();
                    HTuncache_current_document();
 #ifdef NO_ASSUME_SAME_DOC
diff -u old/lyoption.c ./lyoption.c
--- old/lyoption.c      Thu May 27 23:26:12 1999
+++ ./lyoption.c        Fri May 28 00:10:00 1999
@@ -3509,7 +3509,7 @@
  * manually (e.g., doing 'e'dit in 'o'ptions) and submit it to access the
  * restricted items.  Prevent spoofing attempts from index overrun. - LP
  *
- * Exit status: NULLFILE (reloading) or NORMAL (from HText cache).
+ * Exit status: NULLFILE (reload) or NORMAL (use HText cache).
  *
  * On exit, got the document which was current before the Options menu:
  *
@@ -3965,7 +3965,8 @@
     if (!HTLoadAbsolute(&WWWDoc))
        return(NOT_FOUND);

-    HTuncache_current_document(); /* will never use again */
+    /* comment out to avoid warning when removing forms content... */
+    /* HTuncache_current_document(); */ /* will never use again */

     /*
      *  Return to previous doc, not to options menu!
@@ -4038,14 +4039,6 @@
            else
                HTOutputFormat = WWW_SOURCE;
 #endif
-       }
-       if (lynx_mode == FORMS_LYNX_MODE) {
-           /* Sorry! lynx_mode set according the last display_page() state,
-            * it always in form mode since we came from form-based option menu
-            * so the information from mainloop() apperently lost.
-            * reset here until we learn how to do it properly.
-            */
-           lynx_mode = NORMAL_LYNX_MODE;
        }
 #ifdef SOURCE_CACHE
        if (reloading == FALSE) {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]