lynx-dev
[Top][All Lists]
Advanced

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

Re: lynx-dev When unhighlighting some highlighted links, lynx draws them


From: Vlad Harchev
Subject: Re: lynx-dev When unhighlighting some highlighted links, lynx draws them incorrectly
Date: Sat, 13 Mar 1999 06:12:11 +0400 (SAMT)

On Fri, 5 Mar 1999, Vlad Harchev wrote:

> 
>   When unhighlighting highlighted links that contain some extra formatting,
>   lynx-2.8.2dev12 and lynx-2.8 draw them incorrectly ( compared to 
>   the way the were  drawn before becoming highlighted first time)  when 
>   compiled with lss support (at least - I didn't check lynx compiled 
>   without lss). Here is an example of such html (highlight and unhighlight
>   2 last links to see what I mean).
> 
> 
> <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
> <HTML><HEAD><TITLE>e</TITLE></HEAD>
> <BODY LANG="EN">
> <UL> 
> <LI> <A NAME="tex2html36" HREF="node23.html">IPC Identifiers</A>
> <LI> <A NAME="tex2html37" HREF="node24.html">IPC Keys</A>
> <LI> <A NAME="tex2html38" HREF="node25.html">The <TT>ipcs</TT> Command</A>
> <LI> <A NAME="tex2html39" HREF="node26.html">The <TT>ipcrm</TT> Command</A>
> </UL></BODY></HTML>
> 
>  Best regards,
>  -Vlad
> 
> 
  Here is a patch that will fix this unhighlighting bug in lynx-dev19
compiled with lss support. Original behaviour can be restored by defining
NO_HILIT_FIX.
  BTW, what are other bugs in lss code - as a user, I don't see any
 incorrect?

  Best regards,
  -Vlad

diff -ruP 2.8.2dev19-orig/src/GridText.c lynx-2.8.2dev19-fixed/src/GridText.c
--- lynx-2.8.2dev19-orig/src/GridText.c Tue Mar  9 22:45:03 1999
+++ lynx-2.8.2dev19-fixed/src/GridText.c        Sat Mar 13 05:17:34 1999
@@ -10278,3 +10278,234 @@
 
     return (newlines);
 }
