[w3m-dev 03939] next/prev visited link

[email protected] (Yoshinobu Sakane)
Newsgroups gmane.comp.web.w3m.devel
Message-ID <[email protected]>

(NEXT_VISITED/PREV_VISITED)

w3m/0.4.1+cvs-1.852 

 Web 



~/.w3m/keymap 
    
    keymap ESC-i NEXT_VISITED
    keymap ESC-u PREV_VISITED



-- ""
         Yoshinobu Sakane                       
     


--- ./funcname.tab.orig	Thu Jul 17 15:20:39 2003
+++ ./funcname.tab	Thu Jul 17 15:21:31 2003
@@ -147,3 +147,5 @@
 VIEW_IMAGE	followI
 WHEREIS		srchfor
 WRAP_TOGGLE	wrapToggle
+NEXT_VISITED    nextVA
+PREV_VISITED    prevVA
--- ./main.c.orig	Thu Jul 17 15:21:38 2003
+++ ./main.c	Thu Jul 17 16:37:41 2003
@@ -94,6 +94,8 @@
 static void _newT(void);
 static void followTab(TabBuffer * tab);
 static void moveTab(TabBuffer * t, TabBuffer * t2, int right);
+static void _nextA(int);
+static void _prevA(int);
 static int check_target = TRUE;
 #define PREC_NUM (prec_num ? prec_num : 1)
 #define PREC_LIMIT 10000
@@ -3451,10 +3453,39 @@
 void
 nextA(void)
 {
+    _nextA(FALSE);
+}
+
+/* go to the previous anchor */
+void
+prevA(void)
+{
+    _prevA(FALSE);
+}
+
+/* go to the next visited anchor */
+void
+nextVA(void)
+{
+    _nextA(TRUE);
+}
+
+/* go to the previous visited anchor */
+void
+prevVA(void)
+{
+    _prevA(TRUE);
+}
+
+/* go to the next [visited] anchor */
+static void
+_nextA(int visited)
+{
     HmarkerList *hl = Currentbuf->hmarklist;
     BufferPoint *po;
     Anchor *an, *pan;
     int i, x, y, n = searchKeyNum();
+    ParsedURL url;
 
     if (Currentbuf->firstLine == NULL)
 	return;
@@ -3462,40 +3493,63 @@
 	return;
 
     an = retrieveCurrentAnchor(Currentbuf);
-    if (an == NULL)
+    if (visited != TRUE && an == NULL)
 	an = retrieveCurrentForm(Currentbuf);
 
     y = Currentbuf->currentLine->linenumber;
     x = Currentbuf->pos;
 
+    if (visited == TRUE) {
+        n = hl->nmark;
+    }
+
     for (i = 0; i < n; i++) {
 	pan = an;
 	if (an && an->hseq >= 0) {
 	    int hseq = an->hseq + 1;
 	    do {
 		if (hseq >= hl->nmark) {
+                    if (visited == TRUE)
+                        return;
 		    an = pan;
 		    goto _end;
 		}
 		po = &hl->marks[hseq];
 		an = retrieveAnchor(Currentbuf->href, po->line, po->pos);
-		if (an == NULL)
+		if (visited != TRUE && an == NULL)
 		    an = retrieveAnchor(Currentbuf->formitem, po->line,
 					po->pos);
 		hseq++;
+                if (visited == TRUE && an) {
+                    parseURL2(an->url, &url, baseURL(Currentbuf));
+                    if (getHashHist(URLHist, parsedURL2Str(&url)->ptr)) {
+                        goto _end;
+                    }
+                }
 	    } while (an == NULL || an == pan);
 	}
 	else {
 	    an = closest_next_anchor(Currentbuf->href, NULL, x, y);
+            if (visited != TRUE) 
 	    an = closest_next_anchor(Currentbuf->formitem, an, x, y);
 	    if (an == NULL) {
+                if (visited == TRUE)
+                    return;
 		an = pan;
 		break;
 	    }
 	    x = an->start.pos;
 	    y = an->start.line;
+            if (visited == TRUE) {
+                parseURL2(an->url, &url, baseURL(Currentbuf));
+                if (getHashHist(URLHist, parsedURL2Str(&url)->ptr)) {
+                    goto _end;
+                }
+            }
 	}
     }
+    if (visited == TRUE)
+        return;
 
   _end:
     if (an == NULL || an->hseq < 0)
@@ -3508,13 +3562,14 @@
 }
 
 /* go to the previous anchor */
