[elinks-users] caret browsing

Witold Filipczyk witekfl at poczta.gazeta.pl
Thu Nov 20 22:22:16 PST 2003


On Thu, Oct 23, 2003 at 01:04:33PM +0200, Johannes Zellner wrote:
> Hi,
> 
> does elinks support something which is called "caret browsing" in
> Mozilla? -- If this is on, the cursor motion is not limited to jump
> between links but can be moved anywhere on the text. Example:
> 
> [link 1] [link 2] [link 3] [link 4] [link 5] [link 6] [link 7] [link 8]
> [link 9]
> 
> suppose the cursor on [link 1] initially. If I'd like to choose [link 9],
> I'd have to press the <down> key repeatedly to navigate over all the
> other links. If elinks would have something like "caret browsing",
> [link 9] could be reached starting from [link 1] by just pressing a
> single key stroke for moving the cursor down.

Try this patch. Patch is made against current CVS.
You must bind keybindings for route-*. I think that this is what you wanted.


-- 
Witold Filipczyk tohu-bohu
<witekfl at poczta.gazeta.pl>
-------------- next part --------------
--- elinks/src/config/kbdbind.h	2003-11-19 00:10:45.000000000 +0100
+++ elinks.2/src/config/kbdbind.h	2003-11-20 17:10:47.000000000 +0100
@@ -79,6 +79,11 @@
 	ACT_RELOAD,
 	ACT_RESUME_DOWNLOAD,
 	ACT_RIGHT,
+	ACT_ROUTE_ACTIVATE_LINK,
+	ACT_ROUTE_DOWN,
+	ACT_ROUTE_LEFT,
+	ACT_ROUTE_RIGHT,
+	ACT_ROUTE_UP,
 	ACT_SAVE_FORMATTED,
 	ACT_SCRIPTING_FUNCTION,
 	ACT_SCROLL_DOWN,
--- elinks/src/config/kbdbind.c	2003-11-20 05:13:54.000000000 +0100
+++ elinks.2/src/config/kbdbind.c	2003-11-20 17:12:26.000000000 +0100
@@ -441,6 +441,11 @@
 	{ "reload", ACT_RELOAD, DACT(N_("Reload the current page")) },
 	{ "resume-download", ACT_RESUME_DOWNLOAD, DACT(N_("Attempt to resume download of the current link")) },
 	{ "right", ACT_RIGHT, DACT(N_("Move the cursor right")) },
+	{ "route-activate-link", ACT_ROUTE_ACTIVATE_LINK, DACT(N_("Activate link in routing mode")) },
+	{ "route-down", ACT_ROUTE_DOWN, DACT(N_("Move routing cursor down")) },
+	{ "route-left", ACT_ROUTE_LEFT, DACT(N_("Move routing cursor left")) },
+	{ "route-right", ACT_ROUTE_RIGHT, DACT(N_("Move routing cursor right")) },
+	{ "route-up", ACT_ROUTE_UP, DACT(N_("Move routing cursor up")) }, 
 	{ "save-formatted", ACT_SAVE_FORMATTED, DACT(N_("Save formatted document")) },
 	{ "scroll-down", ACT_SCROLL_DOWN, DACT(N_("Scroll down")) },
 	{ "scroll-left", ACT_SCROLL_LEFT, DACT(N_("Scroll left")) },
--- elinks/src/viewer/text/view.c	2003-11-20 16:08:35.000000000 +0100
+++ elinks.2/src/viewer/text/view.c	2003-11-20 18:12:07.000000000 +0100
@@ -43,6 +43,7 @@
 #include "sched/session.h"
 #include "terminal/draw.h"
 #include "terminal/kbd.h"
+#include "terminal/screen.h"
 #include "terminal/tab.h"
 #include "terminal/terminal.h"
 #include "terminal/window.h"
@@ -192,7 +193,9 @@
 	if (width < 2 || height < 2) return;
 
 	if (active) {
+#if 0
 		set_cursor(t, xp + width - 1, yp + height - 1, 1);
+#endif
 		set_window_ptr(get_current_tab(t), xp, yp);
 	}
 
@@ -607,6 +610,7 @@
 frame_ev(struct session *ses, struct document_view *doc_view, struct term_event *ev)
 {
 	int x = 1;
+	struct terminal *term = ses->tab->term;
 
 	assert(ses && doc_view && doc_view->document && doc_view->vs && ev);
 	if_assert_failed return 1;
@@ -695,6 +699,15 @@
 			case ACT_SCROLL_LEFT: rep_ev(ses, doc_view, hscroll, -1 - 7 * !ses->kbdprefix.rep); break;
 			case ACT_SCROLL_RIGHT: rep_ev(ses, doc_view, hscroll, 1 + 7 * !ses->kbdprefix.rep); break;
 
+			case ACT_ROUTE_UP:
+				if (term->screen->cy > 0) set_cursor(term, term->screen->cx, term->screen->cy - 1, 0); x = 2; break;
+			case ACT_ROUTE_DOWN:
+				if (term->screen->cy + 1 < term->height) set_cursor(term, term->screen->cx, term->screen->cy + 1, 0); x = 2; break;
+			case ACT_ROUTE_LEFT:
+				if (term->screen->cx > 0) set_cursor(term, term->screen->cx - 1, term->screen->cy, 0); x = 2; break;
+			case ACT_ROUTE_RIGHT:
+				if (term->screen->cx + 1 < term->width) set_cursor(term, term->screen->cx + 1, term->screen->cy, 0); x = 2; break;
+			case ACT_ROUTE_ACTIVATE_LINK: ev->x = term->screen->cx; ev->y = term->screen->cy - 1; ev->b = B_UP; goto choose_link; break;
 			case ACT_HOME: rep_ev(ses, doc_view, home, 0); break;
 			case ACT_END:  rep_ev(ses, doc_view, x_end, 0); break;
 			case ACT_ENTER: x = enter(ses, doc_view, 0); break;
@@ -740,7 +753,10 @@
 		}
 #ifdef USE_MOUSE
 	} else if (ev->ev == EV_MOUSE) {
-		struct link *link = choose_mouse_link(doc_view, ev);
+		struct link *link;
+
+choose_link:		
+		link = choose_mouse_link(doc_view, ev);
 
 		if ((ev->b & BM_BUTT) >= B_WHEEL_UP) {
 			if ((ev->b & BM_ACT) != B_DOWN) {
@@ -777,7 +793,6 @@
 
 			/* XXX: This is code duplication with kbd handlers. But
 			 * repeatcount-free here. */
-
 			if (ev->y < scrollmargin) {
 				rep_ev(ses, doc_view, scroll, -2);
 			}
--- elinks/src/viewer/text/link.c	2003-11-18 00:07:56.000000000 +0100
+++ elinks.2/src/viewer/text/link.c	2003-11-20 18:14:46.000000000 +0100
@@ -239,8 +239,9 @@
 		if (i == cursor_offset) {
 			int blockable = (!link_is_textinput(link)
 					 && co->color != template->color);
-
+#if 0
 			set_cursor(t, x, y, blockable);
+#endif
 			set_window_ptr(get_current_tab(t), x, y);
 		}
 


More information about the elinks-users mailing list