lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev [PATCH 2.8.3.dev6] fix for psrcview, PSRCVIEW_NO_ANCHOR_NUMBERI


From: Vlad Harchev
Subject: lynx-dev [PATCH 2.8.3.dev6] fix for psrcview, PSRCVIEW_NO_ANCHOR_NUMBERING
Date: Mon, 16 Aug 1999 19:35:59 +0500 (SAMST)

 This patch fixes the problem that was reported by LP (line breaks occured to
early) - this was due to that fact that the number of control chars on the
line wasn't substracted from the line->size when wrappping.

* Added lynx.cfg setting PSRCVIEW_NO_ANCHOR_NUMBERING that inhibbits link
numbering when in psrc mode if set to TRUE (default is FALSE).

  Both tested with and without lss support.
  To be applied over all previous patches.
  I 'p'rinted help screen to file from psrcview mode and from plain source
  view mode (on lynx with and without lss support). The 'diff'erence is 2 
  empty lines (files produced in psrc mode views don't differ, files produced
  in plain source view doesn't differ, files produced in psrc mode differ from
  files produced in plain source mode by 2 empty lines).

PS: Tom, if you wish, mail me when you deside to release dev7, I'll make a
mega-patch for you that will contain all my patches sent here.

 Best regards,
  -Vlad

diff -ru old/lynx.cfg fixed/lynx.cfg
--- old/lynx.cfg        Sat Aug 14 12:31:24 1999
+++ fixed/lynx.cfg      Mon Aug 16 19:17:11 1999
@@ -2253,6 +2253,15 @@
 #HTMLSRC_TAGNAME_XFORM:2
 #HTMLSRC_ATTRNAME_XFORM:2
 
+# PSRCVIEW_NO_ANCHOR_NUMBERING - pretty source view setting
+# If "keypad mode" in 'O'ptions screen is "Links are numbered" or 
+# "Links and form fields are numbered", and PSRCVIEW_NO_ANCHOR_NUMBERING is 
+# TRUE, then links won't be numbered in psrc view and will be numbered 
+# otherwise. Set this setting to TRUE if you prefer numbered links, but wish 
+# to get valid html source when printing or mailing when in psrc view.
+# Default is FALSE.
+#PSRCVIEW_NO_ANCHOR_NUMBERING:FALSE
+
 # FORCE_EMPTY_HREFLESS_A - HTML parsing
 # This option mirrors command-line option with the same name.  Default is
 # FALSE.  If true, then any 'A' element without HREF will be closed
diff -ru old/src/GridText.c fixed/src/GridText.c
--- old/src/GridText.c  Sun Aug 15 18:34:22 1999
+++ fixed/src/GridText.c        Mon Aug 16 19:08:54 1999
@@ -3494,7 +3494,7 @@
         * If we're displaying document source, wrap long lines to keep all of
         * the source visible.
         */