+
+/*
+ this function draws the part of line 'line', pointed by 'str' (which can be 
+ non terminated with null - ie be line->data+N ) drawing 
+ 'len' bytes (not characters) of it. It doesn't check whether the 'len' 
+ bytes cross a character boundary (if multibyte chars are in string). 
+ Assumes that the cursor is positioned in the place where the 1st char of 
+ string should be drawn. Currently used only in redraw_lines_of_link when 
+    defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX)         
+ This code is based on display_line. This code was tested with ncurses only 
+ (since no support for lss is availble for Slang) and with 
+ defined(USE_COLOR_STYLE).    
+ -HV.    
+*/
+PRIVATE void redraw_part_of_line ARGS4( 
+        HTLine *,      line,
+        char*,          str,
+        int,            len,
+       HText *,        text)
+{
+    register int i, j;
+    char buffer[7];
+    char *data,*end_of_data;
+    size_t utf_extra = 0;
+#ifdef USE_COLOR_STYLE
+    int current_style = 0;
+#endif
+    char LastDisplayChar = ' ';
+    
+    int YP,XP;
+    getyx(stdscr,YP,XP);
+    
+    i=XP;
+
+    /* Set up the multibyte character buffer  */
+    buffer[0] = buffer[1] = buffer[2] = '\0';
+
+    data = str;
+    end_of_data = data + len;
+    i++;
+    
+    /* this assumes that the part of line to be drawn fits in the screen*/
+    while (  data < end_of_data ) {
+        buffer[0] = *data;
+       data++;
+
+#if defined(USE_COLOR_STYLE) || defined(SLSC)
+#define CStyle line->styles[current_style]
+
+       while (current_style < line->numstyles &&
+              i >= (int) (CStyle.horizpos + line->offset + 1))
+       {
+               LynxChangeStyle (CStyle.style,CStyle.direction,CStyle.previous);
+               current_style++;
+       }
+#endif
+       switch (buffer[0]) {
+
+#ifndef USE_COLOR_STYLE
+           case LY_UNDERLINE_START_CHAR:
+               if (dump_output_immediately && use_underscore) {
+                   addch('_');
+                   i++;
+               } else {
+                   start_underline();
+               }
+               break;
+
+           case LY_UNDERLINE_END_CHAR:
+               if (dump_output_immediately && use_underscore) {
+                   addch('_');
+                   i++;
+               } else {
+                   stop_underline();
+               }
+               break;
+
+           case LY_BOLD_START_CHAR:
+               start_bold();
+               break;
+
+           case LY_BOLD_END_CHAR:
+               stop_bold ();
+               break;
+
+#endif
+           case LY_SOFT_NEWLINE:
+               if (!dump_output_immediately)
+                   addch('+');
+               break;
+
+           case LY_SOFT_HYPHEN:
+               if (*data != '\0' ||
+                   isspace((unsigned char)LastDisplayChar) ||
+                   LastDisplayChar == '-') {
+                   /*
+                    *  Ignore the soft hyphen if it is not the last
+                    *  character in the line.  Also ignore it if it
+                    *  first character following the margin, or if it
+                    *  is preceded by a white character (we loaded 'M'
+                    *  into LastDisplayChar if it was a multibyte
+                    *  character) or hyphen, though it should have
+                    *  been excluded by HText_appendCharacter() or by
+                    *  split_line() in those cases. - FM
+                    */
+                   break;
+               } else {
+                   /*
+                    *  Make it a hard hyphen and fall through. - FM
+                    */
+                   buffer[0] = '-';
+                   i++;
+               }
+
+           default:
+               i++;
+               if (text->T.output_utf8 && !isascii(buffer[0])) {
+                   if ((*buffer & 0xe0) == 0xc0) {
+                       utf_extra = 1;
+                   } else if ((*buffer & 0xf0) == 0xe0) {
+                       utf_extra = 2;
+                   } else if ((*buffer & 0xf8) == 0xf0) {
+                       utf_extra = 3;
+                   } else if ((*buffer & 0xfc) == 0xf8) {
+                       utf_extra = 4;
+                   } else if ((*buffer & 0xfe) == 0xfc) {
+                       utf_extra = 5;
+                   } else {
+                        /*
+                         *  Garbage.
+                         */
+                       utf_extra = 0;
+                   }
+                   if (strlen(data) < utf_extra) {
+                       /*
+                        *  Shouldn't happen.
+                        */
+                       utf_extra = 0;
+                   }
+                   LastDisplayChar = 'M';
+               }
+               if (utf_extra) {
+                   strncpy(&buffer[1], data, utf_extra);
+                   buffer[utf_extra+1] = '\0';
+                   addstr(buffer);
+                   buffer[1] = '\0';
+                   data += utf_extra;
+                   utf_extra = 0;
+               } else if (HTCJK != NOCJK && !isascii(buffer[0])) {
+                   /*
+                    *  For CJK strings, by Masanobu Kimura.
+                    */
+                   buffer[1] = *data;
+                   data++;
+                   addstr(buffer);
+                   buffer[1] = '\0';
+                   /*
+                    *  For now, load 'M' into LastDisplayChar,
+                    *  but we should check whether it's white
+                    *  and if so, use ' '.  I don't know if
+                    *  there actually are white CJK characters,
+                    *  and we're loading ' ' for multibyte
+                    *  spacing characters in this code set,
+                    *  but this will become an issue when
+                    *  the development code set's multibyte
+                    *  character handling is used. - FM
+                    */
+                   LastDisplayChar = 'M';
+               } else {
+                   addstr(buffer);
+                   LastDisplayChar = buffer[0];
+               }
+       } /* end of switch */
+    } /* end of while */
+
+#ifndef USE_COLOR_STYLE
+    stop_underline();
+    stop_bold();
+#else
+    while (current_style < line->numstyles)
+    {
+       LynxChangeStyle (CStyle.style, CStyle.direction, CStyle.previous);
+       current_style++;
+    }
+#undef CStyle
+#endif
+    return;
+}
+
+
+/*
+  This is used only if compiled with lss support. It's called to draw
+  regular link (1st two lines of link) when it's being unhighlighted in 
+  highlight:LYUtils.
+*/
+
+PUBLIC void redraw_lines_of_link ARGS1( 
+            int , cur )
+{
+#if defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX)        
+#define pvtTITLE_HEIGHT 1
+    HTLine* todr1,*todr2;
+    int lines_back;                    
+    if (HTMainText->next_line == HTMainText->last_line) {
+    /* we are at the last page - that is partially filled */
+       lines_back = HTMainText->Lines - ( links[cur].ly-pvtTITLE_HEIGHT+
+       HTMainText->top_of_screen);
+    } else  {               
+       lines_back=display_lines - (links[cur].ly-pvtTITLE_HEIGHT);
+    };
+    todr1=HTMainText->next_line;
+    while (lines_back--) todr1=todr1->prev;
+    todr2= (links[cur].hightext2 && links[cur].ly < display_lines) ?
+            todr1->next : 0; 
+
+    move(links[cur].ly,links[cur].lx);
+    redraw_part_of_line (todr1, links[cur].hightext, 
+                           strlen(links[cur].hightext),HTMainText);
+    if (todr2) { 
+        move(links[cur].ly+1,links[cur].hightext2_offset);
+        redraw_part_of_line (todr2, links[cur].hightext2, 
+                           strlen(links[cur].hightext2),HTMainText);
+    };
+    
+#undef pvtTITLE_HEIGHT     
+#else
+  /* no dead code !*/
+#endif
+  return;
+};            
+        
\ No newline at end of file
diff -ruP 2.8.2dev19-orig/src/GridText.h lynx-2.8.2dev19-fixed/src/GridText.h
--- lynx-2.8.2dev19-orig/src/GridText.h Tue Mar  9 22:45:03 1999
+++ lynx-2.8.2dev19-fixed/src/GridText.h        Thu Mar 11 13:01:49 1999
@@ -271,4 +271,6 @@
 extern int HText_InsertFile PARAMS((
        struct link *   form_link));
 
