[w3m-dev 03549] link list

* anchor.c (addMultirowsImg): add a->slave
	(getAnchorText): arg AnchorList *al
	(link_list_panel): added
* funcname.tab (LIST): added
	(LIST_MENU): added
	(MOVE_LIST_MENU): added
* main.c (anchorMn): added
	(accessKey): use anchorMn()
	(listMn): added
	(movlistMn): added
	(linkLst): added
* map.c (searchMapList): not static
* menu.c (accesskey_menu): pass AnchorList to getAnchorText()
	(lmKeys): added
	(lmKeys2): added
	(nlmKeys): added
	(nlmKeys2): added
	(lmGoto): added
	(lmSelect): added
	(list_menu): added
* proto.h (linkLst): added
	(listMn): added
	(movlistMn): added
	(list_menu): added
	(searchMapList): added
	(getAnchorText): arg AnchorList *al
	(link_list_panel): added
* doc/README.func (LIST): added
	(LIST_MENU): added
	(MOVE_LIST_MENU): added
* doc-jp/README.func (LINK_MENU): fix message
	(LIST): added
	(LIST_MENU): added
	(MOVE_LIST_MENU): added
* scripts/w3mhelp.cgi.in (Page/Cursor motion): add movlistMn
	(Hyperlink operation): add linkLst linkMn
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
This commit is contained in:
Fumitoshi UKAI
2002-12-09 15:51:08 +00:00
parent 4c89fd63aa
commit 945ebeab6f
10 changed files with 338 additions and 25 deletions

116
anchor.c
View File

@@ -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);
}