-       int target = (int)(line->offset + line->size);
+       int target = (int)(line->offset + line->size) - 
ctrl_chars_on_this_line;        
        if ((target >= (LYcols-1) - style->rightIndent) &&
                HTisDocumentSource()) {
            new_line(text);
@@ -3843,6 +3843,9 @@
      *  If we are doing link_numbering add the link number.
      */
     if ((a->number > 0) &&
+#ifdef USE_PSRC
+       (text->source ? !psrcview_no_anchor_numbering : 1 ) &&
+#endif    
        (keypad_mode == LINKS_ARE_NUMBERED ||
         keypad_mode == LINKS_AND_FIELDS_ARE_NUMBERED)) {
        char saved_lastchar = text->LastChar;
@@ -4343,21 +4346,24 @@
 }
 
 
-PRIVATE void remove_special_attr_chars ARGS1(
+PRIVATE int remove_special_attr_chars ARGS1(
        char *,         buf)
 {
     register char *cp;
+    register int soft_newline_count = 0;
 
     for (cp = buf; *cp != '\0' ; cp++) {
        /*
         *  Don't print underline chars.
         */
+       soft_newline_count += (*cp == LY_SOFT_NEWLINE);
        if (!IsSpecialAttrChar(*cp)) {
           *buf = *cp,
           buf++;
        }
     }
     *buf = '\0';
+    return soft_newline_count;
 }
 
 
@@ -4479,6 +4485,7 @@
     for (anchor_ptr = text->first_anchor;
        anchor_ptr;
        prev_a = anchor_ptr, anchor_ptr=anchor_ptr->next) {
+       int have_soft_newline_in_1st_line=0;
 re_parse:
        /*
         *  Find the right line.
@@ -4611,11 +4618,9 @@
                              (anchor_ptr->extent -
                               strlen(anchor_ptr->hightext)));
                anchor_ptr->hightext2offset = line_ptr2->offset;
-               remove_special_attr_chars(anchor_ptr->hightext2);
-               
                /*handle LY_SOFT_NEWLINEs -VH */                
                anchor_ptr->hightext2offset += 
-                   (line_ptr2->data[0] == LY_SOFT_NEWLINE);            
+                       remove_special_attr_chars(anchor_ptr->hightext2);
                    
                if (anchor_ptr->link_type & HYPERTEXT_ANCHOR) {
                    LYTrimTrailing(anchor_ptr->hightext2);
@@ -4639,8 +4644,10 @@
            register int offset = 0, i = 0;
            for (; i < anchor_ptr->line_pos; i++)
                if (IS_UTF_EXTRA(line_ptr->data[i]) ||
-                   IsSpecialAttrChar(line_ptr->data[i]))
+                   IsSpecialAttrChar(line_ptr->data[i])) {                
                    offset++;
+                   have_soft_newline_in_1st_line += (line_ptr->data[i] == 
LY_SOFT_NEWLINE);
+               }; 
            anchor_ptr->line_pos -= offset;
        }
 
@@ -4651,7 +4658,7 @@
        anchor_ptr->line_num  = cur_line;
        
        /*handle LY_SOFT_NEWLINEs -VH */
-       anchor_ptr->line_pos += (line_ptr->data[0] == LY_SOFT_NEWLINE); 
+       anchor_ptr->line_pos += have_soft_newline_in_1st_line;
 
        CTRACE(tfp, "GridText:     add link on line %d col %d [%d] %s\n",
               cur_line, anchor_ptr->line_pos,
diff -ru old/src/LYPrettySrc.c fixed/src/LYPrettySrc.c
--- old/src/LYPrettySrc.c       Mon Aug 16 19:04:54 1999
+++ fixed/src/LYPrettySrc.c     Mon Aug 16 19:04:20 1999
@@ -20,6 +20,7 @@
   /* tagspecs from lynx.cfg are read here. After .lss file is read (is with lss
      support), the style cache and markup are created before entering the
      mainloop. */
+PUBLIC BOOL psrcview_no_anchor_numbering=FALSE;
 PUBLIC char* HTL_tagspecs[HTL_num_lexems] = {
  /* these values are defaults. They are also listed in comments of 
distibution's
      lynx.cfg.*/
diff -ru old/src/LYPrettySrc.h fixed/src/LYPrettySrc.h
--- old/src/LYPrettySrc.h       Mon Aug 16 19:04:59 1999
+++ fixed/src/LYPrettySrc.h     Mon Aug 16 19:03:57 1999
@@ -68,6 +68,7 @@
 extern int tagname_transform;
 extern int attrname_transform;
 
+extern BOOL psrcview_no_anchor_numbering;
 #endif /* ifdef USE_PSRC */
 
 
diff -ru old/src/LYReadCFG.c fixed/src/LYReadCFG.c
--- old/src/LYReadCFG.c Sat Aug 14 12:30:44 1999
+++ fixed/src/LYReadCFG.c       Mon Aug 16 19:06:44 1999
@@ -1296,6 +1296,9 @@
      PARSE_SET("prepend_base_to_source", CONF_BOOL, &LYPrependBaseToSource),
      PARSE_SET("prepend_charset_to_source", CONF_BOOL, 
&LYPrependCharsetToSource),
      PARSE_FUN("printer", CONF_FUN, printer_fun),
+#ifdef USE_PSRC     
+     
PARSE_SET("psrcview_no_anchor_numbering",CONF_BOOL,&psrcview_no_anchor_numbering),
+#endif     
      PARSE_SET("quit_default_yes", CONF_BOOL, &LYQuitDefaultYes),
      PARSE_SET("reuse_tempfiles", CONF_BOOL, &LYReuseTempfiles),
 #ifndef NO_RULES


reply via email to

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