diff options
Diffstat (limited to '')
| -rw-r--r-- | ChangeLog | 41 | ||||
| -rw-r--r-- | buffer.c | 9 | ||||
| -rw-r--r-- | file.c | 59 | ||||
| -rw-r--r-- | fm.h | 14 | ||||
| -rw-r--r-- | html.c | 42 | ||||
| -rw-r--r-- | html.h | 35 | ||||
| -rw-r--r-- | map.c | 48 | ||||
| -rw-r--r-- | menu.c | 78 | ||||
| -rw-r--r-- | tagtable.tab | 1 | 
9 files changed, 279 insertions, 48 deletions
| @@ -1,3 +1,42 @@ +2002-12-03  Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + +	* [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 + +2002-11-29  Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + +	* [w3m bug] internal tag +	* display.c (loadHTMLstream): HTMLlineproc0 internal +  2002-11-29  Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>  	* [w3m-dev 03498] Re: parse <!-- ... --> in <script> @@ -5248,4 +5287,4 @@ a	* [w3m-dev 03276] compile error on EWS4800  	* release-0-2-1  	* import w3m-0.2.1 -$Id: ChangeLog,v 1.571 2002/11/28 16:00:33 ukai Exp $ +$Id: ChangeLog,v 1.572 2002/12/02 17:27:34 ukai Exp $ @@ -1,4 +1,4 @@ -/* $Id: buffer.c,v 1.15 2002/11/15 15:51:23 ukai Exp $ */ +/* $Id: buffer.c,v 1.16 2002/12/02 17:27:36 ukai Exp $ */  #include "fm.h"  #ifdef USE_MOUSE @@ -517,6 +517,13 @@ reshapeBuffer(Buffer *buf)      buf->name = NULL;      buf->img = NULL;      buf->formitem = NULL; +    buf->formlist = NULL; +    buf->linklist = NULL; +    buf->maplist = NULL; +    if (buf->hmarklist) +	buf->hmarklist->nmark = 0; +    if (buf->imarklist) +	buf->imarklist->nmark = 0;      buf->width = INIT_BUFFER_WIDTH;  #ifdef JP_CHARSET @@ -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 @@ -1,4 +1,4 @@ -/* $Id: fm.h,v 1.89 2002/11/26 18:03:26 ukai Exp $ */ +/* $Id: fm.h,v 1.90 2002/12/02 17:27:37 ukai Exp $ */  /*    * w3m: WWW wo Miru utility   *  @@ -384,6 +384,17 @@ typedef struct {      int prevhseq;  } HmarkerList; +#define LINK_TYPE_NONE 0 +#define LINK_TYPE_REL  1 +#define LINK_TYPE_REV  2 +typedef struct _LinkList { +    char *url; +    char *title;	/* Next, Contents, ... */ +    char *ctype;	/* Content-Type */ +    char type;		/* Rel, Rev */ +    struct _LinkList *next; +} LinkList; +  typedef struct _Buffer {      char *filename;      char *buffername; @@ -413,6 +424,7 @@ typedef struct _Buffer {      AnchorList *name;      AnchorList *img;      AnchorList *formitem; +    LinkList *linklist;      FormList *formlist;      MapList *maplist;      HmarkerList *hmarklist; @@ -1,4 +1,4 @@ -/* $Id: html.c,v 1.15 2002/11/05 17:10:05 ukai Exp $ */ +/* $Id: html.c,v 1.16 2002/12/02 17:27:38 ukai Exp $ */  #include "html.h"  /* Define HTML Tag Infomation Table */ @@ -18,6 +18,9 @@ unsigned char ALST_LI[] = { ATTR_TYPE, ATTR_VALUE, ATTR_CORE };  #define MAXA_LI		MAXA_CORE + 2  unsigned char ALST_HR[] = { ATTR_WIDTH, ATTR_ALIGN, ATTR_CORE };  #define MAXA_HR		MAXA_CORE + 2 +unsigned char ALST_LINK[] = { ATTR_HREF, ATTR_HSEQ, ATTR_REL, ATTR_REV, +    ATTR_TITLE, ATTR_TYPE, ATTR_CORE }; +#define MAXA_LINK	MAXA_CORE + sizeof ALST_LINK/sizeof ALST_LINK[0] - 1  unsigned char ALST_DL[] = { ATTR_COMPACT, ATTR_CORE };  #define MAXA_DL		MAXA_CORE + 1  unsigned char ALST_PRE[] = { ATTR_FOR_TABLE, ATTR_CORE }; @@ -220,7 +223,7 @@ TagInfo TagMAP[MAX_HTMLTAG] = {      {"/sup", NULL, 0, 0},	/* 101 HTML_N_SUP       */      {"sub", NULL, 0, 0},	/* 102 HTML_SUB       */      {"/sub", NULL, 0, 0},	/* 103 HTML_N_SUB       */ -    {NULL, NULL, 0, 0},		/* 104 Undefined       */ +    {"link", ALST_LINK, MAXA_LINK, 0},  /*  104 HTML_LINK      */      {NULL, NULL, 0, 0},		/* 105 Undefined       */      /* pseudo tag */ @@ -296,24 +299,23 @@ TagAttrInfo AttrMAP[MAX_TAGATTR] = {      {"shape", VTYPE_STR, 0},	/* 44 ATTR_SHAPE          */      {"coords", VTYPE_STR, 0},	/* 45 ATTR_COORDS         */      {"ismap", VTYPE_NONE, 0},	/* 46 ATTR_ISMAP          */ - -    {NULL, VTYPE_NONE, 0},	/* 47 Undefined           */ -    {NULL, VTYPE_NONE, 0},	/* 48 Undefined           */ +    {"rel", VTYPE_STR, 0},	/* 47 ATTR_REL            */ +    {"rev", VTYPE_STR, 0},	/* 48 ATTR_REV            */ +    {"title", VTYPE_STR, 0},	/* 49 ATTR_TITLE          */      /* Internal attribute */ -    {"xoffset", VTYPE_NUMBER, AFLG_INT},	/* 49 ATTR_XOFFSET        */ -    {"yoffset", VTYPE_NUMBER, AFLG_INT},	/* 50 ATTR_YOFFSET        */ -    {"top_margin", VTYPE_NUMBER, AFLG_INT},	/* 51 ATTR_TOP_MARGIN,    */ -    {"bottom_margin", VTYPE_NUMBER, AFLG_INT},	/* 52 ATTR_BOTTOM_MARGIN, */ -    {"tid", VTYPE_NUMBER, AFLG_INT},	/* 53 ATTR_TID            */ -    {"fid", VTYPE_NUMBER, AFLG_INT},	/* 54 ATTR_FID            */ -    {"for_table", VTYPE_NONE, AFLG_INT},	/* 55 ATTR_FOR_TABLE      */ -    {"framename", VTYPE_STR, AFLG_INT},	/* 56 ATTR_FRAMENAME      */ -    {"hborder", VTYPE_NONE, 0},	/* 57 ATTR_HBORDER        */ -    {"hseq", VTYPE_NUMBER, AFLG_INT},	/* 58 ATTR_HSEQ           */ -    {"no_effect", VTYPE_NONE, AFLG_INT},	/* 59 ATTR_NO_EFFECT      */ -    {"referer", VTYPE_STR, AFLG_INT},	/* 60 ATTR_REFERER        */ -    {"selectnumber", VTYPE_NUMBER, AFLG_INT},	/* 61 ATTR_SELECTNUMBER   */ -    {"textareanumber", VTYPE_NUMBER, AFLG_INT},	/* 62 ATTR_TEXTAREANUMBER */ -    {"title", VTYPE_STR, AFLG_INT},	/* 63 ATTR_TITLE          */ +    {"xoffset", VTYPE_NUMBER, AFLG_INT},	/* 50 ATTR_XOFFSET        */ +    {"yoffset", VTYPE_NUMBER, AFLG_INT},	/* 51 ATTR_YOFFSET        */ +    {"top_margin", VTYPE_NUMBER, AFLG_INT},	/* 52 ATTR_TOP_MARGIN,    */ +    {"bottom_margin", VTYPE_NUMBER, AFLG_INT},	/* 53 ATTR_BOTTOM_MARGIN, */ +    {"tid", VTYPE_NUMBER, AFLG_INT},	/* 54 ATTR_TID            */ +    {"fid", VTYPE_NUMBER, AFLG_INT},	/* 55 ATTR_FID            */ +    {"for_table", VTYPE_NONE, AFLG_INT},	/* 56 ATTR_FOR_TABLE      */ +    {"framename", VTYPE_STR, AFLG_INT},	/* 57 ATTR_FRAMENAME      */ +    {"hborder", VTYPE_NONE, 0},	/* 58 ATTR_HBORDER        */ +    {"hseq", VTYPE_NUMBER, AFLG_INT},	/* 59 ATTR_HSEQ           */ +    {"no_effect", VTYPE_NONE, AFLG_INT},	/* 60 ATTR_NO_EFFECT      */ +    {"referer", VTYPE_STR, AFLG_INT},	/* 61 ATTR_REFERER        */ +    {"selectnumber", VTYPE_NUMBER, AFLG_INT},	/* 62 ATTR_SELECTNUMBER   */ +    {"textareanumber", VTYPE_NUMBER, AFLG_INT},	/* 63 ATTR_TEXTAREANUMBER */  }; @@ -1,4 +1,4 @@ -/* $Id: html.h,v 1.10 2002/11/15 15:19:45 ukai Exp $ */ +/* $Id: html.h,v 1.11 2002/12/02 17:27:39 ukai Exp $ */  #ifndef _HTML_H  #define _HTML_H  #ifdef USE_SSL @@ -190,6 +190,7 @@ typedef struct {  #define HTML_N_SUP	101  #define HTML_SUB	102  #define HTML_N_SUB	103 +#define HTML_LINK       104     /* pseudo tag */  #define HTML_INTERNAL       106 @@ -266,23 +267,25 @@ typedef struct {  #define ATTR_SHAPE		44  #define ATTR_COORDS		45  #define ATTR_ISMAP		46 +#define ATTR_REL		47 +#define ATTR_REV		48 +#define ATTR_TITLE		49  /* Internal attribute */ -#define ATTR_XOFFSET		49 -#define ATTR_YOFFSET		50 -#define ATTR_TOP_MARGIN		51 -#define ATTR_BOTTOM_MARGIN	52 -#define ATTR_TID		53 -#define ATTR_FID		54 -#define ATTR_FOR_TABLE		55 -#define ATTR_FRAMENAME		56 -#define ATTR_HBORDER		57 -#define ATTR_HSEQ		58 -#define ATTR_NO_EFFECT		59 -#define ATTR_REFERER		60 -#define ATTR_SELECTNUMBER	61 -#define ATTR_TEXTAREANUMBER	62 -#define ATTR_TITLE		63 +#define ATTR_XOFFSET		50 +#define ATTR_YOFFSET		51 +#define ATTR_TOP_MARGIN		52 +#define ATTR_BOTTOM_MARGIN	53 +#define ATTR_TID		54 +#define ATTR_FID		55 +#define ATTR_FOR_TABLE		56 +#define ATTR_FRAMENAME		57 +#define ATTR_HBORDER		58 +#define ATTR_HSEQ		59 +#define ATTR_NO_EFFECT		60 +#define ATTR_REFERER		61 +#define ATTR_SELECTNUMBER	62 +#define ATTR_TEXTAREANUMBER	63  #define MAX_TAGATTR		64 @@ -1,4 +1,4 @@ -/* $Id: map.c,v 1.16 2002/11/25 17:10:52 ukai Exp $ */ +/* $Id: map.c,v 1.17 2002/12/02 17:27:39 ukai Exp $ */  /*   * client-side image maps   */ @@ -408,13 +408,49 @@ append_map_info(Buffer *buf, Str tmp, FormItemList *fi)  	    continue;  	parseURL2(a->url, &pu, baseURL(buf));  	url = html_quote(parsedURL2Str(&pu)->ptr); -	Strcat_m_charp(tmp, "<tr><td>  <td>", -		       html_quote(a->alt), "<td><a href=\"", url, "\">", url, -		       "</a>\n", NULL); +	Strcat_m_charp(tmp, "<tr><td>  <td><a href=\"", url, "\">", +		       html_quote(a->alt), "</a><td>", html_quote(a->url), +		       "\n", NULL);      }      Strcat_charp(tmp, "</table>");  } +/* append links */ +static void +append_link_info(Buffer *buf, Str html, LinkList *link) +{ +    LinkList  *l; +    ParsedURL pu; +    char *url; + +    if (!link) +	return; + +    Strcat_charp(html, "<hr width=50%><h1>Link information</h1>"); +    Strcat_charp(html, "<TABLE>\n"); +    for (l = link; l; l = l->next) { +	if (l->url) { +	    parseURL2(l->url, &pu, baseURL(buf)); +	    url = html_quote(parsedURL2Str(&pu)->ptr); +	} +	else +	    url = "(empty)"; +	Strcat_m_charp(html, "<TR><TD><A HREF=\"", url, "\">", +		       l->title ? html_quote(l->title) : "(empty)", "</A><TD>", +		       NULL); +	if (l->type == LINK_TYPE_REL) +	    Strcat_charp(html, "[Rel]"); +	else if (l->type == LINK_TYPE_REV) +	    Strcat_charp(html, "[Rev]"); +	Strcat_m_charp(html, "<TD>", l->url ? html_quote(l->url) : "(empty)", +		       NULL); +	if (l->ctype) +	    Strcat_m_charp(html, " (", html_quote(l->ctype), ")", NULL); +	Strcat_charp(html, "\n"); +    } +    Strcat_charp(html, "</TABLE>\n"); +} +  /* append frame URL */  static void  append_frame_info(Buffer *buf, Str html, struct frameset *set, int level) @@ -539,6 +575,9 @@ page_info_panel(Buffer *buf)  	    append_map_info(buf, tmp, fi->parent->item);      }      Strcat_charp(tmp, "</table>\n"); + +    append_link_info(buf, tmp, buf->linklist); +      if (buf->document_header != NULL) {  	Strcat_charp(tmp, "<hr width=50%>\n");  	Strcat_charp(tmp, "<h1>Header information</h1>\n"); @@ -547,6 +586,7 @@ page_info_panel(Buffer *buf)  	    Strcat_charp(tmp, "<br>");  	}      } +      if (buf->frameset != NULL)  	f_set = buf->frameset;      else if (buf->bufferprop & BP_FRAME && @@ -1,4 +1,4 @@ -/* $Id: menu.c,v 1.22 2002/11/27 16:29:14 ukai Exp $ */ +/* $Id: menu.c,v 1.23 2002/12/02 17:27:41 ukai Exp $ */  /*    * w3m menu.c   */ @@ -288,6 +288,11 @@ static int smDelTab(char c);  /* --- SelTabMenu (END) --- */ +static Menu LinkMenu; +static int LinkV = 0; +static void initLinkMenu(void); +static void lmGoURL(void); +  /* --- MainMenu --- */  static Menu MainMenu; @@ -1313,6 +1318,7 @@ popupMenu(int x, int y, Menu *menu)  {      initSelectMenu();      initSelTabMenu(); +    initLinkMenu();      menu->cursorX = Currentbuf->cursorX + Currentbuf->rootX;      menu->cursorY = Currentbuf->cursorY + Currentbuf->rootY; @@ -1642,6 +1648,69 @@ smDelTab(char c)  /* --- SelectMenu (END) --- */ +/* --- LinkMenu --- */ + +static void +initLinkMenu(void) +{ +    LinkList *l; +    int i, nitem, len = 0; +    char **label; +    Str str; + +    if (!Currentbuf->linklist) { +	LinkMenu.item = NULL; +	LinkMenu.nitem = 0; +	return; +    } +    for (i = 0, l = Currentbuf->linklist; l; i++, l = l->next) ; +    nitem = i; + +    label = New_N(char *, nitem + 1); +    for (i = 0, l = Currentbuf->linklist; l; i++, l = l->next) { +	str = Strnew_charp(l->title ? l->title : "(empty)"); +	if (l->type == LINK_TYPE_REL) +	    Strcat_charp(str, " [Rel] "); +	else if (l->type == LINK_TYPE_REV) +	    Strcat_charp(str, " [Rev] "); +	else +	    Strcat_charp(str, " "); +	Strcat_charp(str, l->url ? l->url : ""); +	label[i] = str->ptr; +	if (len < str->length) +	    len = str->length; +    } +    label[nitem + 1] = NULL; +    LinkV = 0; + +    new_option_menu(&LinkMenu, label, &LinkV, lmGoURL); +    LinkMenu.initial = LinkV; +    LinkMenu.cursorX = Currentbuf->cursorX + Currentbuf->rootX; +    LinkMenu.cursorY = Currentbuf->cursorY + Currentbuf->rootY; +} + +static void +lmGoURL(void) +{ +    LinkList *l; +    int i; +    ParsedURL pu; + +    for (i = 0, l = Currentbuf->linklist; l; i++, l = l->next) { +	if (i == LinkV) +	    break; +    } +    if (l == NULL || l->url == NULL) +	return; +    CurrentKey = -1; +    CurrentKeyData = NULL; +    CurrentCmdData = l->url; +    gorURL(); +    CurrentCmdData = NULL; +} + +/* --- LinkMenu (END) --- */ +  /* --- OptionMenu --- */  void @@ -1674,7 +1743,7 @@ initMenu(void)      MenuItem *item = NULL;      MenuList *list; -    w3mMenuList = New_N(MenuList, 3); +    w3mMenuList = New_N(MenuList, 4);      w3mMenuList[0].id = "Main";      w3mMenuList[0].menu = &MainMenu;      w3mMenuList[0].item = MainMenuItem; @@ -1684,7 +1753,10 @@ initMenu(void)      w3mMenuList[2].id = "SelectTab";      w3mMenuList[2].menu = &SelTabMenu;      w3mMenuList[2].item = NULL; -    w3mMenuList[3].id = NULL; +    w3mMenuList[3].id = "Link"; +    w3mMenuList[3].menu = &LinkMenu; +    w3mMenuList[3].item = NULL; +    w3mMenuList[4].id = NULL;      if ((mf = fopen(rcFile(MENU_FILE), "rt")) == NULL)  	goto create_menu; diff --git a/tagtable.tab b/tagtable.tab index 31208fb..17aaa92 100644 --- a/tagtable.tab +++ b/tagtable.tab @@ -117,6 +117,7 @@ style		HTML_STYLE  wbr		HTML_WBR  head           HTML_HEAD  /head          HTML_N_HEAD +link           HTML_LINK  body		HTML_BODY  /body		HTML_N_BODY  html		HTML_BODY | 
