lynx-dev
[Top][All Lists]
Advanced

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

Re: lynx-dev Forms based options (patch)


From: Leonid Pauzner
Subject: Re: lynx-dev Forms based options (patch)
Date: Fri, 31 Jul 1998 14:56:53 +0400 (MSD)

I am _sure_. I made equivalent changes here.

>From LYCharSets.c:
/*
 *  Function to select a character set and then set the
 *  character handling and LYHaveCJKCharacterSet flag. - FM
 */
PUBLIC void HTMLUseCharacterSet ARGS1(int,i)
{
    p_entity_values = LYCharSets[i];
    HTMLSetCharacterHandling(i);
    HTMLSetHaveCJKCharacterSet(i);
    HTMLSetDisplayCharsetMatchLocale(i);
    return;
}

among those 4 only HTMLSetCharacterHandling() use RawMode info,
others just set some variables according to display_charset (=i),
which we obviously never change in assume_char_set field.

I do this changes because the settings in assume_char_set and RawMode cases
are equal in fact.

Also I found out that we may change the order in gen_options()
to place assume_char_set AFTER RawMode - it gives a reasonable result
untill we add a flag in postoptions().

HTML fixed in few lines.
I duplicate 'accept/reset changes' at the beginning.

New patch against dev18+(Mike Castle patch) follows:



--- old\lyoption.c      Thu Jul 30 16:00:54 1998
+++ lyoption.c  Fri Jul 31 14:44:50 1998
@@ -23,6 +23,9 @@
 #include <LYLeaks.h>

 #define FREE(x) if (x) {free(x); x = NULL;}
+BOOLEAN term_options;
+
+#ifndef NEW_OPTIONS

 #ifdef VMS
 #define DISPLAY "DECW$DISPLAY"
@@ -32,7 +35,6 @@

 #define COL_OPTION_VALUES 36  /* display column where option values start */

-BOOLEAN term_options;
 PRIVATE void terminate_options PARAMS((int sig));
 PRIVATE int boolean_choice PARAMS((
        int             status,
@@ -61,6 +63,8 @@
 #define L_User_Mode (use_assume_charset ? L_USER_MODE + 1 : L_USER_MODE)
 #define L_User_Agent (use_assume_charset ? L_USER_AGENT + 1 : L_USER_AGENT)

+#endif /* !NEW_OPTIONS */
+
 PRIVATE void option_statusline ARGS1(
        CONST char *,           text)
 {
@@ -108,6 +112,8 @@
     LYStatusLine = -1;
 }

+#ifndef NEW_OPTIONS
+
 PUBLIC void options NOARGS
 {
 #ifdef ALLOW_USERS_TO_CHANGE_EXEC_WITHIN_OPTIONS
@@ -841,7 +847,7 @@
                        }
                        LYRawMode = (UCLYhndl_for_unspec == current_char_set);
                        HTMLSetUseDefaultRawMode(current_char_set, LYRawMode);
-                       HTMLUseCharacterSet(current_char_set);
+                       HTMLSetCharacterHandling(current_char_set);
                        CurrentAssumeCharSet = UCLYhndl_for_unspec;
                        CurrentAssumeLocalCharSet = UCLYhndl_HTFile_for_unspec;
                        CurrentRawMode = LYRawMode;
@@ -3106,6 +3112,9 @@
     }
 }

