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 | |
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-- | ChangeLog | 42 | ||||
-rw-r--r-- | anchor.c | 116 | ||||
-rw-r--r-- | doc-jp/README.func | 5 | ||||
-rw-r--r-- | doc/README.func | 3 | ||||
-rw-r--r-- | funcname.tab | 5 | ||||
-rw-r--r-- | main.c | 51 | ||||
-rw-r--r-- | map.c | 4 | ||||
-rw-r--r-- | menu.c | 118 | ||||
-rw-r--r-- | proto.h | 13 | ||||
-rw-r--r-- | scripts/w3mhelp.cgi.in | 6 |
10 files changed, 338 insertions, 25 deletions
@@ -1,5 +1,45 @@ 2002-12-10 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + * [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 + +2002-12-10 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + * [w3m-dev 03548] close anchor before <img align=...> * file.c (process_img): use div_int (process_hr): use div_int @@ -5632,4 +5672,4 @@ a * [w3m-dev 03276] compile error on EWS4800 * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.605 2002/12/09 15:40:34 ukai Exp $ +$Id: ChangeLog,v 1.606 2002/12/09 15:51:08 ukai Exp $ @@ -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); +} diff --git a/doc-jp/README.func b/doc-jp/README.func index a9383ac..e85046d 100644 --- a/doc-jp/README.func +++ b/doc-jp/README.func @@ -44,7 +44,9 @@ LINE_END 行末に移動します LINE_INFO ページ中での現在位置を表示します LINK_BEGIN 最初のリンクに移動します LINK_END 最後のリンクに移動します -LINK_MENU Link メニューを立ち上げます +LINK_MENU Link 要素一覧のメニューを立ち上げます +LIST リンクと画像の一覧を表示します +LIST_MENU リンク先一覧のメニューを立ち上げ、リンク先の文書を読みこみます LOAD ローカルファイルを指定して開きます MAIN_MENU メニューを立ち上げます MARK マークを設定/解除します @@ -58,6 +60,7 @@ MOVE_DOWN カーソルを下に移動します(改ページ時には半ページスクロール) MOVE_DOWN1 カーソルを下に移動します(改ページ時には1行スクロール) MOVE_LEFT カーソルを左に移動します(左端の場合には半画面分シフト) MOVE_LEFT1 カーソルを左に移動します(左端の場合には1文字分シフト) +MOVE_LIST_MENU リンク先一覧のメニューを立ち上げ、カーソルを移動します MOVE_MOUSE カーソルをマウスカーソルの位置に移動します(マウス操作用) MOVE_RIGHT カーソルを右に移動します(右端の場合には半画面分シフト) MOVE_RIGHT1 カーソルを右に移動します(右端の場合には1文字分シフト) diff --git a/doc/README.func b/doc/README.func index d5a17fb..5fa970f 100644 --- a/doc/README.func +++ b/doc/README.func @@ -45,6 +45,8 @@ 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 +LIST Show all links and images +LIST_MENU Popup link list menu and go to selected link LOAD Load local file MAIN_MENU Popup menu MARK Set/unset mark @@ -58,6 +60,7 @@ MOVE_DOWN Move cursor down (a half screen scroll at the end of screen) MOVE_DOWN1 Move cursor down (1 line scroll at the end of screen) MOVE_LEFT Move cursor left (a half screen shift at the left edge) MOVE_LEFT1 Move cursor left (1 columns shift at the left edge) +MOVE_LIST_MENU Popup link list menu and move cursor to selected link MOVE_MOUSE Move cursor to mouse cursor (for mouse action) MOVE_RIGHT Move cursor right (a half screen shift at the right edge) MOVE_RIGHT1 Move cursor right (1 columns shift at the right edge) diff --git a/funcname.tab b/funcname.tab index f0b3139..a33766f 100644 --- a/funcname.tab +++ b/funcname.tab @@ -1,4 +1,4 @@ -# $Id: funcname.tab,v 1.17 2002/12/05 16:29:07 ukai Exp $ +# $Id: funcname.tab,v 1.18 2002/12/09 15:51:08 ukai Exp $ # macro name function name #---------------------------- @@@ nulcmd @@ -50,6 +50,8 @@ LINE_INFO curlno LINK_BEGIN topA LINK_END lastA LINK_MENU linkMn +LIST linkLst +LIST_MENU listMn LOAD ldfile MAIN_MENU mainMn MARK _mark @@ -64,6 +66,7 @@ MOVE_DOWN movD MOVE_DOWN1 movD1 MOVE_LEFT movL MOVE_LEFT1 movL1 +MOVE_LIST_MENU movlistMn MOVE_MOUSE movMs MOVE_RIGHT movR MOVE_RIGHT1 movR1 @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.162 2002/12/09 15:32:18 ukai Exp $ */ +/* $Id: main.c,v 1.163 2002/12/09 15:51:09 ukai Exp $ */ #define MAINPROGRAM #include "fm.h" #include <signal.h> @@ -4177,27 +4177,64 @@ linkMn(void) parsedURL2Str(&Currentbuf->currentURL)->ptr); } -/* accesskey */ -void -accessKey(void) +static void +anchorMn(Anchor * (*menu_func) (Buffer *), int go) { Anchor *a; BufferPoint *po; if (!Currentbuf->href || !Currentbuf->hmarklist) return; - a = accesskey_menu(Currentbuf); + a = menu_func(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(); + displayBuffer(Currentbuf, B_NORMAL); + if (go) { + onA(); + followA(); + } +} + +/* accesskey */ +void +accessKey(void) +{ + anchorMn(accesskey_menu, TRUE); +} + +/* list menu */ +void +listMn(void) +{ + anchorMn(list_menu, TRUE); +} + +void +movlistMn(void) +{ + anchorMn(list_menu, FALSE); } #endif +/* link,anchor,image list */ +void +linkLst(void) +{ + Buffer *buf; + + buf = link_list_panel(Currentbuf); + if (buf != NULL) { +#ifdef JP_CHARSET + buf->document_code = Currentbuf->document_code; +#endif /* JP_CHARSET */ + cmd_loadBuffer(buf, BP_NORMAL, LB_NOLINK); + } +} + #ifdef USE_COOKIE /* cookie list */ void @@ -1,11 +1,11 @@ -/* $Id: map.c,v 1.20 2002/12/05 16:33:08 ukai Exp $ */ +/* $Id: map.c,v 1.21 2002/12/09 15:51:09 ukai Exp $ */ /* * client-side image maps */ #include "fm.h" #include <math.h> -static MapList * +MapList * searchMapList(Buffer *buf, char *name) { MapList *ml; @@ -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 */ @@ -1,4 +1,4 @@ -/* $Id: proto.h,v 1.66 2002/12/05 16:29:10 ukai Exp $ */ +/* $Id: proto.h,v 1.67 2002/12/09 15:51:09 ukai Exp $ */ /* * This file was automatically generated by version 1.7 of cextract. * Manual editing not recommended. @@ -131,14 +131,20 @@ extern void tabrURL(void); extern void tabR(void); extern void tabL(void); extern void ldDL(void); +extern void linkLst(void); #ifdef USE_MENU extern void linkMn(void); extern LinkList *link_menu(Buffer *buf); extern void accessKey(void); extern Anchor *accesskey_menu(Buffer *buf); +extern void listMn(void); +extern void movlistMn(void); +extern Anchor *list_menu(Buffer *buf); #else #define linkMn nulcmd #define accessKey nulcmd +#define listMn nulcmd +#define movlistMn nulcmd #endif extern int currentLn(Buffer *buf); @@ -373,6 +379,7 @@ extern void do_internal(char *action, char *data); extern void form_write_data(FILE * f, char *boundary, char *name, char *value); extern void form_write_from_file(FILE * f, char *boundary, char *name, char *filename, char *file); +extern MapList *searchMapList(Buffer *buf, char *name); extern void follow_map(struct parsed_tagarg *arg); extern MapArea *follow_map_menu(Buffer *buf, char *name, Anchor *a_img, int x, int y); @@ -539,7 +546,9 @@ 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 char *getAnchorText(Buffer *buf, AnchorList *al, Anchor *a); +extern Buffer *link_list_panel(Buffer *buf); + 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 index a646d1a..6b6a206 100644 --- a/scripts/w3mhelp.cgi.in +++ b/scripts/w3mhelp.cgi.in @@ -1,5 +1,5 @@ #!@PERL@ -# $Id: w3mhelp.cgi.in,v 1.20 2002/12/05 16:29:17 ukai Exp $ +# $Id: w3mhelp.cgi.in,v 1.21 2002/12/09 15:51:10 ukai Exp $ if ( $^O =~ /^(ms)?(dos|win(32|nt)?)/i ) { $CYGPATH = 1; @@ -134,13 +134,13 @@ for $otherlang (@docdirs) { movR1 movL1 movD1 movU1 ldown1 lup1 shiftl shiftr col1L col1R linbeg linend ctrCsrH ctrCsrV goLine goLineF goLineL movRW movLW - topA lastA nextA prevA + topA lastA nextA prevA movlistMn nextR nextL nextD nextU nextRD nextLU")); &show_keymap("Hyperlink operation", split(" ", "followA tabA svA followI svI submitForm curURL peekURL peekIMG pginfo curlno chkURL chkWORD chkNMID - rFrame extbrz linkbrz linkMn accessKey")); + rFrame extbrz linkbrz linkLst listMn linkMn accessKey")); &show_keymap("File/Stream operation", split(" ", "goURL gorURL tabURL tabrURL ldfile readsh pipesh |