diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-12-05 16:29:02 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-12-05 16:29:02 +0000 |
commit | d02a0802cd226cbbf73470dc76a1384f19f10199 (patch) | |
tree | 8d057025083179d6685b8480be7d7ba9ba1395eb /menu.c | |
parent | [w3m-dev 03528] area without alt (diff) | |
download | w3m-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-- | menu.c | 205 |
1 files changed, 131 insertions, 74 deletions
@@ -1,4 +1,4 @@ -/* $Id: menu.c,v 1.24 2002/12/02 17:39:16 ukai Exp $ */ +/* $Id: menu.c,v 1.25 2002/12/05 16:29:10 ukai Exp $ */ /* * w3m 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 */ |