+
+#else /* NEW_OPTIONS code begins here */
+
 /*
  * I'm paranoid about mistyping strings.  Also, this way they get combined
  * so we don't have to worry about the intelligence of the compiler.
@@ -3240,6 +3249,13 @@
  * Handle options from the pseudo-post.  I think we really only need
  * post_data here, but bring along everything just in case.  It's only a
  * pointer.  MRC
+ *
+ * By changing the certain options value (like preferred language or
+ * fake browser name) we need to inform the remote server and reload (uncache)
+ * the document which was active just before the Options menu was invoked.
+ * Another values (like display_char_set or assume_char_set) used by lynx
+ * initial rendering stages and can be changed only after reloading :-(
+ * So we introduce boolean flag 'need_reload' (currently dummy).
  */

 PUBLIC int postoptions ARGS1(
@@ -3248,6 +3264,7 @@
     struct post_pair *data;
     int i;
     BOOLEAN save_all = FALSE;
+    BOOLEAN need_reload = FALSE;

     data = break_data(newdoc->post_data);

@@ -3331,12 +3348,26 @@
        /*
         * prefered_doc_char
         */
-       if (!strcmp(data[i].tag, prefered_doc_lang_string)) {
+       if (!strcmp(data[i].tag, prefered_doc_char_string)) {
            FREE(pref_charset);
            StrAllocCopy(pref_charset, data[i].value);
        }

        /*
+        * raw_mode
+        */
+       if (!strcmp(data[i].tag, raw_mode_string)) {
+           BOOLEAN newmode;
+           newmode = (!strcmp(data[i].value, on_string));
+           if (newmode != LYRawMode) {
+               LYRawMode = newmode;
+               HTMLSetUseDefaultRawMode(current_char_set, LYRawMode);
+               HTMLSetCharacterHandling(current_char_set);
+               need_reload = TRUE;
+           }
+       }
+
+       /*
         * assume_char_set
         */
        if (!strcmp(data[i].tag, assume_char_set_string)) {
@@ -3360,16 +3391,14 @@
                StrAllocCopy(UCAssume_MIMEcharset, data[i].value);
                LYRawMode = (UCLYhndl_for_unspec == current_char_set);
                HTMLSetUseDefaultRawMode(current_char_set, LYRawMode);
-               HTMLUseCharacterSet(current_char_set);
+               HTMLSetCharacterHandling(current_char_set);
+               need_reload = TRUE;
            }
        }

        /*
         * display_char_set
         */
-       /*
-        * FIXME: This needs validation.  - MRC
-        */
        if (!strcmp(data[i].tag, display_char_set_string)) {
            int newval;

@@ -3383,6 +3412,7 @@
                HTMLSetRawModeDefault(current_char_set);
                LYUseDefaultRawMode = TRUE;
                HTMLUseCharacterSet(current_char_set);
+               need_reload = TRUE;
            }
        }

@@ -3403,19 +3433,6 @@
        }

        /*
-        * raw_mode
-        */
-       if (!strcmp(data[i].tag, raw_mode_string)) {
-           BOOLEAN newmode;
-           newmode = (!strcmp(data[i].value, on_string));
-           if (newmode != LYRawMode) {
-               LYRawMode = newmode;
-               HTMLSetUseDefaultRawMode(current_char_set, LYRawMode);
-               HTMLSetCharacterHandling(current_char_set);
-           }
-       }
-
-       /*
         * vi_keys
         */
        if (!strcmp(data[i].tag, vi_keys_string)) {
@@ -3535,7 +3552,11 @@
            HTAlert(OPTIONS_NOT_SAVED);
        }
     }
-    return(NULLFILE);
+    if (need_reload == TRUE)  {
+       /* currently dummy */
+       }
+
+       return(NULLFILE);
 }

 /*
@@ -3545,6 +3566,10 @@
  * Basic Strategy:  For each option, throw up the appropriate type of
  * control, giving defaults as appropriate.  If nothing else, we're
  * probably going to test every control there is.  MRC
+ *
+ * Each option from this form will be processed whether it was changed or not.
+ * The order may be important for some fields (like RawMode)
+ * unless we add a special flag in postoptions()
  */
 PUBLIC int gen_options ARGS1(
        char **,        newfile)
@@ -3567,10 +3592,10 @@
     StrAllocCopy(*newfile, print_filename);
     LYforce_no_cache = TRUE;