-void
-prevA(void)
+static void
+_prevA(int visited)
 {
     HmarkerList *hl = Currentbuf->hmarklist;
     BufferPoint *po;
     Anchor *an, *pan;
     int i, x, y, n = searchKeyNum();
+    ParsedURL url;
 
     if (Currentbuf->firstLine == NULL)
 	return;
@@ -3522,40 +3577,63 @@
 	return;
 
     an = retrieveCurrentAnchor(Currentbuf);
-    if (an == NULL)
+    if (visited != TRUE && an == NULL)
 	an = retrieveCurrentForm(Currentbuf);
 
     y = Currentbuf->currentLine->linenumber;
     x = Currentbuf->pos;
 
+    if (visited == TRUE) {
+        n = hl->nmark;
+    }
+
     for (i = 0; i < n; i++) {
 	pan = an;
 	if (an && an->hseq >= 0) {
 	    int hseq = an->hseq - 1;
 	    do {
 		if (hseq < 0) {
+                    if (visited == TRUE)
+                        return;
 		    an = pan;
 		    goto _end;
 		}
 		po = hl->marks + hseq;
 		an = retrieveAnchor(Currentbuf->href, po->line, po->pos);
-		if (an == NULL)
+		if (visited != TRUE && an == NULL)
 		    an = retrieveAnchor(Currentbuf->formitem, po->line,
 					po->pos);
 		hseq--;
+                if (visited == TRUE && an) {
+                    parseURL2(an->url, &url, baseURL(Currentbuf));
+                    if (getHashHist(URLHist, parsedURL2Str(&url)->ptr)) {
+                        goto _end;
+                    }
+                }
 	    } while (an == NULL || an == pan);
 	}
 	else {
 	    an = closest_prev_anchor(Currentbuf->href, NULL, x, y);
+            if (visited != TRUE)
 	    an = closest_prev_anchor(Currentbuf->formitem, an, x, y);
 	    if (an == NULL) {
+                if (visited == TRUE)
+                    return;
 		an = pan;
 		break;
 	    }
 	    x = an->start.pos;
 	    y = an->start.line;
+            if (visited == TRUE && an) {
+                parseURL2(an->url, &url, baseURL(Currentbuf));
+                if (getHashHist(URLHist, parsedURL2Str(&url)->ptr)) {
+                    goto _end;
+                }
 	}
     }
+    }
+    if (visited == TRUE)
+        return;
 
   _end:
     if (an == NULL || an->hseq < 0)
--- ./proto.h.orig	Thu Jul 17 15:33:29 2003
+++ ./proto.h	Thu Jul 17 15:33:53 2003
@@ -65,6 +65,8 @@
 
 extern void nextA(void);
 extern void prevA(void);
+extern void nextVA(void);
+extern void prevVA(void);
 extern void nextL(void);
 extern void nextLU(void);
 extern void nextR(void);
--- ./doc-jp/README.func.orig	Thu Jul 17 15:36:21 2003
+++ ./doc-jp/README.func	Thu Jul 17 15:37:40 2003
@@ -79,6 +79,7 @@
 NEXT_RIGHT_DOWN        ()
 NEXT_TAB	
 NEXT_UP                
+NEXT_VISITED    
 NEXT_WORD	
 NOTHING		
 NULL		
@@ -93,6 +94,7 @@
 PREV_MARK	
 PREV_PAGE	
 PREV_TAB	
+PREV_VISITED    
 PREV_WORD	
 PRINT		
 QUIT		w3m
--- ./doc/README.func.orig	Thu Jul 17 15:34:26 2003
+++ ./doc/README.func	Thu Jul 17 15:36:10 2003
@@ -79,6 +79,7 @@
 NEXT_RIGHT_DOWN        Move to next right (or downward) link 
 NEXT_TAB	Move to next tab
 NEXT_UP                Move to next upward link 
+NEXT_VISITED    Move to next visited link
 NEXT_WORD	Move to next word
 NOTHING		Do nothing
 NULL		Do nothing
@@ -93,6 +94,7 @@
 PREV_MARK	Move to previous mark
 PREV_PAGE	Move to previous page
 PREV_TAB	Move to previous tab
+PREV_VISITED    Move to previous visited link
 PREV_WORD	Move to previous word
 PRINT		Save buffer to file
 QUIT		Quit w3m
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.