diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-12-09 15:51:08 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-12-09 15:51:08 +0000 |
commit | 945ebeab6f857d345e8e6a5490a6ec3a71c8c6e3 (patch) | |
tree | 6364af577cdd0bce0caf7d72cd55f1a5a84a0c96 /menu.c | |
parent | [w3m-dev 03548] close anchor before <img align=...> (diff) | |
download | w3m-945ebeab6f857d345e8e6a5490a6ec3a71c8c6e3.tar.gz w3m-945ebeab6f857d345e8e6a5490a6ec3a71c8c6e3.zip |
[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>
Diffstat (limited to '')
-rw-r--r-- | menu.c | 118 |
1 files changed, 116 insertions, 2 deletions
@@ -1,4 +1,4 @@ -/* $Id: menu.c,v 1.26 2002/12/05 16:33:09 ukai Exp $ */ +/* $Id: menu.c,v 1.27 2002/12/09 15:51:09 ukai Exp $ */ /* * w3m menu.c */ @@ -1898,7 +1898,7 @@ accesskey_menu(Buffer *buf) 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); + t = getAnchorText(buf, al, a); label[n] = Sprintf("%c: %s", a->accesskey, t ? t : "")->ptr; ap[n] = a; n++; @@ -1947,4 +1947,118 @@ accesskey_menu(Buffer *buf) return (key >= 0) ? ap[key] : NULL; } +static char lmKeys[] = "abcdefgimopqrstuvwxyz"; +static char lmKeys2[] = "1234567890ABCDEFGHILMOPQRSTUVWXYZ"; +#define nlmKeys (sizeof(lmKeys) - 1) +#define nlmKeys2 (sizeof(lmKeys2) - 1) + +static int +lmGoto(char c) +{ + if (IS_ASCII(c) && CurrentMenu->keyselect[(int)c] >= 0) { + goto_menu(CurrentMenu, CurrentMenu->nitem - 1, -1); + goto_menu(CurrentMenu, CurrentMenu->keyselect[(int)c] * nlmKeys, 1); + } + return (MENU_NOTHING); +} + +static int +lmSelect(char c) +{ + if (IS_ASCII(c)) + return select_menu(CurrentMenu, (CurrentMenu->select / nlmKeys) * + nlmKeys + CurrentMenu->keyselect[(int)c]); + else + return (MENU_NOTHING); +} + +Anchor * +list_menu(Buffer *buf) +{ + Menu menu; + AnchorList *al = buf->href; + Anchor *a; + Anchor **ap; + int i, n, nitem = 0, key = -1, two = FALSE; + 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) + nitem++; + } + if (!nitem) + return NULL; + + if (nitem >= nlmKeys) + two = TRUE; + 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) { + t = getAnchorText(buf, al, a); + if (!t) + t = ""; + if (two && n >= nlmKeys2 * nlmKeys) + label[n] = Sprintf(" : %s", t)->ptr; + else if (two) + label[n] = Sprintf("%c%c: %s", lmKeys2[n / nlmKeys], + lmKeys[n % nlmKeys], t)->ptr; + else + label[n] = Sprintf("%c: %s", lmKeys[n], 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; + if (two) { + for (i = 0; i < nlmKeys2; i++) { + c = lmKeys2[i]; + menu.keymap[(int)c] = lmGoto; + menu.keyselect[(int)c] = i; + } + for (i = 0; i < nlmKeys; i++) { + c = lmKeys[i]; + menu.keymap[(int)c] = lmSelect; + menu.keyselect[(int)c] = i; + } + } + else { + for (i = 0; i < nitem; i++) { + c = lmKeys[i]; + menu.keymap[(int)c] = mSelect; + menu.keyselect[(int)c] = i; + } + } + + a = retrieveCurrentAnchor(buf); + if (a) { + 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 */ |