lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev dev22 - SOURCE_CACHE!=NONE and partial display mode


From: Leonid Pauzner
Subject: lynx-dev dev22 - SOURCE_CACHE!=NONE and partial display mode
Date: Thu, 15 Apr 1999 16:03:59 +0400 (MSD)

14-Apr-99 13:38 Scott Bigham wrote:
> On Wed, 14 Apr 1999, Leonid Pauzner wrote:

>> Thanks for you fix!  More problems found with SOURCE_CACHE!=NONE:
>> the length of the re-rendered text may vary so the scrolling down
>> is broken (especially nice when switching to source).
>> This patch will fix it ("more" updated, "lines_in_file" inlined),

> Eek!  Surely this can be localized somewhat.  Try the following patch
> instead, applied on top of my previous dev22 patch:

This letter mostly to Scott Bigham since work in progress.

I have fixed diplay partial mode for source cache operations,
unfortunately, when the document reloaded from cache
the screen than became blank or corrupted due to a highlighted link.
Probably a problem in mainloop() somethere near the point you mentioned abouve.
(Try the reloading of lynx users guide to source mode and wait until
the reloading finished without any key scrolling operations).

So I sent my current resync against clean dev22 (only files GridText.c,
LYMainLoop.c, HTFormat.[ch], LYglobalDefs.h and LYMain.c are affected):


* Fix reload_read_cfg() to avoid persistent cookies mode changing at run time - 
LP
* Fixes for SOURCE_CACHE!=NONE mode, trying to accomodate HTreparse_document()
  for mainloop() events:
  - fix switching to/from source mode when -prettysrc is in effect - VH & dsb.
  - fix case LYK_SOURCE - dsb
  - fix links numbering update - dsb
  - fix document length update - LP
  - add partial display mode for HTreparse_document() operations - LP

(yes, I know this fix looks ugly, display partial staff should went
from mainloop() to HT*Copy(), will be done later
but how about corrupted screen?)



diff -u ./gridtext.c ../gridtext.c
--- ./gridtext.c        Tue Apr 13 03:39:16 1999
+++ ../gridtext.c       Thu Apr 15 13:50:32 1999
@@ -561,7 +561,7 @@
     self->LastChar = '\0';
     self->IgnoreExcess = FALSE;

-#ifndef PSRC_TEST
+#ifndef USE_PSRC
     if (HTOutputFormat == WWW_SOURCE)
        self->source = YES;
     else
@@ -6186,14 +6186,15 @@

        /*
         * This is more or less copied out of HTLoadFile(), except we don't
-        * get a content encoding.  This may be overkill...
+        * get a content encoding.  This may be overkill.  -dsb
         */
        if (HTMainText->node_anchor->content_type) {
            format = HTAtom_for(HTMainText->node_anchor->content_type);
        } else {
            format = HTFileFormat(HTMainText->source_cache_file, NULL, NULL);
            format = HTCharsetFormat(format, HTMainText->node_anchor,
-                                    UCLYhndl_HTFile_for_unspec);
+                                    UCLYhndl_for_unspec);
+               /* not UCLYhndl_HTFile_for_unspec - we are talking about remote 
documents... */
        }
        CTRACE(tfp, "  Content type is \"%s\"\n", format->name);

@@ -6210,12 +6211,34 @@
            FREE(source_cache_filename);
            return FALSE;
        }
+#ifdef DISP_PARTIAL
+               display_partial = display_partial_flag; /* restore */
+               Newline_partial = Newline; /* initialize */
+               NumOfLines_partial = -1;       /* initialize to -1 */
+#endif /* DISP_PARTIAL */
        ret = HTParseFile(format, HTOutputFormat, HTMainText->node_anchor,
                          fp, NULL);
        fclose(fp);
+#ifdef DISP_PARTIAL
+                   if (display_partial) {
+                       /*
+                        *  Override Newline with a new value if user
+                        *  scrolled the document while downloading.
+                        */
+                       if (Newline_partial != Newline
+                        && NumOfLines_partial > 0)
+                           Newline = Newline_partial;
+
+                       /*
+                        *  End of incremental rendering stage here.
+                        */
+                       display_partial = FALSE;
+                   }
+#endif /* DISP_PARTIAL */
        ok = (ret == HT_LOADED);
