diff options
Diffstat (limited to 'anchor.c')
-rw-r--r-- | anchor.c | 116 |
1 files changed, 110 insertions, 6 deletions
@@ -1,4 +1,4 @@ -/* $Id: anchor.c,v 1.12 2002/12/05 16:29:04 ukai Exp $ */ +/* $Id: anchor.c,v 1.13 2002/12/09 15:51:08 ukai Exp $ */ #include "fm.h" #include "myctype.h" #include "regex.h" @@ -480,6 +480,7 @@ addMultirowsImg(Buffer *buf, AnchorList *al) pos = columnPos(l, col); a = registerImg(buf, a_img.url, a_img.title, l->linenumber, pos); a->hseq = -a_img.hseq; + a->slave = TRUE; a->image = img; a->end.pos = pos + ecol - col; for (k = pos; k < a->end.pos; k++) @@ -565,12 +566,12 @@ addMultirowsForm(Buffer *buf, AnchorList *al) } char * -getAnchorText(Buffer *buf, Anchor *a) +getAnchorText(Buffer *buf, AnchorList *al, Anchor *a) { - AnchorList *al = buf->href; int hseq, i; Line *l; Str tmp = NULL; + char *p, *ep; if (!a || a->hseq < 0) return NULL; @@ -586,12 +587,115 @@ getAnchorText(Buffer *buf, Anchor *a) } if (!l) break; + p = l->lineBuf + a->start.pos; + ep = l->lineBuf + a->end.pos; + for (; p < ep && IS_SPACE(*p); p++) ; + if (p == ep) + continue; if (!tmp) - tmp = Strnew_size(a->end.pos - a->start.pos); + tmp = Strnew_size(ep - p); else Strcat_char(tmp, ' '); - Strcat_charp_n(tmp, &l->lineBuf[a->start.pos], - a->end.pos - a->start.pos); + Strcat_charp_n(tmp, p, ep - p); } return tmp ? tmp->ptr : NULL; } + +Buffer * +link_list_panel(Buffer *buf) +{ + LinkList *l; + AnchorList *al; + Anchor *a; + FormItemList *fi; + int i; + char *t, *u; + ParsedURL pu; + Str tmp = Strnew_charp("<title>Link List</title>\ +<h1 align=center>Link List</h1>\n"); + + if (buf->linklist) { + Strcat_charp(tmp, "<hr><h2>Links</h2>\n<ol>\n"); + for (l = buf->linklist; l; l = l->next) { + if (l->url) { + parseURL2(l->url, &pu, baseURL(buf)); + u = html_quote(parsedURL2Str(&pu)->ptr); + } + else + u = ""; + if (l->type == LINK_TYPE_REL) + t = " [Rel]"; + else if (l->type == LINK_TYPE_REV) + t = " [Rev]"; + else + t = ""; + t = Sprintf("%s%s\n", l->title ? l->title : "", t)->ptr; + t = html_quote(t); + Strcat_m_charp(tmp, "<li><a href=\"", u, "\">", t, "</a><br>", u, + "\n", NULL); + } + Strcat_charp(tmp, "</ol>\n"); + } + + if (buf->href) { + Strcat_charp(tmp, "<hr><h2>Anchors</h2>\n<ol>\n"); + al = buf->href; + for (i = 0; i < al->nanchor; i++) { + a = &al->anchors[i]; + if (a->slave) + continue; + parseURL2(a->url, &pu, baseURL(buf)); + u = html_quote(parsedURL2Str(&pu)->ptr); + t = getAnchorText(buf, al, a); + t = t ? html_quote(t) : ""; + Strcat_m_charp(tmp, "<li><a href=\"", u, "\">", t, "</a><br>", u, + "\n", NULL); + } + Strcat_charp(tmp, "</ol>\n"); + } + + if (buf->img) { + Strcat_charp(tmp, "<hr><h2>Images</h2>\n<ol>\n"); + al = buf->img; + for (i = 0; i < al->nanchor; i++) { + a = &al->anchors[i]; + if (a->slave) + continue; + parseURL2(a->url, &pu, baseURL(buf)); + u = html_quote(parsedURL2Str(&pu)->ptr); + t = (a->title && *a->title) ? html_quote(a->title) : + html_quote(a->url); + Strcat_m_charp(tmp, "<li><a href=\"", u, "\">", t, "</a><br>", u, + "\n", NULL); + a = retrieveAnchor(buf->formitem, a->start.line, a->start.pos); + if (!a) + continue; + fi = (FormItemList *)a->url; + fi = fi->parent->item; + if (fi->parent->method == FORM_METHOD_INTERNAL && + !Strcmp_charp(fi->parent->action, "map") && fi->value) { + MapList *ml = searchMapList(buf, fi->value->ptr); + ListItem *mi; + MapArea *m; + if (!ml) + continue; + Strcat_charp(tmp, "<br>\n<b>Image map</b>\n<ol>\n"); + for (mi = ml->area->first; mi != NULL; mi = mi->next) { + m = (MapArea *) mi->ptr; + if (!m) + continue; + parseURL2(m->url, &pu, baseURL(buf)); + u = html_quote(parsedURL2Str(&pu)->ptr); + t = (m->alt && *m->alt) ? html_quote(m->alt) : + html_quote(m->url); + Strcat_m_charp(tmp, "<li><a href=\"", u, "\">", t, + "</a><br>", u, "\n", NULL); + } + Strcat_charp(tmp, "</ol>\n"); + } + } + Strcat_charp(tmp, "</ol>\n"); + } + + return loadHTMLString(tmp); +} |