commit a5289e7ccb7a659944fbf5aab2a2784354402153
parent 81e7ecc81b174cc0bbb53455a6ae423c1ef8bede
Author: ukai <ukai>
Date: Thu, 5 Dec 2002 16:29:02 +0000
[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:
M | ChangeLog | | | 63 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
M | anchor.c | | | 75 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------- |
M | display.c | | | 11 | ++++++++++- |
M | doc-jp/README.func | | | 2 | ++ |
M | doc/README.func | | | 2 | ++ |
M | file.c | | | 116 | ++++++++++++++++++++++++++++++++++++++++++++++++------------------------------- |
M | fm.h | | | 11 | +++++------ |
M | funcname.tab | | | 2 | ++ |
M | html.c | | | 51 | +++++++++++++++++++++++++++++++-------------------- |
M | html.h | | | 33 | +++++++++++++++++---------------- |
M | main.c | | | 41 | +++++++++++++++++++++++++++++++++++++++++ |
M | menu.c | | | 203 | ++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------- |
M | proto.h | | | 19 | ++++++++++++++++--- |
M | scripts/w3mhelp.cgi.in | | | 2 | +- |
14 files changed, 449 insertions(+), 182 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -1,5 +1,68 @@
2002-12-06 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
+ * [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
+
+2002-12-06 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
+
* [w3m-dev 03528] area without alt
* map.c (getCurrentMapLabel): when a->alt is empty
diff --git a/anchor.c b/anchor.c
@@ -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;
+}
diff --git a/display.c b/display.c
@@ -348,10 +348,19 @@ displayBuffer(Buffer *buf, int mode)
#endif
{
Anchor *a = retrieveCurrentAnchor(buf);
+ if (a && a->title && *a->title)
+ s = Sprintf("[%s] ", a->title);
+ else {
+ Anchor *a_img = retrieveCurrentImg(buf);
+ if (a_img && a_img->title && *a_img->title)
+ s = Sprintf("[%s]%s", a_img->title, a ? " " : "");
+ }
if (a) {
ParsedURL pu;
parseURL2(a->url, &pu, baseURL(buf));
- s = parsedURL2Str(&pu);
+ if (!s)
+ s = Strnew();
+ Strcat(s, parsedURL2Str(&pu));
}
}
}
diff --git a/doc-jp/README.func b/doc-jp/README.func
@@ -1,4 +1,5 @@
ABORT 確認せずにw3mを終了します
+ACCESSKEY Accesskey メニューを立ち上げます
ALARM アラームを設定します
ADD_BOOKMARK 現在見ているページをブックマークに追加します
BACK 一つ前のバッファを表示します
@@ -43,6 +44,7 @@ LINE_END
LINE_INFO ページ中での現在位置を表示します
LINK_BEGIN 最初のリンクに移動します
LINK_END 最後のリンクに移動します
+LINK_MENU Link メニューを立ち上げます
LOAD ローカルファイルを指定して開きます
MAIN_MENU メニューを立ち上げます
MARK マークを設定/解除します
diff --git a/doc/README.func b/doc/README.func
@@ -1,4 +1,5 @@
ABORT Quit w3m without confirmation
+ACCESSSKEY Popup acceskey menu
ADD_BOOKMARK Add current page to bookmark
ALARM Set alarm
BACK Back to previous buffer
@@ -43,6 +44,7 @@ LINE_END Go to the end of line
LINE_INFO Show current line number
LINK_BEGIN Go to the first link
LINK_END Go to the last link
+LINK_MENU Popup link element menu
LOAD Load local file
MAIN_MENU Popup menu
MARK Set/unset mark
diff --git a/file.c b/file.c
@@ -2243,9 +2243,8 @@ set_breakpoint(struct readbuffer *obuf, int tag_length)
if (!obuf->bp.init_flag)
return;
- obuf->bp.anchor = obuf->anchor;
- obuf->bp.anchor_target = obuf->anchor_target;
- obuf->bp.anchor_hseq = obuf->anchor_hseq;
+ bcopy((void *)&obuf->anchor, (void *)&obuf->bp.anchor,
+ sizeof(obuf->anchor));
obuf->bp.img_alt = obuf->img_alt;
obuf->bp.in_bold = obuf->in_bold;
obuf->bp.in_under = obuf->in_under;
@@ -2258,9 +2257,8 @@ static void
back_to_breakpoint(struct readbuffer *obuf)
{
obuf->flag = obuf->bp.flag;
- obuf->anchor = obuf->bp.anchor;
- obuf->anchor_target = obuf->bp.anchor_target;
- obuf->anchor_hseq = obuf->bp.anchor_hseq;
+ bcopy((void *)&obuf->bp.anchor, (void *)&obuf->anchor,
+ sizeof(obuf->anchor));
obuf->img_alt = obuf->bp.img_alt;
obuf->in_bold = obuf->bp.in_bold;
obuf->in_under = obuf->bp.in_under;
@@ -2529,7 +2527,7 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent,
append_tags(obuf);
- if (obuf->anchor)
+ if (obuf->anchor.url)
hidden = hidden_anchor = has_hidden_link(obuf, HTML_A);
if (obuf->img_alt) {
if ((hidden_img = has_hidden_link(obuf, HTML_IMG_ALT)) != NULL) {
@@ -2566,7 +2564,7 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent,
}
}
- if (obuf->anchor && !hidden_anchor)
+ if (obuf->anchor.url && !hidden_anchor)
Strcat_charp(line, "</a>");
if (obuf->img_alt && !hidden_img)
Strcat_charp(line, "</img_alt>");
@@ -2739,15 +2737,31 @@ flushline(struct html_feed_environ *h_env, struct readbuffer *obuf, int indent,
fillline(obuf, indent);
if (pass)
passthrough(obuf, pass->ptr, 0);
- if (!hidden_anchor && obuf->anchor) {
+ if (!hidden_anchor && obuf->anchor.url) {
Str tmp;
- if (obuf->anchor_hseq > 0)
- obuf->anchor_hseq = -obuf->anchor_hseq;
- tmp = Sprintf("<A HSEQ=\"%d\" HREF=\"", obuf->anchor_hseq);
- Strcat_charp(tmp, html_quote(obuf->anchor->ptr));
- if (obuf->anchor_target) {
+ if (obuf->anchor.hseq > 0)
+ obuf->anchor.hseq = -obuf->anchor.hseq;
+ tmp = Sprintf("<A HSEQ=\"%d\" HREF=\"", obuf->anchor.hseq);
+ Strcat_charp(tmp, html_quote(obuf->anchor.url));
+ if (obuf->anchor.target) {
Strcat_charp(tmp, "\" TARGET=\"");
- Strcat_charp(tmp, html_quote(obuf->anchor_target->ptr));
+ Strcat_charp(tmp, html_quote(obuf->anchor.target));
+ }
+ if (obuf->anchor.referer) {
+ Strcat_charp(tmp, "\" REFERER=\"");
+ Strcat_charp(tmp, html_quote(obuf->anchor.referer));
+ }
+ if (obuf->anchor.title) {
+ Strcat_charp(tmp, "\" TITLE=\"");
+ Strcat_charp(tmp, html_quote(obuf->anchor.title));
+ }
+ if (obuf->anchor.accesskey) {
+ char *c = html_quote_char(obuf->anchor.accesskey);
+ Strcat_charp(tmp, "\" ACCESSKEY=\"");
+ if (c)
+ Strcat_charp(tmp, c);
+ else
+ Strcat_char(tmp, obuf->anchor.accesskey);
}
Strcat_charp(tmp, "\">");
push_tag(obuf, tmp->ptr, HTML_A);
@@ -2832,7 +2846,7 @@ close_effect0(struct readbuffer *obuf, int cmd)
static void
close_anchor(struct html_feed_environ *h_env, struct readbuffer *obuf)
{
- if (obuf->anchor) {
+ if (obuf->anchor.url) {
int i;
char *p = NULL;
int is_erased = 0;
@@ -2841,14 +2855,14 @@ close_anchor(struct html_feed_environ *h_env, struct readbuffer *obuf)
if (obuf->tag_stack[i]->cmd == HTML_A)
break;
}
- if (i < 0 && obuf->anchor_hseq > 0 && Strlastchar(obuf->line) == ' ') {
+ if (i < 0 && obuf->anchor.hseq > 0 && Strlastchar(obuf->line) == ' ') {
Strshrink(obuf->line, 1);
obuf->pos--;
is_erased = 1;
}
if (i >= 0 || (p = has_hidden_link(obuf, HTML_A))) {
- if (obuf->anchor_hseq > 0) {
+ if (obuf->anchor.hseq > 0) {
HTMLlineproc1(ANSP, h_env);
obuf->prevchar = ' ';
}
@@ -2861,8 +2875,7 @@ close_anchor(struct html_feed_environ *h_env, struct readbuffer *obuf)
else {
passthrough(obuf, p, 1);
}
- obuf->anchor = NULL;
- obuf->anchor_target = NULL;
+ bzero((void *)&obuf->anchor, sizeof(obuf->anchor));
return;
}
is_erased = 0;
@@ -2873,9 +2886,8 @@ close_anchor(struct html_feed_environ *h_env, struct readbuffer *obuf)
}
push_tag(obuf, "</a>", HTML_N_A);
- obuf->anchor = NULL;
}
- obuf->anchor_target = NULL;
+ bzero((void *)&obuf->anchor, sizeof(obuf->anchor));
}
void
@@ -2909,7 +2921,7 @@ restore_fonteffect(struct html_feed_environ *h_env, struct readbuffer *obuf)
Str
process_img(struct parsed_tag *tag, int width)
{
- char *p, *q, *r, *r2 = NULL, *s;
+ char *p, *q, *r, *r2 = NULL, *s, *t;
#ifdef USE_IMAGE
int w, i, nw, ni = 1, n, w0 = -1, i0 = -1;
int align, xoffset, yoffset, top, bottom, ismap = 0;
@@ -2925,6 +2937,8 @@ process_img(struct parsed_tag *tag, int width)
p = remove_space(p);
q = NULL;
parsedtag_get_value(tag, ATTR_ALT, &q);
+ t = q;
+ parsedtag_get_value(tag, ATTR_TITLE, &t);
w = -1;
if (parsedtag_get_value(tag, ATTR_WIDTH, &w)) {
if (w < 0) {
@@ -3053,6 +3067,11 @@ process_img(struct parsed_tag *tag, int width)
}
Strcat_charp(tmp, html_quote(p));
Strcat_charp(tmp, "\"");
+ if (t) {
+ Strcat_charp(tmp, " title=\"");
+ Strcat_charp(tmp, html_quote(t));
+ Strcat_charp(tmp, "\"");
+ }
#ifdef USE_IMAGE
if (use_image) {
if (w0 >= 0)
@@ -4441,20 +4460,26 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env)
obuf->end_tag = 0;
return 1;
case HTML_A:
- if (obuf->anchor)
+ if (obuf->anchor.url)
close_anchor(h_env, obuf);
hseq = 0;
if (parsedtag_get_value(tag, ATTR_HREF, &p))
- obuf->anchor = Strnew_charp(p);
+ obuf->anchor.url = Strnew_charp(p)->ptr;
if (parsedtag_get_value(tag, ATTR_TARGET, &p))
- obuf->anchor_target = Strnew_charp(p);
+ obuf->anchor.target = Strnew_charp(p)->ptr;
+ if (parsedtag_get_value(tag, ATTR_REFERER, &p))
+ obuf->anchor.referer = Strnew_charp(p)->ptr;
+ if (parsedtag_get_value(tag, ATTR_TITLE, &p))
+ obuf->anchor.title = Strnew_charp(p)->ptr;
+ if (parsedtag_get_value(tag, ATTR_ACCESSKEY, &p))
+ obuf->anchor.accesskey = (unsigned char)*p;
if (parsedtag_get_value(tag, ATTR_HSEQ, &hseq))
- obuf->anchor_hseq = hseq;
+ obuf->anchor.hseq = hseq;
- if (hseq == 0 && obuf->anchor) {
- obuf->anchor_hseq = cur_hseq;
+ if (hseq == 0 && obuf->anchor.url) {
+ obuf->anchor.hseq = cur_hseq;
tmp = process_anchor(tag, h_env->tagbuf->ptr);
push_tag(obuf, tmp->ptr, HTML_A);
return 1;
@@ -4951,8 +4976,9 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
idFrame = NULL;
}
}
- p = r = NULL;
+ p = r = s = NULL;
q = buf->baseTarget;
+ t = "";
hseq = 0;
id = NULL;
if (parsedtag_get_value(tag, ATTR_NAME, &id)) {
@@ -4967,6 +4993,8 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
q = url_quote_conv(q, buf->document_code);
if (parsedtag_get_value(tag, ATTR_REFERER, &r))
r = url_quote_conv(r, buf->document_code);
+ parsedtag_get_value(tag, ATTR_TITLE, &s);
+ parsedtag_get_value(tag, ATTR_ACCESSKEY, &t);
parsedtag_get_value(tag, ATTR_HSEQ, &hseq);
if (hseq > 0)
buf->hmarklist =
@@ -4974,16 +5002,15 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
pos, hseq - 1);
if (id && idFrame)
idFrame->body->nameList =
- putAnchor(idFrame->body->nameList,
- id,
- NULL,
- (Anchor **)NULL,
- NULL, currentLn(buf), pos);
+ putAnchor(idFrame->body->nameList, id, NULL,
+ (Anchor **)NULL, NULL, NULL, '\0',
+ currentLn(buf), pos);
if (p) {
effect |= PE_ANCHOR;
- a_href = registerHref(buf, remove_space(p), q,
- r, currentLn(buf), pos);
+ a_href = registerHref(buf, remove_space(p), q, r, s,
+ *t, currentLn(buf), pos);
a_href->hseq = ((hseq > 0) ? hseq : -hseq) - 1;
+ a_href->slave = (hseq > 0) ? FALSE : TRUE;
}
break;
case HTML_N_A:
@@ -5024,9 +5051,11 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
iseq - 1);
}
#endif
+ s = NULL;
+ parsedtag_get_value(tag, ATTR_TITLE, &s);
p = remove_space(p);
p = url_quote_conv(p, buf->document_code);
- a_img = registerImg(buf, p, currentLn(buf), pos);
+ a_img = registerImg(buf, p, s, currentLn(buf), pos);
#ifdef USE_IMAGE
a_img->hseq = iseq;
a_img->image = NULL;
@@ -5330,10 +5359,9 @@ HTMLlineproc2body(Buffer *buf, Str (*feed) (), int llimit)
}
if (id && idFrame)
idFrame->body->nameList =
- putAnchor(idFrame->body->nameList,
- id,
- NULL,
- (Anchor **)NULL, NULL, currentLn(buf), pos);
+ putAnchor(idFrame->body->nameList, id, NULL,
+ (Anchor **)NULL, NULL, NULL, '\0',
+ currentLn(buf), pos);
#endif /* ID_EXT */
}
}
@@ -6069,9 +6097,7 @@ init_henv(struct html_feed_environ *h_env, struct readbuffer *obuf,
obuf->status = R_ST_NORMAL;
obuf->table_level = -1;
obuf->nobr_level = 0;
- obuf->anchor = 0;
- obuf->anchor_target = 0;
- obuf->anchor_hseq = 0;
+ bzero((void *)&obuf->anchor, sizeof(obuf->anchor));
obuf->img_alt = 0;
obuf->in_bold = 0;
obuf->in_under = 0;
diff --git a/fm.h b/fm.h
@@ -358,9 +358,12 @@ typedef struct _anchor {
char *url;
char *target;
char *referer;
+ char *title;
+ unsigned char accesskey;
BufferPoint start;
BufferPoint end;
int hseq;
+ char slave;
short y;
short rows;
#ifdef USE_IMAGE
@@ -513,9 +516,7 @@ typedef struct {
int len;
int tlen;
long flag;
- Str anchor;
- Str anchor_target;
- short anchor_hseq;
+ Anchor anchor;
Str img_alt;
char fontstat[FONTSTAT_SIZE];
short nobr_level;
@@ -537,9 +538,7 @@ struct readbuffer {
unsigned char end_tag;
short table_level;
short nobr_level;
- Str anchor;
- Str anchor_target;
- short anchor_hseq;
+ Anchor anchor;
Str img_alt;
char fontstat[FONTSTAT_SIZE];
char fontstat_stack[FONT_STACK_SIZE][FONTSTAT_SIZE];
diff --git a/funcname.tab b/funcname.tab
@@ -3,6 +3,7 @@
#----------------------------
@@@ nulcmd
ABORT quitfm
+ACCESSKEY accessKey
ADD_BOOKMARK adBmark
ALARM setAlarm
BACK backBf
@@ -48,6 +49,7 @@ LINE_END linend
LINE_INFO curlno
LINK_BEGIN topA
LINK_END lastA
+LINK_MENU linkMn
LOAD ldfile
MAIN_MENU mainMn
MARK _mark
diff --git a/html.c b/html.c
@@ -7,9 +7,9 @@
#define MAXA_CORE 1
unsigned char ALST_A[] = {
ATTR_NAME, ATTR_HREF, ATTR_TARGET, ATTR_HSEQ, ATTR_REFERER,
- ATTR_FRAMENAME, ATTR_CORE
+ ATTR_FRAMENAME, ATTR_TITLE, ATTR_ACCESSKEY, ATTR_CORE
};
-#define MAXA_A MAXA_CORE + 6
+#define MAXA_A MAXA_CORE + 8
unsigned char ALST_P[] = { ATTR_ALIGN, ATTR_CORE };
#define MAXA_P MAXA_CORE + 1
unsigned char ALST_UL[] = { ATTR_START, ATTR_TYPE, ATTR_CORE };
@@ -28,9 +28,9 @@ unsigned char ALST_PRE[] = { ATTR_FOR_TABLE, ATTR_CORE };
#define MAXA_PRE MAXA_CORE + 1
unsigned char ALST_IMG[] =
{ ATTR_SRC, ATTR_ALT, ATTR_WIDTH, ATTR_HEIGHT, ATTR_ALIGN, ATTR_USEMAP,
- ATTR_ISMAP, ATTR_CORE
+ ATTR_ISMAP, ATTR_TITLE, ATTR_CORE
};
-#define MAXA_IMG MAXA_CORE + 7
+#define MAXA_IMG MAXA_CORE + 8
unsigned char ALST_TABLE[] =
{ ATTR_BORDER, ATTR_WIDTH, ATTR_HBORDER, ATTR_CELLSPACING,
ATTR_CELLPADDING, ATTR_VSPACE, ATTR_CORE
@@ -112,9 +112,10 @@ unsigned char ALST_INPUT_ALT[] =
#define MAXA_INPUT_ALT 16
unsigned char ALST_IMG_ALT[] =
{ ATTR_SRC, ATTR_WIDTH, ATTR_HEIGHT, ATTR_USEMAP, ATTR_ISMAP, ATTR_HSEQ,
- ATTR_XOFFSET, ATTR_YOFFSET, ATTR_TOP_MARGIN, ATTR_BOTTOM_MARGIN
+ ATTR_XOFFSET, ATTR_YOFFSET, ATTR_TOP_MARGIN, ATTR_BOTTOM_MARGIN,
+ ATTR_TITLE
};
-#define MAXA_IMG_ALT 10
+#define MAXA_IMG_ALT 11
unsigned char ALST_NOP[] = { ATTR_CORE };
#define MAXA_NOP MAXA_CORE
@@ -304,20 +305,30 @@ TagAttrInfo AttrMAP[MAX_TAGATTR] = {
{"rel", VTYPE_STR, 0}, /* 47 ATTR_REL */
{"rev", VTYPE_STR, 0}, /* 48 ATTR_REV */
{"title", VTYPE_STR, 0}, /* 49 ATTR_TITLE */
+ {"accesskey", VTYPE_STR, 0}, /* 50 ATTR_ACCESSKEY */
+ {NULL, VTYPE_NONE, 0}, /* 51 Undefined */
+ {NULL, VTYPE_NONE, 0}, /* 52 Undefined */
+ {NULL, VTYPE_NONE, 0}, /* 53 Undefined */
+ {NULL, VTYPE_NONE, 0}, /* 54 Undefined */
+ {NULL, VTYPE_NONE, 0}, /* 55 Undefined */
+ {NULL, VTYPE_NONE, 0}, /* 56 Undefined */
+ {NULL, VTYPE_NONE, 0}, /* 57 Undefined */
+ {NULL, VTYPE_NONE, 0}, /* 58 Undefined */
+ {NULL, VTYPE_NONE, 0}, /* 59 Undefined */
/* Internal attribute */
- {"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 */
+ {"xoffset", VTYPE_NUMBER, AFLG_INT}, /* 60 ATTR_XOFFSET */
+ {"yoffset", VTYPE_NUMBER, AFLG_INT}, /* 61 ATTR_YOFFSET */
+ {"top_margin", VTYPE_NUMBER, AFLG_INT}, /* 62 ATTR_TOP_MARGIN, */
+ {"bottom_margin", VTYPE_NUMBER, AFLG_INT}, /* 63 ATTR_BOTTOM_MARGIN, */
+ {"tid", VTYPE_NUMBER, AFLG_INT}, /* 64 ATTR_TID */
+ {"fid", VTYPE_NUMBER, AFLG_INT}, /* 65 ATTR_FID */
+ {"for_table", VTYPE_NONE, AFLG_INT}, /* 66 ATTR_FOR_TABLE */
+ {"framename", VTYPE_STR, AFLG_INT}, /* 67 ATTR_FRAMENAME */
+ {"hborder", VTYPE_NONE, 0}, /* 68 ATTR_HBORDER */
+ {"hseq", VTYPE_NUMBER, AFLG_INT}, /* 69 ATTR_HSEQ */
+ {"no_effect", VTYPE_NONE, AFLG_INT}, /* 70 ATTR_NO_EFFECT */
+ {"referer", VTYPE_STR, AFLG_INT}, /* 71 ATTR_REFERER */
+ {"selectnumber", VTYPE_NUMBER, AFLG_INT}, /* 72 ATTR_SELECTNUMBER */
+ {"textareanumber", VTYPE_NUMBER, AFLG_INT}, /* 73 ATTR_TEXTAREANUMBER */
};
diff --git a/html.h b/html.h
@@ -271,24 +271,25 @@ typedef struct {
#define ATTR_REL 47
#define ATTR_REV 48
#define ATTR_TITLE 49
+#define ATTR_ACCESSKEY 50
/* Internal attribute */
-#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
+#define ATTR_XOFFSET 60
+#define ATTR_YOFFSET 61
+#define ATTR_TOP_MARGIN 62
+#define ATTR_BOTTOM_MARGIN 63
+#define ATTR_TID 64
+#define ATTR_FID 65
+#define ATTR_FOR_TABLE 66
+#define ATTR_FRAMENAME 67
+#define ATTR_HBORDER 68
+#define ATTR_HSEQ 69
+#define ATTR_NO_EFFECT 70
+#define ATTR_REFERER 71
+#define ATTR_SELECTNUMBER 72
+#define ATTR_TEXTAREANUMBER 73
+
+#define MAX_TAGATTR 74
/* HTML Tag Information Table */
diff --git a/main.c b/main.c
@@ -4153,6 +4153,47 @@ follow_map(struct parsed_tagarg *arg)
#endif
}
+#ifdef USE_MENU
+/* link menu */
+void
+linkMn(void)
+{
+ LinkList *l = link_menu(Currentbuf);
+ ParsedURL p_url;
+
+ if (!l || !l->url)
+ return;
+ if (*(l->url) == '#') {
+ gotoLabel(l->url + 1);
+ return;
+ }
+ parseURL2(l->url, &p_url, baseURL(Currentbuf));
+ pushHashHist(URLHist, parsedURL2Str(&p_url)->ptr);
+ cmd_loadURL(l->url, baseURL(Currentbuf),
+ parsedURL2Str(&Currentbuf->currentURL)->ptr);
+}
+
+/* accesskey */
+void
+accessKey(void)
+{
+ Anchor *a;
+ BufferPoint *po;
+
+ if (!Currentbuf->href || !Currentbuf->hmarklist)
+ return;
+ a = accesskey_menu(Currentbuf);
+ if (!a || a->hseq < 0)
+ return;
+ po = &Currentbuf->hmarklist->marks[a->hseq];
+ gotoLine(Currentbuf, po->line);
+ Currentbuf->pos = po->pos;
+ arrangeCursor(Currentbuf);
+ onA();
+ followA();
+}
+#endif
+
#ifdef USE_COOKIE
/* cookie list */
void
diff --git a/menu.c b/menu.c
@@ -288,11 +288,6 @@ 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;
@@ -1318,7 +1313,6 @@ popupMenu(int x, int y, Menu *menu)
{
initSelectMenu();
initSelTabMenu();
- initLinkMenu();
menu->cursorX = Currentbuf->cursorX + Currentbuf->rootX;
menu->cursorY = Currentbuf->cursorY + Currentbuf->rootY;
@@ -1648,68 +1642,6 @@ 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;
-
- 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
@@ -1742,7 +1674,7 @@ initMenu(void)
MenuItem *item = NULL;
MenuList *list;
- w3mMenuList = New_N(MenuList, 4);
+ w3mMenuList = New_N(MenuList, 3);
w3mMenuList[0].id = "Main";
w3mMenuList[0].menu = &MainMenu;
w3mMenuList[0].item = MainMenuItem;
@@ -1752,10 +1684,7 @@ initMenu(void)
w3mMenuList[2].id = "SelectTab";
w3mMenuList[2].menu = &SelTabMenu;
w3mMenuList[2].item = NULL;
- w3mMenuList[3].id = "Link";
- w3mMenuList[3].menu = &LinkMenu;
- w3mMenuList[3].item = NULL;
- w3mMenuList[4].id = NULL;
+ w3mMenuList[3].id = NULL;
if ((mf = fopen(rcFile(MENU_FILE), "rt")) == NULL)
goto create_menu;
@@ -1890,4 +1819,132 @@ getMenuN(MenuList *list, char *id)
/* --- InitMenu (END) --- */
+LinkList *
+link_menu(Buffer *buf)
+{
+ Menu menu;
+ LinkList *l;
+ int i, nitem, len = 0, linkV = -1;
+ char **label;
+ Str str;
+
+ if (!buf->linklist)
+ return NULL;
+
+ for (i = 0, l = buf->linklist; l; i++, l = l->next) ;
+ nitem = i;
+
+ label = New_N(char *, nitem + 1);
+ for (i = 0, l = buf->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] = NULL;
+
+ new_option_menu(&menu, label, &linkV, NULL);
+
+ menu.initial = 0;
+ menu.cursorX = buf->cursorX + buf->rootX;
+ menu.cursorY = buf->cursorY + buf->rootY;
+ menu.x = menu.cursorX + FRAME_WIDTH + 1;
+ menu.y = menu.cursorY + 2;
+
+ popup_menu(NULL, &menu);
+
+ if (linkV < 0)
+ return NULL;
+ for (i = 0, l = buf->linklist; l; i++, l = l->next) {
+ if (i == linkV)
+ return l;
+ }
+ return NULL;
+}
+
+/* --- LinkMenu (END) --- */
+
+Anchor *
+accesskey_menu(Buffer *buf)
+{
+ Menu menu;
+ AnchorList *al = buf->href;
+ Anchor *a;
+ Anchor **ap;
+ int i, n, nitem = 0, key = -1;
+ char **label;
+ char *t;
+ unsigned char c;
+
+ if (!al)
+ return NULL;
+ for (i = 0; i < al->nanchor; i++) {
+ a = &al->anchors[i];
+ if (!a->slave && a->accesskey && IS_ASCII(a->accesskey))
+ nitem++;
+ }
+ if (!nitem)
+ return NULL;
+
+ label = New_N(char *, nitem + 1);
+ ap = New_N(Anchor *, nitem);
+ for (i = 0, n = 0; i < al->nanchor; i++) {
+ a = &al->anchors[i];
+ if (!a->slave && a->accesskey && IS_ASCII(a->accesskey)) {
+ t = getAnchorText(buf, a);
+ label[n] = Sprintf("%c: %s", a->accesskey, t ? t : "")->ptr;
+ ap[n] = a;
+ n++;
+ }
+ }
+ label[nitem] = NULL;
+
+ new_option_menu(&menu, label, &key, NULL);
+
+ menu.initial = 0;
+ menu.cursorX = buf->cursorX + buf->rootX;
+ menu.cursorY = buf->cursorY + buf->rootY;
+ menu.x = menu.cursorX + FRAME_WIDTH + 1;
+ menu.y = menu.cursorY + 2;
+ for (i = 0; i < 128; i++)
+ menu.keyselect[i] = -1;
+ for (i = 0; i < nitem; i++) {
+ c = ap[i]->accesskey;
+ menu.keymap[(int)c] = mSelect;
+ menu.keyselect[(int)c] = i;
+ }
+ for (i = 0; i < nitem; i++) {
+ c = ap[i]->accesskey;
+ if (!IS_ALPHA(c) || menu.keyselect[n] >= 0)
+ continue;
+ c = tolower(c);
+ menu.keymap[(int)c] = mSelect;
+ menu.keyselect[(int)c] = i;
+ c = toupper(c);
+ menu.keymap[(int)c] = mSelect;
+ menu.keyselect[(int)c] = i;
+ }
+
+ a = retrieveCurrentAnchor(buf);
+ if (a && a->accesskey && IS_ASCII(a->accesskey)) {
+ for (i = 0; i < nitem; i++) {
+ if (a == ap[i]) {
+ menu.initial = i;
+ break;
+ }
+ }
+ }
+
+ popup_menu(NULL, &menu);
+
+ return (key >= 0) ? ap[key] : NULL;
+}
+
#endif /* USE_MENU */
diff --git a/proto.h b/proto.h
@@ -131,6 +131,15 @@ extern void tabrURL(void);
extern void tabR(void);
extern void tabL(void);
extern void ldDL(void);
+#ifdef USE_MENU
+extern void linkMn(void);
+extern LinkList *link_menu(Buffer *buf);
+extern void accessKey(void);
+extern Anchor *accesskey_menu(Buffer *buf);
+#else
+#define linkMn nulcmd
+#define accessKey nulcmd
+#endif
extern int currentLn(Buffer *buf);
extern void tmpClearBuffer(Buffer *buf);
@@ -500,12 +509,15 @@ extern Str readFTPDir(ParsedURL *pu);
extern void closeFTP(FILE * f);
extern int Ftpfclose(FILE * f);
extern AnchorList *putAnchor(AnchorList *al, char *url, char *target,
- Anchor **anchor_return, char *referer, int line,
+ Anchor **anchor_return, char *referer,
+ char *title, unsigned char key, int line,
int pos);
extern Anchor *registerHref(Buffer *buf, char *url, char *target,
- char *referer, int line, int pos);
+ char *referer, char *title, unsigned char key,
+ int line, int pos);
extern Anchor *registerName(Buffer *buf, char *url, int line, int pos);
-extern Anchor *registerImg(Buffer *buf, char *url, int line, int pos);
+extern Anchor *registerImg(Buffer *buf, char *url, char *title, int line,
+ int pos);
extern Anchor *registerForm(Buffer *buf, FormList *flist,
struct parsed_tag *tag, int line, int pos);
extern int onAnchor(Anchor *a, int line, int pos);
@@ -527,6 +539,7 @@ extern Anchor *closest_prev_anchor(AnchorList *a, Anchor *an, int x, int y);
void addMultirowsImg(Buffer *buf, AnchorList *al);
#endif
extern HmarkerList *putHmarker(HmarkerList *ml, int line, int pos, int seq);
+extern char *getAnchorText(Buffer *buf, Anchor *a);
extern Str decodeB(char **ww);
extern Str decodeQ(char **ww);
extern Str decodeQP(char **ww);
diff --git a/scripts/w3mhelp.cgi.in b/scripts/w3mhelp.cgi.in
@@ -140,7 +140,7 @@ for $otherlang (@docdirs) {
&show_keymap("Hyperlink operation",
split(" ", "followA tabA svA followI svI submitForm
curURL peekURL peekIMG pginfo curlno chkURL chkWORD chkNMID
- rFrame extbrz linkbrz"));
+ rFrame extbrz linkbrz linkMn accessKey"));
&show_keymap("File/Stream operation",
split(" ", "goURL gorURL tabURL tabrURL ldfile readsh pipesh