+extern void redraw_lines_of_link PARAMS((int cur));
+
 #endif /* LYGRIDTEXT_H */
diff -ruP orig/src/LYUnhighlight.c lynx-2.8.2dev19-fixed/src/LYUnhighlight.c
--- lynx-2.8.2dev19-orig/src/LYUnhighlight.c    Thu Jan  1 04:00:00 1970
+++ lynx-2.8.2dev19-fixed/src/LYUnhighlight.c   Thu Mar 11 13:05:10 1999
@@ -0,0 +1,11 @@
+#include <HTUtils.h>
+
+/* the way it's done prevents inclusion of GridText.h by LYUtils.c */
+
+/* this resides in GridText.c */
+extern void redraw_lines_of_link PARAMS(( int  cur )); 
+
+void LYunhighlight ARGS1( int , cur )
+{
+  redraw_lines_of_link(cur) ;
+}
\ No newline at end of file
diff -ruP orig/src/LYUnhighlight.h lynx-2.8.2dev19-fixed/src/LYUnhighlight.h
--- lynx-2.8.2dev19-orig/src/LYUnhighlight.h    Thu Jan  1 04:00:00 1970
+++ lynx-2.8.2dev19-fixed/src/LYUnhighlight.h   Thu Mar 11 13:01:09 1999
@@ -0,0 +1,2 @@
+
+extern void LYunhighlight PARAMS(( int cur ));
\ No newline at end of file
diff -ruP 2.8.2dev19-orig/src/LYUtils.c lynx-2.8.2dev19-fixed/src/LYUtils.c
--- lynx-2.8.2dev19-orig/src/LYUtils.c  Tue Mar  9 22:45:07 1999
+++ lynx-2.8.2dev19-fixed/src/LYUtils.c Thu Mar 11 13:26:44 1999
@@ -16,6 +16,10 @@
 #include <LYCharUtils.h>
 #include <LYMainLoop.h>
 
