[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lynx-dev unhighlighting problem patch
From: |
Vlad Harchev |
Subject: |
lynx-dev unhighlighting problem patch |
Date: |
Sat, 20 Mar 1999 00:45:52 +0400 (SAMT) |
Here is a patch that fixes unhighlighting problem in lynx-dev20 compiled
with lss support (it slightly differs from one I've sent before - it won't
introduce a new source file). The approach it uses is unchanged.
Best regards,
-Vlad
diff -ruP 2.8.2dev20-orig/src/GridText.c lynx-2.8.2dev20-fixed/src/GridText.c
--- lynx-2.8.2dev20-orig/src/GridText.c Mon Mar 15 23:55:41 1999
+++ lynx-2.8.2dev20-fixed/src/GridText.c Sat Mar 20 00:23:05 1999
@@ -10319,3 +10319,236 @@
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.
+*/
+#if defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX)
+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;
+ LYGetYX(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;
+}
+#endif /* defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX) */
+
+/*
+ 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;
+};
diff -ruP lynx-2.8.2dev20-orig/src/GridText.h
lynx-2.8.2dev20-fixed/src/GridText.h
--- lynx-2.8.2dev20-orig/src/GridText.h Mon Mar 15 23:55:41 1999
+++ lynx-2.8.2dev20-fixed/src/GridText.h Sat Mar 20 00:19:12 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 lynx-2.8.2dev20-orig/src/LYUtils.c lynx-2.8.2dev20-fixed/src/LYUtils.c
--- lynx-2.8.2dev20-orig/src/LYUtils.c Mon Mar 15 23:55:46 1999
+++ lynx-2.8.2dev20-fixed/src/LYUtils.c Sat Mar 20 00:20:12 1999
@@ -125,7 +125,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 +141,10 @@
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)
@@ -179,6 +186,10 @@
LynxChangeStyle(s, STACK_ON, 0);
}
#endif
+#if defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX)
+ }
+#endif
+
if (links[cur].type == WWW_FORM_LINK_TYPE) {
int len;
@@ -196,6 +207,11 @@
addch('_');
} else {
+#if defined(USE_COLOR_STYLE) && !defined(NO_HILIT_FIX)
+ if (flag == OFF) {
+ hl2_drawn=TRUE; redraw_lines_of_link(cur);
+ } else {
+#endif
/*
* Copy into the buffer only what will fit
* within the width of the screen.
@@ -207,12 +223,19 @@
((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
@@ -237,6 +260,9 @@
}
}
}
+#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)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- lynx-dev unhighlighting problem patch,
Vlad Harchev <=