aboutsummaryrefslogtreecommitdiffstats
path: root/anchor.c
diff options
context:
space:
mode:
authorFumitoshi UKAI <ukai@debian.or.jp>2002-12-05 16:29:02 +0000
committerFumitoshi UKAI <ukai@debian.or.jp>2002-12-05 16:29:02 +0000
commitd02a0802cd226cbbf73470dc76a1384f19f10199 (patch)
tree8d057025083179d6685b8480be7d7ba9ba1395eb /anchor.c
parent[w3m-dev 03528] area without alt (diff)
downloadw3m-d02a0802cd226cbbf73470dc76a1384f19f10199.tar.gz
w3m-d02a0802cd226cbbf73470dc76a1384f19f10199.zip
[w3m-dev 03529] Support of title, accesskey of anchor
* anchor.c (putAnchor): arg title, key initialize slave (registerHref): arg title, key (registerName): title = NULL, key = '\0' (registerForm): title = NULL, key = '\0' (_put_anchor_news): title = NULL, key = '\0' (_put_anchor_all): title = NULL, key = '\0' (addMultirowsImg): register title, accesskey (addMultirowsForm): title = NULL, key = '\0' (getAnchorText): added * display.c (displayBuffer): show title if any * file.c (set_breakpoint): use bcopy (back_to_breakpoint): use bcopy (flushline): s/anchor/anchor.url/ s/anchor_hseq/anchor.hseq/ s/anchor_target/anchor.target/ add anchor.* (close_effect0): s/anchor/anchor.url/ s/anchor_hseq/anchor.hseq/ (close_anchor): use bzero (process_img): ATTR_TITLE, (HTMLtagproc1): s/anchor/anchor.url/ target, referer, title, accesskey, hseq (HTMLlineproc2body): ATTR_TITLE, ATTR_ACCESSKEY (init_henv): use bzero * fm.h (Anchor): add title, accesskey, slave (Breakpoint): use Anchor (struct readbuffer): use Anchor * funcname.tab (ACCESSKEY): added (LINK_MENU): added * html.c (ALST_A): add ATTR_TITLE, ATTR_ACCESSKEY (ALST_IMG): add ATTR_TITLE (ALST_IMG_ALT): add ATTR_TITLE (AttrMAP): add accesskey, renum * html.h (ATTR_ACCESSKEY): added (ATTR_*): renum 50->60 * main.c (linkMn): added (accessKey): added * menu.c (LinkMenu): deleted (LinkV): deleted (initLinkMenu): deleted (lmGoURL): deleted (popupMenu): delete initLinkMenu() (initMenu): delete Link (link_menu): added (accesskey_menu): added * proto.h (linkMn): added (link_menu): added (accessKey): added (accesskey_menu): added (putAnchor): arg title, key (registerHref): arg title, key (registerImg): arg title (getAnchorText): added * doc/README.func (ACCESSKEY): added (LINK_MENU): added * doc-jp/README.func (ACCESSKEY): added (LINK_MENU): added * scripts/w3mhelp.cgi.in (Hyperlink operation): add linkMn accessKey From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
Diffstat (limited to '')
-rw-r--r--anchor.c77
1 files changed, 59 insertions, 18 deletions
diff --git a/anchor.c b/anchor.c
index 74a5c21..f38822c 100644
--- a/anchor.c
+++ b/anchor.c
@@ -1,4 +1,4 @@
-/* $Id: anchor.c,v 1.11 2002/09/05 15:43:21 ukai Exp $ */
+/* $Id: anchor.c,v 1.12 2002/12/05 16:29:04 ukai Exp $ */
#include "fm.h"
#include "myctype.h"
#include "regex.h"
@@ -7,7 +7,7 @@
AnchorList *
putAnchor(AnchorList *al, char *url, char *target, Anchor **anchor_return,
- char *referer, int line, int pos)
+ char *referer, char *title, unsigned char key, int line, int pos)
{
int n, i, j;
Anchor *a;
@@ -44,6 +44,9 @@ putAnchor(AnchorList *al, char *url, char *target, Anchor **anchor_return,
a->url = url;
a->target = target;
a->referer = referer;
+ a->title = title;
+ a->accesskey = key;
+ a->slave = FALSE;
a->start = bp;
a->end = bp;
al->nanchor++;
@@ -54,11 +57,12 @@ putAnchor(AnchorList *al, char *url, char *target, Anchor **anchor_return,
Anchor *
-registerHref(Buffer *buf, char *url, char *target, char *referer, int line,
- int pos)
+registerHref(Buffer *buf, char *url, char *target, char *referer, char *title,
+ unsigned char key, int line, int pos)
{
Anchor *a;
- buf->href = putAnchor(buf->href, url, target, &a, referer, line, pos);
+ buf->href = putAnchor(buf->href, url, target, &a, referer, title, key,
+ line, pos);
return a;
}
@@ -66,15 +70,17 @@ Anchor *
registerName(Buffer *buf, char *url, int line, int pos)
{
Anchor *a;
- buf->name = putAnchor(buf->name, url, NULL, &a, NULL, line, pos);
+ buf->name = putAnchor(buf->name, url, NULL, &a, NULL, NULL, '\0', line,
+ pos);
return a;
}
Anchor *
-registerImg(Buffer *buf, char *url, int line, int pos)
+registerImg(Buffer *buf, char *url, char *title, int line, int pos)
{
Anchor *a;
- buf->img = putAnchor(buf->img, url, NULL, &a, NULL, line, pos);
+ buf->img = putAnchor(buf->img, url, NULL, &a, NULL, title, '\0', line,
+ pos);
return a;
}
@@ -88,8 +94,8 @@ registerForm(Buffer *buf, FormList *flist, struct parsed_tag *tag, int line,
fi = formList_addInput(flist, tag);
if (fi == NULL)
return NULL;
- buf->formitem = putAnchor(buf->formitem,
- (char *)fi, flist->target, &a, NULL, line, pos);
+ buf->formitem = putAnchor(buf->formitem, (char *)fi, flist->target, &a,
+ NULL, NULL, '\0', line, pos);
return a;
}
@@ -193,15 +199,16 @@ _put_anchor_news(Buffer *buf, char *p1, char *p2, int line, int pos)
tmp = Strnew_size(sizeof("news:") - 1 + (p2 - p1));
Strcat_charp_n(tmp, "news:", sizeof("news:") - 1);
Strcat_charp_n(tmp, p1, p2 - p1);
- return registerHref(buf, tmp->ptr, NULL, NO_REFERER, line, pos);
+ return registerHref(buf, tmp->ptr, NULL, NO_REFERER, NULL, '\0', line,
+ pos);
}
#endif /* USE_NNTP */
static Anchor *
_put_anchor_all(Buffer *buf, char *p1, char *p2, int line, int pos)
{
- return registerHref(buf, allocStr(p1, p2 - p1), NULL, NO_REFERER, line,
- pos);
+ return registerHref(buf, allocStr(p1, p2 - p1), NULL, NO_REFERER, NULL,
+ '\0', line, pos);
}
static void
@@ -471,7 +478,7 @@ addMultirowsImg(Buffer *buf, AnchorList *al)
if (a_img.start.line == l->linenumber)
continue;
pos = columnPos(l, col);
- a = registerImg(buf, a_img.url, l->linenumber, pos);
+ a = registerImg(buf, a_img.url, a_img.title, l->linenumber, pos);
a->hseq = -a_img.hseq;
a->image = img;
a->end.pos = pos + ecol - col;
@@ -479,15 +486,17 @@ addMultirowsImg(Buffer *buf, AnchorList *al)
l->propBuf[k] |= PE_IMAGE;
if (a_href.url) {
a = registerHref(buf, a_href.url, a_href.target,
- a_href.referer, l->linenumber, pos);
+ a_href.referer, a_href.title,
+ a_href.accesskey, l->linenumber, pos);
a->hseq = a_href.hseq;
+ a->slave = TRUE;
a->end.pos = pos + ecol - col;
for (k = pos; k < a->end.pos; k++)
l->propBuf[k] |= PE_ANCHOR;
}
if (a_form.url) {
buf->formitem = putAnchor(buf->formitem, a_form.url,
- a_form.target, &a, NULL,
+ a_form.target, &a, NULL, NULL, '\0',
l->linenumber, pos);
a->hseq = a_form.hseq;
a->end.pos = pos + ecol - col;
@@ -542,8 +551,8 @@ addMultirowsForm(Buffer *buf, AnchorList *al)
if (a_form.start.line == l->linenumber)
continue;
buf->formitem = putAnchor(buf->formitem, a_form.url,
- a_form.target, &a, NULL, l->linenumber,
- pos);
+ a_form.target, &a, NULL, NULL, '\0',
+ l->linenumber, pos);
a->hseq = a_form.hseq;
a->y = a_form.y;
a->end.pos = pos + ecol - col;
@@ -554,3 +563,35 @@ addMultirowsForm(Buffer *buf, AnchorList *al)
}
}
}
+
+char *
+getAnchorText(Buffer *buf, Anchor *a)
+{
+ AnchorList *al = buf->href;
+ int hseq, i;
+ Line *l;
+ Str tmp = NULL;
+
+ if (!a || a->hseq < 0)
+ return NULL;
+ hseq = a->hseq;
+ l = buf->firstLine;
+ for (i = 0; i < al->nanchor; i++) {
+ a = &al->anchors[i];
+ if (a->hseq != hseq)
+ continue;
+ for (; l; l = l->next) {
+ if (l->linenumber == a->start.line)
+ break;
+ }
+ if (!l)
+ break;
+ if (!tmp)
+ tmp = Strnew_size(a->end.pos - a->start.pos);
+ else
+ Strcat_char(tmp, ' ');
+ Strcat_charp_n(tmp, &l->lineBuf[a->start.pos],
+ a->end.pos - a->start.pos);
+ }
+ return tmp ? tmp->ptr : NULL;
+}