[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lynx-dev [PATCH] explicitly mark hidden links with user-defined string
From: |
Vlad Harchev |
Subject: |
lynx-dev [PATCH] explicitly mark hidden links with user-defined string |
Date: |
Tue, 20 Jun 2000 22:49:44 +0500 (SAMST) |
Here is a patch that allows user to specify string to mark hidden links with
(thus hidden links becoming non-hidden, thus they won't be listed as hidden
in the 'l' page) - the name of the setting is hidden_link_marker. If the
string to mark with is empty, then old behaviour is restored.
Note: expect small offsets when applying - it assumes that chdir-command
patch was already applied (though it doesn't depend on it at all).
Best regards,
-Vlad
diff -ru lynx2.8.4dev3-with-chdir/WWW/Library/Implementation/HText.h
lynx2.8.4dev3/WWW/Library/Implementation/HText.h
--- lynx2.8.4dev3-with-chdir/WWW/Library/Implementation/HText.h Thu Mar 18
07:17:11 1999
+++ lynx2.8.4dev3/WWW/Library/Implementation/HText.h Tue Jun 20 22:27:55 2000
@@ -126,7 +126,7 @@
BOOL underline,
HTChildAnchor * anc));
extern void HText_endAnchor PARAMS((HText * text, int number));
-
+extern BOOL HText_isAnchorBlank PARAMS((HText * text, int number));
/*
diff -ru lynx2.8.4dev3-with-chdir/lynx.cfg lynx2.8.4dev3/lynx.cfg
--- lynx2.8.4dev3-with-chdir/lynx.cfg Mon Jun 12 15:15:42 2000
+++ lynx2.8.4dev3/lynx.cfg Tue Jun 20 22:43:19 2000
@@ -2992,6 +2992,17 @@
#
#FORCE_EMPTY_HREFLESS_A:FALSE
+.h2 HIDDEN_LINK_MARKER
+# HIDDEN_LINK_MARKER - HTML parsing
+# This option defines the string that will be used as title of hidden link (
+# the link that otherwise won't have any any label associated with it).
+# Using the empty string as the value will cause lynx to behave in old way -
+# hidden links will be handled according to other settings (mostly the
+# parameter of --hiddenlinks commandline switch). If the value is non-empty
+# string, hidden link becomes non-hidden so it won't be handled as hidden link
+# (e.g. listed among hidden links on 'l'isting page).
+#
+#HIDDEN_LINK_MARKER:
.h1 Appearance
diff -ru lynx2.8.4dev3-with-chdir/src/GridText.c lynx2.8.4dev3/src/GridText.c
--- lynx2.8.4dev3-with-chdir/src/GridText.c Sat Jun 3 19:54:48 2000
+++ lynx2.8.4dev3/src/GridText.c Tue Jun 20 22:33:33 2000
@@ -5098,6 +5098,188 @@
return(a->number);
}
+/*
+ This returns whether the given anchor has blank content. Shamelessly copied
+ from HText_endAnchor. The values returned are meaningful only for "normal"
+ links - like ones produced by <a href=".">foo</a>, no inputs, etc. - VH
+*/
+PUBLIC BOOL HText_isAnchorBlank ARGS2(
+ HText *, text,
+ int, number)
+{
+ TextAnchor *a;
+
+ /*
+ * The number argument is set to 0 in HTML.c and
+ * LYCharUtils.c when we want to end the anchor
+ * for the immediately preceding HText_beginAnchor()
+ * call. If it's greater than 0, we want to handle
+ * a particular anchor. This allows us to set links
+ * for positions indicated by NAME or ID attributes,
+ * without needing to close any anchor with an HREF
+ * within which that link might be embedded. - FM
+ */
+ if (number <= 0 || number == text->last_anchor->number) {
+ a = text->last_anchor;
+ } else {
+ for (a = text->first_anchor; a; a = a->next) {
+ if (a->number == number) {
+ break;
+ }
+ }
+ if (a == NULL) {
+ /*
+ * There's no anchor with that number,
+ * so we'll default to the last anchor,
+ * and cross our fingers. - FM
+ */
+ a = text->last_anchor;
+ }
+ }
+
+ CTRACE((tfp, "GridText:HText_isAnchorBlank: number:%d link_type:%d\n",
+ a->number, a->link_type));
+ if (a->link_type == INPUT_ANCHOR) {
+ /*
+ * Shouldn't happen, but put test here anyway to be safe. - LE
+ */
+
+ CTRACE((tfp,
+ "HText_isAnchorBlank: internal error: last anchor was input
field!\n"));
+ return 0;
+ }
+ if (a->number) {
+ /*
+ * If it goes somewhere...
+ */
+ int i, j, k, l;
+ HTLine *last = text->last_line;
+ HTLine *prev = text->last_line->prev;
+ HTLine *start = last;
+ int CurBlankExtent = 0;
+ int BlankExtent = 0;
+
+ int extent_adjust = (text->chars + last->size) - a->start -
+ (text->Lines - a->line_num);
+
+ /*
+ * Check if the anchor content has only
+ * white and special characters, starting
+ * with the content on the last line. - FM
+ */
+ a->extent += extent_adjust;
+ if (a->extent > (int)last->size) {
+ /*
+ * The anchor extends over more than one line,
+ * so set up to check the entire last line. - FM
+ */
+ i = last->size;
+ } else {
+ /*
+ * The anchor is restricted to the last line,
+ * so check from the start of the anchor. - FM
+ */
+ i = a->extent;
+ }
+ k = j = (last->size - i);
+ while (j < (int)last->size) {
+ if (!IsSpecialAttrChar(last->data[j]) &&
+ !isspace((unsigned char)last->data[j]) &&
+ last->data[j] != HT_NON_BREAK_SPACE &&
+ last->data[j] != HT_EN_SPACE)
+ break;
+ i--;
+ j++;
+ }
+ if (i == 0) {
+ if (a->extent > (int)last->size) {
+ /*
+ * The anchor starts on a preceding line, and
+ * the last line has only white and special
+ * characters, so declare the entire extent
+ * of the last line as blank. - FM
+ */
+ CurBlankExtent = BlankExtent = last->size;
+ } else {
+ /*
+ * The anchor starts on the last line, and
+ * has only white or special characters, so
+ * declare the anchor's extent as blank. - FM
+ */
+ CurBlankExtent = BlankExtent = a->extent;
+ }
+ }
+ /*
+ * While the anchor starts on a line preceding
+ * the one we just checked, and the one we just
+ * checked has only white and special characters,
+ * check whether the anchor's content on the
+ * immediately preceding line also has only
+ * white and special characters. - FM
+ */
+ while (i == 0 &&
+ (a->extent > CurBlankExtent ||
+ (a->extent == CurBlankExtent &&
+ k == 0 &&
+ prev != text->last_line &&
+ (prev->size == 0 ||
+ prev->data[prev->size - 1] == ']')))) {
+ start = prev;
+ k = j = prev->size - a->extent + CurBlankExtent;
+ if (j < 0) {
+ /*
+ * The anchor starts on a preceding line,
+ * so check all of this line. - FM
+ */
+ j = 0;
+ i = prev->size;
+ } else {
+ /*
+ * The anchor starts on this line. - FM
+ */
+ i = a->extent - CurBlankExtent;
+ }
+ while (j < (int)prev->size) {
+ if (!IsSpecialAttrChar(prev->data[j]) &&
+ !isspace((unsigned char)prev->data[j]) &&
+ prev->data[j] != HT_NON_BREAK_SPACE &&
+ prev->data[j] != HT_EN_SPACE)
+ break;
+ i--;
+ j++;
+ }
+ if (i == 0) {
+ if (a->extent > (CurBlankExtent + (int)prev->size) ||
+ (a->extent == CurBlankExtent + (int)prev->size &&
+ k == 0 &&
+ prev->prev != text->last_line &&
+ (prev->prev->size == 0 ||
+ prev->prev->data[prev->prev->size - 1] == ']'))) {
+ /*
+ * This line has only white and special
+ * characters, so treat its entire extent
+ * as blank, and decrement the pointer for
+ * the line to be analyzed. - FM
+ */
+ CurBlankExtent += prev->size;
+ BlankExtent = CurBlankExtent;
+ prev = prev->prev;
+ } else {
+ /*
+ * The anchor starts on this line, and it
+ * has only white or special characters, so
+ * declare the anchor's extent as blank. - FM
+ */
+ BlankExtent = a->extent;
+ break;
+ }
+ }
+ }
+ a->extent -= extent_adjust;
+ return i==0;
+ } else
+ return 0;
+};
PUBLIC void HText_endAnchor ARGS2(
HText *, text,
diff -ru lynx2.8.4dev3-with-chdir/src/HTML.c lynx2.8.4dev3/src/HTML.c
--- lynx2.8.4dev3-with-chdir/src/HTML.c Sat Jun 3 19:54:48 2000
+++ lynx2.8.4dev3/src/HTML.c Tue Jun 20 22:30:22 2000
@@ -6730,7 +6730,12 @@
* Set to know that we are no longer in an anchor.
*/
me->inA = FALSE;
-
+#ifdef MARK_HIDDEN_LINKS
+ if (hidden_link_marker && *hidden_link_marker &&
+ HText_isAnchorBlank(me->text, me->CurrentANum) ) {
+ HText_appendText(me->text,hidden_link_marker);
+ };
+#endif
UPDATE_STYLE;
if (me->inBoldA == TRUE && me->inBoldH == FALSE)
HText_appendCharacter(me->text, LY_BOLD_END_CHAR);
diff -ru lynx2.8.4dev3-with-chdir/src/LYGlobalDefs.h
lynx2.8.4dev3/src/LYGlobalDefs.h
--- lynx2.8.4dev3-with-chdir/src/LYGlobalDefs.h Sat Jun 3 19:54:48 2000
+++ lynx2.8.4dev3/src/LYGlobalDefs.h Tue Jun 20 22:10:27 2000
@@ -509,4 +509,7 @@
extern int LYsb_end;
#endif
+#ifdef MARK_HIDDEN_LINKS
+extern char* hidden_link_marker;
+#endif
#endif /* LYGLOBALDEFS_H */
diff -ru lynx2.8.4dev3-with-chdir/src/LYMain.c lynx2.8.4dev3/src/LYMain.c
--- lynx2.8.4dev3-with-chdir/src/LYMain.c Sat Jun 3 19:54:48 2000
+++ lynx2.8.4dev3/src/LYMain.c Tue Jun 20 22:21:45 2000
@@ -461,6 +461,10 @@
PUBLIC BOOLEAN textfield_prompt_at_left_edge = FALSE;
+#ifdef MARK_HIDDEN_LINKS
+PUBLIC char* hidden_link_marker = NULL;
+#endif
+
#ifdef DISP_PARTIAL
PUBLIC BOOLEAN display_partial_flag = TRUE; /* Display document during
download */
diff -ru lynx2.8.4dev3-with-chdir/src/LYReadCFG.c lynx2.8.4dev3/src/LYReadCFG.c
--- lynx2.8.4dev3-with-chdir/src/LYReadCFG.c Sat Jun 3 19:54:48 2000
+++ lynx2.8.4dev3/src/LYReadCFG.c Tue Jun 20 22:11:58 2000
@@ -1436,6 +1436,9 @@
PARSE_ENV("gopher_proxy", CONF_ENV, 0 ),
PARSE_SET("gotobuffer", CONF_BOOL, &goto_buffer),
PARSE_STR("helpfile", CONF_STR, &helpfile),
+#ifdef MARK_HIDDEN_LINKS
+ PARSE_STR("hidden_link_marker", CONF_STR, &hidden_link_marker),
+#endif
PARSE_SET("historical_comments", CONF_BOOL, &historical_comments),
#ifdef USE_PRETTYSRC
PARSE_FUN("htmlsrc_attrname_xform", CONF_FUN,
read_htmlsrc_attrname_xform),
diff -ru lynx2.8.4dev3-with-chdir/userdefs.h lynx2.8.4dev3/userdefs.h
--- lynx2.8.4dev3-with-chdir/userdefs.h Mon Jun 12 15:13:13 2000
+++ lynx2.8.4dev3/userdefs.h Tue Jun 20 22:36:51 2000
@@ -1467,6 +1467,7 @@
*/
#define SUPPORT_CHDIR
+#define MARK_HIDDEN_LINKS
/*****************************
* USE_TH_JP_AUTO_DETECT, CONV_JISX0201KANA_JISX0208KANA,
* and KANJI_CODE_OVERRIDE are the macros for Japanese. - TH
; To UNSUBSCRIBE: Send "unsubscribe lynx-dev" to address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- lynx-dev [PATCH] explicitly mark hidden links with user-defined string,
Vlad Harchev <=