diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-12-02 17:27:34 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-12-02 17:27:34 +0000 |
commit | eb44b171c3aeeeca0c7af5fde7be3cd1c7456795 (patch) | |
tree | f5294559ebe099cffc7f838d71f69ad89f8fec02 /file.c | |
parent | [w3m-dev 03498] Re: parse <!-- ... --> in <script> (diff) | |
download | w3m-eb44b171c3aeeeca0c7af5fde7be3cd1c7456795.tar.gz w3m-eb44b171c3aeeeca0c7af5fde7be3cd1c7456795.zip |
[w3m-dev 03501] link tag support
* buffer.c (reshapeBuffer): initialize formlist, linklist,
maplist, hmarklist, imarklist
* file.c (addLink): added
(HTMLlineproc2body): add HTML_LINK
(loadHTMLstream): use HTMLlineproc0 not in R_ST_NORMAL
(reloadBuffer): initialize linklist, maplist,
hmarklist, imarklist
* fm.h (LINK_TYPE_NONE): added
(LINK_TYPE_REL): added
(LINK_TYPE_REV): added
(LinkList): added
(Buffer): add linklist
* html.c (ALST_LINK): added
(TagMAP): add link
(AtrMAP): add rel, rev, title
* html.h (HTML_LINK): added
(ATTR_REL): added
(ATTR_REV): added
(ATTR_TITLE): added
* map.c (append_map_info): anchor
(append_link_info): added
(page_info_panel): append_link_info
* menu.c (LinkMenu): added
(linkV): added
(initLinkMenu): added
(lmGoURL): added
(popupMenu): initLinkMenu()
(initMenu): w3mMenuList new 4
add "Link"
* tagtable.tab (link): added
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 59 |
1 files changed, 57 insertions, 2 deletions
@@ -1,4 +1,4 @@ -/* $Id: file.c,v 1.135 2002/11/28 16:00:33 ukai Exp $ */ +/* $Id: file.c,v 1.136 2002/12/02 17:27:36 ukai Exp $ */ #include "fm.h" #include <sys/types.h> #include "myctype.h" @@ -40,6 +40,7 @@ static void addnewline(Buffer *buf, char *line, Lineprop *prop, Linecolor *color, #endif int pos, int nlines); +static void addLink(Buffer *buf, struct parsed_tag *tag); static Lineprop propBuffer[LINELEN]; #ifdef USE_ANSI_COLOR @@ -4941,6 +4942,11 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit) a_href = NULL; } break; + + case HTML_LINK: + addLink(buf, tag); + break; + case HTML_IMG_ALT: if (parsedtag_get_value(tag, ATTR_SRC, &p)) { #ifdef USE_IMAGE @@ -5302,6 +5308,49 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit) #endif } +static void +addLink(Buffer *buf, struct parsed_tag *tag) +{ + struct parsed_tag *t; + char *href = NULL, *title = NULL, *ctype = NULL, *rel = NULL, *rev = NULL; + char type = LINK_TYPE_NONE; + LinkList *l; + + parsedtag_get_value(tag, ATTR_HREF, &href); + if (href) + href = url_quote_conv(remove_space(href), buf->document_code); + parsedtag_get_value(tag, ATTR_TITLE, &title); + parsedtag_get_value(tag, ATTR_TYPE, &ctype); + parsedtag_get_value(tag, ATTR_REL, &rel); + if (rel != NULL) { + /* forward link type */ + type = LINK_TYPE_REL; + if (title == NULL) + title = rel; + } + parsedtag_get_value(tag, ATTR_REV, &rev); + if (rev != NULL) { + /* reverse link type */ + type = LINK_TYPE_REV; + if (title == NULL) + title = rev; + } + + l = New(LinkList); + l->url = href; + l->title = title; + l->ctype = ctype; + l->type = type; + l->next = NULL; + if (buf->linklist) { + LinkList *i; + for (i = buf->linklist; i->next; i = i->next) ; + i->next = l; + } + else + buf->linklist = l; +} + void HTMLlineproc2(Buffer *buf, TextLineList *tl) { @@ -6300,7 +6349,7 @@ loadHTMLstream(URLFile *f, Buffer *newBuf, FILE * src, int internal) HTMLlineproc0(lineBuf2->ptr, &htmlenv1, internal); } if (obuf.status != R_ST_NORMAL) - HTMLlineproc1(correct_irrtag(obuf.status)->ptr, &htmlenv1); + HTMLlineproc0(correct_irrtag(obuf.status)->ptr, &htmlenv1, internal); obuf.status = R_ST_NORMAL; completeHTMLstream(&htmlenv1, &obuf); flushline(&htmlenv1, &obuf, 0, 2, htmlenv1.limit); @@ -7674,6 +7723,12 @@ reloadBuffer(Buffer *buf) buf->name = NULL; buf->img = NULL; buf->formitem = NULL; + buf->linklist = NULL; + buf->maplist = NULL; + if (buf->hmarklist) + buf->hmarklist->nmark = 0; + if (buf->imarklist) + buf->imarklist->nmark = 0; if (!strcasecmp(buf->type, "text/html")) loadHTMLBuffer(&uf, buf); else |