+#if defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX)        
+# include <LYUnhighlight.h>
+#endif
+
 #ifdef DJGPP_KEYHANDLER
 #include <bios.h>
 #endif /* DJGPP_KEYHANDLER */
@@ -125,6 +129,10 @@
     BOOL TargetEmphasisON = FALSE;
 #endif
     BOOL utf_flag = (LYCharSet_UC[current_char_set].enc == UCT_ENC_UTF8);
+#if defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX)            
+    BOOL hl2_drawn=FALSE;/* whether links[cur].hightext2 is already drawn 
+                            properly*/
+#endif
 
     tmp[0] = tmp[1] = tmp[2] = '\0';
 
@@ -138,6 +146,9 @@
        cur = 0;
 
     if (nlinks > 0) {
+#if  defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX) 
+        if (flag == ON || links[cur].type==WWW_FORM_LINK_TYPE) {
+#endif           
 #ifdef USE_COLOR_STYLE
 #define LXP (links[cur].lx)
 #define LYP (links[cur].ly)
@@ -162,6 +173,10 @@
        }
 #endif
 
+#if  defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX) 
+    }
+#endif
+
        if (links[cur].type == WWW_FORM_LINK_TYPE) {
            int len;
            int avail_space = (LYcols - links[cur].lx) - 1;
@@ -177,7 +192,14 @@
            for (; len < links[cur].form->size && len < avail_space; len++)
                addch('_');
 
-       } else {
+       } else {        
+
+#if defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX)        
+            if (flag == OFF) { 
+                 hl2_drawn=TRUE; LYunhighlight(cur); 
+            } else {
+#endif
+            
            /*
             *  Copy into the buffer only what will fit
             *  within the width of the screen.
@@ -189,12 +211,20 @@
                          ((LYcols - 1) - links[cur].lx),
                          utf_flag);
            addstr(buffer);
+#if defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX)                    
+            }
+#endif 
        }
 
+
        /*
         *  Display a second line as well.
         */
-       if (links[cur].hightext2 && links[cur].ly < display_lines) {
+       if ( links[cur].hightext2 && links[cur].ly < display_lines
+#if defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX)                
+          && hl2_drawn==FALSE 
+#endif          
+        ) {
            lynx_stop_link_color (flag == ON, links[cur].inUnderline);
            move((links[cur].ly + 1), links[cur].hightext2_offset);
 #ifndef USE_COLOR_STYLE
@@ -219,7 +249,12 @@
                 }
            }
        }
+
+#if defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX)            
+        if ( hl2_drawn==FALSE )
+#endif
        lynx_stop_link_color (flag == ON, links[cur].inUnderline);
+
 
 #if defined(FANCY_CURSES) || defined(USE_SLANG)
        /*
diff -ruP 2.8.2dev19-orig/src/makefile.in lynx-2.8.2dev19-fixed/src/makefile.in
--- lynx-2.8.2dev19-orig/src/makefile.in        Tue Mar  9 22:44:51 1999
+++ lynx-2.8.2dev19-fixed/src/makefile.in       Sat Mar 13 05:13:25 1999
@@ -65,7 +65,7 @@
 HTML.o HTFWriter.o HTInit.o DefaultStyle.o LYLocal.o LYUpload.o \
 LYLeaks.o LYexit.o LYJump.o LYList.o LYCgi.o LYTraversal.o \
 LYEditmap.o LYCharSets.o LYCharUtils.o LYMap.o LYCookie.o LYExtern.o \
-LYStyle.o LYHash.o $(CHARTRANS_OBJS) @LIBOBJS@
+LYStyle.o LYHash.o LYUnhighlight.o $(CHARTRANS_OBJS) @LIBOBJS@
 
 C_SRC  = $(OBJS:.o=.c)
 


reply via email to

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