lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev (patch #2) local directory output - add partial mode


From: Leonid Pauzner
Subject: lynx-dev (patch #2) local directory output - add partial mode
Date: Mon, 5 Apr 1999 16:24:52 +0400 (MSD)

4-Apr-99 00:14 I wrote:
> * Reading of long local directories now benefits from partial mode and fully
>   interruptable. Split out print_local_dir() function from HTLoadFile(). - LP

> Comments:
> 1) it should not be overhead from HTDisplayPartial() in a tiny loop and
>   only minore overhead from HTCheckForInterrupt() - invoked once a 1/10 
> second.
>   can be more optimized by a lines counter.

This is a patch applied over the previous one,
it adds some optimization but also:


* DOSPATH changes: local directory style now configurable from lynx.cfg
  (LONG_LIST defined).  Unlike UNIX it is not "ls -l" by default
  but a more compact form (date and size present, from lynx.cfg example).



diff -u old/htfile.c ./htfile.c
--- old/htfile.c        Sat Apr  3 23:08:14 1999
+++ ./htfile.c  Mon Apr  5 16:05:18 1999
@@ -23,7 +23,11 @@
 #include <HTUtils.h>

 #ifndef VMS
-/* #define LONG_LIST */ /* Define this for long style unix listings (ls -l) */
+#ifdef DOSPATH
+#define LONG_LIST  /* Define this for long style unix listings (ls -l),
+                     the actual style configurable from lynx.cfg */
+#define lstat stat
+#endif
 /* #define NO_PARENT_DIR_REFERENCE */ /* Define this for no parent links */
 #endif /* !VMS */

@@ -1552,7 +1556,7 @@

                {
                    HTBTree * bt = HTBTree_new((HTComparer)strcmp);
-                   int num_of_entries = 0;     /* counter, currently not used 
*/
+                   int num_of_entries = 0;     /* lines counter */

                    _HTProgress (gettext("Reading directory..."));
                    status = HT_LOADED; /* assume we don't get interrupted */
@@ -1620,11 +1624,16 @@
                        */
                        HTBTree_add(bt, dirname);

-                       num_of_entries++;
-                       if (HTCheckForInterrupt()) {
-                           status = HT_PARTIAL_CONTENT;
-                           break;
+                       /* optimize for expensive operation: */
+                       if (num_of_entries % (partial_threshold > 0  ?
+                                             partial_threshold : display_lines)
+                                          == 0) {
+                               if (HTCheckForInterrupt()) {
+                                   status = HT_PARTIAL_CONTENT;
+                                   break;
+                               }
                        }
+                       num_of_entries++;

                    }   /* end while directory entries left to read */

@@ -1640,6 +1649,8 @@
                    {
                        HTBTElement * next_element = HTBTree_next(bt,NULL);
                            /* pick up the first element of the list */
+                       int num_of_entries_partial = 0; /* lines counter */
+
                        char state;
                            /* I for initial (.. file),
                               D for directory file,
@@ -1750,6 +1761,10 @@
                                /* pick up the next element of the list;
                                 if none, return NULL*/

+                           /* optimize for expensive operation: */
+                           if (num_of_entries_partial %
+                                 (partial_threshold > 0 ? partial_threshold : 
display_lines)
+                               == 0) {
                            /* num_of_entries, num_of_entries_partial... */
                            /* HTReadProgress...(bytes, 0); */
                            HTDisplayPartial();
@@ -1759,6 +1774,8 @@
                                status = HT_PARTIAL_CONTENT;
                                break;
                            }
+                           }
+                           num_of_entries_partial++;

                        } /* end while next_element */

diff -u old/htformat.c ./htformat.c
--- old/htformat.c      Sat Apr  3 23:28:46 1999
+++ ./htformat.c        Mon Apr  5 15:51:14 1999
@@ -478,7 +478,7 @@
 **     -------------------------------------------
 **
 **   Repaint the page only when necessary.
-**   This is a traverse call for HText_pageDispaly() - it works!.
+**   This is a traverse call for HText_pageDisplay() - it works!.
 **
 */
 PUBLIC void HTDisplayPartial NOARGS
@@ -492,7 +492,7 @@
        **  We update NumOfLines_partial only when we repaint the display.
        **  -1 is the special value:
        **  This is a synchronization flag switched to 0 when HText_new()
-       **  starts a new HTMainText object - all hypertext functions use it,
+       **  starts a new HTMainText object - all HText_ functions use it,
        **  lines counter in particular [we call it from HText_getNumOfLines()].
        **
        **  Otherwise HTMainText holds info from the previous document
@@ -503,17 +503,19 @@
        **  So repaint the page only when necessary:
        */
        if ((NumOfLines_partial != -1)
-               /* new hypertext document available  */
+               /* new HText object available  */
        && ((Newline_partial + display_lines) > NumOfLines_partial)
                /* current page not complete... */
-       && (partial_threshold > 0 ? ((Newline_partial + partial_threshold)  < 
HText_getNumOfLines()) :
-                ((Newline_partial + display_lines) < HText_getNumOfLines()))) {
+       && (partial_threshold > 0 ?
+                ((Newline_partial + partial_threshold) < 
HText_getNumOfLines()) :
+                ((Newline_partial + display_lines) < HText_getNumOfLines()))
                /*
                 * Originally we rendered by increments of 2 lines,
                 * but that got annoying on slow network connections.
                 * Then we switched to full-pages.  Now it's configurable.
-                * If partial_threshold < 0, then it's a full page
+                * If partial_threshold <= 0, then it's a full page
                 */
+       ) {
            NumOfLines_partial = HText_getNumOfLines();
            HText_pageDisplay(Newline_partial, "");
        }
diff -u old/installa ./installa
--- old/installa        Wed Mar 31 00:38:42 1999
+++ ./installa  Mon Apr  5 16:06:34 1999
@@ -265,7 +265,8 @@
        ./po subdirectory.

   --disable-long-list                  (prevent defining LONG_LIST)
-       Use this option to disable long "ls -l" directory listings.
+       Use this option to disable long "ls -l" directory listings
+       (when enabled, the actual directory style configurable from lynx.cfg).

   --disable-menu-options               (define NO_OPTION_MENU)
        Disable the menu-style options screen.  (See --disable-forms-options).
diff -u old/userdefs.h ./userdefs.h
--- old/userdefs.h      Wed Mar 31 00:38:46 1999
+++ ./userdefs.h        Mon Apr  5 15:00:08 1999
@@ -352,6 +352,8 @@
  *     %d      date of last modification
  *     %a      anchor pointing to file or directory
  *     %A      as above but don't show symbolic links
+ *     %t      type of file (description derived from MIME type)
+ *     %T      MIME type as known by Lynx (from mime.types or default)
  *     %k      size of file in Kilobytes
  *     %K      as above but omit size for directories
  *     %s      size of file in bytes
@@ -366,7 +368,11 @@
  *
  * For the Unix "ls -l" format:    "    %p %4l %-8.8o %-8.8g %7s %-12.12d %a"
  */
+#ifdef DOSPATH
+#define LIST_FORMAT "    %4K %-12.12d %a"
+#else
 #define LIST_FORMAT "    %p %4l %-8.8o %-8.8g %7s %-12.12d %a"
+#endif

 /*
  *  If NO_FORCED_CORE_DUMP is set to TRUE, Lynx will not force



reply via email to

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