-       if (!ok)
+       if (!ok) {
            FREE(source_cache_filename);
+       }
     }

     if (LYCacheSource == SOURCE_CACHE_MEMORY &&
@@ -6233,8 +6256,29 @@
        source_cache_chunk = HTMainText->source_cache_chunk;
        HTMainText->source_cache_chunk = NULL;

+#ifdef DISP_PARTIAL
+               display_partial = display_partial_flag; /* restore */
+               Newline_partial = Newline; /* initialize */
+               NumOfLines_partial = -1;       /* initialize to -1 */
+#endif /* DISP_PARTIAL */
        ret = HTParseMem(format, HTOutputFormat, HTMainText->node_anchor,
                         source_cache_chunk, NULL);
+#ifdef DISP_PARTIAL
+                   if (display_partial) {
+                       /*
+                        *  Override Newline with a new value if user
+                        *  scrolled the document while downloading.
+                        */
+                       if (Newline_partial != Newline
+                        && NumOfLines_partial > 0)
+                           Newline = Newline_partial;
+
+                       /*
+                        *  End of incremental rendering stage here.
+                        */
+                       display_partial = FALSE;
+                   }
+#endif /* DISP_PARTIAL */
        ok = (ret == HT_LOADED);
        if (!ok) {
            HTChunkFree(source_cache_chunk);
@@ -6242,7 +6286,17 @@
        }
     }

+    /*
+     * I have no idea what this does, but it seems to be necessary... -dsb
+     */
+    LYUCPopAssumed();
+
     CTRACE(tfp, "Reparse %s\n", (ok ? "succeeded" : "failed"));
+
+    if (ok)  {/* fix few flags: */
+       more = HText_canScrollDown();  /* the length may be changed */
+    }
+
     return ok;
 }

diff -u ./htformat.c ../htformat.c
--- ./htformat.c        Tue Apr 13 03:39:16 1999
+++ ../htformat.c       Thu Apr 15 13:21:22 1999
@@ -783,6 +783,7 @@
 **
 **  Return values:
 **     HT_LOADED       All data sent.
+**     HT_INTERRUPTED  Interruption after some data read.
 **
 **  State of memory and target stream on return:
 **     always          chunk unchanged, target stream still valid.
@@ -794,6 +795,7 @@
     HTStreamClass targetClass = *(sink->isa);
     int bytes = 0;
     CONST char *data = chunk->data;
+    int rv = HT_OK;

     HTReadProgress(0, 0);
     for (;;) {
@@ -810,8 +812,18 @@
        data += n;
        HTReadProgress(bytes, 0);
        HTDisplayPartial();
+
+       if (HTCheckForInterrupt()) {
+           _HTProgress (TRANSFER_INTERRUPTED);
+           if (bytes) {
+               rv = HT_INTERRUPTED;
+           } else {
+               rv = -1;
+           }
+           break;
+       }
     }
-    return HT_LOADED;
+    return rv;
 }
 #endif