-    fprintf(fp0, "<head>\n<title>%s</title>\n</head>\n<body>\n",
+    fprintf(fp0, "<html><head>\n<title>%s</title>\n</head>\n<body>\n",
            OPTIONS_TITLE);

-    fprintf(fp0,"<h1>Options Menu (%s Version %s)</h1><pre>\n",
+    fprintf(fp0,"<h1>Options Menu (%s Version %s)</h1>\n",
            LYNX_NAME, LYNX_VERSION);

     /*
@@ -3588,6 +3613,18 @@
            secure_string, secure_value);

     /*
+     * visible preformated text begins here
+     */
+    fprintf(fp0,"<pre>\n\n");
+
+    /*
+     * save/reset
+     */
+    fprintf(fp0,"<input type=\"submit\" value=\"Accept Changes\">");
+    fprintf(fp0," <input type=\"reset\" value=\"Reset\">");
+    fprintf(fp0," Use the back key to cancel changes.\n\n");
+
+       /*
      * editor
      */
     fprintf(fp0,"<%s>Editor:</%s> ", label_string, label_string);
@@ -3663,6 +3700,33 @@
            (pref_charset && pref_charset[0])?pref_charset:empty_string);

     /*
+     * display_char_set
+     */
+    fprintf(fp0,"<%s>Display character set:</%s> ", label_string,
+           label_string);
+    fprintf(fp0,"<select name=\"%s\">\n", display_char_set_string);
+    for (i = 0; LYchar_set_names[i]; i++) {
+       fprintf(fp0,"<option %s value=\"%d\">%s</options>\n",
+               (i==current_char_set)?selected_string:empty_string,
+               i, LYchar_set_names[i]);
+    }
+    fprintf(fp0,"</select>\n");
+
+    /*
+     * raw_mode
+     */
+    fprintf(fp0,"<%s>Raw 8-bit or CJK mode:</%s> ", label_string,
+           label_string);
+    fprintf(fp0,"<select name=\"%s\">\n", raw_mode_string);
+    fprintf(fp0,"<option %s value=\"%s\">%s</option>\n",
+           (LYRawMode)?empty_string:selected_string,
+           off_string, off_string);
+    fprintf(fp0,"<option %s value=\"%s\">%s</option>\n",
+           (LYRawMode)?selected_string:empty_string,
+           on_string, on_string);
+    fprintf(fp0,"</select>\n");
+
+    /*
      * assume_char_set
      */
     /*
@@ -3692,33 +3756,6 @@
     }

     /*
-     * display_char_set
-     */
-    fprintf(fp0,"<%s>Display character set:</%s> ", label_string,
-           label_string);
-    fprintf(fp0,"<select name=\"%s\">\n", display_char_set_string);
-    for (i = 0; LYchar_set_names[i]; i++) {
-       fprintf(fp0,"<option %s value=\"%d\">%s</options>\n",
-               (i==current_char_set)?selected_string:empty_string,
-               i, LYchar_set_names[i]);
-    }
-    fprintf(fp0,"</select>\n");
-
-    /*
-     * raw_mode
-     */
-    fprintf(fp0,"<%s>Raw 8-bit or CJK mode:</%s> ", label_string,
-           label_string);
-    fprintf(fp0,"<select name=\"%s\">\n", raw_mode_string);
-    fprintf(fp0,"<option %s value=\"%s\">%s</option>\n",
-           (LYRawMode)?empty_string:selected_string,
-           off_string, off_string);
-    fprintf(fp0,"<option %s value=\"%s\">%s</option>\n",
-           (LYRawMode)?selected_string:empty_string,
-           on_string, on_string);
-    fprintf(fp0,"</select>\n");
-
-    /*
      * show_color
      */
 #if defined(USE_SLANG) || defined(COLOR_CURSES)
@@ -3911,12 +3948,19 @@
     /*
      * save/reset
      */
-    fprintf(fp0,"<p>Use the back key to cancel changes.\n");
+    fprintf(fp0,"\n");
     fprintf(fp0,"<input type=\"submit\" value=\"Accept Changes\">");
-    fprintf(fp0," <input type=\"reset\" value=\"Reset\">\n");
-    fprintf(fp0,"</p>");
+    fprintf(fp0," <input type=\"reset\" value=\"Reset\">");
+    fprintf(fp0," Use the back key to cancel changes.\n");
+
+    /*
+     * close HTML
+     */
+    fprintf(fp0,"</pre>\n");
     fprintf(fp0,"</body>\n");
+    fprintf(fp0,"</html>\n");

     fclose(fp0);
     return(0);
 }
+#endif /* NEW_OPTIONS */


reply via email to

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