aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2005-06-02 22:50:02 -0400
committerThomas E. Dickey <dickey@invisible-island.net>2005-06-02 22:50:02 -0400
commit1367261dc669476df3a799f0de45e4bfb2437b8b (patch)
tree3bf6e1c020aab95b4133f2c29baffef454d3d60b /src
parentaaa10562f4a02971f712964cb2fd1014d2a75d33 (diff)
downloadlynx-snapshots-1367261dc669476df3a799f0de45e4bfb2437b8b.tar.gz
snapshot of project "lynx", label v2-8-6dev_12
Diffstat (limited to 'src')
-rw-r--r--src/DefaultStyle.c11
-rw-r--r--src/GridText.c311
-rw-r--r--src/GridText.h6
-rw-r--r--src/HTAlert.c2
-rw-r--r--src/HTML.c38
-rw-r--r--src/LYCurses.c225
-rw-r--r--src/LYCurses.h7
-rw-r--r--src/LYGlobalDefs.h4
-rw-r--r--src/LYKeymap.c2
-rw-r--r--src/LYMain.c14
-rw-r--r--src/LYMainLoop.c220
-rw-r--r--src/LYOptions.c4
-rw-r--r--src/LYStrings.c20
-rw-r--r--src/LYStructs.h1
-rw-r--r--src/LYStyle.c48
-rw-r--r--src/LYUtils.c66
-rw-r--r--src/UCdomap.c2
-rw-r--r--src/chrtrans/makefile.in2
18 files changed, 615 insertions, 368 deletions
diff --git a/src/DefaultStyle.c b/src/DefaultStyle.c
index 770b4919..f1716e9c 100644
--- a/src/DefaultStyle.c
+++ b/src/DefaultStyle.c
@@ -7,6 +7,7 @@
#include <HTFont.h>
#include <HTStyle.h>
+#include <LYGlobalDefs.h>
#include <LYLeaks.h>
/* Tab arrays:
@@ -462,6 +463,11 @@ HTStyleSheet *DefaultStyle(HTStyle ***result_array)
for (p = sheet.styles; p != 0; p = p->next) {
q = HTStyleNew();
*q = *p;
+ if (no_margins) {
+ q->indent1st = 0;
+ q->leftIndent = 0;
+ q->rightIndent = 0;
+ }
st_array[q->id] = q;
q->next = result->styles;
result->styles = q;
@@ -473,6 +479,11 @@ HTStyleSheet *DefaultStyle(HTStyle ***result_array)
HTStyle *r = q->next;
*q = *p;
+ if (no_margins) {
+ q->indent1st = 0;
+ q->leftIndent = 0;
+ q->rightIndent = 0;
+ }
st_array[q->id] = q;
q->next = r;
}
diff --git a/src/GridText.c b/src/GridText.c
index d79f5b17..3e6e329b 100644
--- a/src/GridText.c
+++ b/src/GridText.c
@@ -89,8 +89,6 @@ struct _HTStream { /* only know it as object */
/* ... */
};
-#define TITLE_LINES 1
-
#define IS_UTF_EXTRA(ch) (text->T.output_utf8 && \
(UCH((ch))&0xc0) == 0x80)
@@ -369,6 +367,7 @@ typedef struct {
typedef struct _TextAnchor {
struct _TextAnchor *next;
struct _TextAnchor *prev; /* www_user_search only! */
+ int sgml_offset; /* used for updating position after reparsing */
int number; /* For user interface */
int line_num; /* Place in document */
short line_pos; /* Bytes/chars - extent too */
@@ -420,7 +419,7 @@ typedef enum {
} eEUC_status;
#endif
-/* Notes on struct _Htext:
+/* Notes on struct _HText:
* next_line is valid if stale is false.
* top_of_screen line means the line at the top of the screen
* or just under the title if there is one.
@@ -1292,7 +1291,9 @@ void HText_free(HText *self)
/* Output a line
* -------------
*/
-static int display_line(HTLine *line, HText *text, int scrline GCC_UNUSED,
+static int display_line(HTLine *line,
+ HText *text,
+ int scrline GCC_UNUSED,
const char *target GCC_UNUSED)
{
register int i, j;
@@ -1893,17 +1894,18 @@ static void display_scrollbar(HText *text)
/* Output a page
* -------------
*/
-static void display_page(HText *text, int line_number,
+static void display_page(HText *text,
+ int line_number,
const char *target)
{
HTLine *line = NULL;
int i;
+ int title_lines = TITLE_LINES;
#if defined(USE_COLOR_STYLE) && defined(SHOW_WHEREIS_TARGETS)
const char *cp;
#endif
char tmp[7];
- int last_screen;
TextAnchor *Anchor_ptr = NULL;
int stop_before_for_anchors;
FormInfo *FormInfo_ptr;
@@ -1953,18 +1955,8 @@ static void display_page(HText *text, int line_number,
return;
}
- last_screen = text->Lines - (display_lines - 2);
line = text->last_line->prev;
-
- /*
- * Constrain the line number to be within the document.
- */
- if (text->Lines < (display_lines))
- line_number = 0;
- else if (line_number > text->Lines)
- line_number = last_screen;
- else if (line_number < 0)
- line_number = 0;
+ line_number = HText_getPreferredTopLine(text, line_number);
for (i = 0, line = FirstHTLine(text); /* Find line */
i < line_number && (line != text->last_line);
@@ -2031,7 +2023,12 @@ static void display_page(HText *text, int line_number,
text->top_of_screen = line_number;
text->top_of_screen_line = line;
- display_title(text); /* will move cursor to top of screen */
+ if (no_title) {
+ LYmove(0, 0);
+ title_lines = 0;
+ } else {
+ display_title(text); /* will move cursor to top of screen */
+ }
display_flag = TRUE;
#ifdef USE_COLOR_STYLE
@@ -2093,7 +2090,7 @@ static void display_page(HText *text, int line_number,
if (!display_partial &&
line_number == text->first_lineno_last_disp_partial &&
i + line_number <= text->last_lineno_last_disp_partial)
- LYmove((i + 2), 0);
+ LYmove((i + title_lines + 1), 0);
else
#endif
display_line(line, text, i + 1, target);
@@ -2144,7 +2141,7 @@ static void display_page(HText *text, int line_number,
/*
* First printable character of target.
*/
- LYmove((i + 1), x_pos);
+ LYmove((i + title_lines), x_pos);
}
/*
* Output all the printable target chars.
@@ -2187,7 +2184,7 @@ static void display_page(HText *text, int line_number,
* the end of the line, or not have another hit
* in it. -FM
*/
- LYmove((i + 2), 0);
+ LYmove((i + title_lines + 1), 0);
} /* end while */
#endif /* USE_COLOR_STYLE */
#endif /* SHOW_WHEREIS_TARGETS */
@@ -2201,7 +2198,7 @@ static void display_page(HText *text, int line_number,
* Clear remaining lines of display.
*/
for (i++; i < (display_lines); i++) {
- LYmove((i + 1), 0);
+ LYmove((i + title_lines), 0);
LYclrtoeol();
}
break;
@@ -2257,6 +2254,7 @@ static void display_page(HText *text, int line_number,
links[nlinks].inUnderline = Anchor_ptr->inUnderline;
+ links[nlinks].sgml_offset = Anchor_ptr->sgml_offset;
links[nlinks].anchor_number = Anchor_ptr->number;
links[nlinks].anchor_line_num = Anchor_ptr->line_num;
@@ -2321,6 +2319,7 @@ static void display_page(HText *text, int line_number,
FormInfo_ptr = Anchor_ptr->input_field;
+ links[nlinks].sgml_offset = Anchor_ptr->sgml_offset;
links[nlinks].anchor_number = Anchor_ptr->number;
links[nlinks].anchor_line_num = Anchor_ptr->line_num;
@@ -2574,10 +2573,11 @@ static void move_anchors_in_region(HTLine *line, int line_number,
head_processed = 1;
}
/* Fix the end */
- if (last < ebyte)
+ if (last < ebyte) {
a->extent += shift;
- else
+ } else {
break; /* Keep this `a' for the next step */
+ }
}
*prev_anchor = a;
*prev_head_processed = head_processed;
@@ -3112,9 +3112,10 @@ static void split_line(HText *text, unsigned split)
/* @@ first line indent */
#ifdef WIDEC_CURSES
- spare = WRAP_COLS(text) -
- (int) style->rightIndent - indent +
- ctrl_chars_on_previous_line - LYstrExtent2(previous->data, previous->size);
+ spare = WRAP_COLS(text)
+ - (int) style->rightIndent
+ - indent
+ - LYstrExtent2(previous->data, previous->size);
if (spare < 0 && LYwideLines) /* Can be wider than screen */
spare = 0;
#else
@@ -3362,7 +3363,7 @@ static void split_line(HText *text, unsigned split)
jline = insert_blanks_in_line(previous, CurLine, text,
&last_anchor_of_previous_line /*updates++ */ ,
ht_num_runs - 1, oldpos, newpos);
- free((char *) oldpos);
+ free(oldpos);
if (jline == NULL)
outofmem(__FILE__, "split_line_4");
previous->next->prev = jline;
@@ -3371,13 +3372,12 @@ static void split_line(HText *text, unsigned split)
freeHTLine(text, previous);
previous = jline;
- } { /* (ht_num_runs==1) */
- if (justify_start_position) {
- char *p2 = previous->data;
+ }
+ if (justify_start_position) {
+ char *p2 = previous->data;
- for (; p2 < previous->data + justify_start_position; ++p2)
- *p2 = (*p2 == HT_NON_BREAK_SPACE ? ' ' : *p2);
- }
+ for (; p2 < previous->data + justify_start_position; ++p2)
+ *p2 = (*p2 == HT_NON_BREAK_SPACE ? ' ' : *p2);
}
} else {
if (REALLY_CAN_JUSTIFY(text)) {
@@ -3430,10 +3430,14 @@ static void blank_lines(HText *text, int newlines)
{
if (HText_LastLineEmpty(text, FALSE)) { /* No text on current line */
HTLine *line = text->last_line->prev;
+ BOOL first = (line == text->last_line);
+
+ if (no_title && first)
+ return;
#ifdef USE_COLOR_STYLE
/* Style-change petty requests at the start of the document: */
- if (line == text->last_line && newlines == 1)
+ if (first && newlines == 1)
return; /* Do not add a blank line at start */
#endif
@@ -4238,17 +4242,17 @@ void HText_appendCharacter(HText *text, int ch)
((line->size > 0) &&
(int) (line->data[line->size - 1] == LY_SOFT_HYPHEN ? 1 : 0)));
- if (text->T.output_utf8) {
- actual += (UTFXTRA_ON_THIS_LINE - ctrl_chars_on_this_line + UTF_XLEN(ch));
- limit = LYcols_cu(text);
- } else {
- actual +=
- (int) style->rightIndent - ctrl_chars_on_this_line +
- (((HTCJK != NOCJK) && text->kanji_buf) ? 1 : 0);
- limit = WRAP_COLS(text);
- }
-
- if (actual >= limit) {
+ if ((actual
+ + (int) style->rightIndent
+ - ctrl_chars_on_this_line
+ + (((HTCJK != NOCJK) && text->kanji_buf) ? 1 : 0)
+ ) >= (WRAP_COLS(text) - 1)
+ || (text->T.output_utf8
+ && ((actual
+ + UTFXTRA_ON_THIS_LINE
+ - ctrl_chars_on_this_line
+ + UTF_XLEN(ch)
+ ) >= (LYcols_cu(text) - 1)))) {
if (style->wordWrap && HTOutputFormat != WWW_SOURCE) {
#ifdef EXP_JUSTIFY_ELTS
@@ -5041,6 +5045,7 @@ int HText_beginAnchor(HText *text, BOOL underline,
outofmem(__FILE__, "HText_beginAnchor");
a->inUnderline = underline;
+ a->sgml_offset = SGML_offset();
a->line_num = text->Lines;
a->line_pos = text->last_line->size;
if (text->last_anchor) {
@@ -5685,7 +5690,8 @@ void HText_endAppend(HText *text)
* This needs to be done so that display_page finds the anchors in the
* form it expects when it sets the links[] elements.
*/
-static void HText_trimHightext(HText *text, BOOLEAN final,
+static void HText_trimHightext(HText *text,
+ BOOLEAN final,
int stop_before)
{
int cur_line, cur_shift;
@@ -5774,9 +5780,12 @@ static void HText_trimHightext(HText *text, BOOLEAN final,
anchor_ptr->line_num = cur_line;
}
CTRACE((tfp,
- "GridText: Anchor found on line:%d col:%d [%d] ext:%d\n",
- cur_line, anchor_ptr->line_pos,
- anchor_ptr->number, anchor_ptr->extent));
+ "GridText: Anchor found on line:%d col:%d [%05d:%d] ext:%d\n",
+ cur_line,
+ anchor_ptr->line_pos,
+ anchor_ptr->sgml_offset,
+ anchor_ptr->number,
+ anchor_ptr->extent));
cur_shift = 0;
/*
@@ -5915,11 +5924,11 @@ static void HText_trimHightext(HText *text, BOOLEAN final,
if (anchor_ptr->line_pos > 0) {
/*
* LYstrExtent filters out the formatting characters, so we do not
- * have to count them here.
- *
- * FIXME: do we have to count soft-newlines?
+ * have to count them here, except for soft newlines.
*/
anchor_ptr->line_pos = LYstrExtent2(line_ptr->data, anchor_col);
+ if (line_ptr->data[0] == LY_SOFT_NEWLINE)
+ anchor_ptr->line_pos += 1;
}
#else /* 8-bit curses, etc. */
if (anchor_ptr->line_pos > 0) {
@@ -6411,7 +6420,7 @@ BOOL HText_TAHasMoreLines(int curlink,
* are treated as different fields, as usual;
* if TRUE, fields of the same textarea are treated as a
* group for skipping.
- * The caller wants a information for positioning on the new link to be
+ * The caller wants information for positioning on the new link to be
* deposited in *go_line and (if linknum is not NULL) *linknum.
*
* On failure (no more links in the requested direction) returns NO
@@ -7010,10 +7019,142 @@ BOOL HText_pageHasPrevTarget(void)
}
/*
+ * Find the number of the closest anchor to the given document offset. Used
+ * in reparsing, this will usually find an exact match, as a link shifts around
+ * on the display. It will not find a match when (for example) the source view
+ * shows images that are not links in the html.
+ */
+int HText_closestAnchor(HText *text, int offset)
+{
+ int result = -1;
+ int absdiff = 0;
+ int newdiff;
+ TextAnchor *Anchor_ptr = NULL;
+ TextAnchor *closest = NULL;
+
+ for (Anchor_ptr = text->first_anchor;
+ Anchor_ptr != NULL;
+ Anchor_ptr = Anchor_ptr->next) {
+ if (Anchor_ptr->sgml_offset == offset) {
+ result = Anchor_ptr->number;
+ break;
+ } else {
+ newdiff = abs(Anchor_ptr->sgml_offset - offset);
+ if (absdiff == 0 || absdiff > newdiff) {
+ absdiff = newdiff;
+ closest = Anchor_ptr;
+ }
+ }
+ }
+ if (result < 0 && closest != 0) {
+ result = closest->number;
+ }
+
+ return result;
+}
+
+/*
+ * Find the offset for the given anchor, e.g., the inverse of
+ * HText_closestAnchor().
+ */
+int HText_locateAnchor(HText *text, int anchor_number)
+{
+ int result = -1;
+ TextAnchor *Anchor_ptr = NULL;
+
+ for (Anchor_ptr = text->first_anchor;
+ Anchor_ptr != NULL;
+ Anchor_ptr = Anchor_ptr->next) {
+ if (Anchor_ptr->number == anchor_number) {
+ result = Anchor_ptr->sgml_offset;
+ break;
+ }
+ }
+
+ return result;
+}
+
+/*
+ * This is supposed to give the same result as the inline checks in
+ * display_page(), so we can decide which anchors will be visible.
+ */
+static BOOL anchor_is_numbered(TextAnchor *Anchor_ptr)
+{
+ BOOL result = FALSE;
+
+ if (Anchor_ptr->show_anchor
+ /* FIXME: && non_empty(hi_string) */
+ && (Anchor_ptr->link_type & HYPERTEXT_ANCHOR)) {
+ result = TRUE;
+ } else if (Anchor_ptr->link_type == INPUT_ANCHOR
+ && Anchor_ptr->input_field->type != F_HIDDEN_TYPE) {
+ result = TRUE;
+ }
+ return result;
+}
+
+/*
+ * Return the absolute line number (counting from the beginning of the
+ * document) for the given absolute anchor number. Normally line numbers are
+ * computed within the screen, and for that we use the links[] array. A few
+ * uses require the absolute anchor number. For example, reparsing a document,
+ * e.g., switching between normal and source views will alter the line numbers
+ * of each link, and may require adjusting the top line number used for the
+ * display, before we recompute the links[] array.
+ */
+int HText_getAbsLineNumber(HText *text,
+ int anchor_number)
+{
+ int result = -1;
+
+ if (anchor_number >= 0 && text != 0) {
+ TextAnchor *Anchor_ptr = NULL;
+
+ for (Anchor_ptr = text->first_anchor;
+ Anchor_ptr != NULL;
+ Anchor_ptr = Anchor_ptr->next) {
+ if (anchor_is_numbered(Anchor_ptr)
+ && Anchor_ptr->number == anchor_number) {
+ result = Anchor_ptr->line_num;
+ break;
+ }
+ }
+ }
+ return result;
+}
+
+/*
+ * Compute the link-number in a page, given the top line number of the page and
+ * the absolute anchor number.
+ */
+int HText_anchorRelativeTo(HText *text, int top_lineno, int anchor_number)
+{
+ int result = 0;
+ int from_top = 0;
+ TextAnchor *Anchor_ptr = NULL;
+
+ for (Anchor_ptr = text->first_anchor;
+ Anchor_ptr != NULL;
+ Anchor_ptr = Anchor_ptr->next) {
+ if (Anchor_ptr->number == anchor_number) {
+ result = from_top;
+ break;
+ }
+ if (!anchor_is_numbered(Anchor_ptr))
+ continue;
+ if (Anchor_ptr->line_num >= top_lineno) {
+ ++from_top;
+ }
+ }
+ return result;
+}
+
+/*
* HText_LinksInLines returns the number of links in the
* 'Lines' number of lines beginning with 'line_num'-1. -FM
*/
-int HText_LinksInLines(HText *text, int line_num,
+int HText_LinksInLines(HText *text,
+ int line_num,
int Lines)
{
int total = 0;
@@ -7137,8 +7278,6 @@ BOOL HText_select(HText *text)
*/
if (loaded_texts && HTList_removeObject(loaded_texts, text))
HTList_addObject(loaded_texts, text);
- /* let lynx do it */
- /* display_page(text, text->top_of_screen, ""); */
}
return YES;
}
@@ -7328,6 +7467,24 @@ int HText_getLines(HText *text)
return text->Lines;
}
+/*
+ * Constrain the line number to be within the document. The line number is
+ * zero-based.
+ */
+int HText_getPreferredTopLine(HText *text, int line_number)
+{
+ int last_screen = text->Lines - (display_lines - 2);
+
+ if (text->Lines < display_lines) {
+ line_number = 0;
+ } else if (line_number > text->Lines) {
+ line_number = last_screen;
+ } else if (line_number < 0) {
+ line_number = 0;
+ }
+ return line_number;
+}
+
HTAnchor *HText_linkSelTo(HText *me GCC_UNUSED,
HTAnchor * anchor GCC_UNUSED)
{
@@ -8356,9 +8513,8 @@ BOOLEAN HTreparse_document(void)
ok = (BOOL) (ret == HT_LOADED || ret == HT_PARTIAL_CONTENT);
CTRACE((tfp, "Reparse file %s\n", (ok ? "succeeded" : "failed")));
- }
- if (useMemoryCache()) {
+ } else if (useMemoryCache()) {
HTFormat format = WWW_HTML;
int ret;
@@ -8377,12 +8533,12 @@ BOOLEAN HTreparse_document(void)
format = HTAtom_for(HTMainAnchor->content_type);
} else {
/*
- * This is only done to make things aligned with SOURCE_CACHE_NONE and
- * SOURCE_CACHE_FILE when switching to source mode since the original
- * document's charset will be LYPushAssumed() and then LYPopAssumed().
- * See LYK_SOURCE in mainloop if you change something here. No
- * user-visible benefits, seems just '=' Info Page will show source's
- * effective charset as "(assumed)".
+ * This is only done to make things aligned with SOURCE_CACHE_NONE
+ * and SOURCE_CACHE_FILE when switching to source mode since the
+ * original document's charset will be LYPushAssumed() and then
+ * LYPopAssumed(). See LYK_SOURCE in mainloop if you change
+ * something here. No user-visible benefits, seems just '=' Info
+ * Page will show source's effective charset as "(assumed)".
*/
format = HTCharsetFormat(format, HTMainAnchor,
UCLYhndl_for_unspec);
@@ -9197,6 +9353,7 @@ char *HText_setLastOptionValue(HText *text, char *value,
if (!(value
&& text
&& text->last_anchor
+ && text->last_anchor->input_field
&& text->last_anchor->link_type == INPUT_ANCHOR)) {
CTRACE((tfp, "HText_setLastOptionValue: invalid call! value:%s!\n",
(value ? value : "<NULL>")));
@@ -9419,6 +9576,8 @@ char *HText_setLastOptionValue(HText *text, char *value,
/*
* Change the value.
*/
+ if (HTCurSelectedOptionValue == 0)
+ StrAllocCopy(HTCurSelectedOptionValue, "");
text->last_anchor->input_field->size =
strlen(HTCurSelectedOptionValue);
ret_Value = HTCurSelectedOptionValue;
@@ -9474,6 +9633,7 @@ int HText_beginInput(HText *text, BOOL underline,
if (a == NULL || f == NULL)
outofmem(__FILE__, "HText_beginInput");
+ a->sgml_offset = SGML_offset();
a->inUnderline = underline;
a->line_num = text->Lines;
a->line_pos = text->last_line->size;
@@ -12161,6 +12321,7 @@ static void insert_new_textarea_anchor(TextAnchor **curr_anchor, HTLine **exit_h
a->number = anchor->number;
a->line_pos = anchor->line_pos;
a->extent = anchor->extent;
+ a->sgml_offset = SGML_offset();
a->line_num = anchor->line_num + 1;
LYCopyHiText(a, anchor);
a->link_type = anchor->link_type;
@@ -12982,6 +13143,7 @@ int HText_InsertFile(LinkInfo * form_link)
a->number = anchor_ptr->number;
a->line_pos = anchor_ptr->line_pos;
a->extent = anchor_ptr->extent;
+ a->sgml_offset = SGML_offset();
a->line_num = anchor_ptr->line_num;
LYCopyHiText(a, anchor_ptr);
a->link_type = anchor_ptr->link_type;
@@ -13318,7 +13480,7 @@ static void redraw_part_of_line(HTLine *line, const char *str,
*
* Eventually the two sets of function should be unified, and should handle
* UTF-8 positioning, both lines of hypertext anchors, and WHEREIS in all
- * cases. If possible. The complex WHEREIS target logic in highlight()
+ * cases. If possible. The complex WHEREIS target logic in LYhighlight()
* could then be completely removed. - kw
*/
static void move_to_glyph(int YP,
@@ -13361,6 +13523,9 @@ static void move_to_glyph(int YP,
int len;
+ if (no_title)
+ YP -= TITLE_LINES;
+
if (flags & 1)
flag = YES;
if (flags & 2)
@@ -13862,18 +14027,17 @@ void LYMoveToLink(int cur,
move_to_glyph(links[cur].ly, links[cur].lx, XP_draw_min,
"", 0, links[cur].lx,
target, hightext, flags, utf_flag);
- /* LYmove(links[cur].ly, links[cur].lx); */
}
}
#endif /* !USE_COLOR_STYLE */
/*
- * 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 LYhighlight().
+ * This is used only if compiled with lss support. It's called to redraw a
+ * regular link when it's being unhighlighted in LYhighlight().
*/
+#ifdef USE_COLOR_STYLE
void redraw_lines_of_link(int cur GCC_UNUSED)
{
-#ifdef USE_COLOR_STYLE
#define pvtTITLE_HEIGHT 1
HTLine *todr1;
int lines_back;
@@ -13892,6 +14056,9 @@ void redraw_lines_of_link(int cur GCC_UNUSED)
todr1 = todr1->prev;
row = links[cur].ly;
+ if (no_title)
+ row -= TITLE_LINES;
+
for (count = 0;
row <= display_lines && (text = LYGetHiliteStr(cur, count)) != NULL;
++count) {
@@ -13901,11 +14068,9 @@ void redraw_lines_of_link(int cur GCC_UNUSED)
todr1 = todr1->next;
}
#undef pvtTITLE_HEIGHT
-#else
- /* no dead code ! */
-#endif
return;
}
+#endif
#ifdef USE_PRETTYSRC
void HTMark_asSource(void)
diff --git a/src/GridText.h b/src/GridText.h
index e5e2d44f..43fcd28f 100644
--- a/src/GridText.h
+++ b/src/GridText.h
@@ -82,6 +82,11 @@ US-ASCII control characters <32 which are not defined in Unicode standard
extern int HText_LinksInLines(HText *text, int line_num, int Lines);
+ extern int HText_getAbsLineNumber(HText *text, int anchor_number);
+ extern int HText_closestAnchor(HText *text, int offset);
+ extern int HText_locateAnchor(HText *text, int anchor_number);
+ extern int HText_anchorRelativeTo(HText *text, int top_lineno, int anchor_num);
+
extern void HText_setLastChar(HText *text, char ch);
extern char HText_getLastChar(HText *text);
extern void HText_setIgnoreExcess(HText *text, BOOL ignore);
@@ -163,6 +168,7 @@ US-ASCII control characters <32 which are not defined in Unicode standard
extern int HText_getMaximumColumn(HText *text);
extern int HText_getNumOfBytes(void);
extern int HText_getNumOfLines(void);
+ extern int HText_getPreferredTopLine(HText *text, int line_number);
extern int HText_getTabIDColumn(HText *text, const char *name);
extern int HText_getTopOfScreen(void);
extern int do_www_search(DocInfo *doc);
diff --git a/src/HTAlert.c b/src/HTAlert.c
index a733c5ca..21dfd04c 100644
--- a/src/HTAlert.c
+++ b/src/HTAlert.c
@@ -792,7 +792,7 @@ BOOL HTConfirmCookie(domain_entry * de, const char *server,
char *message = 0;
space_free = (LYcolLimit
- - (strlen(prompt)
+ - (LYstrCells(prompt)
- 10) /* %s and %.*s and %.*s chars */
-strlen(server));
if (space_free < 0)
diff --git a/src/HTML.c b/src/HTML.c
index 821fd3e6..b0c1d47f 100644
--- a/src/HTML.c
+++ b/src/HTML.c
@@ -100,6 +100,7 @@ struct _HTStream {
FILE *fp;
char *filename;
HTChunk *chunk;
+ HTChunk *last_chunk; /* the last chunk in a chain! */
const HTStreamClass *actions;
HTStream *target;
int status;
@@ -7645,6 +7646,8 @@ HTStructured *HTML_new(HTParentAnchor *anchor,
HTStructured *me;
+ CTRACE((tfp, "start HTML_new\n"));
+
if (format_out != WWW_PLAINTEXT && format_out != WWW_PRESENT) {
HTStream *intermediate = HTStreamStack(WWW_HTML, format_out,
stream, anchor);
@@ -7878,7 +7881,7 @@ static void CacheThru_do_free(HTStream *me)
CTRACE((tfp, "SourceCacheWriter: memory chunk %p had errors.\n",
me->chunk));
HTChunkFree(me->chunk);
- me->chunk = NULL;
+ me->chunk = me->last_chunk = NULL;
}
HTAlert(gettext("Source cache error - not enough memory!"));
}
@@ -7926,45 +7929,50 @@ static void CacheThru_abort(HTStream *me, HTError e)
FREE(me);
}
+/*
+ * FIXME: never used!
+ */
static void CacheThru_put_character(HTStream *me, char c_in)
{
if (me->status == HT_OK) {
if (me->fp) {
fputc(c_in, me->fp);
} else if (me->chunk) {
- HTChunkPutc(me->chunk, c_in);
- if (me->chunk->allocated == 0)
+ me->last_chunk = HTChunkPutc2(me->last_chunk, c_in);
+ if (me->last_chunk == NULL || me->last_chunk->allocated == 0)
me->status = HT_ERROR;
}
}
(*me->actions->put_character) (me->target, c_in);
}
+/*
+ * FIXME: never used!
+ */
static void CacheThru_put_string(HTStream *me, const char *str)
{
if (me->status == HT_OK) {
if (me->fp) {
fputs(str, me->fp);
} else if (me->chunk) {
- HTChunkPuts(me->chunk, str);
- if (me->chunk->allocated == 0 && *str)
+ me->last_chunk = HTChunkPuts2(me->last_chunk, str);
+ if (me->last_chunk == NULL || me->last_chunk->allocated == 0)
me->status = HT_ERROR;
}
}
(*me->actions->put_string) (me->target, str);
}
-static void CacheThru_write(HTStream *me, const char *str,
- int l)
+static void CacheThru_write(HTStream *me, const char *str, int l)
{
- if (me->status == HT_OK) {
+ if (me->status == HT_OK && l != 0) {
if (me->fp) {
fwrite(str, 1, l, me->fp);
if (ferror(me->fp))
me->status = HT_ERROR;
} else if (me->chunk) {
- HTChunkPutb(me->chunk, str, l);
- if (me->chunk->allocated == 0 && l != 0)
+ me->last_chunk = HTChunkPutb2(me->last_chunk, str, l);
+ if (me->last_chunk == NULL || me->last_chunk->allocated == 0)
me->status = HT_ERROR;
}
}
@@ -8000,13 +8008,15 @@ static HTStream *CacheThru_new(HTParentAnchor *anchor,
/* oh, assume http protocol: */
if (strcmp(p->name, "http") != 0
&& strcmp(p->name, "https") != 0) {
- CTRACE((tfp, "SourceCacheWriter: Protocol is \"%s\"; not caching\n", p->name));
+ CTRACE((tfp, "SourceCacheWriter: Protocol is \"%s\"; not cached\n", p->name));
return target;
}
#else
/* all HTStreams will be cached */
#endif
+ CTRACE((tfp, "start CacheThru_new\n"));
+
stream = (HTStream *) malloc(sizeof(*stream));
if (!stream)
outofmem(__FILE__, "CacheThru_new");
@@ -8058,11 +8068,7 @@ static HTStream *CacheThru_new(HTParentAnchor *anchor,
"SourceCacheWriter: If successful, will replace memory chunk %p\n",
(void *) anchor->source_cache_chunk));
}
-#ifdef SAVE_TIME_NOT_SPACE
- stream->chunk = HTChunkCreateMayFail(4096, 1);
-#else
- stream->chunk = HTChunkCreateMayFail(128, 1);
-#endif
+ stream->chunk = stream->last_chunk = HTChunkCreateMayFail(4096, 1);
if (!stream->chunk) /* failed already? pretty bad... - kw */
stream->status = HT_ERROR;
diff --git a/src/LYCurses.c b/src/LYCurses.c
index 9221ff82..0cbee711 100644
--- a/src/LYCurses.c
+++ b/src/LYCurses.c
@@ -411,12 +411,12 @@ static void LYAttrset(WINDOW * win, int color,
if (lynx_has_color
&& LYShowColor >= SHOW_COLOR_ON
&& color >= 0) {
- CTRACE2(TRACE_STYLE, (tfp, "CSS:LYAttrset color (%s)\n",
- attr_to_string(color)));
+ CTRACE2(TRACE_STYLE, (tfp, "CSS:LYAttrset color %#x -> (%s)\n",
+ color, attr_to_string(color)));
wattrset(win, color);
} else if (mono >= 0) {
- CTRACE2(TRACE_STYLE, (tfp, "CSS:LYAttrset mono (%s)\n",
- attr_to_string(mono)));
+ CTRACE2(TRACE_STYLE, (tfp, "CSS:LYAttrset mono %#x -> (%s)\n",
+ mono, attr_to_string(mono)));
wattrset(win, mono);
} else {
CTRACE2(TRACE_STYLE, (tfp, "CSS:LYAttrset (A_NORMAL)\n"));
@@ -450,14 +450,14 @@ void curses_w_style(WINDOW * win, int style,
#endif
}
- CTRACE2(TRACE_STYLE, (tfp, "CSS.CS:<%s%s> (%d)\n",
+ CTRACE2(TRACE_STYLE, (tfp, "CSS.CS:<%s%s> code %#x, color %#x\n",
(dir ? "" : "/"),
- ds->name, ds->code));
+ ds->name, ds->code, ds->color));
getyx(win, YP, XP);
if (style == s_normal && dir) {
- wattrset(win, A_NORMAL);
+ LYAttrset(win, ds->color, ds->mono);
if (win == LYwin)
cached_styles[YP][XP] = s_normal;
return;
@@ -723,8 +723,7 @@ static void lynx_map_color(int n)
*/
int lynx_chg_color(int color,
int fg,
- int bg
-)
+ int bg)
{
if (fg == ERR_COLOR || bg == ERR_COLOR)
return -1;
@@ -1609,7 +1608,7 @@ void LYpaddstr(WINDOW * the_window, int width,
}
/*
- * Workaround a bug in ncurses order-of-refresh by setting a pointer to
+ * Work around limitation of curses's order-of-refresh by setting a pointer to
* the topmost window that should be displayed.
*
* FIXME: the associated call on 'keypad()' is not needed for Unix, but
@@ -1623,9 +1622,16 @@ void LYsubwindow(WINDOW * param)
my_subwindow = param;
#if defined(NCURSES) || defined(PDCURSES)
keypad(my_subwindow, TRUE);
-#if defined(HAVE_GETBKGD) /* not defined in ncurses 1.8.7 */
+#if defined(USE_COLOR_STYLE)
+ LynxWChangeStyle(my_subwindow, s_menu_bg, STACK_ON);
+ {
+ long b = LYgetattrs(my_subwindow);
+
+ wbkgd(my_subwindow, b | ' ');
+ }
+ LynxWChangeStyle(my_subwindow, s_menu_bg, STACK_OFF);
+#elif defined(HAVE_GETBKGD) /* not defined in ncurses 1.8.7 */
wbkgd(my_subwindow, getbkgd(LYwin));
- wbkgdset(my_subwindow, getbkgd(LYwin));
#endif
#endif
scrollok(my_subwindow, TRUE);
@@ -1674,22 +1680,6 @@ WINDOW *LYstartPopup(int *top_y,
HTAlert(POPUP_FAILED);
} else {
LYsubwindow(form_window);
-# ifdef USE_COLOR_STYLE
- {
- long b;
-
- /* Get a proper value for the attribute */
- LynxWChangeStyle(form_window, s_menu_bg, STACK_ON);
- b = LYgetattrs(form_window);
- LynxWChangeStyle(form_window, s_menu_bg, STACK_OFF);
- wbkgd(form_window, b | ' ');
- /* wbkgdset does not make a lot of sense with USE_COLOR_STYLE
- since it *forces* attributes on all the cells in the window.
- Undo the change done in LYsubwindow, since we set our styles.
- */
- wbkgdset(form_window, (b & ~(A_BOLD | A_BLINK)) | ' ');
- }
-# endif
}
#endif /* USE_SLANG */
return form_window;
@@ -1760,6 +1750,46 @@ void LYwaddnstr(WINDOW * w GCC_UNUSED,
const char *src,
size_t len)
{
+#ifdef USE_CURSES_PADS
+ /*
+ * If we've configured to use pads for left/right scrolling, that can
+ * interfere with calls to this function that assume they're wrapping.
+ * Writing to a pad which is wider than the screen will simply not wrap.
+ *
+ * Link-highlighting uses wrapping. You can see this by viewing the
+ * options screen in a terminal which is narrower than 80 columns.
+ *
+ * Check for that case, and split up the call into segments for each line.
+ */
+ int y0, x0;
+
+ getyx(LYwin, y0, x0);
+
+ if (LYuseCursesPads
+ && LYshiftWin == 0
+ && LYwideLines == FALSE
+ && ((int) len > (LYcolLimit - x0))) {
+ int start = 0;
+ int piece = (LYcolLimit - x0);
+
+ CTRACE((tfp, "LYwaddnstr wrapping src:%s, len:%d:%d\n", src, len, LYcolLimit));
+ for (;;) {
+ int y, x;
+
+ getyx(LYwin, y, x);
+ CTRACE((tfp, "piece src:%.*s, len:%d\n", piece, src + start, piece));
+ LYwaddnstr(w, src + start, piece);
+ start += piece;
+ if (start >= (int) len)
+ break;
+ LYmove(y + 1, 0);
+ piece = LYcolLimit;
+ if ((start + piece) > (int) len)
+ piece = len - start;
+ }
+ return;
+ }
+#endif
/*
* We only want to trace this function for the color-style code. It would
* be too much logging if not needed.
@@ -1774,116 +1804,6 @@ void LYwaddnstr(WINDOW * w GCC_UNUSED,
}
#endif
/*
- * Wide (multibyte) characters are always written as part of a string. So
- * we can handle the conversion in one place.
- *
- * X/Open curses documents addstr() as able to handle multibyte sequences
- * directly, but that is not (2001/11/5) yet implemented in ncurses. Two
- * alternatives are possible: translating the string to an array of
- * wchar_t's or to an array of cchar_t's. The former is more direct. Both
- * have problems with combining-characters in this version of ncurses
- * (successive calls are not merged), so I'm using them for testing -TD
- */
-#if 0 /* defined(WIDEC_CURSES) && defined(HAVE_MBSTATE_T) */
-#if 1 /* array of wchar_t's */
- {
- static wchar_t *temp = 0;
- static size_t used = 0;
-
- wchar_t wch;
- int l = 0;
- mbstate_t state;
- size_t rc;
- int width;
- unsigned j;
- size_t need;
-
- memset(&state, 0, sizeof(state));
- need = 1 + len;
- if (need > used) {
- used = 2 * need;
- CTRACE((tfp, "allocated %d (%d)\n", used, len));
- FREE(temp);
- temp = typecallocn(wchar_t, used);
- }
- for (j = 0; j < len; j++) {
- rc = mbrtowc(&wch, src + j, len - j, &state);
- if (rc == 0 || rc == (size_t) (-1) || rc == (size_t) (-2))
- break;
- j += rc - 1;
- if ((width = wcwidth(wch)) < 0)
- break;
- temp[l++] = wch;
- }
- temp[l] = L'\0';
- waddnwstr(w, temp, l);
-#ifdef LY_FIND_LEAKS
- FREE(temp);
- used = 0;
-#endif
- }
-#else /* array of cchar_t's */
- {
- static cchar_t *temp = 0;
- static size_t used = 0;
-
- wchar_t wch;
- wchar_t wstr[CCHARW_MAX + 1];
- int l = 0;
- mbstate_t state;
- size_t rc;
- int width;
- int y, x;
- unsigned j, k;
- size_t need;
- attr_t attr;
- short pair;
-
- wattr_get(w, &attr, &pair, (void *) 0);
-
- memset(&state, 0, sizeof(state));
- need = 1 + len;
- if (need > used) {
- used = 2 * need;
- CTRACE((tfp, "allocated %d (%d)\n", used, len));
- FREE(temp);
- temp = typecallocn(cchar_t, used);
- }
- for (j = k = 0; j < len; j++) {
- rc = mbrtowc(&wch, src + j, len - j, &state);
- if (rc == 0 || rc == (size_t) (-1) || rc == (size_t) (-2))
- break;
- j += rc - 1;
- if ((width = wcwidth(wch)) < 0)
- break;
- if ((width > 0 && l > 0) || l == CCHARW_MAX) {
- wstr[l] = L'\0';
- l = 0;
- if (setcchar(temp + k, wstr, attr, 0, NULL) != OK)
- break;
- ++k;
- }
- if (width == 0 && l == 0)
- wstr[l++] = L' ';
- wstr[l++] = wch;
- }
- if (l > 0) {
- wstr[l] = L'\0';
- if (setcchar(temp + k, wstr, attr, 0, NULL) == OK)
- ++k;
- }
- setcchar(temp + k, L"", 0, 0, NULL);
- wadd_wchnstr(w, temp, k);
- getyx(w, y, x); /* we didn't move - do it now */
- wmove(w, y, x + k);
-#ifdef LY_FIND_LEAKS
- FREE(temp);
- used = 0;
-#endif
- }
-#endif
-#else
- /*
* There's no guarantee that a library won't temporarily write on its input.
* Be safe and copy it when we have const-data.
*/
@@ -1896,7 +1816,6 @@ void LYwaddnstr(WINDOW * w GCC_UNUSED,
waddstr(w, temp);
len -= use;
}
-#endif
}
/*
@@ -2476,6 +2395,20 @@ int LYscreenWidth(void)
}
/*
+ * Set the window's background color (make the pad's color agree), e.g., when
+ * we have just parsed it from the config file, or after clearing the screen.
+ */
+void LYnormalColor(void)
+{
+#if defined(USE_COLOR_STYLE) && USE_CURSES_PADS
+ if (LYwin != stdscr) {
+ wbkgd(LYwin, displayStyles[DSTYLE_NORMAL].color | ' ');
+ LYrefresh();
+ }
+#endif
+}
+
+/*
* The functions ifdef'd with USE_CURSES_PADS are implemented that way so we
* don't break the slang configuration.
*/
@@ -2486,6 +2419,7 @@ void LYclear(void)
#else
clear();
#endif
+ LYnormalColor();
}
void LYclrtoeol(void)
@@ -2504,6 +2438,7 @@ void LYerase(void)
#else
erase();
#endif
+ LYnormalColor();
}
void LYmove(int y, int x)
@@ -2750,13 +2685,13 @@ void lynx_stop_underline(void)
* the current option's highlighting or color without the distraction of a
* blinking cursor in the window. - FM
*/
-void LYstowCursor(WINDOW * win, int row,
- int col)
+void LYstowCursor(WINDOW * win, int row, int col)
{
- if (LYShowCursor)
+ if (LYShowCursor) {
wmove(win, row, col);
- else
+ } else {
LYHideCursor();
+ }
#ifdef USE_SLANG
SLsmg_refresh();
#else
@@ -2794,6 +2729,10 @@ long LYgetattrs(WINDOW * win)
attr_t result = 0;
short pair = 0;
+ /*
+ * FIXME: this ignores the color-pair, which for most implementations is
+ * not stored in the attribute value.
+ */
wattr_get(win, &result, &pair, NULL);
#endif
return result;
diff --git a/src/LYCurses.h b/src/LYCurses.h
index f9c52fe3..a632bac0 100644
--- a/src/LYCurses.h
+++ b/src/LYCurses.h
@@ -422,6 +422,7 @@ extern "C" {
extern void LYerase(void);
extern void LYmove(int y, int x);
extern void LYnoVideo(int mask);
+ extern void LYnormalColor(void);
extern void LYpaddstr(WINDOW * w, int width, const char *s);
extern void LYrefresh(void);
extern void LYstartTargetEmphasis(void);
@@ -432,8 +433,6 @@ extern "C" {
extern void stop_curses(void);
#define LYaddstr(s) LYwaddnstr(LYwin, s, strlen(s))
-#define LYaddnstr(s,len) LYwaddnstr(LYwin, s, len)
-#define LYwaddstr(w,s) LYwaddnstr(w, s, strlen(s))
#ifdef VMS
extern int DCLsystem(char *command);
@@ -755,9 +754,9 @@ FANCY_CURSES. Check your config.log to see why the FANCY_CURSES test failed.
* Adjust our "hidden" cursor position accordingly.
*/
#if defined(FANCY_CURSES) || defined(USE_SLANG)
-#define LYHideCursor() LYmove((LYlines - 1), (LYcolLimit))
-#else
#define LYHideCursor() LYmove((LYlines - 1), (LYcolLimit - 1))
+#else
+#define LYHideCursor() LYmove((LYlines - 1), (LYcolLimit - 2))
#endif
extern void LYstowCursor(WINDOW * win, int row, int col);
diff --git a/src/LYGlobalDefs.h b/src/LYGlobalDefs.h
index 5b4e43d5..3f8f32e5 100644
--- a/src/LYGlobalDefs.h
+++ b/src/LYGlobalDefs.h
@@ -186,6 +186,8 @@ extern "C" {
# define rateEtaKB_maybe rateKB
#endif
+#define TITLE_LINES 1
+
extern BOOLEAN LYCursesON; /* start_curses()->TRUE, stop_curses()->FALSE */
extern BOOLEAN LYJumpFileURL; /* URL from the jump file shortcuts? */
extern BOOLEAN LYNewsPosting; /* News posting supported if TRUE */
@@ -357,6 +359,8 @@ extern "C" {
extern char *LYLocalDomain;
extern BOOLEAN use_underscore;
extern BOOLEAN no_list;
+ extern BOOLEAN no_margins;
+ extern BOOLEAN no_title;
extern BOOLEAN historical_comments;
extern BOOLEAN minimal_comments;
extern BOOLEAN soft_dquotes;
diff --git a/src/LYKeymap.c b/src/LYKeymap.c
index f794a828..a9e41625 100644
--- a/src/LYKeymap.c
+++ b/src/LYKeymap.c
@@ -1192,7 +1192,7 @@ int LYStringToKeycode(char *src)
char *dst = 0;
key = strtol(src, &dst, 0);
- if (isEmpty(dst))
+ if (!isEmpty(dst))
key = -1;
} else if (len > 6 && !strncasecomp(src, "key-", 4)) {
char *dst = 0;
diff --git a/src/LYMain.c b/src/LYMain.c
index 05b9b570..f5e8b353 100644
--- a/src/LYMain.c
+++ b/src/LYMain.c
@@ -380,6 +380,8 @@ BOOLEAN keep_mime_headers = FALSE; /* Include mime headers with source dump */
BOOLEAN more = FALSE; /* is there more text to display? */
BOOLEAN more_links = FALSE; /* Links beyond a displayed page with no links? */
BOOLEAN no_list = FALSE;
+BOOLEAN no_margins = FALSE;
+BOOLEAN no_title = FALSE;
BOOLEAN no_url_redirection = FALSE; /* Don't follow URL redirections */
BOOLEAN pseudo_inline_alts = MAKE_PSEUDO_ALTS_FOR_INLINES;
BOOLEAN scan_for_buried_news_references = TRUE;
@@ -3581,6 +3583,10 @@ keys (may be incompatible with some curses packages)"
"nolog", 4|UNSET_ARG, error_logging,
"disable mailing of error messages to document owners"
),
+ PARSE_SET(
+ "nomargins", 4|SET_ARG, no_margins,
+ "disable the right/left margins in the default style-sheet"
+ ),
#if defined(HAVE_SIGACTION) && defined(SIGWINCH)
PARSE_SET(
"nonrestarting_sigwinch", 4|SET_ARG, LYNonRestartingSIGWINCH,
@@ -3621,6 +3627,10 @@ keys (may be incompatible with some curses packages)"
"nostatus", 4|SET_ARG, no_statusline,
"disable the miscellaneous information messages"
),
+ PARSE_SET(
+ "notitle", 4|SET_ARG, no_title,
+ "disable the title at the top of each page"
+ ),
PARSE_FUN(
"nounderline", 4|FUNCTION_ARG, nounderline_fun,
"disable underline video-attribute"
@@ -4047,8 +4057,8 @@ static int arg_eqs_parse(const char *a,
return result;
}
-#define is_true(s) (*s == '1' || *s == '+' || !strcmp(s, "on"))
-#define is_false(s) (*s == '0' || *s == '-' || !strcmp(s, "off"))
+#define is_true(s) (*s == '1' || *s == '+' || !strcasecomp(s, "on") || !strcasecomp(s, "true"))
+#define is_false(s) (*s == '0' || *s == '-' || !strcasecomp(s, "off") || !strcasecomp(s, "false"))
/*
* Parse an option.
diff --git a/src/LYMainLoop.c b/src/LYMainLoop.c
index e43a35ed..38eedf3c 100644
--- a/src/LYMainLoop.c
+++ b/src/LYMainLoop.c
@@ -389,10 +389,13 @@ void LYSetNewline(int value)
Newline = value;
}
+#define LYSetNewline(value) Newline = value
+
int LYGetNewline(void)
{
return Newline;
}
+#define LYGetNewline() Newline
#ifdef USE_SOURCE_CACHE
static BOOLEAN from_source_cache = FALSE;
@@ -402,15 +405,15 @@ static BOOLEAN from_source_cache = FALSE;
*/
static BOOLEAN reparse_document(void)
{
- BOOLEAN ok;
+ BOOLEAN result;
from_source_cache = TRUE; /* set for LYMainLoop_pageDisplay() */
- if ((ok = HTreparse_document()) != FALSE) {
+ if ((result = HTreparse_document()) != FALSE) {
from_source_cache = TRUE; /* set for mainloop refresh */
- return ok;
+ } else {
+ from_source_cache = FALSE;
}
- from_source_cache = FALSE;
- return ok;
+ return result;
}
#endif /* USE_SOURCE_CACHE */
@@ -463,13 +466,13 @@ static void move_address(DocInfo *dst, DocInfo *src)
BOOL LYMainLoop_pageDisplay(int line_num)
{
const char *pound;
- int prev_newline = Newline;
+ int prev_newline = LYGetNewline();
/*
* Override Newline with a new value if user scrolled the document while
* loading (in LYUtils.c).
*/
- Newline = line_num;
+ LYSetNewline(line_num);
#ifdef USE_SOURCE_CACHE
/*
@@ -494,14 +497,14 @@ BOOL LYMainLoop_pageDisplay(int line_num)
&& *pound && *(pound + 1)) {
if (HTFindPoundSelector(pound + 1)) {
/* HTFindPoundSelector will initialize www_search_result */
- Newline = www_search_result;
+ LYSetNewline(www_search_result);
} else {
- Newline = prev_newline; /* restore ??? */
+ LYSetNewline(prev_newline); /* restore ??? */
return NO; /* no repaint */
}
}
- HText_pageDisplay(Newline, prev_target);
+ HText_pageDisplay(LYGetNewline(), prev_target);
return YES;
}
#endif /* DISP_PARTIAL */
@@ -2233,14 +2236,14 @@ static void handle_LYK_DOWN_LINK(int *follow_col,
if (newlink > -1) {
set_curdoc_link(newlink);
} else if (more) { /* next page */
- Newline += (display_lines);
+ Newline += display_lines;
} else if (*old_c != real_c) {
*old_c = real_c;
HTUserMsg(NO_LINKS_BELOW);
return;
}
} else if (more) { /* next page */
- Newline += (display_lines);
+ Newline += display_lines;
} else if (*old_c != real_c) {
*old_c = real_c;
@@ -2413,7 +2416,7 @@ static void handle_LYK_EDIT(int *old_c,
if (S_ISREG(dir_info.st_mode)) {
StrAllocCopy(tp, links[curdoc.link].lname);
HTUnEscapeSome(tp, "/");
- if (edit_current_file(tp, curdoc.link, Newline)) {
+ if (edit_current_file(tp, curdoc.link, LYGetNewline())) {
DIRED_UNCACHE_1;
move_address(&newdoc, &curdoc);
#ifdef NO_SEEK_OLD_POSITION
@@ -2439,7 +2442,7 @@ static void handle_LYK_EDIT(int *old_c,
} else
#endif /* DIRED_SUPPORT */
if (non_empty(editor)) {
- if (edit_current_file(newdoc.address, curdoc.link, Newline)) {
+ if (edit_current_file(newdoc.address, curdoc.link, LYGetNewline())) {
HTuncache_current_document();
LYforce_no_cache = TRUE; /*force reload of document */
free_address(&curdoc); /* so it doesn't get pushed */
@@ -2517,7 +2520,8 @@ static void handle_LYK_EDIT_TEXTAREA(BOOLEAN *refresh_screen,
* the approximate center of the screen.
*/
-/* curdoc.link += n; *//* works, except for page crossing, */
+ /* curdoc.link += n; */
+ /* works, except for page crossing, */
/* damnit; why is nothing ever easy */
/* start screen */
@@ -2648,6 +2652,7 @@ static BOOLEAN handle_LYK_FASTBACKW_LINK(int *cmd,
{
int samepage = 0, nextlink = curdoc.link;
int res;
+ int code = FALSE;
if (nlinks > 1) {
@@ -2674,7 +2679,7 @@ static BOOLEAN handle_LYK_FASTBACKW_LINK(int *cmd,
sametext(links[nextlink].l_form->name, thisname));
samepage = 1;
- } else if (!more && Newline == 1 &&
+ } else if (!more && LYGetNewline() == 1 &&
(links[0].type == WWW_FORM_LINK_TYPE &&
links[0].l_form->type == F_TEXTAREA_TYPE &&
links[0].l_form->number == thisgroup &&
@@ -2686,18 +2691,19 @@ static BOOLEAN handle_LYK_FASTBACKW_LINK(int *cmd,
nextlink = nlinks - 1;
samepage = 1;
- } else if (!more && Newline == 1 && curdoc.link > 0) {
+ } else if (!more && LYGetNewline() == 1 && curdoc.link > 0) {
nextlink = 0;
samepage = 1;
}
} else if (curdoc.link > 0) {
nextlink--;
samepage = 1;
- } else if (!more && Newline == 1) {
+ } else if (!more && LYGetNewline() == 1) {
nextlink = nlinks - 1;
samepage = 1;
}
}
+
if (samepage) {
/*
* If the link as determined so far is part of a group of textarea
@@ -2726,9 +2732,8 @@ static BOOLEAN handle_LYK_FASTBACKW_LINK(int *cmd,
}
}
set_curdoc_link(nextlink);
- return FALSE; /* and we are done. */
- } else if (Newline > 1 && /* need a previous page */
+ } else if (LYGetNewline() > 1 && /* need a previous page */
(res = HTGetLinkOrFieldStart(curdoc.link,
&Newline, &newdoc.link,
-1, TRUE)) != NO) {
@@ -2740,16 +2745,15 @@ static BOOLEAN handle_LYK_FASTBACKW_LINK(int *cmd,
if (nlinks > 0)
curdoc.link = 0;
*cmd = LYK_PREV_LINK;
- return TRUE;
+ code = TRUE;
+ } else {
+ Newline++; /* our line counting starts with 1 not 0 */
}
- Newline++; /* our line counting starts with 1 not 0 */
- /* nothing more to do here */
-
} else if (*old_c != real_c) {
*old_c = real_c;
HTInfoMsg(NO_LINKS_ABOVE);
}
- return FALSE;
+ return code;
}
static void handle_LYK_FASTFORW_LINK(int *old_c,
@@ -2781,27 +2785,26 @@ static void handle_LYK_FASTFORW_LINK(int *old_c,
links[nextlink].l_form->number == thisgroup &&
sametext(links[nextlink].l_form->name, thisname));
samepage = 1;
- } else if (!more && Newline == 1 && curdoc.link > 0) {
+ } else if (!more && LYGetNewline() == 1 && curdoc.link > 0) {
nextlink = 0;
samepage = 1;
}
} else if (curdoc.link < nlinks - 1) {
nextlink++;
samepage = 1;
- } else if (!more && Newline == 1 && curdoc.link > 0) {
+ } else if (!more && LYGetNewline() == 1 && curdoc.link > 0) {
nextlink = 0;
samepage = 1;
}
}
+
if (samepage) {
set_curdoc_link(nextlink);
- return; /* and we are done. */
-
+ } else if (!more && LYGetNewline() == 1 && curdoc.link == nlinks - 1) {
/*
* At the bottom of list and there is only one page. Move to the top
* link on the page.
*/
- } else if (!more && Newline == 1 && curdoc.link == nlinks - 1) {
set_curdoc_link(0);
} else if (more && /* need a later page */
@@ -3215,7 +3218,7 @@ static void handle_LYK_INDEX_SEARCH(BOOLEAN *force_load,
StrAllocCopy(newdoc.post_content_type, curdoc.post_content_type);
newdoc.internal_link = FALSE;
curdoc.line = -1;
- Newline = 0;
+ LYSetNewline(0);
} else if (use_this_url_instead != NULL) {
/*
* Got back a redirecting URL. Check it out.
@@ -3824,11 +3827,11 @@ static void handle_LYK_NEXT_LINK(int c,
* At the bottom of list and there is only one page. Move to the top
* link on the page.
*/
- } else if (!more && Newline == 1 && curdoc.link == nlinks - 1) {
+ } else if (!more && LYGetNewline() == 1 && curdoc.link == nlinks - 1) {
set_curdoc_link(0);
} else if (more) { /* next page */
- Newline += (display_lines);
+ Newline += display_lines;
} else if (*old_c != real_c) {
*old_c = real_c;
@@ -3878,7 +3881,7 @@ static void handle_LYK_PREV_LINK(int *arrowup,
set_curdoc_link(curdoc.link - 1);
} else if (!more &&
- curdoc.link == 0 && Newline == 1) { /* at the top of list */
+ curdoc.link == 0 && LYGetNewline() == 1) { /* at the top of list */
/*
* If there is only one page of data and the user goes off the top,
* just move the cursor to last link on the page.
@@ -3889,8 +3892,9 @@ static void handle_LYK_PREV_LINK(int *arrowup,
/*
* Go back to the previous page.
*/
- int scrollamount = (Newline > display_lines ?
- display_lines : Newline - 1);
+ int scrollamount = (LYGetNewline() > display_lines
+ ? display_lines
+ : LYGetNewline() - 1);
Newline -= scrollamount;
if (scrollamount < display_lines &&
@@ -4020,7 +4024,7 @@ static int handle_PREV_DOC(int *cmd,
static void handle_LYK_PREV_PAGE(int *old_c,
int real_c)
{
- if (Newline > 1) {
+ if (LYGetNewline() > 1) {
Newline -= display_lines;
} else if (curdoc.link > 0) {
set_curdoc_link(0);
@@ -4239,15 +4243,84 @@ static void handle_LYK_SOFT_DQUOTES(void)
return;
}
+#define GetAnchorNumber(link) \
+ ((nlinks > 0 && link >= 0) \
+ ? links[link].anchor_number \
+ : -1)
+#define GetAnchorLineNo(link) \
+ ((nlinks > 0 && link >= 0) \
+ ? links[link].anchor_line_num \
+ : -1)
+
+/*
+ * Adjust the top-of-screen line number for the new document if the redisplayed
+ * screen would not show the given link-number.
+ */
+#ifdef USE_SOURCE_CACHE
+static int wrap_reparse_document(void)
+{
+ int result;
+ int anchor_number = GetAnchorNumber(curdoc.link);
+ int old_line_num = HText_getAbsLineNumber(HTMainText, anchor_number);
+ int old_from_top = old_line_num - LYGetNewline() + 1;
+
+ /* get the offset for the current anchor */
+ int old_offset = ((nlinks > 0 && curdoc.link >= 0)
+ ? links[curdoc.link].sgml_offset
+ : -1);
+
+ CTRACE((tfp, "original anchor %d, topline %d, link %d, offset %d\n",
+ anchor_number, old_line_num, curdoc.link, old_offset));
+
+ /* reparse the document (producing a new anchor list) */
+ result = reparse_document();
+
+ /* readjust top-line and link-number */
+ if (result && old_offset >= 0) {
+ int new_anchor = HText_closestAnchor(HTMainText, old_offset);
+ int new_lineno = HText_getAbsLineNumber(HTMainText, new_anchor);
+ int top_lineno;
+
+ CTRACE((tfp, "old anchor %d -> new anchor %d\n", anchor_number, new_anchor));
+
+ if (new_lineno - old_from_top < 0)
+ old_from_top = new_lineno;
+
+ /* Newline and newdoc.line are 1-based,
+ * but 0-based lines are simpler to work with.
+ */
+ top_lineno = HText_getPreferredTopLine(HTMainText, new_lineno -
+ old_from_top) + 1;
+ CTRACE((tfp, "preferred top %d\n", top_lineno));
+
+ if (top_lineno != LYGetNewline()) {
+ LYSetNewline(top_lineno);
+ newdoc.link = HText_anchorRelativeTo(HTMainText, top_lineno - 1, new_anchor);
+ curdoc.link = newdoc.link;
+ CTRACE((tfp,
+ "adjusted anchor %d, topline %d, link %d, offset %d\n",
+ new_anchor,
+ top_lineno,
+ curdoc.link,
+ HText_locateAnchor(HTMainText, new_anchor)));
+ } else {
+ newdoc.link = curdoc.link;
+ }
+ }
+ return result;
+}
+#endif /* USE_SOURCE_CACHE */
+
static void handle_LYK_SOURCE(char **ownerS_address_p)
{
+#ifdef USE_SOURCE_CACHE
+ BOOLEAN canreparse_post = FALSE;
+#endif
+
/*
* Check if this is a reply from a POST, and if so,
* seek confirmation if the safe element is not set. - FM
*/
-#ifdef USE_SOURCE_CACHE
- BOOLEAN canreparse_post = FALSE;
-#endif
if ((curdoc.post_data != NULL &&
curdoc.safe != TRUE) &&
#ifdef USE_SOURCE_CACHE
@@ -4269,7 +4342,7 @@ static void handle_LYK_SOURCE(char **ownerS_address_p)
}
#ifdef USE_SOURCE_CACHE
- if (reparse_document()) {
+ if (wrap_reparse_document()) {
/*
* These normally get cleaned up after getfile() returns;
* since we're not calling getfile(), we have to clean them
@@ -4295,6 +4368,7 @@ static void handle_LYK_SOURCE(char **ownerS_address_p)
if (curdoc.title)
StrAllocCopy(newdoc.title, curdoc.title);
+
free_address(&curdoc); /* so it doesn't get pushed */
LYforce_no_cache = TRUE;
}
@@ -4398,7 +4472,7 @@ static void handle_LYK_TAG_LINK(void)
}
if (curdoc.link < nlinks - 1) {
set_curdoc_link(curdoc.link + 1);
- } else if (!more && Newline == 1 && curdoc.link == nlinks - 1) {
+ } else if (!more && LYGetNewline() == 1 && curdoc.link == nlinks - 1) {
set_curdoc_link(0);
} else if (more) { /* next page */
Newline += (display_lines);
@@ -4516,17 +4590,17 @@ static void handle_LYK_UP_HALF(int *arrowup,
int *old_c,
int real_c)
{
- if (Newline > 1) {
+ if (LYGetNewline() > 1) {
int scrollamount = display_lines / 2;
- if (Newline - scrollamount < 1)
- scrollamount = Newline - 1;
+ if (LYGetNewline() - scrollamount < 1)
+ scrollamount = LYGetNewline() - 1;
Newline -= scrollamount;
if (nlinks > 0 && curdoc.link > -1) {
if (links[curdoc.link].ly + scrollamount <= display_lines) {
newdoc.link = curdoc.link +
HText_LinksInLines(HTMainText,
- Newline,
+ LYGetNewline(),
scrollamount);
} else {
*arrowup = TRUE;
@@ -4545,7 +4619,7 @@ static void handle_LYK_UP_LINK(int *follow_col,
{
if (curdoc.link > 0 &&
(links[0].ly != links[curdoc.link].ly ||
- !HText_LinksInLines(HTMainText, 1, Newline - 1))) {
+ !HText_LinksInLines(HTMainText, 1, LYGetNewline() - 1))) {
/* more links before this on screen, and first of them on
a different line or no previous links before this screen? */
int newlink;
@@ -4567,9 +4641,10 @@ static void handle_LYK_UP_LINK(int *follow_col,
HTUserMsg(NO_LINKS_ABOVE);
}
- } else if (curdoc.line > 1 && Newline > 1) { /* previous page */
- int scrollamount = (Newline > display_lines ?
- display_lines : Newline - 1);
+ } else if (curdoc.line > 1 && LYGetNewline() > 1) { /* previous page */
+ int scrollamount = (LYGetNewline() > display_lines
+ ? display_lines
+ : LYGetNewline() - 1);
Newline -= scrollamount;
if (scrollamount < display_lines &&
@@ -4592,15 +4667,15 @@ static void handle_LYK_UP_TWO(int *arrowup,
int *old_c,
int real_c)
{
- if (Newline > 1) {
- int scrollamount = (Newline > 2 ? 2 : 1);
+ if (LYGetNewline() > 1) {
+ int scrollamount = (LYGetNewline() > 2 ? 2 : 1);
Newline -= scrollamount;
if (nlinks > 0 && curdoc.link > -1) {
if (links[curdoc.link].ly + scrollamount <= display_lines) {
newdoc.link = curdoc.link +
HText_LinksInLines(HTMainText,
- Newline, scrollamount);
+ LYGetNewline(), scrollamount);
} else {
*arrowup = TRUE;
}
@@ -4873,9 +4948,9 @@ static void handle_LYK_digit(int c,
/*
* Position on a normal link, don't follow it. - KW
*/
- Newline = newdoc.line;
+ LYSetNewline(newdoc.line);
newdoc.line = 1;
- if (Newline == curdoc.line) {
+ if (LYGetNewline() == curdoc.line) {
/*
* It's a link in the current page. - FM
*/
@@ -4907,14 +4982,14 @@ static void handle_LYK_digit(int c,
/*
* Position on a page in this document. - FM
*/
- Newline = newdoc.line;
+ LYSetNewline(newdoc.line);
newdoc.line = 1;
- if (Newline == curdoc.line) {
+ if (LYGetNewline() == curdoc.line) {
/*
* It's the current page, so issue a statusline message for the
* typo-prone users (like me 8-). - FM
*/
- if (Newline <= 1) {
+ if (LYGetNewline() <= 1) {
HTInfoMsg(ALREADY_AT_BEGIN);
} else if (!more) {
HTInfoMsg(ALREADY_AT_END);
@@ -5433,7 +5508,7 @@ int mainloop(void)
* (was previously implemented in case NORMAL).
*/
*prev_target = '\0'; /* Reset for new coming document */
- Newline = newdoc.line; /* set for LYGetNewline() */
+ LYSetNewline(newdoc.line); /* set for LYGetNewline() */
#ifdef USE_PRETTYSRC
psrc_first_tag = TRUE;
@@ -5878,7 +5953,7 @@ int mainloop(void)
* If we are going to a target line or the first page of a
* popped document, override any www_search line result.
*/
- if (Newline > 1 || popped_doc == TRUE)
+ if (LYGetNewline() > 1 || popped_doc == TRUE)
www_search_result = -1;
/*
@@ -6022,7 +6097,7 @@ int mainloop(void)
/*
* This was a WWW search, set the line to the result of the search.
*/
- Newline = www_search_result;
+ LYSetNewline(www_search_result);
www_search_result = -1; /* reset */
}
@@ -6170,14 +6245,14 @@ int mainloop(void)
* If we got new HTMainText go this way. All display_partial calls
* ends here for final redraw.
*/
- if (curdoc.line != Newline) {
+ if (curdoc.line != LYGetNewline()) {
#ifdef INACTIVE_INPUT_STYLE_VH
textinput_redrawn = FALSE;
#endif
refresh_screen = FALSE;
- HText_pageDisplay(Newline, prev_target);
+ HText_pageDisplay(LYGetNewline(), prev_target);
#ifdef DIRED_SUPPORT
if (lynx_edit_mode && nlinks > 0 && !HTList_isEmpty(tagged))
@@ -6189,8 +6264,9 @@ int mainloop(void)
*/
more = HText_canScrollDown();
if (newdoc.link < 0)
- goto_line(Newline);
- curdoc.line = Newline = HText_getTopOfScreen() + 1;
+ goto_line(LYGetNewline());
+ LYSetNewline(HText_getTopOfScreen() + 1);
+ curdoc.line = LYGetNewline();
if (curdoc.title == NULL) {
/*
@@ -6241,7 +6317,7 @@ int mainloop(void)
show_help = FALSE; /* reset */
newdoc.line = 1;
newdoc.link = 0;
- curdoc.line = Newline; /* set */
+ curdoc.line = LYGetNewline(); /* set */
} else if (newdoc.link < 0) {
newdoc.link = 0; /* ...just in case getfile set this */
}
@@ -6259,7 +6335,7 @@ int mainloop(void)
#else
LYclear();
#endif /* FANCY_CURSES || USE_SLANG */
- HText_pageDisplay(Newline, prev_target);
+ HText_pageDisplay(LYGetNewline(), prev_target);
#ifdef DIRED_SUPPORT
if (lynx_edit_mode && nlinks > 0 && !HTList_isEmpty(tagged))
@@ -6957,9 +7033,9 @@ int mainloop(void)
break;
case LYK_HOME:
- if (curdoc.line > 1)
- Newline = 1;
- else {
+ if (curdoc.line > 1) {
+ LYSetNewline(1);
+ } else {
cmd = LYK_PREV_PAGE;
goto new_cmd;
}
@@ -6967,8 +7043,8 @@ int mainloop(void)
case LYK_END:
i = HText_getNumOfLines() - display_lines + 2;
- if (i >= 1 && Newline != i) {
- Newline = i; /* go to end of file */
+ if (i >= 1 && LYGetNewline() != i) {
+ LYSetNewline(i); /* go to end of file */
arrowup = TRUE; /* position on last link */
} else {
cmd = LYK_NEXT_PAGE;
diff --git a/src/LYOptions.c b/src/LYOptions.c
index ff309b27..5eb8b67f 100644
--- a/src/LYOptions.c
+++ b/src/LYOptions.c
@@ -34,9 +34,7 @@ static int LYChosenShowColor = SHOW_COLOR_UNKNOWN; /* whether to show and save *
static void terminate_options(int sig);
-#if !defined(NO_OPTION_MENU) || (defined(USE_MOUSE) && (defined(NCURSES) || defined(PDCURSES)))
#define COL_OPTION_VALUES 36 /* display column where option values start */
-#endif
#if defined(USE_SLANG) || defined(COLOR_CURSES)
static BOOLEAN can_do_colors = FALSE;
@@ -2050,7 +2048,7 @@ void edit_bookmarks(void)
signal(SIGINT, cleanup_sig);
}
-#if !defined(NO_OPTION_MENU) || (defined(USE_MOUSE) && (defined(NCURSES) || defined(PDCURSES)))
+#if defined(USE_CURSES_PADS) || !defined(NO_OPTION_MENU) || (defined(USE_MOUSE) && (defined(NCURSES) || defined(PDCURSES)))
/*
* This function offers the choices for values of an option via a popup window
diff --git a/src/LYStrings.c b/src/LYStrings.c
index ec12ea65..4fe7be02 100644
--- a/src/LYStrings.c
+++ b/src/LYStrings.c
@@ -827,9 +827,21 @@ void ena_csi(BOOLEAN flag)
#ifdef USE_SLANG
#define define_key(string, code) \
- SLkm_define_keysym (string, code, Keymap_List)
+ SLkm_define_keysym ((char*)(string), code, Keymap_List)
+#if SLANG_VERSION < 20000
#define expand_substring(dst, first, last, final) \
- (SLexpand_escaped_string(dst, (char *)first, (char *)last), 1)
+ (SLexpand_escaped_string(dst, (char *)first, (char *)last), 1)
+static int SLang_get_error(void)
+{
+ return SLang_Error;
+}
+#else
+int LY_Slang_UTF8_Mode = 0;
+
+#define expand_substring(dst, first, last, final) \
+ (SLexpand_escaped_string(dst, (char *)first, (char *)last, LY_Slang_UTF8_Mode), 1)
+#endif
+
static SLKeyMap_List_Type *Keymap_List;
/* This value should be larger than anything in LYStrings.h */
@@ -1248,7 +1260,7 @@ static int unsetkey_cmd(char *parse)
* occasionally find useful).
*/
SLang_undefine_key(parse, Keymap_List);
- if (SLang_Error)
+ if (SLang_get_error())
return -1;
#endif
}
@@ -1391,7 +1403,7 @@ int lynx_initialize_keymaps(void)
setup_vtXXX_keymap();
define_key("\033[M", MOUSE_KEYSYM);
- if (SLang_Error)
+ if (SLang_get_error())
SLang_exit_error("Unable to initialize keymaps");
#else
setup_vtXXX_keymap();
diff --git a/src/LYStructs.h b/src/LYStructs.h
index 4d604736..4a030ab7 100644
--- a/src/LYStructs.h
+++ b/src/LYStructs.h
@@ -29,6 +29,7 @@ extern "C" {
int lx;
int ly;
int type; /* Type of link, Forms, WWW, etc. */
+ int sgml_offset; /* document offset used in reparsing */
int anchor_number; /* The anchor number within the HText structure. */
int anchor_line_num; /* The anchor line number in the HText structure. */
HiliteList list;
diff --git a/src/LYStyle.c b/src/LYStyle.c
index 6e8743bf..3249f12f 100644
--- a/src/LYStyle.c
+++ b/src/LYStyle.c
@@ -1,6 +1,6 @@
/* character level styles for Lynx
* (c) 1996 Rob Partington -- donated to the Lyncei (if they want it :-)
- * @Id: LYStyle.c 1.59 Sun, 02 Jan 2005 15:35:21 -0800 dickey @
+ * @Id: LYStyle.c 1.60 Thu, 02 Jun 2005 15:36:59 -0700 dickey @
*/
#include <HTUtils.h>
#include <HTML.h>
@@ -100,6 +100,13 @@ static unsigned char our_pairs[2]
[MAX_COLOR + 1]
[MAX_COLOR + 1];
+static char *TrimLowercase(char *buffer)
+{
+ LYRemoveBlanks(buffer);
+ strtolower(buffer);
+ return buffer;
+}
+
/*
* Parse a string containing a combination of video attributes and color.
*/
@@ -282,6 +289,7 @@ static void parse_style(char *param)
if (buffer == 0)
return;
+ TrimLowercase(buffer);
if ((tmp = strchr(buffer, ':')) == 0) {
fprintf(stderr, gettext("\
Syntax Error parsing style in lss file:\n\
@@ -291,7 +299,6 @@ OBJECT:MONO:COLOR (ie em:bold:brightblue:white)\n\
where OBJECT is one of EM,STRONG,B,I,U,BLINK etc.\n\n"), buffer);
exit_immediately(EXIT_FAILURE);
}
- strtolower(buffer);
*tmp = '\0';
element = buffer;
@@ -317,8 +324,6 @@ where OBJECT is one of EM,STRONG,B,I,U,BLINK etc.\n\n"), buffer);
element, hash_code(element),
(hashStyles[hash_code(element)].name ? "used" : "")));
- strtolower(element);
-
/*
* We use some pseudo-elements, so catch these first
*/
@@ -333,14 +338,15 @@ where OBJECT is one of EM,STRONG,B,I,U,BLINK etc.\n\n"), buffer);
}
if (found) {
- ;
- } else if (!strcasecomp(element, "normal")) /* added - kw */
- {
- parse_attributes(mono, fg, bg, DSTYLE_NORMAL, "html");
- s_normal = hash_code("html"); /* rather bizarre... - kw */
- }
- /* It must be a HTML element, so look through the list until we find it. */
- else {
+ if (!strcasecomp(element, "normal")) {
+ /* added - kw */
+ parse_attributes(mono, fg, bg, DSTYLE_NORMAL, "html");
+ s_normal = hash_code("html"); /* rather bizarre... - kw */
+
+ LYnormalColor();
+ }
+ } else {
+ /* It must be a HTML element, so look through the list until we find it. */
int element_number = -1;
HTTag *t = SGMLFindTag(&HTML_dtd, element);
@@ -348,10 +354,11 @@ where OBJECT is one of EM,STRONG,B,I,U,BLINK etc.\n\n"), buffer);
element_number = t - HTML_dtd.tags;
}
if (element_number >= HTML_A &&
- element_number < HTML_ELEMENTS)
+ element_number < HTML_ELEMENTS) {
parse_attributes(mono, fg, bg, element_number + STARTAT, element);
- else
+ } else {
parse_attributes(mono, fg, bg, DSTYLE_ELEMENTS, element);
+ }
}
FREE(buffer);
}
@@ -480,12 +487,15 @@ static void HStyle_addStyle(char *buffer)
char *name = NULL;
CTRACE((tfp, "HStyle_addStyle(%s)\n", buffer));
+
StrAllocCopy(name, buffer);
+ TrimLowercase(name);
+
if (lss_styles == NULL)
lss_styles = HTList_new();
- strtolower(name);
- if (!strncasecomp(name, "default:", 8)) /* default fg/bg */
- {
+
+ if (!strncasecomp(name, "default:", 8)) {
+ /* default fg/bg */
CTRACE2(TRACE_STYLE, (tfp, "READCSS.default%s:%s\n",
(default_color_reset ? ".ignore" : ""),
name ? name : "!?! empty !?!"));
@@ -531,7 +541,7 @@ static int style_readFromFileREC(char *lss_filename,
LYTrimTail(buffer);
LYTrimHead(buffer);
if (!strncasecomp(buffer, "include:", 8))
- style_readFromFileREC(buffer + 8, lss_filename);
+ style_readFromFileREC(LYSkipBlanks(buffer + 8), lss_filename);
else if (buffer[0] != '#' && (len = strlen(buffer)) > 0)
HStyle_addStyle(buffer);
}
@@ -557,7 +567,7 @@ void TrimColorClass(const char *tagname,
char tmp[64];
sprintf(tmp, ";%.*s", (int) sizeof(tmp) - 3, tagname);
- strtolower(tmp);
+ TrimLowercase(tmp);
if ((lookfrom = styleclassname) != 0) {
do {
diff --git a/src/LYUtils.c b/src/LYUtils.c
index a33686cf..4fde7d96 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -277,6 +277,9 @@ void LYFreeHilites(int first, int last)
}
}
+#define LXP (links[cur].lx)
+#define LYP (links[cur].ly)
+
/*
* Set the initial highlight information for a given link.
*/
@@ -340,13 +343,10 @@ int LYGetHilitePos(int cur,
else if (count > 0)
result = links[cur].list.hl_info[count - 1].hl_x;
else
- result = links[cur].lx;
+ result = LXP;
return result;
}
-#define LXP (links[cur].lx)
-#define LYP (links[cur].ly)
-
#ifdef SHOW_WHEREIS_TARGETS
#define SKIP_GLYPHS(theFlag, theData, theOffset) \
@@ -388,7 +388,7 @@ static BOOL show_whereis_targets(int flag,
if (non_empty(target)
&& (links[cur].type & WWW_LINK_TYPE)
&& non_empty(LYGetHiliteStr(cur, count))
- && links[cur].ly + count < display_lines
+ && LYP + count < display_lines
&& HText_getFirstTargetInLine(HTMainText,
links[cur].anchor_line_num + count,
utf_flag,
@@ -400,7 +400,7 @@ static BOOL show_whereis_targets(int flag,
const char *data;
int tlen = strlen(target);
int hlen, hLen;
- int hLine = links[cur].ly + count;
+ int hLine = LYP + count;
int hoffset = LYGetHilitePos(cur, count);
size_t utf_extra = 0;
@@ -1005,6 +1005,7 @@ void LYhighlight(int flag,
int i;
int hi_count;
int hi_offset;
+ int title_adjust = (no_title ? -TITLE_LINES : 0);
char tmp[7];
const char *hi_string;
@@ -1038,7 +1039,7 @@ void LYhighlight(int flag,
if (nlinks > 0) {
#ifdef USE_COLOR_STYLE
if (flag == ON || links[cur].type == WWW_FORM_LINK_TYPE) {
- LYmove(LYP, LXP);
+ LYmove(LYP + title_adjust, LXP);
LynxChangeStyle(find_cached_style(cur, flag), STACK_ON);
}
#else
@@ -1059,7 +1060,7 @@ void LYhighlight(int flag,
if (links[cur].type == WWW_FORM_LINK_TYPE) {
int len;
- int avail_space = (LYcolLimit - links[cur].lx);
+ int avail_space = (LYcolLimit - LXP) + (LYcolLimit * (LYlines - LYP));
const char *text = LYGetHiliteStr(cur, 0);
if (avail_space > links[cur].l_form->size)
@@ -1068,11 +1069,12 @@ void LYhighlight(int flag,
avail_space = (int) sizeof(buffer) - 1;
LYstrncpy(buffer, NonNull(text), avail_space);
- LYaddstr(buffer);
-
len = strlen(buffer);
- for (; len < links[cur].l_form->size && len < avail_space; len++)
- LYaddch('_');
+ while (len < avail_space) {
+ buffer[len++] = '_';
+ }
+ buffer[len] = 0;
+ LYaddstr(buffer);
#ifdef USE_COLOR_STYLE
} else if (flag == OFF) {
@@ -1090,7 +1092,7 @@ void LYhighlight(int flag,
LYmbcsstrncpy(buffer,
NonNull(LYGetHiliteStr(cur, 0)),
(sizeof(buffer) - 1),
- (LYcolLimit - links[cur].lx),
+ (LYcolLimit - LXP),
utf_flag);
LYaddstr(buffer);
}
@@ -1104,17 +1106,18 @@ void LYhighlight(int flag,
{
for (hi_count = 1;
(hi_string = LYGetHiliteStr(cur, hi_count)) != NULL
- && links[cur].ly + hi_count <= display_lines;
+ && LYP + hi_count <= display_lines;
++hi_count) {
+ int row = LYP + hi_count + title_adjust;
hi_offset = LYGetHilitePos(cur, hi_count);
lynx_stop_link_color(flag == ON, links[cur].inUnderline);
- LYmove(links[cur].ly + hi_count, hi_offset);
+ LYmove(row, hi_offset);
#ifdef USE_COLOR_STYLE
CTRACE2(TRACE_STYLE,
(tfp, "STYLE.highlight.line2: @(%d,%d), style=%d.\n",
- links[cur].ly + hi_count, hi_offset,
+ row, hi_offset,
flag == ON ? s_alink : s_a));
LynxChangeStyle(flag == ON ? s_alink : s_a, ABS_ON);
#else
@@ -1161,8 +1164,7 @@ void LYhighlight(int flag,
/*
* Never hide the cursor if there's no FANCY CURSES or SLANG.
*/
- LYmove(links[cur].ly,
- ((links[cur].lx > 0) ? (links[cur].lx - 1) : 0));
+ LYmove(LYP + title_adjust, ((LXP > 0) ? (LXP - 1) : 0));
if (flag)
LYrefresh();
@@ -1346,6 +1348,19 @@ void statusline(const char *text)
FREE(temp);
} else {
/*
+ * Deal with any newlines or tabs in the string. - FM
+ */
+ LYReduceBlanks(text_buff);
+#ifdef WIDEC_CURSES
+ len = strlen(text_buff);
+ if (len >= (int) (sizeof(buffer) - 1))
+ len = (int) (sizeof(buffer) - 1);
+ strncpy(buffer, text_buff, len)[len] = '\0';
+ /* FIXME: a binary search might be faster */
+ while (len > 0 && LYstrExtent(buffer, len, len) > max_length)
+ buffer[--len] = '\0';
+#else
+ /*
* Strip any escapes, and shorten text if necessary. Note that we
* don't deal with the possibility of UTF-8 characters in the string.
* This is unlikely, but if strings with such characters are used in
@@ -1359,10 +1374,7 @@ void statusline(const char *text)
}
}
buffer[len] = '\0';
- /*
- * Deal with any newlines or tabs in the string. - FM
- */
- LYReduceBlanks(buffer);
+#endif
}
/*
@@ -1382,7 +1394,7 @@ void statusline(const char *text)
}
LYclrtoeol();
- if (text != NULL && text[0] != '\0') {
+ if (non_empty(buffer)) {
BOOLEAN has_CJK = FALSE;
if (HTCJK != NOCJK) {
@@ -1408,10 +1420,10 @@ void statusline(const char *text)
#else
/* draw the status bar in the STATUS style */
{
- int a = (strncmp(buffer, ALERT_FORMAT, ALERT_PREFIX_LEN)
- || !hashStyles[s_alert].name)
- ? s_status
- : s_alert;
+ int a = ((strncmp(buffer, ALERT_FORMAT, ALERT_PREFIX_LEN)
+ || !hashStyles[s_alert].name)
+ ? s_status
+ : s_alert);
LynxChangeStyle(a, STACK_ON);
LYaddstr(buffer);
diff --git a/src/UCdomap.c b/src/UCdomap.c
index 0f63ef14..11ec31bd 100644
--- a/src/UCdomap.c
+++ b/src/UCdomap.c
@@ -2289,11 +2289,9 @@ void LYFindLocaleCharset(void)
current_char_set = value;
} else {
CTRACE((tfp, "Cannot find a handle for MIME name \"%s\"\n", name));
- LYLocaleCharset = FALSE;
}
} else {
CTRACE((tfp, "Cannot find a MIME name for locale\n"));
- LYLocaleCharset = FALSE;
}
}
}
diff --git a/src/chrtrans/makefile.in b/src/chrtrans/makefile.in
index d1600347..67ed495b 100644
--- a/src/chrtrans/makefile.in
+++ b/src/chrtrans/makefile.in
@@ -114,7 +114,7 @@ $(MAKEUCTB) : makeuctb$o
makeuctb$o : $(srcdir)/UCkd.h $(srcdir)/makeuctb.c
-.SUFFIXES : $o .tbl .i
+.SUFFIXES : $o .tbl .i .h
.c$o:
@RULE_CC@