diff -u ./htformat.h ../htformat.h
--- ./htformat.h        Tue Apr 13 03:39:16 1999
+++ ../htformat.h       Thu Apr 15 12:08:32 1999
@@ -325,10 +325,10 @@
 #include <HTChunk.h>
 /*

-HTFileCopy:  Copy a file to a stream
+HTMemCopy:  Copy a memory chunk to a stream

    This is used by the protocol engines to send data down a stream, typically 
one which
-   has been generated by HTStreamStack.  It is currently called by HTParseFile
+   has been generated by HTStreamStack.  It is currently called by HTParseMem

  */
 extern int HTMemCopy PARAMS((
diff -u ./lyglobal.h ../lyglobal.h
--- ./lyglobal.h        Tue Apr 13 03:39:16 1999
+++ ../lyglobal.h       Thu Apr 15 12:51:30 1999
@@ -271,6 +271,8 @@
 extern int NumOfLines_partial;       /* -//- "current" number of lines */
 extern int partial_threshold;
 extern BOOLEAN debug_display_partial;  /* show with MessageSecs delay */
+extern BOOLEAN display_partial_flag; /* permanent flag, not mutable */
+extern int Newline; /* original newline position, from mainloop() */
 #endif
 extern char *form_post_data;         /* User data for post form */
 extern char *form_get_data;          /* User data for get form */
diff -u ./lymainlo.c ../lymainlo.c
--- ./lymainlo.c        Tue Apr 13 03:39:16 1999
+++ ../lymainlo.c       Thu Apr 15 13:26:56 1999
@@ -86,6 +86,10 @@
 #ifdef DISP_PARTIAL
 PUBLIC int Newline_partial = 0;     /* required for display_partial mode */
 PUBLIC int NumOfLines_partial = -1; /* required for display_partial mode */
+PUBLIC BOOLEAN display_partial_flag = FALSE;
+PUBLIC int Newline = 0;
+#else
+PRIVATE int Newline = 0;
 #endif

 PRIVATE document newdoc;
@@ -234,8 +238,6 @@
     int cmd = LYK_DO_NOTHING, real_cmd = LYK_DO_NOTHING;
     int getresult;
     int arrowup = FALSE, show_help = FALSE;
-    int lines_in_file = -1;
-    int Newline = 0;
     char prev_target[512];
     char user_input_buffer[1024];
     char *owner_address = NULL;  /* Holds the responsible owner's address     
*/
@@ -250,7 +252,7 @@
     BOOLEAN rlink_allowed;
     BOOLEAN vi_keys_flag = vi_keys;
     BOOLEAN emacs_keys_flag = emacs_keys;
-    BOOLEAN LYRawMode_flag = LYRawMode;
+    BOOLEAN LYUseDefaultRawMode_flag = LYUseDefaultRawMode;
 #ifndef NO_OPTION_MENU
     BOOLEAN LYSelectPopups_flag = LYSelectPopups;
     BOOLEAN verbose_img_flag = verbose_img;
@@ -263,9 +265,6 @@
 #endif
     BOOLEAN trace_mode_flag = FALSE;
     BOOLEAN forced_HTML_mode = LYforce_HTML_mode;
-#ifdef DISP_PARTIAL
-    BOOLEAN display_partial_flag = display_partial;
-#endif
     char cfile[128];
     FILE *cfp;
     char *cp, *toolbar;
@@ -312,6 +311,9 @@
     user_input_buffer[(sizeof(user_input_buffer) - 1)] = '\0';
     *prev_target = '\0';
     *user_input_buffer = '\0';
+#ifdef DISP_PARTIAL
+    display_partial_flag = display_partial; /* permanent flag, not mutable */
+#endif
     StrAllocCopy(CurrentUserAgent, (LYUserAgent ?
                                    LYUserAgent : ""));
     StrAllocCopy(CurrentNegoLanguage, (language ?
@@ -561,8 +563,7 @@
                     * completed, but only if s/he did not mess screen up by
                     * scrolling before...  So fall down to old behavior here.
                     */
-                   if (!LYCursesON ||
-                              (Newline_partial == 1 && strchr(newdoc.address, 
'#')))
+                   if (Newline_partial == 1 && strchr(newdoc.address, '#'))
                        display_partial = FALSE;
                }
 #endif /* DISP_PARTIAL */
@@ -1260,7 +1261,7 @@
 #ifdef SOURCE_CACHE
        /*
         * If the parse settings have changed since this HText was
-        * generated, we need to reparse and redraw it.
+        * generated, we need to reparse and redraw it.  -dsb
         */
        if (HTdocument_settings_changed()) {
            HTUserMsg(gettext("Reparsing document under current settings..."));
@@ -1269,7 +1270,7 @@
            else {
                /*
                 * Urk.  I have no idea how to recover from a failure here.
-                * At a guess, I'll try reloading.
+                * At a guess, I'll try reloading.  -dsb
                 */
                cmd = LYK_RELOAD;
                goto new_cmd;
@@ -1298,7 +1299,6 @@
             */
            more = HText_canScrollDown();
            curdoc.line = Newline = HText_getTopOfScreen()+1;
-           lines_in_file = HText_getNumOfLines();

            if (curdoc.title == NULL) {
                /*
@@ -1358,6 +1358,15 @@
            if (lynx_edit_mode && nlinks > 0 && !HTList_isEmpty(tagged))
                showtags(tagged);
 #endif /* DIRED_SUPPORT */
+#ifdef SOURCE_CACHE
+           /*
+            * This information can get clobbered if we go to an internal
+            * page while viewing source.  Normally it would be recreated
+            * by reloading the file; we have to do it ourselves.  -dsb
+            */
+           if (curdoc.link < 0 && nlinks > 0)
+               curdoc.link = 0;
+#endif
            if (user_mode == NOVICE_MODE)
                noviceline(more);  /* print help message */
            refresh_screen = FALSE;
@@ -1671,7 +1680,6 @@
                                      links[curdoc.link+1].form->name) != 
0)))))) {

                        HText_ExpandTextarea (&links[curdoc.link], 1);
-                       lines_in_file = HText_getNumOfLines();

                        if (links[curdoc.link].ly < display_lines) {
                            refresh_screen = TRUE;
@@ -2110,6 +2118,25 @@
 #ifdef SOURCE_CACHE
            if (HTreparse_document()) {
                refresh_screen = TRUE;
+               /*
+                * These normally get cleaned up after getfile() returns;
+                * since we're not calling getfile(), we have to clean them
+                * up ourselves.  -dsb
+                */
+               HTOutputFormat = WWW_PRESENT;
+#ifdef USE_PSRC
+               if (psrc_view)
+                   HTMark_asSource();
+               psrc_view = FALSE;
+#endif
+           /*
+            *  Set the remaining document elements.
+            */
+           if (ownerS_address != NULL) {
+               if (!HText_getOwner())
+                   HText_setMainTextOwner(ownerS_address);
+               FREE(ownerS_address);
+           }
                break;
            }
 #endif
@@ -2512,7 +2539,7 @@

        case LYK_END:
            if (more) {
-              Newline = lines_in_file - display_lines + 3;  /* go to end of 
file */
+              Newline = HText_getNumOfLines() - display_lines + 3;  /* go to 
end of file */
               arrowup = TRUE;   /* position on last link */
            } else {
                cmd = LYK_NEXT_PAGE;
@@ -4037,7 +4064,7 @@
                CurrentCharSet_flag != current_char_set ||
                CurrentAssumeCharSet_flag != UCLYhndl_for_unspec ||
                verbose_img_flag != verbose_img ||
-               LYRawMode_flag != LYRawMode ||
+               LYUseDefaultRawMode_flag != LYUseDefaultRawMode ||
                LYSelectPopups_flag != LYSelectPopups ||
                ((strcmp(CurrentUserAgent, (LYUserAgent ?
                                            LYUserAgent : "")) ||
@@ -4113,7 +4140,7 @@
            CurrentAssumeCharSet_flag = UCLYhndl_for_unspec;
            show_dotfiles_flag = show_dotfiles;
            verbose_img_flag = verbose_img;
-           LYRawMode_flag = LYRawMode;
+           LYUseDefaultRawMode_flag = LYUseDefaultRawMode;
            LYSelectPopups_flag = LYSelectPopups;
            StrAllocCopy(CurrentUserAgent, (LYUserAgent ?
                                            LYUserAgent : ""));
@@ -4656,7 +4683,7 @@
             */
            if (strcmp((curdoc.title ? curdoc.title : ""),
                       SHOWINFO_TITLE)) {
-               if (showinfo(&curdoc, lines_in_file,
+               if (showinfo(&curdoc, HText_getNumOfLines(),
                              &newdoc, owner_address) < 0)
                    break;
                StrAllocCopy(newdoc.title, SHOWINFO_TITLE);
@@ -4698,8 +4725,6 @@

                n = HText_ExtEditForm (&links[curdoc.link]);

-               lines_in_file = HText_getNumOfLines();
-
                /*
                 *  TODO: Move cursor "n" lines from the current line to
                 *        position it on the 1st trailing blank line in
@@ -4731,7 +4756,6 @@

                HText_ExpandTextarea (&links[curdoc.link], 
TEXTAREA_EXPAND_SIZE);

-               lines_in_file  = HText_getNumOfLines();
                refresh_screen = TRUE;

            } else {
@@ -4749,8 +4773,6 @@

                n = HText_InsertFile (&links[curdoc.link]);

-               lines_in_file = HText_getNumOfLines();
-
                /*
                 *  TODO: Move cursor "n" lines from the current line to
                 *        position it on the 1st line following the text
@@ -4788,7 +4810,7 @@
                       PRINT_OPTIONS_TITLE)) {

                if (print_options(&newdoc.address,
-                               &curdoc.address, lines_in_file) < 0)
+                               &curdoc.address, HText_getNumOfLines()) < 0)
                    break;
                StrAllocCopy(newdoc.title, PRINT_OPTIONS_TITLE);
                FREE(newdoc.post_data);
@@ -5626,7 +5648,7 @@
                LYUseDefaultRawMode = !LYUseDefaultRawMode;
                HTUserMsg(LYRawMode ? RAWMODE_OFF : RAWMODE_ON);
                HTMLSetCharacterHandling(current_char_set);
-               LYRawMode_flag = LYRawMode;
+               LYUseDefaultRawMode_flag = LYUseDefaultRawMode;
 #ifdef SOURCE_CACHE
                if (HTreparse_document()) {
                    refresh_screen = TRUE;

diff -u ./lymain.c ../lymain.c
--- ./lymain.c  Tue Apr 13 03:39:16 1999
+++ ../lymain.c Wed Apr 14 19:37:42 1999
@@ -1257,6 +1257,14 @@
     StrAllocCopy(UCAssume_MIMEcharset,
                        LYCharSet_UC[UCLYhndl_for_unspec].MIMEname);

+    /*
+     * Make sure we have the edit map declared. - FM
+     */
+    if (!LYEditmapDeclared()) {
+       fprintf(stderr, gettext("\nLynx edit map not declared.\n\n"));
+       exit(-1);
+    }
+
 #if defined(USE_HASH)
     /*
      * If no alternate lynx-style file was specified on
@@ -1304,15 +1312,7 @@
        fclose(fp);
        style_readFromFile(lynx_lss_file);
     }
-#endif
-
-    /*
-     * Make sure we have the edit map declared. - FM
-     */
-    if (!LYEditmapDeclared()) {
-       fprintf(stderr, gettext("\nLynx edit map not declared.\n\n"));
-       exit(-1);
-    }
+#endif /* USE_HASH */

 #if USE_COLOR_TABLE
     /*
@@ -1584,6 +1584,13 @@
     if (dump_output_immediately)
        LYCacheSource = SOURCE_CACHE_NONE;
 #endif
+#ifdef DISP_PARTIAL
+    /*
+     * Disable partial mode if not interactive.
+     */
+    if (dump_output_immediately)
+       display_partial = FALSE;
+#endif

 #ifdef VMS
     set_vms_keys();
@@ -1782,7 +1789,8 @@
         *  mode.  Instead of calling cleanup() here, let's only call
         *  this one. - BJP
         */
-       LYStoreCookies(LYCookieFile);
+       if (persistent_cookies)
+           LYStoreCookies(LYCookieFile);
 #endif /* EXP_PERSISTENT_COOKIES */
        exit_immediately(status);
     } else {
@@ -1832,6 +1840,7 @@
     HTRegisterProtocol(&LYLynxCookies);
 }

+#ifndef NO_CONFIG_INFO
 /*
  *  Some staff to reload lynx.cfg without restarting new lynx session,
  *  also load options menu items and command-line options
@@ -1842,10 +1851,17 @@
  */
 PUBLIC void reload_read_cfg NOARGS
 {
-    if (!LYRestricted) {
+    if (LYRestricted) return;  /* for sure */
+
+    /* save .lynxrc file in case we change something from Options Menu */
+    if (!save_rc()) return;    /* can not write the very own file :( */

-       /* save .lynxrc file in case we change something from Options Menu */
-       if (!save_rc()) return;
+    {
+       /* set few safe flags: */
+#ifdef PERSISTENT_COOKIES
+       BOOLEAN persistent_cookies_flag = persistent_cookies;
+       char * LYCookieFile_flag = LYCookieFile;
+#endif

        /*
         *  Process the configuration file.
@@ -1862,13 +1878,13 @@
        /* but other things may be lost: */

        /*
-        *  Process any command line arguments not already handled. - FM
+        *  Process any command line arguments not already handled.
         */
                /* Not implemented yet here */

        /*
         *  Process any stdin-derived arguments for a lone "-"  which we've
-        *  loaded into LYStdinArgs. - FM
+        *  loaded into LYStdinArgs.
         */
                /* Not implemented yet here */

@@ -1877,11 +1893,23 @@
         */
                /* Not implemented yet here,
                 * a major problem: file paths
-                * like lynx_temp_space, LYCookieFile etc.
+                * like lynx_save_space, LYCookieFile etc.
                 */
+#ifdef PERSISTENT_COOKIES
+       /* restore old settings */
+        if (persistent_cookies != persistent_cookies_flag) {
+            persistent_cookies = persistent_cookies_flag;
+            HTAlert(gettext("persistent cookies state will be changed in next 
session only."));
+        }
+        if (strcmp(LYCookieFile, LYCookieFile_flag)) {
+            StrAllocCopy(LYCookieFile, LYCookieFile_flag);
+            CTRACE(tfp, "cookies file can be changed in next session only, 
restored.\n")
+        }
+#endif

     }
 }
+#endif /* !NO_CONFIG_INFO */


 /* There are different ways of setting arguments on the command line, and
@@ -1913,13 +1941,13 @@
 #ifdef  PARSE_DEBUG
 #define ParseData BOOLEAN *set_value; int *int_value; char **str_value; 
ParseFunc fun_value
 #define PARSE_SET(n,t,v,h) {n,t,    v,  0,  0,  0,    h}
-#define PARSE_INT(n,t,v,h) {n,t,    0, &v,  0,  0,    h}
+#define PARSE_INT(n,t,v,h) {n,t,    0,  v,  0,  0,    h}
 #define PARSE_STR(n,t,v,h) {n,t,    0,  0,  v,  0,    h}
 #define PARSE_FUN(n,t,v,h) {n,t,    0,  0,  0,  v,    h}
 #else
 #define ParseData long value
 #define PARSE_SET(n,t,v,h) {n,t,   (long) (v),        h}
-#define PARSE_INT(n,t,v,h) {n,t,   (long)&(v),        h}
+#define PARSE_INT(n,t,v,h) {n,t,   (long) (v),        h}
 #define PARSE_STR(n,t,v,h) {n,t,   (long) (v),        h}
 #define PARSE_FUN(n,t,v,h) {n,t,   (long) (v),        h}
 #endif
@@ -2751,7 +2779,7 @@
       "toggles inclusion of ISMAP links when client-side\nMAPs are present"
    ),
    PARSE_INT(
-      "link",          NEED_INT_ARG,           ccount,
+      "link",          NEED_INT_ARG,           &ccount,
       "=NUMBER\nstarting count for lnk#.dat files produced by -crawl"
    ),
    PARSE_SET(
@@ -2842,7 +2870,7 @@
       "toggles display partial pages while downloading"
    ),
    PARSE_INT(
-      "partial_thres",  IGNORE_ARG|INT_ARG,     partial_threshold,
+      "partial_thres",  NEED_INT_ARG,          &partial_threshold,
       "[=NUMBER]\nnumber of lines to render before repainting display\n\
 with partial-display logic"
    ),
@@ -2862,7 +2890,7 @@
    PARSE_SET(
       "preparsed",     SET_ARG,                &LYPreparsedSource,
       "show parsed text/html with -source and in source view\n\
-       to visualize how lynx behaves with invalid HTML"
+to visualize how lynx behaves with invalid HTML"
    ),
 #ifdef USE_PSRC
    PARSE_SET(




reply via email to

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